1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Fixed broken map plotting on systems with HiDpi displays

This commit is contained in:
Martin Tůma 2022-05-25 23:03:30 +02:00
parent b98143ef8c
commit c3ba8f1f0d

View File

@ -726,7 +726,7 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
PlotFlags flags) PlotFlags flags)
{ {
QRect orig, adj; QRect orig, adj;
qreal ratio, diff, q, p; qreal mapRatio, ratio, diff, q, p;
QPointF scenePos, scalePos, posPos, motionPos; QPointF scenePos, scalePos, posPos, motionPos;
int zoom; int zoom;
@ -734,7 +734,6 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
// Enter plot mode // Enter plot mode
setUpdatesEnabled(false); setUpdatesEnabled(false);
_plot = true; _plot = true;
_map->setDevicePixelRatio(_deviceRatio, 1.0);
// Compute sizes & ratios // Compute sizes & ratios
orig = viewport()->rect(); orig = viewport()->rect();
@ -753,6 +752,9 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
} }
// Expand the view if plotting into a bitmap // Expand the view if plotting into a bitmap
mapRatio = _mapRatio;
setDevicePixelRatio(_deviceRatio, 1.0);
if (flags & Expand) { if (flags & Expand) {
qreal xdiff = (target.width() - adj.width()) / 2.0; qreal xdiff = (target.width() - adj.width()) / 2.0;
qreal ydiff = (target.height() - adj.height()) / 2.0; qreal ydiff = (target.height() - adj.height()) / 2.0;
@ -805,6 +807,9 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
rescale(); rescale();
centerOn(scenePos); centerOn(scenePos);
} }
setDevicePixelRatio(_deviceRatio, mapRatio);
_mapScale->setDigitalZoom(_digitalZoom); _mapScale->setDigitalZoom(_digitalZoom);
_mapScale->setPos(scalePos); _mapScale->setPos(scalePos);
_positionCoordinates->setDigitalZoom(_digitalZoom); _positionCoordinates->setDigitalZoom(_digitalZoom);
@ -813,7 +818,6 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
_motionInfo->setPos(motionPos); _motionInfo->setPos(motionPos);
// Exit plot mode // Exit plot mode
_map->setDevicePixelRatio(_deviceRatio, _mapRatio);
_plot = false; _plot = false;
setUpdatesEnabled(true); setUpdatesEnabled(true);
} }