forked from Ivasoft/DSView
On loop mode, the view auto scroll to latest data
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -65,6 +65,7 @@ struct AppOptions
|
||||
bool trigPosDisplayInMid;
|
||||
bool displayProfileInBar;
|
||||
bool swapBackBufferAlways;
|
||||
bool autoScrollLatestData;
|
||||
float fontSize;
|
||||
|
||||
std::vector<StringPair> m_protocolFormats;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -714,5 +714,9 @@
|
||||
{
|
||||
"id": "IDS_DLG_ABORT",
|
||||
"text": "放弃"
|
||||
},
|
||||
{
|
||||
"id": "IDS_DLG_AUTO_SCROLL_LATEAST_DATA",
|
||||
"text": "自动滚动到最新数据"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -714,5 +714,9 @@
|
||||
{
|
||||
"id": "IDS_DLG_ABORT",
|
||||
"text": "Abort"
|
||||
},
|
||||
{
|
||||
"id": "IDS_DLG_AUTO_SCROLL_LATEAST_DATA",
|
||||
"text": "Auto scroll to latest data"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user