QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 
22 #include "qgs3drendererregistry.h"
23 #include "qgsabstract3drenderer.h"
24 #include "qgsmaplayerref.h"
25 #include "qgsfeedback.h"
26 #include <QObject>
27 
28 class QgsPointCloudLayer;
29 #include "qgspointcloud3dsymbol.h"
30 #include "qgsfeature3dhandler_p.h"
31 
32 #ifndef SIP_RUN
33 
42 class _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  {
115  value = *( data + offset );
116  return;
117 
119  value = *reinterpret_cast< const qint32 * >( data + offset );
120  return;
122  value = *reinterpret_cast< const quint32 * >( data + offset );
123  return;
124 
126  value = *reinterpret_cast< const qint64 * >( data + offset );
127  return;
129  value = *reinterpret_cast< const quint64 * >( data + offset );
130  return;
131 
133  value = *reinterpret_cast< const short * >( data + offset );
134  return;
135 
137  value = *reinterpret_cast< const unsigned short * >( data + offset );
138  return;
139 
141  value = *reinterpret_cast< const float * >( data + offset );
142  return;
143 
145  value = *reinterpret_cast< const double * >( data + offset );
146  return;
147  }
148  }
149 
155  double zValueScale() const { return mZValueScale; }
156 
162  double zValueFixedOffset() const { return mZValueFixedOffset; }
163 
167  bool isCanceled() const;
168 
173  void cancelRendering() const;
174 
178  void setCoordinateTransform( const QgsCoordinateTransform &coordinateTransform );
179 
183  QgsCoordinateTransform coordinateTransform() const { return mCoordinateTransform; }
184 
188  QgsFeedback *feedback() const { return mFeedback.get(); }
189  private:
190 #ifdef SIP_RUN
192 #endif
194  std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
195  QgsPointCloudCategoryList mFilteredOutCategories;
196  double mZValueScale = 1.0;
197  double mZValueFixedOffset = 0;
198  QgsCoordinateTransform mCoordinateTransform;
199  std::unique_ptr<QgsFeedback> mFeedback;
200 };
201 
202 
212 {
213  public:
215 
217  QgsAbstract3DRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY;
218 };
219 
220 #endif
221 
229 {
230  public:
232  explicit QgsPointCloudLayer3DRenderer();
233 
235  void setLayer( QgsPointCloudLayer *layer );
237  QgsPointCloudLayer *layer() const;
238 
239  QString type() const override;
240  QgsPointCloudLayer3DRenderer *clone() const override SIP_FACTORY;
241  Qt3DCore::QEntity *createEntity( const Qgs3DMapSettings &map ) const override SIP_SKIP;
242 
248  void setSymbol( QgsPointCloud3DSymbol *symbol SIP_TRANSFER );
250  const QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
251 
252  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
253  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
254  void resolveReferences( const QgsProject &project ) override;
255 
263  double maximumScreenError() const;
264 
272  void setMaximumScreenError( double error );
273 
279  bool showBoundingBoxes() const;
280 
286  void setShowBoundingBoxes( bool showBoundingBoxes );
287 
291  int pointRenderingBudget() const { return mPointBudget; };
292 
296  void setPointRenderingBudget( int budget );
297 
298  private:
299  QgsMapLayerRef mLayerRef;
300  std::unique_ptr< QgsPointCloud3DSymbol > mSymbol;
301  double mMaximumScreenError = 1.0;
302  bool mShowBoundingBoxes = false;
303  int mPointBudget = 1000000;
304 
305  private:
306 #ifdef SIP_RUN
309 #endif
310 };
311 
312 
313 #endif // QGSPOINTCLOUDLAYER3DRENDERER_H
Base metadata class for 3D renderers.
QString type() const
Returns unique identifier of the 3D renderer class.
virtual QgsAbstract3DRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context)=0
Returns new instance of the renderer given the DOM element.
Base class for all renderers that may to participate in 3D view.
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...
QgsFeedback * feedback() const
Returns the feedback object used to cancel rendering and check if rendering was canceled.
double zValueScale() const
Returns any constant scaling factor which must be applied to z values taken from the point cloud inde...
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.
QgsPointCloud3DSymbol * symbol() const
Returns the symbol used for rendering the point cloud.
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.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:101
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