2 * This file is part of the PulseView project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
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.
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.
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
21 #ifndef PULSEVIEW_PV_VIEW_VIEW_H
22 #define PULSEVIEW_PV_VIEW_VIEW_H
26 #include <QAbstractScrollArea>
29 #include "cursorpair.h"
41 class View : public QAbstractScrollArea {
45 static const double MaxScale;
46 static const double MinScale;
48 static const int LabelMarginWidth;
49 static const int RulerHeight;
51 static const int MaxScrollValue;
54 static const int SignalHeight;
55 static const int SignalMargin;
56 static const int SignalSnapGridSize;
58 static const QColor CursorAreaColour;
60 static const QSizeF LabelPadding;
63 explicit View(SigSession &session, QWidget *parent = 0);
65 SigSession& session();
68 * Returns the view time scale in seconds per pixel.
73 * Returns the time offset of the left edge of the view in
76 double offset() const;
79 void zoom(double steps);
80 void zoom(double steps, int offset);
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.
87 void set_scale_offset(double scale, double offset);
90 * Returns true if cursors are displayed. false otherwise.
92 bool cursors_shown() const;
95 * Shows or hides the cursors.
97 void show_cursors(bool show = true);
100 * Returns a reference to the pair of cursors.
102 CursorPair& cursors();
104 const QPoint& hover_point() const;
106 void normalize_layout();
109 void hover_point_changed();
111 void signals_moved();
114 void get_scroll_layout(double &length, double &offset) const;
116 void update_scroll();
118 void reset_signal_layout();
121 bool eventFilter(QObject *object, QEvent *event);
123 bool viewportEvent(QEvent *e);
125 void resizeEvent(QResizeEvent *e);
129 void h_scroll_value_changed(int value);
130 void v_scroll_value_changed(int value);
132 void signals_changed();
135 void marker_time_changed();
137 void on_signals_moved();
140 SigSession &_session;
146 uint64_t _data_length;
148 /// The view time scale in seconds per pixel.
151 /// The view time offset in seconds.
155 bool _updating_scroll;
166 #endif // PULSEVIEW_PV_VIEW_VIEW_H