Skip to content
Snippets Groups Projects
Commit 24c20995 authored by Alberto Nidasio's avatar Alberto Nidasio
Browse files

[Graph] Fixed legend and timestamp reset

parent 7430b3ce
Branches
Tags
No related merge requests found
...@@ -93,8 +93,7 @@ void Graph::onClearClicked() ...@@ -93,8 +93,7 @@ void Graph::onClearClicked()
{ {
for (auto graph : graphs) for (auto graph : graphs)
graph->data()->clear(); graph->data()->clear();
plot->replot();
// plot->replot();
} }
void Graph::onStopClicked(bool checked) void Graph::onStopClicked(bool checked)
...@@ -125,14 +124,21 @@ void Graph::onSubscriptionAdded(const TopicAndFieldFilter& filter) ...@@ -125,14 +124,21 @@ void Graph::onSubscriptionAdded(const TopicAndFieldFilter& filter)
graphs.append(graph); graphs.append(graph);
buffersX.append(QVector<double>()); buffersX.append(QVector<double>());
buffersY.append(QVector<double>()); buffersY.append(QVector<double>());
qDebug() << "Graph index:" << graphs.indexOf(graph);
} }
} }
void Graph::onSubscriptionRemoved(const TopicAndFieldFilter& filter) void Graph::onSubscriptionRemoved(const TopicAndFieldFilter& filter)
{ {
qDebug() << "Removing filter" << filter.toString();
if (filters.contains(filter)) if (filters.contains(filter))
{ {
int index = filters.indexOf(filter); int index = filters.indexOf(filter);
qDebug() << "Filter found, index:" << index;
plot->removeGraph(graphs[index]);
plot->replot();
filters.removeAt(index); filters.removeAt(index);
graphs.removeAt(index); graphs.removeAt(index);
...@@ -202,9 +208,21 @@ void Graph::onMsgReceived(const ModuleMessage& msg) ...@@ -202,9 +208,21 @@ void Graph::onMsgReceived(const ModuleMessage& msg)
double x = msg.getField("timestamp").getUInteger(0) / 1e6; double x = msg.getField("timestamp").getUInteger(0) / 1e6;
double y = value.getDouble(0); double y = value.getDouble(0);
// Check if the timestamp resets
if (bufferX.last() < x)
{
bufferX.append(x); bufferX.append(x);
bufferY.append(y); bufferY.append(y);
} }
else
{
bufferX.clear();
bufferY.clear();
auto graph = graphs[index];
graph->data()->clear();
}
}
} }
} }
......
...@@ -47,7 +47,7 @@ private: ...@@ -47,7 +47,7 @@ private:
QList<QVector<double>> buffersY; QList<QVector<double>> buffersY;
QTimer updaterTimer; QTimer updaterTimer;
int updatePeriod = 1000 / 10; int updatePeriod = 1000 / 5; // 5fps
bool stopped = false; bool stopped = false;
bool following = true; bool following = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment