X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fviewport.cpp;h=f8d568109f3c198f78e145ba0bdc25be041779b7;hp=06fab904e75168fab06a9499574446959c93e9a3;hb=f9abf97e78bc4825d80926b0ebc6cbaef40768b1;hpb=01fd32630269c1cfb99eb2b0d6060d7d19a42475 diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp index 06fab904..f8d56810 100644 --- a/pv/view/viewport.cpp +++ b/pv/view/viewport.cpp @@ -26,10 +26,10 @@ #include -#include - -using namespace boost; -using namespace std; +using std::max; +using std::min; +using std::shared_ptr; +using std::vector; namespace pv { namespace view { @@ -42,15 +42,22 @@ Viewport::Viewport(View &parent) : setAutoFillBackground(true); setBackgroundRole(QPalette::Base); + connect(&_view.session(), SIGNAL(signals_changed()), + this, SLOT(on_signals_changed())); + connect(&_view, SIGNAL(signals_moved()), this, SLOT(on_signals_moved())); + + // Trigger the initial event manually. The default device has signals + // which were created before this object came into being + on_signals_changed(); } int Viewport::get_total_height() const { int h = 0; const vector< shared_ptr > traces(_view.get_traces()); - BOOST_FOREACH(const shared_ptr t, traces) { + for (const shared_ptr t : traces) { assert(t); h = max(t->get_v_offset() + View::SignalHeight, h); } @@ -69,12 +76,18 @@ void Viewport::paintEvent(QPaintEvent*) _view.cursors().draw_viewport_background(p, rect()); // Plot the signal - BOOST_FOREACH(const shared_ptr t, traces) + for (const shared_ptr t : traces) { assert(t); - t->paint(p, 0, width()); + t->paint_back(p, 0, width()); } + for (const shared_ptr t : traces) + t->paint_mid(p, 0, width()); + + for (const shared_ptr t : traces) + t->paint_fore(p, 0, width()); + if (_view.cursors_shown()) _view.cursors().draw_viewport_foreground(p, rect()); @@ -102,6 +115,16 @@ void Viewport::mouseMoveEvent(QMouseEvent *event) } } +void Viewport::mouseDoubleClickEvent(QMouseEvent *event) +{ + assert(event); + + if (event->buttons() & Qt::LeftButton) + _view.zoom(2.0, event->x()); + else if (event->buttons() & Qt::RightButton) + _view.zoom(-2.0, event->x()); +} + void Viewport::wheelEvent(QWheelEvent *event) { assert(event); @@ -117,6 +140,16 @@ void Viewport::wheelEvent(QWheelEvent *event) } } +void Viewport::on_signals_changed() +{ + const vector< shared_ptr > traces(_view.get_traces()); + for (shared_ptr t : traces) { + assert(t); + connect(t.get(), SIGNAL(visibility_changed()), + this, SLOT(update())); + } +} + void Viewport::on_signals_moved() { update();