mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-31 00:03:42 -04:00
Since the underlying issues with the Python bindings are now fixed, in most cases we can safely default to allowing an algorithm to run in a background thread!! So now we make this the default, and require individual algorithms which are NOT thread safe to declare this. This includes algorithms which directly manipulate the current project or layers (such as setting layer styles), alter the selections in layers, or which rely on 3rd party libraries (for now, SAGA and GRASS algorithms are marked as not thread safe... TODO - someone more familiar with these libraries can investigate and remove the flag if appropriate). Also models are marked as non-thread safe. TODO: only flag an individual model as thread-unsafe if any of its child algorithms report this flag.
412 lines
13 KiB
Plaintext
412 lines
13 KiB
Plaintext
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/core/processing/models/qgsprocessingmodelalgorithm.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
class QgsProcessingModelAlgorithm : QgsProcessingAlgorithm
|
|
{
|
|
%Docstring
|
|
Model based algorithm with processing.
|
|
|
|
.. versionadded:: 3.0
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsprocessingmodelalgorithm.h"
|
|
%End
|
|
public:
|
|
|
|
QgsProcessingModelAlgorithm( const QString &name = QString(), const QString &group = QString(), const QString &groupId = QString() );
|
|
%Docstring
|
|
Constructor for QgsProcessingModelAlgorithm.
|
|
%End
|
|
|
|
virtual void initAlgorithm( const QVariantMap &configuration = QVariantMap() ); //#spellok
|
|
|
|
|
|
virtual QString name() const;
|
|
|
|
virtual QString displayName() const;
|
|
|
|
virtual QString group() const;
|
|
|
|
virtual QString groupId() const;
|
|
|
|
virtual QIcon icon() const;
|
|
|
|
virtual QString svgIconPath() const;
|
|
|
|
virtual QString shortHelpString() const;
|
|
|
|
virtual QString helpUrl() const;
|
|
|
|
virtual Flags flags() const;
|
|
|
|
|
|
virtual bool canExecute( QString *errorMessage /Out/ = 0 ) const;
|
|
|
|
virtual QString asPythonCommand( const QVariantMap ¶meters, QgsProcessingContext &context ) const;
|
|
|
|
|
|
void setName( const QString &name );
|
|
%Docstring
|
|
Sets the model ``name``.
|
|
|
|
.. seealso:: :py:func:`name`
|
|
%End
|
|
|
|
void setGroup( const QString &group );
|
|
%Docstring
|
|
Sets the model ``group``.
|
|
|
|
.. seealso:: :py:func:`group`
|
|
%End
|
|
|
|
QMap<QString, QgsProcessingModelChildAlgorithm> childAlgorithms() const;
|
|
%Docstring
|
|
Returns the map of child algorithms contained in the model. The keys
|
|
are the child algorithm ids (see QgsProcessingModelAlgorithm.ChildAlgorithm.childId()).
|
|
|
|
.. seealso:: :py:func:`childAlgorithm`
|
|
|
|
.. seealso:: :py:func:`setChildAlgorithms`
|
|
|
|
.. seealso:: :py:func:`addChildAlgorithm`
|
|
%End
|
|
|
|
void setChildAlgorithms( const QMap<QString, QgsProcessingModelChildAlgorithm> &childAlgorithms );
|
|
%Docstring
|
|
Sets the map of child algorithms contained in the model. The keys
|
|
are the child algorithm ids (see QgsProcessingModelAlgorithm.ChildAlgorithm.childId()).
|
|
All existing child algorithms will be replaced.
|
|
|
|
.. seealso:: :py:func:`childAlgorithms`
|
|
|
|
.. seealso:: :py:func:`childAlgorithm`
|
|
|
|
.. seealso:: :py:func:`setChildAlgorithm`
|
|
|
|
.. seealso:: :py:func:`addChildAlgorithm`
|
|
%End
|
|
|
|
void setChildAlgorithm( const QgsProcessingModelChildAlgorithm &algorithm );
|
|
%Docstring
|
|
Sets the child ``algorithm`` within the model. If a child algorithm already
|
|
exists in the model with the same child ID then that algorithm will be replaced.
|
|
|
|
.. seealso:: :py:func:`addChildAlgorithm`
|
|
|
|
.. seealso:: :py:func:`setChildAlgorithms`
|
|
%End
|
|
|
|
QString addChildAlgorithm( QgsProcessingModelChildAlgorithm &algorithm );
|
|
%Docstring
|
|
Adds a new child ``algorithm`` to the model. If a child algorithm already exists
|
|
in the model with the same child ID then ``algorithm`` will be assigned a new
|
|
autogenerated unique ID.
|
|
The assigned child ID will be returned.
|
|
|
|
.. seealso:: :py:func:`childAlgorithms`
|
|
|
|
.. seealso:: :py:func:`childAlgorithm`
|
|
|
|
.. seealso:: :py:func:`setChildAlgorithm`
|
|
|
|
.. seealso:: :py:func:`setChildAlgorithms`
|
|
%End
|
|
|
|
QgsProcessingModelChildAlgorithm &childAlgorithm( const QString &id );
|
|
%Docstring
|
|
Returns the child algorithm with matching ``id``. If no child algorithm exists with
|
|
this ID a new algorithm will be added to the model and returned.
|
|
|
|
.. seealso:: :py:func:`addChildAlgorithm`
|
|
|
|
.. seealso:: :py:func:`childAlgorithms`
|
|
%End
|
|
|
|
bool removeChildAlgorithm( const QString &id );
|
|
%Docstring
|
|
Attempts to remove the child algorithm with matching ``id``.
|
|
Returns true if the algorithm could be removed, or false
|
|
if the algorithm could not be removed (e.g. due to other
|
|
child algorithms depending on it).
|
|
|
|
.. seealso:: :py:func:`deactivateChildAlgorithm`
|
|
%End
|
|
|
|
void deactivateChildAlgorithm( const QString &id );
|
|
%Docstring
|
|
Deactivates the child algorithm with matching ``id``.
|
|
All other child algorithms which depend on the child
|
|
algorithm will also be deactivated.
|
|
|
|
.. seealso:: :py:func:`removeChildAlgorithm`
|
|
|
|
.. seealso:: :py:func:`activateChildAlgorithm`
|
|
%End
|
|
|
|
bool activateChildAlgorithm( const QString &id );
|
|
%Docstring
|
|
Attempts to activate the child algorithm with matching ``id``.
|
|
If any child algorithms on which the child depends are not active,
|
|
then the child will not be activated and false will be returned.
|
|
|
|
.. seealso:: :py:func:`deactivateChildAlgorithm`
|
|
%End
|
|
|
|
QSet< QString > dependentChildAlgorithms( const QString &childId ) const;
|
|
%Docstring
|
|
Returns a list of the child algorithm IDs depending on the child
|
|
algorithm with the specified ``childId``.
|
|
|
|
.. seealso:: :py:func:`dependsOnChildAlgorithms`
|
|
%End
|
|
|
|
QSet< QString > dependsOnChildAlgorithms( const QString &childId ) const;
|
|
%Docstring
|
|
Returns a list of the child algorithm IDs on which the child
|
|
algorithm with the specified ``childId`` depends upon.
|
|
|
|
.. seealso:: :py:func:`dependentChildAlgorithms`
|
|
%End
|
|
|
|
void addModelParameter( QgsProcessingParameterDefinition *definition /Transfer/, const QgsProcessingModelParameter &component );
|
|
%Docstring
|
|
Adds a new parameter to the model, with the specified ``definition`` and graphical ``component``.
|
|
Ownership of ``definition`` is transferred to the model.
|
|
|
|
.. seealso:: :py:func:`updateModelParameter`
|
|
|
|
.. seealso:: :py:func:`removeModelParameter`
|
|
%End
|
|
|
|
void updateModelParameter( QgsProcessingParameterDefinition *definition /Transfer/ );
|
|
%Docstring
|
|
Replaces the definition of an existing parameter (by parameter name) with a new ``definition``. Ownership of
|
|
``definition`` is transferred to the model, and any existing parameter is deleted.
|
|
|
|
.. seealso:: :py:func:`addModelParameter`
|
|
|
|
.. seealso:: :py:func:`removeModelParameter`
|
|
%End
|
|
|
|
void removeModelParameter( const QString &name );
|
|
%Docstring
|
|
Removes an existing model parameter by ``name``. The definition of the matching parameter
|
|
is deleted.
|
|
|
|
.. seealso:: :py:func:`addModelParameter`
|
|
|
|
.. seealso:: :py:func:`updateModelParameter`
|
|
%End
|
|
|
|
bool childAlgorithmsDependOnParameter( const QString &name ) const;
|
|
%Docstring
|
|
Returns true if any child algorithms depend on the model parameter
|
|
with the specified ``name``.
|
|
|
|
.. seealso:: :py:func:`otherParametersDependOnParameter`
|
|
%End
|
|
|
|
bool otherParametersDependOnParameter( const QString &name ) const;
|
|
%Docstring
|
|
Returns true if any other model parameters depend on the parameter
|
|
with the specified ``name`` (e.g. field parameters where ``name``
|
|
is the parent layer parameter).
|
|
|
|
.. seealso:: :py:func:`childAlgorithmsDependOnParameter`
|
|
%End
|
|
|
|
QMap<QString, QgsProcessingModelParameter> parameterComponents() const;
|
|
%Docstring
|
|
Returns the map of parameter components used by the model. The keys
|
|
should match the algorithm's parameter names (see parameterDefinitions() ).
|
|
|
|
.. seealso:: :py:func:`setParameterComponent`
|
|
|
|
.. seealso:: :py:func:`parameterComponent`
|
|
%End
|
|
|
|
void setParameterComponents( const QMap<QString, QgsProcessingModelParameter> ¶meterComponents );
|
|
%Docstring
|
|
Sets the map of parameter components used by the model. The keys
|
|
should match the algorithm's parameter names (see parameterDefinitions() ).
|
|
All existing parameter components will be replaced.
|
|
|
|
.. seealso:: :py:func:`parameterComponents`
|
|
|
|
.. seealso:: :py:func:`setParameterComponent`
|
|
|
|
.. seealso:: :py:func:`parameterComponent`
|
|
%End
|
|
|
|
void setParameterComponent( const QgsProcessingModelParameter &component );
|
|
%Docstring
|
|
Sets a parameter ``component`` for the model. If a parameter component already
|
|
exists in the model with the same parameter name then that component will be replaced.
|
|
|
|
.. seealso:: :py:func:`parameterComponents`
|
|
|
|
.. seealso:: :py:func:`setParameterComponents`
|
|
|
|
.. seealso:: :py:func:`parameterComponent`
|
|
%End
|
|
|
|
QgsProcessingModelParameter ¶meterComponent( const QString &name );
|
|
%Docstring
|
|
Returns the parameter component with matching ``name``. If no parameter component exists with
|
|
this name a new component will be added to the model and returned.
|
|
|
|
.. seealso:: :py:func:`parameterComponents`
|
|
|
|
.. seealso:: :py:func:`setParameterComponents`
|
|
|
|
.. seealso:: :py:func:`setParameterComponent`
|
|
%End
|
|
|
|
void updateDestinationParameters();
|
|
%Docstring
|
|
Updates the model's parameter definitions to include all relevant destination
|
|
parameters as required by child algorithm ModelOutputs.
|
|
Must be called whenever child algorithm ModelOutputs are altered.
|
|
%End
|
|
|
|
bool toFile( const QString &path ) const;
|
|
%Docstring
|
|
Writes the model to a file, at the specified ``path``.
|
|
|
|
.. seealso:: :py:func:`fromFile`
|
|
%End
|
|
|
|
bool fromFile( const QString &path );
|
|
%Docstring
|
|
Reads the model from a file, at the specified ``path``.
|
|
|
|
.. seealso:: :py:func:`toFile`
|
|
%End
|
|
|
|
QVariantMap &helpContent();
|
|
%Docstring
|
|
Returns the model's help contents (a free-form map of values describing the algorithm's
|
|
use and metadata).
|
|
|
|
.. seealso:: :py:func:`setHelpContent`
|
|
%End
|
|
|
|
|
|
void setHelpContent( const QVariantMap &contents );
|
|
%Docstring
|
|
Sets the model's help ``contents`` (a free-form map of values describing the algorithm's
|
|
use and metadata).
|
|
|
|
.. seealso:: :py:func:`helpContent`
|
|
%End
|
|
|
|
QString sourceFilePath() const;
|
|
%Docstring
|
|
Returns the source file path for the model, if available.
|
|
|
|
.. seealso:: :py:func:`setSourceFilePath`
|
|
%End
|
|
|
|
void setSourceFilePath( const QString &path );
|
|
%Docstring
|
|
Sets the source file ``path`` for the model, if available.
|
|
|
|
.. seealso:: :py:func:`sourceFilePath`
|
|
%End
|
|
|
|
QString asPythonCode() const;
|
|
%Docstring
|
|
Attempts to convert the model to executable Python code.
|
|
%End
|
|
|
|
QList< QgsProcessingModelChildParameterSource > availableSourcesForChild( const QString &childId, const QStringList ¶meterTypes = QStringList(),
|
|
const QStringList &outputTypes = QStringList(), const QList< int > &dataTypes = QList< int >() ) const;
|
|
%Docstring
|
|
Returns a list of possible sources which can be used for the parameters for a child
|
|
algorithm in the model. Returned sources are those which match either one of the
|
|
specified ``parameterTypes`` (see QgsProcessingParameterDefinition.type() ) or
|
|
on of the specified ``outputTypes`` (see QgsProcessingOutputDefinition.type() ).
|
|
If specified, an optional list of ``dataTypes`` can be used to filter the returned
|
|
sources to those with compatible data types for the parameter/outputs.
|
|
%End
|
|
|
|
class VariableDefinition
|
|
{
|
|
%Docstring
|
|
Definition of a expression context variable available during model execution.
|
|
|
|
.. versionadded:: 3.0
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsprocessingmodelalgorithm.h"
|
|
%End
|
|
public:
|
|
|
|
VariableDefinition( const QVariant &value = QVariant(), const QgsProcessingModelChildParameterSource &source = QgsProcessingModelChildParameterSource::fromStaticValue( QVariant() ), const QString &description = QString() );
|
|
%Docstring
|
|
Constructor for a new VariableDefinition with the specified ``value`` and original
|
|
parameter ``source``, and ``description``.
|
|
%End
|
|
|
|
QVariant value;
|
|
|
|
QgsProcessingModelChildParameterSource source;
|
|
|
|
QString description;
|
|
};
|
|
|
|
QMap< QString, QgsProcessingModelAlgorithm::VariableDefinition > variablesForChildAlgorithm( const QString &childId, QgsProcessingContext &context, const QVariantMap &modelParameters = QVariantMap(),
|
|
const QVariantMap &results = QVariantMap() ) const;
|
|
%Docstring
|
|
Returns a map of variable name to variable definition for expression context variables which are available
|
|
for use by child algorithm during model execution.
|
|
|
|
The child algorithm ``childId`` and processing ``context``
|
|
are manadatory. If ``modelParameters`` and ``results`` are not specified, then only the variable names and sources
|
|
will be returned, but all variable values will be null. This can be used to determine in advance which variables
|
|
will be available for a specific child algorithm, e.g. for use in expression builder widgets.
|
|
|
|
In order to calculate the actual variable value, the input model ``modelParameters`` and already executed child
|
|
algorithm ``results`` must be passed.
|
|
|
|
.. seealso:: :py:func:`createExpressionContextScopeForChildAlgorithm`
|
|
%End
|
|
|
|
QgsExpressionContextScope *createExpressionContextScopeForChildAlgorithm( const QString &childId, QgsProcessingContext &context, const QVariantMap &modelParameters = QVariantMap(),
|
|
const QVariantMap &results = QVariantMap() ) const /Factory/;
|
|
%Docstring
|
|
Creates a new expression context scope for a child algorithm within the model.
|
|
|
|
.. seealso:: :py:func:`variablesForChildAlgorithm`
|
|
%End
|
|
|
|
protected:
|
|
|
|
virtual QgsProcessingAlgorithm *createInstance() const /Factory/;
|
|
|
|
|
|
virtual QVariantMap processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback );
|
|
|
|
|
|
};
|
|
|
|
|
|
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/core/processing/models/qgsprocessingmodelalgorithm.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
************************************************************************/
|