QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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 
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;
56  QString asPythonString( QgsProcessing::PythonOutputType outputType = QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const override;
57  QStringList dependsOnOtherParameters() const override;
58 
60  static QString typeName() { return QStringLiteral( "meshdatasetgroups" ); }
61 
63  QString meshLayerParameterName() const;
64 
67 
69  static QList<int> valueAsDatasetGroup( const QVariant &value );
70 
71  private:
72  QString mMeshLayerParameterName;
73  QSet<int> mSupportedDataType;
74 
75  static bool valueIsAcceptable( const QVariant &input, bool allowEmpty );
76 };
77 
78 #ifndef SIP_RUN
80 
87 class CORE_EXPORT QgsProcessingParameterTypeMeshDatasetGroups : public QgsProcessingParameterType
88 {
89  public:
90  QgsProcessingParameterDefinition *create( const QString &name ) const override SIP_FACTORY
91  {
92  return new QgsProcessingParameterMeshDatasetGroups( name );
93  }
94 
95  QString description() const override
96  {
97  return QCoreApplication::translate( "Processing", "An input allowing selection dataset groups from a mesh layer" );
98  }
99 
100  QString name() const override
101  {
102  return QCoreApplication::translate( "Processing", "Mesh Dataset Groups" );
103  }
104 
105  QString id() const override
106  {
108  }
109 
110  QString pythonImportString() const override
111  {
112  return QStringLiteral( "from qgis.core import QgsProcessingParameterMeshDatasetGroups" );
113  }
114 
115  QString className() const override
116  {
117  return QStringLiteral( "QgsProcessingParameterMeshDatasetGroups" );
118  }
119 
120  QStringList acceptedPythonTypes() const override
121  {
122  return QStringList() << QObject::tr( "list[int]: list of dataset group indexes, see QgsProcessingParameterMeshDatasetGroups docs" );
123  }
124 };
125 
127 #endif //SIP_RUN
128 
144 {
145  public:
146 
155  const QString &name,
156  const QString &description = QString(),
157  const QString &meshLayerParameterName = QString(),
158  const QString &datasetGroupParameterName = QString() );
159 
161  QString type() const override;
162  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
163  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
164  QString asPythonString( QgsProcessing::PythonOutputType outputType = QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const override;
165  QStringList dependsOnOtherParameters() const override;
166 
168  static QString typeName() { return QStringLiteral( "meshdatasettime" ); }
169 
171  QString meshLayerParameterName() const;
172 
174  QString datasetGroupParameterName() const;
175 
183  static QString valueAsTimeType( const QVariant &value );
184 
191  static QgsMeshDatasetIndex timeValueAsDatasetIndex( const QVariant &value );
192 
199  static QDateTime timeValueAsDefinedDateTime( const QVariant &value );
200 
201  private:
202  QString mMeshLayerParameterName;
203  QString mDatasetGroupParameterName;
204 
205  static bool valueIsAcceptable( const QVariant &input, bool allowEmpty );
206 };
207 
208 #ifndef SIP_RUN
210 
217 class CORE_EXPORT QgsProcessingParameterTypeMeshDatasetTime: public QgsProcessingParameterType
218 {
219  public:
220  QgsProcessingParameterDefinition *create( const QString &name ) const override SIP_FACTORY
221  {
222  return new QgsProcessingParameterMeshDatasetTime( name );
223  }
224 
225  QString description() const override
226  {
227  return QCoreApplication::translate( "Processing", "An input allowing selection of dataset index from a mesh layer by time setting" );
228  }
229 
230  QString name() const override
231  {
232  return QCoreApplication::translate( "Processing", "Mesh Dataset Time" );
233  }
234 
235  QString id() const override
236  {
238  }
239 
240  QString pythonImportString() const override
241  {
242  return QStringLiteral( "from qgis.core import QgsProcessingParameterMeshDatasetTime" );
243  }
244 
245  QString className() const override
246  {
247  return QStringLiteral( "QgsProcessingParameterMeshDatasetTime" );
248  }
249 
250  QStringList acceptedPythonTypes() const override
251  {
252  return QStringList() << QObject::tr( "dict{}: dictionary, see QgsProcessingParameterMeshDatasetTime docs" );
253  }
254 };
255 
257 #endif //SIP_RUN
258 
259 
260 #endif // QGSPROCESSINGPARAMETERMESHDATASET_H
DataType
Location of where data is specified for datasets in the dataset group.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
Contains information about the context in which a processing algorithm is executed.
Base class for the definition of processing parameters.
QString description() const
Returns the description for the parameter.
QString name() const
Returns the name of the parameter.
A parameter for processing algorithms that need a list of mesh dataset groups.
QgsProcessingParameterMeshDatasetGroups(const QString &name, const QString &description=QString(), const QString &meshLayerParameterName=QString(), QSet< int > supportedDataType=QSet< int >(), bool optional=false)
Constructor.
static QString typeName()
Returns the type name for the parameter class.
static QList< int > valueAsDatasetGroup(const QVariant &value)
Returns the value as a list if dataset group indexes.
QString meshLayerParameterName() const
Returns the name of the mesh layer parameter.
bool isDataTypeSupported(QgsMeshDatasetGroupMetadata::DataType dataType) const
Returns whether the data type is supported by the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
A parameter for processing algorithms that need a list of mesh dataset index from time parameter.
QgsProcessingParameterMeshDatasetTime(const QString &name, const QString &description=QString(), const QString &meshLayerParameterName=QString(), const QString &datasetGroupParameterName=QString())
Constructor.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString valueAsTimeType(const QVariant &value)
Returns the dataset value time type as a string : current-context-time : the time is store in the pro...
QString datasetGroupParameterName() const
Returns the name of the dataset groups parameter.
QString meshLayerParameterName() const
Returns the name of the mesh layer parameter.
static QgsMeshDatasetIndex timeValueAsDatasetIndex(const QVariant &value)
Returns the value as a QgsMeshDatasetIndex if the value has "dataset-time-step" type.
static QString typeName()
Returns the type name for the parameter class.
static QDateTime timeValueAsDefinedDateTime(const QVariant &value)
Returns the value as a QDateTime if the value has "defined-date-time" type.
Makes metadata of processing parameters available.
Contains enumerations and other constants for use in processing algorithms and parameters.
Definition: qgsprocessing.h:40
#define SIP_FACTORY
Definition: qgis_sip.h:76
const QString & typeName