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
28 #include <QAbstractScrollArea>
42 class View : public QAbstractScrollArea {
46 static const double MaxScale;
47 static const double MinScale;
49 static const int LabelMarginWidth;
50 static const int RulerHeight;
52 static const int MaxScrollValue;
55 static const int SignalHeight;
57 static const QColor CursorAreaColour;
60 explicit View(SigSession &session, QWidget *parent = 0);
62 SigSession& session();
65 * Returns the view time scale in seconds per pixel.
70 * Returns the time offset of the left edge of the view in
73 double offset() const;
76 void zoom(double steps);
77 void zoom(double steps, int offset);
80 * Sets the scale and offset.
81 * @param scale The new view scale in seconds per pixel.
82 * @param offset The view time offset in seconds.
84 void set_scale_offset(double scale, double offset);
87 * Returns true if cursors are displayed. false otherwise.
89 bool cursors_shown() const;
92 * Shows or hides the cursors.
94 void show_cursors(bool show = true);
97 * Returns a reference to the pair of cursors.
99 std::pair<Cursor, Cursor>& cursors();
101 const QPoint& hover_point() const;
104 void hover_point_changed();
107 void get_scroll_layout(double &length, double &offset) const;
109 void update_scroll();
112 bool eventFilter(QObject *object, QEvent *event);
114 bool viewportEvent(QEvent *e);
116 void resizeEvent(QResizeEvent *e);
120 void h_scroll_value_changed(int value);
121 void v_scroll_value_changed(int value);
125 void marker_time_changed();
128 SigSession &_session;
134 uint64_t _data_length;
136 /// The view time scale in seconds per pixel.
139 /// The view time offset in seconds.
145 std::pair<Cursor, Cursor> _cursors;
153 #endif // PULSEVIEW_PV_VIEW_VIEW_H