]> sigrok.org Git - pulseview.git/blame - pv/views/viewbase.cpp
Change parameter to ViewBase constructor
[pulseview.git] / pv / views / viewbase.cpp
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#ifdef ENABLE_DECODE
22#include <libsigrokdecode/libsigrokdecode.h>
23#endif
24
25#include <libsigrokcxx/libsigrokcxx.hpp>
26
27#include "pv/session.hpp"
28#include "pv/util.hpp"
8c339741 29#include "pv/data/segment.hpp"
f4e57597
SA
30
31using std::shared_ptr;
32
33namespace pv {
34namespace views {
35
baf867ed
SA
36const char* ViewTypeNames[ViewTypeCount] = {
37 "Trace View",
38#ifdef ENABLE_DECODE
39 "Decoder Output View"
40#endif
41};
42
5ed05b69
SA
43const int ViewBase::MaxViewAutoUpdateRate = 25; // No more than 25 Hz
44
a24412db 45ViewBase::ViewBase(Session &session, bool is_main_view, QMainWindow *parent) :
5a206446 46 // Note: Place defaults in ViewBase::reset_view_state(), not here
79926d3f 47 QWidget(parent),
143d322d 48 session_(session),
5a206446 49 is_main_view_(is_main_view)
f4e57597
SA
50{
51 (void)parent;
52
53 connect(&session_, SIGNAL(signals_changed()),
54 this, SLOT(signals_changed()));
55 connect(&session_, SIGNAL(capture_state_changed(int)),
56 this, SLOT(capture_state_updated(int)));
4e86ec70
SA
57 connect(&session_, SIGNAL(new_segment(int)),
58 this, SLOT(on_new_segment(int)));
5ed05b69
SA
59
60 connect(&delayed_view_updater_, SIGNAL(timeout()),
61 this, SLOT(perform_delayed_view_update()));
62 delayed_view_updater_.setSingleShot(true);
63 delayed_view_updater_.setInterval(1000 / MaxViewAutoUpdateRate);
f4e57597
SA
64}
65
5a206446
SA
66void ViewBase::reset_view_state()
67{
5a206446
SA
68 current_segment_ = 0;
69}
70
f4e57597
SA
71Session& ViewBase::session()
72{
73 return session_;
74}
75
76const Session& ViewBase::session() const
77{
78 return session_;
79}
80
81void ViewBase::clear_signals()
82{
83}
84
5ed05b69
SA
85unordered_set< shared_ptr<data::SignalBase> > ViewBase::signalbases() const
86{
87 return signalbases_;
88}
89
90void ViewBase::clear_signalbases()
91{
f4ab4b5c 92 for (const shared_ptr<data::SignalBase>& signalbase : signalbases_) {
5ed05b69
SA
93 disconnect(signalbase.get(), SIGNAL(samples_cleared()),
94 this, SLOT(on_data_updated()));
7f894d95
SA
95 disconnect(signalbase.get(), SIGNAL(samples_added(uint64_t, uint64_t, uint64_t)),
96 this, SLOT(on_samples_added(uint64_t, uint64_t, uint64_t)));
5ed05b69
SA
97 }
98
99 signalbases_.clear();
100}
101
102void ViewBase::add_signalbase(const shared_ptr<data::SignalBase> signalbase)
103{
104 signalbases_.insert(signalbase);
105
106 connect(signalbase.get(), SIGNAL(samples_cleared()),
107 this, SLOT(on_data_updated()));
7f894d95
SA
108 connect(signalbase.get(), SIGNAL(samples_added(uint64_t, uint64_t, uint64_t)),
109 this, SLOT(on_samples_added(uint64_t, uint64_t, uint64_t)));
5ed05b69
SA
110}
111
f4e57597
SA
112#ifdef ENABLE_DECODE
113void ViewBase::clear_decode_signals()
114{
115}
116
ad908057 117void ViewBase::add_decode_signal(shared_ptr<data::DecodeSignal> signal)
f4e57597 118{
ad908057 119 (void)signal;
f4e57597
SA
120}
121
ad908057 122void ViewBase::remove_decode_signal(shared_ptr<data::DecodeSignal> signal)
f4e57597 123{
ad908057 124 (void)signal;
f4e57597
SA
125}
126#endif
127
128void ViewBase::save_settings(QSettings &settings) const
129{
130 (void)settings;
131}
132
133void ViewBase::restore_settings(QSettings &settings)
134{
135 (void)settings;
136}
137
7ea2a4ff 138void ViewBase::trigger_event(int segment_id, util::Timestamp location)
f4e57597 139{
7ea2a4ff 140 (void)segment_id;
f4e57597
SA
141 (void)location;
142}
143
144void ViewBase::signals_changed()
145{
146}
147
4e86ec70
SA
148void ViewBase::on_new_segment(int new_segment_id)
149{
150 (void)new_segment_id;
151}
152
558ad6ce
SA
153void ViewBase::on_segment_completed(int new_segment_id)
154{
155 (void)new_segment_id;
156}
157
f4e57597
SA
158void ViewBase::capture_state_updated(int state)
159{
160 (void)state;
161}
162
5ed05b69
SA
163void ViewBase::perform_delayed_view_update()
164{
165}
166
7f894d95 167void ViewBase::on_samples_added(uint64_t segment_id, uint64_t start_sample,
8c339741
SA
168 uint64_t end_sample)
169{
170 (void)start_sample;
171 (void)end_sample;
172
7f894d95 173 if (segment_id != current_segment_)
8c339741
SA
174 return;
175
176 if (!delayed_view_updater_.isActive())
177 delayed_view_updater_.start();
178}
179
5ed05b69 180void ViewBase::on_data_updated()
f4e57597 181{
5ed05b69
SA
182 if (!delayed_view_updater_.isActive())
183 delayed_view_updater_.start();
f4e57597
SA
184}
185
870ea3db 186} // namespace views
f4e57597 187} // namespace pv