QGIS API Documentation 3.43.0-Master (56aa1fd18d7)
qgsprocessingmeshdatasetwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingmeshdatasetwidget.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 QGSPROCESSINGMESHDATASETWIDGET_H
17#define QGSPROCESSINGMESHDATASETWIDGET_H
18
19#include <QAction>
20
23#include "qgsmeshlayer.h"
24
25#include "ui_qgsprocessingmeshdatasettimewidget.h"
26
27#define SIP_NO_FILE
28
30
31class GUI_EXPORT QgsProcessingMeshDatasetGroupsWidget : public QWidget
32{
33 Q_OBJECT
34 public:
35 QgsProcessingMeshDatasetGroupsWidget( QWidget *parent = nullptr, const QgsProcessingParameterMeshDatasetGroups *param = nullptr );
36
42 void setMeshLayer( QgsMeshLayer *layer, bool layerFromProject = false );
43 void setValue( const QVariant &value );
44 QVariant value() const;
45
46 signals:
47 void changed();
48
49 private slots:
50 void showDialog();
51 void selectCurrentActiveDatasetGroup();
52
53 private:
54 const QgsProcessingParameterMeshDatasetGroups *mParam = nullptr;
55 QVariantList mValue;
56
57 QPointer<QLineEdit> mLineEdit;
58 QPointer<QToolButton> mToolButton;
59 QPointer<QAction> mActionCurrentActiveDatasetGroups;
60 QPointer<QAction> mActionAvailableDatasetGroups;
61 QgsMeshLayer *mMeshLayer = nullptr;
62 QMap<int, QString> mDatasetGroupsNames; //used to store the dataset groups name if layer is not referenced
63
64 QStringList datasetGroupsNames();
65 void updateSummaryText();
66
67 friend class TestProcessingGui;
68};
69
70
71class GUI_EXPORT QgsProcessingMeshDatasetGroupsWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
72{
73 Q_OBJECT
74
75 public:
76 QgsProcessingMeshDatasetGroupsWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr, Qgis::ProcessingMode type = Qgis::ProcessingMode::Standard, QWidget *parent = nullptr );
77
78 QString parameterType() const override;
80 QgsProcessingAbstractParameterDefinitionWidget *createParameterDefinitionWidget(
81 QgsProcessingContext &context,
82 const QgsProcessingParameterWidgetContext &widgetContext,
83 const QgsProcessingParameterDefinition *definition = nullptr,
84 const QgsProcessingAlgorithm *algorithm = nullptr
85 ) override;
86 void postInitialize( const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers ) override;
87
89 void setMeshLayerWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *wrapper );
90
91 protected:
92 QWidget *createWidget() override;
93 void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
94 QVariant widgetValue() const override;
95
96 private:
97 QgsProcessingMeshDatasetGroupsWidget *mWidget = nullptr;
98
99 friend class TestProcessingGui;
100};
101
102class GUI_EXPORT QgsProcessingMeshDatasetGroupsParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
103{
104 Q_OBJECT
105
106 public:
107 QgsProcessingMeshDatasetGroupsParameterDefinitionWidget( QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition = nullptr, const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
108
109 QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, Qgis::ProcessingParameterFlags flags ) const override;
110
111 private:
112 QComboBox *mParentLayerComboBox = nullptr;
113};
114
115class GUI_EXPORT QgsProcessingMeshDatasetTimeWidget : public QWidget, private Ui::QgsProcessingMeshDatasetTimeWidgetBase
116{
117 Q_OBJECT
118
119 public:
120 QgsProcessingMeshDatasetTimeWidget( QWidget *parent = nullptr, const QgsProcessingParameterMeshDatasetTime *param = nullptr, const QgsProcessingParameterWidgetContext &context = QgsProcessingParameterWidgetContext() );
121
127 void setMeshLayer( QgsMeshLayer *layer, bool layerFromProject = false );
128 void setDatasetGroupIndexes( const QList<int> datasetGroupIndexes );
129
130 void setValue( const QVariant &value );
131 QVariant value() const;
132
133 public slots:
134 void updateValue();
135
136 signals:
137 void changed();
138
139 private:
140 const QgsProcessingParameterMeshDatasetTime *mParam = nullptr;
141 QVariantMap mValue;
142 QgsMapCanvas *mCanvas;
143
144 QLineEdit *mLineEdit = nullptr;
145 QToolButton *mToolButton = nullptr;
146 QgsMeshLayer *mMeshLayer = nullptr;
147 QList<int> mDatasetGroupIndexes;
148 QDateTime mReferenceTime;
149
150 void populateTimeSteps();
151 bool hasTemporalDataset() const;
153 void populateTimeStepsFromLayer();
155 void storeTimeStepsFromLayer( QgsMeshLayer *layer );
156 QMap<int, QList<qint64>> mDatasetTimeSteps; //used if layer does not come from project
157
158 void updateWidget();
159 void buildValue();
160
161 friend class TestProcessingGui;
162};
163
164class GUI_EXPORT QgsProcessingMeshDatasetTimeWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
165{
166 Q_OBJECT
167
168 public:
169 QgsProcessingMeshDatasetTimeWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr, Qgis::ProcessingMode type = Qgis::ProcessingMode::Standard, QWidget *parent = nullptr );
170
171 QString parameterType() const override;
172 QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, Qgis::ProcessingMode type ) override;
173 void postInitialize( const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers ) override;
174 QgsProcessingAbstractParameterDefinitionWidget *createParameterDefinitionWidget(
175 QgsProcessingContext &context,
176 const QgsProcessingParameterWidgetContext &widgetContext,
177 const QgsProcessingParameterDefinition *definition = nullptr,
178 const QgsProcessingAlgorithm *algorithm = nullptr
179 ) override;
180
182 void setMeshLayerWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *wrapper );
183
185 void setDatasetGroupIndexesWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *wrapper );
186
187 protected:
188 QWidget *createWidget() override;
189 void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
190 QVariant widgetValue() const override;
191
192 private:
193 QgsProcessingMeshDatasetTimeWidget *mWidget = nullptr;
194 std::unique_ptr<QgsMeshLayer> mTemporarytMeshLayer;
195 friend class TestProcessingGui;
196};
197
198class GUI_EXPORT QgsProcessingMeshDatasetTimeParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
199{
200 Q_OBJECT
201
202 public:
203 QgsProcessingMeshDatasetTimeParameterDefinitionWidget( QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition = nullptr, const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
204
205 QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, Qgis::ProcessingParameterFlags flags ) const override;
206
207 private:
208 QComboBox *mParentDatasetComboBox = nullptr;
209 QString mMeshLayerParameterName;
210};
211
212
214
215#endif // QGSPROCESSINGMESHDATASETWIDGET_H
ProcessingMode
Types of modes which Processing widgets can be created for.
Definition qgis.h:3537
@ Standard
Standard (single-run) algorithm mode.
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
Definition qgis.h:3643
A widget wrapper for Processing parameter value widgets.
Map canvas is a class for displaying all GIS data types on a canvas.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Abstract base class for widgets which allow users to specify the properties of a Processing parameter...
Abstract base class for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
Base class for the definition of processing parameters.
A parameter for processing algorithms that need a list of mesh dataset groups.
A parameter for processing algorithms that need a list of mesh dataset index from time parameter.
Contains settings which reflect the context in which a Processing parameter widget is shown.
An interface for Processing widget wrapper factories.
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_TRANSFERTHIS
Definition qgis_sip.h:53