Skip to content
Permalink
Browse files

[composer] Remove a bunch of duplicate render calls to map items duri…

…ng atlas previews
  • Loading branch information
nyalldawson committed Oct 6, 2014
1 parent 8a0e1ef commit 6d850ad51a41dbb27a226610b4234b4d99b76e4e
@@ -970,6 +970,11 @@ void QgsComposer::on_mActionAtlasPreview_triggered( bool checked )
mActionAtlasNext->setEnabled( checked );
mActionAtlasPrev->setEnabled( checked );

if ( checked )
{
loadAtlasPredefinedScalesFromProject();
}

bool previewEnabled = mComposition->setAtlasMode( checked ? QgsComposition::PreviewAtlas : QgsComposition::AtlasOff );
if ( !previewEnabled )
{
@@ -991,8 +996,6 @@ void QgsComposer::on_mActionAtlasPreview_triggered( bool checked )

if ( checked )
{
loadAtlasPredefinedScalesFromProject();
atlasMap->firstFeature();
emit( atlasPreviewFeatureChanged() );
}
else
@@ -351,13 +351,19 @@ void QgsComposerMapWidget::updateMapForAtlas()
return;
}

//update atlas based extent for map
QgsAtlasComposition* atlas = &composition->atlasComposition();
atlas->prepareMap( mComposerMap );

//redraw map
mComposerMap->cache();
mComposerMap->update();
if ( mComposerMap->atlasDriven() )
{
//update atlas based extent for map
QgsAtlasComposition* atlas = &composition->atlasComposition();
//prepareMap causes a redraw
atlas->prepareMap( mComposerMap );
}
else
{
//redraw map
mComposerMap->cache();
mComposerMap->update();
}
}

void QgsComposerMapWidget::on_mAtlasMarginRadio_toggled( bool checked )
@@ -1032,6 +1032,11 @@ void QgsComposerItem::refreshRotation( const bool updateItem , const bool adjust
}
}

if ( rotation == mEvaluatedItemRotation )
{
return;
}

if ( adjustPosition )
{
//adjustPosition set, so shift the position of the item so that rotation occurs around item center
@@ -1297,8 +1302,12 @@ void QgsComposerItem::refreshDataDefinedProperty( const QgsComposerObject::DataD
property == QgsComposerObject::ItemWidth || property == QgsComposerObject::ItemHeight ||
property == QgsComposerObject::AllProperties )
{
QRectF evaluatedRect = evalItemRect( QRectF( pos().x(), pos().y(), rect().width(), rect().height() ) );
setSceneRect( evaluatedRect );
QRectF beforeRect = QRectF( pos().x(), pos().y(), rect().width(), rect().height() );
QRectF evaluatedRect = evalItemRect( beforeRect );
if ( evaluatedRect != beforeRect )
{
setSceneRect( evaluatedRect );
}
}
if ( property == QgsComposerObject::ItemRotation || property == QgsComposerObject::AllProperties )
{
@@ -817,15 +817,6 @@ 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
@@ -1093,7 +1084,7 @@ void QgsComposerMap::updateItem()
return;
}

if ( mPreviewMode != QgsComposerMap::Rectangle && !mCacheUpdated )
if ( mPreviewMode != QgsComposerMap::Rectangle && !mCacheUpdated )
{
cache();
}
@@ -2033,13 +2024,17 @@ void QgsComposerMap::refreshDataDefinedProperty( const QgsComposerObject::DataDe
property == QgsComposerObject::MapAtlasMargin ||
property == QgsComposerObject::AllProperties )
{
QgsRectangle beforeExtent = *currentMapExtent();
refreshMapExtents();
emit itemChanged();
emit extentChanged();
if ( *currentMapExtent() != beforeExtent )
{
emit extentChanged();
}
}

//force redraw
cache();
mCacheUpdated = false;

QgsComposerItem::refreshDataDefinedProperty( property );
}
@@ -217,8 +217,10 @@ 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();
/**Called when atlas preview is toggled, to force map item to update its extent and redraw
* @deprecated no longer required
*/
Q_DECL_DEPRECATED 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
@@ -225,6 +225,15 @@ void QgsComposition::updateBounds()
void QgsComposition::refreshItems()
{
emit refreshItemsTriggered();
//force a redraw on all maps
QList<QgsComposerMap*> maps;
composerItems( maps );
QList<QgsComposerMap*>::iterator mapIt = maps.begin();
for ( ; mapIt != maps.end(); ++mapIt )
{
( *mapIt )->cache();
( *mapIt )->update();
}
}

void QgsComposition::setSelectedItem( QgsComposerItem *item )
@@ -295,6 +304,11 @@ QRectF QgsComposition::compositionBounds() const

void QgsComposition::setPaperSize( const double width, const double height )
{
if ( width == mPageWidth && height == mPageHeight )
{
return;
}

//update item positions
QList<QGraphicsItem *> itemList = items();
QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
@@ -2825,18 +2839,6 @@ bool QgsComposition::setAtlasMode( const AtlasMode mode )
}
}

QList<QgsComposerMap*> maps;
composerItems( maps );
for ( QList<QgsComposerMap*>::iterator mit = maps.begin(); mit != maps.end(); ++mit )
{
QgsComposerMap* currentMap = ( *mit );
if ( !currentMap->atlasDriven() )
{
continue;
}
currentMap->toggleAtlasPreview();
}

update();
return true;
}

0 comments on commit 6d850ad

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