QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 
30 struct QgsMeshLayerRendererCache;
31 class QgsSymbol;
32 class QgsTriangularMesh;
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 
142  QgsMesh *nativeMesh() SIP_SKIP;
143 
145  QgsTriangularMesh *triangularMesh() SIP_SKIP;
146 
148  QgsMeshLayerRendererCache *rendererCache() SIP_SKIP;
149 
151  QgsMeshRendererSettings rendererSettings() const;
153  void setRendererSettings( const QgsMeshRendererSettings &settings );
154 
170  QgsMeshDatasetValue datasetValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point ) const;
171 
172  signals:
173 
179  void activeScalarDatasetChanged( const QgsMeshDatasetIndex &index );
180 
186  void activeVectorDatasetChanged( const QgsMeshDatasetIndex &index );
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  void assignDefaultStyleToDatasetGroup( int groupIndex );
209 
210  private slots:
211  void onDatasetGroupsAdded( int count );
212 
213  private:
215  QgsMeshDataProvider *mDataProvider = nullptr;
216 
218  QString mProviderKey;
219 
221  std::unique_ptr<QgsMesh> mNativeMesh;
222 
224  std::unique_ptr<QgsTriangularMesh> mTriangularMesh;
225 
227  std::unique_ptr<QgsMeshLayerRendererCache> mRendererCache;
228 
230  QgsMeshRendererSettings mRendererSettings;
231 };
232 
233 #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:63
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.