QGIS API Documentation  3.21.0-Master (5b68dc587e)
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 
335  int levelOfDetailIndex() const;
336 
343  void setLevelOfDetailIndex( int lod );
344 
345  private:
346 
349  float mHeight = 0.0f;
350  std::unique_ptr< QgsAbstractMaterialSettings > mMaterial;
351  bool mAddBackFaces = false;
352 
353  bool mEnabled = true;
354 
356  bool mSmoothedTriangles = false;
357  bool mWireframeEnabled = false;
358  double mWireframeLineWidth = 1.0;
359  QColor mWireframeLineColor = Qt::darkGray;
360  int mLevelOfDetailIndex = 0;
361 
363  double mVerticalScale = 1.0;
364  int mVerticalDatasetGroupIndex = -1;
365  bool mIsVerticalMagnitudeRelative = false;
366 
369  QgsColorRampShader mColorRampShader;
370  QColor mSingleColor = Qt::darkGreen;
371 
373  bool mArrowsEnabled = false;
374  double mArrowsSpacing = 25;
375  bool mArrowsFixedSize = false;
376  QColor mArrowsColor = Qt::yellow;
377  int mMaximumTextureSize = 1024;
378 };
379 
380 #endif // QGSMESH3DSYMBOL_H
AltitudeClamping
how to handle altitude of vector features
Definition: qgs3dtypes.h:35
@ AltClampRelative
Z_final = z_terrain + z_geometry.
Definition: qgs3dtypes.h:37
virtual QgsAbstract3DSymbol * clone() const =0
Returns a new instance of the symbol with the same settings.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
ZValueType
How to render the Z value of the mesh.
void setAddBackFaces(bool add)
Sets whether also triangles facing the other side will be created.
void setAltitudeClamping(Qgs3DTypes::AltitudeClamping altClamping)
Sets method that determines altitude (whether to clamp to feature to terrain)
QString type() const override
Returns identifier of symbol type. Each 3D symbol implementation should return a different type.
void setHeight(float height)
Sets height (altitude) of the symbol (in map units)
bool addBackFaces() const
Returns whether also triangles facing the other side will be created.
float height() const
Returns height (altitude) of the symbol (in map units)
~QgsMesh3DSymbol() override
RenderingStyle
How to render the color of the mesh.
@ ColorRamp
Render the mesh with a color ramp.
@ SingleColor
Render the mesh with a single color.
The class is used as a container of context for various read/write operations on other objects.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76