QGIS API Documentation  3.6.0-Noosa (5873452)
qgsprocessingparameters.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingparameters.h
3  -------------------------
4  begin : April 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSPROCESSINGPARAMETERS_H
19 #define QGSPROCESSINGPARAMETERS_H
20 
21 #include "qgis_core.h"
22 #include "qgis.h"
23 #include "qgsprocessing.h"
24 #include "qgsproperty.h"
26 #include "qgsfeaturesource.h"
27 #include "qgsprocessingutils.h"
28 #include <QMap>
29 #include <limits>
30 
33 class QgsRasterLayer;
34 class QgsMeshLayer;
35 class QgsVectorLayer;
36 class QgsFeatureSink;
41 
52 {
53  public:
54 
58  QgsProcessingFeatureSourceDefinition( const QString &source = QString(), bool selectedFeaturesOnly = false )
59  : source( QgsProperty::fromValue( source ) )
60  , selectedFeaturesOnly( selectedFeaturesOnly )
61  {}
62 
66  QgsProcessingFeatureSourceDefinition( const QgsProperty &source, bool selectedFeaturesOnly = false )
67  : source( source )
68  , selectedFeaturesOnly( selectedFeaturesOnly )
69  {}
70 
75 
80 
82  {
83  return source == other.source && selectedFeaturesOnly == other.selectedFeaturesOnly;
84  }
85 
87  {
88  return !( *this == other );
89  }
90 
92  operator QVariant() const
93  {
94  return QVariant::fromValue( *this );
95  }
96 
97 };
98 
100 
101 
111 {
112  public:
113 
119  QgsProcessingOutputLayerDefinition( const QString &sink = QString(), QgsProject *destinationProject = nullptr )
120  : sink( QgsProperty::fromValue( sink ) )
121  , destinationProject( destinationProject )
122  {}
123 
129  QgsProcessingOutputLayerDefinition( const QgsProperty &sink, QgsProject *destinationProject = nullptr )
130  : sink( sink )
131  , destinationProject( destinationProject )
132  {}
133 
138 
144  QgsProject *destinationProject = nullptr;
145 
150 
157  QVariantMap createOptions;
158 
165  QVariant toVariant() const;
166 
173  bool loadVariant( const QVariantMap &map );
174 
176  operator QVariant() const
177  {
178  return QVariant::fromValue( *this );
179  }
180 
181 };
182 
183 Q_DECLARE_METATYPE( QgsProcessingOutputLayerDefinition )
184 
185 
186 
187 
188 //
189 // Parameter definitions
190 //
191 
192 
205 {
206 
207 #ifdef SIP_RUN
209  if ( sipCpp->type() == QgsProcessingParameterBoolean::typeName() )
210  sipType = sipType_QgsProcessingParameterBoolean;
211  else if ( sipCpp->type() == QgsProcessingParameterCrs::typeName() )
212  sipType = sipType_QgsProcessingParameterCrs;
213  else if ( sipCpp->type() == QgsProcessingParameterMapLayer::typeName() )
214  sipType = sipType_QgsProcessingParameterMapLayer;
215  else if ( sipCpp->type() == QgsProcessingParameterExtent::typeName() )
216  sipType = sipType_QgsProcessingParameterExtent;
217  else if ( sipCpp->type() == QgsProcessingParameterPoint::typeName() )
218  sipType = sipType_QgsProcessingParameterPoint;
219  else if ( sipCpp->type() == QgsProcessingParameterFile::typeName() )
220  sipType = sipType_QgsProcessingParameterFile;
221  else if ( sipCpp->type() == QgsProcessingParameterMatrix::typeName() )
222  sipType = sipType_QgsProcessingParameterMatrix;
223  else if ( sipCpp->type() == QgsProcessingParameterMultipleLayers::typeName() )
224  sipType = sipType_QgsProcessingParameterMultipleLayers;
225  else if ( sipCpp->type() == QgsProcessingParameterNumber::typeName() )
226  sipType = sipType_QgsProcessingParameterNumber;
227  else if ( sipCpp->type() == QgsProcessingParameterDistance::typeName() )
228  sipType = sipType_QgsProcessingParameterDistance;
229  else if ( sipCpp->type() == QgsProcessingParameterRange::typeName() )
230  sipType = sipType_QgsProcessingParameterRange;
231  else if ( sipCpp->type() == QgsProcessingParameterRasterLayer::typeName() )
232  sipType = sipType_QgsProcessingParameterRasterLayer;
233  else if ( sipCpp->type() == QgsProcessingParameterMeshLayer::typeName() )
234  sipType = sipType_QgsProcessingParameterMeshLayer;
235  else if ( sipCpp->type() == QgsProcessingParameterEnum::typeName() )
236  sipType = sipType_QgsProcessingParameterEnum;
237  else if ( sipCpp->type() == QgsProcessingParameterString::typeName() )
238  sipType = sipType_QgsProcessingParameterString;
239  else if ( sipCpp->type() == QgsProcessingParameterExpression::typeName() )
240  sipType = sipType_QgsProcessingParameterExpression;
241  else if ( sipCpp->type() == QgsProcessingParameterAuthConfig::typeName() )
242  sipType = sipType_QgsProcessingParameterAuthConfig;
243  else if ( sipCpp->type() == QgsProcessingParameterVectorLayer::typeName() )
244  sipType = sipType_QgsProcessingParameterVectorLayer;
245  else if ( sipCpp->type() == QgsProcessingParameterField::typeName() )
246  sipType = sipType_QgsProcessingParameterField;
247  else if ( sipCpp->type() == QgsProcessingParameterFeatureSource::typeName() )
248  sipType = sipType_QgsProcessingParameterFeatureSource;
249  else if ( sipCpp->type() == QgsProcessingParameterFeatureSink::typeName() )
250  sipType = sipType_QgsProcessingParameterFeatureSink;
251  else if ( sipCpp->type() == QgsProcessingParameterVectorDestination::typeName() )
252  sipType = sipType_QgsProcessingParameterVectorDestination;
253  else if ( sipCpp->type() == QgsProcessingParameterRasterDestination::typeName() )
254  sipType = sipType_QgsProcessingParameterRasterDestination;
255  else if ( sipCpp->type() == QgsProcessingParameterFileDestination::typeName() )
256  sipType = sipType_QgsProcessingParameterFileDestination;
257  else if ( sipCpp->type() == QgsProcessingParameterFolderDestination::typeName() )
258  sipType = sipType_QgsProcessingParameterFolderDestination;
259  else if ( sipCpp->type() == QgsProcessingParameterBand::typeName() )
260  sipType = sipType_QgsProcessingParameterBand;
261  else
262  sipType = nullptr;
263  SIP_END
264 #endif
265 
266  public:
267 
269  enum Flag
270  {
271  FlagAdvanced = 1 << 1,
272  FlagHidden = 1 << 2,
273  FlagOptional = 1 << 3,
274  FlagIsModelOutput = 1 << 4,
275  };
276  Q_DECLARE_FLAGS( Flags, Flag )
277 
278 
281  QgsProcessingParameterDefinition( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
282  bool optional = false );
283 
284  virtual ~QgsProcessingParameterDefinition() = default;
285 
289  virtual QgsProcessingParameterDefinition *clone() const = 0 SIP_FACTORY;
290 
294  virtual QString type() const = 0;
295 
301  virtual bool isDestination() const { return false; }
302 
308  QString name() const { return mName; }
309 
315  void setName( const QString &name ) { mName = name; }
316 
322  QString description() const { return mDescription; }
323 
329  void setDescription( const QString &description ) { mDescription = description; }
330 
335  QVariant defaultValue() const { return mDefault; }
336 
342  void setDefaultValue( const QVariant &value ) { mDefault = value; }
343 
348  Flags flags() const { return mFlags; }
349 
354  void setFlags( Flags flags ) { mFlags = flags; }
355 
363  virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const;
364 
369  virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;
370 
375  virtual QString asScriptCode() const;
376 
386  virtual QString asPythonString( QgsProcessing::PythonOutputType outputType = QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const;
387 
393  virtual QVariantMap toVariantMap() const;
394 
400  virtual bool fromVariantMap( const QVariantMap &map );
401 
408  SIP_SKIP QVariantMap metadata() const { return mMetadata; }
409 
415  QVariantMap &metadata() { return mMetadata; }
416 
422  void setMetadata( const QVariantMap &metadata ) { mMetadata = metadata; }
423 
428  virtual QStringList dependsOnOtherParameters() const { return QStringList(); }
429 
436 
442  QgsProcessingProvider *provider() const;
443 
448  virtual QString toolTip() const;
449 
457  bool isDynamic() const { return mIsDynamic; }
458 
466  void setIsDynamic( bool dynamic ) { mIsDynamic = dynamic; }
467 
474  QgsPropertyDefinition dynamicPropertyDefinition() const { return mPropertyDefinition; }
475 
482  void setDynamicPropertyDefinition( const QgsPropertyDefinition &definition ) { mPropertyDefinition = definition; }
483 
495  QString dynamicLayerParameterName() const { return mDynamicLayerParameterName; }
496 
508  void setDynamicLayerParameterName( const QString &name ) { mDynamicLayerParameterName = name; }
509 
510  protected:
511 
513  QString mName;
514 
516  QString mDescription;
517 
519  QVariant mDefault;
520 
522  Flags mFlags;
523 
525  QVariantMap mMetadata;
526 
528  QgsProcessingAlgorithm *mAlgorithm = nullptr;
529 
531  bool mIsDynamic = false;
532 
535 
538 
539  // To allow access to mAlgorithm. We don't want a public setter for this!
541 
542 };
543 
544 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingParameterDefinition::Flags )
545 
546 typedef QList< const QgsProcessingParameterDefinition * > QgsProcessingParameterDefinitions;
548 
567 class CORE_EXPORT QgsProcessingParameters
568 {
569 
570  public:
571 
576  static bool isDynamic( const QVariantMap &parameters, const QString &name );
577 
581  static QString parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
582 
587  static QString parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
588 
592  static QString parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
593 
598  static QString parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
599 
603  static double parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
604 
609  static double parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
610 
614  static int parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
615 
620  static int parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
621 
626  static QList<int> parameterAsInts( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
627 
632  static QList<int> parameterAsInts( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
633 
637  static int parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
638 
643  static int parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
644 
648  static QList<int> parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
649 
654  static QList<int> parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
655 
659  static bool parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
660 
665  static bool parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
666 
680  static QgsFeatureSink *parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters,
681  const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs,
682  QgsProcessingContext &context, QString &destinationIdentifier SIP_OUT, QgsFeatureSink::SinkFlags sinkFlags = nullptr ) SIP_FACTORY;
683 
699  static QgsFeatureSink *parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariant &value,
700  const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs,
701  QgsProcessingContext &context, QString &destinationIdentifier SIP_OUT, QgsFeatureSink::SinkFlags sinkFlags = nullptr ) SIP_FACTORY;
702 
711  static QgsProcessingFeatureSource *parameterAsSource( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context ) SIP_FACTORY;
712 
723  static QgsProcessingFeatureSource *parameterAsSource( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context ) SIP_FACTORY;
724 
737  static QString parameterAsCompatibleSourceLayerPath( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters,
738  QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat = QString( "shp" ), QgsProcessingFeedback *feedback = nullptr );
739 
747  static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
748 
758  static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
759 
767  static QgsRasterLayer *parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
768 
778  static QgsRasterLayer *parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
779 
783  static QString parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
784 
789  static QString parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
790 
794  static QString parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
795 
800  static QString parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
801 
809  static QgsVectorLayer *parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
810 
820  static QgsVectorLayer *parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
821 
831  static QgsMeshLayer *parameterAsMeshLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
832 
842  static QgsMeshLayer *parameterAsMeshLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
843 
844 
848  static QgsCoordinateReferenceSystem parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
849 
854  static QgsCoordinateReferenceSystem parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
855 
865  static QgsRectangle parameterAsExtent( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context,
867 
879  static QgsRectangle parameterAsExtent( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context,
881 
893  static QgsGeometry parameterAsExtentGeometry( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context,
895 
901  static QgsCoordinateReferenceSystem parameterAsExtentCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
902 
910  static QgsPointXY parameterAsPoint( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context,
912 
921  static QgsPointXY parameterAsPoint( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context,
923 
929  static QgsCoordinateReferenceSystem parameterAsPointCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
930 
934  static QString parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
935 
940  static QString parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
941 
946  static QVariantList parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
947 
953  static QVariantList parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
954 
958  static QList< QgsMapLayer *> parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
959 
964  static QList< QgsMapLayer *> parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
965 
969  static QList<double> parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
970 
975  static QList<double> parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
976 
980  static QStringList parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
981 
986  static QStringList parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
987 
993  static QgsProcessingParameterDefinition *parameterFromVariantMap( const QVariantMap &map ) SIP_FACTORY;
994 
998  static QString descriptionFromName( const QString &name );
999 
1005  static QgsProcessingParameterDefinition *parameterFromScriptCode( const QString &code ) SIP_FACTORY;
1006 
1007  private:
1008 
1009  static bool parseScriptCodeParameterOptions( const QString &code, bool &isOptional, QString &name, QString &type, QString &definition );
1010 };
1011 
1012 
1013 
1020 class CORE_EXPORT QgsProcessingParameterBoolean : public QgsProcessingParameterDefinition
1021 {
1022  public:
1023 
1027  QgsProcessingParameterBoolean( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1028  bool optional = false );
1029 
1033  static QString typeName() { return QStringLiteral( "boolean" ); }
1034  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1035  QString type() const override { return typeName(); }
1036  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1037  QString asScriptCode() const override;
1038 
1042  static QgsProcessingParameterBoolean *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1043 };
1044 
1051 class CORE_EXPORT QgsProcessingParameterCrs : public QgsProcessingParameterDefinition
1052 {
1053  public:
1054 
1058  QgsProcessingParameterCrs( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1059  bool optional = false );
1060 
1064  static QString typeName() { return QStringLiteral( "crs" ); }
1065  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1066  QString type() const override { return typeName(); }
1067  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1068  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1069 
1073  static QgsProcessingParameterCrs *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1074 
1075 };
1076 
1083 class CORE_EXPORT QgsProcessingParameterMapLayer : public QgsProcessingParameterDefinition
1084 {
1085  public:
1086 
1090  QgsProcessingParameterMapLayer( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1091  bool optional = false );
1092 
1096  static QString typeName() { return QStringLiteral( "layer" ); }
1097  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1098  QString type() const override { return typeName(); }
1099  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1100  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1101 
1105  static QgsProcessingParameterMapLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1106 
1107 };
1108 
1115 class CORE_EXPORT QgsProcessingParameterExtent : public QgsProcessingParameterDefinition
1116 {
1117  public:
1118 
1122  QgsProcessingParameterExtent( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1123  bool optional = false );
1124 
1128  static QString typeName() { return QStringLiteral( "extent" ); }
1129  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1130  QString type() const override { return typeName(); }
1131  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1132  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1133 
1137  static QgsProcessingParameterExtent *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1138 
1139 };
1140 
1141 
1148 class CORE_EXPORT QgsProcessingParameterPoint : public QgsProcessingParameterDefinition
1149 {
1150  public:
1151 
1155  QgsProcessingParameterPoint( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1156  bool optional = false );
1157 
1161  static QString typeName() { return QStringLiteral( "point" ); }
1162  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1163  QString type() const override { return typeName(); }
1164  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1165  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1166 
1170  static QgsProcessingParameterPoint *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1171 
1172 };
1173 
1180 class CORE_EXPORT QgsProcessingParameterFile : public QgsProcessingParameterDefinition
1181 {
1182  public:
1183 
1186  {
1187  File = 0,
1189  };
1190 
1194  QgsProcessingParameterFile( const QString &name, const QString &description = QString(), Behavior behavior = File, const QString &extension = QString(), const QVariant &defaultValue = QVariant(),
1195  bool optional = false );
1196 
1200  static QString typeName() { return QStringLiteral( "file" ); }
1201  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1202  QString type() const override { return typeName(); }
1203  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1204  QString asScriptCode() const override;
1206 
1211  Behavior behavior() const { return mBehavior; }
1212 
1217  void setBehavior( Behavior behavior ) { mBehavior = behavior; }
1218 
1223  QString extension() const { return mExtension; }
1224 
1229  void setExtension( const QString &extension ) { mExtension = extension; }
1230 
1231  QVariantMap toVariantMap() const override;
1232  bool fromVariantMap( const QVariantMap &map ) override;
1233 
1237  static QgsProcessingParameterFile *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition, Behavior behavior = File ) SIP_FACTORY;
1238 
1239  private:
1240 
1241  Behavior mBehavior = File;
1242  QString mExtension;
1243 };
1244 
1251 class CORE_EXPORT QgsProcessingParameterMatrix : public QgsProcessingParameterDefinition
1252 {
1253  public:
1254 
1258  QgsProcessingParameterMatrix( const QString &name, const QString &description = QString(), int numberRows = 3,
1259  bool hasFixedNumberRows = false, const QStringList &headers = QStringList(),
1260  const QVariant &defaultValue = QVariant(),
1261  bool optional = false );
1262 
1266  static QString typeName() { return QStringLiteral( "matrix" ); }
1267  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1268  QString type() const override { return typeName(); }
1269  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1270  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1272 
1277  QStringList headers() const;
1278 
1283  void setHeaders( const QStringList &headers );
1284 
1291  int numberRows() const;
1292 
1299  void setNumberRows( int rows );
1300 
1306  bool hasFixedNumberRows() const;
1307 
1313  void setHasFixedNumberRows( bool hasFixedNumberRows );
1314 
1315  QVariantMap toVariantMap() const override;
1316  bool fromVariantMap( const QVariantMap &map ) override;
1317 
1321  static QgsProcessingParameterMatrix *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1322 
1323  private:
1324 
1325  QStringList mHeaders;
1326  int mNumberRows = 3;
1327  bool mFixedNumberRows = false;
1328 
1329 };
1330 
1337 class CORE_EXPORT QgsProcessingParameterMultipleLayers : public QgsProcessingParameterDefinition
1338 {
1339  public:
1340 
1344  QgsProcessingParameterMultipleLayers( const QString &name, const QString &description = QString(), QgsProcessing::SourceType layerType = QgsProcessing::TypeVectorAnyGeometry,
1345  const QVariant &defaultValue = QVariant(),
1346  bool optional = false );
1347 
1351  static QString typeName() { return QStringLiteral( "multilayer" ); }
1352  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1353  QString type() const override { return typeName(); }
1354  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1355  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1356  QString asScriptCode() const override;
1358 
1363  QgsProcessing::SourceType layerType() const;
1364 
1369  void setLayerType( QgsProcessing::SourceType type );
1370 
1376  int minimumNumberInputs() const;
1377 
1383  void setMinimumNumberInputs( int minimum );
1384 
1385  QVariantMap toVariantMap() const override;
1386  bool fromVariantMap( const QVariantMap &map ) override;
1387 
1391  static QgsProcessingParameterMultipleLayers *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1392 
1393  private:
1394 
1396  int mMinimumNumberInputs = 0;
1397 
1398 };
1399 
1418 class CORE_EXPORT QgsProcessingParameterNumber : public QgsProcessingParameterDefinition
1419 {
1420  public:
1421 
1423  enum Type
1424  {
1427  };
1428 
1432  explicit QgsProcessingParameterNumber( const QString &name, const QString &description = QString(),
1433  Type type = Integer,
1434  const QVariant &defaultValue = QVariant(),
1435  bool optional = false,
1436  double minValue = std::numeric_limits<double>::lowest() + 1,
1437  double maxValue = std::numeric_limits<double>::max()
1438  );
1439 
1443  static QString typeName() { return QStringLiteral( "number" ); }
1444  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1445  QString type() const override { return typeName(); }
1446  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1447  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1448  QString toolTip() const override;
1450 
1455  double minimum() const;
1456 
1461  void setMinimum( double minimum );
1462 
1467  double maximum() const;
1468 
1473  void setMaximum( double maximum );
1474 
1479  Type dataType() const;
1480 
1485  void setDataType( Type type );
1486 
1487  QVariantMap toVariantMap() const override;
1488  bool fromVariantMap( const QVariantMap &map ) override;
1489 
1493  static QgsProcessingParameterNumber *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1494 
1495  private:
1496 
1497  double mMin = std::numeric_limits<double>::lowest() + 1;
1498  double mMax = std::numeric_limits<double>::max();
1499  Type mDataType = Integer;
1500 };
1501 
1522 {
1523  public:
1524 
1528  explicit QgsProcessingParameterDistance( const QString &name, const QString &description = QString(),
1529  const QVariant &defaultValue = QVariant(),
1530  const QString &parentParameterName = QString(),
1531  bool optional = false,
1532  double minValue = std::numeric_limits<double>::lowest() + 1,
1533  double maxValue = std::numeric_limits<double>::max() );
1534 
1538  static QString typeName() { return QStringLiteral( "distance" ); }
1539 
1541 
1542  QString type() const override;
1543  QStringList dependsOnOtherParameters() const override;
1545 
1550  QString parentParameterName() const;
1551 
1556  void setParentParameterName( const QString &parentParameterName );
1557 
1564  QgsUnitTypes::DistanceUnit defaultUnit() const { return mDefaultUnit; }
1565 
1572  void setDefaultUnit( QgsUnitTypes::DistanceUnit unit ) { mDefaultUnit = unit; }
1573 
1574  QVariantMap toVariantMap() const override;
1575  bool fromVariantMap( const QVariantMap &map ) override;
1576 
1577  private:
1578 
1579  QString mParentParameterName;
1581 
1582 };
1583 
1590 class CORE_EXPORT QgsProcessingParameterRange : public QgsProcessingParameterDefinition
1591 {
1592  public:
1593 
1597  QgsProcessingParameterRange( const QString &name, const QString &description = QString(),
1599  const QVariant &defaultValue = QVariant(),
1600  bool optional = false );
1601 
1605  static QString typeName() { return QStringLiteral( "range" ); }
1606  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1607  QString type() const override { return typeName(); }
1608  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1609  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1611 
1616  QgsProcessingParameterNumber::Type dataType() const;
1617 
1622  void setDataType( QgsProcessingParameterNumber::Type dataType );
1623 
1624  QVariantMap toVariantMap() const override;
1625  bool fromVariantMap( const QVariantMap &map ) override;
1626 
1630  static QgsProcessingParameterRange *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1631 
1632  private:
1633 
1635 };
1636 
1643 class CORE_EXPORT QgsProcessingParameterRasterLayer : public QgsProcessingParameterDefinition
1644 {
1645  public:
1646 
1650  QgsProcessingParameterRasterLayer( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1651  bool optional = false );
1652 
1656  static QString typeName() { return QStringLiteral( "raster" ); }
1657  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1658  QString type() const override { return typeName(); }
1659  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1660  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1661 
1665  static QgsProcessingParameterRasterLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1666 
1667 };
1668 
1675 class CORE_EXPORT QgsProcessingParameterEnum : public QgsProcessingParameterDefinition
1676 {
1677  public:
1678 
1682  QgsProcessingParameterEnum( const QString &name, const QString &description = QString(), const QStringList &options = QStringList(),
1683  bool allowMultiple = false,
1684  const QVariant &defaultValue = QVariant(),
1685  bool optional = false );
1686 
1690  static QString typeName() { return QStringLiteral( "enum" ); }
1691  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1692  QString type() const override { return typeName(); }
1693  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1694  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1695  QString asScriptCode() const override;
1697 
1702  QStringList options() const;
1703 
1708  void setOptions( const QStringList &options );
1709 
1714  bool allowMultiple() const;
1715 
1720  void setAllowMultiple( bool allowMultiple );
1721 
1722  QVariantMap toVariantMap() const override;
1723  bool fromVariantMap( const QVariantMap &map ) override;
1724 
1728  static QgsProcessingParameterEnum *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1729 
1730  private:
1731 
1732  QStringList mOptions;
1733  bool mAllowMultiple = false;
1734 
1735 };
1736 
1743 class CORE_EXPORT QgsProcessingParameterString : public QgsProcessingParameterDefinition
1744 {
1745  public:
1746 
1750  QgsProcessingParameterString( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1751  bool multiLine = false,
1752  bool optional = false );
1753 
1757  static QString typeName() { return QStringLiteral( "string" ); }
1758  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1759  QString type() const override { return typeName(); }
1760  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1761  QString asScriptCode() const override;
1763 
1768  bool multiLine() const;
1769 
1774  void setMultiLine( bool multiLine );
1775 
1776  QVariantMap toVariantMap() const override;
1777  bool fromVariantMap( const QVariantMap &map ) override;
1778 
1782  static QgsProcessingParameterString *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1783 
1784  private:
1785 
1786  bool mMultiLine = false;
1787 
1788 };
1789 
1790 
1803 class CORE_EXPORT QgsProcessingParameterAuthConfig : public QgsProcessingParameterDefinition
1804 {
1805  public:
1806 
1810  QgsProcessingParameterAuthConfig( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1811  bool optional = false );
1812 
1816  static QString typeName() { return QStringLiteral( "authcfg" ); }
1817  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1818  QString type() const override { return typeName(); }
1819  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1820  QString asScriptCode() const override;
1821 
1825  static QgsProcessingParameterAuthConfig *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1826 
1827 };
1828 
1835 class CORE_EXPORT QgsProcessingParameterExpression : public QgsProcessingParameterDefinition
1836 {
1837  public:
1838 
1842  QgsProcessingParameterExpression( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1843  const QString &parentLayerParameterName = QString(),
1844  bool optional = false );
1845 
1849  static QString typeName() { return QStringLiteral( "expression" ); }
1850  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1851  QString type() const override { return typeName(); }
1852  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1853  QStringList dependsOnOtherParameters() const override;
1855 
1860  QString parentLayerParameterName() const;
1861 
1866  void setParentLayerParameterName( const QString &parentLayerParameterName );
1867 
1868  QVariantMap toVariantMap() const override;
1869  bool fromVariantMap( const QVariantMap &map ) override;
1870 
1874  static QgsProcessingParameterExpression *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1875 
1876  private:
1877 
1878  QString mParentLayerParameterName;
1879 
1880 };
1881 
1882 
1890 {
1891  public:
1892 
1896  QgsProcessingParameterLimitedDataTypes( const QList< int > &types = QList< int >() );
1897 
1902  QList< int > dataTypes() const;
1903 
1908  void setDataTypes( const QList< int > &types );
1909 
1910  protected:
1911 
1913  QList< int > mDataTypes;
1914 };
1915 
1923 class CORE_EXPORT QgsProcessingParameterVectorLayer : public QgsProcessingParameterDefinition, public QgsProcessingParameterLimitedDataTypes
1924 {
1925  public:
1926 
1930  QgsProcessingParameterVectorLayer( const QString &name,
1931  const QString &description = QString(),
1932  const QList< int > &types = QList< int >(),
1933  const QVariant &defaultValue = QVariant(),
1934  bool optional = false );
1935 
1939  static QString typeName() { return QStringLiteral( "vector" ); }
1940  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1941  QString type() const override { return typeName(); }
1942  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1943  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1945 
1946  QVariantMap toVariantMap() const override;
1947  bool fromVariantMap( const QVariantMap &map ) override;
1948 
1952  static QgsProcessingParameterVectorLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1953 
1954 };
1955 
1962 class CORE_EXPORT QgsProcessingParameterMeshLayer : public QgsProcessingParameterDefinition
1963 {
1964  public:
1965 
1969  QgsProcessingParameterMeshLayer( const QString &name,
1970  const QString &description = QString(),
1971  const QVariant &defaultValue = QVariant(),
1972  bool optional = false );
1973 
1977  static QString typeName() { return QStringLiteral( "mesh" ); }
1978  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1979  QString type() const override { return typeName(); }
1980  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1981  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1982 
1986  static QgsProcessingParameterMeshLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1987 };
1988 
1995 class CORE_EXPORT QgsProcessingParameterField : public QgsProcessingParameterDefinition
1996 {
1997  public:
1998 
2001  {
2002  Any = -1,
2003  Numeric = 0,
2004  String = 1,
2005  DateTime = 2
2006  };
2007 
2011  QgsProcessingParameterField( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
2012  const QString &parentLayerParameterName = QString(),
2013  DataType type = Any,
2014  bool allowMultiple = false,
2015  bool optional = false );
2016 
2020  static QString typeName() { return QStringLiteral( "field" ); }
2021  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
2022  QString type() const override { return typeName(); }
2023  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2024  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2025  QString asScriptCode() const override;
2027  QStringList dependsOnOtherParameters() const override;
2028 
2033  QString parentLayerParameterName() const;
2034 
2039  void setParentLayerParameterName( const QString &parentLayerParameterName );
2040 
2045  DataType dataType() const;
2046 
2051  void setDataType( DataType type );
2052 
2057  bool allowMultiple() const;
2058 
2063  void setAllowMultiple( bool allowMultiple );
2064 
2065  QVariantMap toVariantMap() const override;
2066  bool fromVariantMap( const QVariantMap &map ) override;
2067 
2071  static QgsProcessingParameterField *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2072 
2073  private:
2074 
2075  QString mParentLayerParameterName;
2076  DataType mDataType = Any;
2077  bool mAllowMultiple = false;
2078 
2079 };
2080 
2081 
2088 class CORE_EXPORT QgsProcessingParameterFeatureSource : public QgsProcessingParameterDefinition, public QgsProcessingParameterLimitedDataTypes
2089 {
2090  public:
2091 
2095  QgsProcessingParameterFeatureSource( const QString &name, const QString &description = QString(),
2096  const QList< int > &types = QList< int >(),
2097  const QVariant &defaultValue = QVariant(), bool optional = false );
2098 
2102  static QString typeName() { return QStringLiteral( "source" ); }
2103  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
2104  QString type() const override { return typeName(); }
2105  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2106  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2107  QString asScriptCode() const override;
2109 
2110  QVariantMap toVariantMap() const override;
2111  bool fromVariantMap( const QVariantMap &map ) override;
2112 
2116  static QgsProcessingParameterFeatureSource *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2117 
2118 };
2119 
2127 class CORE_EXPORT QgsProcessingDestinationParameter : public QgsProcessingParameterDefinition
2128 {
2129  public:
2130 
2137  QgsProcessingDestinationParameter( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
2138  bool optional = false, bool createByDefault = true );
2139 
2140  bool isDestination() const override { return true; }
2141  QVariantMap toVariantMap() const override;
2142  bool fromVariantMap( const QVariantMap &map ) override;
2144 
2149  virtual QgsProcessingOutputDefinition *toOutputDefinition() const = 0 SIP_FACTORY;
2150 
2156  bool supportsNonFileBasedOutput() const { return mSupportsNonFileBasedOutputs; }
2157 
2163  void setSupportsNonFileBasedOutput( bool supportsNonFileBasedOutput ) { mSupportsNonFileBasedOutputs = supportsNonFileBasedOutput; }
2164 
2169  virtual QString defaultFileExtension() const = 0;
2170 
2176  virtual QString generateTemporaryDestination() const;
2177 
2183  bool createByDefault() const;
2184 
2190  void setCreateByDefault( bool createByDefault );
2191 
2192  protected:
2193 
2202  QgsProcessingProvider *originalProvider() const { return mOriginalProvider; }
2203 
2204  private:
2205 
2213  QgsProcessingProvider *mOriginalProvider = nullptr;
2214 
2215  bool mSupportsNonFileBasedOutputs = true;
2216  bool mCreateByDefault = true;
2217 
2218  friend class QgsProcessingModelAlgorithm;
2219  friend class TestQgsProcessing;
2220 };
2221 
2222 
2232 {
2233  public:
2234 
2241  QgsProcessingParameterFeatureSink( const QString &name, const QString &description = QString(), QgsProcessing::SourceType type = QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue = QVariant(),
2242  bool optional = false, bool createByDefault = true );
2243 
2247  static QString typeName() { return QStringLiteral( "sink" ); }
2248  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
2249  QString type() const override { return typeName(); }
2250  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2251  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2252  QString asScriptCode() const override;
2254  QString defaultFileExtension() const override;
2256 
2262  virtual QStringList supportedOutputVectorLayerExtensions() const;
2263 
2268  QgsProcessing::SourceType dataType() const;
2269 
2274  bool hasGeometry() const;
2275 
2280  void setDataType( QgsProcessing::SourceType type );
2281 
2282  QVariantMap toVariantMap() const override;
2283  bool fromVariantMap( const QVariantMap &map ) override;
2284  QString generateTemporaryDestination() const override;
2285 
2289  static QgsProcessingParameterFeatureSink *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2290 
2291  private:
2292 
2294 };
2295 
2296 
2308 {
2309  public:
2310 
2317  QgsProcessingParameterVectorDestination( const QString &name, const QString &description = QString(), QgsProcessing::SourceType type = QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue = QVariant(),
2318  bool optional = false, bool createByDefault = true );
2319 
2323  static QString typeName() { return QStringLiteral( "vectorDestination" ); }
2324  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
2325  QString type() const override { return typeName(); }
2326  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2327  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2328  QString asScriptCode() const override;
2330  QString defaultFileExtension() const override;
2332 
2338  virtual QStringList supportedOutputVectorLayerExtensions() const;
2339 
2344  QgsProcessing::SourceType dataType() const;
2345 
2350  bool hasGeometry() const;
2351 
2356  void setDataType( QgsProcessing::SourceType type );
2357 
2358  QVariantMap toVariantMap() const override;
2359  bool fromVariantMap( const QVariantMap &map ) override;
2360 
2364  static QgsProcessingParameterVectorDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2365 
2366 
2367  private:
2368 
2370 };
2371 
2380 {
2381  public:
2382 
2389  QgsProcessingParameterRasterDestination( const QString &name, const QString &description = QString(),
2390  const QVariant &defaultValue = QVariant(),
2391  bool optional = false,
2392  bool createByDefault = true );
2393 
2397  static QString typeName() { return QStringLiteral( "rasterDestination" ); }
2398  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
2399  QString type() const override { return typeName(); }
2400  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2401  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2403  QString defaultFileExtension() const override;
2404 
2410  virtual QStringList supportedOutputRasterLayerExtensions() const;
2411 
2415  static QgsProcessingParameterRasterDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2416 };
2417 
2426 {
2427  public:
2428 
2435  QgsProcessingParameterFileDestination( const QString &name, const QString &description = QString(),
2436  const QString &fileFilter = QString(),
2437  const QVariant &defaultValue = QVariant(),
2438  bool optional = false,
2439  bool createByDefault = true );
2440 
2444  static QString typeName() { return QStringLiteral( "fileDestination" ); }
2445  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
2446  QString type() const override { return typeName(); }
2447  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2448  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2450  QString defaultFileExtension() const override;
2452 
2457  QString fileFilter() const;
2458 
2463  void setFileFilter( const QString &filter );
2464 
2465  QVariantMap toVariantMap() const override;
2466  bool fromVariantMap( const QVariantMap &map ) override;
2467 
2471  static QgsProcessingParameterFileDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2472 
2473 
2474  private:
2475 
2476  QString mFileFilter;
2477 };
2478 
2488 {
2489  public:
2490 
2494  QgsProcessingParameterFolderDestination( const QString &name, const QString &description = QString(),
2495  const QVariant &defaultValue = QVariant(),
2496  bool optional = false );
2497 
2501  static QString typeName() { return QStringLiteral( "folderDestination" ); }
2502  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
2503  QString type() const override { return typeName(); }
2504  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2506  QString defaultFileExtension() const override;
2507 
2511  static QgsProcessingParameterFolderDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2512 
2513 };
2514 
2521 class CORE_EXPORT QgsProcessingParameterBand : public QgsProcessingParameterDefinition
2522 {
2523  public:
2524 
2528  QgsProcessingParameterBand( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
2529  const QString &parentLayerParameterName = QString(),
2530  bool optional = false,
2531  bool allowMultiple = false );
2532 
2536  static QString typeName() { return QStringLiteral( "band" ); }
2537  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
2538  QString type() const override { return typeName(); }
2539  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2540  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2541  QString asScriptCode() const override;
2542  QStringList dependsOnOtherParameters() const override;
2544 
2549  QString parentLayerParameterName() const;
2550 
2555  void setParentLayerParameterName( const QString &parentLayerParameterName );
2556 
2557  QVariantMap toVariantMap() const override;
2558  bool fromVariantMap( const QVariantMap &map ) override;
2559 
2563  static QgsProcessingParameterBand *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2564 
2570  bool allowMultiple() const;
2571 
2577  void setAllowMultiple( bool allowMultiple );
2578 
2579  private:
2580 
2581  QString mParentLayerParameterName;
2582  bool mAllowMultiple = false;
2583 };
2584 
2585 // clazy:excludeall=qstring-allocations
2586 
2587 #endif // QGSPROCESSINGPARAMETERS_H
2588 
2589 
QString type() const override
Unique parameter type name.
QgsProperty sink
Sink/layer definition.
A boolean parameter for processing algorithms.
QList< const QgsProcessingParameterDefinition *> QgsProcessingParameterDefinitions
List of processing parameters.
static QString typeName()
Returns the type name for the parameter class.
QgsPropertyDefinition dynamicPropertyDefinition() const
Returns the property definition for dynamic properties.
An input file or folder parameter for processing algorithms.
A parameter for processing algorithms which accepts multiple map layers.
virtual QString asScriptCode() const
Returns the parameter definition encoded in a string which can be used within a Processing script...
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Base class for all map layer types.
Definition: qgsmaplayer.h:64
QString type() const override
Unique parameter type name.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap & metadata()
Returns the parameter&#39;s freeform metadata.
Base class for providing feedback from a processing algorithm.
virtual bool fromVariantMap(const QVariantMap &map)
Restores this parameter to a QVariantMap.
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm...
QgsProcessingFeatureSourceDefinition(const QString &source=QString(), bool selectedFeaturesOnly=false)
Constructor for QgsProcessingFeatureSourceDefinition, accepting a static string source.
QString type() const override
Unique parameter type name.
QString type() const override
Unique parameter type name.
void setIsDynamic(bool dynamic)
Sets whether the parameter is dynamic, and can support data-defined values (i.e.
QString type() const override
Unique parameter type name.
A vector layer or feature source field parameter for processing algorithms.
void setDynamicLayerParameterName(const QString &name)
Sets the name for the parameter for a layer linked to a dynamic parameter, or an empty string if this...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString type() const override
Unique parameter type name.
QString mDynamicLayerParameterName
Linked vector layer parameter name for dynamic properties.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap metadata() const
Returns the parameter&#39;s freeform metadata.
static QString typeName()
Returns the type name for the parameter class.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
static QString typeName()
Returns the type name for the parameter class.
QString type() const override
Unique parameter type name.
QString type() const override
Unique parameter type name.
A map layer parameter for processing algorithms.
A class to represent a 2D point.
Definition: qgspointxy.h:43
An expression parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
QString type() const override
Unique parameter type name.
virtual QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool isDestination() const override
Returns true if this parameter represents a file or layer destination, e.g.
An interface for objects which accept features via addFeature(s) methods.
PythonOutputType
Available Python output types.
Definition: qgsprocessing.h:58
QgsProcessingProvider * originalProvider() const
Original (source) provider which this parameter has been derived from.
QString type() const override
Unique parameter type name.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap mMetadata
Freeform metadata for parameter. Mostly used by widget wrappers to customize their appearance and beh...
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.
Definition: qgsfields.h:42
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:106
Abstract base class for processing providers.
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
void setFlags(Flags flags)
Sets the flags associated with the parameter.
A raster band parameter for Processing algorithms.
QString type() const override
Unique parameter type name.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsUnitTypes::DistanceUnit defaultUnit() const
Returns the default distance unit for the parameter.
virtual QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QString typeName()
Returns the type name for the parameter class.
QString type() const override
Unique parameter type name.
static QString typeName()
Returns the type name for the parameter class.
void setDefaultUnit(QgsUnitTypes::DistanceUnit unit)
Sets the default distance unit for the parameter.
const QgsCoordinateReferenceSystem & crs
QString type() const override
Unique parameter type name.
static QString typeName()
Returns the type name for the parameter class.
Base class for all parameter definitions which represent file or layer destinations, e.g.
Abstract base class for processing algorithms.
Q_DECLARE_METATYPE(QModelIndex)
A feature sink output for processing algorithms.
bool operator==(const QgsProcessingFeatureSourceDefinition &other)
bool selectedFeaturesOnly
True if only selected features in the source should be used by algorithms.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
A numeric range parameter for processing algorithms.
bool operator!=(const QgsProcessingFeatureSourceDefinition &other)
void setDynamicPropertyDefinition(const QgsPropertyDefinition &definition)
Sets the property definition for dynamic properties.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
Can be inherited by parameters which require limits to their acceptable data types.
A raster layer parameter for processing algorithms.
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:68
void setDescription(const QString &description)
Sets the description for the parameter.
virtual QString toolTip() const
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
QgsProperty source
Source definition.
QString type() const override
Unique parameter type name.
An enum based parameter for processing algorithms, allowing for selection from predefined values...
Flags flags() const
Returns any flags associated with the parameter.
static QString typeName()
Returns the type name for the parameter class.
QVariant defaultValue() const
Returns the default value for the parameter.
#define SIP_SKIP
Definition: qgis_sip.h:119
const QString & typeName
QgsProcessingOutputLayerDefinition(const QgsProperty &sink, QgsProject *destinationProject=nullptr)
Constructor for QgsProcessingOutputLayerDefinition, accepting a QgsProperty sink/layer.
A collection of utilities for working with parameters when running a processing algorithm.
A double numeric parameter for distance values.
QString type() const override
Unique parameter type name.
#define SIP_END
Definition: qgis_sip.h:182
Reads and writes project states.
Definition: qgsproject.h:89
void setDefaultValue(const QVariant &value)
Sets the default value for the parameter.
QString type() const override
Unique parameter type name.
A vector layer (with or without geometry) parameter for processing algorithms.
virtual QString defaultFileExtension() const =0
Returns the default file extension for destination file paths associated with this parameter...
#define SIP_FACTORY
Definition: qgis_sip.h:69
A mesh layer parameter for processing algorithms.
A coordinate reference system parameter for processing algorithms.
A store for object properties.
Definition: qgsproperty.h:229
virtual QStringList dependsOnOtherParameters() const
Returns a list of other parameter names on which this parameter is dependent (e.g.
A rectangular map extent parameter for processing algorithms.
QString type() const override
Unique parameter type name.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
A numeric parameter for processing algorithms.
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
void setExtension(const QString &extension)
Sets a file extension for the parameter.
QString dynamicLayerParameterName() const
Returns the name of the parameter for a layer linked to a dynamic parameter, or an empty string if th...
Definition for a property.
Definition: qgsproperty.h:46
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString name() const
Returns the name of the parameter.
QList< int > mDataTypes
List of acceptable data types for the parameter.
Encapsulates settings relating to a feature source input to a processing algorithm.
bool supportsNonFileBasedOutput() const
Returns true if the destination parameter supports non filed-based outputs, such as memory layers or ...
Behavior behavior() const
Returns the parameter behavior (e.g.
QString type() const override
Unique parameter type name.
virtual bool isDestination() const
Returns true if this parameter represents a file or layer destination, e.g.
DistanceUnit
Units of distance.
Definition: qgsunittypes.h:54
QString extension() const
Returns any specified file extension for the parameter.
QString type() const override
Unique parameter type name.
Base class for the definition of processing outputs.
void setName(const QString &name)
Sets the name of the parameter.
Unknown distance unit.
Definition: qgsunittypes.h:65
A vector layer destination parameter, for specifying the destination path for a vector layer created ...
QString type() const override
Unique parameter type name.
bool isDynamic() const
Returns true if the parameter supports is dynamic, and can support data-defined values (i...
A point parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
An input feature source (such as vector layers) parameter for processing algorithms.
void setMetadata(const QVariantMap &metadata)
Sets the parameter&#39;s freeform metadata.
A folder destination parameter, for specifying the destination path for a folder created by the algor...
QString destinationName
Name to use for sink if it&#39;s to be loaded into a destination project.
#define SIP_OUT
Definition: qgis_sip.h:51
static QString typeName()
Returns the type name for the parameter class.
This class represents a coordinate reference system (CRS).
QgsProcessingOutputLayerDefinition(const QString &sink=QString(), QgsProject *destinationProject=nullptr)
Constructor for QgsProcessingOutputLayerDefinition, accepting a static sink/layer string...
Base class for the definition of processing parameters.
virtual bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const
Checks whether the specified input value is acceptable for the parameter.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:165
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QVariant mDefault
Default value for parameter.
SourceType
Data source types enum.
Definition: qgsprocessing.h:44
QgsPropertyDefinition mPropertyDefinition
Data defined property definition.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingFeatureSourceDefinition(const QgsProperty &source, bool selectedFeaturesOnly=false)
Constructor for QgsProcessingFeatureSourceDefinition, accepting a QgsProperty source.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:89
static QString typeName()
Returns the type name for the parameter class.
virtual QString generateTemporaryDestination() const
Generates a temporary destination value for this parameter.
void setSupportsNonFileBasedOutput(bool supportsNonFileBasedOutput)
Sets whether the destination parameter supports non filed-based outputs, such as memory layers or dir...
static QString typeName()
Returns the type name for the parameter class.
A table (matrix) parameter for processing algorithms.
Full Python QgsProcessingAlgorithm subclass.
Definition: qgsprocessing.h:60
QString type() const override
Unique parameter type name.
A string parameter for authentication configuration configuration ID values.
QString mDescription
Parameter description.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setBehavior(Behavior behavior)
Sets the parameter behavior (e.g.
Represents a vector layer which manages a vector based data sets.
Contains information about the context in which a processing algorithm is executed.
A string parameter for processing algorithms.
QString type() const override
Unique parameter type name.
QString description() const
Returns the description for the parameter.
virtual QgsProcessingParameterDefinition * clone() const =0
Creates a clone of the parameter definition.
virtual QgsProcessingOutputDefinition * toOutputDefinition() const =0
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
Any vector layer with geometry.
Definition: qgsprocessing.h:47
QString type() const override
Unique parameter type name.
QVariantMap createOptions
Map of optional sink/layer creation options, which are passed to the underlying provider when creatin...
QString type() const override
Unique parameter type name.
QString type() const override
Unique parameter type name.
static QString typeName()
Returns the type name for the parameter class.