forked from Ivasoft/DSView
fix: on dso mode, the sample rate have not applied by mouse wheel event, so cursors got an error index map
This commit is contained in:
@@ -2569,8 +2569,7 @@ namespace pv
|
||||
|
||||
void SigSession::apply_samplerate()
|
||||
{
|
||||
set_cur_snap_samplerate(_device_agent.get_sample_rate());
|
||||
set_cur_samplelimits(_device_agent.get_sample_limit());
|
||||
on_load_config_end();
|
||||
}
|
||||
|
||||
} // namespace pv
|
||||
|
||||
@@ -280,13 +280,10 @@ namespace pv
|
||||
bool test;
|
||||
bool ret;
|
||||
|
||||
if (mode == DSO)
|
||||
{
|
||||
|
||||
if (mode == DSO){
|
||||
_device_agent->get_config_bool(SR_CONF_ZERO, zero);
|
||||
|
||||
if (zero)
|
||||
{
|
||||
if (zero){
|
||||
zero_adj();
|
||||
return;
|
||||
}
|
||||
@@ -333,7 +330,7 @@ namespace pv
|
||||
break;
|
||||
}
|
||||
|
||||
_sample_count.setCurrentIndex(i);
|
||||
set_sample_count_index(i);
|
||||
commit_hori_res();
|
||||
|
||||
if (_session->is_working() == false)
|
||||
@@ -354,7 +351,7 @@ namespace pv
|
||||
if (_session->is_working())
|
||||
_session->stop_capture();
|
||||
|
||||
_sample_count.setCurrentIndex(index_back);
|
||||
set_sample_count_index(index_back);
|
||||
commit_hori_res();
|
||||
}
|
||||
|
||||
@@ -598,11 +595,11 @@ namespace pv
|
||||
|
||||
if (pre_duration > _sample_count.itemData(0).value<double>())
|
||||
{
|
||||
_sample_count.setCurrentIndex(0);
|
||||
set_sample_count_index(0);
|
||||
}
|
||||
else if (pre_duration < _sample_count.itemData(_sample_count.count() - 1).value<double>())
|
||||
{
|
||||
_sample_count.setCurrentIndex(_sample_count.count() - 1);
|
||||
set_sample_count_index(_sample_count.count() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -611,7 +608,7 @@ namespace pv
|
||||
double sel_val = _sample_count.itemData(i).value<double>();
|
||||
if (pre_duration >= sel_val)
|
||||
{
|
||||
_sample_count.setCurrentIndex(i);
|
||||
set_sample_count_index(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -669,7 +666,7 @@ namespace pv
|
||||
double sel_val = _sample_count.itemData(i).value<double>();
|
||||
if (duration >= sel_val)
|
||||
{
|
||||
_sample_count.setCurrentIndex(i);
|
||||
set_sample_count_index(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -678,21 +675,29 @@ namespace pv
|
||||
_updating_sample_count = false;
|
||||
}
|
||||
|
||||
void SamplingBar::on_samplecount_sel(int index)
|
||||
{
|
||||
(void)index;
|
||||
void SamplingBar::apply_sample_count(double &hori_res)
|
||||
{
|
||||
hori_res = -1;
|
||||
|
||||
if (_device_agent->get_work_mode() == DSO){
|
||||
commit_hori_res();
|
||||
hori_res = commit_hori_res();
|
||||
|
||||
if (_session->have_view_data() == false){
|
||||
_session->apply_samplerate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_session->broadcast_msg(DSV_MSG_DEVICE_DURATION_UPDATED);
|
||||
}
|
||||
|
||||
void SamplingBar::on_samplecount_sel(int index)
|
||||
{
|
||||
(void)index;
|
||||
|
||||
double hori_res = -1;
|
||||
apply_sample_count(hori_res);
|
||||
}
|
||||
|
||||
double SamplingBar::get_hori_res()
|
||||
{
|
||||
return _sample_count.itemData(_sample_count.currentIndex()).value<double>();
|
||||
@@ -700,28 +705,31 @@ namespace pv
|
||||
|
||||
double SamplingBar::hori_knob(int dir)
|
||||
{
|
||||
int mode = _session->get_device()->get_work_mode();
|
||||
|
||||
assert(mode == DSO);
|
||||
|
||||
double hori_res = -1;
|
||||
int cur_index = -1;
|
||||
|
||||
disconnect(&_sample_count, SIGNAL(currentIndexChanged(int)), this, SLOT(on_samplecount_sel(int)));
|
||||
|
||||
if (0 == dir)
|
||||
{
|
||||
hori_res = commit_hori_res();
|
||||
if ((dir > 0) && (_sample_count.currentIndex() > 0)){
|
||||
cur_index = _sample_count.currentIndex() - 1;
|
||||
}
|
||||
else if ((dir > 0) && (_sample_count.currentIndex() > 0))
|
||||
{
|
||||
_sample_count.setCurrentIndex(_sample_count.currentIndex() - 1);
|
||||
hori_res = commit_hori_res();
|
||||
}
|
||||
else if ((dir < 0) && (_sample_count.currentIndex() < _sample_count.count() - 1))
|
||||
{
|
||||
_sample_count.setCurrentIndex(_sample_count.currentIndex() + 1);
|
||||
hori_res = commit_hori_res();
|
||||
else if ((dir < 0) && (_sample_count.currentIndex() < _sample_count.count() - 1)){
|
||||
cur_index = _sample_count.currentIndex() + 1;
|
||||
}
|
||||
|
||||
connect(&_sample_count, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(on_samplecount_sel(int)));
|
||||
|
||||
if (cur_index != -1){
|
||||
set_sample_count_index(cur_index);
|
||||
}
|
||||
|
||||
apply_sample_count(hori_res);
|
||||
|
||||
return hori_res;
|
||||
}
|
||||
|
||||
@@ -1276,5 +1284,10 @@ namespace pv
|
||||
update_view_status();
|
||||
}
|
||||
|
||||
void SamplingBar::set_sample_count_index(int index)
|
||||
{
|
||||
_sample_count.setCurrentIndex(index);
|
||||
}
|
||||
|
||||
} // namespace toolbars
|
||||
} // namespace pv
|
||||
|
||||
@@ -128,6 +128,10 @@ namespace pv
|
||||
void UpdateTheme() override;
|
||||
void UpdateFont() override;
|
||||
|
||||
void set_sample_count_index(int index);
|
||||
|
||||
void apply_sample_count(double &hori_res);
|
||||
|
||||
private slots:
|
||||
void on_collect_mode();
|
||||
void on_run_stop();
|
||||
|
||||
@@ -1413,12 +1413,30 @@ bool View::get_dso_trig_moved()
|
||||
|
||||
double View::index2pixel(uint64_t index, bool has_hoff)
|
||||
{
|
||||
const uint64_t rateValue = session().cur_snap_samplerate();
|
||||
const double scaleValue = scale();
|
||||
const int64_t offsetValue = offset();
|
||||
const double hoffValue = trig_hoff();
|
||||
|
||||
double pixels = 0;
|
||||
|
||||
const double samples_per_pixel = rateValue * scaleValue;
|
||||
|
||||
if (has_hoff){
|
||||
pixels = index / samples_per_pixel - offsetValue + hoffValue / samples_per_pixel;
|
||||
}
|
||||
else{
|
||||
pixels = index / samples_per_pixel - offsetValue;
|
||||
}
|
||||
|
||||
/*
|
||||
const double samples_per_pixel = session().cur_snap_samplerate() * scale();
|
||||
double pixels;
|
||||
if (has_hoff)
|
||||
pixels = index/samples_per_pixel - offset() + trig_hoff()/samples_per_pixel;
|
||||
else
|
||||
pixels = index/samples_per_pixel - offset();
|
||||
*/
|
||||
|
||||
return pixels;
|
||||
}
|
||||
@@ -1429,11 +1447,12 @@ uint64_t View::pixel2index(double pixel)
|
||||
const double scaleValue = scale();
|
||||
const int64_t offsetValue = offset();
|
||||
const double hoffValue = trig_hoff();
|
||||
|
||||
|
||||
const double samples_per_pixel = rateValue * scaleValue;
|
||||
const double index = (pixel + offsetValue) * samples_per_pixel - hoffValue;
|
||||
|
||||
const uint64_t sampleIndex = (uint64_t)std::round(index);
|
||||
|
||||
return sampleIndex;
|
||||
|
||||
//const double samples_per_pixel = session().cur_snap_samplerate() * scale();
|
||||
|
||||
Reference in New Issue
Block a user