Skip to content
Permalink
Browse files

Add rendering extent information to expression context

  • Loading branch information
m-kuhn committed Jan 13, 2016
1 parent 9551ca7 commit e7b9a314f789aba7443cc371f5093986ddd04a8d
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/core/qgsexpressioncontext.cpp
@@ -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;
}

0 comments on commit e7b9a31

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