X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fviews%2Fviewbase.cpp;h=4449d1905f921dbce64c087765fc4c7450a5c48c;hp=b1190562a9338b15c25926002b0781fde9283d43;hb=79926d3fcc446c00fd892d008978390053634415;hpb=143d322d0c92ea5c2cc51facc37b68787362c244 diff --git a/pv/views/viewbase.cpp b/pv/views/viewbase.cpp index b119056..4449d19 100644 --- a/pv/views/viewbase.cpp +++ b/pv/views/viewbase.cpp @@ -26,13 +26,18 @@ #include "pv/session.hpp" #include "pv/util.hpp" +#include "pv/data/segment.hpp" using std::shared_ptr; namespace pv { namespace views { +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 + QWidget(parent), session_(session), is_main_view_(is_main_view) { @@ -42,10 +47,18 @@ ViewBase::ViewBase(Session &session, bool is_main_view, 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() +{ + current_segment_ = 0; } Session& ViewBase::session() @@ -62,19 +75,46 @@ void ViewBase::clear_signals() { } +unordered_set< shared_ptr > ViewBase::signalbases() const +{ + return signalbases_; +} + +void ViewBase::clear_signalbases() +{ + for (const 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 @@ -88,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; } @@ -97,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