From: Joel Holdsworth Date: Mon, 30 Sep 2013 13:17:30 +0000 (+0900) Subject: Factored out TimeMarker::get_x X-Git-Tag: pulseview-0.2.0~271 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=509727eb807fe8cc8bd6c224099d77cbb2075c18;p=pulseview.git Factored out TimeMarker::get_x --- 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.