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)
};
p.setPen(Qt::transparent);
p.setBrush(hover ? _colour.dark() : _colour);
p.setBrush(_colour);
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
int trigp = get_trig_vpos();
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)
p.drawText(t_vol_rect, Qt::AlignRight | Qt::AlignVCenter, t_vol_s);
// paint the _trig_vpos line
if (_view->get_dso_trig_moved()) {
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
p.setPen(Qt::white);
......
......@@ -183,21 +183,11 @@ void Header::mousePressEvent(QMouseEvent *event)
} else if (action == Trace::NAME && mTrace) {
_nameFlag = true;
} else if (action == Trace::LABEL && mTrace) {
if (mTrace->selected())
mTrace->select(false);
else {
if (mTrace->get_type() != SR_CHANNEL_DSO)
mTrace->select(true);
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());
}
......@@ -236,13 +226,20 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
}
if (_moveFlag) {
//move(event);
_drag_traces.clear();
_view.signals_changed();
_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;
_nameFlag = false;
_moveFlag = false;
_drag_traces.clear();
_view.normalize_layout();
}
......@@ -299,6 +296,7 @@ void Header::mouseMoveEvent(QMouseEvent *event)
if (sig) {
int y = (*i).second + delta;
if (sig->get_type() != SR_CHANNEL_DSO) {
if (~QApplication::keyboardModifiers() & Qt::ControlModifier) {
const int y_snap =
((y + View::SignalSnapGridSize / 2) /
View::SignalSnapGridSize) *
......@@ -307,13 +305,12 @@ void Header::mouseMoveEvent(QMouseEvent *event)
_moveFlag = true;
sig->set_v_offset(y_snap);
}
// Ensure the Trace is selected
sig->select(true);
}
} else {
boost::shared_ptr<DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<DsoSignal>(sig)) {
dsoSig->set_zero_vpos(y);
dsoSig->select(false);
_moveFlag = true;
traces_moved();
}
}
......
......@@ -87,7 +87,9 @@ Ruler::Ruler(View &parent) :
_cursor_sel_visible(false),
_cursor_go_visible(false),
_cursor_sel_x(-1),
_grabbed_marker(NULL)
_grabbed_marker(NULL),
_hitCursor(false),
_curs_moved(false)
{
setMouseTracking(true);
......@@ -208,6 +210,7 @@ void Ruler::mouseMoveEvent(QMouseEvent *e)
_grabbed_marker->set_index((_view.offset() + _view.hover_point().x()) *
_view.scale() * _view.session().cur_samplerate());
_view.cursor_moving();
_curs_moved = true;
}
update();
......@@ -221,24 +224,12 @@ void Ruler::leaveEvent(QEvent *)
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) {
bool hitCursor = false;
bool visible;
if (!_cursor_sel_visible & !_view.get_cursorList().empty()) {
_view.show_cursors(true);
if (_grabbed_marker) {
rel_grabbed_cursor();
hitCursor = true;
_view.cursor_moved();
} else {
list<Cursor*>::iterator i = _view.get_cursorList().begin();
while (i != _view.get_cursorList().end()) {
const QRect cursor_rect((*i)->get_label_rect(rect(), visible));
......@@ -248,21 +239,27 @@ void Ruler::mouseReleaseEvent(QMouseEvent *event)
_cursor_sel_visible = false;
_view.show_cursors(false);
}
hitCursor = true;
_hitCursor = true;
break;
}
if (cursor_rect.contains(event->pos())) {
set_grabbed_cursor(*i);
_cursor_sel_visible = false;
_cursor_go_visible = false;
hitCursor = true;
_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_sel_visible) {
_cursor_sel_x = event->pos().x();
......@@ -293,6 +290,13 @@ void Ruler::mouseReleaseEvent(QMouseEvent *event)
_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) {
......
......@@ -81,7 +81,7 @@ private:
void paintEvent(QPaintEvent *event);
void mouseMoveEvent(QMouseEvent *e);
void mousePressEvent(QMouseEvent *e);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void leaveEvent(QEvent *);
......@@ -114,6 +114,8 @@ private:
double _min_period;
unsigned int _cur_prefix;
bool _hitCursor;
bool _curs_moved;
};
} // namespace view
......
......@@ -285,14 +285,41 @@ void Trace::paint_label(QPainter &p, int right, const QPoint pt)
p.setPen(Qt::transparent);
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));
} else {
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.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
p.setPen(Qt::white);
if (_type == SR_CHANNEL_GROUP)
......
......@@ -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 pv
......@@ -195,6 +195,8 @@ public:
bool get_capture_status(bool &triggered, int &progress);
void set_capture_status();
bool get_dso_trig_moved() const;
signals:
void hover_point_changed();
......
This diff is collapsed.
......@@ -101,6 +101,8 @@ public:
void set_need_update(bool update);
bool get_dso_trig_moved() const;
protected:
void paintEvent(QPaintEvent *event);
......@@ -195,6 +197,8 @@ private:
int _dso_ym_end;
int _waiting_trig;
bool _dso_trig_moved;
bool _curs_moved;
};
} // 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