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
30 #include <QAbstractScrollArea>
33 #include <pv/data/signaldata.h>
35 #include "cursorpair.h"
49 class View : public QAbstractScrollArea {
53 static const double MaxScale;
54 static const double MinScale;
56 static const int MaxScrollValue;
59 static const int SignalHeight;
60 static const int SignalMargin;
61 static const int SignalSnapGridSize;
63 static const QColor CursorAreaColour;
65 static const QSizeF LabelPadding;
68 explicit View(SigSession &session, QWidget *parent = 0);
70 SigSession& session();
71 const SigSession& session() const;
75 const Viewport* viewport() const;
78 * Returns the view time scale in seconds per pixel.
83 * Returns the time offset of the left edge of the view in
86 double offset() const;
89 void zoom(double steps);
90 void zoom(double steps, int offset);
94 void zoom_one_to_one();
97 * Sets the scale and offset.
98 * @param scale The new view scale in seconds per pixel.
99 * @param offset The view time offset in seconds.
101 void set_scale_offset(double scale, double offset);
103 std::vector< std::shared_ptr<Trace> > get_traces() const;
105 std::list<std::weak_ptr<SelectableItem> > selected_items() const;
107 std::set< std::shared_ptr<pv::data::SignalData> >
108 get_visible_data() const;
110 std::pair<double, double> get_time_extents() const;
113 * Returns true if cursors are displayed. false otherwise.
115 bool cursors_shown() const;
118 * Shows or hides the cursors.
120 void show_cursors(bool show = true);
123 * Moves the cursors to a convenient position in the view.
125 void centre_cursors();
128 * Returns a reference to the pair of cursors.
130 CursorPair& cursors();
133 * Returns a reference to the pair of cursors.
135 const CursorPair& cursors() const;
137 const QPoint& hover_point() const;
139 void normalize_layout();
141 void update_viewport();
144 void hover_point_changed();
146 void signals_moved();
148 void selection_changed();
150 void scale_offset_changed();
153 void get_scroll_layout(double &length, double &offset) const;
156 * Simultaneously sets the zoom and offset.
157 * @param scale The scale to set the view to in seconds per pixel. This
158 * value is clamped between MinScale and MaxScale.
159 * @param offset The offset of the left edge of the view in seconds.
161 void set_zoom(double scale, int offset);
163 void update_scroll();
165 void update_layout();
167 static bool compare_trace_v_offsets(
168 const std::shared_ptr<pv::view::Trace> &a,
169 const std::shared_ptr<pv::view::Trace> &b);
172 bool eventFilter(QObject *object, QEvent *event);
174 bool viewportEvent(QEvent *e);
176 void resizeEvent(QResizeEvent *e);
180 void h_scroll_value_changed(int value);
181 void v_scroll_value_changed(int value);
183 void signals_changed();
186 void marker_time_changed();
188 void on_signals_moved();
190 void on_geometry_updated();
192 void on_hover_point_changed();
195 SigSession &_session;
199 CursorHeader *_cursorheader;
202 /// The view time scale in seconds per pixel.
205 /// The view time offset in seconds.
209 bool _updating_scroll;
220 #endif // PULSEVIEW_PV_VIEW_VIEW_H