@@ -0,0 +1,18 | |||||
|
1 | #ifndef SCIQLOP_VISUALIZATIONGRAPHRENDERINGDELEGATE_H | |||
|
2 | #define SCIQLOP_VISUALIZATIONGRAPHRENDERINGDELEGATE_H | |||
|
3 | ||||
|
4 | #include <Common/spimpl.h> | |||
|
5 | ||||
|
6 | class QCustomPlot; | |||
|
7 | class QMouseEvent; | |||
|
8 | ||||
|
9 | class VisualizationGraphRenderingDelegate { | |||
|
10 | public: | |||
|
11 | explicit VisualizationGraphRenderingDelegate(QCustomPlot &plot); | |||
|
12 | ||||
|
13 | private: | |||
|
14 | class VisualizationGraphRenderingDelegatePrivate; | |||
|
15 | spimpl::unique_impl_ptr<VisualizationGraphRenderingDelegatePrivate> impl; | |||
|
16 | }; | |||
|
17 | ||||
|
18 | #endif // SCIQLOP_VISUALIZATIONGRAPHRENDERINGDELEGATE_H |
@@ -0,0 +1,13 | |||||
|
1 | #include "Visualization/VisualizationGraphRenderingDelegate.h" | |||
|
2 | #include "Visualization/qcustomplot.h" | |||
|
3 | ||||
|
4 | struct VisualizationGraphRenderingDelegate::VisualizationGraphRenderingDelegatePrivate { | |||
|
5 | explicit VisualizationGraphRenderingDelegatePrivate(QCustomPlot &plot) : m_Plot{plot} {} | |||
|
6 | ||||
|
7 | QCustomPlot &m_Plot; | |||
|
8 | }; | |||
|
9 | ||||
|
10 | VisualizationGraphRenderingDelegate::VisualizationGraphRenderingDelegate(QCustomPlot &plot) | |||
|
11 | : impl{spimpl::make_unique_impl<VisualizationGraphRenderingDelegatePrivate>(plot)} | |||
|
12 | { | |||
|
13 | } |
@@ -1,6 +1,7 | |||||
1 | #include "Visualization/VisualizationGraphWidget.h" |
|
1 | #include "Visualization/VisualizationGraphWidget.h" | |
2 | #include "Visualization/IVisualizationWidgetVisitor.h" |
|
2 | #include "Visualization/IVisualizationWidgetVisitor.h" | |
3 | #include "Visualization/VisualizationGraphHelper.h" |
|
3 | #include "Visualization/VisualizationGraphHelper.h" | |
|
4 | #include "Visualization/VisualizationGraphRenderingDelegate.h" | |||
4 | #include "ui_VisualizationGraphWidget.h" |
|
5 | #include "ui_VisualizationGraphWidget.h" | |
5 |
|
6 | |||
6 | #include <Data/ArrayData.h> |
|
7 | #include <Data/ArrayData.h> | |
@@ -33,17 +34,21 double toleranceValue(const QString &key, double defaultValue) noexcept | |||||
33 |
|
34 | |||
34 | struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate { |
|
35 | struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate { | |
35 |
|
36 | |||
36 |
explicit VisualizationGraphWidgetPrivate() |
|
37 | explicit VisualizationGraphWidgetPrivate() | |
37 |
|
38 | : m_DoSynchronize{true}, m_IsCalibration{false}, m_RenderingDelegate{nullptr} | ||
|
39 | { | |||
|
40 | } | |||
38 |
|
41 | |||
39 | // Return the operation when range changed |
|
42 | // Return the operation when range changed | |
40 | VisualizationGraphWidgetZoomType getZoomType(const QCPRange &t1, const QCPRange &t2); |
|
43 | VisualizationGraphWidgetZoomType getZoomType(const QCPRange &t1, const QCPRange &t2); | |
41 |
|
44 | |||
42 | // 1 variable -> n qcpplot |
|
45 | // 1 variable -> n qcpplot | |
43 | std::multimap<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMultiMap; |
|
46 | std::multimap<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMultiMap; | |
44 |
|
||||
45 | bool m_DoSynchronize; |
|
47 | bool m_DoSynchronize; | |
46 | bool m_IsCalibration; |
|
48 | bool m_IsCalibration; | |
|
49 | QCPItemTracer *m_TextTracer; | |||
|
50 | /// Delegate used to attach rendering features to the plot | |||
|
51 | std::unique_ptr<VisualizationGraphRenderingDelegate> m_RenderingDelegate; | |||
47 | }; |
|
52 | }; | |
48 |
|
53 | |||
49 | VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget *parent) |
|
54 | VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget *parent) | |
@@ -53,6 +58,9 VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget | |||||
53 | { |
|
58 | { | |
54 | ui->setupUi(this); |
|
59 | ui->setupUi(this); | |
55 |
|
60 | |||
|
61 | // The delegate must be initialized after the ui as it uses the plot | |||
|
62 | impl->m_RenderingDelegate = std::make_unique<VisualizationGraphRenderingDelegate>(*ui->widget); | |||
|
63 | ||||
56 | ui->graphNameLabel->setText(name); |
|
64 | ui->graphNameLabel->setText(name); | |
57 |
|
65 | |||
58 | // 'Close' options : widget is deleted when closed |
|
66 | // 'Close' options : widget is deleted when closed |
General Comments 0
You need to be logged in to leave comments.
Login now