Skip to content

Commit f252a96

Browse files
committed
[composer] Scale changes while in atlas fixed scale mode are permanently applied (fix #9602)
1 parent 5678bed commit f252a96

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/core/composer/qgscomposermap.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,18 @@ void QgsComposerMap::zoomContent( int delta, double x, double y )
655655
currentMapExtent()->setYMaximum( centerY + newIntervalY / 2 );
656656
currentMapExtent()->setYMinimum( centerY - newIntervalY / 2 );
657657

658+
if ( mAtlasDriven && mAtlasScalingMode == Fixed && mComposition->atlasMode() != QgsComposition::AtlasOff )
659+
{
660+
//if map is atlas controlled and set to fixed scaling mode, then scale changes should be treated as permanant
661+
//and also apply to the map's original extent (see #9602)
662+
//we can't use the scaleRatio calculated earlier, as the scale can vary depending on extent for geographic coordinate systems
663+
QgsScaleCalculator calculator;
664+
calculator.setMapUnits( mComposition->mapSettings().mapUnits() );
665+
calculator.setDpi( 25.4 ); //QGraphicsView units are mm
666+
double scaleRatio = scale() / calculator.calculate( mExtent, rect().width() );
667+
mExtent.scale( scaleRatio );
668+
}
669+
658670
cache();
659671
update();
660672
emit itemChanged();
@@ -789,6 +801,19 @@ void QgsComposerMap::setNewScale( double scaleDenominator )
789801

790802
double scaleRatio = scaleDenominator / currentScaleDenominator;
791803
currentMapExtent()->scale( scaleRatio );
804+
805+
if ( mAtlasDriven && mAtlasScalingMode == Fixed && mComposition->atlasMode() != QgsComposition::AtlasOff )
806+
{
807+
//if map is atlas controlled and set to fixed scaling mode, then scale changes should be treated as permanant
808+
//and also apply to the map's original extent (see #9602)
809+
//we can't use the scaleRatio calculated earlier, as the scale can vary depending on extent for geographic coordinate systems
810+
QgsScaleCalculator calculator;
811+
calculator.setMapUnits( mComposition->mapSettings().mapUnits() );
812+
calculator.setDpi( 25.4 ); //QGraphicsView units are mm
813+
scaleRatio = scaleDenominator / calculator.calculate( mExtent, rect().width() );
814+
mExtent.scale( scaleRatio );
815+
}
816+
792817
mCacheUpdated = false;
793818
cache();
794819
update();

0 commit comments

Comments
 (0)