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 FlagDeprecated = FlagHideFromToolbox | FlagHideFromModeler,
84 Q_DECLARE_FLAGS( Flags, Flag )
145 virtual QString name() const = 0;
165 virtual QString displayName() const = 0;
172 virtual QString shortDescription() const;
178 virtual QStringList tags()
const {
return QStringList(); }
186 virtual QString shortHelpString()
const;
195 Q_DECL_DEPRECATED
virtual QString helpString() const
SIP_DEPRECATED;
202 virtual QString helpUrl() const;
208 virtual QIcon icon() const;
214 virtual QString svgIconPath() const;
222 virtual QString group()
const {
return QString(); }
231 virtual QString
groupId()
const {
return QString(); }
237 virtual Flags flags()
const;
245 virtual bool canExecute( QString *errorMessage
SIP_OUT =
nullptr )
const;
254 virtual bool checkParameterValues(
const QVariantMap ¶meters,
264 virtual QVariantMap preprocessParameters(
const QVariantMap ¶meters );
290 int countVisibleParameters()
const;
316 bool hasHtmlOutputs()
const;
364 const QVariantMap ¶meters,
366 const QMap< QString, QgsProcessingAlgorithm::VectorProperties > &sourceProperties )
const;
428 virtual QWidget *createCustomParametersWidget( QWidget *parent =
nullptr ) const
SIP_FACTORY;
445 virtual
bool validateInputCrs( const QVariantMap ¶meters,
455 virtual QString asPythonCommand( const QVariantMap ¶meters,
QgsProcessingContext &context ) const;
489 virtual
void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) = 0;
514 void removeParameter( const QString &name );
626 QString parameterAsString( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
631 QString parameterAsExpression( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
636 double parameterAsDouble( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
641 int parameterAsInt( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
647 QList<
int> parameterAsInts( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
652 int parameterAsEnum( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
657 QList<
int> parameterAsEnums( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
662 bool parameterAsBool( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
668 bool parameterAsBoolean( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
714 QString parameterAsCompatibleSourceLayerPath( const QVariantMap ¶meters, const QString &name,
746 QString parameterAsCompatibleSourceLayerPathAndLayerName( const QVariantMap ¶meters, const QString &name,
782 QString parameterAsOutputLayer( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
787 QString parameterAsFileOutput( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
855 QString parameterAsFile( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
861 QVariantList parameterAsMatrix( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
873 QStringList parameterAsFileList( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
878 QList<
double> parameterAsRange( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
883 QStringList parameterAsFields( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
910 QColor parameterAsColor( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
917 QString parameterAsConnectionName( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
924 QString parameterAsSchema( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
931 QString parameterAsDatabaseTableName( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
938 QDateTime parameterAsDateTime( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
953 static QString invalidSourceError( const QVariantMap ¶meters, const QString &name );
967 static QString invalidRasterError( const QVariantMap ¶meters, const QString &name );
981 static QString invalidSinkError( const QVariantMap ¶meters, const QString &name );
990 virtual
bool supportInPlaceEdit( const
QgsMapLayer *layer ) const;
997 bool mHasPrepared = false;
998 bool mHasExecuted = false;
999 bool mHasPostProcessed = false;
1006 friend class TestQgsProcessing;
1007 friend class QgsProcessingModelAlgorithm;
1015 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingAlgorithm::Flags )
1051 QgsProcessingAlgorithm::Flags flags()
const override;
1080 void initAlgorithm(
const QVariantMap &configuration = QVariantMap() )
override;
1089 virtual QString inputParameterName()
const;
1098 virtual QString inputParameterDescription()
const;
1105 virtual QString outputName()
const = 0;
1112 virtual QList<int> inputLayerTypes()
const;
1130 virtual QgsFeatureSink::SinkFlags sinkFlags()
const;
1168 virtual void initParameters(
const QVariantMap &configuration = QVariantMap() );
1193 bool supportInPlaceEdit(
const QgsMapLayer *layer )
const override;
1203 const QVariantMap ¶meters,
1205 const QMap< QString, QgsProcessingAlgorithm::VectorProperties > &sourceProperties )
const override;
1209 std::unique_ptr< QgsProcessingFeatureSource > mSource;
1215 #endif // QGSPROCESSINGALGORITHM_H