From: Joel Holdsworth Date: Wed, 26 Apr 2017 17:39:48 +0000 (-0600) Subject: TimeMarker: Align to a integer pixel offset X-Git-Tag: pulseview-0.4.0~95 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=cb5a1216019ae561046f7812b7fc67c11ea3d6c5;p=pulseview.git TimeMarker: Align to a integer pixel offset --- diff --git a/pv/view/cursor.cpp b/pv/view/cursor.cpp index 408eb311..f22680b9 100644 --- a/pv/view/cursor.cpp +++ b/pv/view/cursor.cpp @@ -67,7 +67,7 @@ QRectF Cursor::label_rect(const QRectF &rect) const const shared_ptr other(get_other_cursor()); assert(other); - const float x = ((time_ - view_.offset())/ view_.scale()).convert_to(); + const float x = get_x(); QFontMetrics m(QApplication::font()); QSize text_size = m.boundingRect(get_text()).size(); diff --git a/pv/view/cursorpair.cpp b/pv/view/cursorpair.cpp index 3259524c..24d03665 100644 --- a/pv/view/cursorpair.cpp +++ b/pv/view/cursorpair.cpp @@ -187,9 +187,7 @@ pair CursorPair::get_cursor_offsets() const assert(first_); assert(second_); - return pair( - ((first_->time() - view_.offset()) / view_.scale()).convert_to(), - ((second_->time() - view_.offset()) / view_.scale()).convert_to()); + return pair(first_->get_x(), second_->get_x()); } } // namespace TraceView diff --git a/pv/view/timemarker.cpp b/pv/view/timemarker.cpp index 4874eb23..88616bf2 100644 --- a/pv/view/timemarker.cpp +++ b/pv/view/timemarker.cpp @@ -18,6 +18,7 @@ */ #include +#include #include @@ -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(); + return std::roundf(((time_ - view_.offset()) / view_.scale()).convert_to()) + 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(); + const qreal x = get_x(); const QRectF r(label_rect(rect)); const QPointF points[] = { diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp index d81befae..2ed43ba2 100644 --- a/pv/view/viewport.cpp +++ b/pv/view/viewport.cpp @@ -183,7 +183,6 @@ void Viewport::paintEvent(QPaintEvent*) for (const shared_ptr r : row_items) r->paint_fore(p, pp); - p.setRenderHint(QPainter::Antialiasing, false); for (const shared_ptr t : time_items) t->paint_fore(p, pp);