18 #ifndef QGSPROCESSINGALGORITHM_H 19 #define QGSPROCESSINGALGORITHM_H 21 #include "qgis_core.h" 36 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 FlagDeprecated = FlagHideFromToolbox | FlagHideFromModeler,
79 Q_DECLARE_FLAGS( Flags,
Flag )
137 virtual QString name() const = 0;
157 virtual QString displayName() const = 0;
164 virtual QString shortDescription() const;
170 virtual QStringList tags()
const {
return QStringList(); }
178 virtual QString shortHelpString()
const;
186 virtual QString helpString()
const;
193 virtual QString helpUrl()
const;
199 virtual QIcon icon()
const;
205 virtual QString svgIconPath()
const;
213 virtual QString
group()
const {
return QString(); }
222 virtual QString
groupId()
const {
return QString(); }
228 virtual Flags flags()
const;
236 virtual bool canExecute( QString *errorMessage
SIP_OUT =
nullptr )
const;
245 virtual bool checkParameterValues(
const QVariantMap ¶meters,
255 virtual QVariantMap preprocessParameters(
const QVariantMap ¶meters );
281 int countVisibleParameters()
const;
307 bool hasHtmlOutputs()
const;
369 virtual QWidget *createCustomParametersWidget( QWidget *parent =
nullptr )
const SIP_FACTORY;
386 virtual bool validateInputCrs(
const QVariantMap ¶meters,
396 virtual QString asPythonCommand(
const QVariantMap ¶meters,
QgsProcessingContext &context )
const;
430 virtual void initAlgorithm(
const QVariantMap &configuration = QVariantMap() ) = 0;
455 void removeParameter(
const QString &name );
568 QString parameterAsString(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
573 QString parameterAsExpression(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
578 double parameterAsDouble(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
583 int parameterAsInt(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
588 int parameterAsEnum(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
593 QList<int> parameterAsEnums(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
598 bool parameterAsBool(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
639 QString parameterAsCompatibleSourceLayerPath(
const QVariantMap ¶meters,
const QString &name,
663 QString parameterAsOutputLayer(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
668 QString parameterAsFileOutput(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
736 QString parameterAsFile(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
742 QVariantList parameterAsMatrix(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
747 QList< QgsMapLayer *> parameterAsLayerList(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
752 QList<double> parameterAsRange(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
757 QStringList parameterAsFields(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
771 static QString invalidSourceError(
const QVariantMap ¶meters,
const QString &name );
785 static QString invalidRasterError(
const QVariantMap ¶meters,
const QString &name );
799 static QString invalidSinkError(
const QVariantMap ¶meters,
const QString &name );
806 bool mHasPrepared =
false;
807 bool mHasExecuted =
false;
808 bool mHasPostProcessed =
false;
809 std::unique_ptr< QgsProcessingContext > mLocalContext;
814 friend class TestQgsProcessing;
815 friend class QgsProcessingModelAlgorithm;
822 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingAlgorithm::Flags )
860 void initAlgorithm(
const QVariantMap &configuration = QVariantMap() )
override;
867 virtual QString outputName()
const = 0;
874 virtual QList<int> inputLayerTypes()
const;
923 virtual void initParameters(
const QVariantMap &configuration = QVariantMap() );
966 std::unique_ptr< QgsProcessingFeatureSource > mSource;
972 #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...
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.
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.