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