From: Joel Holdsworth Date: Sun, 24 Aug 2014 19:17:18 +0000 (+0100) Subject: Replaced duplicated code with Trace::get_y X-Git-Tag: pulseview-0.3.0~485 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d5d1f925b5480e4f7d40a8cbc67bd653fa89bd89;p=pulseview.git Replaced duplicated code with Trace::get_y --- 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(),