QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 
46  {
47  // Do not render anything
48  NoRendering = 0,
54  RgbRendering
55  };
56 
60  ~QgsPointCloud3DSymbol() override;
61 
62  QString type() const override { return "pointcloud"; }
63 
67  virtual QString symbolType() const = 0;
68 
73  float pointSize() const { return mPointSize; }
74 
79  void setPointSize( float size );
80 
82  virtual unsigned int byteStride() = 0;
84  virtual void fillMaterial( Qt3DRender::QMaterial *material ) = 0 SIP_SKIP;
85 
86  protected:
87  float mPointSize = 2.0;
88 };
89 
100 {
101  public:
104 
105  QString symbolType() const override;
106  QgsAbstract3DSymbol *clone() const override SIP_FACTORY;
107 
108  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
109  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
110 
115  QColor singleColor() const { return mSingleColor; }
116 
121  void setSingleColor( QColor color );
122 
123  unsigned int byteStride() override { return 3 * sizeof( float ); }
124  void fillMaterial( Qt3DRender::QMaterial *material ) override SIP_SKIP;
125 
126 
127  private:
128  QColor mSingleColor = QColor( 0, 0, 255 );
129 };
130 
141 {
142  public:
145 
146  QgsAbstract3DSymbol *clone() const override SIP_FACTORY;
147  QString symbolType() const override;
148 
149  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
150  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
151 
156  QString attribute() const;
157 
162  void setAttribute( const QString &attribute );
163 
168  QgsColorRampShader colorRampShader() const;
169 
174  void setColorRampShader( const QgsColorRampShader &colorRampShader );
175 
180  double colorRampShaderMin() const { return mColorRampShaderMin; }
181 
186  double colorRampShaderMax() const { return mColorRampShaderMax; }
187 
192  void setColorRampShaderMinMax( double min, double max );
193 
194  unsigned int byteStride() override { return 4 * sizeof( float ); }
195  void fillMaterial( Qt3DRender::QMaterial *material ) override SIP_SKIP;
196 
197  private:
198  QString mRenderingParameter;
199  QgsColorRampShader mColorRampShader;
200  double mColorRampShaderMin = 0.0;
201  double mColorRampShaderMax = 1.0;
202 };
203 
214 {
215  public:
218 
221 
224 
225  QString symbolType() const override;
226  QgsAbstract3DSymbol *clone() const override SIP_FACTORY;
227 
228  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
229  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
230 
231  unsigned int byteStride() override { return 6 * sizeof( float ); }
232  void fillMaterial( Qt3DRender::QMaterial *material ) override SIP_SKIP;
233 
241  QString redAttribute() const;
242 
250  void setRedAttribute( const QString &attribute );
251 
259  QString greenAttribute() const;
260 
268  void setGreenAttribute( const QString &attribute );
269 
277  QString blueAttribute() const;
278 
286  void setBlueAttribute( const QString &attribute );
287 
295  QgsContrastEnhancement *redContrastEnhancement();
296 
306  void setRedContrastEnhancement( QgsContrastEnhancement *enhancement SIP_TRANSFER );
307 
315  QgsContrastEnhancement *greenContrastEnhancement();
316 
326  void setGreenContrastEnhancement( QgsContrastEnhancement *enhancement SIP_TRANSFER );
327 
335  QgsContrastEnhancement *blueContrastEnhancement();
336 
346  void setBlueContrastEnhancement( QgsContrastEnhancement *enhancement SIP_TRANSFER );
347 
348  private:
349 
350 #ifdef SIP_RUN
352 #endif
353 
354  QString mRedAttribute = QStringLiteral( "Red" );
355  QString mGreenAttribute = QStringLiteral( "Green" );
356  QString mBlueAttribute = QStringLiteral( "Blue" );
357 
358  std::unique_ptr< QgsContrastEnhancement > mRedContrastEnhancement;
359  std::unique_ptr< QgsContrastEnhancement > mGreenContrastEnhancement;
360  std::unique_ptr< QgsContrastEnhancement > mBlueContrastEnhancement;
361 
362 };
363 
374 {
375  public:
378 
379  QgsAbstract3DSymbol *clone() const override SIP_FACTORY;
380  QString symbolType() const override;
381 
382  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
383  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
384 
389  QString attribute() const;
390 
395  void setAttribute( const QString &attribute );
396 
401  QgsPointCloudCategoryList categoriesList() const { return mCategoriesList; }
402 
407  void setCategoriesList( const QgsPointCloudCategoryList &categories );
408 
413  QgsPointCloudCategoryList getFilteredOutCategories() const;
414 
415  unsigned int byteStride() override { return 4 * sizeof( float ); }
416  void fillMaterial( Qt3DRender::QMaterial *material ) override SIP_SKIP;
417 
418  private:
419  QString mRenderingParameter;
420  QgsPointCloudCategoryList mCategoriesList;
421 
422  QgsColorRampShader colorRampShader() const;
423 };
424 
425 #endif // QGSPOINTCLOUD3DSYMBOL_H
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)=0
Reads symbol configuration from the given DOM element.
virtual QgsAbstract3DSymbol * clone() const =0
Returns a new instance of the symbol with the same settings.
virtual void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const =0
Writes symbol configuration to the given DOM element.
QgsPointCloudCategoryList categoriesList() const
Returns the list of categories of the classification.
unsigned int byteStride() override
Returns the byte stride for the geometries used to for the vertex buffer.
double colorRampShaderMin() const
Returns the minimum value used when classifying colors in the color ramp shader.
double colorRampShaderMax() const
Returns the maximum value used when classifying colors in the color ramp shader.
unsigned int byteStride() override
Returns the byte stride for the geometries used to for the vertex buffer.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Manipulates raster or point cloud pixel values so that they enhanceContrast or clip into a specified ...
virtual unsigned int byteStride()=0
Returns the byte stride for the geometries used to for the vertex buffer.
virtual QString symbolType() const =0
Returns a unique string identifier of the symbol type.
virtual void fillMaterial(Qt3DRender::QMaterial *material)=0SIP_SKIP
Used to fill material object with necessary QParameters (and consequently opengl uniforms)
float pointSize() const
Returns the point size of the point cloud.
RenderingStyle
How to render the point cloud.
@ SingleColor
Render the point cloud with a single color.
@ ColorRamp
Render the point cloud with a color ramp.
QString type() const override
The class is used as a container of context for various read/write operations on other objects.
QgsRgbPointCloud3DSymbol(const QgsRgbPointCloud3DSymbol &other)=delete
QgsRgbPointCloud3DSymbol cannot be copied - use clone() instead.
QgsRgbPointCloud3DSymbol & operator=(const QgsRgbPointCloud3DSymbol &other)=delete
QgsRgbPointCloud3DSymbol cannot be copied - use clone() instead.
unsigned int byteStride() override
Returns the byte stride for the geometries used to for the vertex buffer.
QColor singleColor() const
Returns the color used by the renderer when using SingleColor rendering mode.
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_ABSTRACT
Definition: qgis_sip.h:199
#define SIP_FACTORY
Definition: qgis_sip.h:76
QList< QgsPointCloudCategory > QgsPointCloudCategoryList