diff --git a/src/GUI/mapview.cpp b/src/GUI/mapview.cpp index 1afa5057..72ccaab1 100644 --- a/src/GUI/mapview.cpp +++ b/src/GUI/mapview.cpp @@ -497,7 +497,7 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale, QRect orig, adj; qreal ratio, diff, q; QPointF origScene, origPos; - RectC origC; + int zoom; // Enter plot mode @@ -521,8 +521,8 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale, // Adjust the view for printing if (hires) { + zoom = _map->zoom(); QRectF vr(mapToScene(orig).boundingRect()); - origC = RectC(_map->xy2ll(vr.topLeft()), _map->xy2ll(vr.bottomRight())); origScene = vr.center(); QPointF s(painter->device()->logicalDpiX() @@ -553,11 +553,11 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale, // Revert view changes to display mode if (hires) { - _map->zoomFit(orig.size(), origC); + _map->setZoom(zoom); rescale(); centerOn(origScene); } - _mapScale->setDigitalZoom(0); + _mapScale->setDigitalZoom(_digitalZoom); _mapScale->setPos(origPos); // Exit plot mode diff --git a/src/map/atlas.cpp b/src/map/atlas.cpp index 067cebc7..2140935d 100644 --- a/src/map/atlas.cpp +++ b/src/map/atlas.cpp @@ -208,6 +208,12 @@ int Atlas::zoomFit(const QSize &size, const RectC &br) return _zoom; } +void Atlas::setZoom(int zoom) +{ + _mapIndex = -1; + _zoom = zoom; +} + int Atlas::zoomIn() { _zoom = qMin(_zoom + 1, _zooms.size() - 1); diff --git a/src/map/atlas.h b/src/map/atlas.h index 06338dfa..4654475a 100644 --- a/src/map/atlas.h +++ b/src/map/atlas.h @@ -18,6 +18,7 @@ public: qreal resolution(const QRectF &rect) const; int zoom() const {return _zoom;} + void setZoom(int zoom); int zoomFit(const QSize &size, const RectC &br); int zoomIn(); int zoomOut(); diff --git a/src/map/emptymap.h b/src/map/emptymap.h index 09af50ea..850e490f 100644 --- a/src/map/emptymap.h +++ b/src/map/emptymap.h @@ -16,6 +16,7 @@ public: qreal resolution(const QRectF &rect) const; int zoom() const {return _zoom;} + void setZoom(int zoom) {_zoom = zoom;} int zoomFit(const QSize &size, const RectC &rect); int zoomIn(); int zoomOut(); diff --git a/src/map/map.h b/src/map/map.h index 9641db22..679af429 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -24,6 +24,7 @@ public: virtual qreal resolution(const QRectF &rect) const = 0; virtual int zoom() const = 0; + virtual void setZoom(int zoom) = 0; virtual int zoomFit(const QSize &size, const RectC &rect) = 0; virtual int zoomIn() = 0; virtual int zoomOut() = 0; diff --git a/src/map/offlinemap.h b/src/map/offlinemap.h index 31d9f44f..51fb3de2 100644 --- a/src/map/offlinemap.h +++ b/src/map/offlinemap.h @@ -24,6 +24,7 @@ public: qreal resolution(const QRectF &rect) const; int zoom() const {return _zoom;} + void setZoom(int zoom) {_zoom = zoom;} int zoomFit(const QSize &size, const RectC &rect); int zoomIn(); int zoomOut(); diff --git a/src/map/onlinemap.h b/src/map/onlinemap.h index 1225960d..2205a661 100644 --- a/src/map/onlinemap.h +++ b/src/map/onlinemap.h @@ -21,6 +21,7 @@ public: qreal resolution(const QRectF &rect) const; int zoom() const {return _zoom;} + void setZoom(int zoom) {_zoom = zoom;} int zoomFit(const QSize &size, const RectC &rect); int zoomIn(); int zoomOut(); diff --git a/src/map/wmsmap.cpp b/src/map/wmsmap.cpp index 207a900a..8bc81290 100644 --- a/src/map/wmsmap.cpp +++ b/src/map/wmsmap.cpp @@ -163,6 +163,12 @@ int WMSMap::zoomFit(const QSize &size, const RectC &rect) return _zoom; } +void WMSMap::setZoom(int zoom) +{ + _zoom = zoom; + updateTransform(); +} + int WMSMap::zoomIn() { _zoom = qMin(_zoom + 1, _zooms.size() - 1); diff --git a/src/map/wmsmap.h b/src/map/wmsmap.h index ee2d998e..7fe59e1d 100644 --- a/src/map/wmsmap.h +++ b/src/map/wmsmap.h @@ -21,6 +21,7 @@ public: qreal resolution(const QRectF &rect) const; int zoom() const {return _zoom;} + void setZoom(int zoom); int zoomFit(const QSize &size, const RectC &rect); int zoomIn(); int zoomOut(); diff --git a/src/map/wmtsmap.cpp b/src/map/wmtsmap.cpp index 2866866e..0f453384 100644 --- a/src/map/wmtsmap.cpp +++ b/src/map/wmtsmap.cpp @@ -143,6 +143,12 @@ qreal WMTSMap::resolution(const QRectF &rect) const return ds/ps; } +void WMTSMap::setZoom(int zoom) +{ + _zoom = zoom; + updateTransform(); +} + int WMTSMap::zoomIn() { _zoom = qMin(_zoom + 1, _zooms.size() - 1); diff --git a/src/map/wmtsmap.h b/src/map/wmtsmap.h index bd2be4cf..6701e3e8 100644 --- a/src/map/wmtsmap.h +++ b/src/map/wmtsmap.h @@ -21,6 +21,7 @@ public: qreal resolution(const QRectF &rect) const; int zoom() const {return _zoom;} + void setZoom(int zoom); int zoomFit(const QSize &size, const RectC &rect); int zoomIn(); int zoomOut();