QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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  QgsMeshDatasetGroupMetadata::DataType mScalarDataType = QgsMeshDatasetGroupMetadata::DataType::DataOnVertices;
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  QgsMeshDatasetGroupMetadata::DataType mVectorDataType = QgsMeshDatasetGroupMetadata::DataType::DataOnVertices;
78  std::unique_ptr<QgsMesh3dAveragingMethod> mVectorAveragingMethod;
79 };
80 
81 
83 
92 {
93  public:
96  ~QgsMeshLayerRenderer() override = default;
97  QgsFeedback *feedback() const override;
98  bool render() override;
99 
100  private:
101  void renderMesh();
102  void renderEdgeMesh( const QgsMeshRendererMeshSettings &settings, const QList<int> &edgesInExtent );
103  void renderFaceMesh( const QgsMeshRendererMeshSettings &settings, const QVector<QgsMeshFace> &faces, const QList<int> &facesInExtent );
104  void renderScalarDataset();
105  void renderScalarDatasetOnEdges( const QgsMeshRendererScalarSettings &scalarSettings );
106  void renderScalarDatasetOnFaces( const QgsMeshRendererScalarSettings &scalarSettings );
107 
108  void renderVectorDataset();
109  void copyTriangularMeshes( QgsMeshLayer *layer, QgsRenderContext &context );
110  void copyScalarDatasetValues( QgsMeshLayer *layer );
111  void copyVectorDatasetValues( QgsMeshLayer *layer );
112  void calculateOutputSize();
113  QgsPointXY fractionPoint( const QgsPointXY &p1, const QgsPointXY &p2, double fraction ) const;
114  bool mIsMeshSimplificationActive = false;
115  QColor colorAt( QgsColorRampShader *shader, double val ) const;
116 
117  protected:
119  std::unique_ptr<QgsMeshLayerRendererFeedback> mFeedback;
120 
121  // copy from mesh layer
123 
124  // copy from mesh layer
126 
127  // copy from mesh layer
129 
130  // copy of the scalar dataset
131  QVector<double> mScalarDatasetValues;
134  double mScalarDatasetMinimum = std::numeric_limits<double>::quiet_NaN();
135  double mScalarDatasetMaximum = std::numeric_limits<double>::quiet_NaN();
136 
137  // copy of the vector dataset
139  QVector<double> mVectorDatasetValuesMag;
140  double mVectorDatasetMagMinimum = std::numeric_limits<double>::quiet_NaN();
141  double mVectorDatasetMagMaximum = std::numeric_limits<double>::quiet_NaN();
142  double mVectorDatasetGroupMagMinimum = std::numeric_limits<double>::quiet_NaN();
143  double mVectorDatasetGroupMagMaximum = std::numeric_limits<double>::quiet_NaN();
145 
146  // copy of rendering settings
148 
149  // output screen size
150  QSize mOutputSize;
151 };
152 
153 
154 #endif // QGSMESHLAYERRENDERER_H
QgsMeshLayerRenderer::mScalarDataType
QgsMeshDatasetGroupMetadata::DataType mScalarDataType
Definition: qgsmeshlayerrenderer.h:133
QgsMeshLayerRenderer::mTriangularMesh
QgsTriangularMesh mTriangularMesh
Definition: qgsmeshlayerrenderer.h:125
QgsMeshLayerRenderer::mScalarDatasetValues
QVector< double > mScalarDatasetValues
Definition: qgsmeshlayerrenderer.h:131
QgsMeshLayerRenderer::mRendererSettings
QgsMeshRendererSettings mRendererSettings
Definition: qgsmeshlayerrenderer.h:147
QgsMeshLayerRenderer::mVectorDatasetGroupMagMinimum
double mVectorDatasetGroupMagMinimum
Definition: qgsmeshlayerrenderer.h:142
QgsMeshRendererSettings
Definition: qgsmeshrenderersettings.h:590
QgsMeshLayerRenderer::mScalarDatasetMaximum
double mScalarDatasetMaximum
Definition: qgsmeshlayerrenderer.h:135
QgsMeshRendererMeshSettings
Definition: qgsmeshrenderersettings.h:41
QgsMeshLayerRenderer::mVectorDataType
QgsMeshDatasetGroupMetadata::DataType mVectorDataType
Definition: qgsmeshlayerrenderer.h:144
QgsMeshLayerRenderer::feedback
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr)
Definition: qgsmeshlayerrenderer.cpp:90
QgsMeshLayerRenderer::mLayerExtent
QgsRectangle mLayerExtent
Definition: qgsmeshlayerrenderer.h:128
QgsMeshLayerRenderer::~QgsMeshLayerRenderer
~QgsMeshLayerRenderer() override=default
QgsMeshLayerRenderer::render
bool render() override
Do the rendering (based on data stored in the class)
Definition: qgsmeshlayerrenderer.cpp:284
qgis.h
QgsRenderContext
Definition: qgsrendercontext.h:57
QgsMesh
Definition: qgsmeshdataprovider.h:57
QgsMeshLayerRenderer::mNativeMesh
QgsMesh mNativeMesh
Definition: qgsmeshlayerrenderer.h:122
QgsColorRampShader
Definition: qgscolorrampshader.h:39
QgsRectangle
Definition: qgsrectangle.h:41
QgsMapLayerRenderer
Definition: qgsmaplayerrenderer.h:50
qgstriangularmesh.h
QgsMeshDatasetGroupMetadata::DataOnVertices
@ DataOnVertices
Data is defined on vertices.
Definition: qgsmeshdataset.h:356
qgsrasterinterface.h
QgsMeshLayerRenderer::mVectorDatasetValuesMag
QVector< double > mVectorDatasetValuesMag
Definition: qgsmeshlayerrenderer.h:139
QgsMeshLayerRenderer::mFeedback
std::unique_ptr< QgsMeshLayerRendererFeedback > mFeedback
feedback class for cancellation
Definition: qgsmeshlayerrenderer.h:119
QgsMeshDatasetIndex
Definition: qgsmeshdataset.h:45
QgsFeedback
Definition: qgsfeedback.h:43
QgsMeshLayer
Definition: qgsmeshlayer.h:94
QgsMeshLayerRenderer::QgsMeshLayerRenderer
QgsMeshLayerRenderer(QgsMeshLayer *layer, QgsRenderContext &context)
Ctor.
Definition: qgsmeshlayerrenderer.cpp:43
QgsMeshLayerRenderer::mVectorDatasetValues
QgsMeshDataBlock mVectorDatasetValues
Definition: qgsmeshlayerrenderer.h:138
qgsmaplayerrenderer.h
QgsMeshRendererScalarSettings::None
@ None
Does not use resampling.
Definition: qgsmeshrenderersettings.h:111
QgsMeshLayerRenderer::mVectorDatasetMagMaximum
double mVectorDatasetMagMaximum
Definition: qgsmeshlayerrenderer.h:141
QgsMeshRendererScalarSettings::DataResamplingMethod
DataResamplingMethod
Resampling of value from dataset.
Definition: qgsmeshrenderersettings.h:105
QgsMeshLayerRenderer::mVectorDatasetGroupMagMaximum
double mVectorDatasetGroupMagMaximum
Definition: qgsmeshlayerrenderer.h:143
qgsmeshlayer.h
QgsPointXY
Definition: qgspointxy.h:43
QgsMeshRendererScalarSettings
Definition: qgsmeshrenderersettings.h:94
qgsmeshtracerenderer.h
QgsMeshLayerRenderer::mScalarActiveFaceFlagValues
QgsMeshDataBlock mScalarActiveFaceFlagValues
Definition: qgsmeshlayerrenderer.h:132
QgsMeshDatasetGroupMetadata::DataType
DataType
Location of where data is specified for datasets in the dataset group.
Definition: qgsmeshdataset.h:353
QgsRasterBlockFeedback
Definition: qgsrasterinterface.h:40
QgsMeshLayerRenderer
Definition: qgsmeshlayerrenderer.h:91
QgsMeshDataBlock
Definition: qgsmeshdataset.h:134
QgsTriangularMesh
Definition: qgstriangularmesh.h:49
qgssymbol.h
QgsMeshLayerRenderer::mScalarDatasetMinimum
double mScalarDatasetMinimum
Definition: qgsmeshlayerrenderer.h:134
qgsmeshdataprovider.h
QgsMeshLayerRenderer::mVectorDatasetMagMinimum
double mVectorDatasetMagMinimum
Definition: qgsmeshlayerrenderer.h:140
QgsMeshLayerRenderer::mOutputSize
QSize mOutputSize
Definition: qgsmeshlayerrenderer.h:150