##// END OF EJS Templates
Implementation of the calibration for the synchronization...
perrinel -
r411:a75bae0e8d4d
parent child
Show More
@@ -71,6 +71,10 private slots:
71 71
72 72 /// Slot called when a mouse wheel was made, to perform some processing before the zoom is done
73 73 void onMouseWheel(QWheelEvent *event) noexcept;
74 /// Slot called when a mouse press was made, to activate the calibration of a graph
75 void onMousePress(QMouseEvent *event) noexcept;
76 /// Slot called when a mouse release was made, to deactivate the calibration of a graph
77 void onMouseRelease(QMouseEvent *event) noexcept;
74 78
75 79 void onDataCacheVariableUpdated();
76 80 };
@@ -25,12 +25,17 const auto VERTICAL_ZOOM_MODIFIER = Qt::ControlModifier;
25 25
26 26 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
27 27
28 explicit VisualizationGraphWidgetPrivate() : m_DoSynchronize(true) {}
28 explicit VisualizationGraphWidgetPrivate() : m_DoSynchronize(true), m_IsCalibration(false) {}
29
30
31 // Return the operation when range changed
32 VisualizationGraphWidgetZoomType getZoomType(const QCPRange &t1, const QCPRange &t2);
29 33
30 34 // 1 variable -> n qcpplot
31 35 std::multimap<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMultiMap;
32 36
33 37 bool m_DoSynchronize;
38 bool m_IsCalibration;
34 39 };
35 40
36 41 VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget *parent)
@@ -52,10 +57,13 VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget
52 57 // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation
53 58 ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
54 59 ui->widget->axisRect()->setRangeDrag(Qt::Horizontal);
60 connect(ui->widget, &QCustomPlot::mousePress, this, &VisualizationGraphWidget::onMousePress);
61 connect(ui->widget, &QCustomPlot::mouseRelease, this,
62 &VisualizationGraphWidget::onMouseRelease);
55 63 connect(ui->widget, &QCustomPlot::mouseWheel, this, &VisualizationGraphWidget::onMouseWheel);
56 64 connect(ui->widget->xAxis, static_cast<void (QCPAxis::*)(const QCPRange &, const QCPRange &)>(
57 65 &QCPAxis::rangeChanged),
58 this, &VisualizationGraphWidget::onRangeChanged);
66 this, &VisualizationGraphWidget::onRangeChanged, Qt::DirectConnection);
59 67
60 68 // Activates menu when right clicking on the graph
61 69 ui->widget->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -149,8 +157,7 SqpDateTime VisualizationGraphWidget::graphRange()
149 157
150 158 void VisualizationGraphWidget::setGraphRange(const SqpDateTime &range)
151 159 {
152 qCDebug(LOG_VisualizationGraphWidget())
153 << tr("VisualizationGraphWidget::setGraphRange START");
160 qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::setGraphRange START");
154 161 ui->widget->xAxis->setRange(range.m_TStart, range.m_TEnd);
155 162 ui->widget->replot();
156 163 qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::setGraphRange END");
@@ -216,7 +223,7 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange
216 223
217 224 auto dateTimeRange = SqpDateTime{t1.lower, t1.upper};
218 225
219 auto zoomType = VisualizationGraphWidgetZoomType::ZoomOut;
226 auto zoomType = impl->getZoomType(t1, t2);
220 227 for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
221 228 it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
222 229
@@ -240,14 +247,13 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange
240 247 if (!variable->isInside(currentDateTime)) {
241 248 auto variableDateTime = variable->dateTime();
242 249 if (variable->contains(variableDateTimeWithTolerance)) {
243 qCInfo(LOG_VisualizationGraphWidget())
250 qCDebug(LOG_VisualizationGraphWidget())
244 251 << tr("TORM: Detection zoom in that need request:");
245 252 // add 10% tolerance for each side
246 253 tolerance
247 254 = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
248 255 variableDateTimeWithTolerance.m_TStart -= tolerance;
249 256 variableDateTimeWithTolerance.m_TEnd += tolerance;
250 zoomType = VisualizationGraphWidgetZoomType::ZoomIn;
251 257 }
252 258 else if (variableDateTime.m_TStart < currentDateTime.m_TStart) {
253 259 qCInfo(LOG_VisualizationGraphWidget()) << tr("TORM: Detection pan to right:");
@@ -259,10 +265,9 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange
259 265 tolerance
260 266 = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
261 267 variableDateTimeWithTolerance.m_TEnd += tolerance;
262 zoomType = VisualizationGraphWidgetZoomType::PanRight;
263 268 }
264 269 else if (variableDateTime.m_TEnd > currentDateTime.m_TEnd) {
265 qCInfo(LOG_VisualizationGraphWidget()) << tr("TORM: Detection pan to left: ");
270 qCDebug(LOG_VisualizationGraphWidget()) << tr("TORM: Detection pan to left: ");
266 271 auto diffStartToKeepDelta
267 272 = variableDateTime.m_TStart - currentDateTime.m_TStart;
268 273 currentDateTime.m_TEnd = variableDateTime.m_TEnd - diffStartToKeepDelta;
@@ -271,16 +276,14 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange
271 276 tolerance
272 277 = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
273 278 variableDateTimeWithTolerance.m_TStart -= tolerance;
274 zoomType = VisualizationGraphWidgetZoomType::PanLeft;
275 279 }
276 280 else {
277 qCInfo(LOG_VisualizationGraphWidget())
281 qCCritical(LOG_VisualizationGraphWidget())
278 282 << tr("Detection anormal zoom detection: ");
279 zoomType = VisualizationGraphWidgetZoomType::Unknown;
280 283 }
281 284 }
282 285 else {
283 qCInfo(LOG_VisualizationGraphWidget()) << tr("TORM: Detection zoom out: ");
286 qCDebug(LOG_VisualizationGraphWidget()) << tr("TORM: Detection zoom out: ");
284 287 // add 10% tolerance for each side
285 288 tolerance = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
286 289 variableDateTimeWithTolerance.m_TStart -= tolerance;
@@ -288,12 +291,12 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange
288 291 zoomType = VisualizationGraphWidgetZoomType::ZoomOut;
289 292 }
290 293 if (!variable->contains(dateTimeRange)) {
291 qCInfo(LOG_VisualizationGraphWidget())
294 qCDebug(LOG_VisualizationGraphWidget())
292 295 << "TORM: Modif on variable datetime detected" << currentDateTime;
293 296 variable->setDateTime(currentDateTime);
294 297 }
295 298
296 qCInfo(LOG_VisualizationGraphWidget()) << tr("TORM: Request data detection: ");
299 qCDebug(LOG_VisualizationGraphWidget()) << tr("TORM: Request data detection: ");
297 300 // CHangement detected, we need to ask controller to request data loading
298 301 emit requestDataLoading(variable, variableDateTimeWithTolerance);
299 302 }
@@ -304,7 +307,7 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange
304 307 }
305 308 }
306 309
307 if (impl->m_DoSynchronize) {
310 if (impl->m_DoSynchronize && !impl->m_IsCalibration) {
308 311 auto oldDateTime = SqpDateTime{t2.lower, t2.upper};
309 312 qCDebug(LOG_VisualizationGraphWidget())
310 313 << tr("TORM: VisualizationGraphWidget::Synchronize notify !!")
@@ -331,6 +334,16 void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept
331 334 ui->widget->axisRect()->setRangeZoom(zoomOrientations);
332 335 }
333 336
337 void VisualizationGraphWidget::onMousePress(QMouseEvent *event) noexcept
338 {
339 impl->m_IsCalibration = event->modifiers().testFlag(Qt::ControlModifier);
340 }
341
342 void VisualizationGraphWidget::onMouseRelease(QMouseEvent *event) noexcept
343 {
344 impl->m_IsCalibration = false;
345 }
346
334 347 void VisualizationGraphWidget::onDataCacheVariableUpdated()
335 348 {
336 349 // NOTE:
@@ -360,3 +373,27 void VisualizationGraphWidget::onDataCacheVariableUpdated()
360 373 }
361 374 }
362 375 }
376
377 VisualizationGraphWidgetZoomType
378 VisualizationGraphWidget::VisualizationGraphWidgetPrivate::getZoomType(const QCPRange &t1,
379 const QCPRange &t2)
380 {
381 // t1.lower <= t2.lower && t2.upper <= t1.upper
382 auto zoomType = VisualizationGraphWidgetZoomType::Unknown;
383 if (t1.lower <= t2.lower && t2.upper <= t1.upper) {
384 zoomType = VisualizationGraphWidgetZoomType::ZoomOut;
385 }
386 else if (t1.lower > t2.lower && t1.upper > t2.upper) {
387 zoomType = VisualizationGraphWidgetZoomType::PanRight;
388 }
389 else if (t1.lower < t2.lower && t1.upper < t2.upper) {
390 zoomType = VisualizationGraphWidgetZoomType::PanLeft;
391 }
392 else if (t1.lower > t2.lower && t2.upper > t1.upper) {
393 zoomType = VisualizationGraphWidgetZoomType::ZoomIn;
394 }
395 else {
396 qCCritical(LOG_VisualizationGraphWidget()) << "getZoomType: Unknown type detected";
397 }
398 return zoomType;
399 }
@@ -79,7 +79,6 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V
79 79 = dynamic_cast<VisualizationGraphWidget *>(frameLayout->itemAt(i)->widget());
80 80 if (graphChild && (graphChild != graphWidget)) {
81 81
82 auto dateTimeThatKeepDelta = dateTime;
83 82 auto graphChildRange = graphChild->graphRange();
84 83 switch (zoomType) {
85 84 case VisualizationGraphWidgetZoomType::ZoomIn: {
@@ -87,30 +86,45 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V
87 86 auto deltaRight = oldDateTime.m_TEnd - dateTime.m_TEnd;
88 87 graphChildRange.m_TStart += deltaLeft;
89 88 graphChildRange.m_TEnd -= deltaRight;
90 dateTimeThatKeepDelta = graphChildRange;
89 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomIn");
90 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
91 << deltaLeft;
92 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
93 << deltaRight;
94 qCCritical(LOG_VisualizationZoneWidget())
95 << tr("TORM: dt") << dateTime.m_TEnd - dateTime.m_TStart;
96
91 97 break;
92 98 }
93 99
94 100 case VisualizationGraphWidgetZoomType::ZoomOut: {
101 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomOut");
95 102 auto deltaLeft = oldDateTime.m_TStart - dateTime.m_TStart;
96 103 auto deltaRight = dateTime.m_TEnd - oldDateTime.m_TEnd;
104 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
105 << deltaLeft;
106 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
107 << deltaRight;
108 qCCritical(LOG_VisualizationZoneWidget())
109 << tr("TORM: dt") << dateTime.m_TEnd - dateTime.m_TStart;
97 110 graphChildRange.m_TStart -= deltaLeft;
98 111 graphChildRange.m_TEnd += deltaRight;
99 dateTimeThatKeepDelta = graphChildRange;
100 112 break;
101 113 }
102 114 case VisualizationGraphWidgetZoomType::PanRight: {
115 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: PanRight");
103 116 auto deltaRight = dateTime.m_TEnd - oldDateTime.m_TEnd;
104 117 graphChildRange.m_TStart += deltaRight;
105 118 graphChildRange.m_TEnd += deltaRight;
106 dateTimeThatKeepDelta = graphChildRange;
119 qCCritical(LOG_VisualizationZoneWidget())
120 << tr("TORM: dt") << dateTime.m_TEnd - dateTime.m_TStart;
107 121 break;
108 122 }
109 123 case VisualizationGraphWidgetZoomType::PanLeft: {
124 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: PanLeft");
110 125 auto deltaLeft = oldDateTime.m_TStart - dateTime.m_TStart;
111 126 graphChildRange.m_TStart -= deltaLeft;
112 127 graphChildRange.m_TEnd -= deltaLeft;
113 dateTimeThatKeepDelta = graphChildRange;
114 128 break;
115 129 }
116 130 case VisualizationGraphWidgetZoomType::Unknown: {
@@ -125,7 +139,13 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V
125 139 break;
126 140 }
127 141 graphChild->enableSynchronize(false);
128 graphChild->setGraphRange(dateTimeThatKeepDelta);
142 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ")
143 << graphChild->graphRange();
144 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ")
145 << graphChildRange;
146 qCCritical(LOG_VisualizationZoneWidget())
147 << tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart;
148 graphChild->setGraphRange(graphChildRange);
129 149 graphChild->enableSynchronize(true);
130 150 }
131 151 }
General Comments 3
Under Review
author

Pull request updated. Auto status change to "Under Review"

Changed commits:
  * 3 added
  * 0 removed

Changed files:
  * A plugins/amda/tests-resources/TestAmdaResultParser/FileNotFound.txt
  * M gui/src/Visualization/operations/RescaleAxeOperation.cpp
  * M app/src/MainWindow.cpp
  * M core/include/Data/IDataProvider.h
  * M core/include/DataSource/DataSourceItemAction.h
  * M core/include/Variable/VariableController.h
  * M core/include/Variable/VariableModel.h
  * M core/include/Visualization/VisualizationController.h
  * M core/src/Network/NetworkController.cpp
  * M core/src/Variable/Variable.cpp
  * M core/src/Variable/VariableController.cpp
  * M core/src/Variable/VariableModel.cpp
  * M gui/include/Visualization/VisualizationGraphWidget.h
  * M gui/include/Visualization/VisualizationWidget.h
  * M gui/src/SqpApplication.cpp
  * M gui/src/Variable/VariableInspectorWidget.cpp
  * M gui/src/Visualization/VisualizationGraphHelper.cpp
  * M gui/src/Visualization/VisualizationGraphWidget.cpp
  * M gui/src/Visualization/VisualizationWidget.cpp
  * M gui/src/Visualization/VisualizationZoneWidget.cpp
  * M plugins/amda/include/AmdaProvider.h
  * M plugins/amda/src/AmdaProvider.cpp
  * M plugins/amda/src/AmdaResultParser.cpp
  * M plugins/amda/tests/TestAmdaResultParser.cpp
  * M plugins/mockplugin/include/CosinusProvider.h
  * M plugins/mockplugin/src/CosinusProvider.cpp
  * R COPYING
  * R app/ui/MainWindow.ui
  * R cmake/sciqlop_package_qt.cmake
  * R core/include/Common/MetaTypes.h
  * R core/include/Data/ArrayData.h
  * R core/include/Data/DataProviderParameters.h
  * R core/include/Data/DataSeries.h
  * R core/include/Data/IDataSeries.h
  * R core/include/Data/ScalarSeries.h
  * R core/include/Data/SqpDateTime.h
  * R core/include/Network/NetworkController.h
  * R core/include/Plugin/PluginManager.h
  * R core/include/Time/TimeController.h
  * R core/include/Variable/Variable.h
  * R core/include/Variable/VariableCacheController.h
  * R core/src/Data/ScalarSeries.cpp
  * R core/src/DataSource/DataSourceItemAction.cpp
  * R core/src/Plugin/PluginManager.cpp
  * R core/src/Time/TimeController.cpp
  * R core/src/Variable/VariableCacheController.cpp
  * R core/src/Visualization/VisualizationController.cpp
  * R core/tests/Variable/TestVariableCacheController.cpp
  * R gui/include/DataSource/DataSourceTreeWidgetItem.h
  * R gui/include/DataSource/DataSourceWidget.h
  * R gui/include/SidePane/SqpSidePane.h
  * R gui/include/TimeWidget/TimeWidget.h
  * R gui/include/Variable/VariableInspectorWidget.h
  * R gui/include/Variable/VariableMenuHeaderWidget.h
  * R gui/include/Visualization/IVariableContainer.h
  * R gui/include/Visualization/IVisualizationWidget.h
  * R gui/include/Visualization/IVisualizationWidgetVisitor.h
  * R gui/include/Visualization/VisualizationGraphHelper.h
  * R gui/include/Visualization/VisualizationTabWidget.h
  * R gui/include/Visualization/VisualizationZoneWidget.h
  * R gui/include/Visualization/operations/GenerateVariableMenuOperation.h
  * R gui/include/Visualization/operations/MenuBuilder.h
  * R gui/include/Visualization/operations/RemoveVariableOperation.h
  * R gui/include/Visualization/qcustomplot.h
  * R gui/resources/icones/dataSourceComponent.png
  * R gui/resources/icones/dataSourceNode.png
  * R gui/resources/icones/dataSourceProduct.png
  * R gui/resources/icones/dataSourceRoot.png
  * R gui/resources/icones/delete.png
  * R gui/resources/icones/next.png
  * R gui/resources/icones/openInspector.png
  * R gui/resources/icones/plot.png
  * R gui/resources/icones/previous.png
  * R gui/resources/icones/sciqlop2PNG_1024.png
  * R gui/resources/icones/unplot.png
  * R gui/resources/sqpguiresources.qrc
  * R gui/src/DataSource/DataSourceTreeWidgetItem.cpp
  * R gui/src/DataSource/DataSourceWidget.cpp
  * R gui/src/SidePane/SqpSidePane.cpp
  * R gui/src/TimeWidget/TimeWidget.cpp
  * R gui/src/Variable/VariableMenuHeaderWidget.cpp
  * R gui/src/Visualization/VisualizationTabWidget.cpp
  * R gui/src/Visualization/operations/GenerateVariableMenuOperation.cpp
  * R gui/src/Visualization/operations/MenuBuilder.cpp
  * R gui/src/Visualization/operations/RemoveVariableOperation.cpp
  * R gui/src/Visualization/qcustomplot.cpp
  * R gui/ui/DataSource/DataSourceWidget.ui
  * R gui/ui/SidePane/SqpSidePane.ui
  * R gui/ui/TimeWidget/TimeWidget.ui
  * R gui/ui/Variable/VariableInspectorWidget.ui
  * R gui/ui/Variable/VariableMenuHeaderWidget.ui
  * R gui/ui/Visualization/VisualizationGraphWidget.ui
  * R gui/ui/Visualization/VisualizationTabWidget.ui
  * R gui/ui/Visualization/VisualizationWidget.ui
  * R gui/ui/Visualization/VisualizationZoneWidget.ui
  * R gui/vera-exclusions/exclusions.txt
  * R plugin/CMakeLists.txt
  * R plugin/cmake/Findsciqlop-plugin.cmake
  * R plugin/include/Plugin/IPlugin.h
  * R plugins/amda/CMakeLists.txt
  * R plugins/amda/cmake/Findsciqlop-amda.cmake
  * R plugins/amda/include/AmdaDefs.h
  * R plugins/amda/include/AmdaGlobal.h
  * R plugins/amda/include/AmdaParser.h
  * R plugins/amda/include/AmdaPlugin.h
  * R plugins/amda/include/AmdaResultParser.h
  * R plugins/amda/resources/amda.json
  * R plugins/amda/resources/amdaresources.qrc
  * R plugins/amda/resources/samples/AmdaSample.json
  * R plugins/amda/src/AmdaDefs.cpp
  * R plugins/amda/src/AmdaParser.cpp
  * R plugins/amda/src/AmdaPlugin.cpp
  * R plugins/amda/tests-resources/TestAmdaParser/TwoRootsFile.json
  * R plugins/amda/tests-resources/TestAmdaParser/ValidFile1.json
  * R plugins/amda/tests-resources/TestAmdaParser/WrongRootKey.json
  * R plugins/amda/tests-resources/TestAmdaParser/WrongRootType.json
  * R plugins/amda/tests-resources/TestAmdaResultParser/NaNValue.txt
  * R plugins/amda/tests-resources/TestAmdaResultParser/NoUnit.txt
  * R plugins/amda/tests-resources/TestAmdaResultParser/TooManyValues.txt
  * R plugins/amda/tests-resources/TestAmdaResultParser/ValidScalar1.txt
  * R plugins/amda/tests-resources/TestAmdaResultParser/WrongDate.txt
  * R plugins/amda/tests-resources/TestAmdaResultParser/WrongUnit.txt
  * R plugins/amda/tests-resources/TestAmdaResultParser/WrongValue.txt
  * R plugins/amda/tests/TestAmdaParser.cpp
  * R plugins/mockplugin/CMakeLists.txt
  * R plugins/mockplugin/cmake/Findsciqlop-mockplugin.cmake
  * R plugins/mockplugin/include/MockPlugin.h
  * R plugins/mockplugin/include/MockPluginGlobal.h
  * R plugins/mockplugin/resources/mockplugin.json
  * R plugins/mockplugin/src/MockPlugin.cpp
  * R README.md
  * R app/CMakeLists.txt
  * R app/include/MainWindow.h
  * R app/src/Main.cpp
  * R app/vera-exclusions/exclusions.txt
  * R cmake/sciqlop.cmake
  * R cmake/sciqlop_applications.cmake
  * R cmake/sciqlop_package.cmake
  * R cmake/sciqlop_params.cmake
  * R core/CMakeLists.txt
  * R core/include/Common/spimpl.h
  * R core/include/DataSource/DataSourceController.h
  * R core/include/DataSource/DataSourceItem.h
  * R core/src/DataSource/DataSourceController.cpp
  * R core/src/DataSource/DataSourceItem.cpp
  * R core/tests/DataSource/TestDataSourceController.cpp
  * R core/vera-exclusions/exclusions.txt
  * R formatting/cmake/use_clangformat.cmake
  * R formatting/vera-exclusions/exclusions.txt
  * R gui/CMakeLists.txt
  * R gui/include/SqpApplication.h
  * R LICENSE
  * R app/src/mainwindow.cpp
  * R app/src/mainwindow.ui
Approved
author

Status change > Approved

You need to be logged in to leave comments. Login now