]> sigrok.org Git - pulseview.git/commitdiff
Perform autoranging for analog traces also when new data comes in
authorSoeren Apel <redacted>
Mon, 13 Feb 2017 22:39:13 +0000 (23:39 +0100)
committerUwe Hermann <redacted>
Wed, 15 Feb 2017 11:12:52 +0000 (12:12 +0100)
pv/mainwindow.cpp
pv/view/analogsignal.cpp
pv/view/analogsignal.hpp

index 1821ad1e67a69276bd3e6b04c607df0e2c1f121f..857898c52e98b514440fd3f561babe8def1894cc 100644 (file)
@@ -81,6 +81,7 @@ MainWindow::MainWindow(DeviceManager &device_manager,
        icon_grey_(":/icons/status-grey.svg")
 {
        qRegisterMetaType<util::Timestamp>("util::Timestamp");
+       qRegisterMetaType<uint64_t>("uint64_t");
 
        setup_ui();
        restore_ui_settings();
index 07fb0ef89fa8ab59c2930c5be11972388377f0cd..d9ac2f60afcf853d1b225a18c139854ec94ed824 100644 (file)
@@ -82,6 +82,12 @@ AnalogSignal::AnalogSignal(
        resolution_(0),
        autoranging_(1)
 {
+       pv::data::Analog* analog_data =
+               dynamic_cast<pv::data::Analog*>(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
index 5223338ce5c579d08ebb608fae389ec88b1bb777..542edda95e190237d0638be53b55447b24fdf261 100644 (file)
@@ -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);