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;
669 QString parameterAsEnumString( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
675 QStringList parameterAsEnumStrings( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
680 bool parameterAsBool( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
686 bool parameterAsBoolean( const QVariantMap ¶meters, const QString &name, const
QgsProcessingContext &context ) const;
736 QString parameterAsCompatibleSourceLayerPath( const QVariantMap ¶meters, const QString &name,
768 QString parameterAsCompatibleSourceLayerPathAndLayerName( const QVariantMap ¶meters, const QString &name,
804 QString parameterAsOutputLayer( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
809 QString parameterAsFileOutput( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
897 QString parameterAsFile( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
903 QVariantList parameterAsMatrix( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
915 QStringList parameterAsFileList( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
920 QList<
double> parameterAsRange( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
925 QStringList parameterAsFields( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context ) const;
952 QColor parameterAsColor( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
959 QString parameterAsConnectionName( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
966 QString parameterAsSchema( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
973 QString parameterAsDatabaseTableName( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
980 QDateTime parameterAsDateTime( const QVariantMap ¶meters, const QString &name,
QgsProcessingContext &context );
995 static QString invalidSourceError( const QVariantMap ¶meters, const QString &name );
1009 static QString invalidRasterError( const QVariantMap ¶meters, const QString &name );
1023 static QString invalidSinkError( const QVariantMap ¶meters, const QString &name );
1032 virtual
bool supportInPlaceEdit( const
QgsMapLayer *layer ) const;
1039 bool mHasPrepared = false;
1040 bool mHasExecuted = false;
1041 bool mHasPostProcessed = false;
1048 friend class TestQgsProcessing;
1049 friend class QgsProcessingModelAlgorithm;
1093 QgsProcessingAlgorithm::Flags flags()
const override;
1122 void initAlgorithm(
const QVariantMap &configuration = QVariantMap() )
override;
1131 virtual QString inputParameterName()
const;
1140 virtual QString inputParameterDescription()
const;
1154 virtual QList<int> inputLayerTypes()
const;
1172 virtual QgsFeatureSink::SinkFlags sinkFlags()
const;
1210 virtual void initParameters(
const QVariantMap &configuration = QVariantMap() );
1235 bool supportInPlaceEdit(
const QgsMapLayer *layer )
const override;
1245 const QVariantMap ¶meters,
1247 const QMap< QString, QgsProcessingAlgorithm::VectorProperties > &sourceProperties )
const override;
1251 std::unique_ptr< QgsProcessingFeatureSource > mSource;
This class represents a coordinate reference system (CRS).
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
This class wraps a request for features to a vector layer (or directly its vector data provider).
An interface for objects which accept features via addFeature(s) methods.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
Base class for graphical items within a QgsLayout.
Base class for all map layer types.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
A class to represent a 2D point.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Abstract base class for processing algorithms.
QgsProcessingOutputDefinitions outputDefinitions() const
Returns an ordered list of output definitions utilized by the algorithm.
PropertyAvailability
Property availability, used for QgsProcessingAlgorithm::VectorProperties in order to determine if pro...
@ NotAvailable
Properties are not available.
@ Available
Properties are available.
virtual QString groupId() const
Returns the unique ID of the group this algorithm belongs to.
QgsProcessingParameterDefinitions parameterDefinitions() const
Returns an ordered list of parameter definitions utilized by the algorithm.
Flag
Flags indicating how and when an algorithm operates and should be exposed to users.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
An abstract QgsProcessingAlgorithm base class for processing algorithms which operate "feature-by-fea...
QgsProcessingFeatureBasedAlgorithm()=default
Constructor for QgsProcessingFeatureBasedAlgorithm.
virtual QString outputName() const =0
Returns the translated, user visible name for any layers created by this algorithm.
virtual QgsFeatureList processFeature(const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)=0
Processes an individual input feature from the source.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource,...
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
Base class for providing feedback from a processing algorithm.
Base class for the definition of processing outputs.
Base class for the definition of processing parameters.
Abstract base class for processing providers.
SourceType
Data source types enum.
Represents a raster layer.
A rectangle specified with double values.
Represents a vector layer which manages a vector based data sets.
Handles storage of information regarding WKB types and their properties.
Type
The WKB type describes the number of dimensions a geometry has.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_VIRTUALERRORHANDLER(name)
QList< QgsFeature > QgsFeatureList
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
QList< const QgsProcessingOutputDefinition * > QgsProcessingOutputDefinitions
List of processing parameters.
QList< const QgsProcessingParameterDefinition * > QgsProcessingParameterDefinitions
List of processing parameters.
const QgsCoordinateReferenceSystem & outputCrs
const QgsCoordinateReferenceSystem & crs
Properties of a vector source or sink used in an algorithm.
QgsCoordinateReferenceSystem crs
Coordinate Reference System.