]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * This file is part of the PulseView project. | |
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 | ||
21 | #ifndef PULSEVIEW_PV_VIEW_VIEW_H | |
22 | #define PULSEVIEW_PV_VIEW_VIEW_H | |
23 | ||
24 | #include <stdint.h> | |
25 | ||
26 | #include <QAbstractScrollArea> | |
27 | #include <QSizeF> | |
28 | ||
29 | #include "cursorpair.h" | |
30 | ||
31 | namespace pv { | |
32 | ||
33 | class SigSession; | |
34 | ||
35 | namespace view { | |
36 | ||
37 | class Header; | |
38 | class Ruler; | |
39 | class Viewport; | |
40 | ||
41 | class View : public QAbstractScrollArea { | |
42 | Q_OBJECT | |
43 | ||
44 | private: | |
45 | static const double MaxScale; | |
46 | static const double MinScale; | |
47 | ||
48 | static const int LabelMarginWidth; | |
49 | static const int RulerHeight; | |
50 | ||
51 | static const int MaxScrollValue; | |
52 | ||
53 | public: | |
54 | static const int SignalHeight; | |
55 | static const int SignalMargin; | |
56 | static const int SignalSnapGridSize; | |
57 | ||
58 | static const QColor CursorAreaColour; | |
59 | ||
60 | static const QSizeF LabelPadding; | |
61 | ||
62 | public: | |
63 | explicit View(SigSession &session, QWidget *parent = 0); | |
64 | ||
65 | SigSession& session(); | |
66 | ||
67 | /** | |
68 | * Returns the view time scale in seconds per pixel. | |
69 | */ | |
70 | double scale() const; | |
71 | ||
72 | /** | |
73 | * Returns the time offset of the left edge of the view in | |
74 | * seconds. | |
75 | */ | |
76 | double offset() const; | |
77 | int v_offset() const; | |
78 | ||
79 | void zoom(double steps); | |
80 | void zoom(double steps, int offset); | |
81 | ||
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 | */ | |
87 | void set_scale_offset(double scale, double offset); | |
88 | ||
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 | CursorPair& cursors(); | |
103 | ||
104 | const QPoint& hover_point() const; | |
105 | ||
106 | void normalize_layout(); | |
107 | ||
108 | signals: | |
109 | void hover_point_changed(); | |
110 | ||
111 | void signals_moved(); | |
112 | ||
113 | private: | |
114 | void get_scroll_layout(double &length, double &offset) const; | |
115 | ||
116 | void update_scroll(); | |
117 | ||
118 | void reset_signal_layout(); | |
119 | ||
120 | private: | |
121 | bool eventFilter(QObject *object, QEvent *event); | |
122 | ||
123 | bool viewportEvent(QEvent *e); | |
124 | ||
125 | void resizeEvent(QResizeEvent *e); | |
126 | ||
127 | private slots: | |
128 | ||
129 | void h_scroll_value_changed(int value); | |
130 | void v_scroll_value_changed(int value); | |
131 | ||
132 | void signals_changed(); | |
133 | void data_updated(); | |
134 | ||
135 | void marker_time_changed(); | |
136 | ||
137 | void on_signals_moved(); | |
138 | ||
139 | private: | |
140 | SigSession &_session; | |
141 | ||
142 | Viewport *_viewport; | |
143 | Ruler *_ruler; | |
144 | Header *_header; | |
145 | ||
146 | uint64_t _data_length; | |
147 | ||
148 | /// The view time scale in seconds per pixel. | |
149 | double _scale; | |
150 | ||
151 | /// The view time offset in seconds. | |
152 | double _offset; | |
153 | ||
154 | int _v_offset; | |
155 | bool _updating_scroll; | |
156 | ||
157 | bool _show_cursors; | |
158 | CursorPair _cursors; | |
159 | ||
160 | QPoint _hover_point; | |
161 | }; | |
162 | ||
163 | } // namespace view | |
164 | } // namespace pv | |
165 | ||
166 | #endif // PULSEVIEW_PV_VIEW_VIEW_H |