]> sigrok.org Git - pulseview.git/blame - pv/view/view.h
Added selection_changed signal to pv::view::View
[pulseview.git] / pv / view / view.h
CommitLineData
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
26#include <QAbstractScrollArea>
2e04f9bd 27#include <QSizeF>
adb4b10c 28
b42d25c4 29#include "cursorpair.h"
f76af637 30
51e77110
JH
31namespace pv {
32
adb4b10c 33class SigSession;
adb4b10c 34
cdf7bea7
JH
35namespace view {
36
1d8dca91 37class Header;
ccdd3ef5 38class Ruler;
cdf7bea7
JH
39class Viewport;
40
41class View : public QAbstractScrollArea {
adb4b10c
JH
42 Q_OBJECT
43
44private:
45 static const double MaxScale;
46 static const double MinScale;
47
48 static const int LabelMarginWidth;
49 static const int RulerHeight;
50
f25770e2
JH
51 static const int MaxScrollValue;
52
1d8dca91
JH
53public:
54 static const int SignalHeight;
8d44d030 55 static const int SignalMargin;
49153683 56 static const int SignalSnapGridSize;
1d8dca91 57
f76af637
JH
58 static const QColor CursorAreaColour;
59
2e04f9bd
JH
60 static const QSizeF LabelPadding;
61
adb4b10c 62public:
cdf7bea7 63 explicit View(SigSession &session, QWidget *parent = 0);
adb4b10c 64
1d19ef83
JH
65 SigSession& session();
66
e2f5223b
JH
67 /**
68 * Returns the view time scale in seconds per pixel.
69 */
adb4b10c 70 double scale() const;
e2f5223b
JH
71
72 /**
73 * Returns the time offset of the left edge of the view in
74 * seconds.
75 */
adb4b10c
JH
76 double offset() const;
77 int v_offset() const;
78
79 void zoom(double steps);
17c0f398 80 void zoom(double steps, int offset);
adb4b10c 81
e2f5223b
JH
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 */
adb4b10c
JH
87 void set_scale_offset(double scale, double offset);
88
f76af637
JH
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
b4d91e56
JH
99 /**
100 * Moves the cursors to a convenient position in the view.
101 */
102 void centre_cursors();
103
f76af637
JH
104 /**
105 * Returns a reference to the pair of cursors.
106 */
b42d25c4 107 CursorPair& cursors();
f76af637 108
cbd80f64
JH
109 const QPoint& hover_point() const;
110
4b192962
JH
111 void normalize_layout();
112
cbd80f64
JH
113signals:
114 void hover_point_changed();
115
07204819
JH
116 void signals_moved();
117
8b454527
JH
118 void selection_changed();
119
adb4b10c 120private:
f25770e2
JH
121 void get_scroll_layout(double &length, double &offset) const;
122
adb4b10c
JH
123 void update_scroll();
124
2e575351
JH
125 void reset_signal_layout();
126
adb4b10c 127private:
cbd80f64
JH
128 bool eventFilter(QObject *object, QEvent *event);
129
adb4b10c
JH
130 bool viewportEvent(QEvent *e);
131
132 void resizeEvent(QResizeEvent *e);
133
134private slots:
cbd80f64 135
b16907d3 136 void h_scroll_value_changed(int value);
adb4b10c
JH
137 void v_scroll_value_changed(int value);
138
69dd2b03 139 void signals_changed();
adb4b10c
JH
140 void data_updated();
141
ca4ec3ea
JH
142 void marker_time_changed();
143
07204819 144 void on_signals_moved();
54401bbb 145
adb4b10c
JH
146private:
147 SigSession &_session;
148
cdf7bea7 149 Viewport *_viewport;
ccdd3ef5 150 Ruler *_ruler;
1d8dca91 151 Header *_header;
adb4b10c
JH
152
153 uint64_t _data_length;
154
e2f5223b 155 /// The view time scale in seconds per pixel.
adb4b10c 156 double _scale;
e2f5223b
JH
157
158 /// The view time offset in seconds.
adb4b10c
JH
159 double _offset;
160
161 int _v_offset;
528bd8a1 162 bool _updating_scroll;
cbd80f64 163
f76af637 164 bool _show_cursors;
b42d25c4 165 CursorPair _cursors;
f76af637 166
cbd80f64 167 QPoint _hover_point;
adb4b10c
JH
168};
169
cdf7bea7
JH
170} // namespace view
171} // namespace pv
172
640d091b 173#endif // PULSEVIEW_PV_VIEW_VIEW_H