QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsmesh3dsymbol.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmesh3dsymbol.h
3  -----------------
4  Date : January 2019
5  Copyright : (C) 2019 by Peter Petrik
6  Email : zilolv at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSMESH3DSYMBOL_H
17 #define QGSMESH3DSYMBOL_H
18 
19 #include "qgis_3d.h"
20 
21 #include "qgsabstract3dsymbol.h"
22 #include "qgs3dtypes.h"
23 #include "qgscolorrampshader.h"
24 #include "qgsmeshdataprovider.h"
25 
26 #include <Qt3DRender/QCullFace>
27 
29 
30 #define SIP_NO_FILE
31 
43 class _3D_EXPORT QgsMesh3DSymbol : public QgsAbstract3DSymbol
44 {
45  public:
46 
53  {
55  SingleColor = 0,
59  ColorRamp2DRendering
60  };
61 
68  {
70  VerticesZValue = 0,
72  ScalarDatasetZvalue
73  };
74 
77  ~QgsMesh3DSymbol() override;
78 
79  QString type() const override { return "mesh"; }
80  QgsMesh3DSymbol *clone() const override SIP_FACTORY;
81 
82  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
83  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
84 
90  bool isEnabled() const;
91 
97  void setEnabled( bool enabled );
98 
100  Qgs3DTypes::AltitudeClamping altitudeClamping() const { return mAltClamping; }
102  void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping ) { mAltClamping = altClamping; }
103 
105  float height() const { return mHeight; }
107  void setHeight( float height ) { mHeight = height; }
108 
110  QgsAbstractMaterialSettings *material() const;
111 
117  void setMaterial( QgsAbstractMaterialSettings *material SIP_TRANSFER );
118 
122  bool addBackFaces() const { return mAddBackFaces; }
123 
127  void setAddBackFaces( bool add ) { mAddBackFaces = add; }
128 
134  bool smoothedTriangles() const;
135 
141  void setSmoothedTriangles( bool smoothTriangles );
142 
148  bool wireframeEnabled() const;
149 
155  void setWireframeEnabled( bool wireframeEnabled );
156 
162  double wireframeLineWidth() const;
163 
169  void setWireframeLineWidth( double wireframeLineWidth );
170 
176  QColor wireframeLineColor() const;
177 
183  void setWireframeLineColor( const QColor &wireframeLineColor );
184 
190  double verticalScale() const;
191 
197  void setVerticalScale( double verticalScale );
198 
204  QgsColorRampShader colorRampShader() const;
205 
211  void setColorRampShader( const QgsColorRampShader &colorRampShader );
212 
218  QColor singleMeshColor() const;
219 
225  void setSingleMeshColor( const QColor &singleMeshColor );
226 
232  QgsMesh3DSymbol::RenderingStyle renderingStyle() const;
233 
239  void setRenderingStyle( const QgsMesh3DSymbol::RenderingStyle &textureType );
240 
246  int verticalDatasetGroupIndex() const;
247 
253  void setVerticalDatasetGroupIndex( int verticalDatasetGroupIndex );
254 
260  bool isVerticalMagnitudeRelative() const;
261 
267  void setIsVerticalMagnitudeRelative( bool isVerticalMagnitudeRelative );
268 
274  bool arrowsEnabled() const;
275 
281  void setArrowsEnabled( bool arrowsEnabled );
282 
288  double arrowsSpacing() const;
289 
295  void setArrowsSpacing( double arrowsSpacing );
296 
304  int maximumTextureSize() const;
305 
313  void setMaximumTextureSize( int maximumTextureSize );
314 
320  bool arrowsFixedSize() const;
321 
327  void setArrowsFixedSize( bool arrowsFixedSize );
328 
329  private:
330 
333  float mHeight = 0.0f;
334  std::unique_ptr< QgsAbstractMaterialSettings > mMaterial;
335  bool mAddBackFaces = false;
336 
337  bool mEnabled = true;
338 
340  bool mSmoothedTriangles = false;
341  bool mWireframeEnabled = false;
342  double mWireframeLineWidth = 1.0;
343  QColor mWireframeLineColor = Qt::darkGray;
344 
346  double mVerticalScale = 1.0;
347  int mVerticalDatasetGroupIndex = -1;
348  bool mIsVerticalMagnitudeRelative = false;
349 
352  QgsColorRampShader mColorRampShader;
353  QColor mSingleColor = Qt::darkGreen;
354 
356  bool mArrowsEnabled = false;
357  double mArrowsSpacing = 25;
358  bool mArrowsFixedSize = false;
359  QColor mArrowsColor = Qt::yellow;
360  int mMaximumTextureSize = 1024;
361 };
362 
363 #endif // QGSMESH3DSYMBOL_H
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsMesh3DSymbol::ColorRamp
@ ColorRamp
Render the mesh with a color ramp.
Definition: qgsmesh3dsymbol.h:57
Qgs3DTypes::AltClampRelative
@ AltClampRelative
Z_final = z_terrain + z_geometry.
Definition: qgs3dtypes.h:37
QgsMesh3DSymbol::setAltitudeClamping
void setAltitudeClamping(Qgs3DTypes::AltitudeClamping altClamping)
Sets method that determines altitude (whether to clamp to feature to terrain)
Definition: qgsmesh3dsymbol.h:102
qgscolorrampshader.h
QgsMesh3DSymbol
3 3D symbol that draws mesh geometry as planar triangles.
Definition: qgsmesh3dsymbol.h:44
QgsMesh3DSymbol::height
float height() const
Returns height (altitude) of the symbol (in map units)
Definition: qgsmesh3dsymbol.h:105
QgsColorRampShader
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Definition: qgscolorrampshader.h:40
qgsabstract3dsymbol.h
QgsMesh3DSymbol::addBackFaces
bool addBackFaces() const
Returns whether also triangles facing the other side will be created.
Definition: qgsmesh3dsymbol.h:122
QgsMesh3DSymbol::SingleColor
@ SingleColor
Render the mesh with a single color.
Definition: qgsmesh3dsymbol.h:55
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsAbstract3DSymbol
3 Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
Definition: qgsabstract3dsymbol.h:46
QgsMesh3DSymbol::ZValueType
ZValueType
How to render the Z value of the mesh.
Definition: qgsmesh3dsymbol.h:68
QgsAbstractMaterialSettings
3 Abstract base class for material settings.
Definition: qgsabstractmaterialsettings.h:105
QgsMesh3DSymbol::setHeight
void setHeight(float height)
Sets height (altitude) of the symbol (in map units)
Definition: qgsmesh3dsymbol.h:107
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
qgs3dtypes.h
QgsAbstract3DSymbol::clone
virtual QgsAbstract3DSymbol * clone() const =0
Returns a new instance of the symbol with the same settings.
QgsMesh3DSymbol::~QgsMesh3DSymbol
~QgsMesh3DSymbol() override
Qgs3DTypes::AltitudeClamping
AltitudeClamping
how to handle altitude of vector features
Definition: qgs3dtypes.h:35
QgsMesh3DSymbol::setAddBackFaces
void setAddBackFaces(bool add)
Sets whether also triangles facing the other side will be created.
Definition: qgsmesh3dsymbol.h:127
QgsMesh3DSymbol::RenderingStyle
RenderingStyle
How to render the color of the mesh.
Definition: qgsmesh3dsymbol.h:53
Qgs3DTypes
3 Defines enumerations and other auxiliary types for QGIS 3D
Definition: qgs3dtypes.h:31
qgsmeshdataprovider.h
QgsMesh3DSymbol::type
QString type() const override
Returns identifier of symbol type. Each 3D symbol implementation should return a different type.
Definition: qgsmesh3dsymbol.h:79