QGIS API Documentation 3.39.0-Master (3aed037ce22)
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
66 QgsPointCloudAttributeCollection attributes() const { return mAttributes; }
67
73 void setAttributes( const QgsPointCloudAttributeCollection &attributes );
74
80 QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
81
87 void setSymbol( QgsPointCloud3DSymbol *symbol );
88
93 void setFilteredOutCategories( const QgsPointCloudCategoryList &categories );
94
99 QSet<int> getFilteredOutValues() const;
100
105 template <typename T>
106 void getAttribute( const char *data, std::size_t offset, QgsPointCloudAttribute::DataType type, T &value ) const
107 {
108 switch ( type )
109 {
111 value = *reinterpret_cast< const unsigned char * >( data + offset );
112 return;
114 value = *( data + offset );
115 return;
116
118 value = *reinterpret_cast< const qint32 * >( data + offset );
119 return;
121 value = *reinterpret_cast< const quint32 * >( data + offset );
122 return;
123
125 value = *reinterpret_cast< const qint64 * >( data + offset );
126 return;
128 value = *reinterpret_cast< const quint64 * >( data + offset );
129 return;
130
132 value = *reinterpret_cast< const short * >( data + offset );
133 return;
134
136 value = *reinterpret_cast< const unsigned short * >( data + offset );
137 return;
138
140 value = *reinterpret_cast< const float * >( data + offset );
141 return;
142
144 value = *reinterpret_cast< const double * >( data + offset );
145 return;
146 }
147 }
148
154 double zValueScale() const { return mZValueScale; }
155
161 double zValueFixedOffset() const { return mZValueFixedOffset; }
162
166 bool isCanceled() const;
167
172 void cancelRendering() const;
173
177 void setCoordinateTransform( const QgsCoordinateTransform &coordinateTransform );
178
182 QgsCoordinateTransform coordinateTransform() const { return mCoordinateTransform; }
183
187 QgsFeedback *feedback() const { return mFeedback.get(); }
188
193 QgsRectangle extent() const { return mExtent; }
194
195 private:
197 void updateExtent();
198#ifdef SIP_RUN
200#endif
202 std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
203 QgsPointCloudCategoryList mFilteredOutCategories;
204 double mZValueScale = 1.0;
205 double mZValueFixedOffset = 0;
206 QgsCoordinateTransform mCoordinateTransform;
207 std::unique_ptr<QgsFeedback> mFeedback;
208 QgsRectangle mExtent;
209};
210
211
221{
222 public:
224
226 QgsAbstract3DRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY;
227};
228
229#endif
230
238{
239 public:
242
244 void setLayer( QgsPointCloudLayer *layer );
246 QgsPointCloudLayer *layer() const;
247
248 QString type() const override;
249 QgsPointCloudLayer3DRenderer *clone() const override SIP_FACTORY;
250 Qt3DCore::QEntity *createEntity( const Qgs3DMapSettings &map ) const override SIP_SKIP;
251
257 void setSymbol( QgsPointCloud3DSymbol *symbol SIP_TRANSFER );
259 const QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
260
261 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
262 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
263 void resolveReferences( const QgsProject &project ) override;
264
272 double maximumScreenError() const;
273
281 void setMaximumScreenError( double error );
282
288 bool showBoundingBoxes() const;
289
295 void setShowBoundingBoxes( bool showBoundingBoxes );
296
300 int pointRenderingBudget() const { return mPointBudget; };
301
305 void setPointRenderingBudget( int budget );
306
307 bool convertFrom2DRenderer( QgsPointCloudRenderer *renderer ) override;
308
309 private:
310 QgsMapLayerRef mLayerRef;
311 std::unique_ptr< QgsPointCloud3DSymbol > mSymbol;
312 double mMaximumScreenError = 3.0;
313 bool mShowBoundingBoxes = false;
314 int mPointBudget = 5000000;
315
316 private:
317#ifdef SIP_RUN
320#endif
321};
322
323
324#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.
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
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
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