From: Soeren Apel Date: Mon, 13 Feb 2017 22:39:13 +0000 (+0100) Subject: Perform autoranging for analog traces also when new data comes in X-Git-Tag: pulseview-0.4.0~190 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=85715407f784767052238586f4e7f64440b7693e;p=pulseview.git Perform autoranging for analog traces also when new data comes in --- diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 1821ad1e..857898c5 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -81,6 +81,7 @@ MainWindow::MainWindow(DeviceManager &device_manager, icon_grey_(":/icons/status-grey.svg") { qRegisterMetaType("util::Timestamp"); + qRegisterMetaType("uint64_t"); setup_ui(); restore_ui_settings(); diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 07fb0ef8..d9ac2f60 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -82,6 +82,12 @@ AnalogSignal::AnalogSignal( resolution_(0), autoranging_(1) { + pv::data::Analog* analog_data = + dynamic_cast(data().get()); + + connect(analog_data, SIGNAL(samples_added(QObject*, uint64_t, uint64_t)), + this, SLOT(on_samples_added())); + base_->set_colour(SignalColours[base_->index() % countof(SignalColours)]); update_scale(); } @@ -456,6 +462,17 @@ void AnalogSignal::populate_popup_form(QWidget *parent, QFormLayout *form) form->addRow(layout); } +void AnalogSignal::on_samples_added() +{ + perform_autoranging(); + + if (owner_) { + // Call order is important, otherwise the lazy event handler won't work + owner_->extents_changed(false, true); + owner_->row_item_appearance_changed(false, true); + } +} + void AnalogSignal::on_pos_vdivs_changed(int vdivs) { pos_vdivs_ = vdivs; @@ -500,8 +517,11 @@ void AnalogSignal::on_autoranging_changed(int state) if (autoranging_) perform_autoranging(true); - if (owner_) + if (owner_) { + // Call order is important, otherwise the lazy event handler won't work + owner_->extents_changed(false, true); owner_->row_item_appearance_changed(false, true); + } } } // namespace TraceView diff --git a/pv/view/analogsignal.hpp b/pv/view/analogsignal.hpp index 5223338c..542edda9 100644 --- a/pv/view/analogsignal.hpp +++ b/pv/view/analogsignal.hpp @@ -132,6 +132,8 @@ protected: void populate_popup_form(QWidget *parent, QFormLayout *form); private Q_SLOTS: + void on_samples_added(); + void on_pos_vdivs_changed(int vdivs); void on_neg_vdivs_changed(int vdivs);