##// END OF EJS Templates
Inits tracers and timer...
Alexandre Leroux -
r482:fff83e9eed4b
parent child
Show More
@@ -1,17 +1,46
1 1 #include "Visualization/VisualizationGraphRenderingDelegate.h"
2 2 #include "Visualization/qcustomplot.h"
3 3
4 namespace {
5
6 /// Timeout after which a tracer is displayed
7 const auto TRACER_TIMEOUT = 500;
8
9 } // namespace
10
4 11 struct VisualizationGraphRenderingDelegate::VisualizationGraphRenderingDelegatePrivate {
5 explicit VisualizationGraphRenderingDelegatePrivate(QCustomPlot &plot) : m_Plot{plot} {}
12 explicit VisualizationGraphRenderingDelegatePrivate(QCustomPlot &plot)
13 : m_Plot{plot},
14 m_PointTracer{new QCPItemTracer{&plot}},
15 m_TextTracer{new QCPItemText{&plot}},
16 m_TracerTimer{}
17 {
18
19 m_TracerTimer.setInterval(TRACER_TIMEOUT);
20 m_TracerTimer.setSingleShot(true);
21 }
6 22
7 23 QCustomPlot &m_Plot;
24 QCPItemTracer *m_PointTracer;
25 QCPItemText *m_TextTracer;
26 QTimer m_TracerTimer;
8 27 };
9 28
10 29 VisualizationGraphRenderingDelegate::VisualizationGraphRenderingDelegate(QCustomPlot &plot)
11 30 : impl{spimpl::make_unique_impl<VisualizationGraphRenderingDelegatePrivate>(plot)}
12 31 {
13 32 }
14 33
15 34 void VisualizationGraphRenderingDelegate::onMouseMove(QMouseEvent *event) noexcept
16 35 {
36 // Cancels pending refresh
37 impl->m_TracerTimer.disconnect();
38
39 auto showTracers = [ eventPos = event->pos(), this ]()
40 {
41 };
42
43 // Starts the timer to display tracers at timeout
44 QObject::connect(&impl->m_TracerTimer, &QTimer::timeout, showTracers);
45 impl->m_TracerTimer.start();
17 46 }
General Comments 0
You need to be logged in to leave comments. Login now