QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgspointcloud3dsymbol.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspointcloud3dsymbol.h
3  ------------------------------
4  Date : November 2020
5  Copyright : (C) 2020 by Nedjima Belgacem
6  Email : belgacem dot nedjima 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 QGSPOINTCLOUD3DSYMBOL_H
17 #define QGSPOINTCLOUD3DSYMBOL_H
18 
19 #include "qgis_3d.h"
20 
21 #include <Qt3DRender/QMaterial>
22 
23 #include "qgsabstract3dsymbol.h"
24 #include "qgscolorrampshader.h"
25 #include "qgspointcloudlayer.h"
26 #include "qgscontrastenhancement.h"
28 
39 {
40  public:
41 
45  enum RenderingStyle
46  {
47  // Do not render anything
48  NoRendering = 0,
50  SingleColor,
52  ColorRamp,
54  RgbRendering,
56  Classification
57  };
58 
62  ~QgsPointCloud3DSymbol() override;
63 
64  QString type() const override { return "pointcloud"; }
65 
69  virtual QString symbolType() const = 0;
70 
75  float pointSize() const { return mPointSize; }
76 
81  void setPointSize( float size );
82 
84  virtual unsigned int byteStride() = 0;
86  virtual void fillMaterial( Qt3DRender::QMaterial *material ) = 0 SIP_SKIP;
87 
93  bool renderAsTriangles() const;
94 
100  void setRenderAsTriangles( bool asTriangles );
101 
108  bool horizontalTriangleFilter() const;
109 
116  void setHorizontalTriangleFilter( bool horizontalTriangleFilter );
117 
124  float horizontalFilterThreshold() const;
125 
132  void setHorizontalFilterThreshold( float horizontalFilterThreshold );
133 
140  bool verticalTriangleFilter() const;
141 
148  void setVerticalTriangleFilter( bool verticalTriangleFilter );
149 
156  float verticalFilterThreshold() const;
157 
164  void setVerticalFilterThreshold( float verticalFilterThreshold );
165 
166  void copyBaseSettings( QgsAbstract3DSymbol *destination ) const override;
167 
168  protected:
169  float mPointSize = 3.0;
170  bool mRenderAsTriangles = false;
171  bool mHorizontalTriangleFilter = false;
172  float mHorizontalFilterThreshold = 10.0;
173  bool mVerticalTriangleFilter = false;
174  float mVerticalFilterThreshold = 10.0;
175 
181  void writeBaseXml( QDomElement &elem, const QgsReadWriteContext &context ) const;
182 
188  void readBaseXml( const QDomElement &elem, const QgsReadWriteContext &context );
189 };
190 
201 {
202  public:
205 
206  QString symbolType() const override;
207  QgsAbstract3DSymbol *clone() const override SIP_FACTORY;
208 
209  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
210  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
211 
216  QColor singleColor() const { return mSingleColor; }
217 
222  void setSingleColor( QColor color );
223 
224  unsigned int byteStride() override { return 3 * sizeof( float ); }
225  void fillMaterial( Qt3DRender::QMaterial *material ) override SIP_SKIP;
226 
227 
228  private:
229  QColor mSingleColor = QColor( 0, 0, 255 );
230 };
231 
242 {
243  public:
246 
247  QgsAbstract3DSymbol *clone() const override SIP_FACTORY;
248  QString symbolType() const override;
249 
250  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
251  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
252 
257  QString attribute() const;
258 
263  void setAttribute( const QString &attribute );
264 
269  QgsColorRampShader colorRampShader() const;
270 
275  void setColorRampShader( const QgsColorRampShader &colorRampShader );
276 
281  double colorRampShaderMin() const { return mColorRampShaderMin; }
282 
287  double colorRampShaderMax() const { return mColorRampShaderMax; }
288 
293  void setColorRampShaderMinMax( double min, double max );
294 
295  unsigned int byteStride() override { return 4 * sizeof( float ); }
296  void fillMaterial( Qt3DRender::QMaterial *material ) override SIP_SKIP;
297 
298  private:
299  QString mRenderingParameter;
300  QgsColorRampShader mColorRampShader;
301  double mColorRampShaderMin = 0.0;
302  double mColorRampShaderMax = 1.0;
303 };
304 
315 {
316  public:
319 
321  QgsRgbPointCloud3DSymbol( const QgsRgbPointCloud3DSymbol &other ) = delete;
322 
324  QgsRgbPointCloud3DSymbol &operator=( const QgsRgbPointCloud3DSymbol &other ) = delete;
325 
326  QString symbolType() const override;
327  QgsAbstract3DSymbol *clone() const override SIP_FACTORY;
328 
329  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
330  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
331 
332  unsigned int byteStride() override { return 6 * sizeof( float ); }
333  void fillMaterial( Qt3DRender::QMaterial *material ) override SIP_SKIP;
334 
342  QString redAttribute() const;
343 
351  void setRedAttribute( const QString &attribute );
352 
360  QString greenAttribute() const;
361 
369  void setGreenAttribute( const QString &attribute );
370 
378  QString blueAttribute() const;
379 
387  void setBlueAttribute( const QString &attribute );
388 
396  QgsContrastEnhancement *redContrastEnhancement();
397 
407  void setRedContrastEnhancement( QgsContrastEnhancement *enhancement SIP_TRANSFER );
408 
416  QgsContrastEnhancement *greenContrastEnhancement();
417 
427  void setGreenContrastEnhancement( QgsContrastEnhancement *enhancement SIP_TRANSFER );
428 
436  QgsContrastEnhancement *blueContrastEnhancement();
437 
447  void setBlueContrastEnhancement( QgsContrastEnhancement *enhancement SIP_TRANSFER );
448 
449  private:
450 
451 #ifdef SIP_RUN
453 #endif
454 
455  QString mRedAttribute = QStringLiteral( "Red" );
456  QString mGreenAttribute = QStringLiteral( "Green" );
457  QString mBlueAttribute = QStringLiteral( "Blue" );
458 
459  std::unique_ptr< QgsContrastEnhancement > mRedContrastEnhancement;
460  std::unique_ptr< QgsContrastEnhancement > mGreenContrastEnhancement;
461  std::unique_ptr< QgsContrastEnhancement > mBlueContrastEnhancement;
462 
463 };
464 
475 {
476  public:
479 
480  QgsAbstract3DSymbol *clone() const override SIP_FACTORY;
481  QString symbolType() const override;
482 
483  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
484  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
485 
490  QString attribute() const;
491 
496  void setAttribute( const QString &attribute );
497 
502  QgsPointCloudCategoryList categoriesList() const { return mCategoriesList; }
503 
508  void setCategoriesList( const QgsPointCloudCategoryList &categories );
509 
514  QgsPointCloudCategoryList getFilteredOutCategories() const;
515 
516  unsigned int byteStride() override { return 4 * sizeof( float ); }
517  void fillMaterial( Qt3DRender::QMaterial *material ) override SIP_SKIP;
518 
519  private:
520  QString mRenderingParameter;
521  QgsPointCloudCategoryList mCategoriesList;
522 
523  QgsColorRampShader colorRampShader() const;
524 };
525 
526 #endif // QGSPOINTCLOUD3DSYMBOL_H
QgsRgbPointCloud3DSymbol
3D symbol that draws point cloud geometries as 3D objects using RGB colors in the dataset
Definition: qgspointcloud3dsymbol.h:314
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsColorRampPointCloud3DSymbol::colorRampShaderMin
double colorRampShaderMin() const
Returns the minimum value used when classifying colors in the color ramp shader.
Definition: qgspointcloud3dsymbol.h:281
qgscontrastenhancement.h
QgsSingleColorPointCloud3DSymbol::byteStride
unsigned int byteStride() override
Returns the byte stride for the geometries used to for the vertex buffer.
Definition: qgspointcloud3dsymbol.h:224
QgsPointCloud3DSymbol::fillMaterial
virtual void fillMaterial(Qt3DRender::QMaterial *material)=0SIP_SKIP
Used to fill material object with necessary QParameters (and consequently opengl uniforms)
QgsPointCloudCategoryList
QList< QgsPointCloudCategory > QgsPointCloudCategoryList
Definition: qgspointcloudclassifiedrenderer.h:116
QgsClassificationPointCloud3DSymbol::categoriesList
QgsPointCloudCategoryList categoriesList() const
Returns the list of categories of the classification.
Definition: qgspointcloud3dsymbol.h:502
qgscolorrampshader.h
QgsColorRampPointCloud3DSymbol::colorRampShaderMax
double colorRampShaderMax() const
Returns the maximum value used when classifying colors in the color ramp shader.
Definition: qgspointcloud3dsymbol.h:287
QgsAbstract3DSymbol::copyBaseSettings
virtual void copyBaseSettings(QgsAbstract3DSymbol *destination) const
Copies base class settings from this object to a destination object.
Definition: qgsabstract3dsymbol.cpp:33
QgsPointCloud3DSymbol
3D symbol that draws point cloud geometries as 3D objects.
Definition: qgspointcloud3dsymbol.h:38
QgsColorRampShader
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Definition: qgscolorrampshader.h:42
qgsabstract3dsymbol.h
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsSingleColorPointCloud3DSymbol::singleColor
QColor singleColor() const
Returns the color used by the renderer when using SingleColor rendering mode.
Definition: qgspointcloud3dsymbol.h:216
QgsAbstract3DSymbol
Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
Definition: qgsabstract3dsymbol.h:46
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
qgspointcloudlayer.h
QgsPointCloud3DSymbol::RenderingStyle
RenderingStyle
How to render the point cloud.
Definition: qgspointcloud3dsymbol.h:58
qgspointcloudclassifiedrenderer.h
QgsAbstract3DSymbol::type
virtual QString type() const =0
Returns identifier of symbol type. Each 3D symbol implementation should return a different type.
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsRgbPointCloud3DSymbol::byteStride
unsigned int byteStride() override
Returns the byte stride for the geometries used to for the vertex buffer.
Definition: qgspointcloud3dsymbol.h:332
QgsColorRampPointCloud3DSymbol::byteStride
unsigned int byteStride() override
Returns the byte stride for the geometries used to for the vertex buffer.
Definition: qgspointcloud3dsymbol.h:295
QgsContrastEnhancement
Manipulates raster or point cloud pixel values so that they enhanceContrast or clip into a specified ...
Definition: qgscontrastenhancement.h:42
QgsColorRampPointCloud3DSymbol
3D symbol that draws point cloud geometries as 3D objects.using color ramp shader
Definition: qgspointcloud3dsymbol.h:241
QgsClassificationPointCloud3DSymbol::byteStride
unsigned int byteStride() override
Returns the byte stride for the geometries used to for the vertex buffer.
Definition: qgspointcloud3dsymbol.h:516
QgsSingleColorPointCloud3DSymbol
3D symbol that draws point cloud geometries as 3D objects.using one color
Definition: qgspointcloud3dsymbol.h:200
QgsPointCloud3DSymbol::symbolType
virtual QString symbolType() const =0
Returns a unique string identifier of the symbol type.
QgsClassificationPointCloud3DSymbol
3D symbol that draws point cloud geometries as 3D objects using classification of the dataset
Definition: qgspointcloud3dsymbol.h:474
SIP_ABSTRACT
#define SIP_ABSTRACT
Definition: qgis_sip.h:208