##// END OF EJS Templates
Updates UI to not call the sort method when update graphs, as data series are already sorted
Alexandre Leroux -
r453:a8d8791b7e7a
parent child
Show More
@@ -11,7 +11,7 namespace {
11 11
12 12 class SqpDataContainer : public QCPGraphDataContainer {
13 13 public:
14 void appendGraphDataUnsorted(const QCPGraphData &data) { mData.append(data); }
14 void appendGraphData(const QCPGraphData &data) { mData.append(data); }
15 15 };
16 16
17 17
@@ -40,30 +40,32 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSerie
40 40 qCDebug(LOG_VisualizationGraphHelper()) << "TORM: updateScalarData"
41 41 << QThread::currentThread()->objectName();
42 42 if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) {
43 // Clean the graph
44 // NAIVE approch
45 43 scalarSeries.lockRead();
46 44 {
47 const auto xData = scalarSeries.xAxisData()->data();
48 const auto valuesData = scalarSeries.valuesData()->data();
49 const auto count = xData.count();
50 qCInfo(LOG_VisualizationGraphHelper()) << "TORM: Current points in cache"
51 << xData.count();
52
53 auto dataContainer = qcpGraph->data();
54 dataContainer->clear();
45 const auto &xData = scalarSeries.xAxisData()->cdata();
46 const auto &valuesData = scalarSeries.valuesData()->cdata();
47
48 auto xDataBegin = xData.cbegin();
49 auto xDataEnd = xData.cend();
50
51 qCInfo(LOG_VisualizationGraphHelper())
52 << "TORM: Current points in cache" << xData.count();
53
55 54 auto sqpDataContainer = QSharedPointer<SqpDataContainer>::create();
56 55 qcpGraph->setData(sqpDataContainer);
57 56
58 for (auto i = 0; i < count; ++i) {
59 const auto x = xData[i];
60 if (x >= dateTime.m_TStart && x <= dateTime.m_TEnd) {
61 sqpDataContainer->appendGraphDataUnsorted(QCPGraphData(x, valuesData[i]));
62 }
57 auto lowerIt = std::lower_bound(xDataBegin, xDataEnd, dateTime.m_TStart);
58 auto upperIt = std::upper_bound(xDataBegin, xDataEnd, dateTime.m_TEnd);
59 auto distance = std::distance(xDataBegin, lowerIt);
60
61 auto valuesDataIt = valuesData.cbegin() + distance;
62 for (auto xAxisDataIt = lowerIt; xAxisDataIt != upperIt;
63 ++xAxisDataIt, ++valuesDataIt) {
64 sqpDataContainer->appendGraphData(QCPGraphData(*xAxisDataIt, *valuesDataIt));
63 65 }
64 sqpDataContainer->sort();
65 qCInfo(LOG_VisualizationGraphHelper()) << "TORM: Current points displayed"
66 << sqpDataContainer->size();
66
67 qCInfo(LOG_VisualizationGraphHelper())
68 << "TORM: Current points displayed" << sqpDataContainer->size();
67 69 }
68 70 scalarSeries.unlock();
69 71
General Comments 0
You need to be logged in to leave comments. Login now