18 #ifndef QGSPROCESSINGALGORITHM_H 19 #define QGSPROCESSINGALGORITHM_H 21 #include "qgis_core.h" 35 class QgsProcessingModelAlgorithm;
40 #include <qgsprocessingmodelalgorithm.h> 55 if ( dynamic_cast< QgsProcessingModelAlgorithm * >( sipCpp ) != NULL )
56 sipType = sipType_QgsProcessingModelAlgorithm;
57 else if ( dynamic_cast< QgsProcessingFeatureBasedAlgorithm * >( sipCpp ) != NULL )
58 sipType = sipType_QgsProcessingFeatureBasedAlgorithm;
60 sipType = sipType_QgsProcessingAlgorithm;
69 FlagHideFromToolbox = 1 << 1,
70 FlagHideFromModeler = 1 << 2,
71 FlagSupportsBatch = 1 << 3,
72 FlagCanCancel = 1 << 4,
73 FlagRequiresMatchingCrs = 1 << 5,
74 FlagNoThreading = 1 << 6,
75 FlagDisplayNameIsLiteral = 1 << 7,
76 FlagSupportsInPlaceEdits = 1 << 8,
77 FlagKnownIssues = 1 << 9,
78 FlagDeprecated = FlagHideFromToolbox | FlagHideFromModeler,
80 Q_DECLARE_FLAGS( Flags,
Flag )
94 QgsProcessingAlgorithm( const QgsProcessingAlgorithm &other ) = delete;
96 QgsProcessingAlgorithm &operator=( const QgsProcessingAlgorithm &other ) = delete;
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,
674 QString parameterAsOutputLayer(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
679 QString parameterAsFileOutput(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
747 QString parameterAsFile(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
753 QVariantList parameterAsMatrix(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
758 QList< QgsMapLayer *> parameterAsLayerList(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
763 QList<double> parameterAsRange(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
768 QStringList parameterAsFields(
const QVariantMap ¶meters,
const QString &name,
QgsProcessingContext &context )
const;
782 static QString invalidSourceError(
const QVariantMap ¶meters,
const QString &name );
796 static QString invalidRasterError(
const QVariantMap ¶meters,
const QString &name );
810 static QString invalidSinkError(
const QVariantMap ¶meters,
const QString &name );
819 virtual bool supportInPlaceEdit(
const QgsMapLayer *layer )
const;
826 bool mHasPrepared =
false;
827 bool mHasExecuted =
false;
828 bool mHasPostProcessed =
false;
829 std::unique_ptr< QgsProcessingContext > mLocalContext;
835 friend class TestQgsProcessing;
836 friend class QgsProcessingModelAlgorithm;
844 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingAlgorithm::Flags )
880 QgsProcessingAlgorithm::Flags flags()
const override;
909 void initAlgorithm(
const QVariantMap &configuration = QVariantMap() )
override;
916 virtual QString outputName()
const = 0;
923 virtual QList<int> inputLayerTypes()
const;
941 virtual QgsFeatureSink::SinkFlags sinkFlags()
const;
979 virtual void initParameters(
const QVariantMap &configuration = QVariantMap() );
1004 bool supportInPlaceEdit(
const QgsMapLayer *layer )
const override;
1015 std::unique_ptr< QgsProcessingFeatureSource > mSource;
1021 #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
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.
Base class for the definition of processing outputs.
QList< const QgsProcessingOutputDefinition * > QgsProcessingOutputDefinitions
List of processing parameters.
virtual QString groupId() const
Returns the unique ID of the group this algorithm belongs to.
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)
virtual QString group() const
Returns the name of the group this algorithm belongs to.
SourceType
Data source types enum.
const QgsCoordinateReferenceSystem & outputCrs
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.
QgsProcessingOutputDefinitions outputDefinitions() const
Returns an ordered list of output definitions utilized by the algorithm.