]>
Commit | Line | Data |
---|---|---|
b42d25c4 JH |
1 | /* |
2 | * This file is part of the PulseView project. | |
3 | * | |
4 | * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
efdec55a | 17 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
b42d25c4 JH |
18 | */ |
19 | ||
f4e57597 SA |
20 | #ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_CURSORPAIR_HPP |
21 | #define PULSEVIEW_PV_VIEWS_TRACEVIEW_CURSORPAIR_HPP | |
b42d25c4 | 22 | |
2acdb232 | 23 | #include "cursor.hpp" |
b42d25c4 | 24 | |
f9abf97e | 25 | #include <memory> |
58864c5c | 26 | |
0ba172cf | 27 | #include <QPainter> |
581724de | 28 | #include <QRect> |
0ba172cf | 29 | |
6f925ba9 UH |
30 | using std::pair; |
31 | using std::shared_ptr; | |
32 | ||
b42d25c4 JH |
33 | class QPainter; |
34 | ||
35 | namespace pv { | |
f4e57597 | 36 | namespace views { |
1573bf16 | 37 | namespace trace { |
b42d25c4 | 38 | |
581724de SA |
39 | class View; |
40 | ||
5a0192d4 | 41 | class CursorPair : public TimeItem |
b42d25c4 | 42 | { |
581724de SA |
43 | Q_OBJECT |
44 | ||
5139748b JH |
45 | private: |
46 | static const int DeltaPadding; | |
641574bc | 47 | static const QColor ViewportFillColor; |
5139748b | 48 | |
b42d25c4 JH |
49 | public: |
50 | /** | |
51 | * Constructor. | |
52 | * @param view A reference to the view that owns this cursor pair. | |
53 | */ | |
8debe10d | 54 | CursorPair(View &view); |
b42d25c4 | 55 | |
5a0192d4 JH |
56 | /** |
57 | * Returns true if the item is visible and enabled. | |
58 | */ | |
b2650e69 | 59 | bool enabled() const override; |
5a0192d4 | 60 | |
b42d25c4 | 61 | /** |
58864c5c | 62 | * Returns a pointer to the first cursor. |
b42d25c4 | 63 | */ |
6f925ba9 | 64 | shared_ptr<Cursor> first() const; |
b42d25c4 JH |
65 | |
66 | /** | |
58864c5c | 67 | * Returns a pointer to the second cursor. |
b42d25c4 | 68 | */ |
6f925ba9 | 69 | shared_ptr<Cursor> second() const; |
b42d25c4 | 70 | |
3b9c4a0d JH |
71 | /** |
72 | * Sets the time of the marker. | |
73 | */ | |
60d9b99a | 74 | void set_time(const pv::util::Timestamp& time) override; |
3b9c4a0d | 75 | |
b2650e69 | 76 | float get_x() const override; |
5165bb34 | 77 | |
a3d5a7c7 | 78 | QPoint drag_point(const QRect &rect) const override; |
5a0192d4 | 79 | |
b2650e69 | 80 | pv::widgets::Popup* create_popup(QWidget *parent) override; |
5a0192d4 | 81 | |
0ba172cf | 82 | public: |
b2650e69 | 83 | QRectF label_rect(const QRectF &rect) const override; |
5139748b | 84 | |
49028d6c JH |
85 | /** |
86 | * Paints the marker's label to the ruler. | |
87 | * @param p The painter to draw with. | |
88 | * @param rect The rectangle of the ruler client area. | |
89 | * @param hover true if the label is being hovered over by the mouse. | |
90 | */ | |
b2650e69 | 91 | void paint_label(QPainter &p, const QRect &rect, bool hover) override; |
332afa74 | 92 | |
beb897c6 JH |
93 | /** |
94 | * Paints the background layer of the item with a QPainter | |
95 | * @param p the QPainter to paint into. | |
96 | * @param pp the painting parameters object to paint with. | |
223d0c37 | 97 | */ |
60938e04 | 98 | void paint_back(QPainter &p, ViewItemPaintParams &pp) override; |
0ba172cf | 99 | |
32045253 JH |
100 | /** |
101 | * Constructs the string to display. | |
102 | */ | |
103 | QString format_string(); | |
104 | ||
6f925ba9 | 105 | pair<float, float> get_cursor_offsets() const; |
199441e4 | 106 | |
581724de SA |
107 | public Q_SLOTS: |
108 | void on_hover_point_changed(const QWidget* widget, const QPoint &hp); | |
109 | ||
b42d25c4 | 110 | private: |
6f925ba9 | 111 | shared_ptr<Cursor> first_, second_; |
5139748b | 112 | |
8dbbc7f0 | 113 | QSizeF text_size_; |
581724de SA |
114 | QRectF label_area_; |
115 | bool label_incomplete_; | |
b42d25c4 JH |
116 | }; |
117 | ||
1573bf16 | 118 | } // namespace trace |
f4e57597 | 119 | } // namespace views |
b42d25c4 JH |
120 | } // namespace pv |
121 | ||
f4e57597 | 122 | #endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_CURSORPAIR_HPP |