@@ -11,7 +11,7 namespace { | |||||
11 |
|
11 | |||
12 | class SqpDataContainer : public QCPGraphDataContainer { |
|
12 | class SqpDataContainer : public QCPGraphDataContainer { | |
13 | public: |
|
13 | public: | |
14 |
void appendGraphData |
|
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 | qCDebug(LOG_VisualizationGraphHelper()) << "TORM: updateScalarData" |
|
40 | qCDebug(LOG_VisualizationGraphHelper()) << "TORM: updateScalarData" | |
41 | << QThread::currentThread()->objectName(); |
|
41 | << QThread::currentThread()->objectName(); | |
42 | if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) { |
|
42 | if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) { | |
43 | // Clean the graph |
|
|||
44 | // NAIVE approch |
|
|||
45 | scalarSeries.lockRead(); |
|
43 | scalarSeries.lockRead(); | |
46 | { |
|
44 | { | |
47 | const auto xData = scalarSeries.xAxisData()->data(); |
|
45 | const auto &xData = scalarSeries.xAxisData()->cdata(); | |
48 | const auto valuesData = scalarSeries.valuesData()->data(); |
|
46 | const auto &valuesData = scalarSeries.valuesData()->cdata(); | |
49 | const auto count = xData.count(); |
|
47 | ||
50 | qCInfo(LOG_VisualizationGraphHelper()) << "TORM: Current points in cache" |
|
48 | auto xDataBegin = xData.cbegin(); | |
51 | << xData.count(); |
|
49 | auto xDataEnd = xData.cend(); | |
52 |
|
50 | |||
53 | auto dataContainer = qcpGraph->data(); |
|
51 | qCInfo(LOG_VisualizationGraphHelper()) | |
54 | dataContainer->clear(); |
|
52 | << "TORM: Current points in cache" << xData.count(); | |
|
53 | ||||
55 | auto sqpDataContainer = QSharedPointer<SqpDataContainer>::create(); |
|
54 | auto sqpDataContainer = QSharedPointer<SqpDataContainer>::create(); | |
56 | qcpGraph->setData(sqpDataContainer); |
|
55 | qcpGraph->setData(sqpDataContainer); | |
57 |
|
56 | |||
58 | for (auto i = 0; i < count; ++i) { |
|
57 | auto lowerIt = std::lower_bound(xDataBegin, xDataEnd, dateTime.m_TStart); | |
59 | const auto x = xData[i]; |
|
58 | auto upperIt = std::upper_bound(xDataBegin, xDataEnd, dateTime.m_TEnd); | |
60 | if (x >= dateTime.m_TStart && x <= dateTime.m_TEnd) { |
|
59 | auto distance = std::distance(xDataBegin, lowerIt); | |
61 | sqpDataContainer->appendGraphDataUnsorted(QCPGraphData(x, valuesData[i])); |
|
60 | ||
62 | } |
|
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(); |
|
66 | ||
65 |
qCInfo(LOG_VisualizationGraphHelper()) |
|
67 | qCInfo(LOG_VisualizationGraphHelper()) | |
66 |
|
|
68 | << "TORM: Current points displayed" << sqpDataContainer->size(); | |
67 | } |
|
69 | } | |
68 | scalarSeries.unlock(); |
|
70 | scalarSeries.unlock(); | |
69 |
|
71 |
General Comments 0
You need to be logged in to leave comments.
Login now