diff --git a/DSView/pv/config/appconfig.cpp b/DSView/pv/config/appconfig.cpp index 99141b89..1d6ebc1c 100644 --- a/DSView/pv/config/appconfig.cpp +++ b/DSView/pv/config/appconfig.cpp @@ -122,6 +122,7 @@ static void _loadApp(AppOptions &o, QSettings &st) getFiled("displayProfileInBar", st, o.displayProfileInBar, false); getFiled("swapBackBufferAlways", st, o.swapBackBufferAlways, false); getFiled("fontSize", st, o.fontSize, 9.0); + getFiled("autoScrollLatestData", st, o.autoScrollLatestData, true); o.warnofMultiTrig = true; @@ -148,6 +149,7 @@ static void _saveApp(AppOptions &o, QSettings &st) setFiled("displayProfileInBar", st, o.displayProfileInBar); setFiled("swapBackBufferAlways", st, o.swapBackBufferAlways); setFiled("fontSize", st, o.fontSize); + setFiled("autoScrollLatestData", st, o.autoScrollLatestData); QString fmt = FormatArrayToString(o.m_protocolFormats); setFiled("protocalFormats", st, fmt); diff --git a/DSView/pv/config/appconfig.h b/DSView/pv/config/appconfig.h index e34b91ea..2c02bb60 100644 --- a/DSView/pv/config/appconfig.h +++ b/DSView/pv/config/appconfig.h @@ -65,6 +65,7 @@ struct AppOptions bool trigPosDisplayInMid; bool displayProfileInBar; bool swapBackBufferAlways; + bool autoScrollLatestData; float fontSize; std::vector m_protocolFormats; diff --git a/DSView/pv/dialogs/applicationpardlg.cpp b/DSView/pv/dialogs/applicationpardlg.cpp index d2cc9fe7..fb0a24cb 100644 --- a/DSView/pv/dialogs/applicationpardlg.cpp +++ b/DSView/pv/dialogs/applicationpardlg.cpp @@ -124,6 +124,9 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent) QCheckBox *ck_abortData = new QCheckBox(); ck_abortData->setChecked(app.appOptions.swapBackBufferAlways); + QCheckBox *ck_autoScrollLatestData = new QCheckBox(); + ck_autoScrollLatestData->setChecked(app.appOptions.autoScrollLatestData); + QComboBox *ftCbSize = new DsComboBox(); ftCbSize->setFixedWidth(50); bind_font_size_list(ftCbSize, app.appOptions.fontSize); @@ -137,6 +140,8 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent) logicLay->addWidget(ck_quickScroll, 0, 1, Qt::AlignRight); logicLay->addWidget(new QLabel(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_USE_ABORT_DATA_REPEAT), "Used abort data")), 1, 0, Qt::AlignLeft); logicLay->addWidget(ck_abortData, 1, 1, Qt::AlignRight); + logicLay->addWidget(new QLabel(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_AUTO_SCROLL_LATEAST_DATA), "Auto scoll latest")), 2, 0, Qt::AlignLeft); + logicLay->addWidget(ck_autoScrollLatestData, 2, 1, Qt::AlignRight); lay->addWidget(logicGroup); //Scope group @@ -190,6 +195,10 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent) app.appOptions.fontSize = fSize; bFontChanged = true; } + if (app.appOptions.autoScrollLatestData != ck_autoScrollLatestData->isChecked()){ + app.appOptions.autoScrollLatestData = ck_autoScrollLatestData->isChecked(); + bAppChanged = true; + } if (bAppChanged){ app.SaveApp(); diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 21e4acf2..0a647d88 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -386,6 +386,11 @@ namespace pv return cur_samplelimits() * 1.0 / cur_snap_samplerate(); } + double SigSession::get_logic_data_view_time() + { + return _view_data->get_logic()->get_ring_sample_count() * 1.0 / cur_snap_samplerate(); + } + double SigSession::cur_view_time() { return _device_agent.get_time_base() * DS_CONF_DSO_HDIVS * 1.0 / SR_SEC(1); diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h index d53aeb16..66e69aa2 100644 --- a/DSView/pv/sigsession.h +++ b/DSView/pv/sigsession.h @@ -439,6 +439,8 @@ public: return _dso_status_valid; } + double get_logic_data_view_time(); + private: void set_cur_samplelimits(uint64_t samplelimits); void set_cur_snap_samplerate(uint64_t samplerate); diff --git a/DSView/pv/view/view.cpp b/DSView/pv/view/view.cpp index 2f5d3d7a..e6935e9c 100644 --- a/DSView/pv/view/view.cpp +++ b/DSView/pv/view/view.cpp @@ -1132,6 +1132,16 @@ int64_t View::get_max_offset() (get_view_width() * MaxViewRate)); } +int64_t View::get_logic_lst_data_offset(){ + return ceil((_session->get_logic_data_view_time() / _scale) - + (get_view_width() * MaxViewRate)); +} + +void View::scroll_to_logic_last_data_time() +{ + set_scale_offset(scale(), get_logic_lst_data_offset() + 10); +} + // -- calibration dialog void View::show_calibration() { diff --git a/DSView/pv/view/view.h b/DSView/pv/view/view.h index f93c778d..5e53e4f7 100644 --- a/DSView/pv/view/view.h +++ b/DSView/pv/view/view.h @@ -153,6 +153,7 @@ public: int64_t get_min_offset(); int64_t get_max_offset(); + int64_t get_logic_lst_data_offset(); void capture_init(); @@ -243,6 +244,8 @@ public: return _search_pos; } + void scroll_to_logic_last_data_time(); + /* * horizental cursors */ diff --git a/DSView/pv/view/viewport.cpp b/DSView/pv/view/viewport.cpp index 1d4570b8..d86409e3 100644 --- a/DSView/pv/view/viewport.cpp +++ b/DSView/pv/view/viewport.cpp @@ -766,7 +766,7 @@ void Viewport::mousePressEvent(QMouseEvent *event) } } -void Viewport::mouseMoveEvent(QMouseEvent *event) +void Viewport:: mouseMoveEvent(QMouseEvent *event) { assert(event); _hover_hit = false; @@ -775,8 +775,8 @@ void Viewport::mouseMoveEvent(QMouseEvent *event) if (event->buttons() & Qt::LeftButton) { if (_type == TIME_VIEW) { if (_action_type == NO_ACTION) { - _view.set_scale_offset(_view.scale(), - _mouse_down_offset + (_mouse_down_point - event->pos()).x()); + int64_t x = _mouse_down_offset + (_mouse_down_point - event->pos()).x(); + _view.set_scale_offset(_view.scale(), x); } _drag_strength = (_mouse_down_point - event->pos()).x(); } @@ -1385,7 +1385,9 @@ void Viewport::set_receive_len(quint64 length) _sample_received += length; } - if (_view.session().get_device()->get_work_mode() == LOGIC) + int mode = _view.session().get_device()->get_work_mode(); + + if (mode == LOGIC) { if (_view.session().get_device()->is_file() == false) { @@ -1420,6 +1422,12 @@ void Viewport::set_receive_len(quint64 length) } } + if (mode == LOGIC && AppConfig::Instance().appOptions.autoScrollLatestData + && _view.session().is_realtime_refresh()) + { + _view.scroll_to_logic_last_data_time(); + } + // Received new data, and refresh the view. update(); } diff --git a/lang/cn/dlg.json b/lang/cn/dlg.json index cab06746..56226faf 100644 --- a/lang/cn/dlg.json +++ b/lang/cn/dlg.json @@ -714,5 +714,9 @@ { "id": "IDS_DLG_ABORT", "text": "放弃" + }, + { + "id": "IDS_DLG_AUTO_SCROLL_LATEAST_DATA", + "text": "自动滚动到最新数据" } ] diff --git a/lang/en/dlg.json b/lang/en/dlg.json index 0bddd212..bfb87cda 100644 --- a/lang/en/dlg.json +++ b/lang/en/dlg.json @@ -714,5 +714,9 @@ { "id": "IDS_DLG_ABORT", "text": "Abort" + }, + { + "id": "IDS_DLG_AUTO_SCROLL_LATEAST_DATA", + "text": "Auto scroll to latest data" } ]