Skip to content
Permalink
Browse files
Fix missing map settings expression variables in composer maps
Missing map extent related variables were causing stacking order
issues with the 25d renderer (fix #14604)
  • Loading branch information
nyalldawson committed Apr 15, 2016
1 parent 6880b53 commit 7967e961059ac19f1b031fdaa8d4821c1dfa5fc2
Showing with 11 additions and 0 deletions.
  1. +8 −0 src/core/composer/qgscomposermap.cpp
  2. +3 −0 src/core/qgsexpressioncontext.cpp
@@ -2151,6 +2151,14 @@ QgsExpressionContext* QgsComposerMap::createExpressionContext() const
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_id", QgsComposerItem::id(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_rotation", mMapRotation, true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_scale", scale(), true ) );

QgsRectangle extent( *currentMapExtent() );
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_extent_width", extent.width(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_extent_height", extent.height(), true ) );
QgsGeometry* centerPoint = QgsGeometry::fromPoint( extent.center() );
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_extent_center", QVariant::fromValue( *centerPoint ), true ) );
delete centerPoint;

context->appendScope( scope );

return context;
@@ -713,6 +713,9 @@ void QgsExpressionContextUtils::setLayerVariables( QgsMapLayer* layer, const Qgs

QgsExpressionContextScope* QgsExpressionContextUtils::mapSettingsScope( const QgsMapSettings& mapSettings )
{
// IMPORTANT: ANY CHANGES HERE ALSO NEED TO BE MADE TO QgsComposerMap::createExpressionContext()
// (rationale is described in QgsComposerMap::createExpressionContext() )

QgsExpressionContextScope* scope = new QgsExpressionContextScope( QObject::tr( "Map Settings" ) );

//add known map settings context variables

0 comments on commit 7967e96

Please sign in to comment.