QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
qgsmeshvectorrenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgstriangularmesh.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 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;
34 
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(
53  const QgsTriangularMesh &m,
54  const QgsMeshDataBlock &datasetVectorValues,
55  const QgsMeshDataBlock &scalarActiveFaceFlagValues,
56  const QVector<double> &datasetValuesMag,
57  double datasetMagMaximumValue,
58  double datasetMagMinimumValue,
59  bool dataIsOnVertices,
60  const QgsMeshRendererVectorSettings &settings,
61  QgsRenderContext &context,
62  const QgsRectangle &layerExtent,
63  QSize size );
64 };
65 
74 class QgsMeshVectorArrowRenderer : public QgsMeshVectorRenderer
75 {
76  public:
78  QgsMeshVectorArrowRenderer( const QgsTriangularMesh &m,
79  const QgsMeshDataBlock &datasetValues,
80  const QVector<double> &datasetValuesMag,
81  double datasetMagMaximumValue,
82  double datasetMagMinimumValue,
83  bool dataIsOnVertices,
84  const QgsMeshRendererVectorSettings &settings,
85  QgsRenderContext &context,
86  QSize size );
88  ~QgsMeshVectorArrowRenderer() override;
89 
93  void draw() override;
94 
95  private:
97  void drawVectorDataOnVertices( const QList<int> &trianglesInExtent );
99  void drawVectorDataOnFaces( const QList<int> &trianglesInExtent );
101  void drawVectorDataOnGrid( const QList<int> &trianglesInExtent );
103  void drawVectorArrow( const QgsPointXY &lineStart, double xVal, double yVal, double magnitude );
105  bool calcVectorLineEnd( QgsPointXY &lineEnd,
106  double &vectorLength,
107  double &cosAlpha,
108  double &sinAlpha, //out
109  const QgsPointXY &lineStart,
110  double xVal,
111  double yVal,
112  double magnitude //in
113  );
114 
121  double calcExtentBufferSize() const;
122 
123  const QgsTriangularMesh &mTriangularMesh;
124  const QgsMeshDataBlock &mDatasetValues;
125  const QVector<double> &mDatasetValuesMag; //magnitudes
126  double mMinMag = 0.0;
127  double mMaxMag = 0.0;
128  QgsRenderContext &mContext;
130  bool mDataOnVertices = true;
131  QSize mOutputSize;
132  QgsRectangle mBufferedExtent;
133 };
134 
136 
137 
138 
139 #endif // QGSMESHVECTORRENDERER_H
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Triangular/Derived Mesh is mesh with vertices in map coordinates.
A class to represent a 2D point.
Definition: qgspointxy.h:43
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e...
Represents a streamline renderer settings for vector datasets.
Contains information about the context of a rendering operation.