X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fviews%2Fviewbase.cpp;h=c463ecc2d1a8dc16792a2c25a58f45836b8caaf7;hp=6fb95279fe8fb5b5958e6ce2c0f7b13fd020efc1;hb=46ebcd3f6f85092a9eb6401f6f56cee8fa08131a;hpb=efdec55aec1a137460fa362a381ed1904182bfed diff --git a/pv/views/viewbase.cpp b/pv/views/viewbase.cpp index 6fb95279..c463ecc2 100644 --- a/pv/views/viewbase.cpp +++ b/pv/views/viewbase.cpp @@ -26,14 +26,19 @@ #include "pv/session.hpp" #include "pv/util.hpp" +#include "pv/data/segment.hpp" using std::shared_ptr; namespace pv { namespace views { -ViewBase::ViewBase(Session &session, QWidget *parent) : - session_(session) +const int ViewBase::MaxViewAutoUpdateRate = 25; // No more than 25 Hz + +ViewBase::ViewBase(Session &session, bool is_main_view, QWidget *parent) : + // Note: Place defaults in ViewBase::reset_view_state(), not here + session_(session), + is_main_view_(is_main_view) { (void)parent; @@ -41,10 +46,19 @@ ViewBase::ViewBase(Session &session, QWidget *parent) : this, SLOT(signals_changed())); connect(&session_, SIGNAL(capture_state_changed(int)), this, SLOT(capture_state_updated(int))); - connect(&session_, SIGNAL(data_received()), - this, SLOT(data_updated())); - connect(&session_, SIGNAL(frame_ended()), - this, SLOT(data_updated())); + connect(&session_, SIGNAL(new_segment(int)), + this, SLOT(on_new_segment(int))); + + connect(&delayed_view_updater_, SIGNAL(timeout()), + this, SLOT(perform_delayed_view_update())); + delayed_view_updater_.setSingleShot(true); + delayed_view_updater_.setInterval(1000 / MaxViewAutoUpdateRate); +} + +void ViewBase::reset_view_state() +{ + ruler_shift_ = 0; + current_segment_ = 0; } Session& ViewBase::session() @@ -61,19 +75,46 @@ void ViewBase::clear_signals() { } +unordered_set< shared_ptr > ViewBase::signalbases() const +{ + return signalbases_; +} + +void ViewBase::clear_signalbases() +{ + for (shared_ptr signalbase : signalbases_) { + disconnect(signalbase.get(), SIGNAL(samples_cleared()), + this, SLOT(on_data_updated())); + disconnect(signalbase.get(), SIGNAL(samples_added(uint64_t, uint64_t, uint64_t)), + this, SLOT(on_samples_added(uint64_t, uint64_t, uint64_t))); + } + + signalbases_.clear(); +} + +void ViewBase::add_signalbase(const shared_ptr signalbase) +{ + signalbases_.insert(signalbase); + + connect(signalbase.get(), SIGNAL(samples_cleared()), + this, SLOT(on_data_updated())); + connect(signalbase.get(), SIGNAL(samples_added(uint64_t, uint64_t, uint64_t)), + this, SLOT(on_samples_added(uint64_t, uint64_t, uint64_t))); +} + #ifdef ENABLE_DECODE void ViewBase::clear_decode_signals() { } -void ViewBase::add_decode_signal(shared_ptr signalbase) +void ViewBase::add_decode_signal(shared_ptr signal) { - (void)signalbase; + (void)signal; } -void ViewBase::remove_decode_signal(shared_ptr signalbase) +void ViewBase::remove_decode_signal(shared_ptr signal) { - (void)signalbase; + (void)signal; } #endif @@ -87,8 +128,9 @@ void ViewBase::restore_settings(QSettings &settings) (void)settings; } -void ViewBase::trigger_event(util::Timestamp location) +void ViewBase::trigger_event(int segment_id, util::Timestamp location) { + (void)segment_id; (void)location; } @@ -96,14 +138,43 @@ void ViewBase::signals_changed() { } +void ViewBase::on_new_segment(int new_segment_id) +{ + (void)new_segment_id; +} + +void ViewBase::on_segment_completed(int new_segment_id) +{ + (void)new_segment_id; +} + void ViewBase::capture_state_updated(int state) { (void)state; } -void ViewBase::data_updated() +void ViewBase::perform_delayed_view_update() +{ +} + +void ViewBase::on_samples_added(uint64_t segment_id, uint64_t start_sample, + uint64_t end_sample) +{ + (void)start_sample; + (void)end_sample; + + if (segment_id != current_segment_) + return; + + if (!delayed_view_updater_.isActive()) + delayed_view_updater_.start(); +} + +void ViewBase::on_data_updated() { + if (!delayed_view_updater_.isActive()) + delayed_view_updater_.start(); } -} // namespace view +} // namespace views } // namespace pv