From 473b92e8f7d2b41a8c1e3233f8796cf32670950c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 25 Sep 2016 18:44:33 +0200 Subject: [PATCH] Fixed route marker display issues. Code cleanup. --- src/axisitem.cpp | 2 +- src/routeitem.cpp | 13 +++++-------- src/trackitem.cpp | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/axisitem.cpp b/src/axisitem.cpp index 1fdf5585..939c99d0 100644 --- a/src/axisitem.cpp +++ b/src/axisitem.cpp @@ -83,7 +83,7 @@ void AxisItem::updateBoundingRect() if (_type == X) { _boundingRect = QRectF(-ss.width()/2, -TICK/2, _size + es.width()/2 + ss.width()/2, - ls.height() + es.height() - fm.descent() + TICK + 2*PADDING); + ls.height() + es.height() - fm.descent() + TICK + 2*PADDING + 1); } else { int mtw = 0; QRect ts; diff --git a/src/routeitem.cpp b/src/routeitem.cpp index d516d461..66e6f0da 100644 --- a/src/routeitem.cpp +++ b/src/routeitem.cpp @@ -41,15 +41,15 @@ RouteItem::RouteItem(const Route &route, QGraphicsItem *parent) QVector r = route.route(); Q_ASSERT(r.count() >= 2); - wi = new WaypointItem(r.at(0)); - wi->setParentItem(this); + wi = new WaypointItem(r.at(0), this); + wi->setFlag(QGraphicsItem::ItemIgnoresTransformations, true); const QPointF &p = r.at(0).coordinates(); _path.moveTo(ll2mercator(QPointF(p.x(), -p.y()))); for (int i = 1; i < r.size(); i++) { const QPointF &p = r.at(i).coordinates(); _path.lineTo(ll2mercator(QPointF(p.x(), -p.y()))); - wi = new WaypointItem(r.at(i)); - wi->setParentItem(this); + wi = new WaypointItem(r.at(i), this); + wi->setFlag(QGraphicsItem::ItemIgnoresTransformations, true); } _units = Metric; @@ -66,6 +66,7 @@ RouteItem::RouteItem(const Route &route, QGraphicsItem *parent) _marker = new MarkerItem(this); _marker->setPos(_path.pointAtPercent(0)); + _marker->setFlag(QGraphicsItem::ItemIgnoresTransformations, true); } void RouteItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, @@ -91,10 +92,6 @@ void RouteItem::setScale(qreal scale) _pen.setWidthF(ROUTE_WIDTH * 1.0/scale); QGraphicsItem::setScale(scale); - QList childs = childItems(); - for (int i = 0; i < childs.count(); i++) - childs.at(i)->setScale(1.0/scale); - updateShape(); } diff --git a/src/trackitem.cpp b/src/trackitem.cpp index 9d095d17..06b1bb2e 100644 --- a/src/trackitem.cpp +++ b/src/trackitem.cpp @@ -66,6 +66,7 @@ TrackItem::TrackItem(const Track &track, QGraphicsItem *parent) _marker = new MarkerItem(this); _marker->setPos(_path.pointAtPercent(0)); + _marker->setFlag(QGraphicsItem::ItemIgnoresTransformations, true); } void TrackItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, @@ -90,7 +91,6 @@ void TrackItem::setScale(qreal scale) _pen.setWidthF(TRACK_WIDTH * 1.0/scale); QGraphicsItem::setScale(scale); - _marker->setScale(1.0/scale); updateShape(); }