]>
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 | ||
1bc6525b | 26 | #include <set> |
38eeddea JH |
27 | #include <vector> |
28 | ||
29 | #include <boost/shared_ptr.hpp> | |
94936133 JH |
30 | #include <boost/weak_ptr.hpp> |
31 | ||
adb4b10c | 32 | #include <QAbstractScrollArea> |
2e04f9bd | 33 | #include <QSizeF> |
adb4b10c | 34 | |
1bc6525b JH |
35 | #include <pv/data/signaldata.h> |
36 | ||
b42d25c4 | 37 | #include "cursorpair.h" |
f76af637 | 38 | |
51e77110 JH |
39 | namespace pv { |
40 | ||
adb4b10c | 41 | class SigSession; |
adb4b10c | 42 | |
cdf7bea7 JH |
43 | namespace view { |
44 | ||
1d8dca91 | 45 | class Header; |
ccdd3ef5 | 46 | class Ruler; |
38eeddea | 47 | class Trace; |
cdf7bea7 JH |
48 | class Viewport; |
49 | ||
50 | class View : public QAbstractScrollArea { | |
adb4b10c JH |
51 | Q_OBJECT |
52 | ||
53 | private: | |
54 | static const double MaxScale; | |
55 | static const double MinScale; | |
56 | ||
f25770e2 JH |
57 | static const int MaxScrollValue; |
58 | ||
1d8dca91 JH |
59 | public: |
60 | static const int SignalHeight; | |
8d44d030 | 61 | static const int SignalMargin; |
49153683 | 62 | static const int SignalSnapGridSize; |
1d8dca91 | 63 | |
f76af637 JH |
64 | static const QColor CursorAreaColour; |
65 | ||
2e04f9bd JH |
66 | static const QSizeF LabelPadding; |
67 | ||
adb4b10c | 68 | public: |
cdf7bea7 | 69 | explicit View(SigSession &session, QWidget *parent = 0); |
adb4b10c | 70 | |
1d19ef83 | 71 | SigSession& session(); |
38eeddea | 72 | const SigSession& session() const; |
1d19ef83 | 73 | |
e2f5223b JH |
74 | /** |
75 | * Returns the view time scale in seconds per pixel. | |
76 | */ | |
adb4b10c | 77 | double scale() const; |
e2f5223b JH |
78 | |
79 | /** | |
80 | * Returns the time offset of the left edge of the view in | |
81 | * seconds. | |
82 | */ | |
adb4b10c JH |
83 | double offset() const; |
84 | int v_offset() const; | |
85 | ||
86 | void zoom(double steps); | |
17c0f398 | 87 | void zoom(double steps, int offset); |
adb4b10c | 88 | |
ca46b534 JH |
89 | void zoom_fit(); |
90 | ||
d1e7d82c JH |
91 | void zoom_one_to_one(); |
92 | ||
e2f5223b JH |
93 | /** |
94 | * Sets the scale and offset. | |
95 | * @param scale The new view scale in seconds per pixel. | |
96 | * @param offset The view time offset in seconds. | |
97 | */ | |
adb4b10c JH |
98 | void set_scale_offset(double scale, double offset); |
99 | ||
38eeddea JH |
100 | std::vector< boost::shared_ptr<Trace> > get_traces() const; |
101 | ||
94936133 JH |
102 | std::list<boost::weak_ptr<SelectableItem> > selected_items() const; |
103 | ||
1bc6525b JH |
104 | std::set< boost::shared_ptr<pv::data::SignalData> > |
105 | get_visible_data() const; | |
106 | ||
107 | std::pair<double, double> get_time_extents() const; | |
108 | ||
f76af637 JH |
109 | /** |
110 | * Returns true if cursors are displayed. false otherwise. | |
111 | */ | |
112 | bool cursors_shown() const; | |
113 | ||
114 | /** | |
115 | * Shows or hides the cursors. | |
116 | */ | |
117 | void show_cursors(bool show = true); | |
118 | ||
b4d91e56 JH |
119 | /** |
120 | * Moves the cursors to a convenient position in the view. | |
121 | */ | |
122 | void centre_cursors(); | |
123 | ||
f76af637 JH |
124 | /** |
125 | * Returns a reference to the pair of cursors. | |
126 | */ | |
b42d25c4 | 127 | CursorPair& cursors(); |
f76af637 | 128 | |
58864c5c JH |
129 | /** |
130 | * Returns a reference to the pair of cursors. | |
131 | */ | |
132 | const CursorPair& cursors() const; | |
133 | ||
cbd80f64 JH |
134 | const QPoint& hover_point() const; |
135 | ||
4b192962 JH |
136 | void normalize_layout(); |
137 | ||
9cef9567 JH |
138 | void update_viewport(); |
139 | ||
cbd80f64 JH |
140 | signals: |
141 | void hover_point_changed(); | |
142 | ||
07204819 JH |
143 | void signals_moved(); |
144 | ||
8b454527 JH |
145 | void selection_changed(); |
146 | ||
e0fc5810 JH |
147 | void scale_offset_changed(); |
148 | ||
adb4b10c | 149 | private: |
f25770e2 | 150 | void get_scroll_layout(double &length, double &offset) const; |
3925091a JH |
151 | |
152 | /** | |
153 | * Simultaneously sets the zoom and offset. | |
154 | * @param scale The scale to set the view to in seconds per pixel. This | |
155 | * value is clamped between MinScale and MaxScale. | |
156 | * @param offset The offset of the left edge of the view in seconds. | |
157 | */ | |
d1e7d82c JH |
158 | void set_zoom(double scale, int offset); |
159 | ||
adb4b10c JH |
160 | void update_scroll(); |
161 | ||
d7c0ca4a JH |
162 | void update_layout(); |
163 | ||
38eeddea JH |
164 | static bool compare_trace_v_offsets( |
165 | const boost::shared_ptr<pv::view::Trace> &a, | |
166 | const boost::shared_ptr<pv::view::Trace> &b); | |
167 | ||
adb4b10c | 168 | private: |
cbd80f64 JH |
169 | bool eventFilter(QObject *object, QEvent *event); |
170 | ||
adb4b10c JH |
171 | bool viewportEvent(QEvent *e); |
172 | ||
173 | void resizeEvent(QResizeEvent *e); | |
174 | ||
175 | private slots: | |
cbd80f64 | 176 | |
b16907d3 | 177 | void h_scroll_value_changed(int value); |
adb4b10c JH |
178 | void v_scroll_value_changed(int value); |
179 | ||
69dd2b03 | 180 | void signals_changed(); |
adb4b10c JH |
181 | void data_updated(); |
182 | ||
ca4ec3ea JH |
183 | void marker_time_changed(); |
184 | ||
07204819 | 185 | void on_signals_moved(); |
54401bbb | 186 | |
d7c0ca4a JH |
187 | void on_geometry_updated(); |
188 | ||
adb4b10c JH |
189 | private: |
190 | SigSession &_session; | |
191 | ||
cdf7bea7 | 192 | Viewport *_viewport; |
ccdd3ef5 | 193 | Ruler *_ruler; |
1d8dca91 | 194 | Header *_header; |
adb4b10c | 195 | |
e2f5223b | 196 | /// The view time scale in seconds per pixel. |
adb4b10c | 197 | double _scale; |
e2f5223b JH |
198 | |
199 | /// The view time offset in seconds. | |
adb4b10c JH |
200 | double _offset; |
201 | ||
202 | int _v_offset; | |
528bd8a1 | 203 | bool _updating_scroll; |
cbd80f64 | 204 | |
f76af637 | 205 | bool _show_cursors; |
b42d25c4 | 206 | CursorPair _cursors; |
f76af637 | 207 | |
cbd80f64 | 208 | QPoint _hover_point; |
adb4b10c JH |
209 | }; |
210 | ||
cdf7bea7 JH |
211 | } // namespace view |
212 | } // namespace pv | |
213 | ||
640d091b | 214 | #endif // PULSEVIEW_PV_VIEW_VIEW_H |