QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
qgsmeshlayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmeshlayer.h
3  --------------
4  begin : April 2018
5  copyright : (C) 2018 by Peter Petrik
6  email : zilolv at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSMESHLAYER_H
19 #define QGSMESHLAYER_H
20 
21 #include <memory>
22 
23 #include "qgis_core.h"
24 #include "qgsmaplayer.h"
25 #include "qgsmeshdataprovider.h"
27 #include "qgsmeshtimesettings.h"
28 
30 struct QgsMeshLayerRendererCache;
31 class QgsSymbol;
32 class QgsTriangularMesh;
33 class QgsRenderContext;
34 struct QgsMesh;
35 
90 class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
91 {
92  Q_OBJECT
93  public:
94 
98  struct LayerOptions
99  {
100 
106  : transformContext( transformContext )
107  {}
108 
110 
124  bool skipCrsValidation = false;
125  };
126 
140  explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = QStringLiteral( "mesh_memory" ),
142 
143  ~QgsMeshLayer() override;
144 
146  QgsMeshLayer( const QgsMeshLayer &rhs ) = delete;
148  QgsMeshLayer &operator=( QgsMeshLayer const &rhs ) = delete;
149 
150  QgsMeshDataProvider *dataProvider() override;
151  const QgsMeshDataProvider *dataProvider() const override SIP_SKIP;
152  QgsMeshLayer *clone() const override SIP_FACTORY;
153  QgsRectangle extent() const override;
154  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
155  bool readSymbology( const QDomNode &node, QString &errorMessage,
156  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) override;
157  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
158  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const override;
159  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override;
160  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const override;
161  bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) override;
162  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
163 
164  void reload() override;
165 
167  QString providerType() const;
168 
174  QgsMesh *nativeMesh() SIP_SKIP;
175 
181  const QgsMesh *nativeMesh() const SIP_SKIP;
182 
188  QgsTriangularMesh *triangularMesh() SIP_SKIP;
189 
195  const QgsTriangularMesh *triangularMesh() const SIP_SKIP;
196 
202  QgsMeshLayerRendererCache *rendererCache() SIP_SKIP;
203 
205  QgsMeshRendererSettings rendererSettings() const;
207  void setRendererSettings( const QgsMeshRendererSettings &settings );
208 
214  QgsMeshTimeSettings timeSettings() const;
215 
221  void setTimeSettings( const QgsMeshTimeSettings &settings );
222 
229  QString formatTime( double hours );
230 
246  QgsMeshDatasetValue datasetValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point ) const;
247 
248  public slots:
249 
255  void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
256 
257 
258  signals:
259 
265  void activeScalarDatasetChanged( const QgsMeshDatasetIndex &index );
266 
272  void activeVectorDatasetChanged( const QgsMeshDatasetIndex &index );
273 
279  void timeSettingsChanged( );
280 
281  private: // Private methods
282 
286  bool isReadOnly() const override {return true;}
287 
293  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options );
294 
295 #ifdef SIP_RUN
296  QgsMeshLayer( const QgsMeshLayer &rhs );
297 #endif
298 
299  private:
300  void fillNativeMesh();
301  void assignDefaultStyleToDatasetGroup( int groupIndex );
302  void setDefaultRendererSettings();
303 
304  private slots:
305  void onDatasetGroupsAdded( int count );
306 
307  private:
309  QgsMeshDataProvider *mDataProvider = nullptr;
310 
312  std::unique_ptr<QgsMesh> mNativeMesh;
313 
315  std::unique_ptr<QgsTriangularMesh> mTriangularMesh;
316 
318  std::unique_ptr<QgsMeshLayerRendererCache> mRendererCache;
319 
321  QgsMeshRendererSettings mRendererSettings;
322 
324  QgsMeshTimeSettings mTimeSettings;
325 
326 };
327 
328 #endif //QGSMESHLAYER_H
The class is used as a container of context for various read/write operations on other objects...
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Base class for all map layer types.
Definition: qgsmaplayer.h:79
Triangular/Derived Mesh is mesh with vertices in map coordinates.
QgsCoordinateTransformContext transformContext
Definition: qgsmeshlayer.h:109
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
A class to represent a 2D point.
Definition: qgspointxy.h:43
Setting options for loading mesh layers.
Definition: qgsmeshlayer.h:98
Represents all mesh renderer settings.
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_FACTORY
Definition: qgis_sip.h:76
Contains information about the context in which a coordinate transform is executed.
LayerOptions(const QgsCoordinateTransformContext &transformContext=QgsCoordinateTransformContext())
Constructor for LayerOptions with optional transformContext.
Definition: qgsmeshlayer.h:105
Represents a mesh time settings for mesh datasets.
Base class for providing data for QgsMeshLayer.
Contains information about the context of a rendering operation.
Setting options for creating vector data providers.
Mesh - vertices and faces.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
Base class for utility classes that encapsulate information necessary for rendering of map layers...
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:90
QgsMeshDatasetValue represents single dataset value.