QGIS API Documentation  3.6.0-Noosa (5873452)
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 
29 struct QgsMeshLayerRendererCache;
30 class QgsSymbol;
31 class QgsTriangularMesh;
32 class QgsRenderContext;
33 struct QgsMesh;
34 
89 class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
90 {
91  Q_OBJECT
92  public:
93 
97  struct LayerOptions
98  {
99  int unused;
100  };
101 
115  explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
117  ~QgsMeshLayer() override;
118 
120  QgsMeshLayer( const QgsMeshLayer &rhs ) = delete;
122  QgsMeshLayer &operator=( QgsMeshLayer const &rhs ) = delete;
123 
124  QgsMeshDataProvider *dataProvider() override;
125  const QgsMeshDataProvider *dataProvider() const override SIP_SKIP;
126  QgsMeshLayer *clone() const override SIP_FACTORY;
127  QgsRectangle extent() const override;
128  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
129  bool readSymbology( const QDomNode &node, QString &errorMessage,
130  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) override;
131  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
132  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const override;
133  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override;
134  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const override;
135  bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) override;
136  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
137 
139  QString providerType() const;
140 
146  QgsMesh *nativeMesh() SIP_SKIP;
147 
153  const QgsMesh *nativeMesh() const SIP_SKIP;
154 
160  QgsTriangularMesh *triangularMesh() SIP_SKIP;
161 
167  const QgsTriangularMesh *triangularMesh() const SIP_SKIP;
168 
174  QgsMeshLayerRendererCache *rendererCache() SIP_SKIP;
175 
177  QgsMeshRendererSettings rendererSettings() const;
179  void setRendererSettings( const QgsMeshRendererSettings &settings );
180 
196  QgsMeshDatasetValue datasetValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point ) const;
197 
198  signals:
199 
205  void activeScalarDatasetChanged( const QgsMeshDatasetIndex &index );
206 
212  void activeVectorDatasetChanged( const QgsMeshDatasetIndex &index );
213 
214  private: // Private methods
215 
219  bool isReadOnly() const override {return true;}
220 
226  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options );
227 
228 #ifdef SIP_RUN
229  QgsMeshLayer( const QgsMeshLayer &rhs );
230 #endif
231 
232  private:
233  void fillNativeMesh();
234  void assignDefaultStyleToDatasetGroup( int groupIndex );
235  void setDefaultRendererSettings();
236 
237  private slots:
238  void onDatasetGroupsAdded( int count );
239 
240  private:
242  QgsMeshDataProvider *mDataProvider = nullptr;
243 
245  std::unique_ptr<QgsMesh> mNativeMesh;
246 
248  std::unique_ptr<QgsTriangularMesh> mTriangularMesh;
249 
251  std::unique_ptr<QgsMeshLayerRendererCache> mRendererCache;
252 
254  QgsMeshRendererSettings mRendererSettings;
255 };
256 
257 #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:64
Triangular/Derived Mesh is mesh with vertices in map coordinates.
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:97
Represents all mesh renderer settings.
#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.
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:89
QgsMeshDatasetValue represents single dataset value.