projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added ViewWidget as a common ancestor of all view widgets
[pulseview.git]
/
pv
/
view
/
viewport.cpp
diff --git
a/pv/view/viewport.cpp
b/pv/view/viewport.cpp
index f5f0ab59fb2f949caf1bef931b506d0d859b185a..0c33fe2c4a00685976320634315c26b8ffd90185 100644
(file)
--- a/
pv/view/viewport.cpp
+++ b/
pv/view/viewport.cpp
@@
-22,9
+22,9
@@
#include <cmath>
#include <algorithm>
#include <cmath>
#include <algorithm>
-#include "rowitempaintparams.hpp"
#include "signal.hpp"
#include "view.hpp"
#include "signal.hpp"
#include "view.hpp"
+#include "viewitempaintparams.hpp"
#include "viewport.hpp"
#include <pv/session.hpp>
#include "viewport.hpp"
#include <pv/session.hpp>
@@
-34,6
+34,7
@@
using std::abs;
using std::max;
using std::min;
using std::abs;
using std::max;
using std::min;
+using std::none_of;
using std::shared_ptr;
using std::stable_sort;
using std::vector;
using std::shared_ptr;
using std::stable_sort;
using std::vector;
@@
-42,14
+43,12
@@
namespace pv {
namespace view {
Viewport::Viewport(View &parent) :
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);
mouse_down_valid_(false),
pinch_zoom_active_(false)
{
setAttribute(Qt::WA_AcceptTouchEvents, true);
- setMouseTracking(true);
setAutoFillBackground(true);
setBackgroundRole(QPalette::Base);
setAutoFillBackground(true);
setBackgroundRole(QPalette::Base);
@@
-60,33
+59,36
@@
Viewport::Viewport(View &parent) :
void Viewport::paintEvent(QPaintEvent*)
{
vector< shared_ptr<RowItem> > row_items(view_.begin(), view_.end());
void Viewport::paintEvent(QPaintEvent*)
{
vector< shared_ptr<RowItem> > row_items(view_.begin(), view_.end());
+ assert(none_of(row_items.begin(), row_items.end(),
+ [](const shared_ptr<RowItem> &r) { return !r; }));
+
stable_sort(row_items.begin(), row_items.end(),
[](const shared_ptr<RowItem> &a, const shared_ptr<RowItem> &b) {
return a->visual_v_offset() < b->visual_v_offset(); });
stable_sort(row_items.begin(), row_items.end(),
[](const shared_ptr<RowItem> &a, const shared_ptr<RowItem> &b) {
return a->visual_v_offset() < b->visual_v_offset(); });
+ const vector< shared_ptr<TimeItem> > time_items(view_.time_items());
+ assert(none_of(time_items.begin(), time_items.end(),
+ [](const shared_ptr<TimeItem> &t) { return !t; }));
+
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
- if (view_.cursors_shown())
- view_.cursors().draw_viewport_background(p, rect());
-
- const RowItemPaintParams pp(0, width(), view_.scale(), view_.offset());
+ const ViewItemPaintParams pp(rect(), view_.scale(), view_.offset());
- // Plot the signal
+ for (const shared_ptr<TimeItem> t : time_items)
+ t->paint_back(p, pp);
for (const shared_ptr<RowItem> r : row_items)
for (const shared_ptr<RowItem> r : row_items)
- {
- assert(r);
r->paint_back(p, pp);
r->paint_back(p, pp);
- }
+ for (const shared_ptr<TimeItem> t : time_items)
+ t->paint_mid(p, pp);
for (const shared_ptr<RowItem> r : row_items)
r->paint_mid(p, pp);
for (const shared_ptr<RowItem> r : row_items)
r->paint_fore(p, pp);
for (const shared_ptr<RowItem> r : row_items)
r->paint_mid(p, pp);
for (const shared_ptr<RowItem> r : row_items)
r->paint_fore(p, pp);
-
- if (view_.cursors_shown())
- view_.cursors().draw_viewport_foreground(p, rect());
+ for (const shared_ptr<TimeItem> t : time_items)
+ t->paint_fore(p, pp);
p.end();
}
p.end();
}