18 #ifndef QGSPROCESSINGALGORITHM_H
19 #define QGSPROCESSINGALGORITHM_H
21 #include "qgis_core.h"
35 class QgsProcessingModelAlgorithm;
41 #include <qgsprocessingmodelalgorithm.h>
56 if (
dynamic_cast< QgsProcessingModelAlgorithm *
>( sipCpp ) != NULL )
57 sipType = sipType_QgsProcessingModelAlgorithm;
59 sipType = sipType_QgsProcessingFeatureBasedAlgorithm;
61 sipType = sipType_QgsProcessingAlgorithm;
70 FlagHideFromToolbox = 1 << 1,
71 FlagHideFromModeler = 1 << 2,
72 FlagSupportsBatch = 1 << 3,
73 FlagCanCancel = 1 << 4,
74 FlagRequiresMatchingCrs = 1 << 5,
75 FlagNoThreading = 1 << 6,
76 FlagDisplayNameIsLiteral = 1 << 7,
77 FlagSupportsInPlaceEdits = 1 << 8,
78 FlagKnownIssues = 1 << 9,
79 FlagCustomException = 1 << 10,
80 FlagPruneModelBranchesBasedOnAlgorithmResults = 1 << 11,
81 FlagSkipGenericModelLogging = 1 << 12,
82 FlagNotAvailableInStandaloneTool = 1 << 13,
83 FlagRequiresProject = 1 << 14,
84 FlagDeprecated = FlagHideFromToolbox | FlagHideFromModeler,
86 Q_DECLARE_FLAGS( Flags, Flag )
147 virtual QString name() const = 0;
167 virtual QString displayName() const = 0;
174 virtual QString shortDescription() const;
180 virtual QStringList tags()
const {
return QStringList(); }
188 virtual QString shortHelpString()
const;
197 Q_DECL_DEPRECATED
virtual QString helpString() const
SIP_DEPRECATED;
204 virtual QString helpUrl() const;
210 virtual QIcon icon() const;
216 virtual QString svgIconPath() const;
224 virtual QString group()
const {
return QString(); }
233 virtual QString
groupId()
const {
return QString(); }
239 virtual Flags flags()
const;
247 virtual bool canExecute( QString *errorMessage
SIP_OUT =
nullptr )
const;
256 virtual bool checkParameterValues(
const QVariantMap ¶meters,
266 virtual QVariantMap preprocessParameters(
const QVariantMap ¶meters );
292 int countVisibleParameters()
const;
318 bool hasHtmlOutputs()
const;
366 const QVariantMap ¶meters,
368 const QMap< QString, QgsProcessingAlgorithm::VectorProperties > &sourceProperties )
const;
434 virtual QWidget *createCustomParametersWidget( QWidget *parent =
nullptr ) const
SIP_FACTORY;
451 virtual
bool validateInputCrs( const QVariantMap ¶meters,
461 virtual QString asPythonCommand( const QVariantMap ¶meters,
QgsProcessingContext &context ) const;
495 virtual
void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) = 0;
520 void removeParameter( const QString &name );
632 QString parameterAsString( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
637 QString parameterAsExpression( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
642 double parameterAsDouble( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
647 int parameterAsInt( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
653 QList<
int> parameterAsInts( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
658 int parameterAsEnum( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
663 QList<
int> parameterAsEnums( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
668 bool parameterAsBool( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
674 bool parameterAsBoolean( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
724 QString parameterAsCompatibleSourceLayerPath( const QVariantMap ¶meters, const QString &name,
756 QString parameterAsCompatibleSourceLayerPathAndLayerName( const QVariantMap ¶meters, const QString &name,
792 QString parameterAsOutputLayer( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
797 QString parameterAsFileOutput( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
885 QString parameterAsFile( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
891 QVariantList parameterAsMatrix( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
903 QStringList parameterAsFileList( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
908 QList<
double> parameterAsRange( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
913 QStringList parameterAsFields( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
940 QColor parameterAsColor( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
947 QString parameterAsConnectionName( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
954 QString parameterAsSchema( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
961 QString parameterAsDatabaseTableName( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
968 QDateTime parameterAsDateTime( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
983 static QString invalidSourceError( const QVariantMap ¶meters, const QString &name );
997 static QString invalidRasterError( const QVariantMap ¶meters, const QString &name );
1011 static QString invalidSinkError( const QVariantMap ¶meters, const QString &name );
1020 virtual
bool supportInPlaceEdit( const
QgsMapLayer *layer ) const;
1027 bool mHasPrepared = false;
1028 bool mHasExecuted = false;
1029 bool mHasPostProcessed = false;
1036 friend class TestQgsProcessing;
1037 friend class QgsProcessingModelAlgorithm;
1081 QgsProcessingAlgorithm::Flags flags()
const override;
1110 void initAlgorithm(
const QVariantMap &configuration = QVariantMap() )
override;
1119 virtual QString inputParameterName()
const;
1128 virtual QString inputParameterDescription()
const;
1142 virtual QList<int> inputLayerTypes()
const;
1160 virtual QgsFeatureSink::SinkFlags sinkFlags()
const;
1198 virtual void initParameters(
const QVariantMap &configuration = QVariantMap() );
1223 bool supportInPlaceEdit(
const QgsMapLayer *layer )
const override;
1233 const QVariantMap ¶meters,
1235 const QMap< QString, QgsProcessingAlgorithm::VectorProperties > &sourceProperties )
const override;
1239 std::unique_ptr< QgsProcessingFeatureSource > mSource;
1245 #endif // QGSPROCESSINGALGORITHM_H