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