##// END OF EJS Templates
Corrects the problem of refreshing synchronized graphs from TimeWidget (1)...
Alexandre Leroux -
r1325:87a145505c37
parent child
Show More
@@ -25,6 +25,20 namespace Ui {
25 25 class VisualizationGraphWidget;
26 26 } // namespace Ui
27 27
28 /// Defines options that can be associated with the graph
29 enum GraphFlag {
30 DisableAll = 0x0, ///< Disables acquisition and synchronization
31 EnableAcquisition = 0x1, ///< When this flag is set, the change of the graph's range leads to
32 /// the acquisition of data
33 EnableSynchronization = 0x2, ///< When this flag is set, the change of the graph's range causes
34 /// the call to the synchronization of the graphs contained in the
35 /// same zone of this graph
36 EnableAll = ~DisableAll ///< Enables acquisition and synchronization
37 };
38
39 Q_DECLARE_FLAGS(GraphFlags, GraphFlag)
40 Q_DECLARE_OPERATORS_FOR_FLAGS(GraphFlags)
41
28 42 class VisualizationGraphWidget : public VisualizationDragWidget, public IVisualizationWidget {
29 43 Q_OBJECT
30 44
@@ -41,8 +55,8 public:
41 55 /// Returns the main VisualizationWidget which contains the graph or nullptr
42 56 VisualizationWidget *parentVisualizationWidget() const;
43 57
44 /// If acquisition isn't enable, requestDataLoading signal cannot be emit
45 void enableAcquisition(bool enable);
58 /// Sets graph options
59 void setFlags(GraphFlags flags);
46 60
47 61 void addVariable(std::shared_ptr<Variable> variable, SqpRange range);
48 62
@@ -59,7 +59,7 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
59 59
60 60 explicit VisualizationGraphWidgetPrivate(const QString &name)
61 61 : m_Name{name},
62 m_DoAcquisition{true},
62 m_Flags{GraphFlag::EnableAll},
63 63 m_IsCalibration{false},
64 64 m_RenderingDelegate{nullptr}
65 65 {
@@ -77,7 +77,7 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
77 77 QString m_Name;
78 78 // 1 variable -> n qcpplot
79 79 std::map<std::shared_ptr<Variable>, PlottablesMap> m_VariableToPlotMultiMap;
80 bool m_DoAcquisition;
80 GraphFlags m_Flags;
81 81 bool m_IsCalibration;
82 82 /// Delegate used to attach rendering features to the plot
83 83 std::unique_ptr<VisualizationGraphRenderingDelegate> m_RenderingDelegate;
@@ -287,9 +287,9 VisualizationWidget *VisualizationGraphWidget::parentVisualizationWidget() const
287 287 return qobject_cast<VisualizationWidget *>(parent);
288 288 }
289 289
290 void VisualizationGraphWidget::enableAcquisition(bool enable)
290 void VisualizationGraphWidget::setFlags(GraphFlags flags)
291 291 {
292 impl->m_DoAcquisition = enable;
292 impl->m_Flags = std::move(flags);
293 293 }
294 294
295 295 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable, SqpRange range)
@@ -311,9 +311,9 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable, S
311 311
312 312 connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated()));
313 313
314 this->enableAcquisition(false);
314 this->setFlags(GraphFlag::DisableAll);
315 315 this->setGraphRange(range);
316 this->enableAcquisition(true);
316 this->setFlags(GraphFlag::EnableAll);
317 317
318 318 emit requestDataLoading(QVector<std::shared_ptr<Variable> >() << variable, range, false);
319 319
@@ -696,12 +696,12 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange
696 696 {
697 697 qCDebug(LOG_VisualizationGraphWidget()) << tr("TORM: VisualizationGraphWidget::onRangeChanged")
698 698 << QThread::currentThread()->objectName() << "DoAcqui"
699 << impl->m_DoAcquisition;
699 << impl->m_Flags.testFlag(GraphFlag::EnableAcquisition);
700 700
701 701 auto graphRange = SqpRange{t1.lower, t1.upper};
702 702 auto oldGraphRange = SqpRange{t2.lower, t2.upper};
703 703
704 if (impl->m_DoAcquisition) {
704 if (impl->m_Flags.testFlag(GraphFlag::EnableAcquisition)) {
705 705 QVector<std::shared_ptr<Variable> > variableUnderGraphVector;
706 706
707 707 for (auto it = impl->m_VariableToPlotMultiMap.begin(),
@@ -264,15 +264,15 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V
264 264 // No action
265 265 break;
266 266 }
267 graphChild->enableAcquisition(false);
268 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ")
269 << graphChild->graphRange();
270 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ")
271 << graphChildRange;
267 graphChild->setFlags(GraphFlag::DisableAll);
268 qCDebug(LOG_VisualizationZoneWidget())
269 << tr("TORM: Range before: ") << graphChild->graphRange();
270 qCDebug(LOG_VisualizationZoneWidget())
271 << tr("TORM: Range after : ") << graphChildRange;
272 272 qCDebug(LOG_VisualizationZoneWidget())
273 273 << tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart;
274 274 graphChild->setGraphRange(graphChildRange);
275 graphChild->enableAcquisition(true);
275 graphChild->setFlags(GraphFlag::EnableAll);
276 276 }
277 277 }
278 278 };
@@ -59,9 +59,9 void RescaleAxeOperation::visit(VisualizationGraphWidget *graphWidget)
59 59 if (graphWidget) {
60 60 // If the widget contains the variable, rescale it
61 61 if (impl->m_Variable && graphWidget->contains(*impl->m_Variable)) {
62 graphWidget->enableAcquisition(false);
62 graphWidget->setFlags(GraphFlag::DisableAll);
63 63 graphWidget->setGraphRange(impl->m_Range);
64 graphWidget->enableAcquisition(true);
64 graphWidget->setFlags(GraphFlag::EnableAll);
65 65 }
66 66 }
67 67 else {
General Comments 0
You need to be logged in to leave comments. Login now