X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fviewport.cpp;h=c33af44b6ccc423f3f8dc13d579e0268e7aad3ee;hp=bc010b4bd02fa3cd11270397c87e2588df2af461;hb=f15bb3bc4f964eaafdd4c46f29f69ef74572baee;hpb=3eb29afdb641606c2e2e059289d8cc103d027a25 diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp index bc010b4b..c33af44b 100644 --- a/pv/view/viewport.cpp +++ b/pv/view/viewport.cpp @@ -22,9 +22,9 @@ #include #include -#include "rowitempaintparams.hpp" #include "signal.hpp" #include "view.hpp" +#include "viewitempaintparams.hpp" #include "viewport.hpp" #include @@ -34,6 +34,7 @@ using std::abs; using std::max; using std::min; +using std::none_of; using std::shared_ptr; using std::stable_sort; using std::vector; @@ -42,51 +43,49 @@ namespace pv { namespace view { Viewport::Viewport(View &parent) : - QWidget(&parent), - view_(parent), + ViewWidget(parent), mouse_down_valid_(false), pinch_zoom_active_(false) { setAttribute(Qt::WA_AcceptTouchEvents, true); - setMouseTracking(true); setAutoFillBackground(true); setBackgroundRole(QPalette::Base); - - connect(&view_, SIGNAL(signals_moved()), - this, SLOT(on_signals_moved())); } void Viewport::paintEvent(QPaintEvent*) { vector< shared_ptr > row_items(view_.begin(), view_.end()); + assert(none_of(row_items.begin(), row_items.end(), + [](const shared_ptr &r) { return !r; })); + stable_sort(row_items.begin(), row_items.end(), [](const shared_ptr &a, const shared_ptr &b) { return a->visual_v_offset() < b->visual_v_offset(); }); + const vector< shared_ptr > time_items(view_.time_items()); + assert(none_of(time_items.begin(), time_items.end(), + [](const shared_ptr &t) { return !t; })); + QPainter p(this); p.setRenderHint(QPainter::Antialiasing); - if (view_.cursors_shown()) - view_.cursors().draw_viewport_background(p, rect()); + const ViewItemPaintParams pp(rect(), view_.scale(), view_.offset()); - const RowItemPaintParams pp(0, width()); - - // Plot the signal + for (const shared_ptr t : time_items) + t->paint_back(p, pp); for (const shared_ptr r : row_items) - { - assert(r); r->paint_back(p, pp); - } + for (const shared_ptr t : time_items) + t->paint_mid(p, pp); for (const shared_ptr r : row_items) r->paint_mid(p, pp); for (const shared_ptr r : row_items) r->paint_fore(p, pp); - - if (view_.cursors_shown()) - view_.cursors().draw_viewport_foreground(p, rect()); + for (const shared_ptr t : time_items) + t->paint_fore(p, pp); p.end(); } @@ -217,10 +216,5 @@ bool Viewport::touchEvent(QTouchEvent *event) return true; } -void Viewport::on_signals_moved() -{ - update(); -} - } // namespace view } // namespace pv