Skip to content
Permalink
Browse files

Add transform context to processing context

  • Loading branch information
nyalldawson committed Dec 20, 2017
1 parent 90e5196 commit b24a1bf10d547eeece5349b2a04b76cd995bcc1d
Showing with 47 additions and 1 deletion.
  1. +20 −0 python/core/processing/qgsprocessingcontext.sip
  2. +27 −1 src/core/processing/qgsprocessingcontext.h
@@ -70,6 +70,9 @@ Returns the project in which the algorithm is being executed.
%Docstring
Sets the ``project`` in which the algorithm will be executed.

This also automatically sets the transformContext() to match
the project's transform context.

.. seealso:: :py:func:`project()`
%End

@@ -82,6 +85,23 @@ Returns the expression context.
void setExpressionContext( const QgsExpressionContext &context );
%Docstring
Sets the expression ``context``.
%End

QgsCoordinateTransformContext transformContext() const;
%Docstring
Returns the coordinate transform context.

.. seealso:: :py:func:`setTransformContext()`
%End

void setTransformContext( const QgsCoordinateTransformContext &context );
%Docstring
Sets the coordinate transform ``context``.

Note that setting a project for the context will automatically set the coordinate transform
context.

.. seealso:: :py:func:`transformContext()`
%End

QgsMapLayerStore *temporaryLayerStore();
@@ -102,9 +102,18 @@ class CORE_EXPORT QgsProcessingContext

/**
* Sets the \a project in which the algorithm will be executed.
*
* This also automatically sets the transformContext() to match
* the project's transform context.
*
* \see project()
*/
void setProject( QgsProject *project ) { mProject = project; }
void setProject( QgsProject *project )
{
mProject = project;
if ( mProject )
mTransformContext = mProject->transformContext();
}

/**
* Returns the expression context.
@@ -121,6 +130,22 @@ class CORE_EXPORT QgsProcessingContext
*/
void setExpressionContext( const QgsExpressionContext &context ) { mExpressionContext = context; }

/**
* Returns the coordinate transform context.
* \see setTransformContext()
*/
QgsCoordinateTransformContext transformContext() const { return mTransformContext; }

/**
* Sets the coordinate transform \a context.
*
* Note that setting a project for the context will automatically set the coordinate transform
* context.
*
* \see transformContext()
*/
void setTransformContext( const QgsCoordinateTransformContext &context ) { mTransformContext = context; }

/**
* Returns a reference to the layer store used for storing temporary layers during
* algorithm execution.
@@ -375,6 +400,7 @@ class CORE_EXPORT QgsProcessingContext

QgsProcessingContext::Flags mFlags = nullptr;
QPointer< QgsProject > mProject;
QgsCoordinateTransformContext mTransformContext;
//! Temporary project owned by the context, used for storing temporarily loaded map layers
QgsMapLayerStore tempLayerStore;
QgsExpressionContext mExpressionContext;

0 comments on commit b24a1bf

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