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