]> sigrok.org Git - pulseview.git/blame - pv/views/viewbase.hpp
session: Add support for input format options (-I cmdline parameter)
[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
6f925ba9 35using std::shared_ptr;
5ed05b69 36using std::unordered_set;
6f925ba9 37
f4e57597
SA
38namespace pv {
39
40class Session;
41
42namespace view {
43class DecodeTrace;
44class Signal;
45}
46
47namespace views {
48
49enum ViewType {
50 ViewTypeTrace,
51 ViewTypeTabularDecode
52};
53
c063290a
UH
54class ViewBase : public QWidget
55{
f4e57597
SA
56 Q_OBJECT
57
5ed05b69
SA
58private:
59 static const int MaxViewAutoUpdateRate;
60
f4e57597 61public:
c063290a 62 explicit ViewBase(Session &session, bool is_main_view = false, QWidget *parent = nullptr);
f4e57597
SA
63
64 Session& session();
65 const Session& session() const;
66
67 virtual void clear_signals();
68
5ed05b69
SA
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
f4e57597
SA
78#ifdef ENABLE_DECODE
79 virtual void clear_decode_signals();
80
6f925ba9 81 virtual void add_decode_signal(shared_ptr<data::SignalBase> signalbase);
f4e57597 82
6f925ba9 83 virtual void remove_decode_signal(shared_ptr<data::SignalBase> signalbase);
f4e57597
SA
84#endif
85
86 virtual void save_settings(QSettings &settings) const;
87
88 virtual void restore_settings(QSettings &settings);
89
90public Q_SLOTS:
91 virtual void trigger_event(util::Timestamp location);
92 virtual void signals_changed();
93 virtual void capture_state_updated(int state);
5ed05b69
SA
94 virtual void perform_delayed_view_update();
95
96private Q_SLOTS:
97 void on_data_updated();
f4e57597
SA
98
99protected:
100 Session &session_;
101
143d322d
SA
102 const bool is_main_view_;
103
f4e57597 104 util::TimeUnit time_unit_;
5ed05b69
SA
105
106 unordered_set< shared_ptr<data::SignalBase> > signalbases_;
107
108 QTimer delayed_view_updater_;
f4e57597
SA
109};
110
111} // namespace views
112} // namespace pv
113
114#endif // PULSEVIEW_PV_VIEWS_VIEWBASE_HPP