Skip to content

Commit e7b9a31

Browse files
committed
Add rendering extent information to expression context
1 parent 9551ca7 commit e7b9a31

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/core/qgsexpressioncontext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,11 @@ QgsExpressionContextScope* QgsExpressionContextUtils::mapSettingsScope( const Qg
702702
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_id", "canvas", true ) );
703703
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_rotation", mapSettings.rotation(), true ) );
704704
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_scale", mapSettings.scale(), true ) );
705+
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_extent_width", mapSettings.extent().width() ) );
706+
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_extent_height", mapSettings.extent().height() ) );
707+
QgsGeometry* centerPoint = QgsGeometry::fromPoint( mapSettings.visibleExtent().center() );
708+
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_extent_center", QVariant::fromValue( *centerPoint ), true ) );
709+
delete centerPoint;
705710

706711
return scope;
707712
}

0 commit comments

Comments
 (0)