QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
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
19#include "qgsmeshdataset.h"
23
24#include <QString>
25
26using namespace Qt::StringLiterals;
27
40{
41 public:
42
52 const QString &description = QString(),
53 const QString &meshLayerParameterName = QString(),
54 QSet<int> supportedDataType = QSet<int>(),
55 bool optional = false );
56
58 QString type() const override;
59 bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
60 QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
61 QString asPythonString( QgsProcessing::PythonOutputType outputType = QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass ) const override;
62 QStringList dependsOnOtherParameters() const override;
63 QVariantMap toVariantMap() const override;
64 bool fromVariantMap( const QVariantMap &map ) override;
65
67 static QString typeName() { return u"meshdatasetgroups"_s; }
68
70 QString meshLayerParameterName() const;
71
74
76 static QList<int> valueAsDatasetGroup( const QVariant &value );
77
78 private:
79 QString mMeshLayerParameterName;
80 QSet<int> mSupportedDataType;
81
82 static bool valueIsAcceptable( const QVariant &input, bool allowEmpty );
83};
84
85#ifndef SIP_RUN
87
94class CORE_EXPORT QgsProcessingParameterTypeMeshDatasetGroups : public QgsProcessingParameterType
95{
96 public:
97 QgsProcessingParameterDefinition *create( const QString &name ) const override SIP_FACTORY
98 {
100 }
101
102 QString description() const override
103 {
104 return QCoreApplication::translate( "Processing", "An input allowing selection dataset groups from a mesh layer" );
105 }
106
107 QString name() const override
108 {
109 return QCoreApplication::translate( "Processing", "Mesh Dataset Groups" );
110 }
111
112 QString id() const override
113 {
115 }
116
117 QString pythonImportString() const override
118 {
119 return u"from qgis.core import QgsProcessingParameterMeshDatasetGroups"_s;
120 }
121
122 QString className() const override
123 {
124 return u"QgsProcessingParameterMeshDatasetGroups"_s;
125 }
126
127 QStringList acceptedPythonTypes() const override
128 {
129 return QStringList() << QObject::tr( "list[int]: list of dataset group indexes, see QgsProcessingParameterMeshDatasetGroups docs" );
130 }
131
132 QStringList acceptedParameterTypes() const override
133 {
137 }
138
139 QStringList acceptedOutputTypes() const override
140 {
141 return QStringList() << QgsProcessingOutputString::typeName()
143 }
144};
145
147#endif //SIP_RUN
148
164{
165 public:
166
175 const QString &name,
176 const QString &description = QString(),
177 const QString &meshLayerParameterName = QString(),
178 const QString &datasetGroupParameterName = QString() );
179
181 QString type() const override;
182 bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
183 QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
184 QString asPythonString( QgsProcessing::PythonOutputType outputType = QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass ) const override;
185 QStringList dependsOnOtherParameters() const override;
186 QVariantMap toVariantMap() const override;
187 bool fromVariantMap( const QVariantMap &map ) override;
188
190 static QString typeName() { return u"meshdatasettime"_s; }
191
193 QString meshLayerParameterName() const;
194
197
205 static QString valueAsTimeType( const QVariant &value );
206
213 static QgsMeshDatasetIndex timeValueAsDatasetIndex( const QVariant &value );
214
221 static QDateTime timeValueAsDefinedDateTime( const QVariant &value );
222
223 private:
224 QString mMeshLayerParameterName;
225 QString mDatasetGroupParameterName;
226
227 static bool valueIsAcceptable( const QVariant &input, bool allowEmpty );
228};
229
230#ifndef SIP_RUN
232
239class CORE_EXPORT QgsProcessingParameterTypeMeshDatasetTime: public QgsProcessingParameterType
240{
241 public:
242 QgsProcessingParameterDefinition *create( const QString &name ) const override SIP_FACTORY
243 {
244 return new QgsProcessingParameterMeshDatasetTime( name );
245 }
246
247 QString description() const override
248 {
249 return QCoreApplication::translate( "Processing", "An input allowing selection of dataset index from a mesh layer by time setting" );
250 }
251
252 QString name() const override
253 {
254 return QCoreApplication::translate( "Processing", "Mesh Dataset Time" );
255 }
256
257 QString id() const override
258 {
260 }
261
262 QString pythonImportString() const override
263 {
264 return u"from qgis.core import QgsProcessingParameterMeshDatasetTime"_s;
265 }
266
267 QString className() const override
268 {
269 return u"QgsProcessingParameterMeshDatasetTime"_s;
270 }
271
272 QStringList acceptedPythonTypes() const override
273 {
274 return QStringList() << QObject::tr( "dict{}: dictionary, see QgsProcessingParameterMeshDatasetTime docs" );
275 }
276
277 QStringList acceptedParameterTypes() const override
278 {
279 return QStringList()
283 }
284
285 QStringList acceptedOutputTypes() const override
286 {
287 return QStringList()
289 }
290};
291
293#endif //SIP_RUN
294
295
296#endif // QGSPROCESSINGPARAMETERMESHDATASET_H
DataType
Location of where data is specified for datasets in the dataset group.
An index that identifies the dataset group (e.g.
Contains information about the context in which a processing algorithm is executed.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the output class.
static QString typeName()
Returns the type name for the parameter class.
Base class for the definition of processing parameters.
QString description() const
Returns the description for the parameter.
QgsProcessingParameterDefinition(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &help=QString())
Constructor for QgsProcessingParameterDefinition.
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.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString type() const override
Unique parameter type name.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString meshLayerParameterName() const
Returns the name of the mesh layer parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool isDataTypeSupported(QgsMeshDatasetGroupMetadata::DataType dataType) const
Returns whether the data type is supported by the parameter.
A parameter for processing algorithms that need a list of mesh dataset index from time parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterMeshDatasetTime(const QString &name, const QString &description=QString(), const QString &meshLayerParameterName=QString(), const QString &datasetGroupParameterName=QString())
Constructor.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
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...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
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.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
static QString typeName()
Returns the type name for the parameter class.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QDateTime timeValueAsDefinedDateTime(const QVariant &value)
Returns the value as a QDateTime if the value has "defined-date-time" type.
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.
Makes metadata of processing parameters available.
Contains enumerations and other constants for use in processing algorithms and parameters.
#define SIP_FACTORY
Definition qgis_sip.h:84