From 509727eb807fe8cc8bd6c224099d77cbb2075c18 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Mon, 30 Sep 2013 22:17:30 +0900 Subject: [PATCH] Factored out TimeMarker::get_x --- pv/view/timemarker.cpp | 7 ++++++- pv/view/timemarker.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pv/view/timemarker.cpp b/pv/view/timemarker.cpp index e40c393b..40bb8173 100644 --- a/pv/view/timemarker.cpp +++ b/pv/view/timemarker.cpp @@ -44,6 +44,11 @@ double TimeMarker::time() const return _time; } +float TimeMarker::get_x() const +{ + return (_time - _view.offset()) / _view.scale(); +} + void TimeMarker::set_time(double time) { _time = time; @@ -59,7 +64,7 @@ void TimeMarker::set_time(double time) void TimeMarker::paint(QPainter &p, const QRect &rect) { - const float x = (_time - _view.offset()) / _view.scale(); + const float x = get_x(); p.setPen(_colour); p.drawLine(QPointF(x, rect.top()), QPointF(x, rect.bottom())); } diff --git a/pv/view/timemarker.h b/pv/view/timemarker.h index 54b9c248..03fdd0fb 100644 --- a/pv/view/timemarker.h +++ b/pv/view/timemarker.h @@ -61,6 +61,8 @@ public: */ void set_time(double time); + float get_x() const; + /** * Paints the marker to the viewport. * @param p The painter to draw with. -- 2.30.2