QGIS API Documentation 3.27.0-Master (0a97e3138f)
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
24#include "qgsmaplayerref.h"
25#include "qgsfeedback.h"
26#include <QObject>
27
31
32#ifndef SIP_RUN
33
42class _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
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 {
114 value = *reinterpret_cast< const unsigned char * >( data + offset );
115 return;
117 value = *( data + offset );
118 return;
119
121 value = *reinterpret_cast< const qint32 * >( data + offset );
122 return;
124 value = *reinterpret_cast< const quint32 * >( data + offset );
125 return;
126
128 value = *reinterpret_cast< const qint64 * >( data + offset );
129 return;
131 value = *reinterpret_cast< const quint64 * >( data + offset );
132 return;
133
135 value = *reinterpret_cast< const short * >( data + offset );
136 return;
137
139 value = *reinterpret_cast< const unsigned short * >( data + offset );
140 return;
141
143 value = *reinterpret_cast< const float * >( data + offset );
144 return;
145
147 value = *reinterpret_cast< const double * >( data + offset );
148 return;
149 }
150 }
151
157 double zValueScale() const { return mZValueScale; }
158
164 double zValueFixedOffset() const { return mZValueFixedOffset; }
165
169 bool isCanceled() const;
170
175 void cancelRendering() const;
176
180 void setCoordinateTransform( const QgsCoordinateTransform &coordinateTransform );
181
185 QgsCoordinateTransform coordinateTransform() const { return mCoordinateTransform; }
186
190 QgsFeedback *feedback() const { return mFeedback.get(); }
191 private:
192#ifdef SIP_RUN
194#endif
196 std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
197 QgsPointCloudCategoryList mFilteredOutCategories;
198 double mZValueScale = 1.0;
199 double mZValueFixedOffset = 0;
200 QgsCoordinateTransform mCoordinateTransform;
201 std::unique_ptr<QgsFeedback> mFeedback;
202};
203
204
214{
215 public:
217
219 QgsAbstract3DRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY;
220};
221
222#endif
223
231{
232 public:
235
237 void setLayer( QgsPointCloudLayer *layer );
239 QgsPointCloudLayer *layer() const;
240
241 QString type() const override;
242 QgsPointCloudLayer3DRenderer *clone() const override SIP_FACTORY;
243 Qt3DCore::QEntity *createEntity( const Qgs3DMapSettings &map ) const override SIP_SKIP;
244
250 void setSymbol( QgsPointCloud3DSymbol *symbol SIP_TRANSFER );
252 const QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
253
254 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
255 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
256 void resolveReferences( const QgsProject &project ) override;
257
265 double maximumScreenError() const;
266
274 void setMaximumScreenError( double error );
275
281 bool showBoundingBoxes() const;
282
288 void setShowBoundingBoxes( bool showBoundingBoxes );
289
293 int pointRenderingBudget() const { return mPointBudget; };
294
298 void setPointRenderingBudget( int budget );
299
300 bool convertFrom2DRenderer( QgsPointCloudRenderer *renderer ) override;
301
302 private:
303 QgsMapLayerRef mLayerRef;
304 std::unique_ptr< QgsPointCloud3DSymbol > mSymbol;
305 double mMaximumScreenError = 3.0;
306 bool mShowBoundingBoxes = false;
307 int mPointBudget = 5000000;
308
309 private:
310#ifdef SIP_RUN
313#endif
314};
315
316
317#endif // QGSPOINTCLOUDLAYER3DRENDERER_H
Base metadata class for 3D renderers.
virtual QgsAbstract3DRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context)=0
Returns new instance of the renderer given the DOM element.
QString type() const
Returns unique identifier of the 3D renderer class.
Base class for all renderers that may to participate in 3D view.
Base class for point cloud 3D renderers.
Class for doing transforms between two map coordinate systems.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
Encapsulates the render context for a 3D point cloud rendering operation.
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
QgsPointCloudRenderContext cannot be copied.
QgsCoordinateTransform coordinateTransform() const
Returns the coordinate transform used to transform points from layer CRS to the map CRS.
double zValueFixedOffset() const
Returns any constant offset which must be applied to z values taken from the point cloud index.
QgsPointCloud3DRenderContext & operator=(const QgsPointCloud3DRenderContext &)=delete
QgsPointCloudRenderContext cannot be copied.
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.
Metadata for point cloud layer 3D renderer to allow creation of its instances from XML.
3D renderer that renders all points from a point cloud layer
const QgsPointCloud3DSymbol * symbol() const
Returns 3D symbol associated with the renderer.
int pointRenderingBudget() const
Returns the maximum number of points that will be rendered to the scene.
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:104
The class is used as a container of context for various read/write operations on other objects.
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76
QList< QgsPointCloudCategory > QgsPointCloudCategoryList