QGIS API Documentation 4.1.0-Master (60fea48833c)
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:
96
97
103 {
104 NotStarted = 0,
105 Calculating = 1 << 0,
106 Calculated = 1 << 1
107 };
108 Q_ENUM( PointCloudStatisticsCalculationState )
109
110
113 explicit QgsPointCloudLayer(
114 const QString &uri = QString(), const QString &baseName = QString(), const QString &providerLib = u"pointcloud"_s, const QgsPointCloudLayer::LayerOptions &options = QgsPointCloudLayer::LayerOptions()
115 );
116
117 ~QgsPointCloudLayer() override;
118
121
122#ifdef SIP_RUN
123 // clang-format off
124 SIP_PYOBJECT __repr__();
125 % MethodCode
126 QString str = u"<QgsPointCloudLayer: '%1' (%2)>"_s.arg( sipCpp->name(), sipCpp->dataProvider() ? sipCpp->dataProvider()->name() : u"Invalid"_s );
127 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
128 % End
129// clang-format on
130#endif
131
132 QgsPointCloudLayer *clone() const override SIP_FACTORY;
133 QgsRectangle extent() const override;
135 QgsAbstractProfileSource *profileSource() override { return this; }
136 QString profileSourceId() const override { return id(); }
137 QString profileSourceName() const override { return name(); }
139
141 const QgsPointCloudDataProvider *dataProvider() const override SIP_SKIP;
142
143 bool supportsEditing() const override;
144 bool isEditable() const override;
145 bool isModified() const override;
146
147 bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
148
149 bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
150
151 bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
152 bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) final;
153
154 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) const override;
155 bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) const final;
156
157 void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
158
159 QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override;
160 QString decodedSource( const QString &source, const QString &dataProvider, const QgsReadWriteContext &context ) const override;
161 QString loadDefaultStyle( bool &resultFlag SIP_OUT ) final;
162 QString htmlMetadata() const override;
163 QgsMapLayerElevationProperties *elevationProperties() override;
164
168 QgsPointCloudAttributeCollection attributes() const;
169
173 qint64 pointCount() const;
174
180 QgsPointCloudRenderer *renderer();
181
188 const QgsPointCloudRenderer *renderer() const SIP_SKIP;
189
197 void setRenderer( QgsPointCloudRenderer *renderer SIP_TRANSFER );
198
206 bool setSubsetString( const QString &subset );
207
214 QString subsetString() const;
215
222 void setSync3DRendererTo2DRenderer( bool sync );
223
230 bool sync3DRendererTo2DRenderer() const;
231
238 bool convertRenderer3DFromRenderer2D();
239
244 const QgsPointCloudStatistics statistics() const { return mStatistics; }
245
251 PointCloudStatisticsCalculationState statisticsCalculationState() const { return mStatisticsCalculationState; }
252
268 bool startEditing();
269
289 bool commitChanges( bool stopEditing = true );
290
297 QString commitError() const;
298
306 bool rollBack();
307
322 bool changeAttributeValue( const QgsPointCloudNodeId &n, const QVector<int> &points, const QgsPointCloudAttribute &attribute, double value ) SIP_SKIP;
323
337 bool changeAttributeValue( const QHash<int, QHash<QgsPointCloudNodeId, QVector<int>>> &mappedPoints, const QgsPointCloudAttribute &attribute, double value ) SIP_SKIP;
338
346 QgsPointCloudIndex index() const;
347
355 QVector<QgsPointCloudSubIndex> subIndexes() const;
356
362 bool isVpc() const { return mIsVpc; }
363
369 QgsPointCloudIndex overview() const;
370
371 signals:
372
379
385 void raiseError( const QString &msg );
386
393
399 void chunkAttributeValuesChanged( const QgsPointCloudNodeId &n, const int position );
400
401 private slots:
402 void onPointCloudIndexGenerationStateChanged( QgsPointCloudDataProvider::PointCloudIndexGenerationState state );
403 void setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags ) override;
404
405 private:
406 bool isReadOnly() const override { return true; }
407
408 void calculateStatistics();
409
410 void resetRenderer();
411
412 void loadIndexesForRenderContext( QgsRenderContext &rendererContext ) const;
413
414#ifdef SIP_RUN
416#endif
417
418 std::unique_ptr<QgsPointCloudDataProvider> mDataProvider;
419
420 std::unique_ptr<QgsPointCloudRenderer> mRenderer;
421
422 QgsPointCloudLayerElevationProperties *mElevationProperties = nullptr;
423
424 LayerOptions mLayerOptions;
425
426 bool mSync3DRendererTo2DRenderer = true;
427 QgsPointCloudStatistics mStatistics;
428 PointCloudStatisticsCalculationState mStatisticsCalculationState = PointCloudStatisticsCalculationState::NotStarted;
429 long mStatsCalculationTask = 0;
430
431 QgsPointCloudIndex mEditIndex;
432 mutable QMap< int, QgsPointCloudIndex > mEditingIndexes;
433 bool mIsVpc = false;
434 bool mEditable = false;
435 QString mCommitError;
436
438};
439
440
441#endif // QGSPOINTCLOUDLAYER_H
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:512
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.
bool isVpc() const
Returns whether the layer has a virtual point cloud data provider or not.
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.
friend class TestQgsVirtualPointCloudProvider
void subsetStringChanged()
Emitted when the layer's subset string has changed.
QgsPointCloudLayer & operator=(QgsPointCloudLayer const &rhs)=delete
void chunkAttributeValuesChanged(const QgsPointCloudNodeId &n, const int position)
Emitted when a node gets some attribute values of some points changed.
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:274
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_OUT
Definition qgis_sip.h:57
#define SIP_FACTORY
Definition qgis_sip.h:83
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.