From ba34aeb95f09257349e35dba7e6aec7d5da13ef3 Mon Sep 17 00:00:00 2001 From: DreamSourceLab Date: Tue, 14 Jan 2020 22:38:01 +0800 Subject: [PATCH] Fix vertical scale issue after stop capturing @dso mode --- DSView/pv/sigsession.cpp | 29 +++++++++++++++++++++++++++++ DSView/pv/sigsession.h | 5 +++++ DSView/pv/toolbars/samplingbar.cpp | 14 +------------- DSView/pv/view/dsosignal.cpp | 10 +++------- DSView/pv/view/dsosignal.h | 1 - 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 3debb650..2a56b405 100755 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -116,6 +116,7 @@ SigSession::SigSession(DeviceManager &device_manager) : _math_trace = NULL; _saving = false; _dso_feed = false; + _stop_scale = 1; // Create snapshots & data containers _cur_logic_snapshot.reset(new data::LogicSnapshot()); @@ -351,6 +352,7 @@ void SigSession::capture_init() set_cur_snap_samplerate(_dev_inst->get_sample_rate()); set_cur_samplelimits(_dev_inst->get_sample_limit()); + set_stop_scale(1); _data_updated = false; _trigger_flag = false; _trigger_ch = 0; @@ -1781,4 +1783,31 @@ void SigSession::set_saving(bool saving) _saving = saving; } +void SigSession::exit_capture() +{ + set_repeating(false); + bool wait_upload = false; + if (get_run_mode() != SigSession::Repetitive) { + GVariant *gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_WAIT_UPLOAD); + if (gvar != NULL) { + wait_upload = g_variant_get_boolean(gvar); + g_variant_unref(gvar); + } + } + if (!wait_upload) { + stop_capture(); + capture_state_changed(SigSession::Stopped); + } +} + +float SigSession::stop_scale() const +{ + return _stop_scale; +} + +void SigSession::set_stop_scale(float scale) +{ + _stop_scale = scale; +} + } // namespace pv diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h index 6d71c9cf..96fd0649 100755 --- a/DSView/pv/sigsession.h +++ b/DSView/pv/sigsession.h @@ -256,6 +256,10 @@ public: uint64_t get_save_end() const; bool get_saving() const; void set_saving(bool saving); + void set_stop_scale(float scale); + float stop_scale() const; + + void exit_capture(); private: void set_capture_state(capture_state state); @@ -367,6 +371,7 @@ private: bool _saving; bool _dso_feed; + float _stop_scale; signals: void capture_state_changed(int state); diff --git a/DSView/pv/toolbars/samplingbar.cpp b/DSView/pv/toolbars/samplingbar.cpp index bf60dbf7..13505a07 100755 --- a/DSView/pv/toolbars/samplingbar.cpp +++ b/DSView/pv/toolbars/samplingbar.cpp @@ -822,19 +822,7 @@ void SamplingBar::commit_settings() void SamplingBar::on_run_stop() { if (get_sampling() || _session.isRepeating()) { - _session.set_repeating(false); - bool wait_upload = false; - if (_session.get_run_mode() != SigSession::Repetitive) { - GVariant *gvar = get_selected_device()->get_config(NULL, NULL, SR_CONF_WAIT_UPLOAD); - if (gvar != NULL) { - wait_upload = g_variant_get_boolean(gvar); - g_variant_unref(gvar); - } - } - if (!wait_upload) { - _session.stop_capture(); - _session.capture_state_changed(SigSession::Stopped); - } + _session.exit_capture(); } else { enable_run_stop(false); enable_instant(false); diff --git a/DSView/pv/view/dsosignal.cpp b/DSView/pv/view/dsosignal.cpp index 7999855b..ea510127 100755 --- a/DSView/pv/view/dsosignal.cpp +++ b/DSView/pv/view/dsosignal.cpp @@ -62,7 +62,6 @@ DsoSignal::DsoSignal(boost::shared_ptr dev_inst, Signal(dev_inst, probe), _data(data), _scale(0), - _stop_scale(1), _en_lock(false), _show(true), _vDialActive(false), @@ -121,7 +120,7 @@ boost::shared_ptr DsoSignal::dso_data() const void DsoSignal::set_scale(int height) { - _scale = height / (_ref_max - _ref_min) * _stop_scale; + _scale = height / (_ref_max - _ref_min) * _view->session().stop_scale(); } float DsoSignal::get_scale() @@ -218,7 +217,7 @@ bool DsoSignal::go_vDialPre(bool manul) _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV, g_variant_new_uint64(_vDial->get_value())); if (_view->session().get_capture_state() == SigSession::Stopped) { - _stop_scale *= pre_vdiv/_vDial->get_value(); + _view->session().set_stop_scale(_view->session().stop_scale() * (pre_vdiv/_vDial->get_value())); set_scale(get_view_rect().height()); } _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET, @@ -248,7 +247,7 @@ bool DsoSignal::go_vDialNext(bool manul) _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV, g_variant_new_uint64(_vDial->get_value())); if (_view->session().get_capture_state() == SigSession::Stopped) { - _stop_scale *= pre_vdiv/_vDial->get_value(); + _view->session().set_stop_scale(_view->session().stop_scale() * (pre_vdiv/_vDial->get_value())); set_scale(get_view_rect().height()); } _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET, @@ -839,9 +838,6 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColor assert(_view); assert(right >= left); - if (_view->session().get_capture_state() == SigSession::Running) - _stop_scale = 1; - if (enabled()) { const int index = get_index(); const int width = right - left; diff --git a/DSView/pv/view/dsosignal.h b/DSView/pv/view/dsosignal.h index 586f1ae1..a1b040c4 100755 --- a/DSView/pv/view/dsosignal.h +++ b/DSView/pv/view/dsosignal.h @@ -232,7 +232,6 @@ private: private: boost::shared_ptr _data; float _scale; - float _stop_scale; bool _en_lock; bool _show;