##// END OF EJS Templates
add Skeleton for displaying data which are already in cache
perrinel -
r571:ba71c0cdaccd
parent child
Show More
@@ -73,6 +73,9 signals:
73 /// Signal emitted when a data acquisition is requested on a range for a variable
73 /// Signal emitted when a data acquisition is requested on a range for a variable
74 void rangeChanged(std::shared_ptr<Variable> variable, const SqpRange &range);
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 public slots:
79 public slots:
77 /// Request the data loading of the variable whithin range
80 /// Request the data loading of the variable whithin range
78 void onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, const SqpRange &range,
81 void onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, const SqpRange &range,
@@ -80,7 +80,8 struct VariableController::VariableControllerPrivate {
80 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
80 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
81 m_VariableCacheController{std::make_unique<VariableCacheController>()},
81 m_VariableCacheController{std::make_unique<VariableCacheController>()},
82 m_VariableCacheStrategy{std::make_unique<VariableCacheStrategy>()},
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 m_VariableAcquisitionWorker->moveToThread(&m_VariableAcquisitionWorkerThread);
87 m_VariableAcquisitionWorker->moveToThread(&m_VariableAcquisitionWorkerThread);
@@ -126,6 +127,9 struct VariableController::VariableControllerPrivate {
126 m_GroupIdToVariableSynchronizationGroupMap;
127 m_GroupIdToVariableSynchronizationGroupMap;
127 std::map<QUuid, QUuid> m_VariableIdGroupIdMap;
128 std::map<QUuid, QUuid> m_VariableIdGroupIdMap;
128 std::set<std::shared_ptr<IDataProvider> > m_ProviderSet;
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 auto varRangesRequested
467 auto varRangesRequested
464 = m_VariableCacheStrategy->computeCacheRange(var->range(), rangeRequested);
468 = m_VariableCacheStrategy->computeCacheRange(var->range(), rangeRequested);
465 auto notInCacheRangeList = var->provideNotInCacheRangeList(varRangesRequested.second);
469 auto notInCacheRangeList = var->provideNotInCacheRangeList(varRangesRequested.second);
470 auto inCacheRangeList = var->provideInCacheRangeList(varRangesRequested.second);
466
471
467 if (!notInCacheRangeList.empty()) {
472 if (!notInCacheRangeList.empty()) {
468 auto identifier = m_VariableToIdentifierMap.at(var);
473 auto identifier = m_VariableToIdentifierMap.at(var);
@@ -477,6 +482,10 void VariableController::VariableControllerPrivate::processRequest(std::shared_p
477 qCCritical(LOG_VariableController())
482 qCCritical(LOG_VariableController())
478 << "Impossible to provide data with a null provider";
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 else {
490 else {
482 var->setRange(rangeRequested);
491 var->setRange(rangeRequested);
@@ -79,6 +79,8 private slots:
79 void onMouseRelease(QMouseEvent *event) noexcept;
79 void onMouseRelease(QMouseEvent *event) noexcept;
80
80
81 void onDataCacheVariableUpdated();
81 void onDataCacheVariableUpdated();
82
83 void onUpdateVarDisplaying(std::shared_ptr<Variable> variable, const SqpRange &range);
82 };
84 };
83
85
84 #endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
86 #endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
@@ -43,27 +43,28 void updateScalarData(QCPAbstractPlottable *component, std::shared_ptr<ScalarSer
43 if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) {
43 if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) {
44 scalarSeries->lockRead();
44 scalarSeries->lockRead();
45 {
45 {
46 const auto &xData = scalarSeries->xAxisData()->cdata();
46 // auto bounds = scalarSeries->subData(rang
47 const auto &valuesData = scalarSeries->valuesData()->cdata();
47 // const auto &xData = scalarSeries->xAxisData()->cdata();
48 // const auto &valuesData = scalarSeries->valuesData()->cdata();
48
49
49 auto xDataBegin = xData.cbegin();
50 // auto xDataBegin = xData.cbegin();
50 auto xDataEnd = xData.cend();
51 // auto xDataEnd = xData.cend();
51
52
52 qCInfo(LOG_VisualizationGraphHelper()) << "TODEBUG: Current points in cache"
53 // qCInfo(LOG_VisualizationGraphHelper()) << "TODEBUG: Current points in cache"
53 << xData.count();
54 // << xData.count();
54
55
55 auto sqpDataContainer = QSharedPointer<SqpDataContainer>::create();
56 // auto sqpDataContainer = QSharedPointer<SqpDataContainer>::create();
56 qcpGraph->setData(sqpDataContainer);
57 // qcpGraph->setData(sqpDataContainer);
57
58
58 auto lowerIt = std::lower_bound(xDataBegin, xDataEnd, dateTime.m_TStart);
59 // auto lowerIt = std::lower_bound(xDataBegin, xDataEnd, dateTime.m_TStart);
59 auto upperIt = std::upper_bound(xDataBegin, xDataEnd, dateTime.m_TEnd);
60 // auto upperIt = std::upper_bound(xDataBegin, xDataEnd, dateTime.m_TEnd);
60 auto distance = std::distance(xDataBegin, lowerIt);
61 // auto distance = std::distance(xDataBegin, lowerIt);
61
62
62 auto valuesDataIt = valuesData.cbegin() + distance;
63 // auto valuesDataIt = valuesData.cbegin() + distance;
63 for (auto xAxisDataIt = lowerIt; xAxisDataIt != upperIt;
64 // for (auto xAxisDataIt = lowerIt; xAxisDataIt != upperIt;
64 ++xAxisDataIt, ++valuesDataIt) {
65 // ++xAxisDataIt, ++valuesDataIt) {
65 sqpDataContainer->appendGraphData(QCPGraphData(*xAxisDataIt, *valuesDataIt));
66 // sqpDataContainer->appendGraphData(QCPGraphData(*xAxisDataIt, *valuesDataIt));
66 }
67 // }
67
68
68 qCInfo(LOG_VisualizationGraphHelper()) << "TODEBUG: Current points displayed"
69 qCInfo(LOG_VisualizationGraphHelper()) << "TODEBUG: Current points displayed"
69 << sqpDataContainer->size();
70 << sqpDataContainer->size();
@@ -80,6 +80,9 VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget
80
80
81 connect(this, &VisualizationGraphWidget::requestDataLoading, &sqpApp->variableController(),
81 connect(this, &VisualizationGraphWidget::requestDataLoading, &sqpApp->variableController(),
82 &VariableController::onRequestDataLoading);
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 }
General Comments 0
You need to be logged in to leave comments. Login now