Commit 5c832a8d authored by DreamSourceLab's avatar DreamSourceLab

improve cursor/channel/trigger move operation, support both press-drag and hit-move-release mode

parent 22f5a7be
...@@ -943,9 +943,36 @@ void DsoSignal::paint_fore(QPainter &p, int left, int right) ...@@ -943,9 +943,36 @@ void DsoSignal::paint_fore(QPainter &p, int left, int right)
}; };
p.setPen(Qt::transparent); p.setPen(Qt::transparent);
p.setBrush(hover ? _colour.dark() : _colour); p.setBrush(_colour);
p.drawPolygon(points, countof(points)); p.drawPolygon(points, countof(points));
p.setPen(Qt::white);
const QPointF arrow_points[] = {
QPoint(label_rect.left(), label_rect.center().y()),
QPoint(label_rect.left(), label_rect.center().y()-1),
QPoint(label_rect.left(), label_rect.center().y()+1),
QPoint(label_rect.left(), label_rect.center().y()-2),
QPoint(label_rect.left(), label_rect.center().y()+2),
QPoint(label_rect.left(), label_rect.center().y()-3),
QPoint(label_rect.left(), label_rect.center().y()+3),
QPoint(label_rect.left(), label_rect.center().y()-4),
QPoint(label_rect.left(), label_rect.center().y()+4),
QPoint(label_rect.left()-1, label_rect.center().y()-3),
QPoint(label_rect.left()-1, label_rect.center().y()+3),
QPoint(label_rect.left()+1, label_rect.center().y()-3),
QPoint(label_rect.left()+1, label_rect.center().y()+3),
QPoint(label_rect.left()-1, label_rect.center().y()-2),
QPoint(label_rect.left()-1, label_rect.center().y()+2),
QPoint(label_rect.left()+1, label_rect.center().y()-2),
QPoint(label_rect.left()+1, label_rect.center().y()+2),
QPoint(label_rect.left()-2, label_rect.center().y()-2),
QPoint(label_rect.left()-2, label_rect.center().y()+2),
QPoint(label_rect.left()+2, label_rect.center().y()-2),
QPoint(label_rect.left()+2, label_rect.center().y()+2),
};
if (hover || selected())
p.drawPoints(arrow_points, countof(arrow_points));
// paint the trig voltage // paint the trig voltage
int trigp = get_trig_vpos(); int trigp = get_trig_vpos();
float t_vol = (_zero_vrate - get_trig_vrate()) * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS; float t_vol = (_zero_vrate - get_trig_vrate()) * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS;
...@@ -957,8 +984,10 @@ void DsoSignal::paint_fore(QPainter &p, int left, int right) ...@@ -957,8 +984,10 @@ void DsoSignal::paint_fore(QPainter &p, int left, int right)
p.drawText(t_vol_rect, Qt::AlignRight | Qt::AlignVCenter, t_vol_s); p.drawText(t_vol_rect, Qt::AlignRight | Qt::AlignVCenter, t_vol_s);
// paint the _trig_vpos line // paint the _trig_vpos line
p.setPen(QPen(_colour, 1, Qt::DotLine)); if (_view->get_dso_trig_moved()) {
p.drawLine(left, trigp, right - p.boundingRect(t_vol_rect, Qt::AlignLeft, t_vol_s).width(), trigp); p.setPen(QPen(_colour, 1, Qt::DotLine));
p.drawLine(left, trigp, right - p.boundingRect(t_vol_rect, Qt::AlignLeft, t_vol_s).width(), trigp);
}
// Paint the text // Paint the text
p.setPen(Qt::white); p.setPen(Qt::white);
......
...@@ -183,21 +183,11 @@ void Header::mousePressEvent(QMouseEvent *event) ...@@ -183,21 +183,11 @@ void Header::mousePressEvent(QMouseEvent *event)
} else if (action == Trace::NAME && mTrace) { } else if (action == Trace::NAME && mTrace) {
_nameFlag = true; _nameFlag = true;
} else if (action == Trace::LABEL && mTrace) { } else if (action == Trace::LABEL && mTrace) {
if (mTrace->selected()) mTrace->select(true);
mTrace->select(false); if (~QApplication::keyboardModifiers() &
else { Qt::ControlModifier)
if (mTrace->get_type() != SR_CHANNEL_DSO) _drag_traces.clear();
mTrace->select(true); _drag_traces.push_back(make_pair(mTrace, mTrace->get_zero_vpos()));
if (~QApplication::keyboardModifiers() &
Qt::ControlModifier)
_drag_traces.clear();
// Add the Trace to the drag list
if (event->button() & Qt::LeftButton) {
_drag_traces.push_back(make_pair(mTrace, mTrace->get_zero_vpos()));
}
}
mTrace->set_old_v_offset(mTrace->get_v_offset()); mTrace->set_old_v_offset(mTrace->get_v_offset());
} }
...@@ -236,13 +226,20 @@ void Header::mouseReleaseEvent(QMouseEvent *event) ...@@ -236,13 +226,20 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
} }
if (_moveFlag) { if (_moveFlag) {
//move(event); //move(event);
_drag_traces.clear();
_view.signals_changed(); _view.signals_changed();
_view.set_all_update(true); _view.set_all_update(true);
const vector< boost::shared_ptr<Trace> > traces(
_view.get_traces(ALL_VIEW));
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
t->select(false);
} }
_colorFlag = false; _colorFlag = false;
_nameFlag = false; _nameFlag = false;
_moveFlag = false; _moveFlag = false;
_drag_traces.clear();
_view.normalize_layout(); _view.normalize_layout();
} }
...@@ -299,21 +296,21 @@ void Header::mouseMoveEvent(QMouseEvent *event) ...@@ -299,21 +296,21 @@ void Header::mouseMoveEvent(QMouseEvent *event)
if (sig) { if (sig) {
int y = (*i).second + delta; int y = (*i).second + delta;
if (sig->get_type() != SR_CHANNEL_DSO) { if (sig->get_type() != SR_CHANNEL_DSO) {
const int y_snap = if (~QApplication::keyboardModifiers() & Qt::ControlModifier) {
((y + View::SignalSnapGridSize / 2) / const int y_snap =
View::SignalSnapGridSize) * ((y + View::SignalSnapGridSize / 2) /
View::SignalSnapGridSize; View::SignalSnapGridSize) *
if (y_snap != sig->get_v_offset()) { View::SignalSnapGridSize;
_moveFlag = true; if (y_snap != sig->get_v_offset()) {
sig->set_v_offset(y_snap); _moveFlag = true;
sig->set_v_offset(y_snap);
}
} }
// Ensure the Trace is selected
sig->select(true);
} else { } else {
boost::shared_ptr<DsoSignal> dsoSig; boost::shared_ptr<DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<DsoSignal>(sig)) { if (dsoSig = dynamic_pointer_cast<DsoSignal>(sig)) {
dsoSig->set_zero_vpos(y); dsoSig->set_zero_vpos(y);
dsoSig->select(false); _moveFlag = true;
traces_moved(); traces_moved();
} }
} }
......
...@@ -87,7 +87,9 @@ Ruler::Ruler(View &parent) : ...@@ -87,7 +87,9 @@ Ruler::Ruler(View &parent) :
_cursor_sel_visible(false), _cursor_sel_visible(false),
_cursor_go_visible(false), _cursor_go_visible(false),
_cursor_sel_x(-1), _cursor_sel_x(-1),
_grabbed_marker(NULL) _grabbed_marker(NULL),
_hitCursor(false),
_curs_moved(false)
{ {
setMouseTracking(true); setMouseTracking(true);
...@@ -208,6 +210,7 @@ void Ruler::mouseMoveEvent(QMouseEvent *e) ...@@ -208,6 +210,7 @@ void Ruler::mouseMoveEvent(QMouseEvent *e)
_grabbed_marker->set_index((_view.offset() + _view.hover_point().x()) * _grabbed_marker->set_index((_view.offset() + _view.hover_point().x()) *
_view.scale() * _view.session().cur_samplerate()); _view.scale() * _view.session().cur_samplerate());
_view.cursor_moving(); _view.cursor_moving();
_curs_moved = true;
} }
update(); update();
...@@ -221,48 +224,42 @@ void Ruler::leaveEvent(QEvent *) ...@@ -221,48 +224,42 @@ void Ruler::leaveEvent(QEvent *)
update(); update();
} }
void Ruler::mousePressEvent(QMouseEvent *e) void Ruler::mousePressEvent(QMouseEvent *event)
{ {
(void)e;
}
void Ruler::mouseReleaseEvent(QMouseEvent *event)
{
bool addCursor = false;
bool visible;
if (event->button() & Qt::LeftButton) { if (event->button() & Qt::LeftButton) {
bool hitCursor = false; bool visible;
if (!_cursor_sel_visible & !_view.get_cursorList().empty()) { if (!_cursor_sel_visible & !_view.get_cursorList().empty()) {
_view.show_cursors(true); _view.show_cursors(true);
if (_grabbed_marker) { list<Cursor*>::iterator i = _view.get_cursorList().begin();
rel_grabbed_cursor(); while (i != _view.get_cursorList().end()) {
hitCursor = true; const QRect cursor_rect((*i)->get_label_rect(rect(), visible));
_view.cursor_moved(); if ((*i)->get_close_rect(cursor_rect).contains(event->pos())) {
} else { _view.del_cursor(*i);
list<Cursor*>::iterator i = _view.get_cursorList().begin(); if (_view.get_cursorList().empty()) {
while (i != _view.get_cursorList().end()) {
const QRect cursor_rect((*i)->get_label_rect(rect(), visible));
if ((*i)->get_close_rect(cursor_rect).contains(event->pos())) {
_view.del_cursor(*i);
if (_view.get_cursorList().empty()) {
_cursor_sel_visible = false;
_view.show_cursors(false);
}
hitCursor = true;
break;
}
if (cursor_rect.contains(event->pos())) {
set_grabbed_cursor(*i);
_cursor_sel_visible = false; _cursor_sel_visible = false;
_cursor_go_visible = false; _view.show_cursors(false);
hitCursor = true;
break;
} }
i++; _hitCursor = true;
break;
}
if (cursor_rect.contains(event->pos())) {
set_grabbed_cursor(*i);
_cursor_sel_visible = false;
_cursor_go_visible = false;
_hitCursor = true;
break;
} }
i++;
} }
} }
if (!hitCursor && !_grabbed_marker) { }
}
void Ruler::mouseReleaseEvent(QMouseEvent *event)
{
bool addCursor = false;
if (event->button() & Qt::LeftButton) {
if (!_hitCursor && !_grabbed_marker) {
if (!_cursor_go_visible) { if (!_cursor_go_visible) {
if (!_cursor_sel_visible) { if (!_cursor_sel_visible) {
_cursor_sel_x = event->pos().x(); _cursor_sel_x = event->pos().x();
...@@ -293,6 +290,13 @@ void Ruler::mouseReleaseEvent(QMouseEvent *event) ...@@ -293,6 +290,13 @@ void Ruler::mouseReleaseEvent(QMouseEvent *event)
_cursor_go_visible = false; _cursor_go_visible = false;
} }
} }
if (_curs_moved && _grabbed_marker) {
rel_grabbed_cursor();
_hitCursor = false;
_curs_moved = false;
_view.cursor_moved();
}
} }
if (event->button() & Qt::RightButton) { if (event->button() & Qt::RightButton) {
......
...@@ -81,7 +81,7 @@ private: ...@@ -81,7 +81,7 @@ private:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
void mouseMoveEvent(QMouseEvent *e); void mouseMoveEvent(QMouseEvent *e);
void mousePressEvent(QMouseEvent *e); void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event);
void leaveEvent(QEvent *); void leaveEvent(QEvent *);
...@@ -114,6 +114,8 @@ private: ...@@ -114,6 +114,8 @@ private:
double _min_period; double _min_period;
unsigned int _cur_prefix; unsigned int _cur_prefix;
bool _hitCursor;
bool _curs_moved;
}; };
} // namespace view } // namespace view
......
...@@ -285,14 +285,41 @@ void Trace::paint_label(QPainter &p, int right, const QPoint pt) ...@@ -285,14 +285,41 @@ void Trace::paint_label(QPainter &p, int right, const QPoint pt)
p.setPen(Qt::transparent); p.setPen(Qt::transparent);
if (_type == SR_CHANNEL_DSO || _type == SR_CHANNEL_FFT) { if (_type == SR_CHANNEL_DSO || _type == SR_CHANNEL_FFT) {
p.setBrush((label_rect.contains(pt) || selected()) ? _colour.darker() : _colour); p.setBrush(_colour);
p.drawPolygon(points, countof(points)); p.drawPolygon(points, countof(points));
} else { } else {
QColor color = PROBE_COLORS[*_index_list.begin() % countof(PROBE_COLORS)]; QColor color = PROBE_COLORS[*_index_list.begin() % countof(PROBE_COLORS)];
p.setBrush((label_rect.contains(pt) || selected()) ? color.lighter() : color); p.setBrush(color);
p.drawPolygon(points, countof(points)); p.drawPolygon(points, countof(points));
} }
p.setPen(Qt::white);
const QPointF arrow_points[] = {
QPoint(label_rect.right(), label_rect.center().y()),
QPoint(label_rect.right(), label_rect.center().y()-1),
QPoint(label_rect.right(), label_rect.center().y()+1),
QPoint(label_rect.right(), label_rect.center().y()-2),
QPoint(label_rect.right(), label_rect.center().y()+2),
QPoint(label_rect.right(), label_rect.center().y()-3),
QPoint(label_rect.right(), label_rect.center().y()+3),
QPoint(label_rect.right(), label_rect.center().y()-4),
QPoint(label_rect.right(), label_rect.center().y()+4),
QPoint(label_rect.right()-1, label_rect.center().y()-3),
QPoint(label_rect.right()-1, label_rect.center().y()+3),
QPoint(label_rect.right()+1, label_rect.center().y()-3),
QPoint(label_rect.right()+1, label_rect.center().y()+3),
QPoint(label_rect.right()-1, label_rect.center().y()-2),
QPoint(label_rect.right()-1, label_rect.center().y()+2),
QPoint(label_rect.right()+1, label_rect.center().y()-2),
QPoint(label_rect.right()+1, label_rect.center().y()+2),
QPoint(label_rect.right()-2, label_rect.center().y()-2),
QPoint(label_rect.right()-2, label_rect.center().y()+2),
QPoint(label_rect.right()+2, label_rect.center().y()-2),
QPoint(label_rect.right()+2, label_rect.center().y()+2),
};
if (label_rect.contains(pt) || selected())
p.drawPoints(arrow_points, countof(arrow_points));
// Paint the text // Paint the text
p.setPen(Qt::white); p.setPen(Qt::white);
if (_type == SR_CHANNEL_GROUP) if (_type == SR_CHANNEL_GROUP)
......
...@@ -1166,5 +1166,10 @@ void View::set_capture_status() ...@@ -1166,5 +1166,10 @@ void View::set_capture_status()
} }
} }
bool View::get_dso_trig_moved() const
{
return _time_viewport->get_dso_trig_moved();
}
} // namespace view } // namespace view
} // namespace pv } // namespace pv
...@@ -195,6 +195,8 @@ public: ...@@ -195,6 +195,8 @@ public:
bool get_capture_status(bool &triggered, int &progress); bool get_capture_status(bool &triggered, int &progress);
void set_capture_status(); void set_capture_status();
bool get_dso_trig_moved() const;
signals: signals:
void hover_point_changed(); void hover_point_changed();
......
This diff is collapsed.
...@@ -101,6 +101,8 @@ public: ...@@ -101,6 +101,8 @@ public:
void set_need_update(bool update); void set_need_update(bool update);
bool get_dso_trig_moved() const;
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
...@@ -195,6 +197,8 @@ private: ...@@ -195,6 +197,8 @@ private:
int _dso_ym_end; int _dso_ym_end;
int _waiting_trig; int _waiting_trig;
bool _dso_trig_moved;
bool _curs_moved;
}; };
} // namespace view } // namespace view
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment