QGIS API Documentation 3.39.0-Master (bca3cdb6021)
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"
21
24#include "qgsmaplayerref.h"
25#include "qgsfeedback.h"
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,
55 double zValueScale, double zValueFixedOffset );
56
59
65 QgsPointCloudAttributeCollection attributes() const { return mAttributes; }
66
72 void setAttributes( const QgsPointCloudAttributeCollection &attributes );
73
79 QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
80
86 void setSymbol( QgsPointCloud3DSymbol *symbol );
87
92 void setFilteredOutCategories( const QgsPointCloudCategoryList &categories );
93
98 QSet<int> getFilteredOutValues() const;
99
104 template <typename T>
105 void getAttribute( const char *data, std::size_t offset, QgsPointCloudAttribute::DataType type, T &value ) const
106 {
107 switch ( type )
108 {
110 value = *reinterpret_cast< const unsigned char * >( data + offset );
111 return;
113 value = *( data + offset );
114 return;
115
117 value = *reinterpret_cast< const qint32 * >( data + offset );
118 return;
120 value = *reinterpret_cast< const quint32 * >( data + offset );
121 return;
122
124 value = *reinterpret_cast< const qint64 * >( data + offset );
125 return;
127 value = *reinterpret_cast< const quint64 * >( data + offset );
128 return;
129
131 value = *reinterpret_cast< const short * >( data + offset );
132 return;
133
135 value = *reinterpret_cast< const unsigned short * >( data + offset );
136 return;
137
139 value = *reinterpret_cast< const float * >( data + offset );
140 return;
141
143 value = *reinterpret_cast< const double * >( data + offset );
144 return;
145 }
146 }
147
153 double zValueScale() const { return mZValueScale; }
154
160 double zValueFixedOffset() const { return mZValueFixedOffset; }
161
165 bool isCanceled() const;
166
171 void cancelRendering() const;
172
176 void setCoordinateTransform( const QgsCoordinateTransform &coordinateTransform );
177
181 QgsCoordinateTransform coordinateTransform() const { return mCoordinateTransform; }
182
186 QgsFeedback *feedback() const { return mFeedback.get(); }
187
192 QgsRectangle layerExtent() const { return mLayerExtent; }
193
194 private:
196 void updateExtent();
197#ifdef SIP_RUN
199#endif
201 std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
202 QgsPointCloudCategoryList mFilteredOutCategories;
203 double mZValueScale = 1.0;
204 double mZValueFixedOffset = 0;
205 QgsCoordinateTransform mCoordinateTransform;
206 std::unique_ptr<QgsFeedback> mFeedback;
207 QgsRectangle mLayerExtent;
208};
209
210
220{
221 public:
223
225 QgsAbstract3DRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY;
226};
227
228#endif
229
237{
238 public:
241
243 void setLayer( QgsPointCloudLayer *layer );
245 QgsPointCloudLayer *layer() const;
246
247 QString type() const override;
248 QgsPointCloudLayer3DRenderer *clone() const override SIP_FACTORY;
249 Qt3DCore::QEntity *createEntity( Qgs3DMapSettings *map ) const override SIP_SKIP;
250
256 void setSymbol( QgsPointCloud3DSymbol *symbol SIP_TRANSFER );
258 const QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
259
260 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
261 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
262 void resolveReferences( const QgsProject &project ) override;
263
271 double maximumScreenError() const;
272
280 void setMaximumScreenError( double error );
281
287 bool showBoundingBoxes() const;
288
294 void setShowBoundingBoxes( bool showBoundingBoxes );
295
299 int pointRenderingBudget() const { return mPointBudget; };
300
304 void setPointRenderingBudget( int budget );
305
306 bool convertFrom2DRenderer( QgsPointCloudRenderer *renderer ) override;
307
308 private:
309 QgsMapLayerRef mLayerRef;
310 std::unique_ptr< QgsPointCloud3DSymbol > mSymbol;
311 double mMaximumScreenError = 3.0;
312 bool mShowBoundingBoxes = false;
313 int mPointBudget = 5000000;
314
315 private:
316#ifdef SIP_RUN
319#endif
320};
321
322
323#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:44
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
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 & operator=(const QgsPointCloud3DRenderContext &)=delete
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:107
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
#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