From d5d1f925b5480e4f7d40a8cbc67bd653fa89bd89 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sun, 24 Aug 2014 20:17:18 +0100 Subject: [PATCH] Replaced duplicated code with Trace::get_y --- pv/view/analogsignal.cpp | 3 +-- pv/view/decodetrace.cpp | 1 - pv/view/logicsignal.cpp | 5 ++--- pv/view/trace.cpp | 6 ++---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 38468942..bba84cae 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -90,8 +90,7 @@ void AnalogSignal::paint_mid(QPainter &p, int left, int right) assert(_data); assert(right >= left); - assert(_view); - const int y = _v_offset - _view->v_offset(); + const int y = get_y(); const double scale = _view->scale(); assert(scale > 0); diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 700b221b..cb455c5a 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -181,7 +181,6 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right) } // Iterate through the rows - assert(_view); int y = get_y(); pair sample_range = get_sample_range(left, right); diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 21bd5b95..d9987170 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -138,9 +138,8 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right) assert(_data); assert(right >= left); - assert(_view); - const int y = _v_offset - _view->v_offset(); - + const int y = get_y(); + const double scale = _view->scale(); assert(scale > 0); diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index e825337c..1231eae4 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -109,8 +109,7 @@ void Trace::paint_fore(QPainter &p, int left, int right) void Trace::paint_label(QPainter &p, int right, bool hover) { - assert(_view); - const int y = _v_offset - _view->v_offset(); + const int y = get_y(); p.setBrush(_colour); @@ -187,6 +186,7 @@ pv::widgets::Popup* Trace::create_popup(QWidget *parent) int Trace::get_y() const { + assert(_view); return _v_offset - _view->v_offset(); } @@ -194,8 +194,6 @@ QRectF Trace::label_rect(int right) { using pv::view::View; - assert(_view); - QFontMetrics m(QApplication::font()); const QSize text_size( m.boundingRect(QRect(), 0, _name).width(), -- 2.30.2