18 #ifndef QGSPROCESSINGMODELALGORITHM_H
19 #define QGSPROCESSINGMODELALGORITHM_H
21 #include "qgis_core.h"
47 QgsProcessingModelAlgorithm(
const QString &name = QString(),
const QString &group = QString(),
const QString &groupId = QString() );
49 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 );
305 void updateDestinationParameters();
315 void addGroupBox(
const QgsProcessingModelGroupBox &groupBox );
323 QList< QgsProcessingModelGroupBox > groupBoxes()
const;
332 void removeGroupBox(
const QString &uuid );
338 bool toFile(
const QString &path )
const;
344 bool fromFile(
const QString &path );
353 QVariant toVariant()
const;
362 bool loadVariant(
const QVariant &variant );
369 QVariantMap &helpContent() {
return mHelpContent; }
376 SIP_SKIP QVariantMap helpContent()
const;
383 void setHelpContent(
const QVariantMap &contents );
389 QString sourceFilePath()
const;
395 void setSourceFilePath(
const QString &path );
405 bool modelNameMatchesFilePath()
const;
424 QList< QgsProcessingModelChildParameterSource > availableSourcesForChild(
const QString &childId,
const QStringList ¶meterTypes = QStringList(),
425 const QStringList &outputTypes = QStringList(),
const QList< int > &dataTypes = QList< int >() )
const;
432 class CORE_EXPORT VariableDefinition
440 VariableDefinition(
const QVariant &value = QVariant(),
const QgsProcessingModelChildParameterSource &source = QgsProcessingModelChildParameterSource::fromStaticValue( QVariant() ),
const QString &description = QString() )
443 , description( description )
450 QgsProcessingModelChildParameterSource source;
469 QMap< QString, QgsProcessingModelAlgorithm::VariableDefinition > variablesForChildAlgorithm(
const QString &childId,
QgsProcessingContext &context,
const QVariantMap &modelParameters = QVariantMap(),
470 const QVariantMap &results = QVariantMap() )
const;
477 const QVariantMap &results = QVariantMap() ) const
SIP_FACTORY;
488 QVariantMap variables() const;
499 void setVariables( const QVariantMap &variables );
512 QVariantMap designerParameterValues() const;
525 void setDesignerParameterValues( const QVariantMap &values ) { mDesignerParameterValues = values; }
541 static QString safeName(
const QString &name,
bool capitalize =
false );
546 enum class InternalVersion
551 Q_ENUM( InternalVersion )
563 InternalVersion mInternalVersion = InternalVersion::Version2;
567 QString mModelGroupId;
569 QMap< QString, QgsProcessingModelChildAlgorithm > mChildAlgorithms;
572 QMap< QString, QgsProcessingModelParameter > mParameterComponents;
574 QVariantMap mHelpContent;
579 QVariantMap mResults;
581 QVariantMap mVariables;
583 QVariantMap mDesignerParameterValues;
585 QMap< QString, QgsProcessingModelGroupBox > mGroupBoxes;
587 QStringList mParameterOrder;
589 void dependsOnChildAlgorithmsRecursive( const QString &childId, QSet<QString> &depends ) const;
590 void dependentChildAlgorithmsRecursive( const QString &childId, QSet<QString> &depends, const QString &branch ) const;
592 QVariantMap parametersForChildAlgorithm( const QgsProcessingModelChildAlgorithm &child, const QVariantMap &modelParameters, const QVariantMap &results, const
QgsExpressionContext &expressionContext, QString &error ) const;
598 bool childOutputIsRequired( const QString &childId, const QString &outputName ) const;
609 static
bool vectorOutputIsCompatibleType( const QList<
int> &acceptableDataTypes,
QgsProcessing::SourceType outputType );
614 void reattachAlgorithms() const;
616 friend class TestQgsProcessingModelAlgorithm;
621 #endif // QGSPROCESSINGMODELALGORITHM_H