]> sigrok.org Git - pulseview.git/blob - pv/views/viewbase.hpp
Move trace view files
[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 using std::shared_ptr;
36 using std::unordered_set;
37
38 namespace pv {
39
40 class Session;
41
42 namespace view {
43 class DecodeTrace;
44 class Signal;
45 }
46
47 namespace views {
48
49 enum ViewType {
50         ViewTypeTrace,
51         ViewTypeTabularDecode
52 };
53
54 class ViewBase : public QWidget
55 {
56         Q_OBJECT
57
58 private:
59         static const int MaxViewAutoUpdateRate;
60
61 public:
62         explicit ViewBase(Session &session, bool is_main_view = false, QWidget *parent = nullptr);
63
64         Session& session();
65         const Session& session() const;
66
67         virtual void clear_signals();
68
69         /**
70          * Returns the signal bases contained in this view.
71          */
72         unordered_set< shared_ptr<data::SignalBase> > signalbases() const;
73
74         virtual void clear_signalbases();
75
76         virtual void add_signalbase(const shared_ptr<data::SignalBase> signalbase);
77
78 #ifdef ENABLE_DECODE
79         virtual void clear_decode_signals();
80
81         virtual void add_decode_signal(shared_ptr<data::SignalBase> signalbase);
82
83         virtual void remove_decode_signal(shared_ptr<data::SignalBase> signalbase);
84 #endif
85
86         virtual void save_settings(QSettings &settings) const;
87
88         virtual void restore_settings(QSettings &settings);
89
90 public Q_SLOTS:
91         virtual void trigger_event(util::Timestamp location);
92         virtual void signals_changed();
93         virtual void capture_state_updated(int state);
94         virtual void perform_delayed_view_update();
95
96 private Q_SLOTS:
97         void on_data_updated();
98
99 protected:
100         Session &session_;
101
102         const bool is_main_view_;
103
104         util::TimeUnit time_unit_;
105
106         unordered_set< shared_ptr<data::SignalBase> > signalbases_;
107
108         QTimer delayed_view_updater_;
109 };
110
111 } // namespace views
112 } // namespace pv
113
114 #endif // PULSEVIEW_PV_VIEWS_VIEWBASE_HPP