QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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
21class 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 "qgsmeshdataprovider.h"
37
40
42
47class QgsMeshLayerRendererFeedback : public QgsRasterBlockFeedback
48{
49 Q_OBJECT
50};
51
52
56struct CORE_NO_EXPORT QgsMeshLayerRendererCache
57{
58 int mDatasetGroupsCount = 0;
59
60 // scalar dataset
61 QgsMeshDatasetIndex mActiveScalarDatasetIndex;
62 QVector<double> mScalarDatasetValues;
63 QgsMeshDataBlock mScalarActiveFaceFlagValues;
65 double mScalarDatasetMinimum = std::numeric_limits<double>::quiet_NaN();
66 double mScalarDatasetMaximum = std::numeric_limits<double>::quiet_NaN();
68 std::unique_ptr<QgsMesh3DAveragingMethod> mScalarAveragingMethod;
69
70 // vector dataset
71 QgsMeshDatasetIndex mActiveVectorDatasetIndex;
72 QgsMeshDataBlock mVectorDatasetValues;
73 QgsMeshDataBlock mVectorActiveFaceFlagValues;
74 QVector<double> mVectorDatasetValuesMag;
75 double mVectorDatasetMagMinimum = std::numeric_limits<double>::quiet_NaN();
76 double mVectorDatasetMagMaximum = std::numeric_limits<double>::quiet_NaN();
77 double mVectorDatasetGroupMagMinimum = std::numeric_limits<double>::quiet_NaN();
78 double mVectorDatasetGroupMagMaximum = std::numeric_limits<double>::quiet_NaN();
80 std::unique_ptr<QgsMesh3DAveragingMethod> mVectorAveragingMethod;
81};
82
83
85
94{
95 public:
98 ~QgsMeshLayerRenderer() override = default;
99 QgsFeedback *feedback() const override;
100 bool render() override;
101 bool forceRasterRender() const override;
102
103 private:
104 void prepareLabeling( QgsMeshLayer *layer, QSet<QString> &attributeNames );
105 void renderMesh();
106 void renderEdgeMesh( const QgsMeshRendererMeshSettings &settings, const QList<int> &edgesInExtent );
107 void renderFaceMesh( const QgsMeshRendererMeshSettings &settings, const QVector<QgsMeshFace> &faces, const QList<int> &facesInExtent );
108 void renderScalarDataset();
109 void renderScalarDatasetOnEdges( const QgsMeshRendererScalarSettings &scalarSettings );
110 void renderScalarDatasetOnFaces( const QgsMeshRendererScalarSettings &scalarSettings );
111 void registerLabelFeatures();
112
113 void renderVectorDataset();
114 void copyTriangularMeshes( QgsMeshLayer *layer, QgsRenderContext &context );
115 void copyScalarDatasetValues( QgsMeshLayer *layer );
116 void copyVectorDatasetValues( QgsMeshLayer *layer );
117 void calculateOutputSize();
118 QgsPointXY fractionPoint( const QgsPointXY &p1, const QgsPointXY &p2, double fraction ) const;
119 bool mIsMeshSimplificationActive = false;
120 QColor colorAt( QgsColorRampShader *shader, double val ) const;
121 bool mIsEditable = false;
122
127 QgsMeshLayerLabelProvider *mLabelProvider = nullptr;
128
129 protected:
130 QString mLayerName;
131
133 std::unique_ptr<QgsMeshLayerRendererFeedback> mFeedback;
134
135 // copy from mesh layer
137
138 // copy from mesh layer
140
141 // copy from mesh layer
143
144 // copy of the scalar dataset
145 QVector<double> mScalarDatasetValues;
148 double mScalarDatasetMinimum = std::numeric_limits<double>::quiet_NaN();
149 double mScalarDatasetMaximum = std::numeric_limits<double>::quiet_NaN();
150
151 // copy of the vector dataset
154 QVector<double> mVectorDatasetValuesMag;
155 double mVectorDatasetMagMinimum = std::numeric_limits<double>::quiet_NaN();
156 double mVectorDatasetMagMaximum = std::numeric_limits<double>::quiet_NaN();
157 double mVectorDatasetGroupMagMinimum = std::numeric_limits<double>::quiet_NaN();
158 double mVectorDatasetGroupMagMaximum = std::numeric_limits<double>::quiet_NaN();
160
161 // copy of rendering settings
163
164 QList< QgsMapClippingRegion > mClippingRegions;
165
166 // output screen size
168
169 double mElevationScale = 1.0;
170 double mElevationOffset = 0.0;
172
173 bool mEnableProfile = false;
174 quint64 mPreparationTime = 0;
175
176 private:
177
178 double mLayerOpacity = 1.0;
179};
180
181
182#endif // QGSMESHLAYERRENDERER_H
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Base class for utility classes that encapsulate information necessary for rendering of map layers.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
DataType
Location of where data is specified for datasets in the dataset group.
@ DataOnVertices
Data is defined on vertices.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
The QgsMeshLayerLabelProvider class implements a label provider for mesh layers.
Implementation of threaded rendering for mesh layers.
QgsMeshDatasetGroupMetadata::DataType mScalarDataType
QgsTriangularMesh mTriangularMesh
QVector< double > mScalarDatasetValues
std::unique_ptr< QgsMeshLayerRendererFeedback > mFeedback
feedback class for cancellation
~QgsMeshLayerRenderer() override=default
QgsMeshDataBlock mScalarActiveFaceFlagValues
bool render() override
Do the rendering (based on data stored in the class).
QVector< double > mVectorDatasetValuesMag
QgsMeshRendererSettings mRendererSettings
bool forceRasterRender() const override
Returns true if the renderer must be rendered to a raster paint device (e.g.
QgsMeshDatasetGroupMetadata::DataType mVectorDataType
QList< QgsMapClippingRegion > mClippingRegions
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr)
QgsMeshDataBlock mVectorActiveFaceFlagValues
QgsMeshDataBlock mVectorDatasetValues
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Represents a mesh renderer settings for mesh object.
Represents a mesh renderer settings for scalar datasets.
DataResamplingMethod
Resampling of value from dataset.
@ NoResampling
Does not use resampling.
Represents all mesh renderer settings.
A class to represent a 2D point.
Definition qgspointxy.h:60
Feedback object tailored for raster block reading.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
Triangular/Derived Mesh is mesh with vertices in map coordinates.
Mesh - vertices, edges and faces.