]> sigrok.org Git - pulseview.git/commitdiff
TimeMarker: Align to a integer pixel offset
authorJoel Holdsworth <redacted>
Wed, 26 Apr 2017 17:39:48 +0000 (11:39 -0600)
committerUwe Hermann <redacted>
Wed, 3 May 2017 17:08:10 +0000 (19:08 +0200)
pv/view/cursor.cpp
pv/view/cursorpair.cpp
pv/view/timemarker.cpp
pv/view/viewport.cpp

index 408eb311e9a57a15c2432ee3307207e8fce779e3..f22680b9f46f547bfbb315f43f9131140a588dc0 100644 (file)
@@ -67,7 +67,7 @@ QRectF Cursor::label_rect(const QRectF &rect) const
        const shared_ptr<Cursor> other(get_other_cursor());
        assert(other);
 
-       const float x = ((time_ - view_.offset())/ view_.scale()).convert_to<float>();
+       const float x = get_x();
 
        QFontMetrics m(QApplication::font());
        QSize text_size = m.boundingRect(get_text()).size();
index 3259524c754acbf151dc7755146b220a347eaa31..24d036652d763ca6d9a4be898a2cdcbeedd35020 100644 (file)
@@ -187,9 +187,7 @@ pair<float, float> CursorPair::get_cursor_offsets() const
        assert(first_);
        assert(second_);
 
-       return pair<float, float>(
-               ((first_->time() - view_.offset()) / view_.scale()).convert_to<float>(),
-               ((second_->time() - view_.offset()) / view_.scale()).convert_to<float>());
+       return pair<float, float>(first_->get_x(), second_->get_x());
 }
 
 } // namespace TraceView
index 4874eb233c7ebf7d9fe5e282883dc93a1efbc8a7..88616bf20fb2cdb1a06367aeb8ee77250fc2c55b 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include <algorithm>
+#include <cmath>
 
 #include <extdef.h>
 
@@ -73,7 +74,7 @@ void TimeMarker::set_time(const pv::util::Timestamp& time)
 
 float TimeMarker::get_x() const
 {
-       return ((time_ - view_.offset()) / view_.scale()).convert_to<float>();
+       return std::roundf(((time_ - view_.offset()) / view_.scale()).convert_to<float>()) + 0.5f;
 }
 
 QPoint TimeMarker::point(const QRect &rect) const
@@ -107,7 +108,7 @@ void TimeMarker::paint_label(QPainter &p, const QRect &rect, bool hover)
        if (!enabled())
                return;
 
-       const qreal x = ((time_ - view_.offset()) / view_.scale()).convert_to<qreal>();
+       const qreal x = get_x();
        const QRectF r(label_rect(rect));
 
        const QPointF points[] = {
index d81befae9cb69522ea3a52f82f6b85540bfa6d19..2ed43ba283b4f16c8f9c1a20a22e7138e2b3c63e 100644 (file)
@@ -183,7 +183,6 @@ void Viewport::paintEvent(QPaintEvent*)
        for (const shared_ptr<RowItem> r : row_items)
                r->paint_fore(p, pp);
 
-       p.setRenderHint(QPainter::Antialiasing, false);
        for (const shared_ptr<TimeItem> t : time_items)
                t->paint_fore(p, pp);