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:
+14
-3
@@ -58,6 +58,8 @@ GraphingWindow::GraphingWindow(QVector<CANFrame> *frames, QWidget *parent) :
|
|||||||
|
|
||||||
selectedPen.setWidth(1);
|
selectedPen.setWidth(1);
|
||||||
selectedPen.setColor(Qt::blue);
|
selectedPen.setColor(Qt::blue);
|
||||||
|
|
||||||
|
needScaleSetup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphingWindow::~GraphingWindow()
|
GraphingWindow::~GraphingWindow()
|
||||||
@@ -82,6 +84,7 @@ void GraphingWindow::updatedFrames(int numFrames)
|
|||||||
//there shouldn't be any need to actually remove the graphs.
|
//there shouldn't be any need to actually remove the graphs.
|
||||||
//regenerate them instead
|
//regenerate them instead
|
||||||
ui->graphingView->clearGraphs(); //temporarily remove the graphs from the graph view
|
ui->graphingView->clearGraphs(); //temporarily remove the graphs from the graph view
|
||||||
|
needScaleSetup = true;
|
||||||
for (int i = 0; i < graphParams.count(); i++)
|
for (int i = 0; i < graphParams.count(); i++)
|
||||||
{
|
{
|
||||||
createGraph(graphParams[i], false); //regenerate each one
|
createGraph(graphParams[i], false); //regenerate each one
|
||||||
@@ -225,6 +228,9 @@ void GraphingWindow::removeSelectedGraph()
|
|||||||
graphParams.removeAt(idx);
|
graphParams.removeAt(idx);
|
||||||
|
|
||||||
ui->graphingView->removeGraph(ui->graphingView->selectedGraphs().first());
|
ui->graphingView->removeGraph(ui->graphingView->selectedGraphs().first());
|
||||||
|
|
||||||
|
if (graphParams.count() == 0) needScaleSetup = true;
|
||||||
|
|
||||||
ui->graphingView->replot();
|
ui->graphingView->replot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,6 +261,7 @@ void GraphingWindow::removeAllGraphs()
|
|||||||
{
|
{
|
||||||
ui->graphingView->clearGraphs();
|
ui->graphingView->clearGraphs();
|
||||||
graphParams.clear();
|
graphParams.clear();
|
||||||
|
needScaleSetup = true;
|
||||||
ui->graphingView->replot();
|
ui->graphingView->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,9 +432,13 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
|||||||
graphPen.setWidth(1);
|
graphPen.setWidth(1);
|
||||||
ui->graphingView->graph()->setPen(graphPen);
|
ui->graphingView->graph()->setPen(graphPen);
|
||||||
|
|
||||||
ui->graphingView->xAxis->setRange(xminval, xmaxval);
|
if (needScaleSetup)
|
||||||
ui->graphingView->yAxis->setRange(yminval, ymaxval);
|
{
|
||||||
ui->graphingView->axisRect()->setupFullAxesBox();
|
needScaleSetup = false;
|
||||||
|
ui->graphingView->xAxis->setRange(xminval, xmaxval);
|
||||||
|
ui->graphingView->yAxis->setRange(yminval, ymaxval);
|
||||||
|
ui->graphingView->axisRect()->setupFullAxesBox();
|
||||||
|
}
|
||||||
|
|
||||||
ui->graphingView->replot();
|
ui->graphingView->replot();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ private:
|
|||||||
QVector<CANFrame> *modelFrames;
|
QVector<CANFrame> *modelFrames;
|
||||||
QList<GraphParams> graphParams;
|
QList<GraphParams> graphParams;
|
||||||
QPen selectedPen;
|
QPen selectedPen;
|
||||||
|
bool needScaleSetup; //do we need to set x,y graphing extents?s
|
||||||
|
|
||||||
void showParamsDialog(int idx);
|
void showParamsDialog(int idx);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user