Fix graphing of realtime data (previously an error caused only last

graph to update).
This commit is contained in:
Collin Kidder
2017-08-30 21:30:00 -04:00
parent cbc6115ec4
commit 290af20e62
+17 -9
View File
@@ -131,6 +131,9 @@ void GraphingWindow::updatedFrames(int numFrames)
{ {
CANFrame thisFrame; CANFrame thisFrame;
QVector<double> x, y; QVector<double> x, y;
bool appendedToGraph = false;
bool needReplot = false;
if (numFrames == -1) //all frames deleted. Kill the display if (numFrames == -1) //all frames deleted. Kill the display
{ {
//removeAllGraphs(); //removeAllGraphs();
@@ -158,26 +161,31 @@ void GraphingWindow::updatedFrames(int numFrames)
} }
else //just got some new frames. See if they are relevant. else //just got some new frames. See if they are relevant.
{ {
bool appendedToGraph = false;
if (numFrames > modelFrames->count()) return; if (numFrames > modelFrames->count()) return;
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
for (int j = 0; j < graphParams.count(); j++)
{ {
thisFrame = modelFrames->at(i); appendedToGraph = false;
for (int j = 0; j < graphParams.count(); j++) x.clear();
y.clear();
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
{ {
thisFrame = modelFrames->at(i);
if (graphParams[j].ID == thisFrame.ID) if (graphParams[j].ID == thisFrame.ID)
{ {
appendToGraph(graphParams[j], thisFrame, x, y); appendToGraph(graphParams[j], thisFrame, x, y);
appendedToGraph = true; appendedToGraph = true;
} }
} }
} if (appendedToGraph)
if (appendedToGraph) {
for (int j = 0; j < graphParams.count(); j++)
{ {
//graphParams[j].ref->setData(graphParams[j].x, graphParams[j].y); graphParams[j].ref->addData(x, y);
graphParams[j].ref->addData(x, y, true); needReplot = true;
} }
}
if (needReplot)
{
if (followGraphEnd) if (followGraphEnd)
{ {
//find the current X span and maintain that span but move the end of it over to match the new end //find the current X span and maintain that span but move the end of it over to match the new end