From ba71c0cdaccd72a6af0bb74244afed684c8f514a 2017-08-17 13:39:45 From: mperrinel Date: 2017-08-17 13:39:45 Subject: [PATCH] add Skeleton for displaying data which are already in cache --- diff --git a/core/include/Variable/VariableController.h b/core/include/Variable/VariableController.h index cf14962..d2b6384 100644 --- a/core/include/Variable/VariableController.h +++ b/core/include/Variable/VariableController.h @@ -73,6 +73,9 @@ signals: /// Signal emitted when a data acquisition is requested on a range for a variable void rangeChanged(std::shared_ptr variable, const SqpRange &range); + /// Signal emitted when a sub range of the cacheRange of the variable can be displayed + void updateVarDisplaying(std::shared_ptr variable, const SqpRange &range); + public slots: /// Request the data loading of the variable whithin range void onRequestDataLoading(QVector > variables, const SqpRange &range, diff --git a/core/src/Variable/VariableController.cpp b/core/src/Variable/VariableController.cpp index ad796fd..908db03 100644 --- a/core/src/Variable/VariableController.cpp +++ b/core/src/Variable/VariableController.cpp @@ -80,7 +80,8 @@ struct VariableController::VariableControllerPrivate { m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}}, m_VariableCacheController{std::make_unique()}, m_VariableCacheStrategy{std::make_unique()}, - m_VariableAcquisitionWorker{std::make_unique()} + m_VariableAcquisitionWorker{std::make_unique()}, + q{parent} { m_VariableAcquisitionWorker->moveToThread(&m_VariableAcquisitionWorkerThread); @@ -126,6 +127,9 @@ struct VariableController::VariableControllerPrivate { m_GroupIdToVariableSynchronizationGroupMap; std::map m_VariableIdGroupIdMap; std::set > m_ProviderSet; + + + VariableController *q; }; @@ -463,6 +467,7 @@ void VariableController::VariableControllerPrivate::processRequest(std::shared_p auto varRangesRequested = m_VariableCacheStrategy->computeCacheRange(var->range(), rangeRequested); auto notInCacheRangeList = var->provideNotInCacheRangeList(varRangesRequested.second); + auto inCacheRangeList = var->provideInCacheRangeList(varRangesRequested.second); if (!notInCacheRangeList.empty()) { auto identifier = m_VariableToIdentifierMap.at(var); @@ -477,6 +482,10 @@ void VariableController::VariableControllerPrivate::processRequest(std::shared_p qCCritical(LOG_VariableController()) << "Impossible to provide data with a null provider"; } + + if (!inCacheRangeList.empty()) { + emit q->updateVarDisplaying(var, inCacheRangeList.first()); + } } else { var->setRange(rangeRequested); diff --git a/gui/include/Visualization/VisualizationGraphWidget.h b/gui/include/Visualization/VisualizationGraphWidget.h index d9a03ac..c40ee8b 100644 --- a/gui/include/Visualization/VisualizationGraphWidget.h +++ b/gui/include/Visualization/VisualizationGraphWidget.h @@ -79,6 +79,8 @@ private slots: void onMouseRelease(QMouseEvent *event) noexcept; void onDataCacheVariableUpdated(); + + void onUpdateVarDisplaying(std::shared_ptr variable, const SqpRange &range); }; #endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H diff --git a/gui/src/Visualization/VisualizationGraphHelper.cpp b/gui/src/Visualization/VisualizationGraphHelper.cpp index 17611c9..8b494cc 100644 --- a/gui/src/Visualization/VisualizationGraphHelper.cpp +++ b/gui/src/Visualization/VisualizationGraphHelper.cpp @@ -43,27 +43,28 @@ void updateScalarData(QCPAbstractPlottable *component, std::shared_ptr(component)) { scalarSeries->lockRead(); { - const auto &xData = scalarSeries->xAxisData()->cdata(); - const auto &valuesData = scalarSeries->valuesData()->cdata(); +// auto bounds = scalarSeries->subData(rang +// const auto &xData = scalarSeries->xAxisData()->cdata(); +// const auto &valuesData = scalarSeries->valuesData()->cdata(); - auto xDataBegin = xData.cbegin(); - auto xDataEnd = xData.cend(); +// auto xDataBegin = xData.cbegin(); +// auto xDataEnd = xData.cend(); - qCInfo(LOG_VisualizationGraphHelper()) << "TODEBUG: Current points in cache" - << xData.count(); +// qCInfo(LOG_VisualizationGraphHelper()) << "TODEBUG: Current points in cache" +// << xData.count(); - auto sqpDataContainer = QSharedPointer::create(); - qcpGraph->setData(sqpDataContainer); +// auto sqpDataContainer = QSharedPointer::create(); +// qcpGraph->setData(sqpDataContainer); - auto lowerIt = std::lower_bound(xDataBegin, xDataEnd, dateTime.m_TStart); - auto upperIt = std::upper_bound(xDataBegin, xDataEnd, dateTime.m_TEnd); - auto distance = std::distance(xDataBegin, lowerIt); +// auto lowerIt = std::lower_bound(xDataBegin, xDataEnd, dateTime.m_TStart); +// auto upperIt = std::upper_bound(xDataBegin, xDataEnd, dateTime.m_TEnd); +// auto distance = std::distance(xDataBegin, lowerIt); - auto valuesDataIt = valuesData.cbegin() + distance; - for (auto xAxisDataIt = lowerIt; xAxisDataIt != upperIt; - ++xAxisDataIt, ++valuesDataIt) { - sqpDataContainer->appendGraphData(QCPGraphData(*xAxisDataIt, *valuesDataIt)); - } +// auto valuesDataIt = valuesData.cbegin() + distance; +// for (auto xAxisDataIt = lowerIt; xAxisDataIt != upperIt; +// ++xAxisDataIt, ++valuesDataIt) { +// sqpDataContainer->appendGraphData(QCPGraphData(*xAxisDataIt, *valuesDataIt)); +// } qCInfo(LOG_VisualizationGraphHelper()) << "TODEBUG: Current points displayed" << sqpDataContainer->size(); diff --git a/gui/src/Visualization/VisualizationGraphWidget.cpp b/gui/src/Visualization/VisualizationGraphWidget.cpp index 7d2935f..ad7b12a 100644 --- a/gui/src/Visualization/VisualizationGraphWidget.cpp +++ b/gui/src/Visualization/VisualizationGraphWidget.cpp @@ -80,6 +80,9 @@ VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget connect(this, &VisualizationGraphWidget::requestDataLoading, &sqpApp->variableController(), &VariableController::onRequestDataLoading); + + connect(&sqpApp->variableController(), &VariableController::updateVarDisplaying, this, + &VisualizationGraphWidget::onUpdateVarDisplaying); } @@ -305,3 +308,13 @@ void VisualizationGraphWidget::onDataCacheVariableUpdated() } } } + +void VisualizationGraphWidget::onUpdateVarDisplaying(std::shared_ptr variable, + const SqpRange &range) +{ + auto componentsIt = impl->m_VariableToPlotMultiMap.equal_range(variable); + for (auto it = componentsIt.first; it != componentsIt.second;) { + VisualizationGraphHelper::updateData(QVector{} << it->second, + variable->dataSeries(), range); + } +}