]> sigrok.org Git - pulseview.git/blob - pv/views/viewbase.hpp
Use getter for the conversion type instead of a local copy
[pulseview.git] / pv / views / viewbase.hpp
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
18  * along with this program; if not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #ifndef PULSEVIEW_PV_VIEWS_VIEWBASE_HPP
22 #define PULSEVIEW_PV_VIEWS_VIEWBASE_HPP
23
24 #include <cstdint>
25 #include <memory>
26 #include <unordered_set>
27 #include <vector>
28
29 #include <QTimer>
30 #include <QWidget>
31
32 #include <pv/data/signalbase.hpp>
33 #include <pv/util.hpp>
34
35 #ifdef ENABLE_DECODE
36 #include <pv/data/decodesignal.hpp>
37 #endif
38
39 using std::shared_ptr;
40 using std::unordered_set;
41
42 namespace pv {
43
44 class Session;
45
46 namespace view {
47 class DecodeTrace;
48 class Signal;
49 }
50
51 namespace views {
52
53 enum ViewType {
54         ViewTypeTrace,
55         ViewTypeTabularDecode
56 };
57
58 class ViewBase : public QWidget
59 {
60         Q_OBJECT
61
62 private:
63         static const int MaxViewAutoUpdateRate;
64
65 public:
66         explicit ViewBase(Session &session, bool is_main_view = false, QWidget *parent = nullptr);
67
68         Session& session();
69         const Session& session() const;
70
71         virtual void clear_signals();
72
73         /**
74          * Returns the signal bases contained in this view.
75          */
76         unordered_set< shared_ptr<data::SignalBase> > signalbases() const;
77
78         virtual void clear_signalbases();
79
80         virtual void add_signalbase(const shared_ptr<data::SignalBase> signalbase);
81
82 #ifdef ENABLE_DECODE
83         virtual void clear_decode_signals();
84
85         virtual void add_decode_signal(shared_ptr<data::DecodeSignal> signal);
86
87         virtual void remove_decode_signal(shared_ptr<data::DecodeSignal> signal);
88 #endif
89
90         virtual void save_settings(QSettings &settings) const;
91
92         virtual void restore_settings(QSettings &settings);
93
94 public Q_SLOTS:
95         virtual void trigger_event(util::Timestamp location);
96         virtual void signals_changed();
97         virtual void capture_state_updated(int state);
98         virtual void perform_delayed_view_update();
99
100 private Q_SLOTS:
101         void on_data_updated();
102
103 protected:
104         Session &session_;
105
106         const bool is_main_view_;
107
108         util::TimeUnit time_unit_;
109
110         unordered_set< shared_ptr<data::SignalBase> > signalbases_;
111
112         QTimer delayed_view_updater_;
113 };
114
115 } // namespace views
116 } // namespace pv
117
118 #endif // PULSEVIEW_PV_VIEWS_VIEWBASE_HPP