]> sigrok.org Git - pulseview.git/blame - pv/views/viewbase.hpp
Add temporary snapping disable menu to markers and cursors
[pulseview.git] / pv / views / viewbase.hpp
CommitLineData
f4e57597
SA
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 * Copyright (C) 2016 Soeren Apel <soeren@apelpie.net>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
efdec55a 18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
f4e57597
SA
19 */
20
21#ifndef PULSEVIEW_PV_VIEWS_VIEWBASE_HPP
22#define PULSEVIEW_PV_VIEWS_VIEWBASE_HPP
23
cafe470e 24#include <cstdint>
f4e57597 25#include <memory>
5ed05b69 26#include <unordered_set>
f4e57597
SA
27#include <vector>
28
5ed05b69 29#include <QTimer>
f4e57597
SA
30#include <QWidget>
31
32#include <pv/data/signalbase.hpp>
33#include <pv/util.hpp>
34
ad908057
SA
35#ifdef ENABLE_DECODE
36#include <pv/data/decodesignal.hpp>
37#endif
38
6f925ba9 39using std::shared_ptr;
5ed05b69 40using std::unordered_set;
6f925ba9 41
f4e57597
SA
42namespace pv {
43
44class Session;
45
46namespace view {
47class DecodeTrace;
48class Signal;
49}
50
51namespace views {
52
53enum ViewType {
54 ViewTypeTrace,
55 ViewTypeTabularDecode
56};
57
c063290a
UH
58class ViewBase : public QWidget
59{
f4e57597
SA
60 Q_OBJECT
61
5ed05b69
SA
62private:
63 static const int MaxViewAutoUpdateRate;
64
f4e57597 65public:
c063290a 66 explicit ViewBase(Session &session, bool is_main_view = false, QWidget *parent = nullptr);
f4e57597 67
5a206446
SA
68 /**
69 * Resets the view to its default state after construction. It does however
70 * not reset the signal bases or any other connections with the session.
71 */
72 virtual void reset_view_state();
73
f4e57597
SA
74 Session& session();
75 const Session& session() const;
76
77 virtual void clear_signals();
78
5ed05b69
SA
79 /**
80 * Returns the signal bases contained in this view.
81 */
82 unordered_set< shared_ptr<data::SignalBase> > signalbases() const;
83
84 virtual void clear_signalbases();
85
86 virtual void add_signalbase(const shared_ptr<data::SignalBase> signalbase);
87
f4e57597
SA
88#ifdef ENABLE_DECODE
89 virtual void clear_decode_signals();
90
ad908057 91 virtual void add_decode_signal(shared_ptr<data::DecodeSignal> signal);
f4e57597 92
ad908057 93 virtual void remove_decode_signal(shared_ptr<data::DecodeSignal> signal);
f4e57597
SA
94#endif
95
96 virtual void save_settings(QSettings &settings) const;
97
98 virtual void restore_settings(QSettings &settings);
99
100public Q_SLOTS:
7ea2a4ff 101 virtual void trigger_event(int segment_id, util::Timestamp location);
f4e57597
SA
102 virtual void signals_changed();
103 virtual void capture_state_updated(int state);
4e86ec70 104 virtual void on_new_segment(int new_segment_id);
558ad6ce 105 virtual void on_segment_completed(int new_segment_id);
5ed05b69
SA
106 virtual void perform_delayed_view_update();
107
108private Q_SLOTS:
7f894d95 109 void on_samples_added(uint64_t segment_id, uint64_t start_sample,
8c339741
SA
110 uint64_t end_sample);
111
5ed05b69 112 void on_data_updated();
f4e57597
SA
113
114protected:
115 Session &session_;
116
143d322d
SA
117 const bool is_main_view_;
118
f4e57597 119 util::TimeUnit time_unit_;
5ed05b69
SA
120
121 unordered_set< shared_ptr<data::SignalBase> > signalbases_;
122
8c339741
SA
123 /// The ID of the currently displayed segment
124 uint32_t current_segment_;
125
5ed05b69 126 QTimer delayed_view_updater_;
f4e57597
SA
127};
128
129} // namespace views
130} // namespace pv
131
132#endif // PULSEVIEW_PV_VIEWS_VIEWBASE_HPP