##// END OF EJS Templates
Handles double click on color scale...
Alexandre Leroux -
r1043:4ab6e8aca534
parent child
Show More
@@ -18,6 +18,7 public:
18 /// @remarks the graph widget must exist throughout the life cycle of the delegate
18 /// @remarks the graph widget must exist throughout the life cycle of the delegate
19 explicit VisualizationGraphRenderingDelegate(VisualizationGraphWidget &graphWidget);
19 explicit VisualizationGraphRenderingDelegate(VisualizationGraphWidget &graphWidget);
20
20
21 void onMouseDoubleClick(QMouseEvent *event) noexcept;
21 void onMouseMove(QMouseEvent *event) noexcept;
22 void onMouseMove(QMouseEvent *event) noexcept;
22
23
23 /// Sets properties of the plot's axes from the data series passed as parameter
24 /// Sets properties of the plot's axes from the data series passed as parameter
@@ -104,6 +104,8 private slots:
104 /// Rescale the X axe to range parameter
104 /// Rescale the X axe to range parameter
105 void onRangeChanged(const QCPRange &t1, const QCPRange &t2);
105 void onRangeChanged(const QCPRange &t1, const QCPRange &t2);
106
106
107 /// Slot called when a mouse double click was made
108 void onMouseDoubleClick(QMouseEvent *event) noexcept;
107 /// Slot called when a mouse move was made
109 /// Slot called when a mouse move was made
108 void onMouseMove(QMouseEvent *event) noexcept;
110 void onMouseMove(QMouseEvent *event) noexcept;
109 /// Slot called when a mouse wheel was made, to perform some processing before the zoom is done
111 /// Slot called when a mouse wheel was made, to perform some processing before the zoom is done
@@ -1,5 +1,6
1 #include "Visualization/VisualizationGraphRenderingDelegate.h"
1 #include "Visualization/VisualizationGraphRenderingDelegate.h"
2 #include "Visualization/AxisRenderingUtils.h"
2 #include "Visualization/AxisRenderingUtils.h"
3 #include "Visualization/ColorScaleEditor.h"
3 #include "Visualization/PlottablesRenderingUtils.h"
4 #include "Visualization/PlottablesRenderingUtils.h"
4 #include "Visualization/VisualizationGraphWidget.h"
5 #include "Visualization/VisualizationGraphWidget.h"
5 #include "Visualization/qcustomplot.h"
6 #include "Visualization/qcustomplot.h"
@@ -172,6 +173,15 VisualizationGraphRenderingDelegate::VisualizationGraphRenderingDelegate(
172 {
173 {
173 }
174 }
174
175
176 void VisualizationGraphRenderingDelegate::onMouseDoubleClick(QMouseEvent *event) noexcept
177 {
178 // Opens color scale editor if color scale is double clicked
179 if (auto colorScale
180 = dynamic_cast<QCPColorScale *>(impl->m_Plot.layoutElementAt(event->pos()))) {
181 ColorScaleEditor{}.exec();
182 }
183 }
184
175 void VisualizationGraphRenderingDelegate::onMouseMove(QMouseEvent *event) noexcept
185 void VisualizationGraphRenderingDelegate::onMouseMove(QMouseEvent *event) noexcept
176 {
186 {
177 // Cancels pending refresh
187 // Cancels pending refresh
@@ -141,6 +141,8 VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget
141 &VisualizationGraphWidget::onMouseRelease);
141 &VisualizationGraphWidget::onMouseRelease);
142 connect(ui->widget, &QCustomPlot::mouseMove, this, &VisualizationGraphWidget::onMouseMove);
142 connect(ui->widget, &QCustomPlot::mouseMove, this, &VisualizationGraphWidget::onMouseMove);
143 connect(ui->widget, &QCustomPlot::mouseWheel, this, &VisualizationGraphWidget::onMouseWheel);
143 connect(ui->widget, &QCustomPlot::mouseWheel, this, &VisualizationGraphWidget::onMouseWheel);
144 connect(ui->widget, &QCustomPlot::mouseDoubleClick, this,
145 &VisualizationGraphWidget::onMouseDoubleClick);
144 connect(ui->widget->xAxis, static_cast<void (QCPAxis::*)(const QCPRange &, const QCPRange &)>(
146 connect(ui->widget->xAxis, static_cast<void (QCPAxis::*)(const QCPRange &, const QCPRange &)>(
145 &QCPAxis::rangeChanged),
147 &QCPAxis::rangeChanged),
146 this, &VisualizationGraphWidget::onRangeChanged, Qt::DirectConnection);
148 this, &VisualizationGraphWidget::onRangeChanged, Qt::DirectConnection);
@@ -476,6 +478,11 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange
476 }
478 }
477 }
479 }
478
480
481 void VisualizationGraphWidget::onMouseDoubleClick(QMouseEvent *event) noexcept
482 {
483 impl->m_RenderingDelegate->onMouseDoubleClick(event);
484 }
485
479 void VisualizationGraphWidget::onMouseMove(QMouseEvent *event) noexcept
486 void VisualizationGraphWidget::onMouseMove(QMouseEvent *event) noexcept
480 {
487 {
481 // Handles plot rendering when mouse is moving
488 // Handles plot rendering when mouse is moving
General Comments 0
You need to be logged in to leave comments. Login now