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/>.
22 #include <libsigrokdecode/libsigrokdecode.h>
25 #include <libsigrokcxx/libsigrokcxx.hpp>
27 #include "pv/session.hpp"
28 #include "pv/util.hpp"
30 using std::shared_ptr;
35 const int ViewBase::MaxViewAutoUpdateRate = 25; // No more than 25 Hz
37 ViewBase::ViewBase(Session &session, bool is_main_view, QWidget *parent) :
39 is_main_view_(is_main_view)
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)));
47 connect(&session_, SIGNAL(new_segment(int)),
48 this, SLOT(on_new_segment(int)));
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);
56 Session& ViewBase::session()
61 const Session& ViewBase::session() const
66 void ViewBase::clear_signals()
70 unordered_set< shared_ptr<data::SignalBase> > ViewBase::signalbases() const
75 void ViewBase::clear_signalbases()
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()));
87 void ViewBase::add_signalbase(const shared_ptr<data::SignalBase> signalbase)
89 signalbases_.insert(signalbase);
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()));
98 void ViewBase::clear_decode_signals()
102 void ViewBase::add_decode_signal(shared_ptr<data::DecodeSignal> signal)
107 void ViewBase::remove_decode_signal(shared_ptr<data::DecodeSignal> signal)
113 void ViewBase::save_settings(QSettings &settings) const
118 void ViewBase::restore_settings(QSettings &settings)
123 void ViewBase::trigger_event(util::Timestamp location)
128 void ViewBase::signals_changed()
132 void ViewBase::on_new_segment(int new_segment_id)
134 (void)new_segment_id;
137 void ViewBase::capture_state_updated(int state)
142 void ViewBase::perform_delayed_view_update()
146 void ViewBase::on_data_updated()
148 if (!delayed_view_updater_.isActive())
149 delayed_view_updater_.start();