QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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"
23 #include "qgs3dtypes.h"
24 #include "qgscolorrampshader.h"
25 #include "qgsmeshdataprovider.h"
26 
27 #include <Qt3DRender/QCullFace>
28 
29 #define SIP_NO_FILE
30 
42 class _3D_EXPORT QgsMesh3DSymbol : public QgsAbstract3DSymbol
43 {
44  public:
45 
52  {
54  SingleColor = 0,
58  ColorRamp2DRendering
59  };
60 
67  {
69  VerticesZValue = 0,
71  ScalarDatasetZvalue
72  };
73 
75  QgsMesh3DSymbol() = default;
76 
77  QString type() const override { return "mesh"; }
78  QgsAbstract3DSymbol *clone() const override SIP_FACTORY;
79 
80  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
81  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
82 
88  bool isEnabled() const;
89 
95  void setEnabled( bool enabled );
96 
98  Qgs3DTypes::AltitudeClamping altitudeClamping() const { return mAltClamping; }
100  void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping ) { mAltClamping = altClamping; }
101 
103  float height() const { return mHeight; }
105  void setHeight( float height ) { mHeight = height; }
106 
108  QgsPhongMaterialSettings material() const { return mMaterial; }
110  void setMaterial( const QgsPhongMaterialSettings &material ) { mMaterial = material; }
111 
115  bool addBackFaces() const { return mAddBackFaces; }
116 
120  void setAddBackFaces( bool add ) { mAddBackFaces = add; }
121 
127  bool smoothedTriangles() const;
128 
134  void setSmoothedTriangles( bool smoothTriangles );
135 
141  bool wireframeEnabled() const;
142 
148  void setWireframeEnabled( bool wireframeEnabled );
149 
155  double wireframeLineWidth() const;
156 
162  void setWireframeLineWidth( double wireframeLineWidth );
163 
169  QColor wireframeLineColor() const;
170 
176  void setWireframeLineColor( const QColor &wireframeLineColor );
177 
183  double verticalScale() const;
184 
190  void setVerticalScale( double verticalScale );
191 
197  QgsColorRampShader colorRampShader() const;
198 
204  void setColorRampShader( const QgsColorRampShader &colorRampShader );
205 
211  QColor singleMeshColor() const;
212 
218  void setSingleMeshColor( const QColor &singleMeshColor );
219 
225  QgsMesh3DSymbol::RenderingStyle renderingStyle() const;
226 
232  void setRenderingStyle( const QgsMesh3DSymbol::RenderingStyle &textureType );
233 
239  int verticalDatasetGroupIndex() const;
240 
246  void setVerticalDatasetGroupIndex( int verticalDatasetGroupIndex );
247 
253  bool isVerticalMagnitudeRelative() const;
254 
260  void setIsVerticalMagnitudeRelative( bool isVerticalMagnitudeRelative );
261 
267  bool arrowsEnabled() const;
268 
274  void setArrowsEnabled( bool arrowsEnabled );
275 
281  double arrowsSpacing() const;
282 
288  void setArrowsSpacing( double arrowsSpacing );
289 
297  int maximumTextureSize() const;
298 
306  void setMaximumTextureSize( int maximumTextureSize );
307 
313  bool arrowsFixedSize() const;
314 
320  void setArrowsFixedSize( bool arrowsFixedSize );
321 
322  private:
323 
326  float mHeight = 0.0f;
327  QgsPhongMaterialSettings mMaterial;
328  bool mAddBackFaces = false;
329 
330  bool mEnabled = true;
331 
333  bool mSmoothedTriangles = false;
334  bool mWireframeEnabled = false;
335  double mWireframeLineWidth = 1.0;
336  QColor mWireframeLineColor = Qt::darkGray;
337 
339  double mVerticalScale = 1.0;
340  int mVerticalDatasetGroupIndex = -1;
341  bool mIsVerticalMagnitudeRelative = false;
342 
345  QgsColorRampShader mColorRampShader;
346  QColor mSingleColor = Qt::darkGreen;
347 
349  bool mArrowsEnabled = false;
350  double mArrowsSpacing = 25;
351  bool mArrowsFixedSize = false;
352  QColor mArrowsColor = Qt::yellow;
353  int mMaximumTextureSize = 1024;
354 };
355 
356 #endif // QGSMESH3DSYMBOL_H
QgsReadWriteContext
Definition: qgsreadwritecontext.h:34
QgsMesh3DSymbol::ColorRamp
@ ColorRamp
Render the mesh with a color ramp.
Definition: qgsmesh3dsymbol.h:56
Qgs3DTypes::AltClampRelative
@ AltClampRelative
Z_final = z_terrain + z_geometry.
Definition: qgs3dtypes.h:63
QgsMesh3DSymbol::setAltitudeClamping
void setAltitudeClamping(Qgs3DTypes::AltitudeClamping altClamping)
Sets method that determines altitude (whether to clamp to feature to terrain)
Definition: qgsmesh3dsymbol.h:100
qgscolorrampshader.h
QgsMesh3DSymbol
Definition: qgsmesh3dsymbol.h:42
QgsMesh3DSymbol::height
float height() const
Returns height (altitude) of the symbol (in map units)
Definition: qgsmesh3dsymbol.h:103
QgsColorRampShader
Definition: qgscolorrampshader.h:39
qgsabstract3dsymbol.h
QgsMesh3DSymbol::addBackFaces
bool addBackFaces() const
Returns whether also triangles facing the other side will be created.
Definition: qgsmesh3dsymbol.h:115
QgsMesh3DSymbol::SingleColor
@ SingleColor
Render the mesh with a single color.
Definition: qgsmesh3dsymbol.h:54
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsMesh3DSymbol::material
QgsPhongMaterialSettings material() const
Returns material used for shading of the symbol.
Definition: qgsmesh3dsymbol.h:108
QgsPhongMaterialSettings
Definition: qgsphongmaterialsettings.h:35
QgsAbstract3DSymbol
Definition: qgsabstract3dsymbol.h:41
QgsMesh3DSymbol::ZValueType
ZValueType
How to render the Z value of the mesh.
Definition: qgsmesh3dsymbol.h:66
QgsMesh3DSymbol::setHeight
void setHeight(float height)
Sets height (altitude) of the symbol (in map units)
Definition: qgsmesh3dsymbol.h:105
qgs3dtypes.h
QgsAbstract3DSymbol::clone
virtual QgsAbstract3DSymbol * clone() const =0
Returns a new instance of the symbol with the same settings.
Qgs3DTypes::AltitudeClamping
AltitudeClamping
how to handle altitude of vector features
Definition: qgs3dtypes.h:47
QgsMesh3DSymbol::setMaterial
void setMaterial(const QgsPhongMaterialSettings &material)
Sets material used for shading of the symbol.
Definition: qgsmesh3dsymbol.h:110
QgsMesh3DSymbol::setAddBackFaces
void setAddBackFaces(bool add)
Sets whether also triangles facing the other side will be created.
Definition: qgsmesh3dsymbol.h:120
QgsMesh3DSymbol::RenderingStyle
RenderingStyle
How to render the color of the mesh.
Definition: qgsmesh3dsymbol.h:51
qgsphongmaterialsettings.h
Qgs3DTypes
Definition: qgs3dtypes.h:30
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:77