QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 
32 class QgsRasterLayer;
33 class QgsVectorLayer;
34 class QgsFeatureSink;
39 
50 {
51  public:
52 
56  QgsProcessingFeatureSourceDefinition( const QString &source = QString(), bool selectedFeaturesOnly = false )
57  : source( QgsProperty::fromValue( source ) )
58  , selectedFeaturesOnly( selectedFeaturesOnly )
59  {}
60 
64  QgsProcessingFeatureSourceDefinition( const QgsProperty &source, bool selectedFeaturesOnly = false )
65  : source( source )
66  , selectedFeaturesOnly( selectedFeaturesOnly )
67  {}
68 
73 
78 
80  {
81  return source == other.source && selectedFeaturesOnly == other.selectedFeaturesOnly;
82  }
83 
85  {
86  return !( *this == other );
87  }
88 
90  operator QVariant() const
91  {
92  return QVariant::fromValue( *this );
93  }
94 
95 };
96 
98 
99 
109 {
110  public:
111 
117  QgsProcessingOutputLayerDefinition( const QString &sink = QString(), QgsProject *destinationProject = nullptr )
118  : sink( QgsProperty::fromValue( sink ) )
119  , destinationProject( destinationProject )
120  {}
121 
127  QgsProcessingOutputLayerDefinition( const QgsProperty &sink, QgsProject *destinationProject = nullptr )
128  : sink( sink )
129  , destinationProject( destinationProject )
130  {}
131 
136 
142  QgsProject *destinationProject = nullptr;
143 
148 
155  QVariantMap createOptions;
156 
163  QVariant toVariant() const;
164 
171  bool loadVariant( const QVariantMap &map );
172 
174  operator QVariant() const
175  {
176  return QVariant::fromValue( *this );
177  }
178 
179 };
180 
181 Q_DECLARE_METATYPE( QgsProcessingOutputLayerDefinition )
182 
183 
184 
185 
186 //
187 // Parameter definitions
188 //
189 
190 
203 {
204 
205 #ifdef SIP_RUN
207  if ( sipCpp->type() == QgsProcessingParameterBoolean::typeName() )
208  sipType = sipType_QgsProcessingParameterBoolean;
209  else if ( sipCpp->type() == QgsProcessingParameterCrs::typeName() )
210  sipType = sipType_QgsProcessingParameterCrs;
211  else if ( sipCpp->type() == QgsProcessingParameterMapLayer::typeName() )
212  sipType = sipType_QgsProcessingParameterMapLayer;
213  else if ( sipCpp->type() == QgsProcessingParameterExtent::typeName() )
214  sipType = sipType_QgsProcessingParameterExtent;
215  else if ( sipCpp->type() == QgsProcessingParameterPoint::typeName() )
216  sipType = sipType_QgsProcessingParameterPoint;
217  else if ( sipCpp->type() == QgsProcessingParameterFile::typeName() )
218  sipType = sipType_QgsProcessingParameterFile;
219  else if ( sipCpp->type() == QgsProcessingParameterMatrix::typeName() )
220  sipType = sipType_QgsProcessingParameterMatrix;
221  else if ( sipCpp->type() == QgsProcessingParameterMultipleLayers::typeName() )
222  sipType = sipType_QgsProcessingParameterMultipleLayers;
223  else if ( sipCpp->type() == QgsProcessingParameterNumber::typeName() )
224  sipType = sipType_QgsProcessingParameterNumber;
225  else if ( sipCpp->type() == QgsProcessingParameterDistance::typeName() )
226  sipType = sipType_QgsProcessingParameterDistance;
227  else if ( sipCpp->type() == QgsProcessingParameterRange::typeName() )
228  sipType = sipType_QgsProcessingParameterRange;
229  else if ( sipCpp->type() == QgsProcessingParameterRasterLayer::typeName() )
230  sipType = sipType_QgsProcessingParameterRasterLayer;
231  else if ( sipCpp->type() == QgsProcessingParameterEnum::typeName() )
232  sipType = sipType_QgsProcessingParameterEnum;
233  else if ( sipCpp->type() == QgsProcessingParameterString::typeName() )
234  sipType = sipType_QgsProcessingParameterString;
235  else if ( sipCpp->type() == QgsProcessingParameterExpression::typeName() )
236  sipType = sipType_QgsProcessingParameterExpression;
237  else if ( sipCpp->type() == QgsProcessingParameterVectorLayer::typeName() )
238  sipType = sipType_QgsProcessingParameterVectorLayer;
239  else if ( sipCpp->type() == QgsProcessingParameterField::typeName() )
240  sipType = sipType_QgsProcessingParameterField;
241  else if ( sipCpp->type() == QgsProcessingParameterFeatureSource::typeName() )
242  sipType = sipType_QgsProcessingParameterFeatureSource;
243  else if ( sipCpp->type() == QgsProcessingParameterFeatureSink::typeName() )
244  sipType = sipType_QgsProcessingParameterFeatureSink;
245  else if ( sipCpp->type() == QgsProcessingParameterVectorDestination::typeName() )
246  sipType = sipType_QgsProcessingParameterVectorDestination;
247  else if ( sipCpp->type() == QgsProcessingParameterRasterDestination::typeName() )
248  sipType = sipType_QgsProcessingParameterRasterDestination;
249  else if ( sipCpp->type() == QgsProcessingParameterFileDestination::typeName() )
250  sipType = sipType_QgsProcessingParameterFileDestination;
251  else if ( sipCpp->type() == QgsProcessingParameterFolderDestination::typeName() )
252  sipType = sipType_QgsProcessingParameterFolderDestination;
253  else if ( sipCpp->type() == QgsProcessingParameterBand::typeName() )
254  sipType = sipType_QgsProcessingParameterBand;
255  else
256  sipType = nullptr;
257  SIP_END
258 #endif
259 
260  public:
261 
263  enum Flag
264  {
265  FlagAdvanced = 1 << 1,
266  FlagHidden = 1 << 2,
267  FlagOptional = 1 << 3,
268  FlagIsModelOutput = 1 << 4,
269  };
270  Q_DECLARE_FLAGS( Flags, Flag )
271 
272 
275  QgsProcessingParameterDefinition( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
276  bool optional = false );
277 
278  virtual ~QgsProcessingParameterDefinition() = default;
279 
283  virtual QgsProcessingParameterDefinition *clone() const = 0 SIP_FACTORY;
284 
288  virtual QString type() const = 0;
289 
295  virtual bool isDestination() const { return false; }
296 
302  QString name() const { return mName; }
303 
309  void setName( const QString &name ) { mName = name; }
310 
316  QString description() const { return mDescription; }
317 
323  void setDescription( const QString &description ) { mDescription = description; }
324 
329  QVariant defaultValue() const { return mDefault; }
330 
336  void setDefaultValue( const QVariant &value ) { mDefault = value; }
337 
342  Flags flags() const { return mFlags; }
343 
348  void setFlags( Flags flags ) { mFlags = flags; }
349 
357  virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const;
358 
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 
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 
570  static QString parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
571 
575  static QString parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
576 
581  static QString parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
582 
586  static double parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
587 
592  static double parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
593 
597  static int parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
598 
603  static int parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
604 
609  static QList<int> parameterAsInts( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
610 
615  static QList<int> parameterAsInts( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
616 
620  static int parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
621 
626  static int parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
627 
631  static QList<int> parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
632 
637  static QList<int> parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
638 
642  static bool parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
643 
648  static bool parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
649 
663  static QgsFeatureSink *parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters,
664  const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs,
665  QgsProcessingContext &context, QString &destinationIdentifier SIP_OUT, QgsFeatureSink::SinkFlags sinkFlags = nullptr ) SIP_FACTORY;
666 
682  static QgsFeatureSink *parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariant &value,
683  const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs,
684  QgsProcessingContext &context, QString &destinationIdentifier SIP_OUT, QgsFeatureSink::SinkFlags sinkFlags = nullptr ) SIP_FACTORY;
685 
694  static QgsProcessingFeatureSource *parameterAsSource( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context ) SIP_FACTORY;
695 
706  static QgsProcessingFeatureSource *parameterAsSource( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context ) SIP_FACTORY;
707 
720  static QString parameterAsCompatibleSourceLayerPath( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters,
721  QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat = QString( "shp" ), QgsProcessingFeedback *feedback = nullptr );
722 
730  static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
731 
741  static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
742 
750  static QgsRasterLayer *parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
751 
761  static QgsRasterLayer *parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
762 
766  static QString parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
767 
772  static QString parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
773 
777  static QString parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
778 
783  static QString parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
784 
792  static QgsVectorLayer *parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
793 
803  static QgsVectorLayer *parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
804 
808  static QgsCoordinateReferenceSystem parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
809 
814  static QgsCoordinateReferenceSystem parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
815 
825  static QgsRectangle parameterAsExtent( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context,
827 
839  static QgsRectangle parameterAsExtent( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context,
841 
853  static QgsGeometry parameterAsExtentGeometry( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context,
855 
861  static QgsCoordinateReferenceSystem parameterAsExtentCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
862 
870  static QgsPointXY parameterAsPoint( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context,
872 
881  static QgsPointXY parameterAsPoint( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context,
883 
889  static QgsCoordinateReferenceSystem parameterAsPointCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
890 
894  static QString parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
895 
900  static QString parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
901 
906  static QVariantList parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
907 
913  static QVariantList parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
914 
918  static QList< QgsMapLayer *> parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
919 
924  static QList< QgsMapLayer *> parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
925 
929  static QList<double> parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
930 
935  static QList<double> parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
936 
940  static QStringList parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
941 
946  static QStringList parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
947 
953  static QgsProcessingParameterDefinition *parameterFromVariantMap( const QVariantMap &map ) SIP_FACTORY;
954 
958  static QString descriptionFromName( const QString &name );
959 
965  static QgsProcessingParameterDefinition *parameterFromScriptCode( const QString &code ) SIP_FACTORY;
966 
967  private:
968 
969  static bool parseScriptCodeParameterOptions( const QString &code, bool &isOptional, QString &name, QString &type, QString &definition );
970 };
971 
972 
973 
981 {
982  public:
983 
987  QgsProcessingParameterBoolean( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
988  bool optional = false );
989 
993  static QString typeName() { return QStringLiteral( "boolean" ); }
995  QString type() const override { return typeName(); }
996  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
997  QString asScriptCode() const override;
998 
1002  static QgsProcessingParameterBoolean *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1003 };
1004 
1012 {
1013  public:
1014 
1018  QgsProcessingParameterCrs( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1019  bool optional = false );
1020 
1024  static QString typeName() { return QStringLiteral( "crs" ); }
1026  QString type() const override { return typeName(); }
1027  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1028  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1029 
1033  static QgsProcessingParameterCrs *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1034 
1035 };
1036 
1044 {
1045  public:
1046 
1050  QgsProcessingParameterMapLayer( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1051  bool optional = false );
1052 
1056  static QString typeName() { return QStringLiteral( "layer" ); }
1058  QString type() const override { return typeName(); }
1059  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1060  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1061 
1065  static QgsProcessingParameterMapLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1066 
1067 };
1068 
1076 {
1077  public:
1078 
1082  QgsProcessingParameterExtent( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1083  bool optional = false );
1084 
1088  static QString typeName() { return QStringLiteral( "extent" ); }
1090  QString type() const override { return typeName(); }
1091  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1092  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1093 
1097  static QgsProcessingParameterExtent *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1098 
1099 };
1100 
1101 
1109 {
1110  public:
1111 
1115  QgsProcessingParameterPoint( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1116  bool optional = false );
1117 
1121  static QString typeName() { return QStringLiteral( "point" ); }
1123  QString type() const override { return typeName(); }
1124  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1125  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1126 
1130  static QgsProcessingParameterPoint *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1131 
1132 };
1133 
1141 {
1142  public:
1143 
1146  {
1147  File = 0,
1149  };
1150 
1154  QgsProcessingParameterFile( const QString &name, const QString &description = QString(), Behavior behavior = File, const QString &extension = QString(), const QVariant &defaultValue = QVariant(),
1155  bool optional = false );
1156 
1160  static QString typeName() { return QStringLiteral( "file" ); }
1162  QString type() const override { return typeName(); }
1163  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1164  QString asScriptCode() const override;
1165 
1170  Behavior behavior() const { return mBehavior; }
1171 
1176  void setBehavior( Behavior behavior ) { mBehavior = behavior; }
1177 
1182  QString extension() const { return mExtension; }
1183 
1188  void setExtension( const QString &extension ) { mExtension = extension; }
1189 
1190  QVariantMap toVariantMap() const override;
1191  bool fromVariantMap( const QVariantMap &map ) override;
1192 
1196  static QgsProcessingParameterFile *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition, Behavior behavior = File ) SIP_FACTORY;
1197 
1198  private:
1199 
1200  Behavior mBehavior = File;
1201  QString mExtension;
1202 };
1203 
1211 {
1212  public:
1213 
1217  QgsProcessingParameterMatrix( const QString &name, const QString &description = QString(), int numberRows = 3,
1218  bool hasFixedNumberRows = false, const QStringList &headers = QStringList(),
1219  const QVariant &defaultValue = QVariant(),
1220  bool optional = false );
1221 
1225  static QString typeName() { return QStringLiteral( "matrix" ); }
1227  QString type() const override { return typeName(); }
1228  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1229  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1230 
1235  QStringList headers() const;
1236 
1241  void setHeaders( const QStringList &headers );
1242 
1249  int numberRows() const;
1250 
1257  void setNumberRows( int rows );
1258 
1264  bool hasFixedNumberRows() const;
1265 
1271  void setHasFixedNumberRows( bool hasFixedNumberRows );
1272 
1273  QVariantMap toVariantMap() const override;
1274  bool fromVariantMap( const QVariantMap &map ) override;
1275 
1279  static QgsProcessingParameterMatrix *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1280 
1281  private:
1282 
1283  QStringList mHeaders;
1284  int mNumberRows = 3;
1285  bool mFixedNumberRows = false;
1286 
1287 };
1288 
1296 {
1297  public:
1298 
1302  QgsProcessingParameterMultipleLayers( const QString &name, const QString &description = QString(), QgsProcessing::SourceType layerType = QgsProcessing::TypeVectorAnyGeometry,
1303  const QVariant &defaultValue = QVariant(),
1304  bool optional = false );
1305 
1309  static QString typeName() { return QStringLiteral( "multilayer" ); }
1311  QString type() const override { return typeName(); }
1312  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1313  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1314  QString asScriptCode() const override;
1315 
1320  QgsProcessing::SourceType layerType() const;
1321 
1326  void setLayerType( QgsProcessing::SourceType type );
1327 
1333  int minimumNumberInputs() const;
1334 
1340  void setMinimumNumberInputs( int minimum );
1341 
1342  QVariantMap toVariantMap() const override;
1343  bool fromVariantMap( const QVariantMap &map ) override;
1344 
1348  static QgsProcessingParameterMultipleLayers *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1349 
1350  private:
1351 
1353  int mMinimumNumberInputs = 0;
1354 
1355 };
1356 
1376 {
1377  public:
1378 
1380  enum Type
1381  {
1384  };
1385 
1389  explicit QgsProcessingParameterNumber( const QString &name, const QString &description = QString(),
1390  Type type = Integer,
1391  const QVariant &defaultValue = QVariant(),
1392  bool optional = false,
1393  double minValue = std::numeric_limits<double>::lowest() + 1,
1394  double maxValue = std::numeric_limits<double>::max()
1395  );
1396 
1400  static QString typeName() { return QStringLiteral( "number" ); }
1402  QString type() const override { return typeName(); }
1403  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1404  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1405  QString toolTip() const override;
1406 
1411  double minimum() const;
1412 
1417  void setMinimum( double minimum );
1418 
1423  double maximum() const;
1424 
1429  void setMaximum( double maximum );
1430 
1435  Type dataType() const;
1436 
1441  void setDataType( Type type );
1442 
1443  QVariantMap toVariantMap() const override;
1444  bool fromVariantMap( const QVariantMap &map ) override;
1445 
1449  static QgsProcessingParameterNumber *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1450 
1451  private:
1452 
1453  double mMin = std::numeric_limits<double>::lowest() + 1;
1454  double mMax = std::numeric_limits<double>::max();
1455  Type mDataType = Integer;
1456 };
1457 
1478 {
1479  public:
1480 
1484  explicit QgsProcessingParameterDistance( const QString &name, const QString &description = QString(),
1485  const QVariant &defaultValue = QVariant(),
1486  const QString &parentParameterName = QString(),
1487  bool optional = false,
1488  double minValue = std::numeric_limits<double>::lowest() + 1,
1489  double maxValue = std::numeric_limits<double>::max() );
1490 
1494  static QString typeName() { return QStringLiteral( "distance" ); }
1495 
1497 
1498  QString type() const override;
1499  QStringList dependsOnOtherParameters() const override;
1500 
1505  QString parentParameterName() const;
1506 
1511  void setParentParameterName( const QString &parentParameterName );
1512 
1519  QgsUnitTypes::DistanceUnit defaultUnit() const { return mDefaultUnit; }
1520 
1527  void setDefaultUnit( QgsUnitTypes::DistanceUnit unit ) { mDefaultUnit = unit; }
1528 
1529  QVariantMap toVariantMap() const override;
1530  bool fromVariantMap( const QVariantMap &map ) override;
1531 
1532  private:
1533 
1534  QString mParentParameterName;
1536 
1537 };
1538 
1546 {
1547  public:
1548 
1552  QgsProcessingParameterRange( const QString &name, const QString &description = QString(),
1554  const QVariant &defaultValue = QVariant(),
1555  bool optional = false );
1556 
1560  static QString typeName() { return QStringLiteral( "range" ); }
1562  QString type() const override { return typeName(); }
1563  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1564  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1565 
1570  QgsProcessingParameterNumber::Type dataType() const;
1571 
1576  void setDataType( QgsProcessingParameterNumber::Type dataType );
1577 
1578  QVariantMap toVariantMap() const override;
1579  bool fromVariantMap( const QVariantMap &map ) override;
1580 
1584  static QgsProcessingParameterRange *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1585 
1586  private:
1587 
1589 };
1590 
1598 {
1599  public:
1600 
1604  QgsProcessingParameterRasterLayer( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1605  bool optional = false );
1606 
1610  static QString typeName() { return QStringLiteral( "raster" ); }
1612  QString type() const override { return typeName(); }
1613  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1614  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1615 
1619  static QgsProcessingParameterRasterLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1620 
1621 };
1622 
1630 {
1631  public:
1632 
1636  QgsProcessingParameterEnum( const QString &name, const QString &description = QString(), const QStringList &options = QStringList(),
1637  bool allowMultiple = false,
1638  const QVariant &defaultValue = QVariant(),
1639  bool optional = false );
1640 
1644  static QString typeName() { return QStringLiteral( "enum" ); }
1646  QString type() const override { return typeName(); }
1647  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1648  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1649  QString asScriptCode() const override;
1650 
1655  QStringList options() const;
1656 
1661  void setOptions( const QStringList &options );
1662 
1667  bool allowMultiple() const;
1668 
1673  void setAllowMultiple( bool allowMultiple );
1674 
1675  QVariantMap toVariantMap() const override;
1676  bool fromVariantMap( const QVariantMap &map ) override;
1677 
1681  static QgsProcessingParameterEnum *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1682 
1683  private:
1684 
1685  QStringList mOptions;
1686  bool mAllowMultiple = false;
1687 
1688 };
1689 
1697 {
1698  public:
1699 
1703  QgsProcessingParameterString( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1704  bool multiLine = false,
1705  bool optional = false );
1706 
1710  static QString typeName() { return QStringLiteral( "string" ); }
1712  QString type() const override { return typeName(); }
1713  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1714  QString asScriptCode() const override;
1715 
1720  bool multiLine() const;
1721 
1726  void setMultiLine( bool multiLine );
1727 
1728  QVariantMap toVariantMap() const override;
1729  bool fromVariantMap( const QVariantMap &map ) override;
1730 
1734  static QgsProcessingParameterString *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1735 
1736  private:
1737 
1738  bool mMultiLine = false;
1739 
1740 };
1741 
1749 {
1750  public:
1751 
1755  QgsProcessingParameterExpression( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1756  const QString &parentLayerParameterName = QString(),
1757  bool optional = false );
1758 
1762  static QString typeName() { return QStringLiteral( "expression" ); }
1764  QString type() const override { return typeName(); }
1765  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1766  QStringList dependsOnOtherParameters() const override;
1767 
1772  QString parentLayerParameterName() const;
1773 
1778  void setParentLayerParameterName( const QString &parentLayerParameterName );
1779 
1780  QVariantMap toVariantMap() const override;
1781  bool fromVariantMap( const QVariantMap &map ) override;
1782 
1786  static QgsProcessingParameterExpression *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1787 
1788  private:
1789 
1790  QString mParentLayerParameterName;
1791 
1792 };
1793 
1794 
1802 {
1803  public:
1804 
1808  QgsProcessingParameterLimitedDataTypes( const QList< int > &types = QList< int >() );
1809 
1814  QList< int > dataTypes() const;
1815 
1820  void setDataTypes( const QList< int > &types );
1821 
1822  protected:
1823 
1825  QList< int > mDataTypes;
1826 };
1827 
1836 {
1837  public:
1838 
1842  QgsProcessingParameterVectorLayer( const QString &name,
1843  const QString &description = QString(),
1844  const QList< int > &types = QList< int >(),
1845  const QVariant &defaultValue = QVariant(),
1846  bool optional = false );
1847 
1851  static QString typeName() { return QStringLiteral( "vector" ); }
1853  QString type() const override { return typeName(); }
1854  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1855  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1856 
1857  QVariantMap toVariantMap() const override;
1858  bool fromVariantMap( const QVariantMap &map ) override;
1859 
1863  static QgsProcessingParameterVectorLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1864 
1865 };
1866 
1874 {
1875  public:
1876 
1879  {
1880  Any = -1,
1881  Numeric = 0,
1882  String = 1,
1883  DateTime = 2
1884  };
1885 
1889  QgsProcessingParameterField( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
1890  const QString &parentLayerParameterName = QString(),
1891  DataType type = Any,
1892  bool allowMultiple = false,
1893  bool optional = false );
1894 
1898  static QString typeName() { return QStringLiteral( "field" ); }
1900  QString type() const override { return typeName(); }
1901  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1902  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1903  QString asScriptCode() const override;
1904  QStringList dependsOnOtherParameters() const override;
1905 
1910  QString parentLayerParameterName() const;
1911 
1916  void setParentLayerParameterName( const QString &parentLayerParameterName );
1917 
1922  DataType dataType() const;
1923 
1928  void setDataType( DataType type );
1929 
1934  bool allowMultiple() const;
1935 
1940  void setAllowMultiple( bool allowMultiple );
1941 
1942  QVariantMap toVariantMap() const override;
1943  bool fromVariantMap( const QVariantMap &map ) override;
1944 
1948  static QgsProcessingParameterField *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1949 
1950  private:
1951 
1952  QString mParentLayerParameterName;
1953  DataType mDataType = Any;
1954  bool mAllowMultiple = false;
1955 
1956 };
1957 
1958 
1966 {
1967  public:
1968 
1972  QgsProcessingParameterFeatureSource( const QString &name, const QString &description = QString(),
1973  const QList< int > &types = QList< int >(),
1974  const QVariant &defaultValue = QVariant(), bool optional = false );
1975 
1979  static QString typeName() { return QStringLiteral( "source" ); }
1981  QString type() const override { return typeName(); }
1982  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
1983  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
1984  QString asScriptCode() const override;
1985 
1986  QVariantMap toVariantMap() const override;
1987  bool fromVariantMap( const QVariantMap &map ) override;
1988 
1992  static QgsProcessingParameterFeatureSource *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
1993 
1994 };
1995 
2004 {
2005  public:
2006 
2013  QgsProcessingDestinationParameter( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
2014  bool optional = false, bool createByDefault = true );
2015 
2016  bool isDestination() const override { return true; }
2017  QVariantMap toVariantMap() const override;
2018  bool fromVariantMap( const QVariantMap &map ) override;
2019 
2024  virtual QgsProcessingOutputDefinition *toOutputDefinition() const = 0 SIP_FACTORY;
2025 
2031  bool supportsNonFileBasedOutput() const { return mSupportsNonFileBasedOutputs; }
2032 
2038  void setSupportsNonFileBasedOutput( bool supportsNonFileBasedOutput ) { mSupportsNonFileBasedOutputs = supportsNonFileBasedOutput; }
2039 
2044  virtual QString defaultFileExtension() const = 0;
2045 
2051  virtual QString generateTemporaryDestination() const;
2052 
2058  bool createByDefault() const;
2059 
2065  void setCreateByDefault( bool createByDefault );
2066 
2067  protected:
2068 
2077  QgsProcessingProvider *originalProvider() const { return mOriginalProvider; }
2078 
2079  private:
2080 
2088  QgsProcessingProvider *mOriginalProvider = nullptr;
2089 
2090  bool mSupportsNonFileBasedOutputs = true;
2091  bool mCreateByDefault = true;
2092 
2093  friend class QgsProcessingModelAlgorithm;
2094  friend class TestQgsProcessing;
2095 };
2096 
2097 
2107 {
2108  public:
2109 
2116  QgsProcessingParameterFeatureSink( const QString &name, const QString &description = QString(), QgsProcessing::SourceType type = QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue = QVariant(),
2117  bool optional = false, bool createByDefault = true );
2118 
2122  static QString typeName() { return QStringLiteral( "sink" ); }
2124  QString type() const override { return typeName(); }
2125  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2126  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2127  QString asScriptCode() const override;
2129  QString defaultFileExtension() const override;
2130 
2136  virtual QStringList supportedOutputVectorLayerExtensions() const;
2137 
2142  QgsProcessing::SourceType dataType() const;
2143 
2148  bool hasGeometry() const;
2149 
2154  void setDataType( QgsProcessing::SourceType type );
2155 
2156  QVariantMap toVariantMap() const override;
2157  bool fromVariantMap( const QVariantMap &map ) override;
2158  QString generateTemporaryDestination() const override;
2159 
2163  static QgsProcessingParameterFeatureSink *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2164 
2165  private:
2166 
2168 };
2169 
2170 
2182 {
2183  public:
2184 
2191  QgsProcessingParameterVectorDestination( const QString &name, const QString &description = QString(), QgsProcessing::SourceType type = QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue = QVariant(),
2192  bool optional = false, bool createByDefault = true );
2193 
2197  static QString typeName() { return QStringLiteral( "vectorDestination" ); }
2199  QString type() const override { return typeName(); }
2200  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2201  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2202  QString asScriptCode() const override;
2204  QString defaultFileExtension() const override;
2205 
2211  virtual QStringList supportedOutputVectorLayerExtensions() const;
2212 
2217  QgsProcessing::SourceType dataType() const;
2218 
2223  bool hasGeometry() const;
2224 
2229  void setDataType( QgsProcessing::SourceType type );
2230 
2231  QVariantMap toVariantMap() const override;
2232  bool fromVariantMap( const QVariantMap &map ) override;
2233 
2237  static QgsProcessingParameterVectorDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2238 
2239 
2240  private:
2241 
2243 };
2244 
2253 {
2254  public:
2255 
2262  QgsProcessingParameterRasterDestination( const QString &name, const QString &description = QString(),
2263  const QVariant &defaultValue = QVariant(),
2264  bool optional = false,
2265  bool createByDefault = true );
2266 
2270  static QString typeName() { return QStringLiteral( "rasterDestination" ); }
2272  QString type() const override { return typeName(); }
2273  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2274  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2276  QString defaultFileExtension() const override;
2277 
2283  virtual QStringList supportedOutputRasterLayerExtensions() const;
2284 
2288  static QgsProcessingParameterRasterDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2289 };
2290 
2299 {
2300  public:
2301 
2308  QgsProcessingParameterFileDestination( const QString &name, const QString &description = QString(),
2309  const QString &fileFilter = QString(),
2310  const QVariant &defaultValue = QVariant(),
2311  bool optional = false,
2312  bool createByDefault = true );
2313 
2317  static QString typeName() { return QStringLiteral( "fileDestination" ); }
2319  QString type() const override { return typeName(); }
2320  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2321  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2323  QString defaultFileExtension() const override;
2324 
2329  QString fileFilter() const;
2330 
2335  void setFileFilter( const QString &filter );
2336 
2337  QVariantMap toVariantMap() const override;
2338  bool fromVariantMap( const QVariantMap &map ) override;
2339 
2343  static QgsProcessingParameterFileDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2344 
2345 
2346  private:
2347 
2348  QString mFileFilter;
2349 };
2350 
2360 {
2361  public:
2362 
2366  QgsProcessingParameterFolderDestination( const QString &name, const QString &description = QString(),
2367  const QVariant &defaultValue = QVariant(),
2368  bool optional = false );
2369 
2373  static QString typeName() { return QStringLiteral( "folderDestination" ); }
2375  QString type() const override { return typeName(); }
2376  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2378  QString defaultFileExtension() const override;
2379 
2383  static QgsProcessingParameterFolderDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2384 
2385 };
2386 
2394 {
2395  public:
2396 
2400  QgsProcessingParameterBand( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
2401  const QString &parentLayerParameterName = QString(),
2402  bool optional = false,
2403  bool allowMultiple = false );
2404 
2408  static QString typeName() { return QStringLiteral( "band" ); }
2410  QString type() const override { return typeName(); }
2411  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
2412  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
2413  QString asScriptCode() const override;
2414  QStringList dependsOnOtherParameters() const override;
2415 
2420  QString parentLayerParameterName() const;
2421 
2426  void setParentLayerParameterName( const QString &parentLayerParameterName );
2427 
2428  QVariantMap toVariantMap() const override;
2429  bool fromVariantMap( const QVariantMap &map ) override;
2430 
2434  static QgsProcessingParameterBand *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY;
2435 
2441  bool allowMultiple() const;
2442 
2448  void setAllowMultiple( bool allowMultiple );
2449 
2450  private:
2451 
2452  QString mParentLayerParameterName;
2453  bool mAllowMultiple = false;
2454 };
2455 
2456 // clazy:excludeall=qstring-allocations
2457 
2458 #endif // QGSPROCESSINGPARAMETERS_H
2459 
2460 
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.
QVariantList parameterAsMatrix(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a matrix/table of values.
virtual QStringList dependsOnOtherParameters() const
Returns a list of other parameter names on which this parameter is dependent (e.g.
An input file or folder parameter for processing algorithms.
A parameter for processing algorithms which accepts multiple map layers.
QgsRectangle parameterAsExtent(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem()) const
Evaluates the parameter with matching name to a rectangular extent.
A rectangle specified with double values.
Definition: qgsrectangle.h:40
Base class for all map layer types.
Definition: qgsmaplayer.h:63
QgsCoordinateReferenceSystem parameterAsPointCrs(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value. ...
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.
QString parameterAsString(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static string value.
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.
QString name() const
Returns the name of the parameter.
static QString typeName()
Returns the type name for the parameter class.
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.
virtual QString name() const =0
Returns the algorithm name, used for identifying the algorithm.
A map layer parameter for processing algorithms.
QgsProcessingFeatureSource * parameterAsSource(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a feature source.
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.
int parameterAsInt(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static integer value.
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.
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.
QList< int > parameterAsEnums(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to list of enum values.
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.
Behavior behavior() const
Returns the parameter behavior (e.g.
A numeric range parameter for processing algorithms.
bool operator!=(const QgsProcessingFeatureSourceDefinition &other)
QList< QgsMapLayer * > parameterAsLayerList(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a list of map layers.
int parameterAsEnum(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a enum value.
QgsRasterLayer * parameterAsRasterLayer(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a raster layer.
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.
QList< int > parameterAsInts(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a list of integer values.
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.
static QString typeName()
Returns the type name for the parameter class.
QgsPointXY parameterAsPoint(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem()) const
Evaluates the parameter with matching name to a point.
virtual bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsProperty source
Source definition.
QgsCoordinateReferenceSystem parameterAsCrs(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a coordinate reference system.
QgsCoordinateReferenceSystem parameterAsExtentCrs(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
QString type() const override
Unique parameter type name.
An enum based parameter for processing algorithms, allowing for selection from predefined values...
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.
#define SIP_SKIP
Definition: qgis_sip.h:119
QList< double > parameterAsRange(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a range of values.
QString parameterAsExpression(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to an expression.
QgsProcessingProvider * originalProvider() const
Original (source) provider which this parameter has been derived from.
bool isDynamic() const
Returns true if the parameter supports is dynamic, and can support data-defined values (i...
QgsVectorLayer * parameterAsVectorLayer(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a vector layer.
const QString & typeName
QStringList parameterAsFields(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a list of fields.
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.
Flags flags() const
Returns any flags associated with the parameter.
A double numeric parameter for distance values.
QgsMapLayer * parameterAsLayer(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a map layer.
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...
QString parameterAsOutputLayer(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a output layer destination.
#define SIP_FACTORY
Definition: qgis_sip.h:69
QString description() const
Returns the description for the parameter.
A coordinate reference system parameter for processing algorithms.
QgsUnitTypes::DistanceUnit defaultUnit() const
Returns the default distance unit for the parameter.
A store for object properties.
Definition: qgsproperty.h:229
A rectangular map extent parameter for processing algorithms.
QString type() const override
Unique parameter type name.
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 parameterAsFileOutput(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a file based output destination.
Definition for a property.
Definition: qgsproperty.h:46
QgsGeometry parameterAsExtentGeometry(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching name to a rectangular extent, and returns a geometry covering t...
QVariantMap metadata() const
Returns the parameter&#39;s freeform metadata.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsFeatureSink * parameterAsSink(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, QString &destinationIdentifier, const QgsFields &fields, QgsWkbTypes::Type geometryType=QgsWkbTypes::NoGeometry, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem(), QgsFeatureSink::SinkFlags sinkFlags=nullptr) const
Evaluates the parameter with matching name to a feature sink.
QList< int > mDataTypes
List of acceptable data types for the parameter.
Encapsulates settings relating to a feature source input to a processing algorithm.
virtual QString asScriptCode() const
Returns the parameter definition encoded in a string which can be used within a Python processing scr...
QString type() const override
Unique parameter type name.
DistanceUnit
Units of distance.
Definition: qgsunittypes.h:53
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:64
A vector layer destination parameter, for specifying the destination path for a vector layer created ...
QString type() const override
Unique parameter type name.
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
virtual QString generateTemporaryDestination() const
Generates a temporary destination value for this parameter.
A point parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
QgsPropertyDefinition dynamicPropertyDefinition() const
Returns the property definition for dynamic properties.
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.
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
#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.
#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.
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.
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.
QVariant defaultValue() const
Returns the default value for the parameter.
QString type() const override
Unique parameter type name.
QString mDescription
Parameter description.
QString extension() const
Returns any specified file extension for the parameter.
bool parameterAsBool(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static boolean value.
QString parameterAsCompatibleSourceLayerPath(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr)
Evaluates the parameter with matching name to a source vector layer file path of compatible format...
double parameterAsDouble(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static double value.
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.
bool supportsNonFileBasedOutput() const
Returns true if the destination parameter supports non filed-based outputs, such as memory layers or ...
QString parameterAsFile(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a file/folder name.
A string parameter for processing algorithms.
QString type() const override
Unique parameter type name.
QString dynamicLayerParameterName() const
Returns the name of the parameter for a layer linked to a dynamic parameter, or an empty string if th...
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.