Skip to content

Commit

Permalink
Add rendering extent information to expression context
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jan 13, 2016
1 parent 9551ca7 commit e7b9a31
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/qgsexpressioncontext.cpp
Expand Up @@ -702,6 +702,11 @@ QgsExpressionContextScope* QgsExpressionContextUtils::mapSettingsScope( const Qg
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_id", "canvas", true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_rotation", mapSettings.rotation(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_scale", mapSettings.scale(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_extent_width", mapSettings.extent().width() ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_extent_height", mapSettings.extent().height() ) );
QgsGeometry* centerPoint = QgsGeometry::fromPoint( mapSettings.visibleExtent().center() );
scope->addVariable( QgsExpressionContextScope::StaticVariable( "map_extent_center", QVariant::fromValue( *centerPoint ), true ) );

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Jan 13, 2016

Collaborator

@m-kuhn what about exposing the visible extent as a geometry? That would allow us of predicates (eg feature completely within extent). Could potentially also be useful...

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Jan 14, 2016

Author Member

No objections

delete centerPoint;

return scope;
}
Expand Down

0 comments on commit e7b9a31

Please sign in to comment.