From 7f8006f93bf924588ebbb3def0c8609f066bc2fe Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Thu, 11 Dec 2014 14:16:57 +0100 Subject: [PATCH] [Fix #11841] Revert "Fix calculation of atlas map extent when set to fixed scale mode" This reverts commit b106f8225324237175aac741ede9eb5d3268edcd and fixes the setting of the atlas feature in composer. According to Nyall original commit b106f8225324237175aac741ede9eb5d3268edcd was introduced to fix a test. He will look to fix the test, but in the mean time we rather need working features rather than passing tests. One might wants to disable the test? --- src/core/composer/qgsatlascomposition.cpp | 27 +++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/core/composer/qgsatlascomposition.cpp b/src/core/composer/qgsatlascomposition.cpp index 864dc8a6e93d..7e812e39efca 100644 --- a/src/core/composer/qgsatlascomposition.cpp +++ b/src/core/composer/qgsatlascomposition.cpp @@ -514,8 +514,7 @@ void QgsAtlasComposition::prepareMap( QgsComposerMap* map ) double ya1 = mTransformedFeatureBounds.yMinimum(); double ya2 = mTransformedFeatureBounds.yMaximum(); QgsRectangle newExtent = mTransformedFeatureBounds; - QgsRectangle originalExtent( map->extent() ); - QgsRectangle currentExtent( *map->currentMapExtent() ); + QgsRectangle mOrigExtent( map->extent() ); //sanity check - only allow fixed scale mode for point layers bool isPointLayer = false; @@ -537,19 +536,19 @@ void QgsAtlasComposition::prepareMap( QgsComposerMap* map ) QgsScaleCalculator calc; calc.setMapUnits( composition()->mapSettings().mapUnits() ); calc.setDpi( 25.4 ); - double originalScale = calc.calculate( currentExtent, map->rect().width() ); + double originalScale = calc.calculate( mOrigExtent, map->rect().width() ); double geomCenterX = ( xa1 + xa2 ) / 2.0; double geomCenterY = ( ya1 + ya2 ) / 2.0; if ( map->atlasScalingMode() == QgsComposerMap::Fixed || isPointLayer ) { // only translate, keep the original scale (i.e. width x height) - double xMin = geomCenterX - currentExtent.width() / 2.0; - double yMin = geomCenterY - currentExtent.height() / 2.0; + double xMin = geomCenterX - mOrigExtent.width() / 2.0; + double yMin = geomCenterY - mOrigExtent.height() / 2.0; newExtent = QgsRectangle( xMin, yMin, - xMin + currentExtent.width(), - yMin + currentExtent.height() ); + xMin + mOrigExtent.width(), + yMin + mOrigExtent.height() ); //scale newExtent to match original scale of map //this is required for geographic coordinate systems, where the scale varies by extent @@ -559,14 +558,14 @@ void QgsAtlasComposition::prepareMap( QgsComposerMap* map ) else if ( map->atlasScalingMode() == QgsComposerMap::Predefined ) { // choose one of the predefined scales - double newWidth = currentExtent.width(); - double newHeight = currentExtent.height(); + double newWidth = mOrigExtent.width(); + double newHeight = mOrigExtent.height(); const QVector& scales = mPredefinedScales; for ( int i = 0; i < scales.size(); i++ ) { double ratio = scales[i] / originalScale; - newWidth = currentExtent.width() * ratio; - newHeight = currentExtent.height() * ratio; + newWidth = mOrigExtent.width() * ratio; + newHeight = mOrigExtent.height() * ratio; // compute new extent, centered on feature double xMin = geomCenterX - newWidth / 2.0; @@ -594,12 +593,12 @@ void QgsAtlasComposition::prepareMap( QgsComposerMap* map ) // auto scale double geomRatio = mTransformedFeatureBounds.width() / mTransformedFeatureBounds.height(); - double mapRatio = originalExtent.width() / originalExtent.height(); + double mapRatio = mOrigExtent.width() / mOrigExtent.height(); // geometry height is too big if ( geomRatio < mapRatio ) { - //extend the bbox's width + // extent the bbox's width double adjWidth = ( mapRatio * mTransformedFeatureBounds.height() - mTransformedFeatureBounds.width() ) / 2.0; xa1 -= adjWidth; xa2 += adjWidth; @@ -607,7 +606,7 @@ void QgsAtlasComposition::prepareMap( QgsComposerMap* map ) // geometry width is too big else if ( geomRatio > mapRatio ) { - //extend the bbox's height + // extent the bbox's height double adjHeight = ( mTransformedFeatureBounds.width() / mapRatio - mTransformedFeatureBounds.height() ) / 2.0; ya1 -= adjHeight; ya2 += adjHeight;