QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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  };
111 
125  explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = QStringLiteral( "mesh_memory" ),
127 
128  ~QgsMeshLayer() override;
129 
131  QgsMeshLayer( const QgsMeshLayer &rhs ) = delete;
133  QgsMeshLayer &operator=( QgsMeshLayer const &rhs ) = delete;
134 
135  QgsMeshDataProvider *dataProvider() override;
136  const QgsMeshDataProvider *dataProvider() const override SIP_SKIP;
137  QgsMeshLayer *clone() const override SIP_FACTORY;
138  QgsRectangle extent() const override;
139  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
140  bool readSymbology( const QDomNode &node, QString &errorMessage,
141  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) override;
142  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
143  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const override;
144  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override;
145  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const override;
146  bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) override;
147  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
148 
149  void reload() override;
150 
152  QString providerType() const;
153 
159  QgsMesh *nativeMesh() SIP_SKIP;
160 
166  const QgsMesh *nativeMesh() const SIP_SKIP;
167 
173  QgsTriangularMesh *triangularMesh() SIP_SKIP;
174 
180  const QgsTriangularMesh *triangularMesh() const SIP_SKIP;
181 
187  QgsMeshLayerRendererCache *rendererCache() SIP_SKIP;
188 
190  QgsMeshRendererSettings rendererSettings() const;
192  void setRendererSettings( const QgsMeshRendererSettings &settings );
193 
199  QgsMeshTimeSettings timeSettings() const;
200 
206  void setTimeSettings( const QgsMeshTimeSettings &settings );
207 
214  QString formatTime( double hours );
215 
231  QgsMeshDatasetValue datasetValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point ) const;
232 
233  public slots:
234 
240  void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
241 
242 
243  signals:
244 
250  void activeScalarDatasetChanged( const QgsMeshDatasetIndex &index );
251 
257  void activeVectorDatasetChanged( const QgsMeshDatasetIndex &index );
258 
264  void timeSettingsChanged( );
265 
266  private: // Private methods
267 
271  bool isReadOnly() const override {return true;}
272 
278  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options );
279 
280 #ifdef SIP_RUN
281  QgsMeshLayer( const QgsMeshLayer &rhs );
282 #endif
283 
284  private:
285  void fillNativeMesh();
286  void assignDefaultStyleToDatasetGroup( int groupIndex );
287  void setDefaultRendererSettings();
288 
289  private slots:
290  void onDatasetGroupsAdded( int count );
291 
292  private:
294  QgsMeshDataProvider *mDataProvider = nullptr;
295 
297  std::unique_ptr<QgsMesh> mNativeMesh;
298 
300  std::unique_ptr<QgsTriangularMesh> mTriangularMesh;
301 
303  std::unique_ptr<QgsMeshLayerRendererCache> mRendererCache;
304 
306  QgsMeshRendererSettings mRendererSettings;
307 
309  QgsMeshTimeSettings mTimeSettings;
310 
311 };
312 
313 #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:78
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:119
#define SIP_FACTORY
Definition: qgis_sip.h:69
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.