]>
Commit | Line | Data |
---|---|---|
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 | ViewTypeDecoderOutput, | |
56 | ViewTypeTabularDecode | |
57 | }; | |
58 | ||
59 | class ViewBase : public QWidget | |
60 | { | |
61 | Q_OBJECT | |
62 | ||
63 | private: | |
64 | static const int MaxViewAutoUpdateRate; | |
65 | ||
66 | public: | |
67 | explicit ViewBase(Session &session, bool is_main_view = false, QWidget *parent = nullptr); | |
68 | ||
69 | /** | |
70 | * Resets the view to its default state after construction. It does however | |
71 | * not reset the signal bases or any other connections with the session. | |
72 | */ | |
73 | virtual void reset_view_state(); | |
74 | ||
75 | Session& session(); | |
76 | const Session& session() const; | |
77 | ||
78 | virtual void clear_signals(); | |
79 | ||
80 | /** | |
81 | * Returns the signal bases contained in this view. | |
82 | */ | |
83 | unordered_set< shared_ptr<data::SignalBase> > signalbases() const; | |
84 | ||
85 | virtual void clear_signalbases(); | |
86 | ||
87 | virtual void add_signalbase(const shared_ptr<data::SignalBase> signalbase); | |
88 | ||
89 | #ifdef ENABLE_DECODE | |
90 | virtual void clear_decode_signals(); | |
91 | ||
92 | virtual void add_decode_signal(shared_ptr<data::DecodeSignal> signal); | |
93 | ||
94 | virtual void remove_decode_signal(shared_ptr<data::DecodeSignal> signal); | |
95 | #endif | |
96 | ||
97 | virtual void save_settings(QSettings &settings) const; | |
98 | ||
99 | virtual void restore_settings(QSettings &settings); | |
100 | ||
101 | public Q_SLOTS: | |
102 | virtual void trigger_event(int segment_id, util::Timestamp location); | |
103 | virtual void signals_changed(); | |
104 | virtual void capture_state_updated(int state); | |
105 | virtual void on_new_segment(int new_segment_id); | |
106 | virtual void on_segment_completed(int new_segment_id); | |
107 | virtual void perform_delayed_view_update(); | |
108 | ||
109 | private Q_SLOTS: | |
110 | void on_samples_added(uint64_t segment_id, uint64_t start_sample, | |
111 | uint64_t end_sample); | |
112 | ||
113 | void on_data_updated(); | |
114 | ||
115 | protected: | |
116 | Session &session_; | |
117 | ||
118 | const bool is_main_view_; | |
119 | ||
120 | util::TimeUnit time_unit_; | |
121 | ||
122 | unordered_set< shared_ptr<data::SignalBase> > signalbases_; | |
123 | ||
124 | /// The ID of the currently displayed segment | |
125 | uint32_t current_segment_; | |
126 | ||
127 | QTimer delayed_view_updater_; | |
128 | }; | |
129 | ||
130 | } // namespace views | |
131 | } // namespace pv | |
132 | ||
133 | #endif // PULSEVIEW_PV_VIEWS_VIEWBASE_HPP |