@@ -5,10 +5,14 | |||
|
5 | 5 | |
|
6 | 6 | class QCustomPlot; |
|
7 | 7 | class QMouseEvent; |
|
8 | class VisualizationGraphWidget; | |
|
8 | 9 | |
|
9 | 10 | class VisualizationGraphRenderingDelegate { |
|
10 | 11 | public: |
|
11 | explicit VisualizationGraphRenderingDelegate(QCustomPlot &plot); | |
|
12 | /// Ctor | |
|
13 | /// @param graphWidget the graph widget to which the delegate is associated | |
|
14 | /// @remarks the graph widget must exist throughout the life cycle of the delegate | |
|
15 | explicit VisualizationGraphRenderingDelegate(VisualizationGraphWidget &graphWidget); | |
|
12 | 16 | |
|
13 | 17 | void onMouseMove(QMouseEvent *event) noexcept; |
|
14 | 18 |
@@ -13,6 +13,7 | |||
|
13 | 13 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationGraphWidget) |
|
14 | 14 | |
|
15 | 15 | class QCPRange; |
|
16 | class QCustomPlot; | |
|
16 | 17 | class SqpRange; |
|
17 | 18 | class Variable; |
|
18 | 19 | |
@@ -23,6 +24,8 class VisualizationGraphWidget; | |||
|
23 | 24 | class VisualizationGraphWidget : public QWidget, public IVisualizationWidget { |
|
24 | 25 | Q_OBJECT |
|
25 | 26 | |
|
27 | friend class VisualizationGraphRenderingDelegate; | |
|
28 | ||
|
26 | 29 | public: |
|
27 | 30 | explicit VisualizationGraphWidget(const QString &name = {}, QWidget *parent = 0); |
|
28 | 31 | virtual ~VisualizationGraphWidget(); |
@@ -52,10 +55,11 signals: | |||
|
52 | 55 | void requestDataLoading(QVector<std::shared_ptr<Variable> > variable, const SqpRange &range, |
|
53 | 56 | const SqpRange &oldRange, bool synchronise); |
|
54 | 57 | |
|
55 | ||
|
56 | 58 | void variableAdded(std::shared_ptr<Variable> var); |
|
57 | 59 | |
|
58 | 60 | |
|
61 | QCustomPlot &plot() noexcept; | |
|
62 | ||
|
59 | 63 | private: |
|
60 | 64 | Ui::VisualizationGraphWidget *ui; |
|
61 | 65 |
@@ -1,4 +1,5 | |||
|
1 | 1 | #include "Visualization/VisualizationGraphRenderingDelegate.h" |
|
2 | #include "Visualization/VisualizationGraphWidget.h" | |
|
2 | 3 | #include "Visualization/qcustomplot.h" |
|
3 | 4 | |
|
4 | 5 | #include <Common/DateUtils.h> |
@@ -42,8 +43,10 void initPointTracerStyle(QCPItemTracer &tracer) noexcept | |||
|
42 | 43 | } // namespace |
|
43 | 44 | |
|
44 | 45 | struct VisualizationGraphRenderingDelegate::VisualizationGraphRenderingDelegatePrivate { |
|
45 |
explicit VisualizationGraphRenderingDelegatePrivate( |
|
|
46 | : m_Plot{plot}, m_PointTracer{new QCPItemTracer{&plot}}, m_TracerTimer{} | |
|
46 | explicit VisualizationGraphRenderingDelegatePrivate(VisualizationGraphWidget &graphWidget) | |
|
47 | : m_Plot{graphWidget.plot()}, | |
|
48 | m_PointTracer{new QCPItemTracer{&m_Plot}}, | |
|
49 | m_TracerTimer{}, | |
|
47 | 50 | { |
|
48 | 51 | initPointTracerStyle(*m_PointTracer); |
|
49 | 52 | |
@@ -56,8 +59,9 struct VisualizationGraphRenderingDelegate::VisualizationGraphRenderingDelegateP | |||
|
56 | 59 | QTimer m_TracerTimer; |
|
57 | 60 | }; |
|
58 | 61 | |
|
59 |
VisualizationGraphRenderingDelegate::VisualizationGraphRenderingDelegate( |
|
|
60 | : impl{spimpl::make_unique_impl<VisualizationGraphRenderingDelegatePrivate>(plot)} | |
|
62 | VisualizationGraphRenderingDelegate::VisualizationGraphRenderingDelegate( | |
|
63 | VisualizationGraphWidget &graphWidget) | |
|
64 | : impl{spimpl::make_unique_impl<VisualizationGraphRenderingDelegatePrivate>(graphWidget)} | |
|
61 | 65 | { |
|
62 | 66 | } |
|
63 | 67 |
@@ -204,6 +204,11 QString VisualizationGraphWidget::name() const | |||
|
204 | 204 | return impl->m_Name; |
|
205 | 205 | } |
|
206 | 206 | |
|
207 | QCustomPlot &VisualizationGraphWidget::plot() noexcept | |
|
208 | { | |
|
209 | return *ui->widget; | |
|
210 | } | |
|
211 | ||
|
207 | 212 | void VisualizationGraphWidget::onGraphMenuRequested(const QPoint &pos) noexcept |
|
208 | 213 | { |
|
209 | 214 | QMenu graphMenu{}; |
General Comments 0
You need to be logged in to leave comments.
Login now