From b41b5a9346eba94e8604934f37cac4d9c17982a2 2017-10-02 09:26:37 From: mperrinel Date: 2017-10-02 09:26:37 Subject: [PATCH] Implémentation timewidget --- diff --git a/core/include/Variable/VariableController.h b/core/include/Variable/VariableController.h index b016617..3e18ad1 100644 --- a/core/include/Variable/VariableController.h +++ b/core/include/Variable/VariableController.h @@ -83,7 +83,7 @@ signals: public slots: /// Request the data loading of the variable whithin range void onRequestDataLoading(QVector > variables, const SqpRange &range, - const SqpRange &oldRange, bool synchronise); + bool synchronise); /** * Creates a new variable and adds it to the model * @param name the name of the new variable diff --git a/core/src/Variable/VariableController.cpp b/core/src/Variable/VariableController.cpp index fa6e0c1..08faec6 100644 --- a/core/src/Variable/VariableController.cpp +++ b/core/src/Variable/VariableController.cpp @@ -299,22 +299,24 @@ VariableController::createVariable(const QString &name, const QVariantHash &meta void VariableController::onDateTimeOnSelection(const SqpRange &dateTime) { - // TODO check synchronisation and Rescale + // NOTE: Even if acquisition request is aborting, the graphe range will be changed qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection" << QThread::currentThread()->objectName(); auto selectedRows = impl->m_VariableSelectionModel->selectedRows(); - auto varRequestId = QUuid::createUuid(); + auto variables = QVector >{}; for (const auto &selectedRow : qAsConst(selectedRows)) { if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) { - selectedVariable->setRange(dateTime); - impl->processRequest(selectedVariable, dateTime, varRequestId); + variables << selectedVariable; // notify that rescale operation has to be done emit rangeChanged(selectedVariable, dateTime); } } - impl->updateVariableRequest(varRequestId); + + if (!variables.isEmpty()) { + this->onRequestDataLoading(variables, dateTime, true); + } } void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested, @@ -459,8 +461,7 @@ void VariableController::desynchronize(std::shared_ptr variable, } void VariableController::onRequestDataLoading(QVector > variables, - const SqpRange &range, const SqpRange &oldRange, - bool synchronise) + const SqpRange &range, bool synchronise) { // NOTE: oldRange isn't really necessary since oldRange == variable->range(). diff --git a/core/tests/Variable/TestVariableSync.cpp b/core/tests/Variable/TestVariableSync.cpp index 21a8907..204826e 100644 --- a/core/tests/Variable/TestVariableSync.cpp +++ b/core/tests/Variable/TestVariableSync.cpp @@ -105,8 +105,7 @@ struct Move : public IOperation { void exec(VariableController &variableController) const override { if (auto variable = variableController.variableModel()->variable(m_Index)) { - variableController.onRequestDataLoading({variable}, m_NewRange, variable->range(), - !m_Shift); + variableController.onRequestDataLoading({variable}, m_NewRange, !m_Shift); } } diff --git a/gui/include/Visualization/VisualizationGraphWidget.h b/gui/include/Visualization/VisualizationGraphWidget.h index 5b7b250..98a1c1d 100644 --- a/gui/include/Visualization/VisualizationGraphWidget.h +++ b/gui/include/Visualization/VisualizationGraphWidget.h @@ -39,7 +39,6 @@ public: /// Removes a variable from the graph void removeVariable(std::shared_ptr variable) noexcept; - void setRange(std::shared_ptr variable, const SqpRange &range); void setYRange(const SqpRange &range); SqpRange graphRange() const noexcept; void setGraphRange(const SqpRange &range); @@ -54,7 +53,7 @@ public: signals: void synchronize(const SqpRange &range, const SqpRange &oldRange); void requestDataLoading(QVector > variable, const SqpRange &range, - const SqpRange &oldRange, bool synchronise); + bool synchronise); /// Signal emitted when the variable is about to be removed from the graph void variableAboutToBeRemoved(std::shared_ptr var); diff --git a/gui/src/Visualization/VisualizationGraphWidget.cpp b/gui/src/Visualization/VisualizationGraphWidget.cpp index fc99f91..50d0562 100644 --- a/gui/src/Visualization/VisualizationGraphWidget.cpp +++ b/gui/src/Visualization/VisualizationGraphWidget.cpp @@ -119,14 +119,11 @@ void VisualizationGraphWidget::addVariable(std::shared_ptr variable, S connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated())); - auto varRange = variable->range(); - this->enableAcquisition(false); this->setGraphRange(range); this->enableAcquisition(true); - emit requestDataLoading(QVector >() << variable, range, varRange, - false); + emit requestDataLoading(QVector >() << variable, range, false); emit variableAdded(variable); } @@ -155,17 +152,6 @@ void VisualizationGraphWidget::removeVariable(std::shared_ptr variable ui->widget->replot(); } -void VisualizationGraphWidget::setRange(std::shared_ptr variable, const SqpRange &range) -{ - // Note: in case of different axes that depends on variable, we could start with a code like - // that: - // auto componentsIt = impl->m_VariableToPlotMultiMap.equal_range(variable); - // for (auto it = componentsIt.first; it != componentsIt.second;) { - // } - ui->widget->xAxis->setRange(range.m_TStart, range.m_TEnd); - ui->widget->replot(); -} - void VisualizationGraphWidget::setYRange(const SqpRange &range) { ui->widget->yAxis->setRange(range.m_TStart, range.m_TEnd); @@ -282,7 +268,7 @@ void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange it != end; it = impl->m_VariableToPlotMultiMap.upper_bound(it->first)) { variableUnderGraphVector.push_back(it->first); } - emit requestDataLoading(std::move(variableUnderGraphVector), graphRange, oldGraphRange, + emit requestDataLoading(std::move(variableUnderGraphVector), graphRange, !impl->m_IsCalibration); if (!impl->m_IsCalibration) { diff --git a/gui/src/Visualization/operations/RescaleAxeOperation.cpp b/gui/src/Visualization/operations/RescaleAxeOperation.cpp index 5c5583e..543b26c 100644 --- a/gui/src/Visualization/operations/RescaleAxeOperation.cpp +++ b/gui/src/Visualization/operations/RescaleAxeOperation.cpp @@ -59,7 +59,9 @@ void RescaleAxeOperation::visit(VisualizationGraphWidget *graphWidget) if (graphWidget) { // If the widget contains the variable, rescale it if (impl->m_Variable && graphWidget->contains(*impl->m_Variable)) { - graphWidget->setRange(impl->m_Variable, impl->m_Range); + graphWidget->enableAcquisition(false); + graphWidget->setGraphRange(impl->m_Range); + graphWidget->enableAcquisition(true); } } else { diff --git a/plugins/amda/tests/TestAmdaAcquisition.cpp b/plugins/amda/tests/TestAmdaAcquisition.cpp index 5f0bc89..596f8b5 100644 --- a/plugins/amda/tests/TestAmdaAcquisition.cpp +++ b/plugins/amda/tests/TestAmdaAcquisition.cpp @@ -123,8 +123,7 @@ void TestAmdaAcquisition::testAcquisition() auto nextSqpR = SqpRange{DateUtils::secondsSinceEpoch(tStart), DateUtils::secondsSinceEpoch(tEnd)}; - vc.onRequestDataLoading(QVector >{} << var, nextSqpR, - var->range(), true); + vc.onRequestDataLoading(QVector >{} << var, nextSqpR, true); QEventLoop loop; QTimer::singleShot(timeToWaitMs, &loop, &QEventLoop::quit);