QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsmeshvectorrenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmeshvectorrenderer.h
3  -------------------
4  begin : May 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 QGSMESHVECTORRENDERER_H
19 #define QGSMESHVECTORRENDERER_H
20 
21 
22 #define SIP_NO_FILE
23 
24 #include <QVector>
25 #include <QSize>
26 
27 #include "qgis_core.h"
28 #include "qgsmeshdataprovider.h"
29 #include "qgstriangularmesh.h"
30 #include "qgsmeshlayer.h"
31 #include "qgspointxy.h"
32 
33 class QgsRenderContext;
36 
37 
38 class QgsMeshVectorRenderer
39 {
40  public:
42  QgsMeshVectorRenderer() = default;
43 
47  virtual ~QgsMeshVectorRenderer();
48 
49  virtual void draw() = 0;
50 
52  static QgsMeshVectorRenderer *makeVectorRenderer( const QgsTriangularMesh &m,
53  const QgsMeshDataBlock &datasetVectorValues,
54  const QgsMeshDataBlock &scalarActiveFaceFlagValues,
55  const QVector<double> &datasetValuesMag,
56  double datasetMagMaximumValue,
57  double datasetMagMinimumValue,
59  const QgsMeshRendererVectorSettings &settings,
60  QgsRenderContext &context,
61  const QgsRectangle &layerExtent,
62  QSize size );
63 };
64 
73 class QgsMeshVectorArrowRenderer : public QgsMeshVectorRenderer
74 {
75  public:
77  QgsMeshVectorArrowRenderer( const QgsTriangularMesh &m,
78  const QgsMeshDataBlock &datasetValues,
79  const QVector<double> &datasetValuesMag,
80  double datasetMagMaximumValue,
81  double datasetMagMinimumValue,
83  const QgsMeshRendererVectorSettings &settings,
84  QgsRenderContext &context,
85  QSize size );
87  ~QgsMeshVectorArrowRenderer() override;
88 
92  void draw() override;
93 
94  private:
96  void drawVectorDataOnVertices( );
98  void drawVectorDataOnFaces( );
100  void drawVectorDataOnEdges( );
102  void drawVectorDataOnPoints( const QSet<int> indexesToRender, const QVector<QgsMeshVertex> &points );
104  void drawVectorDataOnGrid( );
106  void drawVectorArrow( const QgsPointXY &lineStart, double xVal, double yVal, double magnitude );
108  bool calcVectorLineEnd( QgsPointXY &lineEnd,
109  double &vectorLength,
110  double &cosAlpha,
111  double &sinAlpha, //out
112  const QgsPointXY &lineStart,
113  double xVal,
114  double yVal,
115  double magnitude //in
116  );
117 
124  double calcExtentBufferSize() const;
125 
126  const QgsTriangularMesh &mTriangularMesh;
127  const QgsMeshDataBlock &mDatasetValues;
128  const QVector<double> &mDatasetValuesMag; //magnitudes
129  double mMinMag = 0.0;
130  double mMaxMag = 0.0;
131  QgsRenderContext &mContext;
133  QgsMeshDatasetGroupMetadata::DataType mDataType = QgsMeshDatasetGroupMetadata::DataType::DataOnVertices;
134  QSize mOutputSize;
135  QgsRectangle mBufferedExtent;
136  QPen mPen;
137 
138  QgsInterpolatedLineColor mVectorColoring;
139 
140 };
141 
142 
143 
145 
146 
147 
148 #endif // QGSMESHVECTORRENDERER_H
Class defining color to render mesh datasets.
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.
Represents a renderer settings for vector datasets.
A class to represent a 2D point.
Definition: qgspointxy.h:59
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Contains information about the context of a rendering operation.
Triangular/Derived Mesh is mesh with vertices in map coordinates.