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