QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgspointcloudlayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspointcloudlayer.h
3  --------------------
4  begin : October 2020
5  copyright : (C) 2020 by Peter Petrik
6  email : zilolv at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSPOINTCLOUDLAYER_H
19 #define QGSPOINTCLOUDLAYER_H
20 
22 
24 #include "qgsmaplayer.h"
25 #include "qgis_core.h"
28 
29 #include <QString>
30 #include <memory>
31 
35 
45 class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer, public QgsAbstractProfileSource
46 {
47  Q_OBJECT
48  public:
49 
53  struct LayerOptions
54  {
55 
60  : transformContext( transformContext )
61  {}
62 
67 
69  bool loadDefaultStyle = true;
70 
82  bool skipCrsValidation = false;
83 
87  bool skipIndexGeneration = false;
88 
93  bool skipStatisticsCalculation = false;
94  };
95 
96 
102  {
103  NotStarted = 0,
104  Calculating = 1 << 0,
105  Calculated = 1 << 1
106  };
107  Q_ENUM( PointCloudStatisticsCalculationState )
108 
109 
112  explicit QgsPointCloudLayer( const QString &uri = QString(),
113  const QString &baseName = QString(),
114  const QString &providerLib = QStringLiteral( "pointcloud" ),
116 
117  ~QgsPointCloudLayer() override;
118 
120  QgsPointCloudLayer( const QgsPointCloudLayer &rhs ) = delete;
122  QgsPointCloudLayer &operator=( QgsPointCloudLayer const &rhs ) = delete;
123 
124 #ifdef SIP_RUN
125  SIP_PYOBJECT __repr__();
126  % MethodCode
127  QString str = QStringLiteral( "<QgsPointCloudLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider() ? sipCpp->dataProvider()->name() : QStringLiteral( "Invalid" ) );
128  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
129  % End
130 #endif
131 
132  QgsPointCloudLayer *clone() const override SIP_FACTORY;
133  QgsRectangle extent() const override;
134  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
135  QgsAbstractProfileGenerator *createProfileGenerator( const QgsProfileRequest &request ) override SIP_FACTORY;
136 
137  QgsPointCloudDataProvider *dataProvider() override;
138  const QgsPointCloudDataProvider *dataProvider() const override SIP_SKIP;
139 
140  bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
141 
142  bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
143 
144  bool readSymbology( const QDomNode &node, QString &errorMessage,
145  QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
146  bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) FINAL;
147 
148  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
149  StyleCategories categories = AllStyleCategories ) const override;
150  bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) const FINAL;
151 
152  void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
153 
154  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override;
155  QString decodedSource( const QString &source, const QString &dataProvider, const QgsReadWriteContext &context ) const override;
156  QString loadDefaultStyle( bool &resultFlag SIP_OUT ) FINAL;
157  QString htmlMetadata() const override;
158  QgsMapLayerElevationProperties *elevationProperties() override;
159 
163  QgsPointCloudAttributeCollection attributes() const;
164 
168  qint64 pointCount() const;
169 
175  QgsPointCloudRenderer *renderer();
176 
183  const QgsPointCloudRenderer *renderer() const SIP_SKIP;
184 
192  void setRenderer( QgsPointCloudRenderer *renderer SIP_TRANSFER );
193 
201  bool setSubsetString( const QString &subset );
202 
209  QString subsetString() const;
210 
217  void setSync3DRendererTo2DRenderer( bool sync );
218 
225  bool sync3DRendererTo2DRenderer() const;
226 
233  bool convertRenderer3DFromRenderer2D();
234 
239  const QgsPointCloudStatistics statistics() const { return mStatistics; }
240 
246  PointCloudStatisticsCalculationState statisticsCalculationState() const { return mStatisticsCalculationState; }
247  signals:
248 
254  void subsetStringChanged();
255 
261  void raiseError( const QString &msg );
262 
268  void statisticsCalculationStateChanged( QgsPointCloudLayer::PointCloudStatisticsCalculationState state );
269 
270  private slots:
271  void onPointCloudIndexGenerationStateChanged( QgsPointCloudDataProvider::PointCloudIndexGenerationState state );
272  void setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags ) override;
273 
274  private:
275 
276  bool isReadOnly() const override {return true;}
277 
278  void calculateStatistics();
279 
280  void resetRenderer();
281 
282 #ifdef SIP_RUN
284 #endif
285 
286  std::unique_ptr<QgsPointCloudDataProvider> mDataProvider;
287 
288  std::unique_ptr<QgsPointCloudRenderer> mRenderer;
289 
290  QgsPointCloudLayerElevationProperties *mElevationProperties = nullptr;
291 
292  LayerOptions mLayerOptions;
293 
294  bool mSync3DRendererTo2DRenderer = true;
295  QgsPointCloudStatistics mStatistics;
296  PointCloudStatisticsCalculationState mStatisticsCalculationState = PointCloudStatisticsCalculationState::NotStarted;
297  long mStatsCalculationTask = 0;
298 };
299 
300 
301 #endif // QGSPOINTCLOUDPLAYER_H
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:57
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:107
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsMapLayerElevationProperties
Base class for storage of map layer elevation properties.
Definition: qgsmaplayerelevationproperties.h:41
QgsMapLayer::clone
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
QgsPointCloudLayerElevationProperties
Point cloud layer specific subclass of QgsMapLayerElevationProperties.
Definition: qgspointcloudlayerelevationproperties.h:33
QgsPointCloudLayer
Represents a map layer supporting display of point clouds.
Definition: qgspointcloudlayer.h:45
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsAbstractProfileGenerator
Abstract base class for objects which generate elevation profiles.
Definition: qgsabstractprofilegenerator.h:392
QgsPointCloudLayer::PointCloudStatisticsCalculationState
PointCloudStatisticsCalculationState
Point cloud statistics calculation task.
Definition: qgspointcloudlayer.h:101
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsPointCloudStatistics
Class used to store statistics of a point cloud dataset.
Definition: qgspointcloudstatistics.h:61
qgsabstractprofilesource.h
FINAL
#define FINAL
Definition: qgis_sip.h:237
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsMapLayerRenderer
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Definition: qgsmaplayerrenderer.h:54
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
qgspointcloudstatistics.h
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsMapLayer::operator=
QgsMapLayer & operator=(QgsMapLayer const &)=delete
QgsMapLayer cannot be copied.
QgsPointCloudLayer::LayerOptions::LayerOptions
LayerOptions(const QgsCoordinateTransformContext &transformContext=QgsCoordinateTransformContext())
Constructor for LayerOptions with optional transformContext.
Definition: qgspointcloudlayer.h:59
qgsmaplayer.h
QgsPointCloudAttributeCollection
Collection of point cloud attributes.
Definition: qgspointcloudattribute.h:141
QgsAbstractPointCloud3DRenderer
Base class for point cloud 3D renderers.
Definition: qgsabstractpointcloud3drenderer.h:40
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsProfileRequest
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
Definition: qgsprofilerequest.h:37
QgsPointCloudDataProvider
Base class for providing data for QgsPointCloudLayer.
Definition: qgspointclouddataprovider.h:46
str
#define str(x)
Definition: qgis.cpp:37
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
qgspointclouddataprovider.h
QgsPointCloudRenderer
Abstract base class for 2d point cloud renderers.
Definition: qgspointcloudrenderer.h:296
QgsPointCloudLayer::LayerOptions::transformContext
QgsCoordinateTransformContext transformContext
Coordinate transform context.
Definition: qgspointcloudlayer.h:66
QgsPointCloudDataProvider::PointCloudIndexGenerationState
PointCloudIndexGenerationState
Point cloud index state.
Definition: qgspointclouddataprovider.h:67
QgsPointCloudLayer::LayerOptions
Setting options for loading point cloud layers.
Definition: qgspointcloudlayer.h:53
QgsPointCloudLayer::statisticsCalculationState
PointCloudStatisticsCalculationState statisticsCalculationState() const
Returns the status of point cloud statistics calculation.
Definition: qgspointcloudlayer.h:246
QgsPointCloudLayerRenderer
Implementation of threaded rendering for point cloud layers.
Definition: qgspointcloudlayerrenderer.h:59
QgsAbstractProfileSource
Interface for classes which can generate elevation profiles.
Definition: qgsabstractprofilesource.h:33