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 <boost/weak_ptr.hpp>
28 #include <QAbstractScrollArea>
31 #include "cursorpair.h"
43 class View : public QAbstractScrollArea {
47 static const double MaxScale;
48 static const double MinScale;
50 static const int LabelMarginWidth;
51 static const int RulerHeight;
53 static const int MaxScrollValue;
56 static const int SignalHeight;
57 static const int SignalMargin;
58 static const int SignalSnapGridSize;
60 static const QColor CursorAreaColour;
62 static const QSizeF LabelPadding;
65 explicit View(SigSession &session, QWidget *parent = 0);
67 SigSession& session();
70 * Returns the view time scale in seconds per pixel.
75 * Returns the time offset of the left edge of the view in
78 double offset() const;
81 void zoom(double steps);
82 void zoom(double steps, int offset);
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.
89 void set_scale_offset(double scale, double offset);
91 std::list<boost::weak_ptr<SelectableItem> > selected_items() const;
94 * Returns true if cursors are displayed. false otherwise.
96 bool cursors_shown() const;
99 * Shows or hides the cursors.
101 void show_cursors(bool show = true);
104 * Moves the cursors to a convenient position in the view.
106 void centre_cursors();
109 * Returns a reference to the pair of cursors.
111 CursorPair& cursors();
114 * Returns a reference to the pair of cursors.
116 const CursorPair& cursors() const;
118 const QPoint& hover_point() const;
120 void normalize_layout();
123 void hover_point_changed();
125 void signals_moved();
127 void selection_changed();
130 void get_scroll_layout(double &length, double &offset) const;
132 void update_scroll();
135 bool eventFilter(QObject *object, QEvent *event);
137 bool viewportEvent(QEvent *e);
139 void resizeEvent(QResizeEvent *e);
143 void h_scroll_value_changed(int value);
144 void v_scroll_value_changed(int value);
146 void signals_changed();
149 void marker_time_changed();
151 void on_signals_moved();
154 SigSession &_session;
160 uint64_t _data_length;
162 /// The view time scale in seconds per pixel.
165 /// The view time offset in seconds.
169 bool _updating_scroll;
180 #endif // PULSEVIEW_PV_VIEW_VIEW_H