From 420e96a2f4e8383e8cd27ec38a525d94ab87b7a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 12 Sep 2016 23:53:14 +0200 Subject: [PATCH] Fixed rendering issues --- src/axisitem.cpp | 7 ++++--- src/scaleitem.cpp | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/axisitem.cpp b/src/axisitem.cpp index 5b9e015a..6379f654 100644 --- a/src/axisitem.cpp +++ b/src/axisitem.cpp @@ -35,7 +35,9 @@ AxisItem::AxisItem(Type type, QGraphicsItem *parent) : QGraphicsItem(parent) _type = type; _size = 0; +#ifndef Q_OS_MAC setCacheMode(QGraphicsItem::DeviceCoordinateCache); +#endif // Q_OS_MAC } void AxisItem::setRange(const RangeF &range) @@ -93,9 +95,8 @@ void AxisItem::updateBoundingRect() mtw = qMax(ts.width(), mtw); } - _boundingRect = QRectF(-(ls.height() + mtw + 2*PADDING - - fm.descent() + TICK/2), -(_size + es.height()/2 - + fm.descent()), ls.height() -fm.descent() + mtw + 2*PADDING + _boundingRect = QRectF(-(ls.height() + mtw + 2*PADDING + TICK/2), + -(_size + es.height()/2 + fm.descent()), ls.height() + mtw + 2*PADDING + TICK, _size + es.height()/2 + fm.descent() + ss.height()/2); } } diff --git a/src/scaleitem.cpp b/src/scaleitem.cpp index 1639e5a6..7352f90f 100644 --- a/src/scaleitem.cpp +++ b/src/scaleitem.cpp @@ -18,7 +18,9 @@ ScaleItem::ScaleItem(QGraphicsItem *parent) : QGraphicsItem(parent) _zoom = ZOOM_MIN; _lat = 0; +#ifndef Q_OS_MAC setCacheMode(QGraphicsItem::DeviceCoordinateCache); +#endif // Q_OS_MAC } void ScaleItem::updateBoundingRect() @@ -33,9 +35,9 @@ void ScaleItem::updateBoundingRect() es = fm.tightBoundingRect(QString::number(_length * SEGMENTS)); us = fm.tightBoundingRect(units()); - _boundingRect = QRectF(-ss.width()/2, 0, - _width * SEGMENTS + ss.width()/2 + qMax(us.width() + PADDING, es.width()/2), - SCALE_HEIGHT + PADDING + ss.height() + 2*fm.descent()); + _boundingRect = QRectF(-ss.width()/2, 0, _width * SEGMENTS + ss.width()/2 + + qMax(us.width() + PADDING, es.width()/2) + 1, SCALE_HEIGHT + PADDING + + ss.height() + 2*fm.descent()); } void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, @@ -69,10 +71,12 @@ void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, for (int i = 0; i < SEGMENTS; i += 2) painter->fillRect(QRectF(i * _width, br.height() + PADDING, _width, SCALE_HEIGHT), Qt::black); + /* painter->setPen(Qt::red); painter->drawRect(boundingRect()); */ + if (aa) painter->setRenderHint(QPainter::Antialiasing, true); }