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 FlagKnownIssues = 1 << 9,
79 FlagDeprecated = FlagHideFromToolbox | FlagHideFromModeler,
81 Q_DECLARE_FLAGS( Flags,
Flag )
142 virtual QString name() const = 0;
162 virtual QString displayName() const = 0;
169 virtual QString shortDescription() const;
175 virtual QStringList tags()
const {
return QStringList(); }
183 virtual QString shortHelpString()
const;
192 Q_DECL_DEPRECATED
virtual QString helpString()
const SIP_DEPRECATED;
199 virtual QString helpUrl()
const;
205 virtual QIcon icon()
const;
211 virtual QString svgIconPath()
const;
219 virtual QString
group()
const {
return QString(); }
228 virtual QString
groupId()
const {
return QString(); }
234 virtual Flags flags()
const;
242 virtual bool canExecute( QString *errorMessage
SIP_OUT =
nullptr )
const;
251 virtual bool checkParameterValues(
const QVariantMap ¶meters,
261 virtual QVariantMap preprocessParameters(
const QVariantMap ¶meters );
287 int countVisibleParameters()
const;
313 bool hasHtmlOutputs()
const;
375 virtual QWidget *createCustomParametersWidget( QWidget *parent =
nullptr )
const SIP_FACTORY;
392 virtual bool validateInputCrs(
const QVariantMap ¶meters,
402 virtual QString asPythonCommand(
const QVariantMap ¶meters,
QgsProcessingContext &context )
const;
436 virtual void initAlgorithm(
const QVariantMap &configuration = QVariantMap() ) = 0;
461 void removeParameter(
const QString &name );
574 QString parameterAsString(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
579 QString parameterAsExpression(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
584 double parameterAsDouble(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
589 int parameterAsInt(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
595 QList<int> parameterAsInts(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
600 int parameterAsEnum(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
605 QList<int> parameterAsEnums(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
610 bool parameterAsBool(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
616 bool parameterAsBoolean(
const QVariantMap ¶meters,
const QString &name,
const QgsProcessingContext &context )
const;
657 QString parameterAsCompatibleSourceLayerPath(
const QVariantMap ¶meters,
const QString &name,
693 QString parameterAsOutputLayer(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
698 QString parameterAsFileOutput(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
766 QString parameterAsFile(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
772 QVariantList parameterAsMatrix(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
777 QList< QgsMapLayer *> parameterAsLayerList(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
782 QList<double> parameterAsRange(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
787 QStringList parameterAsFields(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
821 static QString invalidSourceError(
const QVariantMap ¶meters,
const QString &name );
835 static QString invalidRasterError(
const QVariantMap ¶meters,
const QString &name );
849 static QString invalidSinkError(
const QVariantMap ¶meters,
const QString &name );
858 virtual bool supportInPlaceEdit(
const QgsMapLayer *layer )
const;
865 bool mHasPrepared =
false;
866 bool mHasExecuted =
false;
867 bool mHasPostProcessed =
false;
868 std::unique_ptr< QgsProcessingContext > mLocalContext;
874 friend class TestQgsProcessing;
875 friend class QgsProcessingModelAlgorithm;
883 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingAlgorithm::Flags )
919 QgsProcessingAlgorithm::Flags flags()
const override;
948 void initAlgorithm(
const QVariantMap &configuration = QVariantMap() )
override;
955 virtual QString outputName()
const = 0;
962 virtual QList<int> inputLayerTypes()
const;
980 virtual QgsFeatureSink::SinkFlags sinkFlags()
const;
1018 virtual void initParameters(
const QVariantMap &configuration = QVariantMap() );
1043 bool supportInPlaceEdit(
const QgsMapLayer *layer )
const override;
1054 std::unique_ptr< QgsProcessingFeatureSource > mSource;
1060 #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.
Base class for graphical items within a QgsLayout.
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.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
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.