Graphing window now retains your current view when graphs are added and subtracted unless you get down to no graphs.

This makes it easier to load lots of graphs and do work without having the graph constantly resize.
This commit is contained in:
Collin Kidder
2015-06-04 21:08:25 -04:00
parent a658e335d5
commit 8caafce022
2 changed files with 15 additions and 3 deletions
+14 -3
View File
@@ -58,6 +58,8 @@ GraphingWindow::GraphingWindow(QVector<CANFrame> *frames, QWidget *parent) :
selectedPen.setWidth(1);
selectedPen.setColor(Qt::blue);
needScaleSetup = true;
}
GraphingWindow::~GraphingWindow()
@@ -82,6 +84,7 @@ void GraphingWindow::updatedFrames(int numFrames)
//there shouldn't be any need to actually remove the graphs.
//regenerate them instead
ui->graphingView->clearGraphs(); //temporarily remove the graphs from the graph view
needScaleSetup = true;
for (int i = 0; i < graphParams.count(); i++)
{
createGraph(graphParams[i], false); //regenerate each one
@@ -225,6 +228,9 @@ void GraphingWindow::removeSelectedGraph()
graphParams.removeAt(idx);
ui->graphingView->removeGraph(ui->graphingView->selectedGraphs().first());
if (graphParams.count() == 0) needScaleSetup = true;
ui->graphingView->replot();
}
}
@@ -255,6 +261,7 @@ void GraphingWindow::removeAllGraphs()
{
ui->graphingView->clearGraphs();
graphParams.clear();
needScaleSetup = true;
ui->graphingView->replot();
}
@@ -425,9 +432,13 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
graphPen.setWidth(1);
ui->graphingView->graph()->setPen(graphPen);
ui->graphingView->xAxis->setRange(xminval, xmaxval);
ui->graphingView->yAxis->setRange(yminval, ymaxval);
ui->graphingView->axisRect()->setupFullAxesBox();
if (needScaleSetup)
{
needScaleSetup = false;
ui->graphingView->xAxis->setRange(xminval, xmaxval);
ui->graphingView->yAxis->setRange(yminval, ymaxval);
ui->graphingView->axisRect()->setupFullAxesBox();
}
ui->graphingView->replot();
}
+1
View File
@@ -55,6 +55,7 @@ private:
QVector<CANFrame> *modelFrames;
QList<GraphParams> graphParams;
QPen selectedPen;
bool needScaleSetup; //do we need to set x,y graphing extents?s
void showParamsDialog(int idx);
};