QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
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,
77 QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
78
79 QString parameterType() const override;
81 QgsProcessingAbstractParameterDefinitionWidget *createParameterDefinitionWidget(
82 QgsProcessingContext &context,
83 const QgsProcessingParameterWidgetContext &widgetContext,
84 const QgsProcessingParameterDefinition *definition = nullptr,
85 const QgsProcessingAlgorithm *algorithm = nullptr ) override;
86 void postInitialize( const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers ) override;
87
89 void setMeshLayerWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *wrapper );
90
91 protected:
92 QStringList compatibleParameterTypes() const override;
93 QStringList compatibleOutputTypes() const override;
94 QWidget *createWidget() override;
95 void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
96 QVariant widgetValue() const override;
97
98 private:
99 QgsProcessingMeshDatasetGroupsWidget *mWidget = nullptr;
100
101 friend class TestProcessingGui;
102};
103
104class GUI_EXPORT QgsProcessingMeshDatasetGroupsParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
105{
106 Q_OBJECT
107
108 public:
109 QgsProcessingMeshDatasetGroupsParameterDefinitionWidget( QgsProcessingContext &context,
110 const QgsProcessingParameterWidgetContext &widgetContext,
111 const QgsProcessingParameterDefinition *definition = nullptr,
112 const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
113
114 QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, Qgis::ProcessingParameterFlags flags ) const override;
115
116 private:
117 QComboBox *mParentLayerComboBox = nullptr;
118};
119
120class GUI_EXPORT QgsProcessingMeshDatasetTimeWidget : public QWidget, private Ui::QgsProcessingMeshDatasetTimeWidgetBase
121{
122 Q_OBJECT
123
124 public:
125 QgsProcessingMeshDatasetTimeWidget( QWidget *parent = nullptr,
126 const QgsProcessingParameterMeshDatasetTime *param = nullptr,
128
134 void setMeshLayer( QgsMeshLayer *layer, bool layerFromProject = false );
135 void setDatasetGroupIndexes( const QList<int> datasetGroupIndexes );
136
137 void setValue( const QVariant &value );
138 QVariant value() const;
139
140 public slots:
141 void updateValue();
142
143 signals:
144 void changed();
145
146 private:
147 const QgsProcessingParameterMeshDatasetTime *mParam = nullptr;
148 QVariantMap mValue;
149 QgsMapCanvas *mCanvas;
150
151 QLineEdit *mLineEdit = nullptr;
152 QToolButton *mToolButton = nullptr;
153 QgsMeshLayer *mMeshLayer = nullptr;
154 QList<int> mDatasetGroupIndexes;
155 QDateTime mReferenceTime;
156
157 void populateTimeSteps();
158 bool hasTemporalDataset() const;
160 void populateTimeStepsFromLayer();
162 void storeTimeStepsFromLayer( QgsMeshLayer *layer );
163 QMap<int, QList<qint64>> mDatasetTimeSteps; //used if layer does not come from project
164
165 void updateWidget();
166 void buildValue();
167
168 friend class TestProcessingGui;
169};
170
171class GUI_EXPORT QgsProcessingMeshDatasetTimeWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
172{
173 Q_OBJECT
174
175 public:
176 QgsProcessingMeshDatasetTimeWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
177 QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
178
179 QString parameterType() const override;
181 void postInitialize( const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers ) override;
182 QgsProcessingAbstractParameterDefinitionWidget *createParameterDefinitionWidget(
183 QgsProcessingContext &context,
184 const QgsProcessingParameterWidgetContext &widgetContext,
185 const QgsProcessingParameterDefinition *definition = nullptr,
186 const QgsProcessingAlgorithm *algorithm = nullptr ) override;
187
189 void setMeshLayerWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *wrapper );
190
192 void setDatasetGroupIndexesWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *wrapper );
193
194 protected:
195 QStringList compatibleParameterTypes() const override;
196 QStringList compatibleOutputTypes() const override;
197 QWidget *createWidget() override;
198 void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
199 QVariant widgetValue() const override;
200
201 private:
202 QgsProcessingMeshDatasetTimeWidget *mWidget = nullptr;
203 std::unique_ptr<QgsMeshLayer> mTemporarytMeshLayer;
204 friend class TestProcessingGui;
205};
206
207class GUI_EXPORT QgsProcessingMeshDatasetTimeParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
208{
209 Q_OBJECT
210
211 public:
212 QgsProcessingMeshDatasetTimeParameterDefinitionWidget( QgsProcessingContext &context,
213 const QgsProcessingParameterWidgetContext &widgetContext,
214 const QgsProcessingParameterDefinition *definition = nullptr,
215 const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
216
217 QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, Qgis::ProcessingParameterFlags flags ) const override;
218
219 private:
220 QComboBox *mParentDatasetComboBox = nullptr;
221 QString mMeshLayerParameterName;
222};
223
224
226
227#endif // QGSPROCESSINGMESHDATASETWIDGET_H
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
Definition qgis.h:3499
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.
WidgetType
Types of dialogs which Processing widgets can be created for.
@ Standard
Standard algorithm dialog.
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