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;
58 else if ( dynamic_cast< QgsProcessingFeatureBasedAlgorithm * >( sipCpp ) != NULL )
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 FlagDeprecated = FlagHideFromToolbox | FlagHideFromModeler,
80 Q_DECLARE_FLAGS( Flags,
Flag )
141 virtual QString name() const = 0;
161 virtual QString displayName() const = 0;
168 virtual QString shortDescription() const;
174 virtual QStringList tags()
const {
return QStringList(); }
182 virtual QString shortHelpString()
const;
191 Q_DECL_DEPRECATED
virtual QString helpString()
const SIP_DEPRECATED;
198 virtual QString helpUrl()
const;
204 virtual QIcon icon()
const;
210 virtual QString svgIconPath()
const;
218 virtual QString
group()
const {
return QString(); }
227 virtual QString
groupId()
const {
return QString(); }
233 virtual Flags flags()
const;
241 virtual bool canExecute( QString *errorMessage
SIP_OUT =
nullptr )
const;
250 virtual bool checkParameterValues(
const QVariantMap ¶meters,
260 virtual QVariantMap preprocessParameters(
const QVariantMap ¶meters );
286 int countVisibleParameters()
const;
312 bool hasHtmlOutputs()
const;
374 virtual QWidget *createCustomParametersWidget( QWidget *parent =
nullptr )
const SIP_FACTORY;
391 virtual bool validateInputCrs(
const QVariantMap ¶meters,
401 virtual QString asPythonCommand(
const QVariantMap ¶meters,
QgsProcessingContext &context )
const;
435 virtual void initAlgorithm(
const QVariantMap &configuration = QVariantMap() ) = 0;
460 void removeParameter(
const QString &name );
573 QString parameterAsString(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
578 QString parameterAsExpression(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
583 double parameterAsDouble(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
588 int parameterAsInt(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
594 QList<int> parameterAsInts(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
599 int parameterAsEnum(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
604 QList<int> parameterAsEnums(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
609 bool parameterAsBool(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
650 QString parameterAsCompatibleSourceLayerPath(
const QVariantMap ¶meters,
const QString &name,
686 QString parameterAsOutputLayer(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
691 QString parameterAsFileOutput(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
759 QString parameterAsFile(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
765 QVariantList parameterAsMatrix(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
770 QList< QgsMapLayer *> parameterAsLayerList(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
775 QList<double> parameterAsRange(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
780 QStringList parameterAsFields(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
794 static QString invalidSourceError(
const QVariantMap ¶meters,
const QString &name );
808 static QString invalidRasterError(
const QVariantMap ¶meters,
const QString &name );
822 static QString invalidSinkError(
const QVariantMap ¶meters,
const QString &name );
831 virtual bool supportInPlaceEdit(
const QgsMapLayer *layer )
const;
838 bool mHasPrepared =
false;
839 bool mHasExecuted =
false;
840 bool mHasPostProcessed =
false;
841 std::unique_ptr< QgsProcessingContext > mLocalContext;
847 friend class TestQgsProcessing;
848 friend class QgsProcessingModelAlgorithm;
856 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingAlgorithm::Flags )
892 QgsProcessingAlgorithm::Flags flags()
const override;
921 void initAlgorithm(
const QVariantMap &configuration = QVariantMap() )
override;
928 virtual QString outputName()
const = 0;
935 virtual QList<int> inputLayerTypes()
const;
953 virtual QgsFeatureSink::SinkFlags sinkFlags()
const;
991 virtual void initParameters(
const QVariantMap &configuration = QVariantMap() );
1016 bool supportInPlaceEdit(
const QgsMapLayer *layer )
const override;
1027 std::unique_ptr< QgsProcessingFeatureSource > mSource;
1033 #endif // QGSPROCESSINGALGORITHM_H #define SIP_VIRTUALERRORHANDLER(name)
QList< const QgsProcessingParameterDefinition *> QgsProcessingParameterDefinitions
List of processing parameters.
A rectangle specified with double values.
Base class for all map layer types.
Base class for providing feedback from a processing algorithm.
QgsProcessingParameterDefinitions parameterDefinitions() const
Returns an ordered list of parameter definitions utilized by the algorithm.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
QList< QgsFeature > QgsFeatureList
virtual QString group() const
Returns the name of the group this algorithm belongs to.
A class to represent a 2D point.
An interface for objects which accept features via addFeature(s) methods.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource, modifying results according to the settings in a QgsProcessingContext.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
Abstract base class for processing providers.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
const QgsCoordinateReferenceSystem & crs
Abstract base class for processing algorithms.
Type
The WKB type describes the number of dimensions a geometry has.
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)...
Custom exception class for processing related exceptions.
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
QgsProcessingOutputDefinitions outputDefinitions() const
Returns an ordered list of output definitions utilized by the algorithm.
Base class for the definition of processing outputs.
QList< const QgsProcessingOutputDefinition *> QgsProcessingOutputDefinitions
List of processing parameters.
This class represents a coordinate reference system (CRS).
Base class for the definition of processing parameters.
Flag
Flags indicating how and when an algorithm operates and should be exposed to users.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
SourceType
Data source types enum.
const QgsCoordinateReferenceSystem & outputCrs
Represents a mesh layer supporting display of data on structured or unstructured meshes.
virtual QString groupId() const
Returns the unique ID of the group this algorithm belongs to.
An abstract QgsProcessingAlgorithm base class for processing algorithms which operate "feature-by-fea...
Represents a vector layer which manages a vector based data sets.
Contains information about the context in which a processing algorithm is executed.