@@ -4,10 +4,15 | |||
|
4 | 4 | |
|
5 | 5 | #include <Common/DateUtils.h> |
|
6 | 6 | |
|
7 | #include <SqpApplication.h> | |
|
8 | ||
|
7 | 9 | namespace { |
|
8 | 10 | |
|
9 | 11 | const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss:zzz"); |
|
10 | 12 | |
|
13 | /// Name of the overlay layer in QCustomPlot | |
|
14 | const auto OVERLAY_LAYER = QStringLiteral("overlay"); | |
|
15 | ||
|
11 | 16 | const auto TOOLTIP_FORMAT = QStringLiteral("key: %1\nvalue: %2"); |
|
12 | 17 | |
|
13 | 18 | /// Offset used to shift the tooltip of the mouse |
@@ -40,6 +45,33 void initPointTracerStyle(QCPItemTracer &tracer) noexcept | |||
|
40 | 45 | tracer.setBrush(Qt::black); |
|
41 | 46 | } |
|
42 | 47 | |
|
48 | void initClosePixmapStyle(QCPItemPixmap &pixmap) noexcept | |
|
49 | { | |
|
50 | // Icon | |
|
51 | pixmap.setPixmap( | |
|
52 | sqpApp->style()->standardIcon(QStyle::SP_TitleBarCloseButton).pixmap(QSize{16, 16})); | |
|
53 | ||
|
54 | // Position | |
|
55 | pixmap.topLeft->setType(QCPItemPosition::ptAxisRectRatio); | |
|
56 | pixmap.topLeft->setCoords(1, 0); | |
|
57 | pixmap.setClipToAxisRect(false); | |
|
58 | ||
|
59 | // Can be selected | |
|
60 | pixmap.setSelectable(true); | |
|
61 | } | |
|
62 | ||
|
63 | void initTitleTextStyle(QCPItemText &text) noexcept | |
|
64 | { | |
|
65 | // Font and background styles | |
|
66 | text.setColor(Qt::gray); | |
|
67 | text.setBrush(Qt::white); | |
|
68 | ||
|
69 | // Position | |
|
70 | text.setPositionAlignment(Qt::AlignTop | Qt::AlignLeft); | |
|
71 | text.position->setType(QCPItemPosition::ptAxisRectRatio); | |
|
72 | text.position->setCoords(0.5, 0); | |
|
73 | } | |
|
74 | ||
|
43 | 75 | } // namespace |
|
44 | 76 | |
|
45 | 77 | struct VisualizationGraphRenderingDelegate::VisualizationGraphRenderingDelegatePrivate { |
@@ -47,16 +79,28 struct VisualizationGraphRenderingDelegate::VisualizationGraphRenderingDelegateP | |||
|
47 | 79 | : m_Plot{graphWidget.plot()}, |
|
48 | 80 | m_PointTracer{new QCPItemTracer{&m_Plot}}, |
|
49 | 81 | m_TracerTimer{}, |
|
82 | m_ClosePixmap{new QCPItemPixmap{&m_Plot}}, | |
|
83 | m_TitleText{new QCPItemText{&m_Plot}} | |
|
50 | 84 | { |
|
51 | 85 | initPointTracerStyle(*m_PointTracer); |
|
52 | 86 | |
|
53 | 87 | m_TracerTimer.setInterval(TOOLTIP_TIMEOUT); |
|
54 | 88 | m_TracerTimer.setSingleShot(true); |
|
89 | ||
|
90 | // Inits "close button" in plot overlay | |
|
91 | m_ClosePixmap->setLayer(OVERLAY_LAYER); | |
|
92 | initClosePixmapStyle(*m_ClosePixmap); | |
|
93 | // Inits graph name in plot overlay | |
|
94 | m_TitleText->setLayer(OVERLAY_LAYER); | |
|
95 | m_TitleText->setText(graphWidget.name()); | |
|
96 | initTitleTextStyle(*m_TitleText); | |
|
55 | 97 | } |
|
56 | 98 | |
|
57 | 99 | QCustomPlot &m_Plot; |
|
58 | 100 | QCPItemTracer *m_PointTracer; |
|
59 | 101 | QTimer m_TracerTimer; |
|
102 | QCPItemPixmap *m_ClosePixmap; /// Graph's close button | |
|
103 | QCPItemText *m_TitleText; /// Graph's title | |
|
60 | 104 | }; |
|
61 | 105 | |
|
62 | 106 | VisualizationGraphRenderingDelegate::VisualizationGraphRenderingDelegate( |
General Comments 0
You need to be logged in to leave comments.
Login now