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()
{
_view->signals_changed();
_view->signals_changed(NULL);
}
void MainWindow::receive_trigger(quint64 trigger_pos)

View File

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

View File

@ -305,14 +305,6 @@ public:
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);
inline bool is_closed(){
@ -571,7 +563,6 @@ private:
SESSION_ERROR_STATUS _error;
uint64_t _error_pattern;
int _map_zoom;
float _stop_scale;
bool _bClose;
uint64_t _save_start;

View File

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

View File

@ -117,7 +117,7 @@ DsoSignal::~DsoSignal()
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)
@ -191,7 +191,7 @@ bool DsoSignal::go_vDialPre(bool manul)
_vDial->get_value(), _probe, NULL);
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());
}
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);
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());
}
session->get_device()->set_config_uint16(SR_CONF_PROBE_OFFSET,
@ -985,7 +985,7 @@ void DsoSignal::paint_trace(QPainter &p,
uint8_t value;
float x = (start / samples_per_pixel - pixels_offset) + left + _view->trig_hoff()*pixels_per_sample;
float y;
for (int64_t sample = 0; sample < sample_count; sample++) {
value = samples_buffer[sample];
y = min(max(top, zeroY + (value - hw_offset) * _scale), bottom);

View File

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

View File

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

View File

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

View File

@ -313,7 +313,7 @@ public:
void update_view_port();
inline void update_all_trace_postion(){
signals_changed();
signals_changed(NULL);
}
inline Viewport* get_time_view(){
@ -353,11 +353,13 @@ public:
static bool compare_trace_view_index(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:
void reload();
void set_measure_en(int enable);
void signals_changed();
void data_updated();
void update_scale_offset();
void show_region(uint64_t start, uint64_t end, bool keep);