QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgspointcloudlayer3drenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspointcloudlayer3drenderer.h
3  --------------------------------------
4  Date : October 2020
5  Copyright : (C) 2020 by Peter Petrik
6  Email : zilolv dot sk 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 QGSPOINTCLOUDLAYER3DRENDERER_H
17 #define QGSPOINTCLOUDLAYER3DRENDERER_H
18 
19 #include "qgis_3d.h"
20 #include "qgis_sip.h"
21 
22 #include "qgs3drendererregistry.h"
24 #include "qgsmaplayerref.h"
25 #include "qgsfeedback.h"
26 #include <QObject>
27 
28 class QgsPointCloudLayer;
29 #include "qgspointcloud3dsymbol.h"
30 #include "qgsfeature3dhandler_p.h"
31 
32 #ifndef SIP_RUN
33 
42 class _3D_NO_EXPORT QgsPointCloud3DRenderContext : public Qgs3DRenderContext
43 {
44  public:
45 
55  QgsPointCloud3DRenderContext( const Qgs3DMapSettings &map, const QgsCoordinateTransform &coordinateTransform, std::unique_ptr< QgsPointCloud3DSymbol > symbol,
56  double zValueScale, double zValueFixedOffset );
57 
60 
62  QgsPointCloud3DRenderContext &operator=( const QgsPointCloud3DRenderContext & ) = delete;
63 
69  QgsPointCloudAttributeCollection attributes() const { return mAttributes; }
70 
76  void setAttributes( const QgsPointCloudAttributeCollection &attributes );
77 
83  QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
84 
90  void setSymbol( QgsPointCloud3DSymbol *symbol );
91 
96  void setFilteredOutCategories( const QgsPointCloudCategoryList &categories );
97 
102  QSet<int> getFilteredOutValues() const;
103 
108  template <typename T>
109  void getAttribute( const char *data, std::size_t offset, QgsPointCloudAttribute::DataType type, T &value ) const
110  {
111  switch ( type )
112  {
115  value = *( data + offset );
116  return;
117 
119  value = *reinterpret_cast< const qint32 * >( data + offset );
120  return;
122  value = *reinterpret_cast< const quint32 * >( data + offset );
123  return;
124 
126  value = *reinterpret_cast< const qint64 * >( data + offset );
127  return;
129  value = *reinterpret_cast< const quint64 * >( data + offset );
130  return;
131 
133  value = *reinterpret_cast< const short * >( data + offset );
134  return;
135 
137  value = *reinterpret_cast< const unsigned short * >( data + offset );
138  return;
139 
141  value = *reinterpret_cast< const float * >( data + offset );
142  return;
143 
145  value = *reinterpret_cast< const double * >( data + offset );
146  return;
147  }
148  }
149 
155  double zValueScale() const { return mZValueScale; }
156 
162  double zValueFixedOffset() const { return mZValueFixedOffset; }
163 
167  bool isCanceled() const;
168 
173  void cancelRendering() const;
174 
178  void setCoordinateTransform( const QgsCoordinateTransform &coordinateTransform );
179 
183  QgsCoordinateTransform coordinateTransform() const { return mCoordinateTransform; }
184 
188  QgsFeedback *feedback() const { return mFeedback.get(); }
189  private:
190 #ifdef SIP_RUN
192 #endif
194  std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
195  QgsPointCloudCategoryList mFilteredOutCategories;
196  double mZValueScale = 1.0;
197  double mZValueFixedOffset = 0;
198  QgsCoordinateTransform mCoordinateTransform;
199  std::unique_ptr<QgsFeedback> mFeedback;
200 };
201 
202 
212 {
213  public:
215 
217  QgsAbstract3DRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY;
218 };
219 
220 #endif
221 
229 {
230  public:
232  explicit QgsPointCloudLayer3DRenderer();
233 
235  void setLayer( QgsPointCloudLayer *layer );
237  QgsPointCloudLayer *layer() const;
238 
239  QString type() const override;
241  Qt3DCore::QEntity *createEntity( const Qgs3DMapSettings &map ) const override SIP_SKIP;
242 
248  void setSymbol( QgsPointCloud3DSymbol *symbol SIP_TRANSFER );
250  const QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
251 
252  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
253  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
254  void resolveReferences( const QgsProject &project ) override;
255 
263  double maximumScreenError() const;
264 
272  void setMaximumScreenError( double error );
273 
279  bool showBoundingBoxes() const;
280 
286  void setShowBoundingBoxes( bool showBoundingBoxes );
287 
291  int pointRenderingBudget() const { return mPointBudget; };
292 
296  void setPointRenderingBudget( int budget );
297 
298  bool convertFrom2DRenderer( QgsPointCloudRenderer *renderer ) override;
299 
300  private:
301  QgsMapLayerRef mLayerRef;
302  std::unique_ptr< QgsPointCloud3DSymbol > mSymbol;
303  double mMaximumScreenError = 3.0;
304  bool mShowBoundingBoxes = false;
305  int mPointBudget = 5000000;
306 
307  private:
308 #ifdef SIP_RUN
311 #endif
312 };
313 
314 
315 #endif // QGSPOINTCLOUDLAYER3DRENDERER_H
QgsPointCloudLayer3DRenderer::pointRenderingBudget
int pointRenderingBudget() const
Returns the maximum number of points that will be rendered to the scene.
Definition: qgspointcloudlayer3drenderer.h:291
qgsfeature3dhandler_p.h
QgsPointCloudAttribute::DataType
DataType
Systems of unit measurement.
Definition: qgspointcloudattribute.h:44
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
Qgs3DRendererAbstractMetadata::createRenderer
virtual QgsAbstract3DRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context)=0
Returns new instance of the renderer given the DOM element.
QgsAbstract3DRenderer::type
virtual QString type() const =0
Returns unique identifier of the renderer class (used to identify subclass)
QgsPointCloud3DRenderContext::getAttribute
void getAttribute(const char *data, std::size_t offset, QgsPointCloudAttribute::DataType type, T &value) const
Retrieves the attribute value from data at the specified offset, where type indicates the original da...
Definition: qgspointcloudlayer3drenderer.h:109
QgsPointCloudLayer
Represents a map layer supporting display of point clouds.
Definition: qgspointcloudlayer.h:45
QgsAbstract3DRenderer
Base class for all renderers that may to participate in 3D view.
Definition: qgsabstract3drenderer.h:48
QgsPointCloudLayer3DRendererMetadata
Metadata for point cloud layer 3D renderer to allow creation of its instances from XML.
Definition: qgspointcloudlayer3drenderer.h:211
QgsPointCloudCategoryList
QList< QgsPointCloudCategory > QgsPointCloudCategoryList
Definition: qgspointcloudclassifiedrenderer.h:116
QgsAbstractPointCloud3DRenderer::convertFrom2DRenderer
virtual bool convertFrom2DRenderer(QgsPointCloudRenderer *renderer)=0
Updates the 3D renderer's symbol to match that of a given QgsPointCloudRenderer.
Qgs3DRendererAbstractMetadata
Base metadata class for 3D renderers.
Definition: qgs3drendererregistry.h:34
QgsPointCloudAttribute::UInt32
@ UInt32
Unsigned int32 4 bytes.
Definition: qgspointcloudattribute.h:51
QgsPointCloud3DRenderContext::zValueFixedOffset
double zValueFixedOffset() const
Returns any constant offset which must be applied to z values taken from the point cloud index.
Definition: qgspointcloudlayer3drenderer.h:162
QgsPointCloudLayer3DRenderer::symbol
const QgsPointCloud3DSymbol * symbol() const
Returns 3D symbol associated with the renderer.
Definition: qgspointcloudlayer3drenderer.h:250
QgsPointCloud3DSymbol
3D symbol that draws point cloud geometries as 3D objects.
Definition: qgspointcloud3dsymbol.h:38
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:103
QgsPointCloudAttribute::Double
@ Double
Double 8 bytes.
Definition: qgspointcloudattribute.h:55
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsPointCloudAttribute::Short
@ Short
Short int 2 bytes.
Definition: qgspointcloudattribute.h:48
QgsPointCloud3DRenderContext::coordinateTransform
QgsCoordinateTransform coordinateTransform() const
Returns the coordinate transform used to transform points from layer CRS to the map CRS.
Definition: qgspointcloudlayer3drenderer.h:183
QgsAbstract3DRenderer::readXml
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)=0
Reads renderer's properties from given XML element.
QgsAbstract3DRenderer::resolveReferences
virtual void resolveReferences(const QgsProject &project)
Resolves references to other objects - second phase of loading - after readXml()
Definition: qgsabstract3drenderer.cpp:19
qgspointcloud3dsymbol.h
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsPointCloudAttribute::UInt64
@ UInt64
Unsigned int64 8 bytes.
Definition: qgspointcloudattribute.h:53
QgsPointCloudAttribute::Int32
@ Int32
Int32 4 bytes.
Definition: qgspointcloudattribute.h:50
QgsPointCloudRenderContext
Encapsulates the render context for a 2D point cloud rendering operation.
Definition: qgspointcloudrenderer.h:41
QgsPointCloudAttribute::UShort
@ UShort
Unsigned short int 2 bytes.
Definition: qgspointcloudattribute.h:49
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsAbstract3DRenderer::writeXml
virtual void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const =0
Writes renderer's properties to given XML element.
QgsPointCloudAttributeCollection
Collection of point cloud attributes.
Definition: qgspointcloudattribute.h:141
QgsAbstractPointCloud3DRenderer
Base class for point cloud 3D renderers.
Definition: qgsabstractpointcloud3drenderer.h:40
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsPointCloud3DRenderContext::zValueScale
double zValueScale() const
Returns any constant scaling factor which must be applied to z values taken from the point cloud inde...
Definition: qgspointcloudlayer3drenderer.h:155
Qgs3DMapSettings
Definition of the world.
Definition: qgs3dmapsettings.h:57
QgsPointCloudAttribute::Char
@ Char
Char 1 byte.
Definition: qgspointcloudattribute.h:46
qgs3drendererregistry.h
QgsAbstract3DRenderer::createEntity
virtual Qt3DCore::QEntity * createEntity(const Qgs3DMapSettings &map) const =0
Returns a 3D entity that will be used to show renderer's data in 3D scene.
QgsPointCloud3DRenderContext::attributes
QgsPointCloudAttributeCollection attributes() const
Returns the attributes associated with the rendered block.
Definition: qgspointcloudlayer3drenderer.h:69
QgsPointCloudAttribute::Int64
@ Int64
Int64 8 bytes.
Definition: qgspointcloudattribute.h:52
QgsPointCloud3DRenderContext
Encapsulates the render context for a 3D point cloud rendering operation.
Definition: qgspointcloudlayer3drenderer.h:42
QgsAbstract3DRenderer::clone
virtual QgsAbstract3DRenderer * clone() const =0
Returns a cloned instance.
QgsPointCloudRenderer
Abstract base class for 2d point cloud renderers.
Definition: qgspointcloudrenderer.h:296
qgsabstractpointcloud3drenderer.h
qgsmaplayerref.h
QgsPointCloud3DRenderContext::symbol
QgsPointCloud3DSymbol * symbol() const
Returns the symbol used for rendering the point cloud.
Definition: qgspointcloudlayer3drenderer.h:83
_LayerRef< QgsMapLayer >
QgsPointCloudAttribute::UChar
@ UChar
Unsigned char 1 byte.
Definition: qgspointcloudattribute.h:47
QgsPointCloud3DRenderContext::feedback
QgsFeedback * feedback() const
Returns the feedback object used to cancel rendering and check if rendering was canceled.
Definition: qgspointcloudlayer3drenderer.h:188
QgsPointCloudLayer3DRenderer
3D renderer that renders all points from a point cloud layer
Definition: qgspointcloudlayer3drenderer.h:228
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:57
qgsfeedback.h
QgsPointCloudAttribute::Float
@ Float
Float 4 bytes.
Definition: qgspointcloudattribute.h:54