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