update_scale();
}
-void AnalogSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp)
+void AnalogSignal::paint_back(QPainter &p, ViewItemPaintParams &pp)
{
if (base_->enabled()) {
Trace::paint_back(p, pp);
}
}
-void AnalogSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp)
+void AnalogSignal::paint_mid(QPainter &p, ViewItemPaintParams &pp)
{
assert(base_->analog_data());
assert(owner_);
}
}
-void AnalogSignal::paint_fore(QPainter &p, const ViewItemPaintParams &pp)
+void AnalogSignal::paint_fore(QPainter &p, ViewItemPaintParams &pp)
{
if (!enabled())
return;
delete[] e.samples;
}
-void AnalogSignal::paint_logic_mid(QPainter &p, const ViewItemPaintParams &pp)
+void AnalogSignal::paint_logic_mid(QPainter &p, ViewItemPaintParams &pp)
{
QLineF *line;
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with..
*/
- void paint_back(QPainter &p, const ViewItemPaintParams &pp);
+ void paint_back(QPainter &p, ViewItemPaintParams &pp);
/**
* Paints the mid-layer of the signal with a QPainter
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with..
*/
- void paint_mid(QPainter &p, const ViewItemPaintParams &pp);
+ void paint_mid(QPainter &p, ViewItemPaintParams &pp);
/**
* Paints the foreground layer of the item with a QPainter
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with.
*/
- void paint_fore(QPainter &p, const ViewItemPaintParams &pp);
+ void paint_fore(QPainter &p, ViewItemPaintParams &pp);
private:
void paint_grid(QPainter &p, int y, int left, int right);
int y, int left, const int64_t start, const int64_t end,
const double pixels_offset, const double samples_per_pixel);
- void paint_logic_mid(QPainter &p, const ViewItemPaintParams &pp);
+ void paint_logic_mid(QPainter &p, ViewItemPaintParams &pp);
void paint_logic_caps(QPainter &p, QLineF *const lines,
vector< pair<int64_t, bool> > &edges,
}
}
-void CursorPair::paint_back(QPainter &p, const ViewItemPaintParams &pp)
+void CursorPair::paint_back(QPainter &p, ViewItemPaintParams &pp)
{
if (!enabled())
return;
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with.
*/
- void paint_back(QPainter &p, const ViewItemPaintParams &pp) override;
+ void paint_back(QPainter &p, ViewItemPaintParams &pp) override;
/**
* Constructs the string to display.
return make_pair(-row_height, row_height * row_count);
}
-void DecodeTrace::paint_back(QPainter &p, const ViewItemPaintParams &pp)
+void DecodeTrace::paint_back(QPainter &p, ViewItemPaintParams &pp)
{
Trace::paint_back(p, pp);
paint_axis(p, pp, get_visual_y());
}
-void DecodeTrace::paint_mid(QPainter &p, const ViewItemPaintParams &pp)
+void DecodeTrace::paint_mid(QPainter &p, ViewItemPaintParams &pp)
{
using namespace pv::data::decode;
max_visible_rows_ = max(max_visible_rows_, (int)visible_rows_.size());
}
-void DecodeTrace::paint_fore(QPainter &p, const ViewItemPaintParams &pp)
+void DecodeTrace::paint_fore(QPainter &p, ViewItemPaintParams &pp)
{
using namespace pv::data::decode;
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with..
*/
- void paint_back(QPainter &p, const ViewItemPaintParams &pp);
+ void paint_back(QPainter &p, ViewItemPaintParams &pp);
/**
* Paints the mid-layer of the trace with a QPainter
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with.
*/
- void paint_mid(QPainter &p, const ViewItemPaintParams &pp);
+ void paint_mid(QPainter &p, ViewItemPaintParams &pp);
/**
* Paints the foreground layer of the trace with a QPainter
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with.
*/
- void paint_fore(QPainter &p, const ViewItemPaintParams &pp);
+ void paint_fore(QPainter &p, ViewItemPaintParams &pp);
void populate_popup_form(QWidget *parent, QFormLayout *form);
signal_height_ = ((units < 1) ? 1 : units) * font_height;
}
-void LogicSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp)
+void LogicSignal::paint_mid(QPainter &p, ViewItemPaintParams &pp)
{
QLineF *line;
delete[] sampling_points;
}
-void LogicSignal::paint_fore(QPainter &p, const ViewItemPaintParams &pp)
+void LogicSignal::paint_fore(QPainter &p, ViewItemPaintParams &pp)
{
// Draw the trigger marker
if (!trigger_match_ || !base_->enabled())
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with..
*/
- void paint_mid(QPainter &p, const ViewItemPaintParams &pp);
+ void paint_mid(QPainter &p, ViewItemPaintParams &pp);
/**
* Paints the foreground layer of the signal with a QPainter
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with.
*/
- virtual void paint_fore(QPainter &p, const ViewItemPaintParams &pp);
+ virtual void paint_fore(QPainter &p, ViewItemPaintParams &pp);
private:
void paint_caps(QPainter &p, QLineF *const lines,
return items_;
}
-void Signal::paint_back(QPainter &p, const ViewItemPaintParams &pp)
+void Signal::paint_back(QPainter &p, ViewItemPaintParams &pp)
{
if (base_->enabled())
Trace::paint_back(p, pp);
*/
const item_list& child_items() const;
- void paint_back(QPainter &p, const ViewItemPaintParams &pp);
+ void paint_back(QPainter &p, ViewItemPaintParams &pp);
virtual void populate_popup_form(QWidget *parent, QFormLayout *form);
text_height, text_height);
}
-void SignalScaleHandle::paint_fore(QPainter &p, const ViewItemPaintParams &pp)
+void SignalScaleHandle::paint_fore(QPainter &p, ViewItemPaintParams &pp)
{
if (!enabled())
return;
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with.
*/
- void paint_fore(QPainter &p, const ViewItemPaintParams &pp);
+ void paint_fore(QPainter &p, ViewItemPaintParams &pp);
private:
Signal &owner_;
p.drawText(r, Qt::AlignCenter | Qt::AlignVCenter, get_text());
}
-void TimeMarker::paint_fore(QPainter &p, const ViewItemPaintParams &pp)
+void TimeMarker::paint_fore(QPainter &p, ViewItemPaintParams &pp)
{
if (!enabled())
return;
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with.
*/
- void paint_fore(QPainter &p, const ViewItemPaintParams &pp) override;
+ void paint_fore(QPainter &p, ViewItemPaintParams &pp) override;
virtual pv::widgets::Popup* create_popup(QWidget *parent) override;
label_size.height());
}
-void Trace::paint_back(QPainter &p, const ViewItemPaintParams &pp)
+void Trace::paint_back(QPainter &p, ViewItemPaintParams &pp)
{
const View *view = owner_->view();
assert(view);
pp.width(), extents.second - extents.first);
}
-void Trace::paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y)
+void Trace::paint_axis(QPainter &p, ViewItemPaintParams &pp, int y)
{
p.setRenderHint(QPainter::Antialiasing, false);
* @param p The QPainter to paint into.
* @param pp The painting parameters object to paint with.
*/
- virtual void paint_back(QPainter &p, const ViewItemPaintParams &pp);
+ virtual void paint_back(QPainter &p, ViewItemPaintParams &pp);
/**
* Paints a zero axis across the viewport.
* @param pp the painting parameters object to paint with.
* @param y the y-offset of the axis.
*/
- void paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y);
+ void paint_axis(QPainter &p, ViewItemPaintParams &pp, int y);
void add_colour_option(QWidget *parent, QFormLayout *form);
return QPoint(get_x(), rect.bottom());
}
-void TriggerMarker::paint_fore(QPainter &p, const ViewItemPaintParams &pp)
+void TriggerMarker::paint_fore(QPainter &p, ViewItemPaintParams &pp)
{
if (!enabled())
return;
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with.
*/
- void paint_fore(QPainter &p, const ViewItemPaintParams &pp) override;
+ void paint_fore(QPainter &p, ViewItemPaintParams &pp) override;
private:
pv::util::Timestamp time_;
(void)hover;
}
-void ViewItem::paint_back(QPainter &p, const ViewItemPaintParams &pp)
+void ViewItem::paint_back(QPainter &p, ViewItemPaintParams &pp)
{
(void)p;
(void)pp;
}
-void ViewItem::paint_mid(QPainter &p, const ViewItemPaintParams &pp)
+void ViewItem::paint_mid(QPainter &p, ViewItemPaintParams &pp)
{
(void)p;
(void)pp;
}
-void ViewItem::paint_fore(QPainter &p, const ViewItemPaintParams &pp)
+void ViewItem::paint_fore(QPainter &p, ViewItemPaintParams &pp)
{
(void)p;
(void)pp;
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with.
*/
- virtual void paint_back(QPainter &p, const ViewItemPaintParams &pp);
+ virtual void paint_back(QPainter &p, ViewItemPaintParams &pp);
/**
* Paints the mid-layer of the item with a QPainter
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with.
*/
- virtual void paint_mid(QPainter &p, const ViewItemPaintParams &pp);
+ virtual void paint_mid(QPainter &p, ViewItemPaintParams &pp);
/**
* Paints the foreground layer of the item with a QPainter
* @param p the QPainter to paint into.
* @param pp the painting parameters object to paint with.
*/
- virtual void paint_fore(QPainter &p, const ViewItemPaintParams &pp);
+ virtual void paint_fore(QPainter &p, ViewItemPaintParams &pp);
public:
/**
void Viewport::paintEvent(QPaintEvent*)
{
+ typedef void (ViewItem::*LayerPaintFunc)(
+ QPainter &p, ViewItemPaintParams &pp);
+ LayerPaintFunc layer_paint_funcs[] = {
+ &ViewItem::paint_back, &ViewItem::paint_mid,
+ &ViewItem::paint_fore, nullptr};
+
vector< shared_ptr<RowItem> > row_items(view_.list_by_type<RowItem>());
assert(none_of(row_items.begin(), row_items.end(),
[](const shared_ptr<RowItem> &r) { return !r; }));
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
- const ViewItemPaintParams pp(rect(), view_.scale(), view_.offset());
-
- for (const shared_ptr<TimeItem> t : time_items)
- t->paint_back(p, pp);
- for (const shared_ptr<RowItem> r : row_items)
- r->paint_back(p, pp);
+ for (LayerPaintFunc *paint_func = layer_paint_funcs;
+ *paint_func; paint_func++) {
+ ViewItemPaintParams time_pp(rect(), view_.scale(), view_.offset());
+ for (const shared_ptr<TimeItem> t : time_items)
+ (t.get()->*(*paint_func))(p, time_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<TimeItem> t : time_items)
- t->paint_fore(p, pp);
+ ViewItemPaintParams row_pp(rect(), view_.scale(), view_.offset());
+ for (const shared_ptr<RowItem> r : row_items)
+ (r.get()->*(*paint_func))(p, row_pp);
+ }
p.end();
}