]>
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 JH |
27 | #include <QPainter> |
28 | ||
6f925ba9 UH |
29 | using std::pair; |
30 | using std::shared_ptr; | |
31 | ||
b42d25c4 JH |
32 | class QPainter; |
33 | ||
34 | namespace pv { | |
f4e57597 SA |
35 | namespace views { |
36 | namespace TraceView { | |
b42d25c4 | 37 | |
5a0192d4 | 38 | class CursorPair : public TimeItem |
b42d25c4 | 39 | { |
5139748b JH |
40 | private: |
41 | static const int DeltaPadding; | |
ccee9230 | 42 | static const QColor ViewportFillColour; |
5139748b | 43 | |
b42d25c4 JH |
44 | public: |
45 | /** | |
46 | * Constructor. | |
47 | * @param view A reference to the view that owns this cursor pair. | |
48 | */ | |
8debe10d | 49 | CursorPair(View &view); |
b42d25c4 | 50 | |
5a0192d4 JH |
51 | public: |
52 | /** | |
53 | * Returns true if the item is visible and enabled. | |
54 | */ | |
b2650e69 | 55 | bool enabled() const override; |
5a0192d4 | 56 | |
b42d25c4 | 57 | /** |
58864c5c | 58 | * Returns a pointer to the first cursor. |
b42d25c4 | 59 | */ |
6f925ba9 | 60 | shared_ptr<Cursor> first() const; |
b42d25c4 JH |
61 | |
62 | /** | |
58864c5c | 63 | * Returns a pointer to the second cursor. |
b42d25c4 | 64 | */ |
6f925ba9 | 65 | shared_ptr<Cursor> second() const; |
b42d25c4 | 66 | |
3b9c4a0d JH |
67 | /** |
68 | * Sets the time of the marker. | |
69 | */ | |
60d9b99a | 70 | void set_time(const pv::util::Timestamp& time) override; |
3b9c4a0d | 71 | |
b2650e69 | 72 | float get_x() const override; |
5165bb34 | 73 | |
b2650e69 | 74 | QPoint point(const QRect &rect) const override; |
5a0192d4 | 75 | |
b2650e69 | 76 | pv::widgets::Popup* create_popup(QWidget *parent) override; |
5a0192d4 | 77 | |
0ba172cf | 78 | public: |
b2650e69 | 79 | QRectF label_rect(const QRectF &rect) const override; |
5139748b | 80 | |
49028d6c JH |
81 | /** |
82 | * Paints the marker's label to the ruler. | |
83 | * @param p The painter to draw with. | |
84 | * @param rect The rectangle of the ruler client area. | |
85 | * @param hover true if the label is being hovered over by the mouse. | |
86 | */ | |
b2650e69 | 87 | void paint_label(QPainter &p, const QRect &rect, bool hover) override; |
332afa74 | 88 | |
beb897c6 JH |
89 | /** |
90 | * Paints the background layer of the item with a QPainter | |
91 | * @param p the QPainter to paint into. | |
92 | * @param pp the painting parameters object to paint with. | |
223d0c37 | 93 | */ |
b2650e69 | 94 | void paint_back(QPainter &p, const ViewItemPaintParams &pp) override; |
0ba172cf | 95 | |
32045253 JH |
96 | /** |
97 | * Constructs the string to display. | |
98 | */ | |
99 | QString format_string(); | |
100 | ||
101 | void compute_text_size(QPainter &p); | |
5139748b | 102 | |
6f925ba9 | 103 | pair<float, float> get_cursor_offsets() const; |
199441e4 | 104 | |
b42d25c4 | 105 | private: |
6f925ba9 | 106 | shared_ptr<Cursor> first_, second_; |
5139748b | 107 | |
8dbbc7f0 | 108 | QSizeF text_size_; |
b42d25c4 JH |
109 | }; |
110 | ||
f4e57597 SA |
111 | } // namespace TraceView |
112 | } // namespace views | |
b42d25c4 JH |
113 | } // namespace pv |
114 | ||
f4e57597 | 115 | #endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_CURSORPAIR_HPP |