QGIS API Documentation 3.41.0-Master (af5edcb665c)
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, QgsProcessingGui::WidgetType type = QgsProcessingGui::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 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, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition = nullptr, const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
110
111 QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, Qgis::ProcessingParameterFlags flags ) const override;
112
113 private:
114 QComboBox *mParentLayerComboBox = nullptr;
115};
116
117class GUI_EXPORT QgsProcessingMeshDatasetTimeWidget : public QWidget, private Ui::QgsProcessingMeshDatasetTimeWidgetBase
118{
119 Q_OBJECT
120
121 public:
122 QgsProcessingMeshDatasetTimeWidget( QWidget *parent = nullptr, const QgsProcessingParameterMeshDatasetTime *param = nullptr, const QgsProcessingParameterWidgetContext &context = QgsProcessingParameterWidgetContext() );
123
129 void setMeshLayer( QgsMeshLayer *layer, bool layerFromProject = false );
130 void setDatasetGroupIndexes( const QList<int> datasetGroupIndexes );
131
132 void setValue( const QVariant &value );
133 QVariant value() const;
134
135 public slots:
136 void updateValue();
137
138 signals:
139 void changed();
140
141 private:
142 const QgsProcessingParameterMeshDatasetTime *mParam = nullptr;
143 QVariantMap mValue;
144 QgsMapCanvas *mCanvas;
145
146 QLineEdit *mLineEdit = nullptr;
147 QToolButton *mToolButton = nullptr;
148 QgsMeshLayer *mMeshLayer = nullptr;
149 QList<int> mDatasetGroupIndexes;
150 QDateTime mReferenceTime;
151
152 void populateTimeSteps();
153 bool hasTemporalDataset() const;
155 void populateTimeStepsFromLayer();
157 void storeTimeStepsFromLayer( QgsMeshLayer *layer );
158 QMap<int, QList<qint64>> mDatasetTimeSteps; //used if layer does not come from project
159
160 void updateWidget();
161 void buildValue();
162
163 friend class TestProcessingGui;
164};
165
166class GUI_EXPORT QgsProcessingMeshDatasetTimeWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
167{
168 Q_OBJECT
169
170 public:
171 QgsProcessingMeshDatasetTimeWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr, QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
172
173 QString parameterType() const override;
175 void postInitialize( const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers ) override;
176 QgsProcessingAbstractParameterDefinitionWidget *createParameterDefinitionWidget(
177 QgsProcessingContext &context,
178 const QgsProcessingParameterWidgetContext &widgetContext,
179 const QgsProcessingParameterDefinition *definition = nullptr,
180 const QgsProcessingAlgorithm *algorithm = nullptr
181 ) override;
182
184 void setMeshLayerWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *wrapper );
185
187 void setDatasetGroupIndexesWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *wrapper );
188
189 protected:
190 QStringList compatibleParameterTypes() const override;
191 QStringList compatibleOutputTypes() const override;
192 QWidget *createWidget() override;
193 void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
194 QVariant widgetValue() const override;
195
196 private:
197 QgsProcessingMeshDatasetTimeWidget *mWidget = nullptr;
198 std::unique_ptr<QgsMeshLayer> mTemporarytMeshLayer;
199 friend class TestProcessingGui;
200};
201
202class GUI_EXPORT QgsProcessingMeshDatasetTimeParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
203{
204 Q_OBJECT
205
206 public:
207 QgsProcessingMeshDatasetTimeParameterDefinitionWidget( QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition = nullptr, const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
208
209 QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, Qgis::ProcessingParameterFlags flags ) const override;
210
211 private:
212 QComboBox *mParentDatasetComboBox = nullptr;
213 QString mMeshLayerParameterName;
214};
215
216
218
219#endif // QGSPROCESSINGMESHDATASETWIDGET_H
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
Definition qgis.h:3562
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