]> sigrok.org Git - pulseview.git/blame - pv/views/viewbase.cpp
Rework new segment notification mechanism
[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"
29
30using std::shared_ptr;
31
32namespace pv {
33namespace views {
34
5ed05b69
SA
35const int ViewBase::MaxViewAutoUpdateRate = 25; // No more than 25 Hz
36
143d322d
SA
37ViewBase::ViewBase(Session &session, bool is_main_view, QWidget *parent) :
38 session_(session),
39 is_main_view_(is_main_view)
f4e57597
SA
40{
41 (void)parent;
42
43 connect(&session_, SIGNAL(signals_changed()),
44 this, SLOT(signals_changed()));
45 connect(&session_, SIGNAL(capture_state_changed(int)),
46 this, SLOT(capture_state_updated(int)));
4e86ec70
SA
47 connect(&session_, SIGNAL(new_segment(int)),
48 this, SLOT(on_new_segment(int)));
5ed05b69
SA
49
50 connect(&delayed_view_updater_, SIGNAL(timeout()),
51 this, SLOT(perform_delayed_view_update()));
52 delayed_view_updater_.setSingleShot(true);
53 delayed_view_updater_.setInterval(1000 / MaxViewAutoUpdateRate);
f4e57597
SA
54}
55
56Session& ViewBase::session()
57{
58 return session_;
59}
60
61const Session& ViewBase::session() const
62{
63 return session_;
64}
65
66void ViewBase::clear_signals()
67{
68}
69
5ed05b69
SA
70unordered_set< shared_ptr<data::SignalBase> > ViewBase::signalbases() const
71{
72 return signalbases_;
73}
74
75void ViewBase::clear_signalbases()
76{
77 for (shared_ptr<data::SignalBase> signalbase : signalbases_) {
78 disconnect(signalbase.get(), SIGNAL(samples_cleared()),
79 this, SLOT(on_data_updated()));
80 disconnect(signalbase.get(), SIGNAL(samples_added(QObject*, uint64_t, uint64_t)),
81 this, SLOT(on_data_updated()));
82 }
83
84 signalbases_.clear();
85}
86
87void ViewBase::add_signalbase(const shared_ptr<data::SignalBase> signalbase)
88{
89 signalbases_.insert(signalbase);
90
91 connect(signalbase.get(), SIGNAL(samples_cleared()),
92 this, SLOT(on_data_updated()));
93 connect(signalbase.get(), SIGNAL(samples_added(QObject*, uint64_t, uint64_t)),
94 this, SLOT(on_data_updated()));
95}
96
f4e57597
SA
97#ifdef ENABLE_DECODE
98void ViewBase::clear_decode_signals()
99{
100}
101
ad908057 102void ViewBase::add_decode_signal(shared_ptr<data::DecodeSignal> signal)
f4e57597 103{
ad908057 104 (void)signal;
f4e57597
SA
105}
106
ad908057 107void ViewBase::remove_decode_signal(shared_ptr<data::DecodeSignal> signal)
f4e57597 108{
ad908057 109 (void)signal;
f4e57597
SA
110}
111#endif
112
113void ViewBase::save_settings(QSettings &settings) const
114{
115 (void)settings;
116}
117
118void ViewBase::restore_settings(QSettings &settings)
119{
120 (void)settings;
121}
122
123void ViewBase::trigger_event(util::Timestamp location)
124{
125 (void)location;
126}
127
128void ViewBase::signals_changed()
129{
130}
131
4e86ec70
SA
132void ViewBase::on_new_segment(int new_segment_id)
133{
134 (void)new_segment_id;
135}
136
f4e57597
SA
137void ViewBase::capture_state_updated(int state)
138{
139 (void)state;
140}
141
5ed05b69
SA
142void ViewBase::perform_delayed_view_update()
143{
144}
145
146void ViewBase::on_data_updated()
f4e57597 147{
5ed05b69
SA
148 if (!delayed_view_updater_.isActive())
149 delayed_view_updater_.start();
f4e57597
SA
150}
151
870ea3db 152} // namespace views
f4e57597 153} // namespace pv