QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
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
23#include <memory>
24
25#include "qgis_core.h"
27#include "qgsmaplayer.h"
30
31#include <QString>
32
33using namespace Qt::StringLiterals;
34
38
49{
50 Q_OBJECT
51 public:
52
98
99
105 {
106 NotStarted = 0,
107 Calculating = 1 << 0,
108 Calculated = 1 << 1
109 };
110 Q_ENUM( PointCloudStatisticsCalculationState )
111
112
115 explicit QgsPointCloudLayer( const QString &uri = QString(),
116 const QString &baseName = QString(),
117 const QString &providerLib = u"pointcloud"_s,
119
120 ~QgsPointCloudLayer() override;
121
124
125#ifdef SIP_RUN
126 SIP_PYOBJECT __repr__();
127 % MethodCode
128 QString str = u"<QgsPointCloudLayer: '%1' (%2)>"_s.arg( sipCpp->name(), sipCpp->dataProvider() ? sipCpp->dataProvider()->name() : u"Invalid"_s );
129 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
130 % End
131#endif
132
133 QgsPointCloudLayer *clone() const override SIP_FACTORY;
134 QgsRectangle extent() const override;
136 QgsAbstractProfileSource *profileSource() override {return this;}
137 QString profileSourceId() const override {return id();}
138 QString profileSourceName() const override {return name();}
140
142 const QgsPointCloudDataProvider *dataProvider() const override SIP_SKIP;
143
144 bool supportsEditing() const override;
145 bool isEditable() const override;
146 bool isModified() const override;
147
148 bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
149
150 bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
151
152 bool readSymbology( const QDomNode &node, QString &errorMessage,
153 QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
154 bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) final;
155
156 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
157 StyleCategories categories = AllStyleCategories ) const override;
158 bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) const final;
159
160 void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
161
162 QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override;
163 QString decodedSource( const QString &source, const QString &dataProvider, const QgsReadWriteContext &context ) const override;
164 QString loadDefaultStyle( bool &resultFlag SIP_OUT ) final;
165 QString htmlMetadata() const override;
166 QgsMapLayerElevationProperties *elevationProperties() override;
167
171 QgsPointCloudAttributeCollection attributes() const;
172
176 qint64 pointCount() const;
177
183 QgsPointCloudRenderer *renderer();
184
191 const QgsPointCloudRenderer *renderer() const SIP_SKIP;
192
200 void setRenderer( QgsPointCloudRenderer *renderer SIP_TRANSFER );
201
209 bool setSubsetString( const QString &subset );
210
217 QString subsetString() const;
218
225 void setSync3DRendererTo2DRenderer( bool sync );
226
233 bool sync3DRendererTo2DRenderer() const;
234
241 bool convertRenderer3DFromRenderer2D();
242
247 const QgsPointCloudStatistics statistics() const { return mStatistics; }
248
254 PointCloudStatisticsCalculationState statisticsCalculationState() const { return mStatisticsCalculationState; }
255
271 bool startEditing();
272
292 bool commitChanges( bool stopEditing = true );
293
300 QString commitError() const;
301
309 bool rollBack();
310
325 bool changeAttributeValue( const QgsPointCloudNodeId &n, const QVector<int> &points, const QgsPointCloudAttribute &attribute, double value ) SIP_SKIP;
326
340 bool changeAttributeValue( const QHash<QgsPointCloudNodeId, QVector<int>> &nodesAndPoints, const QgsPointCloudAttribute &attribute, double value ) SIP_SKIP;
341
349 QgsPointCloudIndex index() const;
350
351
352 signals:
353
360
366 void raiseError( const QString &msg );
367
374
381
382 private slots:
383 void onPointCloudIndexGenerationStateChanged( QgsPointCloudDataProvider::PointCloudIndexGenerationState state );
384 void setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags ) override;
385
386 private:
387
388 bool isReadOnly() const override {return true;}
389
390 void calculateStatistics();
391
392 void resetRenderer();
393
394 void loadIndexesForRenderContext( QgsRenderContext &rendererContext ) const;
395
396#ifdef SIP_RUN
398#endif
399
400 std::unique_ptr<QgsPointCloudDataProvider> mDataProvider;
401
402 std::unique_ptr<QgsPointCloudRenderer> mRenderer;
403
404 QgsPointCloudLayerElevationProperties *mElevationProperties = nullptr;
405
406 LayerOptions mLayerOptions;
407
408 bool mSync3DRendererTo2DRenderer = true;
409 QgsPointCloudStatistics mStatistics;
410 PointCloudStatisticsCalculationState mStatisticsCalculationState = PointCloudStatisticsCalculationState::NotStarted;
411 long mStatsCalculationTask = 0;
412
413 QgsPointCloudIndex mEditIndex;
414 QString mCommitError;
415
417};
418
419
420#endif // QGSPOINTCLOUDLAYER_H
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:505
Base class for point cloud 3D renderers.
Abstract base class for objects which generate elevation profiles.
Interface for classes which can generate elevation profiles.
virtual QgsAbstractProfileGenerator * createProfileGenerator(const QgsProfileRequest &request)=0
Given a profile request, returns a new profile generator ready for generating elevation profiles.
Contains information about the context in which a coordinate transform is executed.
Base class for storage of map layer elevation properties.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
QString name
Definition qgsmaplayer.h:87
QString id
Definition qgsmaplayer.h:86
QgsMapLayer(Qgis::LayerType type=Qgis::LayerType::Vector, const QString &name=QString(), const QString &source=QString())
Constructor for QgsMapLayer.
QgsMapLayer::LayerFlags flags
Definition qgsmaplayer.h:99
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
virtual Q_INVOKABLE QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be nullptr.
A collection of point cloud attributes.
Attribute for point cloud data pair of name and size in bytes.
Base class for providing data for QgsPointCloudLayer.
PointCloudIndexGenerationState
Point cloud index state.
Smart pointer for QgsAbstractPointCloudIndex.
Point cloud layer specific subclass of QgsMapLayerElevationProperties.
Implementation of threaded rendering for point cloud layers.
Represents a map layer supporting display of point clouds.
PointCloudStatisticsCalculationState
Point cloud statistics calculation task.
QgsRectangle extent() const override
Returns the extent of the layer.
void raiseError(const QString &msg)
Signals an error related to this point cloud layer.
PointCloudStatisticsCalculationState statisticsCalculationState() const
Returns the status of point cloud statistics calculation.
QString profileSourceName() const override
Returns a name for displaying this profile source in the elevation profile layer tree.
QgsPointCloudLayer(const QgsPointCloudLayer &rhs)=delete
void statisticsCalculationStateChanged(QgsPointCloudLayer::PointCloudStatisticsCalculationState state)
Emitted when statistics calculation state has changed.
QString profileSourceId() const override
Returns a unique identifier for this profile source.
const QgsPointCloudStatistics statistics() const
Returns the object containing statistics.
QgsAbstractProfileSource * profileSource() override
Returns the layer's profile source if it has profile capabilities.
QgsPointCloudLayer(const QString &uri=QString(), const QString &baseName=QString(), const QString &providerLib=u"pointcloud"_s, const QgsPointCloudLayer::LayerOptions &options=QgsPointCloudLayer::LayerOptions())
Constructor - creates a point cloud layer.
void chunkAttributeValuesChanged(const QgsPointCloudNodeId &n)
Emitted when a node gets some attribute values of some points changed.
friend class TestQgsVirtualPointCloudProvider
void subsetStringChanged()
Emitted when the layer's subset string has changed.
QgsPointCloudLayer & operator=(QgsPointCloudLayer const &rhs)=delete
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
Represents an indexed point cloud node's position in octree.
Abstract base class for 2d point cloud renderers.
Used to store statistics of a point cloud dataset.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
A container for the context for various read/write operations on objects.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:275
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_FACTORY
Definition qgis_sip.h:84
Setting options for creating vector data providers.
Setting options for loading point cloud layers.
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS.
bool skipStatisticsCalculation
Set to true if the statistics calculation for this point cloud is disabled.
bool loadDefaultStyle
Set to true if the default layer style should be loaded.
bool skipIndexGeneration
Set to true if point cloud index generation should be skipped.
LayerOptions(const QgsCoordinateTransformContext &transformContext=QgsCoordinateTransformContext())
Constructor for LayerOptions with optional transformContext.
QgsCoordinateTransformContext transformContext
Coordinate transform context.