From f252a965e91c7165d7269802f0f0cdbed1f2a7ab Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Sat, 14 Jun 2014 21:36:20 +1000 Subject: [PATCH] [composer] Scale changes while in atlas fixed scale mode are permanently applied (fix #9602) --- src/core/composer/qgscomposermap.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/core/composer/qgscomposermap.cpp b/src/core/composer/qgscomposermap.cpp index a7bfee14e7e..9cc3df2963a 100644 --- a/src/core/composer/qgscomposermap.cpp +++ b/src/core/composer/qgscomposermap.cpp @@ -655,6 +655,18 @@ void QgsComposerMap::zoomContent( int delta, double x, double y ) currentMapExtent()->setYMaximum( centerY + newIntervalY / 2 ); currentMapExtent()->setYMinimum( centerY - newIntervalY / 2 ); + if ( mAtlasDriven && mAtlasScalingMode == Fixed && mComposition->atlasMode() != QgsComposition::AtlasOff ) + { + //if map is atlas controlled and set to fixed scaling mode, then scale changes should be treated as permanant + //and also apply to the map's original extent (see #9602) + //we can't use the scaleRatio calculated earlier, as the scale can vary depending on extent for geographic coordinate systems + QgsScaleCalculator calculator; + calculator.setMapUnits( mComposition->mapSettings().mapUnits() ); + calculator.setDpi( 25.4 ); //QGraphicsView units are mm + double scaleRatio = scale() / calculator.calculate( mExtent, rect().width() ); + mExtent.scale( scaleRatio ); + } + cache(); update(); emit itemChanged(); @@ -789,6 +801,19 @@ void QgsComposerMap::setNewScale( double scaleDenominator ) double scaleRatio = scaleDenominator / currentScaleDenominator; currentMapExtent()->scale( scaleRatio ); + + if ( mAtlasDriven && mAtlasScalingMode == Fixed && mComposition->atlasMode() != QgsComposition::AtlasOff ) + { + //if map is atlas controlled and set to fixed scaling mode, then scale changes should be treated as permanant + //and also apply to the map's original extent (see #9602) + //we can't use the scaleRatio calculated earlier, as the scale can vary depending on extent for geographic coordinate systems + QgsScaleCalculator calculator; + calculator.setMapUnits( mComposition->mapSettings().mapUnits() ); + calculator.setDpi( 25.4 ); //QGraphicsView units are mm + scaleRatio = scaleDenominator / calculator.calculate( mExtent, rect().width() ); + mExtent.scale( scaleRatio ); + } + mCacheUpdated = false; cache(); update();