Skip to content

Commit

Permalink
Fix setting atlas variables in main map canvas for previewing atlas
Browse files Browse the repository at this point in the history
renders
  • Loading branch information
nyalldawson committed Sep 7, 2015
1 parent 2fe6d8c commit a45ead1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,14 @@ void QgsComposer::atlasFeatureChanged( QgsFeature *feature )
mAtlasPageComboBox->setEditText( QString::number( mComposition->atlasComposition().currentFeatureNumber() + 1 ) );
}
mAtlasPageComboBox->blockSignals( false );

//update expression context variables in map canvas to allow for previewing atlas feature based renderering
mapCanvas()->expressionContextScope().addVariable( QgsExpressionContextScope::StaticVariable( "atlas_featurenumber", mComposition->atlasComposition().currentFeatureNumber() + 1, true ) );
mapCanvas()->expressionContextScope().addVariable( QgsExpressionContextScope::StaticVariable( "atlas_pagename", mComposition->atlasComposition().currentPageName(), true ) );
QgsFeature atlasFeature = mComposition->atlasComposition().feature();
mapCanvas()->expressionContextScope().addVariable( QgsExpressionContextScope::StaticVariable( "atlas_feature", QVariant::fromValue( atlasFeature ), true ) );
mapCanvas()->expressionContextScope().addVariable( QgsExpressionContextScope::StaticVariable( "atlas_featureid", atlasFeature.id(), true ) );
mapCanvas()->expressionContextScope().addVariable( QgsExpressionContextScope::StaticVariable( "atlas_geometry", QVariant::fromValue( *atlasFeature.constGeometry() ), true ) );
}

void QgsComposer::on_mActionAtlasPreview_triggered( bool checked )
Expand Down

0 comments on commit a45ead1

Please sign in to comment.