QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsprocessingparametermeshdataset.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingparametermeshdataset.h
3  ---------------------
4  Date : October 2020
5  Copyright : (C) 2020 by Vincent Cloarec
6  Email : vcloarec at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSPROCESSINGPARAMETERMESHDATASET_H
17 #define QGSPROCESSINGPARAMETERMESHDATASET_H
18 
21 #include "qgsmeshdataset.h"
22 
35 {
36  public:
37 
46  QgsProcessingParameterMeshDatasetGroups( const QString &name,
47  const QString &description = QString(),
48  const QString &meshLayerParameterName = QString(),
49  QSet<int> supportedDataType = QSet<int>(),
50  bool optional = false );
51 
53  QString type() const override;
54  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
55  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
57  QStringList dependsOnOtherParameters() const override;
58  QVariantMap toVariantMap() const override;
59  bool fromVariantMap( const QVariantMap &map ) override;
60 
62  static QString typeName() { return QStringLiteral( "meshdatasetgroups" ); }
63 
65  QString meshLayerParameterName() const;
66 
68  bool isDataTypeSupported( QgsMeshDatasetGroupMetadata::DataType dataType ) const;
69 
71  static QList<int> valueAsDatasetGroup( const QVariant &value );
72 
73  private:
74  QString mMeshLayerParameterName;
75  QSet<int> mSupportedDataType;
76 
77  static bool valueIsAcceptable( const QVariant &input, bool allowEmpty );
78 };
79 
80 #ifndef SIP_RUN
81 
89 class CORE_EXPORT QgsProcessingParameterTypeMeshDatasetGroups : public QgsProcessingParameterType
90 {
91  public:
92  QgsProcessingParameterDefinition *create( const QString &name ) const override SIP_FACTORY
93  {
94  return new QgsProcessingParameterMeshDatasetGroups( name );
95  }
96 
97  QString description() const override
98  {
99  return QCoreApplication::translate( "Processing", "An input allowing selection dataset groups from a mesh layer" );
100  }
101 
102  QString name() const override
103  {
104  return QCoreApplication::translate( "Processing", "Mesh Dataset Groups" );
105  }
106 
107  QString id() const override
108  {
110  }
111 
112  QString pythonImportString() const override
113  {
114  return QStringLiteral( "from qgis.core import QgsProcessingParameterMeshDatasetGroups" );
115  }
116 
117  QString className() const override
118  {
119  return QStringLiteral( "QgsProcessingParameterMeshDatasetGroups" );
120  }
121 
122  QStringList acceptedPythonTypes() const override
123  {
124  return QStringList() << QObject::tr( "list[int]: list of dataset group indexes, see QgsProcessingParameterMeshDatasetGroups docs" );
125  }
126 };
127 
129 #endif //SIP_RUN
130 
146 {
147  public:
148 
157  const QString &name,
158  const QString &description = QString(),
159  const QString &meshLayerParameterName = QString(),
160  const QString &datasetGroupParameterName = QString() );
161 
163  QString type() const override;
164  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
165  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
167  QStringList dependsOnOtherParameters() const override;
168  QVariantMap toVariantMap() const override;
169  bool fromVariantMap( const QVariantMap &map ) override;
170 
172  static QString typeName() { return QStringLiteral( "meshdatasettime" ); }
173 
175  QString meshLayerParameterName() const;
176 
178  QString datasetGroupParameterName() const;
179 
187  static QString valueAsTimeType( const QVariant &value );
188 
195  static QgsMeshDatasetIndex timeValueAsDatasetIndex( const QVariant &value );
196 
203  static QDateTime timeValueAsDefinedDateTime( const QVariant &value );
204 
205  private:
206  QString mMeshLayerParameterName;
207  QString mDatasetGroupParameterName;
208 
209  static bool valueIsAcceptable( const QVariant &input, bool allowEmpty );
210 };
211 
212 #ifndef SIP_RUN
213 
221 class CORE_EXPORT QgsProcessingParameterTypeMeshDatasetTime: public QgsProcessingParameterType
222 {
223  public:
224  QgsProcessingParameterDefinition *create( const QString &name ) const override SIP_FACTORY
225  {
226  return new QgsProcessingParameterMeshDatasetTime( name );
227  }
228 
229  QString description() const override
230  {
231  return QCoreApplication::translate( "Processing", "An input allowing selection of dataset index from a mesh layer by time setting" );
232  }
233 
234  QString name() const override
235  {
236  return QCoreApplication::translate( "Processing", "Mesh Dataset Time" );
237  }
238 
239  QString id() const override
240  {
242  }
243 
244  QString pythonImportString() const override
245  {
246  return QStringLiteral( "from qgis.core import QgsProcessingParameterMeshDatasetTime" );
247  }
248 
249  QString className() const override
250  {
251  return QStringLiteral( "QgsProcessingParameterMeshDatasetTime" );
252  }
253 
254  QStringList acceptedPythonTypes() const override
255  {
256  return QStringList() << QObject::tr( "dict{}: dictionary, see QgsProcessingParameterMeshDatasetTime docs" );
257  }
258 };
259 
261 #endif //SIP_RUN
262 
263 
264 #endif // QGSPROCESSINGPARAMETERMESHDATASET_H
QgsProcessingParameterType::create
virtual QgsProcessingParameterDefinition * create(const QString &name) const =0
Creates a new parameter of this type.
qgsprocessingparametertype.h
QgsProcessingParameterMeshDatasetTime
A parameter for processing algorithms that need a list of mesh dataset index from time parameter.
Definition: qgsprocessingparametermeshdataset.h:145
QgsProcessingParameterDefinition::toVariantMap
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:2895
QgsProcessingParameterDefinition::valueAsPythonString
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...
Definition: qgsprocessingparameters.cpp:2444
QgsProcessingParameterType::description
virtual QString description() const =0
A human readable and translatable description for this parameter type.
QgsProcessingParameterType::name
virtual QString name() const =0
A human readable and translatable short name for this parameter type.
QgsProcessingParameterDefinition
Base class for the definition of processing parameters.
Definition: qgsprocessingparameters.h:334
QgsProcessingParameterType
Makes metadata of processing parameters available.
Definition: qgsprocessingparametertype.h:33
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsProcessing::PythonQgsProcessingAlgorithmSubclass
@ PythonQgsProcessingAlgorithmSubclass
Full Python QgsProcessingAlgorithm subclass.
Definition: qgsprocessing.h:64
QgsProcessingParameterDefinition::fromVariantMap
virtual bool fromVariantMap(const QVariantMap &map)
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:2909
QgsProcessingContext
Contains information about the context in which a processing algorithm is executed.
Definition: qgsprocessingcontext.h:46
QgsMeshDatasetIndex
QgsMeshDatasetIndex is index that identifies the dataset group (e.g. wind speed) and a dataset in thi...
Definition: qgsmeshdataset.h:48
QgsProcessingParameterType::id
virtual QString id() const =0
A static id for this type which will be used for storing this parameter type.
QgsProcessingParameterMeshDatasetTime::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparametermeshdataset.h:172
typeName
const QString & typeName
Definition: qgswfsgetfeature.cpp:109
QgsProcessingParameterMeshDatasetGroups::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparametermeshdataset.h:75
qgsprocessingparameters.h
QgsProcessingParameterMeshDatasetGroups
A parameter for processing algorithms that need a list of mesh dataset groups.
Definition: qgsprocessingparametermeshdataset.h:34
QgsProcessingParameterType::className
virtual QString className() const
Returns the corresponding class name for the parameter type.
Definition: qgsprocessingparametertype.h:103
QgsProcessingParameterType::pythonImportString
virtual QString pythonImportString() const
Returns a valid Python import string for importing the corresponding parameter type,...
Definition: qgsprocessingparametertype.h:93
QgsMeshDatasetGroupMetadata::DataType
DataType
Location of where data is specified for datasets in the dataset group.
Definition: qgsmeshdataset.h:356
qgsmeshdataset.h
QgsProcessingParameterDefinition::asPythonString
virtual QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:2870
QgsProcessingParameterDefinition::clone
virtual QgsProcessingParameterDefinition * clone() const =0
Creates a clone of the parameter definition.
QgsProcessingParameterDefinition::type
virtual QString type() const =0
Unique parameter type name.
QgsProcessing::PythonOutputType
PythonOutputType
Available Python output types.
Definition: qgsprocessing.h:62
QgsProcessingParameterType::acceptedPythonTypes
virtual QStringList acceptedPythonTypes() const
Returns a list of the Python data types accepted as values for the parameter.
Definition: qgsprocessingparametertype.cpp:30
QgsProcessingParameterDefinition::dependsOnOtherParameters
virtual QStringList dependsOnOtherParameters() const
Returns a list of other parameter names on which this parameter is dependent (e.g.
Definition: qgsprocessingparameters.h:727
QgsProcessingParameterDefinition::checkValueIsAcceptable
virtual bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:2432