Hi,
I would like to enable a faster way to moving the cursors around using the
right-click action.
Enclosed is the diff against current pulseview master branch and here is
the online version
https://github.com/ticapix/pulseview/pull/1/files
(I presume the same action can be done for tactile screen with a long
finger pressure+move)
--
Pierre Gronlier
diff --git a/pv/view/view.cpp b/pv/view/view.cpp
index 1d55e14..dec3911 100644
--- a/pv/view/view.cpp
+++ b/pv/view/view.cpp
@@ -107,6 +107,9 @@ View::View(SigSession &session, QWidget *parent) :
connect(_header, SIGNAL(signals_moved()),
this, SLOT(on_signals_moved()));
+ connect(_viewport, SIGNAL(traces_selected()),
+ this, SLOT(traces_selected()));
+
connect(_header, SIGNAL(selection_changed()),
_cursorheader, SLOT(clear_selection()));
connect(_cursorheader, SIGNAL(selection_changed()),
@@ -550,5 +553,14 @@ void View::on_geometry_updated()
update_layout();
}
+void View::traces_selected()
+{
+ _cursors.first()->set_time(_viewport->get_selection_from().x() * scale()
+ + offset());
+ _cursors.second()->set_time(_viewport->get_selection_to().x() * scale()
+ + offset());
+ _viewport->update();
+}
+
} // namespace view
} // namespace pv
diff --git a/pv/view/view.h b/pv/view/view.h
index 021767d..70b14ba 100644
--- a/pv/view/view.h
+++ b/pv/view/view.h
@@ -185,6 +185,7 @@ private Q_SLOTS:
void on_geometry_updated();
+ void traces_selected();
private:
SigSession &_session;
diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp
index b141c38..34e94cd 100644
--- a/pv/view/viewport.cpp
+++ b/pv/view/viewport.cpp
@@ -27,6 +27,7 @@
#include "../sigsession.h"
#include <QMouseEvent>
+#include <QApplication>
using std::abs;
using std::max;
@@ -41,13 +42,16 @@ Viewport::Viewport(View &parent) :
QWidget(&parent),
_view(parent),
_mouse_down_valid(false),
- _pinch_zoom_active(false)
+ _pinch_zoom_active(false),
+ _on_selection(false)
{
setAttribute(Qt::WA_AcceptTouchEvents, true);
setMouseTracking(true);
setAutoFillBackground(true);
setBackgroundRole(QPalette::Base);
+ _selection_color = QApplication::palette().highlight().color();
+ _selection_color.setAlphaF(0.5);
connect(&_view.session(), SIGNAL(signals_changed()),
this, SLOT(on_signals_changed()));
@@ -60,6 +64,16 @@ Viewport::Viewport(View &parent) :
on_signals_changed();
}
+QPoint Viewport::get_selection_from() const
+{
+ return _selected_area.from;
+}
+
+QPoint Viewport::get_selection_to() const
+{
+ return _selected_area.to;
+}
+
int Viewport::get_total_height() const
{
int h = 0;
@@ -98,6 +112,10 @@ void Viewport::paintEvent(QPaintEvent*)
if (_view.cursors_shown())
_view.cursors().draw_viewport_foreground(p, rect());
+ if (_on_selection) {
+ p.fillRect(QRect(_selected_area.from, _selected_area.to).normalized(),
+ _selection_color);
+ }
p.end();
}
@@ -127,6 +145,10 @@ void Viewport::mousePressEvent(QMouseEvent *event)
_mouse_down_offset = _view.offset();
_mouse_down_valid = true;
}
+ if (event->buttons() & Qt::RightButton) {
+ _on_selection = true;
+ _selected_area.from = event->pos();
+ }
}
void Viewport::mouseReleaseEvent(QMouseEvent *event)
@@ -135,6 +157,16 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
if (event->button() == Qt::LeftButton)
_mouse_down_valid = false;
+
+ _mouse_down_point = event->pos();
+ _mouse_down_offset = _view.offset();
+ if (_on_selection) {
+ _on_selection = false;
+ _selected_area.to = event->pos();
+ if (_selected_area.from.x() > _selected_area.to.x())
+ std::swap(_selected_area.from, _selected_area.to);
+ traces_selected();
+ }
}
void Viewport::mouseMoveEvent(QMouseEvent *event)
@@ -153,6 +185,10 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
(_mouse_down_point - event->pos()).x() *
_view.scale());
}
+ if (_on_selection) {
+ _selected_area.to = event->pos();
+ update();
+ }
}
void Viewport::mouseDoubleClickEvent(QMouseEvent *event)
diff --git a/pv/view/viewport.h b/pv/view/viewport.h
index 10b88b4..4593138 100644
--- a/pv/view/viewport.h
+++ b/pv/view/viewport.h
@@ -42,6 +42,8 @@ public:
explicit Viewport(View &parent);
int get_total_height() const;
+ QPoint get_selection_from() const;
+ QPoint get_selection_to() const;
protected:
void paintEvent(QPaintEvent *event);
@@ -59,6 +61,9 @@ private Q_SLOTS:
void on_signals_changed();
void on_signals_moved();
+Q_SIGNALS:
+ void traces_selected();
+
private:
View &_view;
@@ -69,6 +74,13 @@ private:
double _pinch_offset0;
double _pinch_offset1;
bool _pinch_zoom_active;
+
+ bool _on_selection;
+ struct {
+ QPoint from;
+ QPoint to;
+ } _selected_area;
+ QColor _selection_color;
};
} // namespace view
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel