2 * This file is part of the PulseView project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 * Copyright (C) 2016 Soeren Apel <soeren@apelpie.net>
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.
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.
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/>.
21 #ifndef PULSEVIEW_PV_VIEWS_VIEWBASE_HPP
22 #define PULSEVIEW_PV_VIEWS_VIEWBASE_HPP
26 #include <unordered_set>
32 #include <pv/data/signalbase.hpp>
33 #include <pv/util.hpp>
36 #include <pv/data/decodesignal.hpp>
39 using std::shared_ptr;
40 using std::unordered_set;
53 // When adding an entry here, don't forget to update ViewTypeNames as well
57 ViewTypeDecoderOutput,
59 ViewTypeCount // Indicates how many view types there are, must always be last
62 extern const char* ViewTypeNames[ViewTypeCount];
64 class ViewBase : public QWidget
69 static const int MaxViewAutoUpdateRate;
72 explicit ViewBase(Session &session, bool is_main_view = false, QWidget *parent = nullptr);
75 * Resets the view to its default state after construction. It does however
76 * not reset the signal bases or any other connections with the session.
78 virtual void reset_view_state();
81 const Session& session() const;
83 virtual void clear_signals();
86 * Returns the signal bases contained in this view.
88 unordered_set< shared_ptr<data::SignalBase> > signalbases() const;
90 virtual void clear_signalbases();
92 virtual void add_signalbase(const shared_ptr<data::SignalBase> signalbase);
95 virtual void clear_decode_signals();
97 virtual void add_decode_signal(shared_ptr<data::DecodeSignal> signal);
99 virtual void remove_decode_signal(shared_ptr<data::DecodeSignal> signal);
102 virtual void save_settings(QSettings &settings) const;
104 virtual void restore_settings(QSettings &settings);
107 virtual void trigger_event(int segment_id, util::Timestamp location);
108 virtual void signals_changed();
109 virtual void capture_state_updated(int state);
110 virtual void on_new_segment(int new_segment_id);
111 virtual void on_segment_completed(int new_segment_id);
112 virtual void perform_delayed_view_update();
115 void on_samples_added(uint64_t segment_id, uint64_t start_sample,
116 uint64_t end_sample);
118 void on_data_updated();
123 const bool is_main_view_;
125 util::TimeUnit time_unit_;
127 unordered_set< shared_ptr<data::SignalBase> > signalbases_;
129 /// The ID of the currently displayed segment
130 uint32_t current_segment_;
132 QTimer delayed_view_updater_;
138 #endif // PULSEVIEW_PV_VIEWS_VIEWBASE_HPP