QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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
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
196 QgsRectangle extent() const { return mExtent; }
197
198 private:
200 void updateExtent();
201#ifdef SIP_RUN
203#endif
205 std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
206 QgsPointCloudCategoryList mFilteredOutCategories;
207 double mZValueScale = 1.0;
208 double mZValueFixedOffset = 0;
209 QgsCoordinateTransform mCoordinateTransform;
210 std::unique_ptr<QgsFeedback> mFeedback;
211 QgsRectangle mExtent;
212};
213
214
224{
225 public:
227
229 QgsAbstract3DRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY;
230};
231
232#endif
233
241{
242 public:
245
247 void setLayer( QgsPointCloudLayer *layer );
249 QgsPointCloudLayer *layer() const;
250
251 QString type() const override;
252 QgsPointCloudLayer3DRenderer *clone() const override SIP_FACTORY;
253 Qt3DCore::QEntity *createEntity( const Qgs3DMapSettings &map ) const override SIP_SKIP;
254
260 void setSymbol( QgsPointCloud3DSymbol *symbol SIP_TRANSFER );
262 const QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
263
264 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
265 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
266 void resolveReferences( const QgsProject &project ) override;
267
275 double maximumScreenError() const;
276
284 void setMaximumScreenError( double error );
285
291 bool showBoundingBoxes() const;
292
298 void setShowBoundingBoxes( bool showBoundingBoxes );
299
303 int pointRenderingBudget() const { return mPointBudget; };
304
308 void setPointRenderingBudget( int budget );
309
310 bool convertFrom2DRenderer( QgsPointCloudRenderer *renderer ) override;
311
312 private:
313 QgsMapLayerRef mLayerRef;
314 std::unique_ptr< QgsPointCloud3DSymbol > mSymbol;
315 double mMaximumScreenError = 3.0;
316 bool mShowBoundingBoxes = false;
317 int mPointBudget = 5000000;
318
319 private:
320#ifdef SIP_RUN
323#endif
324};
325
326
327#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.
QgsRectangle extent() const
Returns the 3D scene's extent in layer crs.
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: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