18#ifndef QGSPROCESSINGMODELALGORITHM_H
19#define QGSPROCESSINGMODELALGORITHM_H
46 QgsProcessingModelAlgorithm(
const QString &name = QString(),
const QString &group = QString(),
const QString &groupId = QString() );
48 void initAlgorithm(
const QVariantMap &configuration = QVariantMap() )
override;
51 QString
name()
const override;
53 QString
group()
const override;
54 QString
groupId()
const override;
55 QIcon
icon()
const override;
59 QString
helpUrl()
const override;
69 void setName(
const QString &name );
75 void setGroup(
const QString &group );
84 bool validate( QStringList &issues
SIP_OUT )
const;
93 QMap<QString, QgsProcessingModelChildAlgorithm> childAlgorithms()
const;
104 void setChildAlgorithms(
const QMap<QString, QgsProcessingModelChildAlgorithm> &childAlgorithms );
112 void setChildAlgorithm(
const QgsProcessingModelChildAlgorithm &
algorithm );
124 QString addChildAlgorithm( QgsProcessingModelChildAlgorithm &
algorithm );
132 QgsProcessingModelChildAlgorithm &childAlgorithm(
const QString &
id );
141 bool removeChildAlgorithm(
const QString &
id );
150 void deactivateChildAlgorithm(
const QString &
id );
158 bool activateChildAlgorithm(
const QString &
id );
170 QSet< QString > dependentChildAlgorithms(
const QString &childId,
const QString &conditionalBranch = QString() )
const;
177 QSet< QString > dependsOnChildAlgorithms(
const QString &childId )
const;
184 QList< QgsProcessingModelChildDependency > availableDependenciesForChildAlgorithm(
const QString &childId )
const;
195 bool validateChildAlgorithm(
const QString &childId, QStringList &issues
SIP_OUT )
const;
219 void removeModelParameter(
const QString &name );
228 void changeParameterName(
const QString &oldName,
const QString &newName );
235 bool childAlgorithmsDependOnParameter(
const QString &name )
const;
243 bool otherParametersDependOnParameter(
const QString &name )
const;
251 QMap<QString, QgsProcessingModelParameter> parameterComponents()
const;
261 void setParameterComponents(
const QMap<QString, QgsProcessingModelParameter> ¶meterComponents );
270 void setParameterComponent(
const QgsProcessingModelParameter &component );
279 QgsProcessingModelParameter ¶meterComponent(
const QString &name );
287 QList< QgsProcessingModelParameter > orderedParameters()
const;
298 void setParameterOrder(
const QStringList &order );
306 QList< QgsProcessingModelOutput > orderedOutputs()
const;
317 void setOutputOrder(
const QStringList &order );
325 QString outputGroup()
const;
333 void setOutputGroup(
const QString &group );
340 void updateDestinationParameters();
350 void addGroupBox(
const QgsProcessingModelGroupBox &groupBox );
358 QList< QgsProcessingModelGroupBox > groupBoxes()
const;
367 void removeGroupBox(
const QString &uuid );
373 bool toFile(
const QString &path )
const;
379 bool fromFile(
const QString &path );
388 QVariant toVariant()
const;
397 bool loadVariant(
const QVariant &variant );
404 QVariantMap &helpContent() {
return mHelpContent; }
411 SIP_SKIP QVariantMap helpContent()
const;
418 void setHelpContent(
const QVariantMap &contents );
424 QString sourceFilePath()
const;
430 void setSourceFilePath(
const QString &path );
440 bool modelNameMatchesFilePath()
const;
459 QList< QgsProcessingModelChildParameterSource > availableSourcesForChild(
const QString &childId,
const QStringList ¶meterTypes = QStringList(),
460 const QStringList &outputTypes = QStringList(),
const QList< int > &dataTypes = QList< int >() )
const;
466 class CORE_EXPORT VariableDefinition
474 VariableDefinition(
const QVariant &value = QVariant(),
const QgsProcessingModelChildParameterSource &source = QgsProcessingModelChildParameterSource::fromStaticValue( QVariant() ),
const QString &description = QString() )
477 , description( description )
484 QgsProcessingModelChildParameterSource source;
503 QMap< QString, QgsProcessingModelAlgorithm::VariableDefinition > variablesForChildAlgorithm(
const QString &childId,
QgsProcessingContext *context =
nullptr,
const QVariantMap &modelParameters = QVariantMap(),
504 const QVariantMap &results = QVariantMap() )
const;
511 const QVariantMap &results = QVariantMap() ) const
SIP_FACTORY;
522 QVariantMap variables() const;
533 void setVariables( const QVariantMap &variables );
546 QVariantMap designerParameterValues() const;
559 void setDesignerParameterValues( const QVariantMap &values ) { mDesignerParameterValues = values; }
575 static QString safeName(
const QString &name,
bool capitalize =
false );
580 enum class InternalVersion
585 Q_ENUM( InternalVersion )
597 InternalVersion mInternalVersion = InternalVersion::Version2;
601 QString mModelGroupId;
603 QMap< QString, QgsProcessingModelChildAlgorithm > mChildAlgorithms;
606 QMap< QString, QgsProcessingModelParameter > mParameterComponents;
608 QVariantMap mHelpContent;
613 QVariantMap mResults;
615 QVariantMap mVariables;
617 QVariantMap mDesignerParameterValues;
619 QMap< QString, QgsProcessingModelGroupBox > mGroupBoxes;
621 QStringList mParameterOrder;
622 QStringList mOutputOrder;
623 QString mOutputGroup;
625 void dependsOnChildAlgorithmsRecursive( const QString &childId, QSet<QString> &depends ) const;
626 void dependentChildAlgorithmsRecursive( const QString &childId, QSet<QString> &depends, const QString &branch ) const;
628 QVariantMap parametersForChildAlgorithm( const QgsProcessingModelChildAlgorithm &child, const QVariantMap &modelParameters, const QVariantMap &results, const
QgsExpressionContext &expressionContext, QString &error, const
QgsProcessingContext *context =
nullptr ) const;
634 bool childOutputIsRequired( const QString &childId, const QString &outputName ) const;
645 static
bool vectorOutputIsCompatibleType( const QList<
int> &acceptableDataTypes,
Qgis::ProcessingSourceType outputType );
650 void reattachAlgorithms() const;
652 friend class TestQgsProcessingModelAlgorithm;
The Qgis class provides global constants for use throughout the application.
QFlags< ProcessingAlgorithmFlag > ProcessingAlgorithmFlags
Flags indicating how and when an algorithm operates and should be exposed to users.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Abstract base class for processing algorithms.
virtual QgsProcessingAlgorithm * createInstance() const =0
Creates a new instance of the algorithm class.
virtual QString group() const
Returns the name of the group this algorithm belongs to.
virtual QString groupId() const
Returns the unique ID of the group this algorithm belongs to.
virtual QString helpUrl() const
Returns a url pointing to the algorithm's help page.
virtual QIcon icon() const
Returns an icon for the algorithm.
virtual QString shortHelpString() const
Returns a localised short helper string for the algorithm.
virtual Qgis::ProcessingAlgorithmFlags flags() const
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
virtual QString shortDescription() const
Returns an optional translated short description of the algorithm.
friend class QgsProcessingModelAlgorithm
virtual QString displayName() const =0
Returns the translated algorithm name, which should be used for any user-visible display of the algor...
virtual QgsExpressionContext createExpressionContext(const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeatureSource *source=nullptr) const
Creates an expression context relating to the algorithm.
virtual QString svgIconPath() const
Returns a path to an SVG version of the algorithm's icon.
virtual void initAlgorithm(const QVariantMap &configuration=QVariantMap())=0
Initializes the algorithm using the specified configuration.
virtual QString asPythonCommand(const QVariantMap ¶meters, QgsProcessingContext &context) const
Returns a Python command string which can be executed to run the algorithm using the specified parame...
virtual bool canExecute(QString *errorMessage=nullptr) const
Returns true if the algorithm can execute.
virtual QString name() const =0
Returns the algorithm name, used for identifying the algorithm.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource,...
Base class for providing feedback from a processing algorithm.
Base class for the definition of processing parameters.
PythonOutputType
Available Python output types.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
#define SIP_THROW(name,...)