From 87a145505c3766fda06da9c4eadaa3289d81b3f4 2017-12-21 14:46:58 From: Alexandre Leroux Date: 2017-12-21 14:46:58 Subject: [PATCH] Corrects the problem of refreshing synchronized graphs from TimeWidget (1) Introduces graph flags to set options for the widget --- diff --git a/gui/include/Visualization/VisualizationGraphWidget.h b/gui/include/Visualization/VisualizationGraphWidget.h index 8f97ea9..efee1c9 100644 --- a/gui/include/Visualization/VisualizationGraphWidget.h +++ b/gui/include/Visualization/VisualizationGraphWidget.h @@ -25,6 +25,20 @@ namespace Ui { class VisualizationGraphWidget; } // namespace Ui +/// Defines options that can be associated with the graph +enum GraphFlag { + DisableAll = 0x0, ///< Disables acquisition and synchronization + EnableAcquisition = 0x1, ///< When this flag is set, the change of the graph's range leads to + /// the acquisition of data + EnableSynchronization = 0x2, ///< When this flag is set, the change of the graph's range causes + /// the call to the synchronization of the graphs contained in the + /// same zone of this graph + EnableAll = ~DisableAll ///< Enables acquisition and synchronization +}; + +Q_DECLARE_FLAGS(GraphFlags, GraphFlag) +Q_DECLARE_OPERATORS_FOR_FLAGS(GraphFlags) + class VisualizationGraphWidget : public VisualizationDragWidget, public IVisualizationWidget { Q_OBJECT @@ -41,8 +55,8 @@ public: /// Returns the main VisualizationWidget which contains the graph or nullptr VisualizationWidget *parentVisualizationWidget() const; - /// If acquisition isn't enable, requestDataLoading signal cannot be emit - void enableAcquisition(bool enable); + /// Sets graph options + void setFlags(GraphFlags flags); void addVariable(std::shared_ptr variable, SqpRange range); diff --git a/gui/src/Visualization/VisualizationGraphWidget.cpp b/gui/src/Visualization/VisualizationGraphWidget.cpp index b1e2048..e22132d 100644 --- a/gui/src/Visualization/VisualizationGraphWidget.cpp +++ b/gui/src/Visualization/VisualizationGraphWidget.cpp @@ -59,7 +59,7 @@ struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate { explicit VisualizationGraphWidgetPrivate(const QString &name) : m_Name{name}, - m_DoAcquisition{true}, + m_Flags{GraphFlag::EnableAll}, m_IsCalibration{false}, m_RenderingDelegate{nullptr} { @@ -77,7 +77,7 @@ struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate { QString m_Name; // 1 variable -> n qcpplot std::map, PlottablesMap> m_VariableToPlotMultiMap; - bool m_DoAcquisition; + GraphFlags m_Flags; bool m_IsCalibration; /// Delegate used to attach rendering features to the plot std::unique_ptr m_RenderingDelegate; @@ -287,9 +287,9 @@ VisualizationWidget *VisualizationGraphWidget::parentVisualizationWidget() const return qobject_cast(parent); } -void VisualizationGraphWidget::enableAcquisition(bool enable) +void VisualizationGraphWidget::setFlags(GraphFlags flags) { - impl->m_DoAcquisition = enable; + impl->m_Flags = std::move(flags); } void VisualizationGraphWidget::addVariable(std::shared_ptr variable, SqpRange range) @@ -311,9 +311,9 @@ void VisualizationGraphWidget::addVariable(std::shared_ptr variable, S connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated())); - this->enableAcquisition(false); + this->setFlags(GraphFlag::DisableAll); this->setGraphRange(range); - this->enableAcquisition(true); + this->setFlags(GraphFlag::EnableAll); emit requestDataLoading(QVector >() << variable, range, false); @@ -696,12 +696,12 @@ void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange { qCDebug(LOG_VisualizationGraphWidget()) << tr("TORM: VisualizationGraphWidget::onRangeChanged") << QThread::currentThread()->objectName() << "DoAcqui" - << impl->m_DoAcquisition; + << impl->m_Flags.testFlag(GraphFlag::EnableAcquisition); auto graphRange = SqpRange{t1.lower, t1.upper}; auto oldGraphRange = SqpRange{t2.lower, t2.upper}; - if (impl->m_DoAcquisition) { + if (impl->m_Flags.testFlag(GraphFlag::EnableAcquisition)) { QVector > variableUnderGraphVector; for (auto it = impl->m_VariableToPlotMultiMap.begin(), diff --git a/gui/src/Visualization/VisualizationZoneWidget.cpp b/gui/src/Visualization/VisualizationZoneWidget.cpp index 5f967a9..eb1222c 100644 --- a/gui/src/Visualization/VisualizationZoneWidget.cpp +++ b/gui/src/Visualization/VisualizationZoneWidget.cpp @@ -264,15 +264,15 @@ VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptrenableAcquisition(false); - qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ") - << graphChild->graphRange(); - qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ") - << graphChildRange; + graphChild->setFlags(GraphFlag::DisableAll); + qCDebug(LOG_VisualizationZoneWidget()) + << tr("TORM: Range before: ") << graphChild->graphRange(); + qCDebug(LOG_VisualizationZoneWidget()) + << tr("TORM: Range after : ") << graphChildRange; qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart; graphChild->setGraphRange(graphChildRange); - graphChild->enableAcquisition(true); + graphChild->setFlags(GraphFlag::EnableAll); } } }; diff --git a/gui/src/Visualization/operations/RescaleAxeOperation.cpp b/gui/src/Visualization/operations/RescaleAxeOperation.cpp index 543b26c..c49e9c1 100644 --- a/gui/src/Visualization/operations/RescaleAxeOperation.cpp +++ b/gui/src/Visualization/operations/RescaleAxeOperation.cpp @@ -59,9 +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->enableAcquisition(false); + graphWidget->setFlags(GraphFlag::DisableAll); graphWidget->setGraphRange(impl->m_Range); - graphWidget->enableAcquisition(true); + graphWidget->setFlags(GraphFlag::EnableAll); } } else {