mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-23 13:42:55 +08:00
Fix minor issues of sesion load and/display/drag-and-drop
This commit is contained in:
parent
63772095b3
commit
705819fac3
@ -256,7 +256,7 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) :
|
||||
_widget->setLayout(layout);
|
||||
|
||||
this->setWidget(_widget);
|
||||
_widget->setGeometry(0, 0, sizeHint().width(), 1000);
|
||||
//_widget->setGeometry(0, 0, sizeHint().width(), 1000);
|
||||
_widget->setObjectName("triggerWidget");
|
||||
}
|
||||
|
||||
|
@ -683,10 +683,8 @@ bool MainWindow::load_session(QString name)
|
||||
s->set_trig(obj["strigger"].toDouble());
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
|
||||
dsoSig->update_hDial();
|
||||
//dsoSig->update_vDial();
|
||||
dsoSig->load_settings();
|
||||
dsoSig->set_zeroRate(obj["zeroPos"].toDouble());
|
||||
dsoSig->set_enable(obj["enabled"].toBool());
|
||||
dsoSig->set_trigRate(obj["trigValue"].toDouble());
|
||||
}
|
||||
break;
|
||||
|
@ -157,9 +157,7 @@ DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
|
||||
_ms_en[DSO_MS_VMAX] = true;
|
||||
_ms_en[DSO_MS_VMIN] = true;
|
||||
|
||||
update_vDial();
|
||||
update_hDial();
|
||||
update_acCoupling();
|
||||
load_settings();
|
||||
}
|
||||
|
||||
DsoSignal::~DsoSignal()
|
||||
@ -425,12 +423,44 @@ bool DsoSignal::go_hDialNext(bool setted)
|
||||
}
|
||||
}
|
||||
|
||||
bool DsoSignal::update_vDial()
|
||||
bool DsoSignal::load_settings()
|
||||
{
|
||||
GVariant* gvar;
|
||||
|
||||
// -- enable
|
||||
bool enable;
|
||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_EN_CH);
|
||||
if (gvar != NULL) {
|
||||
enable = g_variant_get_boolean(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_EN_CH failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
// -- hdiv
|
||||
uint64_t hdiv;
|
||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_TIMEBASE);
|
||||
if (gvar != NULL) {
|
||||
hdiv = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_TIMEBASE failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
_hDial->set_value(hdiv);
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_TIMEBASE,
|
||||
g_variant_new_uint64(_hDial->get_value()));
|
||||
if (_view) {
|
||||
const double scale = _hDial->get_value() * std::pow(10.0, -9.0) * DS_CONF_DSO_HDIVS / get_view_rect().width();
|
||||
_view->set_scale_offset(scale, _view->offset());
|
||||
}
|
||||
|
||||
// -- vdiv
|
||||
uint64_t vdiv;
|
||||
uint64_t vfactor;
|
||||
//uint64_t pre_vdiv = _vDial->get_value();
|
||||
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_VDIV);
|
||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_VDIV);
|
||||
if (gvar != NULL) {
|
||||
vdiv = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
@ -449,33 +479,23 @@ bool DsoSignal::update_vDial()
|
||||
|
||||
_vDial->set_value(vdiv);
|
||||
_vDial->set_factor(vfactor);
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_VDIV,
|
||||
g_variant_new_uint64(_vDial->get_value()));
|
||||
|
||||
if (_view) {
|
||||
update_zeroPos();
|
||||
_view->set_need_update(true);
|
||||
_view->update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DsoSignal::update_hDial()
|
||||
{
|
||||
uint64_t hdiv;
|
||||
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_TIMEBASE);
|
||||
// -- coupling
|
||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_COUPLING);
|
||||
if (gvar != NULL) {
|
||||
hdiv = g_variant_get_uint64(gvar);
|
||||
_acCoupling = g_variant_get_byte(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_TIMEBASE failed.";
|
||||
qDebug() << "ERROR: config_get SR_CONF_COUPLING failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
_hDial->set_value(hdiv);
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_TIMEBASE,
|
||||
g_variant_new_uint64(_hDial->get_value()));
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_COUPLING,
|
||||
g_variant_new_byte(_acCoupling));
|
||||
|
||||
if (_view) {
|
||||
const double scale = _hDial->get_value() * std::pow(10.0, -9.0) * DS_CONF_DSO_HDIVS / get_view_rect().width();
|
||||
_view->set_scale_offset(scale, _view->offset());
|
||||
_view->set_need_update(true);
|
||||
_view->update();
|
||||
}
|
||||
@ -516,22 +536,6 @@ void DsoSignal::set_acCoupling(uint8_t coupling)
|
||||
}
|
||||
}
|
||||
|
||||
bool DsoSignal::update_acCoupling()
|
||||
{
|
||||
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_COUPLING);
|
||||
if (gvar != NULL) {
|
||||
_acCoupling = g_variant_get_byte(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_COUPLING failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_COUPLING,
|
||||
g_variant_new_byte(_acCoupling));
|
||||
return true;
|
||||
}
|
||||
|
||||
int DsoSignal::get_trig_vpos() const
|
||||
{
|
||||
return _trig_vpos * get_view_rect().height() + UpMargin;
|
||||
@ -797,6 +801,8 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right)
|
||||
assert(scale > 0);
|
||||
const double offset = _view->offset();
|
||||
|
||||
paint_measure(p);
|
||||
|
||||
const deque< boost::shared_ptr<pv::data::DsoSnapshot> > &snapshots =
|
||||
_data->get_snapshots();
|
||||
if (snapshots.empty())
|
||||
@ -834,8 +840,6 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right)
|
||||
start_sample, end_sample,
|
||||
pixels_offset, samples_per_pixel, number_channels);
|
||||
}
|
||||
|
||||
paint_measure(p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1112,16 +1116,12 @@ void DsoSignal::paint_measure(QPainter &p)
|
||||
_ms_string[DSO_MS_VMEA] = "Vmean: " + (abs(value_vmean) > 1000 ? QString::number(value_vmean/1000.0, 'f', 2) + "V" : QString::number(value_vmean, 'f', 2) + "mV");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QColor measure_colour = _colour;
|
||||
measure_colour.setAlpha(180);
|
||||
QColor back_colour = Qt::white;
|
||||
back_colour.setAlpha(100);
|
||||
//p.setPen(measure_colour);
|
||||
//p.drawText(QRectF(0, 100*index + UpMargin, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Max: ")+max_string+" ");
|
||||
//p.drawText(QRectF(0, 100*index + UpMargin + 20, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Min: ")+min_string+" ");
|
||||
//p.drawText(QRectF(0, 100*index + UpMargin + 40, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Period: ")+period_string+" ");
|
||||
//p.drawText(QRectF(0, 100*index + UpMargin + 60, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Frequency: ")+freq_string+" ");
|
||||
|
||||
bool antialiasing = p.Antialiasing;
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
@ -1156,8 +1156,6 @@ void DsoSignal::paint_measure(QPainter &p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
p.setRenderHint(QPainter::Antialiasing, antialiasing);
|
||||
|
||||
if (_autoV) {
|
||||
@ -1196,7 +1194,6 @@ void DsoSignal::paint_measure(QPainter &p)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_view->update();
|
||||
}
|
||||
|
||||
@ -1215,14 +1212,18 @@ bool DsoSignal::measure(const QPointF &p)
|
||||
{
|
||||
if (_ms_gear_rect.contains(QPoint(p.x(), p.y()))) {
|
||||
_ms_gear_hover = true;
|
||||
_view->set_need_update(true);
|
||||
return false;
|
||||
} else {
|
||||
} else if (_ms_gear_hover) {
|
||||
_view->set_need_update(true);
|
||||
_ms_gear_hover = false;
|
||||
}
|
||||
if (_ms_show_rect.contains(QPoint(p.x(), p.y()))) {
|
||||
_ms_show_hover = true;
|
||||
_view->set_need_update(true);
|
||||
return false;
|
||||
} else {
|
||||
} else if (_ms_show_hover){
|
||||
_view->set_need_update(true);
|
||||
_ms_show_hover = false;
|
||||
}
|
||||
|
||||
|
@ -121,9 +121,7 @@ public:
|
||||
void set_factor(uint64_t factor);
|
||||
uint64_t get_factor();
|
||||
|
||||
bool update_vDial();
|
||||
bool update_hDial();
|
||||
bool update_acCoupling();
|
||||
bool load_settings();
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -538,11 +538,14 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
|
||||
if (_view.session().get_device()->dev_inst()->mode == LOGIC &&
|
||||
_measure_type != LOGIC_EDGE) {
|
||||
const double strength = _drag_strength*DragTimerInterval*1.0/_time.elapsed();
|
||||
if (abs(_drag_strength) < MinorDragOffsetUp && abs(strength) > MinorDragRateUp) {
|
||||
if (_time.elapsed() < 200 &&
|
||||
abs(_drag_strength) < MinorDragOffsetUp &&
|
||||
abs(strength) > MinorDragRateUp) {
|
||||
_drag_strength = _drag_strength;
|
||||
_drag_timer.start(DragTimerInterval);
|
||||
_measure_type = LOGIC_MOVE;
|
||||
} else if (abs(strength) > DragTimerInterval) {
|
||||
} else if (_time.elapsed() < 200 &&
|
||||
abs(strength) > DragTimerInterval) {
|
||||
_drag_strength = strength * 5;
|
||||
_drag_timer.start(DragTimerInterval);
|
||||
_measure_type = LOGIC_MOVE;
|
||||
@ -623,7 +626,7 @@ void Viewport::leaveEvent(QEvent *)
|
||||
_measure_shown = _dso_xm || _dso_ym;
|
||||
_mouse_point = QPoint(-1, -1);
|
||||
//_view.show_cursors(false);
|
||||
if (_measure_type == LOGIC_EDGE) {
|
||||
if (_measure_type == LOGIC_EDGE || _measure_type == LOGIC_MOVE) {
|
||||
_measure_type = NO_MEASURE;
|
||||
_measure_shown = false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user