Skip to content
Permalink
Browse files

[composer] Make sure scalebars are updated during atlas previews

  • Loading branch information
nyalldawson committed Jan 1, 2014
1 parent 8c64fbc commit eb241a68c3c1789d21fad3ae36b778a2a52f5219
@@ -635,6 +635,15 @@ void QgsComposerMap::setNewAtlasFeatureExtent( const QgsRectangle& extent )
emit extentChanged();
}

void QgsComposerMap::toggleAtlasPreview()
{
//atlas preview has been toggled, so update item and extents
mCacheUpdated = false;
updateItem();
emit itemChanged();
emit extentChanged();
}

QgsRectangle* QgsComposerMap::currentMapExtent()
{
//non-const version
@@ -156,6 +156,9 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
*/
void setNewAtlasFeatureExtent( const QgsRectangle& extent );

/**Called when atlas preview is toggled, to force map item to update its extent and redraw*/
void toggleAtlasPreview();

/**Returns a pointer to the current map extent, which is either the original user specified
extent or the temporary atlas-driven feature extent depending on the current atlas state of the composition.
Both a const and non-const version are included.*/
@@ -164,7 +164,7 @@ void QgsComposerScaleBar::refreshSegmentMillimeters()
if ( mComposerMap )
{
//get extent of composer map
QgsRectangle composerMapRect = mComposerMap->extent();
QgsRectangle composerMapRect = *( mComposerMap->currentMapExtent() );

//get mm dimension of composer map
QRectF composerItemRect = mComposerMap->rect();
@@ -181,7 +181,7 @@ double QgsComposerScaleBar::mapWidth() const
return 0.0;
}

QgsRectangle composerMapRect = mComposerMap->extent();
QgsRectangle composerMapRect = *( mComposerMap->currentMapExtent() );
if ( mUnits == MapUnits )
{
return composerMapRect.width();
@@ -2345,6 +2345,11 @@ bool QgsComposition::setAtlasPreviewEnabled( bool e )
}
}

if ( mAtlasComposition.composerMap() )
{
mAtlasComposition.composerMap()->toggleAtlasPreview();
}

update();
return true;
}

0 comments on commit eb241a6

Please sign in to comment.
You can’t perform that action at this time.