QGIS API Documentation  3.23.0-Master (eb871beae0)
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  {
114  value = *( data + offset );
115  return;
116 
118  value = *reinterpret_cast< const qint32 * >( data + offset );
119  return;
120 
122  value = *reinterpret_cast< const short * >( data + offset );
123  return;
124 
126  value = *reinterpret_cast< const unsigned short * >( data + offset );
127  return;
128 
130  value = *reinterpret_cast< const float * >( data + offset );
131  return;
132 
134  value = *reinterpret_cast< const double * >( data + offset );
135  return;
136  }
137  }
138 
144  double zValueScale() const { return mZValueScale; }
145 
151  double zValueFixedOffset() const { return mZValueFixedOffset; }
152 
156  bool isCanceled() const;
157 
162  void cancelRendering() const;
163 
167  void setCoordinateTransform( const QgsCoordinateTransform &coordinateTransform );
168 
172  QgsCoordinateTransform coordinateTransform() const { return mCoordinateTransform; }
173 
177  QgsFeedback *feedback() const { return mFeedback.get(); }
178  private:
179 #ifdef SIP_RUN
181 #endif
183  std::unique_ptr<QgsPointCloud3DSymbol> mSymbol;
184  QgsPointCloudCategoryList mFilteredOutCategories;
185  double mZValueScale = 1.0;
186  double mZValueFixedOffset = 0;
187  QgsCoordinateTransform mCoordinateTransform;
188  std::unique_ptr<QgsFeedback> mFeedback;
189 };
190 
191 
201 {
202  public:
204 
206  QgsAbstract3DRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY;
207 };
208 
209 #endif
210 
218 {
219  public:
221  explicit QgsPointCloudLayer3DRenderer();
222 
224  void setLayer( QgsPointCloudLayer *layer );
226  QgsPointCloudLayer *layer() const;
227 
228  QString type() const override;
229  QgsPointCloudLayer3DRenderer *clone() const override SIP_FACTORY;
230  Qt3DCore::QEntity *createEntity( const Qgs3DMapSettings &map ) const override SIP_SKIP;
231 
237  void setSymbol( QgsPointCloud3DSymbol *symbol SIP_TRANSFER );
239  const QgsPointCloud3DSymbol *symbol() const { return mSymbol.get(); }
240 
241  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
242  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
243  void resolveReferences( const QgsProject &project ) override;
244 
252  double maximumScreenError() const;
253 
261  void setMaximumScreenError( double error );
262 
268  bool showBoundingBoxes() const;
269 
275  void setShowBoundingBoxes( bool showBoundingBoxes );
276 
280  int pointRenderingBudget() const { return mPointBudget; };
281 
285  void setPointRenderingBudget( int budget );
286 
287  private:
288  QgsMapLayerRef mLayerRef;
289  std::unique_ptr< QgsPointCloud3DSymbol > mSymbol;
290  double mMaximumScreenError = 1.0;
291  bool mShowBoundingBoxes = false;
292  int mPointBudget = 1000000;
293 
294  private:
295 #ifdef SIP_RUN
298 #endif
299 };
300 
301 
302 #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.
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