QGIS API Documentation 3.41.0-Master (02257426e5a)
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:
53 QgsPointCloud3DRenderContext( const Qgs3DRenderContext &context, const QgsCoordinateTransform &coordinateTransform, std::unique_ptr<QgsPointCloud3DSymbol> symbol, double zValueScale, double zValueFixedOffset );
54
57
63 QgsPointCloudAttributeCollection attributes() const { return mAttributes; }
64
70 void setAttributes( const QgsPointCloudAttributeCollection &attributes );
71
77 QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
78
84 void setSymbol( QgsPointCloud3DSymbol *symbol );
85
90 void setFilteredOutCategories( const QgsPointCloudCategoryList &categories );
91
96 QSet<int> getFilteredOutValues() const;
97
102 template<typename T>
103 void getAttribute( const char *data, std::size_t offset, QgsPointCloudAttribute::DataType type, T &value ) const
104 {
105 switch ( type )
106 {
108 value = *reinterpret_cast<const unsigned char *>( data + offset );
109 return;
111 value = *( data + offset );
112 return;
113
115 value = *reinterpret_cast<const qint32 *>( data + offset );
116 return;
118 value = *reinterpret_cast<const quint32 *>( data + offset );
119 return;
120
122 value = *reinterpret_cast<const qint64 *>( data + offset );
123 return;
125 value = *reinterpret_cast<const quint64 *>( data + offset );
126 return;
127
129 value = *reinterpret_cast<const short *>( data + offset );
130 return;
131
133 value = *reinterpret_cast<const unsigned short *>( data + offset );
134 return;
135
137 value = *reinterpret_cast<const float *>( data + offset );
138 return;
139
141 value = *reinterpret_cast<const double *>( data + offset );
142 return;
143 }
144 }
145
151 double zValueScale() const { return mZValueScale; }
152
158 double zValueFixedOffset() const { return mZValueFixedOffset; }
159
163 bool isCanceled() const;
164
169 void cancelRendering() const;
170
174 void setCoordinateTransform( const QgsCoordinateTransform &coordinateTransform );
175
179 QgsCoordinateTransform coordinateTransform() const { return mCoordinateTransform; }
180
184 QgsFeedback *feedback() const { return mFeedback.get(); }
185
190 QgsRectangle layerExtent() const { return mLayerExtent; }
191
192 private:
194 void updateExtent();
195#ifdef SIP_RUN
197#endif
199 std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
200 QgsPointCloudCategoryList mFilteredOutCategories;
201 double mZValueScale = 1.0;
202 double mZValueFixedOffset = 0;
203 QgsCoordinateTransform mCoordinateTransform;
204 std::unique_ptr<QgsFeedback> mFeedback;
205 QgsRectangle mLayerExtent;
206};
207
208
218{
219 public:
221
223 QgsAbstract3DRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY;
224};
225
226#endif
227
235{
236 public:
239
241 void setLayer( QgsPointCloudLayer *layer );
243 QgsPointCloudLayer *layer() const;
244
245 QString type() const override;
246 QgsPointCloudLayer3DRenderer *clone() const override SIP_FACTORY;
247 Qt3DCore::QEntity *createEntity( Qgs3DMapSettings *map ) const override SIP_SKIP;
248
254 void setSymbol( QgsPointCloud3DSymbol *symbol SIP_TRANSFER );
256 const QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
257
258 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
259 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
260 void resolveReferences( const QgsProject &project ) override;
261
269 double maximumScreenError() const;
270
278 void setMaximumScreenError( double error );
279
285 bool showBoundingBoxes() const;
286
292 void setShowBoundingBoxes( bool showBoundingBoxes );
293
297 int pointRenderingBudget() const { return mPointBudget; };
298
302 void setPointRenderingBudget( int budget );
303
304 bool convertFrom2DRenderer( QgsPointCloudRenderer *renderer ) override;
305
310 void setZoomOutBehavior( const Qgis::PointCloudZoomOutRenderBehavior behavior ) { mZoomOutBehavior = behavior; }
311
316 Qgis::PointCloudZoomOutRenderBehavior zoomOutBehavior() const { return mZoomOutBehavior; }
317
318 private:
319 QgsMapLayerRef mLayerRef;
320 std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
321 double mMaximumScreenError = 3.0;
322 bool mShowBoundingBoxes = false;
323 int mPointBudget = 5000000;
325
326 private:
327#ifdef SIP_RUN
330#endif
331};
332
333
334#endif // QGSPOINTCLOUDLAYER3DRENDERER_H
PointCloudZoomOutRenderBehavior
Point cloud zoom out options.
Definition qgis.h:5742
@ RenderExtents
Render only point cloud extents when zoomed out.
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.
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: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