1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-18 03:42:09 +01:00

Fixed rendering issues

This commit is contained in:
Martin Tůma 2016-09-12 23:53:14 +02:00
parent a5f11cb77b
commit 420e96a2f4
2 changed files with 11 additions and 6 deletions

View File

@ -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);
}
}

View File

@ -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);
}