1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-27 11:39:16 +02:00

Propper handling of vector tiles scaling in all map display modes

This commit is contained in:
2018-11-17 10:10:35 +01:00
parent 4c88414677
commit 3c6ce2dde2
22 changed files with 153 additions and 107 deletions

View File

@ -924,8 +924,8 @@ void GUI::openOptions()
#endif // ENABLE_HTTP2
#ifdef ENABLE_HIDPI
if (options.hidpiMap != _options.hidpiMap)
_mapView->setDevicePixelRatio(options.hidpiMap ? devicePixelRatioF()
: 1.0);
_mapView->setDevicePixelRatio(devicePixelRatioF(),
options.hidpiMap ? devicePixelRatioF() : 1.0);
#endif // ENABLE_HIDPI
if (reload)
@ -2047,7 +2047,8 @@ void GUI::readSettings()
if (_options.useOpenGL)
_mapView->useOpenGL(true);
#ifdef ENABLE_HIDPI
_mapView->setDevicePixelRatio(_options.hidpiMap ? devicePixelRatioF() : 1.0);
_mapView->setDevicePixelRatio(devicePixelRatioF(),
_options.hidpiMap ? devicePixelRatioF() : 1.0);
#endif // ENABLE_HIDPI
for (int i = 0; i < _tabs.count(); i++) {
@ -2130,7 +2131,8 @@ void GUI::show()
void GUI::screenChanged(QScreen *screen)
{
#ifdef ENABLE_HIDPI
_mapView->setDevicePixelRatio(_options.hidpiMap ? devicePixelRatioF() : 1.0);
_mapView->setDevicePixelRatio(devicePixelRatioF(),
_options.hidpiMap ? devicePixelRatioF() : 1.0);
disconnect(SIGNAL(logicalDotsPerInchChanged(qreal)), this,
SLOT(logicalDotsPerInchChanged(qreal)));
@ -2146,6 +2148,7 @@ void GUI::logicalDotsPerInchChanged(qreal dpi)
Q_UNUSED(dpi)
#ifdef ENABLE_HIDPI
_mapView->setDevicePixelRatio(_options.hidpiMap ? devicePixelRatioF() : 1.0);
_mapView->setDevicePixelRatio(devicePixelRatioF(),
_options.hidpiMap ? devicePixelRatioF() : 1.0);
#endif // ENBLE_HIDPI
}

View File

@ -73,7 +73,8 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
_poiColor = Qt::black;
#ifdef ENABLE_HIDPI
_ratio = 1.0;
_deviceRatio = 1.0;
_mapRatio = 1.0;
#endif // ENABLE_HIDPI
_opengl = false;
_plot = false;
@ -271,7 +272,7 @@ void MapView::setMap(Map *map)
_map = map;
_map->load();
#ifdef ENABLE_HIDPI
_map->setDevicePixelRatio(_ratio);
_map->setDevicePixelRatio(_deviceRatio, _mapRatio);
#endif // ENABLE_HIDPI
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
@ -506,7 +507,7 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
setUpdatesEnabled(false);
_plot = true;
#ifdef ENABLE_HIDPI
_map->setDevicePixelRatio(1.0);
_map->setDevicePixelRatio(_deviceRatio, 1.0);
#endif // ENABLE_HIDPI
// Compute sizes & ratios
@ -567,7 +568,7 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
// Exit plot mode
#ifdef ENABLE_HIDPI
_map->setDevicePixelRatio(_ratio);
_map->setDevicePixelRatio(_deviceRatio, _mapRatio);
#endif // ENABLE_HIDPI
_plot = false;
setUpdatesEnabled(true);
@ -845,19 +846,21 @@ void MapView::reloadMap()
_scene->invalidate();
}
void MapView::setDevicePixelRatio(qreal ratio)
void MapView::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
{
#ifdef ENABLE_HIDPI
if (_ratio == ratio)
if (_deviceRatio == deviceRatio && _mapRatio == mapRatio)
return;
_ratio = ratio;
_deviceRatio = deviceRatio;
_mapRatio = mapRatio;
QPixmapCache::clear();
QRectF vr(mapToScene(viewport()->rect()).boundingRect()
.intersected(_map->bounds()));
RectC cr(_map->xy2ll(vr.topLeft()), _map->xy2ll(vr.bottomRight()));
_map->setDevicePixelRatio(_ratio);
_map->setDevicePixelRatio(_deviceRatio, _mapRatio);
_scene->setSceneRect(_map->bounds());
for (int i = 0; i < _tracks.size(); i++)

View File

@ -69,7 +69,7 @@ public slots:
void showRouteWaypoints(bool show);
void clearMapCache();
void setCoordinatesFormat(CoordinatesFormat format);
void setDevicePixelRatio(qreal ratio);
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
private slots:
void updatePOI();
@ -140,7 +140,8 @@ private:
bool _plot;
#ifdef ENABLE_HIDPI
qreal _ratio;
qreal _deviceRatio;
qreal _mapRatio;
#endif // ENABLE_HIDPI
bool _opengl;
};