diff --git a/.vscode/settings.json b/.vscode/settings.json index 8d85298b755bc7e2bcb260a16c882140a4805d8e..a68dd339b84a62ed3dc7bae3e4a9d77e403ba158 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -152,7 +152,19 @@ "qconemesh": "cpp", "qgeometryrenderer": "cpp", "qrenderaspect": "cpp", - "qcuboidmesh": "cpp" + "qcuboidmesh": "cpp", + "qtcore": "cpp", + "qtdatavisualization": "cpp", + "qtgui": "cpp", + "qtmacextras": "cpp", + "qtnetwork": "cpp", + "qtquickcontrols2": "cpp", + "qtquicktest": "cpp", + "qtwidgets": "cpp", + "qtnetworkauth": "cpp", + "qtscript": "cpp", + "qtsvg": "cpp", + "qtvirtualkeyboard": "cpp" }, "editor.defaultFormatter": "ms-vscode.cpptools", "[xml]": { diff --git a/src/shared/Modules/Graph/Graph.cpp b/src/shared/Modules/Graph/Graph.cpp index 14d6992c0a29481b7e34cd7015b02b504067d817..c59f15e79981ad4efd10750b273143ac503461b6 100644 --- a/src/shared/Modules/Graph/Graph.cpp +++ b/src/shared/Modules/Graph/Graph.cpp @@ -138,13 +138,15 @@ void Graph::onFilterAdded(const Filter& filter) if (stopped && !lines.contains(filter)) return; + if (!message.getFields().contains("timestamp")) + return; + for (auto field : filter.getFields()) { if (field == "timestamp") continue; - auto& line = lines[filter].first[field]; - + auto& line = lines[filter].first[field]; QVector<double>& bufferX = line.bufferX; QVector<double>& bufferY = line.bufferY; @@ -153,18 +155,12 @@ void Graph::onFilterAdded(const Filter& filter) double y = message.getField(field).getDouble(); // Check if the timestamp resets - if (bufferX.last() < x) - { - bufferX.append(x); - bufferY.append(y); - } - else - { - bufferX.clear(); - bufferY.clear(); + if (lastTimestamp - 1 > x) + onClearClicked(); - line.graph->data()->clear(); - } + lastTimestamp = x; + bufferX.append(x); + bufferY.append(y); } // Flag the data as updated diff --git a/src/shared/Modules/Graph/Graph.h b/src/shared/Modules/Graph/Graph.h index 4b0c551d2d72633335291f7ddcd92e371c2da606..820813e93b1e7400b363fa972b8ca2a26cc9a947 100644 --- a/src/shared/Modules/Graph/Graph.h +++ b/src/shared/Modules/Graph/Graph.h @@ -51,6 +51,8 @@ private: QTimer updaterTimer; int updatePeriod = 1000 / 5; // 5fps + double lastTimestamp = 0; + bool stopped = false; bool following = true; };