fix: Unable to set a different scale for each channel on dso mode

This commit is contained in:
dreamsourcelabTAI 2023-07-06 14:00:41 +08:00
parent d05af104e0
commit a048fb9e97
9 changed files with 34 additions and 35 deletions

View File

@ -1458,7 +1458,7 @@ namespace pv
void MainWindow::on_signals_changed() void MainWindow::on_signals_changed()
{ {
_view->signals_changed(); _view->signals_changed(NULL);
} }
void MainWindow::receive_trigger(quint64 trigger_pos) void MainWindow::receive_trigger(quint64 trigger_pos)

View File

@ -112,7 +112,6 @@ namespace pv
_lissajous_trace = NULL; _lissajous_trace = NULL;
_math_trace = NULL; _math_trace = NULL;
_stop_scale = 1;
_is_decoding = false; _is_decoding = false;
_bClose = false; _bClose = false;
_callback = NULL; _callback = NULL;
@ -441,7 +440,6 @@ namespace pv
set_cur_snap_samplerate(_device_agent.get_sample_rate()); set_cur_snap_samplerate(_device_agent.get_sample_rate());
set_cur_samplelimits(_device_agent.get_sample_limit()); set_cur_samplelimits(_device_agent.get_sample_limit());
set_stop_scale(1);
_data_updated = false; _data_updated = false;
_trigger_flag = false; _trigger_flag = false;
@ -472,12 +470,13 @@ namespace pv
for (auto s : _signals) for (auto s : _signals)
{ {
if (s->signal_type() == SR_CHANNEL_DSO){ if (s->signal_type() == SR_CHANNEL_DSO){
view::DsoSignal *dsoSig = (view::DsoSignal*)s; auto sig = (view::DsoSignal*)s;
dsoSig->set_zero_ratio(dsoSig->get_zero_ratio()); sig->set_zero_ratio(sig->get_zero_ratio());
sig->set_stop_scale(1);
} }
else if (s->signal_type() == SR_CHANNEL_ANALOG){ else if (s->signal_type() == SR_CHANNEL_ANALOG){
view::AnalogSignal *analogSig = (view::AnalogSignal*)s; auto sig = (view::AnalogSignal*)s;
analogSig->set_zero_ratio(analogSig->get_zero_ratio()); sig->set_zero_ratio(sig->get_zero_ratio());
} }
} }

View File

@ -305,14 +305,6 @@ public:
return _save_end; return _save_end;
} }
inline void set_stop_scale(float scale){
_stop_scale = scale;
}
inline float stop_scale(){
return _stop_scale;
}
void clear_all_decoder(bool bUpdateView = true); void clear_all_decoder(bool bUpdateView = true);
inline bool is_closed(){ inline bool is_closed(){
@ -571,7 +563,6 @@ private:
SESSION_ERROR_STATUS _error; SESSION_ERROR_STATUS _error;
uint64_t _error_pattern; uint64_t _error_pattern;
int _map_zoom; int _map_zoom;
float _stop_scale;
bool _bClose; bool _bClose;
uint64_t _save_start; uint64_t _save_start;

View File

@ -541,7 +541,7 @@ void DecodeTrace::on_new_decode_data()
if (_view && _view->session().is_stopped_status()) if (_view && _view->session().is_stopped_status())
_view->data_updated(); _view->data_updated();
if (_totalHeight/_view->get_signalHeight() != rows_size()) if (_totalHeight/_view->get_signalHeight() != rows_size())
_view->signals_changed(); _view->signals_changed(NULL);
} }
int DecodeTrace::get_progress() int DecodeTrace::get_progress()

View File

@ -117,7 +117,7 @@ DsoSignal::~DsoSignal()
void DsoSignal::set_scale(int height) void DsoSignal::set_scale(int height)
{ {
_scale = height / (_ref_max - _ref_min) * session->stop_scale(); _scale = height / (_ref_max - _ref_min) * _stop_scale;
} }
void DsoSignal::set_enable(bool enable) void DsoSignal::set_enable(bool enable)
@ -191,7 +191,7 @@ bool DsoSignal::go_vDialPre(bool manul)
_vDial->get_value(), _probe, NULL); _vDial->get_value(), _probe, NULL);
if (session->is_stopped_status()) { if (session->is_stopped_status()) {
session->set_stop_scale(session->stop_scale() * (pre_vdiv/_vDial->get_value())); set_stop_scale(_stop_scale * (pre_vdiv/_vDial->get_value()));
set_scale(get_view_rect().height()); set_scale(get_view_rect().height());
} }
session->get_device()->set_config_uint16(SR_CONF_PROBE_OFFSET, session->get_device()->set_config_uint16(SR_CONF_PROBE_OFFSET,
@ -226,7 +226,7 @@ bool DsoSignal::go_vDialNext(bool manul)
_vDial->get_value(), _probe, NULL); _vDial->get_value(), _probe, NULL);
if (session->is_stopped_status()) { if (session->is_stopped_status()) {
session->set_stop_scale(session->stop_scale() * (pre_vdiv/_vDial->get_value())); set_stop_scale(_stop_scale * (pre_vdiv/_vDial->get_value()));
set_scale(get_view_rect().height()); set_scale(get_view_rect().height());
} }
session->get_device()->set_config_uint16(SR_CONF_PROBE_OFFSET, session->get_device()->set_config_uint16(SR_CONF_PROBE_OFFSET,

View File

@ -239,6 +239,9 @@ public:
bool mouse_wheel(int right, const QPoint pt, const int shift); bool mouse_wheel(int right, const QPoint pt, const int shift);
inline void set_stop_scale(float v){
_stop_scale = v;
}
protected: protected:
void paint_type_options(QPainter &p, int right, const QPoint pt, QColor fore); void paint_type_options(QPainter &p, int right, const QPoint pt, QColor fore);
@ -264,6 +267,7 @@ private:
private: private:
pv::data::DsoSnapshot *_data; pv::data::DsoSnapshot *_data;
float _scale; float _scale;
float _stop_scale = 1;
bool _en_lock; bool _en_lock;
bool _show; bool _show;

View File

@ -275,7 +275,7 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
if (_moveFlag) { if (_moveFlag) {
_drag_traces.clear(); _drag_traces.clear();
_view.signals_changed(); _view.signals_changed(mTrace);
_view.set_all_update(true); _view.set_all_update(true);
std::vector<Trace*> traces; std::vector<Trace*> traces;

View File

@ -616,7 +616,7 @@ void View::mode_changed()
_scale = max(min(_scale, _maxscale), _minscale); _scale = max(min(_scale, _maxscale), _minscale);
} }
void View::signals_changed() void View::signals_changed(const Trace* eventTrace)
{ {
double actualMargin = SignalMargin; double actualMargin = SignalMargin;
int total_rows = 0; int total_rows = 0;
@ -628,6 +628,8 @@ void View::signals_changed()
std::vector<Trace*> logic_traces; std::vector<Trace*> logic_traces;
std::vector<Trace*> decoder_traces; std::vector<Trace*> decoder_traces;
(void)eventTrace;
get_traces(ALL_VIEW, traces); get_traces(ALL_VIEW, traces);
for(auto t : traces) { for(auto t : traces) {
@ -761,14 +763,15 @@ void View::signals_changed()
t->set_v_offset(next_v_offset + 0.5 * traceHeight + actualMargin); t->set_v_offset(next_v_offset + 0.5 * traceHeight + actualMargin);
next_v_offset += traceHeight + 2 * actualMargin; next_v_offset += traceHeight + 2 * actualMargin;
view::DsoSignal *dsoSig = NULL; if (t->signal_type() == SR_CHANNEL_DSO)
if ((dsoSig = dynamic_cast<view::DsoSignal*>(t))) { {
dsoSig->set_scale(dsoSig->get_view_rect().height()); auto sig = dynamic_cast<view::DsoSignal*>(t);
sig->set_scale(sig->get_view_rect().height());
} }
else if (t->signal_type() == SR_CHANNEL_ANALOG)
view::AnalogSignal *analogSig = NULL; {
if ((analogSig = dynamic_cast<view::AnalogSignal*>(t))) { auto sig = dynamic_cast<view::AnalogSignal*>(t);
analogSig->set_scale(analogSig->get_totalHeight()); sig->set_scale(sig->get_view_rect().height());
} }
} }
_time_viewport->clear_measure(); _time_viewport->clear_measure();
@ -852,7 +855,7 @@ void View::resizeEvent(QResizeEvent*)
setViewportMargins(headerWidth(), RulerHeight, 0, 0); setViewportMargins(headerWidth(), RulerHeight, 0, 0);
update_margins(); update_margins();
update_scroll(); update_scroll();
signals_changed(); signals_changed(NULL);
if (_device_agent->get_work_mode() == DSO) if (_device_agent->get_work_mode() == DSO)
_scale = _session->cur_view_time() / get_view_width(); _scale = _session->cur_view_time() / get_view_width();
@ -1143,7 +1146,7 @@ void View::vDial_updated()
void View::show_lissajous(bool show) void View::show_lissajous(bool show)
{ {
_show_lissajous = show; _show_lissajous = show;
signals_changed(); signals_changed(NULL);
} }
void View::show_region(uint64_t start, uint64_t end, bool keep) void View::show_region(uint64_t start, uint64_t end, bool keep)
@ -1175,7 +1178,7 @@ void View::splitterMoved(int pos, int index)
{ {
(void)pos; (void)pos;
(void)index; (void)index;
signals_changed(); signals_changed(NULL);
} }
void View::reload() void View::reload()

View File

@ -313,7 +313,7 @@ public:
void update_view_port(); void update_view_port();
inline void update_all_trace_postion(){ inline void update_all_trace_postion(){
signals_changed(); signals_changed(NULL);
} }
inline Viewport* get_time_view(){ inline Viewport* get_time_view(){
@ -354,10 +354,12 @@ public:
static bool compare_trace_y(const Trace *a, const Trace *b); static bool compare_trace_y(const Trace *a, const Trace *b);
void signals_changed(const Trace* eventTrace);
public slots: public slots:
void reload(); void reload();
void set_measure_en(int enable); void set_measure_en(int enable);
void signals_changed();
void data_updated(); void data_updated();
void update_scale_offset(); void update_scale_offset();
void show_region(uint64_t start, uint64_t end, bool keep); void show_region(uint64_t start, uint64_t end, bool keep);