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