QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
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"
23#include "qgsfeedback.h"
24#include "qgsmaplayerref.h"
25
26#include <QObject>
27
30#include "qgs3drendercontext.h"
31#ifndef SIP_RUN
32
42{
43 public:
44
54 QgsPointCloud3DRenderContext( const Qgs3DRenderContext &context, const QgsCoordinateTransform &coordinateTransform, std::unique_ptr<QgsPointCloud3DSymbol> symbol, double zValueScale, double zValueFixedOffset );
55
58
64 QgsPointCloudAttributeCollection attributes() const { return mAttributes; }
65
71 void setAttributes( const QgsPointCloudAttributeCollection &attributes );
72
78 QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
79
85 void setSymbol( QgsPointCloud3DSymbol *symbol );
86
91 void setFilteredOutCategories( const QgsPointCloudCategoryList &categories );
92
97 QSet<int> getFilteredOutValues() const;
98
103 template<typename T>
104 void getAttribute( const char *data, std::size_t offset, QgsPointCloudAttribute::DataType type, T &value ) const
105 {
106 switch ( type )
107 {
109 value = *reinterpret_cast<const unsigned char *>( data + offset );
110 return;
112 value = *( data + offset );
113 return;
114
116 value = *reinterpret_cast<const qint32 *>( data + offset );
117 return;
119 value = *reinterpret_cast<const quint32 *>( data + offset );
120 return;
121
123 value = *reinterpret_cast<const qint64 *>( data + offset );
124 return;
126 value = *reinterpret_cast<const quint64 *>( data + offset );
127 return;
128
130 value = *reinterpret_cast<const short *>( data + offset );
131 return;
132
134 value = *reinterpret_cast<const unsigned short *>( data + offset );
135 return;
136
138 value = *reinterpret_cast<const float *>( data + offset );
139 return;
140
142 value = *reinterpret_cast<const double *>( data + offset );
143 return;
144 }
145 }
146
152 double zValueScale() const { return mZValueScale; }
153
159 double zValueFixedOffset() const { return mZValueFixedOffset; }
160
164 bool isCanceled() const;
165
170 void cancelRendering() const;
171
175 void setCoordinateTransform( const QgsCoordinateTransform &coordinateTransform );
176
180 QgsCoordinateTransform coordinateTransform() const { return mCoordinateTransform; }
181
185 QgsFeedback *feedback() const { return mFeedback.get(); }
186
191 QgsRectangle layerExtent() const { return mLayerExtent; }
192
193 private:
195 void updateExtent();
196#ifdef SIP_RUN
198#endif
200 std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
201 QgsPointCloudCategoryList mFilteredOutCategories;
202 double mZValueScale = 1.0;
203 double mZValueFixedOffset = 0;
204 QgsCoordinateTransform mCoordinateTransform;
205 std::unique_ptr<QgsFeedback> mFeedback;
206 QgsRectangle mLayerExtent;
207};
208
209
219{
220 public:
222
224 QgsAbstract3DRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY;
225};
226
227#endif
228
236{
237 public:
240
244 QgsPointCloudLayer *layer() const;
245
246 QString type() const override;
248 Qt3DCore::QEntity *createEntity( Qgs3DMapSettings *map ) const override SIP_SKIP;
249
257 const QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
258
259 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
260 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
261 void resolveReferences( const QgsProject &project ) override;
262
270 double maximumScreenError() const;
271
279 void setMaximumScreenError( double error );
280
286 bool showBoundingBoxes() const;
287
293 void setShowBoundingBoxes( bool showBoundingBoxes );
294
298 int pointRenderingBudget() const { return mPointBudget; };
299
303 void setPointRenderingBudget( int budget );
304
305 bool convertFrom2DRenderer( QgsPointCloudRenderer *renderer ) override;
306
311 void setZoomOutBehavior( const Qgis::PointCloudZoomOutRenderBehavior behavior ) { mZoomOutBehavior = behavior; }
312
317 Qgis::PointCloudZoomOutRenderBehavior zoomOutBehavior() const { return mZoomOutBehavior; }
318
319 private:
320 QgsMapLayerRef mLayerRef;
321 std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
322 double mMaximumScreenError = 3.0;
323 bool mShowBoundingBoxes = false;
324 int mPointBudget = 5000000;
326
327 private:
328#ifdef SIP_RUN
331#endif
332};
333
334
335#endif // QGSPOINTCLOUDLAYER3DRENDERER_H
PointCloudZoomOutRenderBehavior
Point cloud zoom out options.
Definition qgis.h:6085
@ RenderExtents
Render only point cloud extents when zoomed out.
Definition qgis.h:6086
Definition of the world.
Qgs3DRenderContext()=default
virtual QgsAbstract3DRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context)=0
Returns new instance of the renderer given the DOM element.
Qgs3DRendererAbstractMetadata(const QString &type)
Constructor of the base class.
QString type() const
Returns unique identifier of the 3D renderer class.
Base class for all renderers that participate in 3D views.
Handles coordinate transforms between two coordinate systems.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
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...
QgsPointCloud3DSymbol * symbol() const
Returns the symbol used for rendering the point cloud.
double zValueScale() const
Returns any constant scaling factor which must be applied to z values taken from the point cloud inde...
QgsFeedback * feedback() const
Returns the feedback object used to cancel rendering and check if rendering was canceled.
QgsPointCloudAttributeCollection attributes() const
Returns the attributes associated with the rendered block.
QgsPointCloud3DRenderContext(const QgsPointCloud3DRenderContext &rh)=delete
QgsCoordinateTransform coordinateTransform() const
Returns the coordinate transform used to transform points from layer CRS to the map CRS.
QgsRectangle layerExtent() const
Returns the 3D scene's extent in layer crs.
double zValueFixedOffset() const
Returns any constant offset which must be applied to z values taken from the point cloud index.
QgsPointCloud3DRenderContext(const Qgs3DRenderContext &context, const QgsCoordinateTransform &coordinateTransform, std::unique_ptr< QgsPointCloud3DSymbol > symbol, double zValueScale, double zValueFixedOffset)
Constructor for QgsPointCloud3DRenderContext.
QgsPointCloud3DRenderContext & operator=(const QgsPointCloud3DRenderContext &)=delete
3D symbol that draws point cloud geometries as 3D objects.
A collection of point cloud attributes.
DataType
Systems of unit measurement.
@ UShort
Unsigned short int 2 bytes.
@ UChar
Unsigned char 1 byte.
@ UInt32
Unsigned int32 4 bytes.
@ UInt64
Unsigned int64 8 bytes.
3D renderer that renders all points from a point cloud layer.
void setLayer(QgsPointCloudLayer *layer)
Sets point cloud layer associated with the renderer.
const QgsPointCloud3DSymbol * symbol() const
Returns 3D symbol associated with the renderer.
QgsPointCloudLayer3DRenderer()
Takes ownership of the symbol object.
QgsPointCloudLayer3DRenderer * clone() const override
Returns a cloned instance.
QgsPointCloudLayer * layer() const
Returns point cloud layer associated with the renderer.
void setSymbol(QgsPointCloud3DSymbol *symbol)
Sets the 3D symbol associated with the renderer.
Qt3DCore::QEntity * createEntity(Qgs3DMapSettings *map) const override
Returns a 3D entity that will be used to show renderer's data in 3D scene.
void setZoomOutBehavior(const Qgis::PointCloudZoomOutRenderBehavior behavior)
Sets the renderer behavior when zoomed out.
int pointRenderingBudget() const
Returns the maximum number of points that will be rendered to the scene.
Qgis::PointCloudZoomOutRenderBehavior zoomOutBehavior() const
Returns the renderer behavior when zoomed out.
Represents a map layer supporting display of point clouds.
Encapsulates the render context for a 2D point cloud rendering operation.
Abstract base class for 2d point cloud renderers.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:109
A container for the context for various read/write operations on objects.
A rectangle specified with double values.
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84
_LayerRef< QgsMapLayer > QgsMapLayerRef
QList< QgsPointCloudCategory > QgsPointCloudCategoryList