QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 "qgsrendercontext.h"
33 #include "qgstriangularmesh.h"
34 #include "qgsmeshlayer.h"
35 #include "qgssymbol.h"
36 #include "qgsmeshdataprovider.h"
37 
39 
44 class QgsMeshLayerRendererFeedback : public QgsRasterBlockFeedback
45 {
46 };
47 
48 
52 struct CORE_NO_EXPORT QgsMeshLayerRendererCache
53 {
54  int mDatasetGroupsCount = 0;
55 
56  // scalar dataset
57  QgsMeshDatasetIndex mActiveScalarDatasetIndex;
58  QVector<double> mScalarDatasetValues;
59  QVector<bool> mScalarActiveFaceFlagValues;
60  bool mScalarDataOnVertices = true;
61  double mScalarDatasetMinimum = std::numeric_limits<double>::quiet_NaN();
62  double mScalarDatasetMaximum = std::numeric_limits<double>::quiet_NaN();
63 
64  // vector dataset
65  QgsMeshDatasetIndex mActiveVectorDatasetIndex;
66  QVector<double> mVectorDatasetValuesX;
67  QVector<double> mVectorDatasetValuesY;
68  QVector<double> mVectorDatasetValuesMag;
69  double mVectorDatasetMagMinimum = std::numeric_limits<double>::quiet_NaN();
70  double mVectorDatasetMagMaximum = std::numeric_limits<double>::quiet_NaN();
71  bool mVectorDataOnVertices = true;
72 };
73 
75 
84 {
85  public:
88  ~QgsMeshLayerRenderer() override = default;
89  QgsFeedback *feedback() const override;
90  bool render() override;
91 
92  private:
93  void renderMesh();
94  void renderMesh( const QgsMeshRendererMeshSettings &settings, const QVector<QgsMeshFace> &faces, const QList<int> facesInExtent );
95  void renderScalarDataset();
96  void renderVectorDataset();
97  void copyScalarDatasetValues( QgsMeshLayer *layer );
98  void copyVectorDatasetValues( QgsMeshLayer *layer );
99  void calculateOutputSize();
100 
101  protected:
103  std::unique_ptr<QgsMeshLayerRendererFeedback> mFeedback;
104 
105  // copy from mesh layer
107 
108  // copy from mesh layer
110 
111  // copy of the scalar dataset
112  QVector<double> mScalarDatasetValues;
114  bool mScalarDataOnVertices = true;
115  double mScalarDatasetMinimum = std::numeric_limits<double>::quiet_NaN();
116  double mScalarDatasetMaximum = std::numeric_limits<double>::quiet_NaN();
117 
118  // copy of the vector dataset
119  QVector<double> mVectorDatasetValuesX;
120  QVector<double> mVectorDatasetValuesY;
121  QVector<double> mVectorDatasetValuesMag;
122  double mVectorDatasetMagMinimum = std::numeric_limits<double>::quiet_NaN();
123  double mVectorDatasetMagMaximum = std::numeric_limits<double>::quiet_NaN();
124  bool mVectorDataOnVertices = true;
125 
126  // rendering context
128 
129  // copy of rendering settings
131 
132  // output screen size
133  QSize mOutputSize;
134 };
135 
136 
137 #endif // QGSMESHLAYERRENDERER_H
QVector< bool > mScalarActiveFaceFlagValues
QVector< double > mVectorDatasetValuesX
Triangular/Derived Mesh is mesh with vertices in map coordinates.
QgsMeshRendererSettings mRendererSettings
Represents a mesh renderer settings for mesh object.
QVector< double > mScalarDatasetValues
Implementation of threaded rendering for mesh layers.
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:44
Represents all mesh renderer settings.
QVector< double > mVectorDatasetValuesY
std::unique_ptr< QgsMeshLayerRendererFeedback > mFeedback
feedback class for cancellation
QgsRenderContext & mContext
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:89
Feedback object tailored for raster block reading.