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

Drawing performance improvement

This commit is contained in:
Martin Tůma 2016-09-11 17:15:23 +02:00
parent eeed5ceba3
commit ebf3c3bc14
6 changed files with 10 additions and 4 deletions

View File

@ -34,6 +34,8 @@ AxisItem::AxisItem(Type type, QGraphicsItem *parent) : QGraphicsItem(parent)
{ {
_type = type; _type = type;
_size = 0; _size = 0;
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
} }
void AxisItem::setRange(const RangeF &range) void AxisItem::setRange(const RangeF &range)

View File

@ -53,6 +53,7 @@ RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
setToolTip(toolTip()); setToolTip(toolTip());
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
updateShape(); updateShape();

View File

@ -17,6 +17,8 @@ ScaleItem::ScaleItem(QGraphicsItem *parent) : QGraphicsItem(parent)
_units = Metric; _units = Metric;
_zoom = ZOOM_MIN; _zoom = ZOOM_MIN;
_lat = 0; _lat = 0;
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
} }
void ScaleItem::updateBoundingRect() void ScaleItem::updateBoundingRect()
@ -112,9 +114,10 @@ void ScaleItem::computeScale()
} }
} }
void ScaleItem::setLatitude(qreal lat) void ScaleItem::setZoom(int z, qreal lat)
{ {
prepareGeometryChange(); prepareGeometryChange();
_zoom = z;
_lat = lat; _lat = lat;
computeScale(); computeScale();
updateBoundingRect(); updateBoundingRect();

View File

@ -13,8 +13,8 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget); QWidget *widget);
void setLatitude(qreal lat);
void setZoom(int z); void setZoom(int z);
void setZoom(int z, qreal lat);
void setUnits(enum Units units); void setUnits(enum Units units);
private: private:

View File

@ -53,6 +53,7 @@ TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
setToolTip(toolTip()); setToolTip(toolTip());
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
updateShape(); updateShape();

View File

@ -136,8 +136,7 @@ void TrackView::loadGPX(const GPX &gpx)
_scene->setSceneRect(ba); _scene->setSceneRect(ba);
centerOn(ba.center()); centerOn(ba.center());
_mapScale->setLatitude(-(br.center().ry() * _scale)); _mapScale->setZoom(_zoom, -(br.center().ry() * _scale));
_mapScale->setZoom(_zoom);
if (_mapScale->scene() != _scene) if (_mapScale->scene() != _scene)
_scene->addItem(_mapScale); _scene->addItem(_mapScale);
} }