QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
qgsmeshlayerrenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmeshlayerrenderer.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 QGSMESHLAYERRENDERER_H
19 #define QGSMESHLAYERRENDERER_H
20 
21 class QgsMeshLayer;
22 
23 #define SIP_NO_FILE
24 
25 #include <memory>
26 #include <limits>
27 
28 #include "qgis.h"
29 
30 #include "qgsmaplayerrenderer.h"
31 #include "qgsrasterinterface.h"
32 #include "qgstriangularmesh.h"
33 #include "qgsmeshlayer.h"
34 #include "qgssymbol.h"
35 #include "qgsmeshdataprovider.h"
36 #include "qgsmeshtracerenderer.h"
37 
38 class QgsRenderContext;
39 
41 
46 class QgsMeshLayerRendererFeedback : public QgsRasterBlockFeedback
47 {
48  Q_OBJECT
49 };
50 
51 
55 struct CORE_NO_EXPORT QgsMeshLayerRendererCache
56 {
57  int mDatasetGroupsCount = 0;
58 
59  // scalar dataset
60  QgsMeshDatasetIndex mActiveScalarDatasetIndex;
61  QVector<double> mScalarDatasetValues;
62  QgsMeshDataBlock mScalarActiveFaceFlagValues;
63  bool mScalarDataOnVertices = true;
64  double mScalarDatasetMinimum = std::numeric_limits<double>::quiet_NaN();
65  double mScalarDatasetMaximum = std::numeric_limits<double>::quiet_NaN();
67  std::unique_ptr<QgsMesh3dAveragingMethod> mScalarAveragingMethod;
68 
69  // vector dataset
70  QgsMeshDatasetIndex mActiveVectorDatasetIndex;
71  QgsMeshDataBlock mVectorDatasetValues;
72  QVector<double> mVectorDatasetValuesMag;
73  double mVectorDatasetMagMinimum = std::numeric_limits<double>::quiet_NaN();
74  double mVectorDatasetMagMaximum = std::numeric_limits<double>::quiet_NaN();
75  double mVectorDatasetGroupMagMinimum = std::numeric_limits<double>::quiet_NaN();
76  double mVectorDatasetGroupMagMaximum = std::numeric_limits<double>::quiet_NaN();
77  bool mVectorDataOnVertices = true;
78  std::unique_ptr<QgsMesh3dAveragingMethod> mVectorAveragingMethod;
79 };
80 
82 
91 {
92  public:
95  ~QgsMeshLayerRenderer() override = default;
96  QgsFeedback *feedback() const override;
97  bool render() override;
98 
99  private:
100  void renderMesh();
101  void renderMesh( const QgsMeshRendererMeshSettings &settings, const QVector<QgsMeshFace> &faces, const QList<int> &facesInExtent );
102  void renderScalarDataset();
103  void renderVectorDataset();
104  void copyScalarDatasetValues( QgsMeshLayer *layer );
105  void copyVectorDatasetValues( QgsMeshLayer *layer );
106  void calculateOutputSize();
107 
108  protected:
110  std::unique_ptr<QgsMeshLayerRendererFeedback> mFeedback;
111 
112  // copy from mesh layer
114 
115  // copy from mesh layer
117 
118  // copy from mesh layer
120 
121  // copy of the scalar dataset
122  QVector<double> mScalarDatasetValues;
124  bool mScalarDataOnVertices = true;
125  double mScalarDatasetMinimum = std::numeric_limits<double>::quiet_NaN();
126  double mScalarDatasetMaximum = std::numeric_limits<double>::quiet_NaN();
127 
128  // copy of the vector dataset
130  QVector<double> mVectorDatasetValuesMag;
131  double mVectorDatasetMagMinimum = std::numeric_limits<double>::quiet_NaN();
132  double mVectorDatasetMagMaximum = std::numeric_limits<double>::quiet_NaN();
133  double mVectorDatasetGroupMagMinimum = std::numeric_limits<double>::quiet_NaN();
134  double mVectorDatasetGroupMagMaximum = std::numeric_limits<double>::quiet_NaN();
135  bool mVectorDataOnVertices = true;
136 
137  // copy of rendering settings
139 
140  // output screen size
141  QSize mOutputSize;
142 };
143 
144 
145 #endif // QGSMESHLAYERRENDERER_H
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Triangular/Derived Mesh is mesh with vertices in map coordinates.
QgsMeshRendererSettings mRendererSettings
Represents a mesh renderer settings for mesh object.
Use data defined on face centers, do not interpolate to vertices.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e...
QVector< double > mScalarDatasetValues
Implementation of threaded rendering for mesh layers.
QgsMeshDataBlock mVectorDatasetValues
QVector< double > mVectorDatasetValuesMag
QgsTriangularMesh mTriangularMesh
Base class for feedback objects to be used for cancellation of something running in a worker thread...
Definition: qgsfeedback.h:45
Represents all mesh renderer settings.
DataInterpolationMethod
Interpolation of value defined on vertices from datasets with data defined on faces.
std::unique_ptr< QgsMeshLayerRendererFeedback > mFeedback
feedback class for cancellation
Contains information about the context of a rendering operation.
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:91
QgsMeshDataBlock mScalarActiveFaceFlagValues
Feedback object tailored for raster block reading.