QGIS API Documentation  3.6.0-Noosa (5873452)
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 
37 class QgsRenderContext;
38 
40 
45 class QgsMeshLayerRendererFeedback : public QgsRasterBlockFeedback
46 {
47 };
48 
49 
53 struct CORE_NO_EXPORT QgsMeshLayerRendererCache
54 {
55  int mDatasetGroupsCount = 0;
56 
57  // scalar dataset
58  QgsMeshDatasetIndex mActiveScalarDatasetIndex;
59  QVector<double> mScalarDatasetValues;
60  QgsMeshDataBlock mScalarActiveFaceFlagValues;
61  bool mScalarDataOnVertices = true;
62  double mScalarDatasetMinimum = std::numeric_limits<double>::quiet_NaN();
63  double mScalarDatasetMaximum = std::numeric_limits<double>::quiet_NaN();
64 
65  // vector dataset
66  QgsMeshDatasetIndex mActiveVectorDatasetIndex;
67  QgsMeshDataBlock mVectorDatasetValues;
68  QVector<double> mVectorDatasetValuesMag;
69  double mVectorDatasetMagMinimum = std::numeric_limits<double>::quiet_NaN();
70  double mVectorDatasetMagMaximum = std::numeric_limits<double>::quiet_NaN();
71  double mVectorDatasetGroupMagMinimum = std::numeric_limits<double>::quiet_NaN();
72  double mVectorDatasetGroupMagMaximum = std::numeric_limits<double>::quiet_NaN();
73  bool mVectorDataOnVertices = true;
74 };
75 
77 
86 {
87  public:
90  ~QgsMeshLayerRenderer() override = default;
91  QgsFeedback *feedback() const override;
92  bool render() override;
93 
94  private:
95  void renderMesh();
96  void renderMesh( const QgsMeshRendererMeshSettings &settings, const QVector<QgsMeshFace> &faces, const QList<int> facesInExtent );
97  void renderScalarDataset();
98  void renderVectorDataset();
99  void copyScalarDatasetValues( QgsMeshLayer *layer );
100  void copyVectorDatasetValues( QgsMeshLayer *layer );
101  void calculateOutputSize();
102 
103  protected:
105  std::unique_ptr<QgsMeshLayerRendererFeedback> mFeedback;
106 
107  // copy from mesh layer
109 
110  // copy from mesh layer
112 
113  // copy of the scalar dataset
114  QVector<double> mScalarDatasetValues;
116  bool mScalarDataOnVertices = true;
117  double mScalarDatasetMinimum = std::numeric_limits<double>::quiet_NaN();
118  double mScalarDatasetMaximum = std::numeric_limits<double>::quiet_NaN();
119 
120  // copy of the vector dataset
122  QVector<double> mVectorDatasetValuesMag;
123  double mVectorDatasetMagMinimum = std::numeric_limits<double>::quiet_NaN();
124  double mVectorDatasetMagMaximum = std::numeric_limits<double>::quiet_NaN();
125  double mVectorDatasetGroupMagMinimum = std::numeric_limits<double>::quiet_NaN();
126  double mVectorDatasetGroupMagMaximum = std::numeric_limits<double>::quiet_NaN();
127  bool mVectorDataOnVertices = true;
128 
129  // rendering context
131 
132  // copy of rendering settings
134 
135  // output screen size
136  QSize mOutputSize;
137 };
138 
139 
140 #endif // QGSMESHLAYERRENDERER_H
Triangular/Derived Mesh is mesh with vertices in map coordinates.
QgsMeshRendererSettings mRendererSettings
Represents a mesh renderer settings for mesh object.
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 cancelation of something running in a worker thread...
Definition: qgsfeedback.h:44
Represents all mesh renderer settings.
std::unique_ptr< QgsMeshLayerRendererFeedback > mFeedback
feedback class for cancelation
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
QgsMeshDataBlock mScalarActiveFaceFlagValues
Feedback object tailored for raster block reading.