##// END OF EJS Templates
Merge branch 'feature/DisplayDataBeforeAcquisition' into develop
perrinel -
r574:23422057e407 merge
parent child
Show More
@@ -47,6 +47,7 public:
47 47 bool cacheIsInside(const SqpRange &range) const noexcept;
48 48
49 49 QVector<SqpRange> provideNotInCacheRangeList(const SqpRange &range) const noexcept;
50 QVector<SqpRange> provideInCacheRangeList(const SqpRange &range) const noexcept;
50 51 void setDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept;
51 52 void mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept;
52 53
@@ -73,6 +73,9 signals:
73 73 /// Signal emitted when a data acquisition is requested on a range for a variable
74 74 void rangeChanged(std::shared_ptr<Variable> variable, const SqpRange &range);
75 75
76 /// Signal emitted when a sub range of the cacheRange of the variable can be displayed
77 void updateVarDisplaying(std::shared_ptr<Variable> variable, const SqpRange &range);
78
76 79 public slots:
77 80 /// Request the data loading of the variable whithin range
78 81 void onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, const SqpRange &range,
@@ -182,6 +182,8 bool Variable::cacheIsInside(const SqpRange &range) const noexcept
182 182
183 183 QVector<SqpRange> Variable::provideNotInCacheRangeList(const SqpRange &range) const noexcept
184 184 {
185 // This code assume that cach in contigue. Can return 0, 1 or 2 SqpRange
186
185 187 auto notInCache = QVector<SqpRange>{};
186 188
187 189 if (!this->cacheContains(range)) {
@@ -209,3 +211,33 QVector<SqpRange> Variable::provideNotInCacheRangeList(const SqpRange &range) co
209 211
210 212 return notInCache;
211 213 }
214
215 QVector<SqpRange> Variable::provideInCacheRangeList(const SqpRange &range) const noexcept
216 {
217 // This code assume that cach in contigue. Can return 0 or 1 SqpRange
218
219 auto inCache = QVector<SqpRange>{};
220
221
222 if (this->cacheContains(range)) {
223 if (range.m_TStart <= impl->m_CacheRange.m_TEnd
224 && range.m_TEnd >= impl->m_CacheRange.m_TEnd) {
225 inCache << SqpRange{range.m_TStart, impl->m_CacheRange.m_TEnd};
226 }
227
228 else if (range.m_TStart >= impl->m_CacheRange.m_TStart
229 && range.m_TEnd < impl->m_CacheRange.m_TEnd) {
230 inCache << range;
231 }
232 else if (range.m_TStart < impl->m_CacheRange.m_TStart
233 && range.m_TEnd >= impl->m_CacheRange.m_TStart) {
234 inCache << SqpRange{impl->m_CacheRange.m_TStart, range.m_TEnd};
235 }
236 else {
237 qCCritical(LOG_Variable()) << tr("Detection of unknown case.")
238 << QThread::currentThread();
239 }
240 }
241
242 return inCache;
243 }
@@ -80,7 +80,8 struct VariableController::VariableControllerPrivate {
80 80 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
81 81 m_VariableCacheController{std::make_unique<VariableCacheController>()},
82 82 m_VariableCacheStrategy{std::make_unique<VariableCacheStrategy>()},
83 m_VariableAcquisitionWorker{std::make_unique<VariableAcquisitionWorker>()}
83 m_VariableAcquisitionWorker{std::make_unique<VariableAcquisitionWorker>()},
84 q{parent}
84 85 {
85 86
86 87 m_VariableAcquisitionWorker->moveToThread(&m_VariableAcquisitionWorkerThread);
@@ -126,6 +127,9 struct VariableController::VariableControllerPrivate {
126 127 m_GroupIdToVariableSynchronizationGroupMap;
127 128 std::map<QUuid, QUuid> m_VariableIdGroupIdMap;
128 129 std::set<std::shared_ptr<IDataProvider> > m_ProviderSet;
130
131
132 VariableController *q;
129 133 };
130 134
131 135
@@ -463,6 +467,7 void VariableController::VariableControllerPrivate::processRequest(std::shared_p
463 467 auto varRangesRequested
464 468 = m_VariableCacheStrategy->computeCacheRange(var->range(), rangeRequested);
465 469 auto notInCacheRangeList = var->provideNotInCacheRangeList(varRangesRequested.second);
470 auto inCacheRangeList = var->provideInCacheRangeList(varRangesRequested.second);
466 471
467 472 if (!notInCacheRangeList.empty()) {
468 473 auto identifier = m_VariableToIdentifierMap.at(var);
@@ -477,6 +482,10 void VariableController::VariableControllerPrivate::processRequest(std::shared_p
477 482 qCCritical(LOG_VariableController())
478 483 << "Impossible to provide data with a null provider";
479 484 }
485
486 if (!inCacheRangeList.empty()) {
487 emit q->updateVarDisplaying(var, inCacheRangeList.first());
488 }
480 489 }
481 490 else {
482 491 var->setRange(rangeRequested);
@@ -79,6 +79,8 private slots:
79 79 void onMouseRelease(QMouseEvent *event) noexcept;
80 80
81 81 void onDataCacheVariableUpdated();
82
83 void onUpdateVarDisplaying(std::shared_ptr<Variable> variable, const SqpRange &range);
82 84 };
83 85
84 86 #endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
@@ -36,33 +36,18 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis)
36 36 }
37 37
38 38 void updateScalarData(QCPAbstractPlottable *component, std::shared_ptr<ScalarSeries> scalarSeries,
39 const SqpRange &dateTime)
39 const SqpRange &range)
40 40 {
41 41 qCDebug(LOG_VisualizationGraphHelper()) << "TORM: updateScalarData"
42 42 << QThread::currentThread()->objectName();
43 43 if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) {
44 44 scalarSeries->lockRead();
45 45 {
46 const auto &xData = scalarSeries->xAxisData()->cdata();
47 const auto &valuesData = scalarSeries->valuesData()->cdata();
48
49 auto xDataBegin = xData.cbegin();
50 auto xDataEnd = xData.cend();
51
52 qCInfo(LOG_VisualizationGraphHelper()) << "TODEBUG: Current points in cache"
53 << xData.count();
54
55 46 auto sqpDataContainer = QSharedPointer<SqpDataContainer>::create();
56 47 qcpGraph->setData(sqpDataContainer);
57
58 auto lowerIt = std::lower_bound(xDataBegin, xDataEnd, dateTime.m_TStart);
59 auto upperIt = std::upper_bound(xDataBegin, xDataEnd, dateTime.m_TEnd);
60 auto distance = std::distance(xDataBegin, lowerIt);
61
62 auto valuesDataIt = valuesData.cbegin() + distance;
63 for (auto xAxisDataIt = lowerIt; xAxisDataIt != upperIt;
64 ++xAxisDataIt, ++valuesDataIt) {
65 sqpDataContainer->appendGraphData(QCPGraphData(*xAxisDataIt, *valuesDataIt));
48 auto bounds = scalarSeries->subData(range.m_TStart, range.m_TEnd);
49 for (auto it = bounds.first; it != bounds.second; ++it) {
50 sqpDataContainer->appendGraphData(QCPGraphData(it->x(), it->value()));
66 51 }
67 52
68 53 qCInfo(LOG_VisualizationGraphHelper()) << "TODEBUG: Current points displayed"
@@ -80,6 +80,9 VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget
80 80
81 81 connect(this, &VisualizationGraphWidget::requestDataLoading, &sqpApp->variableController(),
82 82 &VariableController::onRequestDataLoading);
83
84 connect(&sqpApp->variableController(), &VariableController::updateVarDisplaying, this,
85 &VisualizationGraphWidget::onUpdateVarDisplaying);
83 86 }
84 87
85 88
@@ -305,3 +308,13 void VisualizationGraphWidget::onDataCacheVariableUpdated()
305 308 }
306 309 }
307 310 }
311
312 void VisualizationGraphWidget::onUpdateVarDisplaying(std::shared_ptr<Variable> variable,
313 const SqpRange &range)
314 {
315 auto componentsIt = impl->m_VariableToPlotMultiMap.equal_range(variable);
316 for (auto it = componentsIt.first; it != componentsIt.second;) {
317 VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *>{} << it->second,
318 variable->dataSeries(), range);
319 }
320 }
@@ -258,11 +258,11 void TestAmdaResultParser::testReadScalarTxt_data()
258 258 QVector<QDateTime>{}, QVector<double>{}};
259 259
260 260 // Invalid files
261 QTest::newRow("Invalid file (unexisting file)")
262 << QStringLiteral("UnexistingFile.txt") << ExpectedResults<ScalarSeries>{};
261 QTest::newRow("Invalid file (unexisting file)") << QStringLiteral("UnexistingFile.txt")
262 << ExpectedResults<ScalarSeries>{};
263 263
264 QTest::newRow("Invalid file (file not found on server)")
265 << QStringLiteral("FileNotFound.txt") << ExpectedResults<ScalarSeries>{};
264 QTest::newRow("Invalid file (file not found on server)") << QStringLiteral("FileNotFound.txt")
265 << ExpectedResults<ScalarSeries>{};
266 266 }
267 267
268 268 void TestAmdaResultParser::testReadScalarTxt()
General Comments 0
You need to be logged in to leave comments. Login now