]> sigrok.org Git - pulseview.git/commitdiff
Factored out TimeMarker::get_x
authorJoel Holdsworth <redacted>
Mon, 30 Sep 2013 13:17:30 +0000 (22:17 +0900)
committerJoel Holdsworth <redacted>
Sun, 13 Oct 2013 10:05:22 +0000 (11:05 +0100)
pv/view/timemarker.cpp
pv/view/timemarker.h

index e40c393ba6e629e32724f9cba1c382bf4d48a5a3..40bb81731884c54fec36b1ed18bba5195c0879df 100644 (file)
@@ -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()));
 }
index 54b9c248529ff3e4a6c87d3fef5a1f274c626ca2..03fdd0fb2e0d55faeab68ddd1f4881cfdc8f4679 100644 (file)
@@ -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.