18 #ifndef QGSPROCESSINGPARAMETERS_H
19 #define QGSPROCESSINGPARAMETERS_H
21 #include "qgis_core.h"
67 FlagOverrideDefaultGeometryCheck = 1 << 0,
68 FlagCreateIndividualOutputPerInputFeature = 1 << 1,
70 Q_DECLARE_FLAGS( Flags, Flag )
88 , selectedFeaturesOnly( selectedFeaturesOnly )
89 , featureLimit( featureLimit )
91 , geometryCheck( geometryCheck )
110 , selectedFeaturesOnly( selectedFeaturesOnly )
111 , featureLimit( featureLimit )
113 , geometryCheck( geometryCheck )
132 long long featureLimit = -1;
139 Flags flags = Flags();
157 QVariant toVariant()
const;
165 bool loadVariant(
const QVariantMap &map );
170 return source == other.
source
173 && flags == other.
flags
179 return !( *
this == other );
183 operator QVariant()
const
185 return QVariant::fromValue( *
this );
213 , destinationProject( destinationProject )
223 , destinationProject( destinationProject )
286 QVariant toVariant()
const;
294 bool loadVariant(
const QVariantMap &map );
297 operator QVariant()
const
299 return QVariant::fromValue( *
this );
308 bool mUseRemapping =
false;
348 sipType = sipType_QgsProcessingParameterBoolean;
350 sipType = sipType_QgsProcessingParameterCrs;
352 sipType = sipType_QgsProcessingParameterMapLayer;
354 sipType = sipType_QgsProcessingParameterExtent;
356 sipType = sipType_QgsProcessingParameterPoint;
358 sipType = sipType_QgsProcessingParameterGeometry;
360 sipType = sipType_QgsProcessingParameterFile;
362 sipType = sipType_QgsProcessingParameterMatrix;
364 sipType = sipType_QgsProcessingParameterMultipleLayers;
366 sipType = sipType_QgsProcessingParameterNumber;
368 sipType = sipType_QgsProcessingParameterDistance;
370 sipType = sipType_QgsProcessingParameterDuration;
372 sipType = sipType_QgsProcessingParameterScale;
374 sipType = sipType_QgsProcessingParameterRange;
376 sipType = sipType_QgsProcessingParameterRasterLayer;
378 sipType = sipType_QgsProcessingParameterMeshLayer;
380 sipType = sipType_QgsProcessingParameterEnum;
382 sipType = sipType_QgsProcessingParameterString;
384 sipType = sipType_QgsProcessingParameterExpression;
386 sipType = sipType_QgsProcessingParameterAuthConfig;
388 sipType = sipType_QgsProcessingParameterVectorLayer;
390 sipType = sipType_QgsProcessingParameterField;
392 sipType = sipType_QgsProcessingParameterFeatureSource;
394 sipType = sipType_QgsProcessingParameterFeatureSink;
396 sipType = sipType_QgsProcessingParameterVectorDestination;
398 sipType = sipType_QgsProcessingParameterRasterDestination;
400 sipType = sipType_QgsProcessingParameterPointCloudDestination;
402 sipType = sipType_QgsProcessingParameterFileDestination;
404 sipType = sipType_QgsProcessingParameterFolderDestination;
406 sipType = sipType_QgsProcessingParameterBand;
408 sipType = sipType_QgsProcessingParameterLayout;
410 sipType = sipType_QgsProcessingParameterLayoutItem;
412 sipType = sipType_QgsProcessingParameterColor;
414 sipType = sipType_QgsProcessingParameterCoordinateOperation;
416 sipType = sipType_QgsProcessingParameterMapTheme;
418 sipType = sipType_QgsProcessingParameterDateTime;
420 sipType = sipType_QgsProcessingParameterProviderConnection;
422 sipType = sipType_QgsProcessingParameterDatabaseSchema;
424 sipType = sipType_QgsProcessingParameterDatabaseTable;
426 sipType = sipType_QgsProcessingParameterFieldMapping;
428 sipType = sipType_QgsProcessingParameterTinInputLayers;
430 sipType = sipType_QgsProcessingParameterVectorTileWriterLayers;
432 sipType = sipType_QgsProcessingParameterDxfLayers;
434 sipType = sipType_QgsProcessingParameterMeshDatasetGroups;
436 sipType = sipType_QgsProcessingParameterMeshDatasetTime;
438 sipType = sipType_QgsProcessingParameterPointCloudLayer;
440 sipType = sipType_QgsProcessingParameterAnnotationLayer;
451 FlagAdvanced = 1 << 1,
453 FlagOptional = 1 << 3,
454 FlagIsModelOutput = 1 << 4,
456 Q_DECLARE_FLAGS( Flags, Flag )
462 bool optional =
false,
const QString &help = QString() );
474 virtual QString type()
const = 0;
488 QString
name()
const {
return mName; }
495 void setName(
const QString &name ) { mName = name; }
509 void setDescription(
const QString &description ) { mDescription = description; }
520 QString
help()
const {
return mHelp; }
531 void setHelp(
const QString &help ) { mHelp = help; }
594 Flags
flags()
const {
return mFlags; }
609 virtual bool checkValueIsAcceptable(
const QVariant &input,
QgsProcessingContext *context =
nullptr )
const;
618 virtual QString valueAsPythonString(
const QVariant &value,
QgsProcessingContext &context )
const;
631 virtual QVariant valueAsJsonObject(
const QVariant &value,
QgsProcessingContext &context )
const;
668 virtual QString valueAsPythonComment(
const QVariant &value,
QgsProcessingContext &context )
const;
674 virtual QString asScriptCode()
const;
692 virtual QVariantMap toVariantMap()
const;
699 virtual bool fromVariantMap(
const QVariantMap &map );
721 void setMetadata(
const QVariantMap &metadata ) { mMetadata = metadata; }
747 virtual QString toolTip()
const;
870 bool mIsDynamic =
false;
918 static bool isDynamic(
const QVariantMap ¶meters,
const QString &name );
1125 QgsProcessingContext &context, QString &destinationIdentifier
SIP_OUT, QgsFeatureSink::SinkFlags sinkFlags = QgsFeatureSink::SinkFlags(),
const QVariantMap &createOptions = QVariantMap(),
const QStringList &datasourceOptions = QStringList(),
const QStringList &layerOptions = QStringList() )
SIP_FACTORY;
1148 QgsProcessingContext &context, QString &destinationIdentifier
SIP_OUT, QgsFeatureSink::SinkFlags sinkFlags = QgsFeatureSink::SinkFlags(),
const QVariantMap &createOptions = QVariantMap(),
const QStringList &datasourceOptions = QStringList(),
const QStringList &layerOptions = QStringList() )
SIP_THROW(
QgsProcessingException )
SIP_FACTORY;
1687 static QString descriptionFromName(
const QString &name );
1698 static bool parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition );
1717 bool optional =
false );
1722 static QString
typeName() {
return QStringLiteral(
"boolean" ); }
1747 QgsProcessingParameterCrs(
const QString &name,
const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
1748 bool optional =
false );
1753 static QString
typeName() {
return QStringLiteral(
"crs" ); }
1780 bool optional =
false );
1785 static QString
typeName() {
return QStringLiteral(
"extent" ); }
1812 QgsProcessingParameterPoint(
const QString &name,
const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
1813 bool optional =
false );
1818 static QString
typeName() {
return QStringLiteral(
"point" ); }
1848 QgsProcessingParameterGeometry(
const QString &name,
const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
bool optional =
false,
const QList< int > &geometryTypes = QList< int >(),
bool allowMultipart =
true );
1853 static QString
typeName() {
return QStringLiteral(
"geometry" ); }
1896 QList<int> mGeomTypes;
1897 bool mAllowMultipart;
1925 QgsProcessingParameterFile(
const QString &name,
const QString &description = QString(), Behavior behavior = File,
const QString &extension = QString(),
const QVariant &defaultValue = QVariant(),
1926 bool optional =
false,
const QString &fileFilter = QString() );
1931 static QString
typeName() {
return QStringLiteral(
"file" ); }
1969 void setExtension(
const QString &extension );
1977 QString fileFilter()
const;
1988 void setFileFilter(
const QString &filter );
1996 static QgsProcessingParameterFile *fromScriptCode(
const QString &name,
const QString &description,
bool isOptional,
const QString &definition, Behavior behavior = File )
SIP_FACTORY;
2000 Behavior mBehavior = File;
2002 QString mFileFilter;
2019 bool hasFixedNumberRows =
false,
const QStringList &headers = QStringList(),
2020 const QVariant &defaultValue = QVariant(),
2021 bool optional =
false );
2026 static QString
typeName() {
return QStringLiteral(
"matrix" ); }
2037 QStringList headers()
const;
2043 void setHeaders(
const QStringList &headers );
2051 int numberRows()
const;
2059 void setNumberRows(
int rows );
2066 bool hasFixedNumberRows()
const;
2073 void setHasFixedNumberRows(
bool hasFixedNumberRows );
2085 QStringList mHeaders;
2086 int mNumberRows = 3;
2087 bool mFixedNumberRows =
false;
2105 const QVariant &defaultValue = QVariant(),
2106 bool optional =
false );
2111 static QString
typeName() {
return QStringLiteral(
"multilayer" ); }
2137 int minimumNumberInputs()
const;
2144 void setMinimumNumberInputs(
int minimum );
2157 int mMinimumNumberInputs = 0;
2194 Type type = Integer,
2195 const QVariant &defaultValue = QVariant(),
2196 bool optional =
false,
2197 double minValue = std::numeric_limits<double>::lowest() + 1,
2198 double maxValue = std::numeric_limits<double>::max()
2204 static QString
typeName() {
return QStringLiteral(
"number" ); }
2209 QString
toolTip()
const override;
2216 double minimum()
const;
2222 void setMinimum(
double minimum );
2228 double maximum()
const;
2234 void setMaximum(
double maximum );
2240 Type dataType()
const;
2246 void setDataType( Type type );
2258 double mMin = std::numeric_limits<double>::lowest() + 1;
2259 double mMax = std::numeric_limits<double>::max();
2260 Type mDataType = Integer;
2290 const QVariant &defaultValue = QVariant(),
2291 const QString &parentParameterName = QString(),
2292 bool optional =
false,
2293 double minValue = std::numeric_limits<double>::lowest() + 1,
2294 double maxValue = std::numeric_limits<double>::max() );
2299 static QString
typeName() {
return QStringLiteral(
"distance" ); }
2303 QString type() const override;
2304 QStringList dependsOnOtherParameters() const override;
2305 QString asPythonString(
QgsProcessing::PythonOutputType outputType =
QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const override;
2311 QString parentParameterName() const;
2317 void setParentParameterName( const QString &parentParameterName );
2340 QString mParentParameterName;
2360 const QVariant &defaultValue = QVariant(),
2361 bool optional =
false,
2362 double minValue = std::numeric_limits<double>::lowest() + 1,
2363 double maxValue = std::numeric_limits<double>::max() );
2368 static QString
typeName() {
return QStringLiteral(
"duration" ); }
2372 QString type() const override;
2373 QString asPythonString(
QgsProcessing::PythonOutputType outputType =
QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const override;
2416 const QVariant &defaultValue = QVariant(),
2417 bool optional =
false );
2422 static QString
typeName() {
return QStringLiteral(
"scale" ); }
2426 QString type() const override;
2427 QString asPythonString(
QgsProcessing::PythonOutputType outputType =
QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const override;
2451 const QVariant &defaultValue = QVariant(),
2452 bool optional =
false );
2457 static QString
typeName() {
return QStringLiteral(
"range" ); }
2503 bool optional =
false );
2508 static QString
typeName() {
return QStringLiteral(
"raster" ); }
2547 QgsProcessingParameterEnum(
const QString &name,
const QString &description = QString(),
const QStringList &options = QStringList(),
2548 bool allowMultiple =
false,
2549 const QVariant &defaultValue = QVariant(),
2550 bool optional =
false,
2551 bool usesStaticStrings =
false );
2556 static QString
typeName() {
return QStringLiteral(
"enum" ); }
2569 QStringList options()
const;
2575 void setOptions(
const QStringList &options );
2581 bool allowMultiple()
const;
2587 void setAllowMultiple(
bool allowMultiple );
2595 bool usesStaticStrings()
const;
2603 void setUsesStaticStrings(
bool usesStaticStrings );
2615 QStringList mOptions;
2616 bool mAllowMultiple =
false;
2617 bool mUsesStaticStrings =
false;
2655 bool multiLine =
false,
2656 bool optional =
false );
2661 static QString
typeName() {
return QStringLiteral(
"string" ); }
2672 bool multiLine()
const;
2678 void setMultiLine(
bool multiLine );
2690 bool mMultiLine =
false;
2715 bool optional =
false );
2720 static QString
typeName() {
return QStringLiteral(
"authcfg" ); }
2747 const QString &parentLayerParameterName = QString(),
2748 bool optional =
false );
2753 static QString
typeName() {
return QStringLiteral(
"expression" ); }
2764 QString parentLayerParameterName()
const;
2770 void setParentLayerParameterName(
const QString &parentLayerParameterName );
2782 QString mParentLayerParameterName;
2806 QList< int > dataTypes()
const;
2812 void setDataTypes(
const QList< int > &types );
2835 const QString &description = QString(),
2836 const QList< int > &types = QList< int >(),
2837 const QVariant &defaultValue = QVariant(),
2838 bool optional =
false );
2843 static QString
typeName() {
return QStringLiteral(
"vector" ); }
2875 const QString &description = QString(),
2876 const QVariant &defaultValue = QVariant(),
2877 bool optional =
false );
2882 static QString
typeName() {
return QStringLiteral(
"mesh" ); }
2909 bool optional =
false,
2910 const QList< int > &types = QList< int >() );
2915 static QString
typeName() {
return QStringLiteral(
"layer" ); }
2956 QgsProcessingParameterField(
const QString &name,
const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
2957 const QString &parentLayerParameterName = QString(),
2958 DataType type = Any,
2959 bool allowMultiple =
false,
2960 bool optional =
false,
2961 bool defaultToAllFields =
false );
2966 static QString
typeName() {
return QStringLiteral(
"field" ); }
2979 QString parentLayerParameterName()
const;
2985 void setParentLayerParameterName(
const QString &parentLayerParameterName );
2991 DataType dataType()
const;
2997 void setDataType( DataType type );
3003 bool allowMultiple()
const;
3009 void setAllowMultiple(
bool allowMultiple );
3020 bool defaultToAllFields()
const;
3031 void setDefaultToAllFields(
bool enabled );
3043 QString mParentLayerParameterName;
3044 DataType mDataType = Any;
3045 bool mAllowMultiple =
false;
3046 bool mDefaultToAllFields =
false;
3065 const QList< int > &types = QList< int >(),
3066 const QVariant &defaultValue = QVariant(),
bool optional =
false );
3071 static QString
typeName() {
return QStringLiteral(
"source" ); }
3108 bool optional =
false,
bool createByDefault =
true );
3140 virtual QString defaultFileExtension()
const = 0;
3147 virtual QString generateTemporaryDestination()
const;
3170 bool createByDefault()
const;
3177 void setCreateByDefault(
bool createByDefault );
3202 bool mSupportsNonFileBasedOutputs =
true;
3203 bool mCreateByDefault =
true;
3205 friend class QgsProcessingModelAlgorithm;
3206 friend class TestQgsProcessing;
3207 friend class TestQgsProcessingModelAlgorithm;
3230 bool optional =
false,
bool createByDefault =
true,
bool supportsAppend =
false );
3235 static QString
typeName() {
return QStringLiteral(
"sink" ); }
3242 QString defaultFileExtension() const override;
3243 QString asPythonString(
QgsProcessing::PythonOutputType outputType =
QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const override;
3244 QString createFileFilter() const override;
3251 virtual QStringList supportedOutputVectorLayerExtensions() const;
3263 bool hasGeometry() const;
3279 bool supportsAppend() const;
3289 void setSupportsAppend(
bool supportsAppend );
3291 QVariantMap toVariantMap() const override;
3292 bool fromVariantMap( const QVariantMap &map ) override;
3293 QString generateTemporaryDestination() const override;
3303 bool mSupportsAppend = false;
3328 bool optional =
false,
bool createByDefault =
true );
3333 static QString
typeName() {
return QStringLiteral(
"vectorDestination" ); }
3340 QString defaultFileExtension() const override;
3341 QString asPythonString(
QgsProcessing::PythonOutputType outputType =
QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const override;
3342 QString createFileFilter() const override;
3349 virtual QStringList supportedOutputVectorLayerExtensions() const;
3361 bool hasGeometry() const;
3369 QVariantMap toVariantMap() const override;
3370 bool fromVariantMap( const QVariantMap &map ) override;
3401 const QVariant &defaultValue = QVariant(),
3402 bool optional =
false,
3403 bool createByDefault =
true );
3408 static QString
typeName() {
return QStringLiteral(
"rasterDestination" ); }
3414 QString defaultFileExtension() const override;
3415 QString createFileFilter() const override;
3422 virtual QStringList supportedOutputRasterLayerExtensions() const;
3462 const QString &fileFilter = QString(),
3463 const QVariant &defaultValue = QVariant(),
3464 bool optional =
false,
3465 bool createByDefault =
true );
3470 static QString
typeName() {
return QStringLiteral(
"fileDestination" ); }
3476 QString defaultFileExtension() const override;
3477 QString asPythonString(
QgsProcessing::PythonOutputType outputType =
QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const override;
3478 QString createFileFilter() const override;
3484 QString fileFilter() const;
3490 void setFileFilter( const QString &filter );
3492 QVariantMap toVariantMap() const override;
3493 bool fromVariantMap( const QVariantMap &map ) override;
3503 QString mFileFilter;
3521 const QVariant &defaultValue = QVariant(),
3522 bool optional =
false,
3523 bool createByDefault =
true );
3528 static QString
typeName() {
return QStringLiteral(
"folderDestination" ); }
3533 QString defaultFileExtension() const override;
3555 QgsProcessingParameterBand(
const QString &name,
const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
3556 const QString &parentLayerParameterName = QString(),
3557 bool optional =
false,
3558 bool allowMultiple =
false );
3563 static QString
typeName() {
return QStringLiteral(
"band" ); }
3576 QString parentLayerParameterName()
const;
3582 void setParentLayerParameterName(
const QString &parentLayerParameterName );
3597 bool allowMultiple()
const;
3604 void setAllowMultiple(
bool allowMultiple );
3608 QString mParentLayerParameterName;
3609 bool mAllowMultiple =
false;
3631 bool optional =
false );
3636 static QString
typeName() {
return QStringLiteral(
"layout" ); }
3669 const QString &parentLayoutParameterName = QString(),
3671 bool optional =
false );
3676 static QString
typeName() {
return QStringLiteral(
"layoutitem" ); }
3695 QString parentLayoutParameterName()
const;
3701 void setParentLayoutParameterName(
const QString &name );
3710 int itemType()
const;
3719 void setItemType(
int type );
3722 QString mParentLayoutParameterName;
3744 QgsProcessingParameterColor(
const QString &name,
const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
3745 bool opacityEnabled =
true,
3746 bool optional =
false );
3751 static QString
typeName() {
return QStringLiteral(
"color" ); }
3767 bool opacityEnabled()
const;
3776 void setOpacityEnabled(
bool enabled );
3785 bool mAllowOpacity =
true;
3807 const QString &sourceCrsParameterName = QString(),
const QString &destinationCrsParameterName = QString(),
3808 const QVariant &staticSourceCrs = QVariant(),
const QVariant &staticDestinationCrs = QVariant(),
3809 bool optional =
false );
3814 static QString
typeName() {
return QStringLiteral(
"coordinateoperation" ); }
3888 QString mSourceParameterName;
3889 QString mDestParameterName;
3890 QVariant mSourceCrs;
3913 bool optional =
false );
3918 static QString
typeName() {
return QStringLiteral(
"maptheme" ); }
3964 Type type = DateTime,
3965 const QVariant &defaultValue = QVariant(),
3966 bool optional =
false,
3967 const QDateTime &minValue = QDateTime(),
3968 const QDateTime &maxValue = QDateTime()
3974 static QString
typeName() {
return QStringLiteral(
"datetime" ); }
3979 QString
toolTip()
const override;
3989 QDateTime minimum()
const;
4002 void setMinimum(
const QDateTime &minimum );
4011 QDateTime maximum()
const;
4024 void setMaximum(
const QDateTime &maximum );
4030 Type dataType()
const;
4036 void setDataType( Type type );
4050 Type mDataType = DateTime;
4075 bool optional =
false );
4080 static QString
typeName() {
return QStringLiteral(
"providerconnection" ); }
4109 QString mProviderId;
4135 QgsProcessingParameterDatabaseSchema(
const QString &name,
const QString &description,
const QString &connectionParameterName = QString(),
const QVariant &defaultValue = QVariant(),
4136 bool optional =
false );
4141 static QString
typeName() {
return QStringLiteral(
"databaseschema" ); }
4156 QString parentConnectionParameterName()
const;
4162 void setParentConnectionParameterName(
const QString &name );
4171 QString mParentConnectionParameterName;
4199 const QString &connectionParameterName = QString(),
4200 const QString &schemaParameterName = QString(),
4201 const QVariant &defaultValue = QVariant(),
4202 bool optional =
false,
4203 bool allowNewTableNames =
false );
4208 static QString
typeName() {
return QStringLiteral(
"databasetable" ); }
4223 QString parentConnectionParameterName()
const;
4229 void setParentConnectionParameterName(
const QString &name );
4235 QString parentSchemaParameterName()
const;
4241 void setParentSchemaParameterName(
const QString &name );
4254 bool allowNewTableNames()
const;
4262 void setAllowNewTableNames(
bool allowed );
4266 QString mParentConnectionParameterName;
4267 QString mParentSchemaParameterName;
4268 bool mAllowNewTableNames =
false;
4286 const QVariant &defaultValue = QVariant(),
bool optional =
false );
4291 static QString
typeName() {
return QStringLiteral(
"pointcloud" ); }
4319 const QVariant &defaultValue = QVariant(),
bool optional =
false );
4324 static QString
typeName() {
return QStringLiteral(
"annotation" ); }
4354 const QVariant &defaultValue = QVariant(),
4355 bool optional =
false,
4356 bool createByDefault =
true );
4361 static QString
typeName() {
return QStringLiteral(
"pointCloudDestination" ); }
4367 QString defaultFileExtension() const override;
4368 QString createFileFilter() const override;
4374 virtual QStringList supportedOutputPointCloudLayerExtensions() const;
4384 #endif // QGSPROCESSINGPARAMETERS_H