QGIS API Documentation  3.2.0-Bonn (bc43194)
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 <QMap>
28 #include <limits>
29 
31 class QgsRasterLayer;
32 class QgsVectorLayer;
33 class QgsFeatureSink;
38 
49 {
50  public:
51 
55  QgsProcessingFeatureSourceDefinition( const QString &source = QString(), bool selectedFeaturesOnly = false )
56  : source( QgsProperty::fromValue( source ) )
57  , selectedFeaturesOnly( selectedFeaturesOnly )
58  {}
59 
63  QgsProcessingFeatureSourceDefinition( const QgsProperty &source, bool selectedFeaturesOnly = false )
64  : source( source )
65  , selectedFeaturesOnly( selectedFeaturesOnly )
66  {}
67 
72 
77 
79  {
80  return source == other.source && selectedFeaturesOnly == other.selectedFeaturesOnly;
81  }
82 
84  {
85  return !( *this == other );
86  }
87 
89  operator QVariant() const
90  {
91  return QVariant::fromValue( *this );
92  }
93 
94 };
95 
97 
98 
108 {
109  public:
110 
116  QgsProcessingOutputLayerDefinition( const QString &sink = QString(), QgsProject *destinationProject = nullptr )
117  : sink( QgsProperty::fromValue( sink ) )
118  , destinationProject( destinationProject )
119  {}
120 
126  QgsProcessingOutputLayerDefinition( const QgsProperty &sink, QgsProject *destinationProject = nullptr )
127  : sink( sink )
128  , destinationProject( destinationProject )
129  {}
130 
135 
141  QgsProject *destinationProject = nullptr;
142 
147 
154  QVariantMap createOptions;
155 
162  QVariant toVariant() const;
163 
170  bool loadVariant( const QVariantMap &map );
171 
173  operator QVariant() const
174  {
175  return QVariant::fromValue( *this );
176  }
177 
178 };
179 
180 Q_DECLARE_METATYPE( QgsProcessingOutputLayerDefinition )
181 
182 
183 
184 
185 //
186 // Parameter definitions
187 //
188 
189 
202 {
203 
204 #ifdef SIP_RUN
206  if ( sipCpp->type() == QgsProcessingParameterBoolean::typeName() )
207  sipType = sipType_QgsProcessingParameterBoolean;
208  else if ( sipCpp->type() == QgsProcessingParameterCrs::typeName() )
209  sipType = sipType_QgsProcessingParameterCrs;
210  else if ( sipCpp->type() == QgsProcessingParameterMapLayer::typeName() )
211  sipType = sipType_QgsProcessingParameterMapLayer;
212  else if ( sipCpp->type() == QgsProcessingParameterExtent::typeName() )
213  sipType = sipType_QgsProcessingParameterExtent;
214  else if ( sipCpp->type() == QgsProcessingParameterPoint::typeName() )
215  sipType = sipType_QgsProcessingParameterPoint;
216  else if ( sipCpp->type() == QgsProcessingParameterFile::typeName() )
217  sipType = sipType_QgsProcessingParameterFile;
218  else if ( sipCpp->type() == QgsProcessingParameterMatrix::typeName() )
219  sipType = sipType_QgsProcessingParameterMatrix;
220  else if ( sipCpp->type() == QgsProcessingParameterMultipleLayers::typeName() )
221  sipType = sipType_QgsProcessingParameterMultipleLayers;
222  else if ( sipCpp->type() == QgsProcessingParameterNumber::typeName() )
223  sipType = sipType_QgsProcessingParameterNumber;
224  else if ( sipCpp->type() == QgsProcessingParameterDistance::typeName() )
225  sipType = sipType_QgsProcessingParameterDistance;
226  else if ( sipCpp->type() == QgsProcessingParameterRange::typeName() )
227  sipType = sipType_QgsProcessingParameterRange;
228  else if ( sipCpp->type() == QgsProcessingParameterRasterLayer::typeName() )
229  sipType = sipType_QgsProcessingParameterRasterLayer;
230  else if ( sipCpp->type() == QgsProcessingParameterEnum::typeName() )
231  sipType = sipType_QgsProcessingParameterEnum;
232  else if ( sipCpp->type() == QgsProcessingParameterString::typeName() )
233  sipType = sipType_QgsProcessingParameterString;
234  else if ( sipCpp->type() == QgsProcessingParameterExpression::typeName() )
235  sipType = sipType_QgsProcessingParameterExpression;
236  else if ( sipCpp->type() == QgsProcessingParameterVectorLayer::typeName() )
237  sipType = sipType_QgsProcessingParameterVectorLayer;
238  else if ( sipCpp->type() == QgsProcessingParameterField::typeName() )
239  sipType = sipType_QgsProcessingParameterField;
240  else if ( sipCpp->type() == QgsProcessingParameterFeatureSource::typeName() )
241  sipType = sipType_QgsProcessingParameterFeatureSource;
242  else if ( sipCpp->type() == QgsProcessingParameterFeatureSink::typeName() )
243  sipType = sipType_QgsProcessingParameterFeatureSink;
244  else if ( sipCpp->type() == QgsProcessingParameterVectorDestination::typeName() )
245  sipType = sipType_QgsProcessingParameterVectorDestination;
246  else if ( sipCpp->type() == QgsProcessingParameterRasterDestination::typeName() )
247  sipType = sipType_QgsProcessingParameterRasterDestination;
248  else if ( sipCpp->type() == QgsProcessingParameterFileDestination::typeName() )
249  sipType = sipType_QgsProcessingParameterFileDestination;
250  else if ( sipCpp->type() == QgsProcessingParameterFolderDestination::typeName() )
251  sipType = sipType_QgsProcessingParameterFolderDestination;
252  else if ( sipCpp->type() == QgsProcessingParameterBand::typeName() )
253  sipType = sipType_QgsProcessingParameterBand;
254  else
255  sipType = nullptr;
256  SIP_END
257 #endif
258 
259  public:
260 
262  enum Flag
263  {
264  FlagAdvanced = 1 << 1,
265  FlagHidden = 1 << 2,
266  FlagOptional = 1 << 3,
267  FlagIsModelOutput = 1 << 4,
268  };
269  Q_DECLARE_FLAGS( Flags, Flag )
270 
271 
274  QgsProcessingParameterDefinition( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
275  bool optional = false );
276 
277  virtual ~QgsProcessingParameterDefinition() = default;
278 
282  virtual QgsProcessingParameterDefinition *clone() const = 0 SIP_FACTORY;
283 
287  virtual QString type() const = 0;
288 
294  virtual bool isDestination() const { return false; }
295 
301  QString name() const { return mName; }
302 
308  void setName( const QString &name ) { mName = name; }
309 
315  QString description() const { return mDescription; }
316 
322  void setDescription( const QString &description ) { mDescription = description; }
323 
328  QVariant defaultValue() const { return mDefault; }
329 
335  void setDefaultValue( const QVariant &value ) { mDefault = value; }
336 
341  Flags flags() const { return mFlags; }
342 
347  void setFlags( Flags flags ) { mFlags = flags; }
348 
356  virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const;
357 
363  virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;
364 
369  virtual QString asScriptCode() const;
370 
376  virtual QVariantMap toVariantMap() const;
377 
383  virtual bool fromVariantMap( const QVariantMap &map );
384 
391  SIP_SKIP QVariantMap metadata() const { return mMetadata; }
392 
398  QVariantMap &metadata() { return mMetadata; }
399 
405  void setMetadata( const QVariantMap &metadata ) { mMetadata = metadata; }
406 
411  virtual QStringList dependsOnOtherParameters() const { return QStringList(); }
412 
419 
425  QgsProcessingProvider *provider() const;
426 
431  virtual QString toolTip() const;
432 
440  bool isDynamic() const { return mIsDynamic; }
441 
449  void setIsDynamic( bool dynamic ) { mIsDynamic = dynamic; }
450 
457  QgsPropertyDefinition dynamicPropertyDefinition() const { return mPropertyDefinition; }
458 
465  void setDynamicPropertyDefinition( const QgsPropertyDefinition &definition ) { mPropertyDefinition = definition; }
466 
478  QString dynamicLayerParameterName() const { return mDynamicLayerParameterName; }
479 
491  void setDynamicLayerParameterName( const QString &name ) { mDynamicLayerParameterName = name; }
492 
493  protected:
494 
496  QString mName;
497 
499  QString mDescription;
500 
502  QVariant mDefault;
503 
505  Flags mFlags;
506 
508  QVariantMap mMetadata;
509 
511  QgsProcessingAlgorithm *mAlgorithm = nullptr;
512 
514  bool mIsDynamic = false;
515 
518 
521 
522  // To allow access to mAlgorithm. We don't want a public setter for this!
524 
525 };
526 
527 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingParameterDefinition::Flags )
528 
529 typedef QList< const QgsProcessingParameterDefinition * > QgsProcessingParameterDefinitions;
531 
550 class CORE_EXPORT QgsProcessingParameters
551 {
552 
553  public:
554 
559  static bool isDynamic( const QVariantMap &parameters, const QString &name );
560 
564  static QString parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
565 
569  static QString parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
570 
574  static double parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
575 
579  static int parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
580 
584  static int parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
585 
589  static QList<int> parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
590 
594  static bool parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
595 
609  static QgsFeatureSink *parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters,
610  const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs,
611  QgsProcessingContext &context, QString &destinationIdentifier SIP_OUT ) SIP_FACTORY;
612 
621  static QgsProcessingFeatureSource *parameterAsSource( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context ) SIP_FACTORY;
622 
635  static QString parameterAsCompatibleSourceLayerPath( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters,
636  QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat = QString( "shp" ), QgsProcessingFeedback *feedback = nullptr );
637 
645  static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
646 
654  static QgsRasterLayer *parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
655 
659  static QString parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
660 
664  static QString parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
665 
673  static QgsVectorLayer *parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
674 
678  static QgsCoordinateReferenceSystem parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
679 
689  static QgsRectangle parameterAsExtent( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context,
691 
703  static QgsGeometry parameterAsExtentGeometry( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context,
705 
711  static QgsCoordinateReferenceSystem parameterAsExtentCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
712 
720  static QgsPointXY parameterAsPoint( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context,
722 
728  static QgsCoordinateReferenceSystem parameterAsPointCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
729 
733  static QString parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
734 
739  static QVariantList parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
740 
744  static QList< QgsMapLayer *> parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
745 
749  static QList<double> parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
750 
754  static QStringList parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
755 
761  static QgsProcessingParameterDefinition *parameterFromVariantMap( const QVariantMap &map ) SIP_FACTORY;
762 
766  static QString descriptionFromName( const QString &name );
767 
773  static QgsProcessingParameterDefinition *parameterFromScriptCode( const QString &code ) SIP_FACTORY;
774 
775  private:
776 
777  static bool parseScriptCodeParameterOptions( const QString &code, bool &isOptional, QString &name, QString &type, QString &definition );
778 };
779 
780 
781 
788 class CORE_EXPORT QgsProcessingParameterBoolean : public QgsProcessingParameterDefinition
789 {
790  public:
791 
795  QgsProcessingParameterBoolean( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
796  bool optional = false );
797 
801  static QString typeName() { return QStringLiteral( "boolean" ); }
802  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
803  QString type() const override { return typeName(); }
804  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
805  QString asScriptCode() const override;
806 
810  static QgsProcessingParameterBoolean *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
811 };
812 
819 class CORE_EXPORT QgsProcessingParameterCrs : public QgsProcessingParameterDefinition
820 {
821  public:
822 
826  QgsProcessingParameterCrs( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
827  bool optional = false );
828 
832  static QString typeName() { return QStringLiteral( "crs" ); }
833  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
834  QString type() const override { return typeName(); }
835  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
836  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
837 
841  static QgsProcessingParameterCrs *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
842 
843 };
844 
851 class CORE_EXPORT QgsProcessingParameterMapLayer : public QgsProcessingParameterDefinition
852 {
853  public:
854 
858  QgsProcessingParameterMapLayer( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
859  bool optional = false );
860 
864  static QString typeName() { return QStringLiteral( "layer" ); }
865  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
866  QString type() const override { return typeName(); }
867  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
868  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
869 
873  static QgsProcessingParameterMapLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
874 
875 };
876 
883 class CORE_EXPORT QgsProcessingParameterExtent : public QgsProcessingParameterDefinition
884 {
885  public:
886 
890  QgsProcessingParameterExtent( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
891  bool optional = false );
892 
896  static QString typeName() { return QStringLiteral( "extent" ); }
897  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
898  QString type() const override { return typeName(); }
899  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
900  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
901 
905  static QgsProcessingParameterExtent *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
906 
907 };
908 
909 
916 class CORE_EXPORT QgsProcessingParameterPoint : public QgsProcessingParameterDefinition
917 {
918  public:
919 
923  QgsProcessingParameterPoint( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
924  bool optional = false );
925 
929  static QString typeName() { return QStringLiteral( "point" ); }
930  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
931  QString type() const override { return typeName(); }
932  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
933  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
934 
938  static QgsProcessingParameterPoint *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
939 
940 };
941 
948 class CORE_EXPORT QgsProcessingParameterFile : public QgsProcessingParameterDefinition
949 {
950  public:
951 
953  enum Behavior
954  {
955  File = 0,
957  };
958 
962  QgsProcessingParameterFile( const QString &name, const QString &description = QString(), Behavior behavior = File, const QString &extension = QString(), const QVariant &defaultValue = QVariant(),
963  bool optional = false );
964 
968  static QString typeName() { return QStringLiteral( "file" ); }
969  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
970  QString type() const override { return typeName(); }
971  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
972  QString asScriptCode() const override;
973 
978  Behavior behavior() const { return mBehavior; }
979 
984  void setBehavior( Behavior behavior ) { mBehavior = behavior; }
985 
990  QString extension() const { return mExtension; }
991 
996  void setExtension( const QString &extension ) { mExtension = extension; }
997 
998  QVariantMap toVariantMap() const override;
999  bool fromVariantMap( const QVariantMap &map ) override;
1000 
1004  static QgsProcessingParameterFile *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition, Behavior behavior = File ) SIP_FACTORY;
1005 
1006  private:
1007 
1008  Behavior mBehavior = File;
1009  QString mExtension;
1010 };
1011 
1018 class CORE_EXPORT QgsProcessingParameterMatrix : public QgsProcessingParameterDefinition
1019 {
1020  public:
1021 
1025  QgsProcessingParameterMatrix( const QString &name, const QString &description = QString(), int numberRows = 3,
1026  bool hasFixedNumberRows = false, const QStringList &headers = QStringList(),
1027  const QVariant &defaultValue = QVariant(),
1028  bool optional = false );
1029 
1033  static QString typeName() { return QStringLiteral( "matrix" ); }
1034  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1035  QString type() const override { return typeName(); }
1036  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1037  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1038 
1043  QStringList headers() const;
1044 
1049  void setHeaders( const QStringList &headers );
1050 
1057  int numberRows() const;
1058 
1065  void setNumberRows( int rows );
1066 
1072  bool hasFixedNumberRows() const;
1073 
1079  void setHasFixedNumberRows( bool hasFixedNumberRows );
1080 
1081  QVariantMap toVariantMap() const override;
1082  bool fromVariantMap( const QVariantMap &map ) override;
1083 
1087  static QgsProcessingParameterMatrix *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1088 
1089  private:
1090 
1091  QStringList mHeaders;
1092  int mNumberRows = 3;
1093  bool mFixedNumberRows = false;
1094 
1095 };
1096 
1103 class CORE_EXPORT QgsProcessingParameterMultipleLayers : public QgsProcessingParameterDefinition
1104 {
1105  public:
1106 
1110  QgsProcessingParameterMultipleLayers( const QString &name, const QString &description = QString(), QgsProcessing::SourceType layerType = QgsProcessing::TypeVectorAnyGeometry,
1111  const QVariant &defaultValue = QVariant(),
1112  bool optional = false );
1113 
1117  static QString typeName() { return QStringLiteral( "multilayer" ); }
1118  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1119  QString type() const override { return typeName(); }
1120  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1121  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1122  QString asScriptCode() const override;
1123 
1128  QgsProcessing::SourceType layerType() const;
1129 
1134  void setLayerType( QgsProcessing::SourceType type );
1135 
1141  int minimumNumberInputs() const;
1142 
1148  void setMinimumNumberInputs( int minimum );
1149 
1150  QVariantMap toVariantMap() const override;
1151  bool fromVariantMap( const QVariantMap &map ) override;
1152 
1156  static QgsProcessingParameterMultipleLayers *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1157 
1158  private:
1159 
1161  int mMinimumNumberInputs = 0;
1162 
1163 };
1164 
1171 class CORE_EXPORT QgsProcessingParameterNumber : public QgsProcessingParameterDefinition
1172 {
1173  public:
1174 
1176  enum Type
1177  {
1180  };
1181 
1185  explicit QgsProcessingParameterNumber( const QString &name, const QString &description = QString(),
1186  Type type = Integer,
1187  const QVariant &defaultValue = QVariant(),
1188  bool optional = false,
1189  double minValue = std::numeric_limits<double>::lowest() + 1,
1190  double maxValue = std::numeric_limits<double>::max()
1191  );
1192 
1196  static QString typeName() { return QStringLiteral( "number" ); }
1197  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1198  QString type() const override { return typeName(); }
1199  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1200  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1201  QString toolTip() const override;
1202 
1207  double minimum() const;
1208 
1213  void setMinimum( double minimum );
1214 
1219  double maximum() const;
1220 
1225  void setMaximum( double maximum );
1226 
1231  Type dataType() const;
1232 
1237  void setDataType( Type type );
1238 
1239  QVariantMap toVariantMap() const override;
1240  bool fromVariantMap( const QVariantMap &map ) override;
1241 
1245  static QgsProcessingParameterNumber *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1246 
1247  private:
1248 
1249  double mMin = std::numeric_limits<double>::lowest() + 1;
1250  double mMax = std::numeric_limits<double>::max();
1251  Type mDataType = Integer;
1252 };
1253 
1262 {
1263  public:
1264 
1268  explicit QgsProcessingParameterDistance( const QString &name, const QString &description = QString(),
1269  const QVariant &defaultValue = QVariant(),
1270  const QString &parentParameterName = QString(),
1271  bool optional = false,
1272  double minValue = std::numeric_limits<double>::lowest() + 1,
1273  double maxValue = std::numeric_limits<double>::max() );
1274 
1278  static QString typeName() { return QStringLiteral( "distance" ); }
1279 
1281 
1282  QString type() const override;
1283  QStringList dependsOnOtherParameters() const override;
1284 
1289  QString parentParameterName() const;
1290 
1295  void setParentParameterName( const QString &parentParameterName );
1296 
1297  QVariantMap toVariantMap() const override;
1298  bool fromVariantMap( const QVariantMap &map ) override;
1299 
1300  private:
1301 
1302  QString mParentParameterName;
1303 
1304 };
1305 
1312 class CORE_EXPORT QgsProcessingParameterRange : public QgsProcessingParameterDefinition
1313 {
1314  public:
1315 
1319  QgsProcessingParameterRange( const QString &name, const QString &description = QString(),
1321  const QVariant &defaultValue = QVariant(),
1322  bool optional = false );
1323 
1327  static QString typeName() { return QStringLiteral( "range" ); }
1328  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1329  QString type() const override { return typeName(); }
1330  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1331  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1332 
1337  QgsProcessingParameterNumber::Type dataType() const;
1338 
1343  void setDataType( QgsProcessingParameterNumber::Type dataType );
1344 
1345  QVariantMap toVariantMap() const override;
1346  bool fromVariantMap( const QVariantMap &map ) override;
1347 
1351  static QgsProcessingParameterRange *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1352 
1353  private:
1354 
1356 };
1357 
1364 class CORE_EXPORT QgsProcessingParameterRasterLayer : public QgsProcessingParameterDefinition
1365 {
1366  public:
1367 
1371  QgsProcessingParameterRasterLayer( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1372  bool optional = false );
1373 
1377  static QString typeName() { return QStringLiteral( "raster" ); }
1378  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1379  QString type() const override { return typeName(); }
1380  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1381  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1382 
1386  static QgsProcessingParameterRasterLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1387 
1388 };
1389 
1396 class CORE_EXPORT QgsProcessingParameterEnum : public QgsProcessingParameterDefinition
1397 {
1398  public:
1399 
1403  QgsProcessingParameterEnum( const QString &name, const QString &description = QString(), const QStringList &options = QStringList(),
1404  bool allowMultiple = false,
1405  const QVariant &defaultValue = QVariant(),
1406  bool optional = false );
1407 
1411  static QString typeName() { return QStringLiteral( "enum" ); }
1412  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1413  QString type() const override { return typeName(); }
1414  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1415  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1416  QString asScriptCode() const override;
1417 
1422  QStringList options() const;
1423 
1428  void setOptions( const QStringList &options );
1429 
1434  bool allowMultiple() const;
1435 
1440  void setAllowMultiple( bool allowMultiple );
1441 
1442  QVariantMap toVariantMap() const override;
1443  bool fromVariantMap( const QVariantMap &map ) override;
1444 
1448  static QgsProcessingParameterEnum *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1449 
1450  private:
1451 
1452  QStringList mOptions;
1453  bool mAllowMultiple = false;
1454 
1455 };
1456 
1463 class CORE_EXPORT QgsProcessingParameterString : public QgsProcessingParameterDefinition
1464 {
1465  public:
1466 
1470  QgsProcessingParameterString( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1471  bool multiLine = false,
1472  bool optional = false );
1473 
1477  static QString typeName() { return QStringLiteral( "string" ); }
1478  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1479  QString type() const override { return typeName(); }
1480  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1481  QString asScriptCode() const override;
1482 
1487  bool multiLine() const;
1488 
1493  void setMultiLine( bool multiLine );
1494 
1495  QVariantMap toVariantMap() const override;
1496  bool fromVariantMap( const QVariantMap &map ) override;
1497 
1501  static QgsProcessingParameterString *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1502 
1503  private:
1504 
1505  bool mMultiLine = false;
1506 
1507 };
1508 
1515 class CORE_EXPORT QgsProcessingParameterExpression : public QgsProcessingParameterDefinition
1516 {
1517  public:
1518 
1522  QgsProcessingParameterExpression( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1523  const QString &parentLayerParameterName = QString(),
1524  bool optional = false );
1525 
1529  static QString typeName() { return QStringLiteral( "expression" ); }
1530  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1531  QString type() const override { return typeName(); }
1532  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1533  QStringList dependsOnOtherParameters() const override;
1534 
1539  QString parentLayerParameterName() const;
1540 
1545  void setParentLayerParameterName( const QString &parentLayerParameterName );
1546 
1547  QVariantMap toVariantMap() const override;
1548  bool fromVariantMap( const QVariantMap &map ) override;
1549 
1553  static QgsProcessingParameterExpression *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1554 
1555  private:
1556 
1557  QString mParentLayerParameterName;
1558 
1559 };
1560 
1561 
1569 {
1570  public:
1571 
1575  QgsProcessingParameterLimitedDataTypes( const QList< int > &types = QList< int >() );
1576 
1581  QList< int > dataTypes() const;
1582 
1587  void setDataTypes( const QList< int > &types );
1588 
1589  protected:
1590 
1592  QList< int > mDataTypes;
1593 };
1594 
1602 class CORE_EXPORT QgsProcessingParameterVectorLayer : public QgsProcessingParameterDefinition, public QgsProcessingParameterLimitedDataTypes
1603 {
1604  public:
1605 
1609  QgsProcessingParameterVectorLayer( const QString &name,
1610  const QString &description = QString(),
1611  const QList< int > &types = QList< int >(),
1612  const QVariant &defaultValue = QVariant(),
1613  bool optional = false );
1614 
1618  static QString typeName() { return QStringLiteral( "vector" ); }
1619  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1620  QString type() const override { return typeName(); }
1621  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1622  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1623 
1624  QVariantMap toVariantMap() const override;
1625  bool fromVariantMap( const QVariantMap &map ) override;
1626 
1630  static QgsProcessingParameterVectorLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1631 
1632 };
1633 
1640 class CORE_EXPORT QgsProcessingParameterField : public QgsProcessingParameterDefinition
1641 {
1642  public:
1643 
1646  {
1647  Any = -1,
1648  Numeric = 0,
1649  String = 1,
1650  DateTime = 2
1651  };
1652 
1656  QgsProcessingParameterField( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1657  const QString &parentLayerParameterName = QString(),
1658  DataType type = Any,
1659  bool allowMultiple = false,
1660  bool optional = false );
1661 
1665  static QString typeName() { return QStringLiteral( "field" ); }
1666  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1667  QString type() const override { return typeName(); }
1668  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1669  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1670  QString asScriptCode() const override;
1671  QStringList dependsOnOtherParameters() const override;
1672 
1677  QString parentLayerParameterName() const;
1678 
1683  void setParentLayerParameterName( const QString &parentLayerParameterName );
1684 
1689  DataType dataType() const;
1690 
1695  void setDataType( DataType type );
1696 
1701  bool allowMultiple() const;
1702 
1707  void setAllowMultiple( bool allowMultiple );
1708 
1709  QVariantMap toVariantMap() const override;
1710  bool fromVariantMap( const QVariantMap &map ) override;
1711 
1715  static QgsProcessingParameterField *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1716 
1717  private:
1718 
1719  QString mParentLayerParameterName;
1720  DataType mDataType = Any;
1721  bool mAllowMultiple = false;
1722 
1723 };
1724 
1725 
1732 class CORE_EXPORT QgsProcessingParameterFeatureSource : public QgsProcessingParameterDefinition, public QgsProcessingParameterLimitedDataTypes
1733 {
1734  public:
1735 
1739  QgsProcessingParameterFeatureSource( const QString &name, const QString &description = QString(),
1740  const QList< int > &types = QList< int >(),
1741  const QVariant &defaultValue = QVariant(), bool optional = false );
1742 
1746  static QString typeName() { return QStringLiteral( "source" ); }
1747  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1748  QString type() const override { return typeName(); }
1749  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1750  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1751  QString asScriptCode() const override;
1752 
1753  QVariantMap toVariantMap() const override;
1754  bool fromVariantMap( const QVariantMap &map ) override;
1755 
1759  static QgsProcessingParameterFeatureSource *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1760 
1761 };
1762 
1770 class CORE_EXPORT QgsProcessingDestinationParameter : public QgsProcessingParameterDefinition
1771 {
1772  public:
1773 
1780  QgsProcessingDestinationParameter( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1781  bool optional = false, bool createByDefault = true );
1782 
1783  bool isDestination() const override { return true; }
1784  QVariantMap toVariantMap() const override;
1785  bool fromVariantMap( const QVariantMap &map ) override;
1786 
1791  virtual QgsProcessingOutputDefinition *toOutputDefinition() const = 0 SIP_FACTORY;
1792 
1798  bool supportsNonFileBasedOutput() const { return mSupportsNonFileBasedOutputs; }
1799 
1805  void setSupportsNonFileBasedOutput( bool supportsNonFileBasedOutput ) { mSupportsNonFileBasedOutputs = supportsNonFileBasedOutput; }
1806 
1811  virtual QString defaultFileExtension() const = 0;
1812 
1818  virtual QString generateTemporaryDestination() const;
1819 
1825  bool createByDefault() const;
1826 
1832  void setCreateByDefault( bool createByDefault );
1833 
1834  protected:
1835 
1844  QgsProcessingProvider *originalProvider() const { return mOriginalProvider; }
1845 
1846  private:
1847 
1855  QgsProcessingProvider *mOriginalProvider = nullptr;
1856 
1857  bool mSupportsNonFileBasedOutputs = true;
1858  bool mCreateByDefault = true;
1859 
1860  friend class QgsProcessingModelAlgorithm;
1861  friend class TestQgsProcessing;
1862 };
1863 
1864 
1874 {
1875  public:
1876 
1883  QgsProcessingParameterFeatureSink( const QString &name, const QString &description = QString(), QgsProcessing::SourceType type = QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue = QVariant(),
1884  bool optional = false, bool createByDefault = true );
1885 
1889  static QString typeName() { return QStringLiteral( "sink" ); }
1890  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1891  QString type() const override { return typeName(); }
1892  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1893  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1894  QString asScriptCode() const override;
1896  QString defaultFileExtension() const override;
1897 
1903  virtual QStringList supportedOutputVectorLayerExtensions() const;
1904 
1909  QgsProcessing::SourceType dataType() const;
1910 
1915  bool hasGeometry() const;
1916 
1921  void setDataType( QgsProcessing::SourceType type );
1922 
1923  QVariantMap toVariantMap() const override;
1924  bool fromVariantMap( const QVariantMap &map ) override;
1925  QString generateTemporaryDestination() const override;
1926 
1930  static QgsProcessingParameterFeatureSink *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1931 
1932  private:
1933 
1935 };
1936 
1937 
1949 {
1950  public:
1951 
1958  QgsProcessingParameterVectorDestination( const QString &name, const QString &description = QString(), QgsProcessing::SourceType type = QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue = QVariant(),
1959  bool optional = false, bool createByDefault = true );
1960 
1964  static QString typeName() { return QStringLiteral( "vectorDestination" ); }
1965  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
1966  QString type() const override { return typeName(); }
1967  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1968  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1969  QString asScriptCode() const override;
1971  QString defaultFileExtension() const override;
1972 
1978  virtual QStringList supportedOutputVectorLayerExtensions() const;
1979 
1984  QgsProcessing::SourceType dataType() const;
1985 
1990  bool hasGeometry() const;
1991 
1996  void setDataType( QgsProcessing::SourceType type );
1997 
1998  QVariantMap toVariantMap() const override;
1999  bool fromVariantMap( const QVariantMap &map ) override;
2000 
2004  static QgsProcessingParameterVectorDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2005 
2006 
2007  private:
2008 
2010 };
2011 
2020 {
2021  public:
2022 
2029  QgsProcessingParameterRasterDestination( const QString &name, const QString &description = QString(),
2030  const QVariant &defaultValue = QVariant(),
2031  bool optional = false,
2032  bool createByDefault = true );
2033 
2037  static QString typeName() { return QStringLiteral( "rasterDestination" ); }
2038  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
2039  QString type() const override { return typeName(); }
2040  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2041  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2043  QString defaultFileExtension() const override;
2044 
2050  virtual QStringList supportedOutputRasterLayerExtensions() const;
2051 
2055  static QgsProcessingParameterRasterDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2056 };
2057 
2066 {
2067  public:
2068 
2075  QgsProcessingParameterFileDestination( const QString &name, const QString &description = QString(),
2076  const QString &fileFilter = QString(),
2077  const QVariant &defaultValue = QVariant(),
2078  bool optional = false,
2079  bool createByDefault = true );
2080 
2084  static QString typeName() { return QStringLiteral( "fileDestination" ); }
2085  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
2086  QString type() const override { return typeName(); }
2087  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2088  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2090  QString defaultFileExtension() const override;
2091 
2096  QString fileFilter() const;
2097 
2102  void setFileFilter( const QString &filter );
2103 
2104  QVariantMap toVariantMap() const override;
2105  bool fromVariantMap( const QVariantMap &map ) override;
2106 
2110  static QgsProcessingParameterFileDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2111 
2112 
2113  private:
2114 
2115  QString mFileFilter;
2116 };
2117 
2127 {
2128  public:
2129 
2133  QgsProcessingParameterFolderDestination( const QString &name, const QString &description = QString(),
2134  const QVariant &defaultValue = QVariant(),
2135  bool optional = false );
2136 
2140  static QString typeName() { return QStringLiteral( "folderDestination" ); }
2141  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
2142  QString type() const override { return typeName(); }
2143  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2145  QString defaultFileExtension() const override;
2146 
2150  static QgsProcessingParameterFolderDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2151 
2152 };
2153 
2160 class CORE_EXPORT QgsProcessingParameterBand : public QgsProcessingParameterDefinition
2161 {
2162  public:
2163 
2167  QgsProcessingParameterBand( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
2168  const QString &parentLayerParameterName = QString(),
2169  bool optional = false );
2170 
2174  static QString typeName() { return QStringLiteral( "band" ); }
2175  QgsProcessingParameterDefinition *clone() const override SIP_FACTORY;
2176  QString type() const override { return typeName(); }
2177  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2178  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2179  QString asScriptCode() const override;
2180  QStringList dependsOnOtherParameters() const override;
2181 
2186  QString parentLayerParameterName() const;
2187 
2192  void setParentLayerParameterName( const QString &parentLayerParameterName );
2193 
2194  QVariantMap toVariantMap() const override;
2195  bool fromVariantMap( const QVariantMap &map ) override;
2196 
2200  static QgsProcessingParameterBand *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2201 
2202  private:
2203 
2204  QString mParentLayerParameterName;
2205 };
2206 
2207 // clazy:excludeall=qstring-allocations
2208 
2209 #endif // QGSPROCESSINGPARAMETERS_H
2210 
2211 
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 Python processing scr...
A rectangle specified with double values.
Definition: qgsrectangle.h:40
Base class for all map layer types.
Definition: qgsmaplayer.h:61
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 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.
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.
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:104
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.
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.
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.
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.
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:67
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
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:85
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 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.
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.
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.
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.
QString type() const override
Unique parameter type name.
QString mDescription
Parameter description.
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.
static QString typeName()
Returns the type name for the parameter class.