QGIS API Documentation  3.21.0-Master (909859188c)
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 
31 class 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 = nullptr;
58  QPointer<QToolButton> mToolButton = nullptr;
59  QPointer<QAction> mActionCurrentActiveDatasetGroups = nullptr;
60  QPointer<QAction> mActionAvailableDatasetGroups = nullptr;
61  QgsMeshLayer *mMeshLayer = nullptr;
62  QMap<int, QString> mDatasetGroupsNames; //used to store the dataet groups name if layer is not referenced
63 
64  QStringList datasetGroupsNames();
65  void updateSummaryText();
66 
67  friend class TestProcessingGui;
68 };
69 
70 
71 class 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  void postInitialize( const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers ) override;
82 
84  void setMeshLayerWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *wrapper );
85 
86  protected:
87  QStringList compatibleParameterTypes() const override;
88  QStringList compatibleOutputTypes() const override;
89  QWidget *createWidget() override;
90  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
91  QVariant widgetValue() const override;
92 
93  private:
94  QgsProcessingMeshDatasetGroupsWidget *mWidget = nullptr;
95  std::unique_ptr<QgsMeshLayer> mTemporarytMeshLayer;
96 
97  friend class TestProcessingGui;
98 };
99 
100 
101 class GUI_EXPORT QgsProcessingMeshDatasetTimeWidget : public QWidget, private Ui::QgsProcessingMeshDatasetTimeWidgetBase
102 {
103  Q_OBJECT
104  public:
105  QgsProcessingMeshDatasetTimeWidget( QWidget *parent = nullptr,
106  const QgsProcessingParameterMeshDatasetTime *param = nullptr,
108 
114  void setMeshLayer( QgsMeshLayer *layer, bool layerFromProject = false );
115  void setDatasetGroupIndexes( const QList<int> datasetGroupIndexes );
116 
117  void setValue( const QVariant &value );
118  QVariant value() const;
119 
120  public slots:
121  void updateValue();
122 
123  signals:
124  void changed();
125 
126  private:
127  const QgsProcessingParameterMeshDatasetTime *mParam = nullptr;
128  QVariantMap mValue;
129  QgsMapCanvas *mCanvas;
130 
131  QLineEdit *mLineEdit = nullptr;
132  QToolButton *mToolButton = nullptr;
133  QgsMeshLayer *mMeshLayer = nullptr;
134  QList<int> mDatasetGroupIndexes;
135  QDateTime mReferenceTime;
136 
137  void populateTimeSteps();
138  bool hasTemporalDataset() const;
140  void populateTimeStepsFromLayer();
142  void storeTimeStepsFromLayer( QgsMeshLayer *layer );
143  QMap<int, QList<qint64>> mDatasetTimeSteps; //used if layer does not come from project
144 
145  void updateWidget();
146  void buildValue();
147 
148  friend class TestProcessingGui;
149 };
150 
151 class GUI_EXPORT QgsProcessingMeshDatasetTimeWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
152 {
153  Q_OBJECT
154 
155  public:
156  QgsProcessingMeshDatasetTimeWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
157  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
158 
159  QString parameterType() const override;
161  void postInitialize( const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers ) override;
162 
164  void setMeshLayerWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *wrapper );
165 
167  void setDatasetGroupIndexesWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *wrapper );
168 
169  protected:
170  QStringList compatibleParameterTypes() const override;
171  QStringList compatibleOutputTypes() const override;
172  QWidget *createWidget() override;
173  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
174  QVariant widgetValue() const override;
175 
176  private:
177  QgsProcessingMeshDatasetTimeWidget *mWidget = nullptr;
178  std::unique_ptr<QgsMeshLayer> mTemporarytMeshLayer;
179  friend class TestProcessingGui;
180 };
181 
183 
184 #endif // QGSPROCESSINGMESHDATASETWIDGET_H
A widget wrapper for Processing parameter value widgets.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:87
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:96
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.