Skip to content

Commit

Permalink
Merge pull request #4682 from nyalldawson/processing_pt3
Browse files Browse the repository at this point in the history
Processing rebuilding...
  • Loading branch information
nyalldawson committed Jun 6, 2017
2 parents 2b0af00 + 1d2e54d commit 72f95e6
Show file tree
Hide file tree
Showing 181 changed files with 1,546 additions and 628 deletions.
29 changes: 29 additions & 0 deletions python/core/processing/qgsprocessingalgorithm.sip
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class QgsProcessingAlgorithm
FlagHideFromToolbox,
FlagHideFromModeler,
FlagSupportsBatch,
FlagCanCancel,
FlagDeprecated,
};
typedef QFlags<QgsProcessingAlgorithm::Flag> Flags;
Expand Down Expand Up @@ -128,6 +129,7 @@ class QgsProcessingAlgorithm
virtual Flags flags() const;
%Docstring
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
Default flags are FlagSupportsBatch and FlagCanCancel.
:rtype: Flags
%End

Expand Down Expand Up @@ -205,6 +207,12 @@ class QgsProcessingAlgorithm
:rtype: QgsProcessingOutputDefinition
%End

bool hasHtmlOutputs() const;
%Docstring
Returns true if this algorithm generates HTML outputs.
:rtype: bool
%End

QVariantMap run( const QVariantMap &parameters,
QgsProcessingContext &context, QgsProcessingFeedback *feedback ) const;
%Docstring
Expand All @@ -228,6 +236,15 @@ class QgsProcessingAlgorithm
:rtype: QWidget
%End

QgsExpressionContext createExpressionContext( const QVariantMap &parameters,
QgsProcessingContext &context ) const;
%Docstring
Creates an expression context relating to the algorithm. This can be called by algorithms
to create a new expression context ready for evaluating expressions within the algorithm.
:rtype: QgsExpressionContext
%End


protected:

bool addParameter( QgsProcessingParameterDefinition *parameterDefinition /Transfer/ );
Expand Down Expand Up @@ -357,6 +374,18 @@ class QgsProcessingAlgorithm
:rtype: QgsRasterLayer
%End

QString parameterAsRasterOutputLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a raster output layer destination.
:rtype: str
%End

QString parameterAsFileOutput( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a file based output destination.
:rtype: str
%End

QgsVectorLayer *parameterAsVectorLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a vector layer.
Expand Down
43 changes: 43 additions & 0 deletions python/core/processing/qgsprocessingoutputs.sip
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class QgsProcessingOutputDefinition
%ConvertToSubClassCode
if ( sipCpp->type() == "outputVector" )
sipType = sipType_QgsProcessingOutputVectorLayer;
else if ( sipCpp->type() == "outputRaster" )
sipType = sipType_QgsProcessingOutputRasterLayer;
else if ( sipCpp->type() == "outputHtml" )
sipType = sipType_QgsProcessingOutputHtml;
%End
public:

Expand Down Expand Up @@ -118,6 +122,45 @@ class QgsProcessingOutputVectorLayer : QgsProcessingOutputDefinition

};

class QgsProcessingOutputRasterLayer : QgsProcessingOutputDefinition
{
%Docstring
A raster layer output for processing algorithms.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsprocessingoutputs.h"
%End
public:

QgsProcessingOutputRasterLayer( const QString &name, const QString &description = QString() );
%Docstring
Constructor for QgsProcessingOutputRasterLayer.
%End

virtual QString type() const;
};

class QgsProcessingOutputHtml : QgsProcessingOutputDefinition
{
%Docstring
A HTML file output for processing algorithms.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsprocessingoutputs.h"
%End
public:

QgsProcessingOutputHtml( const QString &name, const QString &description = QString() );
%Docstring
Constructor for QgsProcessingOutputHtml.
%End

virtual QString type() const;
};



Expand Down
110 changes: 99 additions & 11 deletions python/core/processing/qgsprocessingparameters.sip
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ Allows direct construction of QVariants.



class QgsProcessingFeatureSinkDefinition
class QgsProcessingOutputLayerDefinition
{
%Docstring

Encapsulates settings relating to a feature sink input to a processing algorithm.
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm.

.. versionadded:: 3.0
%End
Expand All @@ -70,35 +70,35 @@ class QgsProcessingFeatureSinkDefinition
%End
public:

QgsProcessingFeatureSinkDefinition( const QString &sink = QString(), QgsProject *destinationProject = 0 );
QgsProcessingOutputLayerDefinition( const QString &sink = QString(), QgsProject *destinationProject = 0 );
%Docstring
Constructor for QgsProcessingFeatureSinkDefinition, accepting a static string sink.
Constructor for QgsProcessingOutputLayerDefinition, accepting a static sink/layer string.
The ``destinationProject`` parameter can be set to a QgsProject instance in which
to automatically load the resulting sink after completing processing.
to automatically load the resulting sink/layer after completing processing.
%End

QgsProcessingFeatureSinkDefinition( const QgsProperty &sink, QgsProject *destinationProject = 0 );
QgsProcessingOutputLayerDefinition( const QgsProperty &sink, QgsProject *destinationProject = 0 );
%Docstring
Constructor for QgsProcessingFeatureSinkDefinition, accepting a QgsProperty sink.
Constructor for QgsProcessingOutputLayerDefinition, accepting a QgsProperty sink/layer.
The ``destinationProject`` parameter can be set to a QgsProject instance in which
to automatically load the resulting sink after completing processing.
to automatically load the resulting sink/layer after completing processing.
%End

QgsProperty sink;
%Docstring
Sink definition. Usually a static property set to the destination file name for the sink's layer.
Sink/layer definition. Usually a static property set to the destination file name for the sink's layer.
%End

QgsProject *destinationProject;
%Docstring
Destination project. Can be set to a QgsProject instance in which
to automatically load the resulting sink after completing processing.
to automatically load the resulting sink/layer after completing processing.
The default behavior is not to load the result into any project (None).
%End

QVariantMap createOptions;
%Docstring
Map of optional sink creation options, which
Map of optional sink/layer creation options, which
are passed to the underlying provider when creating new layers. Known options also
include 'fileEncoding', which is used to specify a file encoding to use for created
files.
Expand Down Expand Up @@ -171,6 +171,10 @@ class QgsProcessingParameterDefinition
sipType = sipType_QgsProcessingParameterFeatureSource;
else if ( sipCpp->type() == "sink" )
sipType = sipType_QgsProcessingParameterFeatureSink;
else if ( sipCpp->type() == "rasterOut" )
sipType = sipType_QgsProcessingParameterRasterOutput;
else if ( sipCpp->type() == "fileOut" )
sipType = sipType_QgsProcessingParameterFileOutput;
%End
public:

Expand Down Expand Up @@ -419,6 +423,18 @@ class QgsProcessingParameters
:rtype: QgsRasterLayer
%End

static QString parameterAsRasterOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
%Docstring
Evaluates the parameter with matching ``definition`` to a raster output layer destination.
:rtype: str
%End

static QString parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
%Docstring
Evaluates the parameter with matching ``definition`` to a file based output destination.
:rtype: str
%End

static QgsVectorLayer *parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
%Docstring
Evaluates the parameter with matching ``definition`` to a vector layer.
Expand Down Expand Up @@ -1206,6 +1222,13 @@ class QgsProcessingParameterFeatureSink : QgsProcessingParameterDefinition
:rtype: QgsProcessingParameterDefinition.LayerType
%End

bool hasGeometry() const;
%Docstring
Returns true if sink is likely to include geometries. In cases were presence of geometry
cannot be reliably determined in advance, this method will default to returning true.
:rtype: bool
%End

void setDataType( QgsProcessingParameterDefinition::LayerType type );
%Docstring
Sets the layer ``type`` for the sinks associated with the parameter.
Expand All @@ -1214,6 +1237,71 @@ class QgsProcessingParameterFeatureSink : QgsProcessingParameterDefinition

};

class QgsProcessingParameterRasterOutput : QgsProcessingParameterDefinition
{
%Docstring
A raster layer output parameter.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsprocessingparameters.h"
%End
public:

QgsProcessingParameterRasterOutput( const QString &name, const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
bool optional = false );
%Docstring
Constructor for QgsProcessingParameterRasterOutput.
%End

virtual QString type() const;
virtual bool isDestination() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;

};

class QgsProcessingParameterFileOutput : QgsProcessingParameterDefinition
{
%Docstring
A generic file based output parameter.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsprocessingparameters.h"
%End
public:

QgsProcessingParameterFileOutput( const QString &name, const QString &description = QString(),
const QString &fileFilter = QString(),
const QVariant &defaultValue = QVariant(),
bool optional = false );
%Docstring
Constructor for QgsProcessingParameterFileOutput.
%End

virtual QString type() const;
virtual bool isDestination() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;


QString fileFilter() const;
%Docstring
Returns the file filter string for files compatible with this output.
.. seealso:: setFileFilter()
:rtype: str
%End

void setFileFilter( const QString &filter );
%Docstring
Sets the file ``filter`` string for files compatible with this output.
.. seealso:: fileFilter()
%End

};



/************************************************************************
Expand Down
8 changes: 8 additions & 0 deletions python/core/qgsexpressioncontext.sip
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,14 @@ class QgsExpressionContextUtils
:rtype: QgsExpressionContext
%End

static QgsExpressionContextScope *processingAlgorithmScope( const QgsProcessingAlgorithm *algorithm, const QVariantMap &parameters, QgsProcessingContext &context ) /Factory/;
%Docstring
Creates a new scope which contains variables and functions relating to a processing ``algorithm``,
when used with the specified ``parameters`` and ``context``.
For instance, algorithm name and parameter functions.
:rtype: QgsExpressionContextScope
%End

static void registerContextFunctions();
%Docstring
Registers all known core functions provided by QgsExpressionContextScope objects.
Expand Down
Loading

0 comments on commit 72f95e6

Please sign in to comment.