QGIS API Documentation  3.2.0-Bonn (bc43194)
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 "qgsrendercontext.h"
26 #include "qgsmeshdataprovider.h"
28 
29 const int NO_ACTIVE_MESH_DATASET = -1;
30 
32 class QgsSymbol;
33 class QgsTriangularMesh;
34 struct QgsMesh;
35 
90 class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
91 {
92  Q_OBJECT
93  public:
94 
98  struct LayerOptions
99  {
100  int unused;
101  };
102 
116  explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
118  ~QgsMeshLayer() override;
119 
121  QgsMeshLayer( const QgsMeshLayer &rhs ) = delete;
123  QgsMeshLayer &operator=( QgsMeshLayer const &rhs ) = delete;
124 
125  QgsMeshDataProvider *dataProvider() override;
126  const QgsMeshDataProvider *dataProvider() const override SIP_SKIP;
127  QgsMeshLayer *clone() const override SIP_FACTORY;
128  QgsRectangle extent() const override;
129  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
130  bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context ) override;
131  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context ) const override;
132  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override;
133  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const override;
134  bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) override;
135  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
136 
138  QString providerType() const;
139 
141  QgsMesh *nativeMesh() SIP_SKIP;
142 
144  QgsTriangularMesh *triangularMesh() SIP_SKIP;
145 
147  QgsMeshRendererMeshSettings rendererNativeMeshSettings() const;
148 
150  void setRendererNativeMeshSettings( const QgsMeshRendererMeshSettings &settings );
151 
153  QgsMeshRendererMeshSettings rendererTriangularMeshSettings() const;
154 
156  void setRendererTriangularMeshSettings( const QgsMeshRendererMeshSettings &settings );
157 
159  QgsMeshRendererScalarSettings rendererScalarSettings() const;
160 
162  void setRendererScalarSettings( const QgsMeshRendererScalarSettings &settings );
163 
165  QgsMeshRendererVectorSettings rendererVectorSettings() const;
166 
168  void setRendererVectorSettings( const QgsMeshRendererVectorSettings &settings );
169 
175  void setActiveScalarDataset( int index = NO_ACTIVE_MESH_DATASET );
177  int activeScalarDataset() const { return mActiveScalarDataset; }
178 
184  void setActiveVectorDataset( int index = NO_ACTIVE_MESH_DATASET );
186  int activeVectorDataset() const { return mActiveVectorDataset; }
187 
188  private: // Private methods
189 
193  bool isReadOnly() const override {return true;}
194 
200  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options );
201 
202 #ifdef SIP_RUN
203  QgsMeshLayer( const QgsMeshLayer &rhs );
204 #endif
205 
206  private:
207  void fillNativeMesh();
208 
209  private:
211  QgsMeshDataProvider *mDataProvider = nullptr;
212 
214  QString mProviderKey;
215 
217  std::unique_ptr<QgsMesh> mNativeMesh;
218 
220  std::unique_ptr<QgsTriangularMesh> mTriangularMesh;
221 
222  QgsMeshRendererMeshSettings mRendererNativeMeshSettings;
223  QgsMeshRendererMeshSettings mRendererTriangularMeshSettings;
224  QgsMeshRendererScalarSettings mRendererScalarSettings;
225  QgsMeshRendererVectorSettings mRendererVectorSettings;
226 
228  int mActiveScalarDataset = NO_ACTIVE_MESH_DATASET;
229 
231  int mActiveVectorDataset = NO_ACTIVE_MESH_DATASET;
232 };
233 
234 #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:40
Base class for all map layer types.
Definition: qgsmaplayer.h:61
Triangular/Derived Mesh.
int activeVectorDataset() const
Returns active vector dataset.
Definition: qgsmeshlayer.h:186
Represents a mesh renderer settings for mesh object.
Represents a mesh renderer settings for scalar datasets.
Setting options for loading mesh layers.
Definition: qgsmeshlayer.h:98
const int NO_ACTIVE_MESH_DATASET
Definition: qgsmeshlayer.h:29
Represents a mesh renderer settings for vector datasets.
#define SIP_SKIP
Definition: qgis_sip.h:119
#define SIP_FACTORY
Definition: qgis_sip.h:69
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.
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