]>
Commit | Line | Data |
---|---|---|
adb4b10c | 1 | /* |
b3f22de0 | 2 | * This file is part of the PulseView project. |
adb4b10c JH |
3 | * |
4 | * Copyright (C) 2012 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 | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
640d091b UH |
21 | #ifndef PULSEVIEW_PV_VIEW_VIEW_H |
22 | #define PULSEVIEW_PV_VIEW_VIEW_H | |
adb4b10c JH |
23 | |
24 | #include <stdint.h> | |
25 | ||
f76af637 JH |
26 | #include <utility> |
27 | ||
adb4b10c | 28 | #include <QAbstractScrollArea> |
2e04f9bd | 29 | #include <QSizeF> |
adb4b10c | 30 | |
f76af637 JH |
31 | #include "cursor.h" |
32 | ||
51e77110 JH |
33 | namespace pv { |
34 | ||
adb4b10c | 35 | class SigSession; |
adb4b10c | 36 | |
cdf7bea7 JH |
37 | namespace view { |
38 | ||
1d8dca91 | 39 | class Header; |
ccdd3ef5 | 40 | class Ruler; |
cdf7bea7 JH |
41 | class Viewport; |
42 | ||
43 | class View : public QAbstractScrollArea { | |
adb4b10c JH |
44 | Q_OBJECT |
45 | ||
46 | private: | |
47 | static const double MaxScale; | |
48 | static const double MinScale; | |
49 | ||
50 | static const int LabelMarginWidth; | |
51 | static const int RulerHeight; | |
52 | ||
f25770e2 JH |
53 | static const int MaxScrollValue; |
54 | ||
1d8dca91 JH |
55 | public: |
56 | static const int SignalHeight; | |
57 | ||
f76af637 JH |
58 | static const QColor CursorAreaColour; |
59 | ||
2e04f9bd JH |
60 | static const QSizeF LabelPadding; |
61 | ||
adb4b10c | 62 | public: |
cdf7bea7 | 63 | explicit View(SigSession &session, QWidget *parent = 0); |
adb4b10c | 64 | |
1d19ef83 JH |
65 | SigSession& session(); |
66 | ||
e2f5223b JH |
67 | /** |
68 | * Returns the view time scale in seconds per pixel. | |
69 | */ | |
adb4b10c | 70 | double scale() const; |
e2f5223b JH |
71 | |
72 | /** | |
73 | * Returns the time offset of the left edge of the view in | |
74 | * seconds. | |
75 | */ | |
adb4b10c JH |
76 | double offset() const; |
77 | int v_offset() const; | |
78 | ||
79 | void zoom(double steps); | |
17c0f398 | 80 | void zoom(double steps, int offset); |
adb4b10c | 81 | |
e2f5223b JH |
82 | /** |
83 | * Sets the scale and offset. | |
84 | * @param scale The new view scale in seconds per pixel. | |
85 | * @param offset The view time offset in seconds. | |
86 | */ | |
adb4b10c JH |
87 | void set_scale_offset(double scale, double offset); |
88 | ||
f76af637 JH |
89 | /** |
90 | * Returns true if cursors are displayed. false otherwise. | |
91 | */ | |
92 | bool cursors_shown() const; | |
93 | ||
94 | /** | |
95 | * Shows or hides the cursors. | |
96 | */ | |
97 | void show_cursors(bool show = true); | |
98 | ||
99 | /** | |
100 | * Returns a reference to the pair of cursors. | |
101 | */ | |
102 | std::pair<Cursor, Cursor>& cursors(); | |
103 | ||
cbd80f64 JH |
104 | const QPoint& hover_point() const; |
105 | ||
106 | signals: | |
107 | void hover_point_changed(); | |
108 | ||
adb4b10c | 109 | private: |
f25770e2 JH |
110 | void get_scroll_layout(double &length, double &offset) const; |
111 | ||
adb4b10c JH |
112 | void update_scroll(); |
113 | ||
adb4b10c | 114 | private: |
cbd80f64 JH |
115 | bool eventFilter(QObject *object, QEvent *event); |
116 | ||
adb4b10c JH |
117 | bool viewportEvent(QEvent *e); |
118 | ||
119 | void resizeEvent(QResizeEvent *e); | |
120 | ||
121 | private slots: | |
cbd80f64 | 122 | |
adb4b10c JH |
123 | void h_scroll_value_changed(int value); |
124 | void v_scroll_value_changed(int value); | |
125 | ||
126 | void data_updated(); | |
127 | ||
ca4ec3ea JH |
128 | void marker_time_changed(); |
129 | ||
adb4b10c JH |
130 | private: |
131 | SigSession &_session; | |
132 | ||
cdf7bea7 | 133 | Viewport *_viewport; |
ccdd3ef5 | 134 | Ruler *_ruler; |
1d8dca91 | 135 | Header *_header; |
adb4b10c JH |
136 | |
137 | uint64_t _data_length; | |
138 | ||
e2f5223b | 139 | /// The view time scale in seconds per pixel. |
adb4b10c | 140 | double _scale; |
e2f5223b JH |
141 | |
142 | /// The view time offset in seconds. | |
adb4b10c JH |
143 | double _offset; |
144 | ||
145 | int _v_offset; | |
cbd80f64 | 146 | |
f76af637 JH |
147 | bool _show_cursors; |
148 | std::pair<Cursor, Cursor> _cursors; | |
149 | ||
cbd80f64 | 150 | QPoint _hover_point; |
adb4b10c JH |
151 | }; |
152 | ||
cdf7bea7 JH |
153 | } // namespace view |
154 | } // namespace pv | |
155 | ||
640d091b | 156 | #endif // PULSEVIEW_PV_VIEW_VIEW_H |