]> sigrok.org Git - pulseview.git/blob - pv/views/viewbase.hpp
c4ac059d0c169bfa24f7eb6fc9b950b7ee558852
[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 <stdint.h>
25
26 #include <memory>
27 #include <set>
28 #include <vector>
29
30 #include <QWidget>
31
32 #include <pv/data/signalbase.hpp>
33 #include <pv/util.hpp>
34
35 using std::shared_ptr;
36
37 namespace pv {
38
39 class Session;
40
41 namespace view {
42 class DecodeTrace;
43 class Signal;
44 }
45
46 namespace views {
47
48 enum ViewType {
49         ViewTypeTrace,
50         ViewTypeTabularDecode
51 };
52
53 class ViewBase : public QWidget {
54         Q_OBJECT
55
56 public:
57         explicit ViewBase(Session &session, bool is_main_view=false, QWidget *parent = nullptr);
58
59         Session& session();
60         const Session& session() const;
61
62         virtual void clear_signals();
63
64 #ifdef ENABLE_DECODE
65         virtual void clear_decode_signals();
66
67         virtual void add_decode_signal(shared_ptr<data::SignalBase> signalbase);
68
69         virtual void remove_decode_signal(shared_ptr<data::SignalBase> signalbase);
70 #endif
71
72         virtual void save_settings(QSettings &settings) const;
73
74         virtual void restore_settings(QSettings &settings);
75
76 public Q_SLOTS:
77         virtual void trigger_event(util::Timestamp location);
78         virtual void signals_changed();
79         virtual void capture_state_updated(int state);
80         virtual void data_updated();
81
82 protected:
83         Session &session_;
84
85         const bool is_main_view_;
86
87         util::TimeUnit time_unit_;
88 };
89
90 } // namespace views
91 } // namespace pv
92
93 #endif // PULSEVIEW_PV_VIEWS_VIEWBASE_HPP