Skip to content

Commit

Permalink
refs #6956
Browse files Browse the repository at this point in the history
Fix map frame resizing : do not touch the frame size, adapt the geometry's extent if needed
  • Loading branch information
Hugo Mercier committed Jan 14, 2013
1 parent 831f99a commit ca77a98
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/core/composer/qgsatlascomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,21 @@ void QgsAtlasComposition::prepareForFeature( size_t featureI )
// geometry height is too big
if ( geom_ratio < map_ratio )
{
new_extent = QgsRectangle(( xa1 + xa2 + map_ratio * ( ya1 - ya2 ) ) / 2.0,
ya1,
xa1 + map_ratio * ( ya2 - ya1 ),
ya2 );
// extent the bbox's width
double adj_width = ( map_ratio * geom_rect.height() - geom_rect.width() ) / 2.0;
xa1 -= adj_width;
xa2 += adj_width;
}
// geometry width is too big
else if ( geom_ratio > map_ratio )
{
new_extent = QgsRectangle( xa1,
( ya1 + ya2 + ( xa1 - xa2 ) / map_ratio ) / 2.0,
xa2,
ya1 + ( xa2 - xa1 ) / map_ratio );
// extent the bbox's height
double adj_height = (geom_rect.width() / map_ratio - geom_rect.height() ) / 2.0;
ya1 -= adj_height;
ya2 += adj_height;
}
new_extent = QgsRectangle( xa1, ya1, xa2, ya2 );

if ( mMargin > 0.0 )
{
new_extent.scale( 1 + mMargin );
Expand Down

0 comments on commit ca77a98

Please sign in to comment.