From 2be85ec1d94d57e8ed285590a86750dd1696a128 Mon Sep 17 00:00:00 2001 From: uclaros Date: Tue, 7 Jan 2025 19:28:30 +0200 Subject: [PATCH] adjust to use the new QgsPointCloudIndex class --- .../pointcloud/qgspointcloudindex.sip.in | 19 ++++++++ .../pointcloud/qgspointcloudlayer.sip.in | 8 ++++ .../pointcloud/qgspointcloudindex.sip.in | 19 ++++++++ .../pointcloud/qgspointcloudlayer.sip.in | 8 ++++ .../pointcloud/qgspointcloudeditingindex.cpp | 48 +++++++++---------- .../pointcloud/qgspointcloudeditingindex.h | 10 ++-- src/core/pointcloud/qgspointcloudindex.cpp | 24 ++++++++++ src/core/pointcloud/qgspointcloudindex.h | 37 ++++++++++---- src/core/pointcloud/qgspointcloudlayer.cpp | 20 ++++---- src/core/pointcloud/qgspointcloudlayer.h | 10 ++-- .../qgspointcloudlayereditutils.cpp | 13 +++-- .../pointcloud/qgspointcloudlayereditutils.h | 4 +- tests/src/core/testqgspointcloudediting.cpp | 47 +++++++++--------- 13 files changed, 179 insertions(+), 88 deletions(-) diff --git a/python/PyQt6/core/auto_generated/pointcloud/qgspointcloudindex.sip.in b/python/PyQt6/core/auto_generated/pointcloud/qgspointcloudindex.sip.in index a99fbd00167c..18cbe8b42976 100644 --- a/python/PyQt6/core/auto_generated/pointcloud/qgspointcloudindex.sip.in +++ b/python/PyQt6/core/auto_generated/pointcloud/qgspointcloudindex.sip.in @@ -269,6 +269,13 @@ Returns all attributes that are stored in the file + bool updateNodeData( const QHash &data ); +%Docstring +Tries to update the data for the specified nodes. + +:return: ``True`` on success, otherwise ``False`` +%End + QgsRectangle extent() const; %Docstring Returns extent of the data @@ -346,6 +353,18 @@ Returns extra metadata that's not accessible through the other methods in an implementation-specific dynamic structure. .. seealso:: :py:func:`QgsAbstractPointCloudIndex.extraMetadata` +%End + + bool commitChanges(); +%Docstring +Tries to store pending changes to the data provider. + +:return: ``True`` on success, otherwise ``False`` +%End + + bool isModified() const; +%Docstring +Returns ``True`` if there are uncommitted changes, ``False`` otherwise %End }; diff --git a/python/PyQt6/core/auto_generated/pointcloud/qgspointcloudlayer.sip.in b/python/PyQt6/core/auto_generated/pointcloud/qgspointcloudlayer.sip.in index a008b4a5eb4e..090caa36c2ee 100644 --- a/python/PyQt6/core/auto_generated/pointcloud/qgspointcloudlayer.sip.in +++ b/python/PyQt6/core/auto_generated/pointcloud/qgspointcloudlayer.sip.in @@ -274,6 +274,14 @@ Stops a current editing operation and discards any uncommitted edits. %End + QgsPointCloudIndex index() const; +%Docstring +Returns the point cloud index associated with the layer. +If the layer is editable, its :py:class:`QgsPointCloudEditingIndex` is returned, +otherwise the index is fetched from the data provider. + +.. versionadded:: 3.42 +%End signals: diff --git a/python/core/auto_generated/pointcloud/qgspointcloudindex.sip.in b/python/core/auto_generated/pointcloud/qgspointcloudindex.sip.in index a99fbd00167c..18cbe8b42976 100644 --- a/python/core/auto_generated/pointcloud/qgspointcloudindex.sip.in +++ b/python/core/auto_generated/pointcloud/qgspointcloudindex.sip.in @@ -269,6 +269,13 @@ Returns all attributes that are stored in the file + bool updateNodeData( const QHash &data ); +%Docstring +Tries to update the data for the specified nodes. + +:return: ``True`` on success, otherwise ``False`` +%End + QgsRectangle extent() const; %Docstring Returns extent of the data @@ -346,6 +353,18 @@ Returns extra metadata that's not accessible through the other methods in an implementation-specific dynamic structure. .. seealso:: :py:func:`QgsAbstractPointCloudIndex.extraMetadata` +%End + + bool commitChanges(); +%Docstring +Tries to store pending changes to the data provider. + +:return: ``True`` on success, otherwise ``False`` +%End + + bool isModified() const; +%Docstring +Returns ``True`` if there are uncommitted changes, ``False`` otherwise %End }; diff --git a/python/core/auto_generated/pointcloud/qgspointcloudlayer.sip.in b/python/core/auto_generated/pointcloud/qgspointcloudlayer.sip.in index 5d512a751e5f..d239635dce4a 100644 --- a/python/core/auto_generated/pointcloud/qgspointcloudlayer.sip.in +++ b/python/core/auto_generated/pointcloud/qgspointcloudlayer.sip.in @@ -274,6 +274,14 @@ Stops a current editing operation and discards any uncommitted edits. %End + QgsPointCloudIndex index() const; +%Docstring +Returns the point cloud index associated with the layer. +If the layer is editable, its :py:class:`QgsPointCloudEditingIndex` is returned, +otherwise the index is fetched from the data provider. + +.. versionadded:: 3.42 +%End signals: diff --git a/src/core/pointcloud/qgspointcloudeditingindex.cpp b/src/core/pointcloud/qgspointcloudeditingindex.cpp index b3079eef9141..6287e07c7655 100644 --- a/src/core/pointcloud/qgspointcloudeditingindex.cpp +++ b/src/core/pointcloud/qgspointcloudeditingindex.cpp @@ -20,7 +20,7 @@ QgsPointCloudEditingIndex::QgsPointCloudEditingIndex( QgsPointCloudLayer *layer ) - : mIndex( layer ? layer->index() : nullptr ) + : mIndex( layer ? layer->index() : QgsPointCloudIndex() ) { if ( !layer || !layer->dataProvider() || @@ -28,18 +28,18 @@ QgsPointCloudEditingIndex::QgsPointCloudEditingIndex( QgsPointCloudLayer *layer !( layer->dataProvider()->capabilities() & QgsPointCloudDataProvider::Capability::ChangeAttributeValues ) ) return; - mAttributes = mIndex->attributes(); - mScale = mIndex->scale(); - mOffset = mIndex->offset(); - mExtent = mIndex->extent(); - mZMin = mIndex->zMin(); - mZMax = mIndex->zMax(); - mRootBounds = mIndex->rootNodeBounds(); - mSpan = mIndex->span(); + mAttributes = mIndex.attributes(); + mScale = mIndex.scale(); + mOffset = mIndex.offset(); + mExtent = mIndex.extent(); + mZMin = mIndex.zMin(); + mZMax = mIndex.zMax(); + mRootBounds = mIndex.rootNodeBounds(); + mSpan = mIndex.span(); mIsValid = true; } -std::unique_ptr QgsPointCloudEditingIndex::clone() const +std::unique_ptr QgsPointCloudEditingIndex::clone() const { return nullptr; } @@ -51,37 +51,37 @@ void QgsPointCloudEditingIndex::load( const QString & ) bool QgsPointCloudEditingIndex::isValid() const { - return mIsValid && mIndex->isValid(); + return mIsValid && mIndex.isValid(); } -QgsPointCloudIndex::AccessType QgsPointCloudEditingIndex::accessType() const +Qgis::PointCloudAccessType QgsPointCloudEditingIndex::accessType() const { - return mIndex->accessType(); + return mIndex.accessType(); } QgsCoordinateReferenceSystem QgsPointCloudEditingIndex::crs() const { - return mIndex->crs(); + return mIndex.crs(); } qint64 QgsPointCloudEditingIndex::pointCount() const { - return mIndex->pointCount(); + return mIndex.pointCount(); } QVariantMap QgsPointCloudEditingIndex::originalMetadata() const { - return mIndex->originalMetadata(); + return mIndex.originalMetadata(); } bool QgsPointCloudEditingIndex::hasNode( const QgsPointCloudNodeId &n ) const { - return mIndex->hasNode( n ); + return mIndex.hasNode( n ); } QgsPointCloudNode QgsPointCloudEditingIndex::getNode( const QgsPointCloudNodeId &id ) const { - return mIndex->getNode( id ); + return mIndex.getNode( id ); } std::unique_ptr< QgsPointCloudBlock > QgsPointCloudEditingIndex::nodeData( const QgsPointCloudNodeId &n, const QgsPointCloudRequest &request ) @@ -89,21 +89,21 @@ std::unique_ptr< QgsPointCloudBlock > QgsPointCloudEditingIndex::nodeData( const if ( mEditedNodeData.contains( n ) ) { const QByteArray data = mEditedNodeData.value( n ); - int nPoints = data.size() / mIndex->attributes().pointRecordSize(); + int nPoints = data.size() / mIndex.attributes().pointRecordSize(); - const QByteArray requestedData = QgsPointCloudLayerEditUtils::dataForAttributes( mIndex->attributes(), data, request ); + const QByteArray requestedData = QgsPointCloudLayerEditUtils::dataForAttributes( mIndex.attributes(), data, request ); std::unique_ptr block = std::make_unique< QgsPointCloudBlock >( nPoints, request.attributes(), requestedData, - mIndex->scale(), - mIndex->offset() ); + mIndex.scale(), + mIndex.offset() ); return block; } else { - return mIndex->nodeData( n, request ); + return mIndex.nodeData( n, request ); } } @@ -118,7 +118,7 @@ bool QgsPointCloudEditingIndex::commitChanges() if ( !isModified() ) return true; - if ( !mIndex->updateNodeData( mEditedNodeData ) ) + if ( !mIndex.updateNodeData( mEditedNodeData ) ) return false; mEditedNodeData.clear(); diff --git a/src/core/pointcloud/qgspointcloudeditingindex.h b/src/core/pointcloud/qgspointcloudeditingindex.h index d03e4917a899..70a892de201b 100644 --- a/src/core/pointcloud/qgspointcloudeditingindex.h +++ b/src/core/pointcloud/qgspointcloudeditingindex.h @@ -33,16 +33,16 @@ class QgsPointCloudLayer; * * \since QGIS 3.42 */ -class CORE_EXPORT QgsPointCloudEditingIndex : public QgsPointCloudIndex +class CORE_EXPORT QgsPointCloudEditingIndex : public QgsAbstractPointCloudIndex { public: //! Ctor explicit QgsPointCloudEditingIndex( QgsPointCloudLayer *layer ); - std::unique_ptr clone() const override; + std::unique_ptr clone() const override; void load( const QString &fileName ) override; bool isValid() const override; - AccessType accessType() const override; + Qgis::PointCloudAccessType accessType() const override; QgsCoordinateReferenceSystem crs() const override; qint64 pointCount() const override; QVariantMap originalMetadata() const override; @@ -56,7 +56,7 @@ class CORE_EXPORT QgsPointCloudEditingIndex : public QgsPointCloudIndex bool updateNodeData( const QHash &data ) override; /** - * Try to store pending changes to the data provider. + * Tries to store pending changes to the data provider. * \return TRUE on success, otherwise FALSE */ bool commitChanges(); @@ -66,7 +66,7 @@ class CORE_EXPORT QgsPointCloudEditingIndex : public QgsPointCloudIndex private: - QgsPointCloudIndex *mIndex = nullptr; + QgsPointCloudIndex mIndex; bool mIsValid = false; QHash mEditedNodeData; }; diff --git a/src/core/pointcloud/qgspointcloudindex.cpp b/src/core/pointcloud/qgspointcloudindex.cpp index 63e3966eac9f..af5aa064b656 100644 --- a/src/core/pointcloud/qgspointcloudindex.cpp +++ b/src/core/pointcloud/qgspointcloudindex.cpp @@ -32,6 +32,7 @@ #include "qgstiledownloadmanager.h" #include "qgspointcloudstatistics.h" #include "qgslogger.h" +#include "qgspointcloudeditingindex.h" QgsPointCloudNodeId::QgsPointCloudNodeId(): mD( -1 ), @@ -425,6 +426,12 @@ QgsPointCloudBlockRequest *QgsPointCloudIndex::asyncNodeData( const QgsPointClou return mIndex->asyncNodeData( n, request ); } +bool QgsPointCloudIndex::updateNodeData( const QHash &data ) +{ + Q_ASSERT( mIndex ); + return mIndex->updateNodeData( data ); +} + QgsRectangle QgsPointCloudIndex::extent() const { Q_ASSERT( mIndex ); @@ -497,3 +504,20 @@ QVariantMap QgsPointCloudIndex::extraMetadata() const return mIndex->extraMetadata(); } +bool QgsPointCloudIndex::commitChanges() +{ + Q_ASSERT( mIndex ); + if ( QgsPointCloudEditingIndex *index = dynamic_cast( mIndex.get() ) ) + return index->commitChanges(); + + return false; +} + +bool QgsPointCloudIndex::isModified() const +{ + if ( QgsPointCloudEditingIndex *index = dynamic_cast( mIndex.get() ) ) + return index->isModified(); + + return false; +} + diff --git a/src/core/pointcloud/qgspointcloudindex.h b/src/core/pointcloud/qgspointcloudindex.h index ff63e1ab0aac..430cff42d678 100644 --- a/src/core/pointcloud/qgspointcloudindex.h +++ b/src/core/pointcloud/qgspointcloudindex.h @@ -25,6 +25,7 @@ #include #include #include +#include #include "qgis_core.h" #include "qgspointcloudstatistics.h" @@ -273,15 +274,6 @@ class CORE_EXPORT QgsAbstractPointCloudIndex //! Returns object for a given node virtual QgsPointCloudNode getNode( const QgsPointCloudNodeId &id ) const; - /** - * Tries to update the data for the specified nodes. - * Subclasses that support editing should override this to handle storing the data. - * Default implementation does nothing, returns false. - * \returns TRUE on success, otherwise FALSE - * \since QGIS 3.42 - */ - virtual bool updateNodeData( const QHash &data ); - //! Returns all attributes that are stored in the file QgsPointCloudAttributeCollection attributes() const; @@ -307,6 +299,15 @@ class CORE_EXPORT QgsAbstractPointCloudIndex */ virtual QgsPointCloudBlockRequest *asyncNodeData( const QgsPointCloudNodeId &n, const QgsPointCloudRequest &request ) = 0; + /** + * Tries to update the data for the specified nodes. + * Subclasses that support editing should override this to handle storing the data. + * Default implementation does nothing, returns false. + * \returns TRUE on success, otherwise FALSE + * \since QGIS 3.42 + */ + virtual bool updateNodeData( const QHash &data ); + //! Returns extent of the data QgsRectangle extent() const { return mExtent; } @@ -542,6 +543,13 @@ class CORE_EXPORT QgsPointCloudIndex SIP_NODEFAULTCTORS */ QgsPointCloudBlockRequest *asyncNodeData( const QgsPointCloudNodeId &n, const QgsPointCloudRequest &request ) SIP_SKIP; + /** + * Tries to update the data for the specified nodes. + * + * \returns TRUE on success, otherwise FALSE + */ + bool updateNodeData( const QHash &data ); + /** * Returns extent of the data * @@ -633,8 +641,19 @@ class CORE_EXPORT QgsPointCloudIndex SIP_NODEFAULTCTORS */ QVariantMap extraMetadata() const; + /** + * Tries to store pending changes to the data provider. + * \return TRUE on success, otherwise FALSE + */ + bool commitChanges(); + + //! Returns TRUE if there are uncommitted changes, FALSE otherwise + bool isModified() const; + private: std::shared_ptr mIndex; + + friend class TestQgsPointCloudEditing; }; diff --git a/src/core/pointcloud/qgspointcloudlayer.cpp b/src/core/pointcloud/qgspointcloudlayer.cpp index df9395504971..67bffcf2f0a1 100644 --- a/src/core/pointcloud/qgspointcloudlayer.cpp +++ b/src/core/pointcloud/qgspointcloudlayer.cpp @@ -979,11 +979,11 @@ bool QgsPointCloudLayer::startEditing() if ( mEditIndex ) return false; - mEditIndex = std::make_unique( this ); + mEditIndex = QgsPointCloudIndex( new QgsPointCloudEditingIndex( this ) ); - if ( !mEditIndex->isValid() ) + if ( !mEditIndex.isValid() ) { - mEditIndex.reset(); + mEditIndex = QgsPointCloudIndex(); return false; } @@ -995,12 +995,12 @@ bool QgsPointCloudLayer::commitChanges( bool stopEditing ) { QGIS_PROTECT_QOBJECT_THREAD_ACCESS if ( !mEditIndex || - !mEditIndex->commitChanges() ) + !mEditIndex.commitChanges() ) return false; if ( stopEditing ) { - mEditIndex.reset(); + mEditIndex = QgsPointCloudIndex(); emit editingStopped(); } @@ -1025,7 +1025,7 @@ bool QgsPointCloudLayer::rollBack() triggerRepaint(); } - mEditIndex.reset(); + mEditIndex = QgsPointCloudIndex(); emit editingStopped(); return true; @@ -1052,7 +1052,7 @@ bool QgsPointCloudLayer::isModified() const if ( !mEditIndex ) return false; - return mEditIndex->isModified(); + return mEditIndex.isModified(); } bool QgsPointCloudLayer::changeAttributeValue( const QgsPointCloudNodeId &n, const QVector &pts, const QgsPointCloudAttribute &attribute, double value ) @@ -1072,14 +1072,14 @@ bool QgsPointCloudLayer::changeAttributeValue( const QgsPointCloudNodeId &n, con return success; } -QgsPointCloudIndex *QgsPointCloudLayer::index() const +QgsPointCloudIndex QgsPointCloudLayer::index() const { QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL if ( mEditIndex ) - return mEditIndex.get(); + return mEditIndex; if ( mDataProvider ) return mDataProvider->index(); - return nullptr; + return QgsPointCloudIndex(); } diff --git a/src/core/pointcloud/qgspointcloudlayer.h b/src/core/pointcloud/qgspointcloudlayer.h index 764d39e9a71e..fef96e8d1925 100644 --- a/src/core/pointcloud/qgspointcloudlayer.h +++ b/src/core/pointcloud/qgspointcloudlayer.h @@ -32,7 +32,6 @@ class QgsPointCloudLayerRenderer; class QgsPointCloudRenderer; class QgsPointCloudLayerElevationProperties; class QgsAbstractPointCloud3DRenderer; -class QgsPointCloudEditingIndex; /** * \ingroup core @@ -324,12 +323,9 @@ class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer, public QgsAbstractPro * If the layer is editable, its QgsPointCloudEditingIndex is returned, * otherwise the index is fetched from the data provider. * - * Can be nullptr (e.g. the index is being created) - * - * \note Not available in Python bindings * \since QGIS 3.42 */ - QgsPointCloudIndex *index() const SIP_SKIP; + QgsPointCloudIndex index() const; signals: @@ -375,8 +371,6 @@ class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer, public QgsAbstractPro std::unique_ptr mDataProvider; - std::unique_ptr mEditIndex; - std::unique_ptr mRenderer; QgsPointCloudLayerElevationProperties *mElevationProperties = nullptr; @@ -387,6 +381,8 @@ class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer, public QgsAbstractPro QgsPointCloudStatistics mStatistics; PointCloudStatisticsCalculationState mStatisticsCalculationState = PointCloudStatisticsCalculationState::NotStarted; long mStatsCalculationTask = 0; + + QgsPointCloudIndex mEditIndex; QString mCommitError; friend class TestQgsVirtualPointCloudProvider; diff --git a/src/core/pointcloud/qgspointcloudlayereditutils.cpp b/src/core/pointcloud/qgspointcloudlayereditutils.cpp index d24f3f42861f..1a59aa88bbb5 100644 --- a/src/core/pointcloud/qgspointcloudlayereditutils.cpp +++ b/src/core/pointcloud/qgspointcloudlayereditutils.cpp @@ -14,13 +14,12 @@ ***************************************************************************/ #include "qgspointcloudlayereditutils.h" -#include "qgspointcloudeditingindex.h" #include "qgspointcloudlayer.h" #include "qgslazdecoder.h" QgsPointCloudLayerEditUtils::QgsPointCloudLayerEditUtils( QgsPointCloudLayer *layer ) - : mIndex( dynamic_cast( layer->index() ) ) + : mIndex( layer->index() ) { } @@ -32,10 +31,10 @@ bool QgsPointCloudLayerEditUtils::changeAttributeValue( const QgsPointCloudNodeI attribute.name().compare( QLatin1String( "Z" ), Qt::CaseInsensitive ) == 0 ) return false; - if ( !n.isValid() || !mIndex->hasNode( n ) ) // todo: should not have to check if n.isValid + if ( !n.isValid() || !mIndex.hasNode( n ) ) // todo: should not have to check if n.isValid return false; - const QgsPointCloudAttributeCollection attributeCollection = mIndex->attributes(); + const QgsPointCloudAttributeCollection attributeCollection = mIndex.attributes(); int attributeOffset; const QgsPointCloudAttribute *at = attributeCollection.find( attribute.name(), attributeOffset ); @@ -57,13 +56,13 @@ bool QgsPointCloudLayerEditUtils::changeAttributeValue( const QgsPointCloudNodeI std::sort( sortedPoints.begin(), sortedPoints.end() ); if ( sortedPoints.constFirst() < 0 || - sortedPoints.constLast() > mIndex->getNode( n ).pointCount() ) + sortedPoints.constLast() > mIndex.getNode( n ).pointCount() ) return false; QgsPointCloudRequest req; req.setAttributes( attributeCollection ); - std::unique_ptr block = mIndex->nodeData( n, req ); + std::unique_ptr block = mIndex.nodeData( n, req ); const int count = block->pointCount(); const int recordSize = attributeCollection.pointRecordSize(); @@ -78,7 +77,7 @@ bool QgsPointCloudLayerEditUtils::changeAttributeValue( const QgsPointCloudNodeI lazStoreToStream_( ptr, i * recordSize + attributeOffset, attribute.type(), value ); } - return mIndex->updateNodeData( {{n, data}} );; + return mIndex.updateNodeData( {{n, data}} );; } QByteArray QgsPointCloudLayerEditUtils::dataForAttributes( const QgsPointCloudAttributeCollection &allAttributes, const QByteArray &data, const QgsPointCloudRequest &request ) diff --git a/src/core/pointcloud/qgspointcloudlayereditutils.h b/src/core/pointcloud/qgspointcloudlayereditutils.h index 783a3fa61b1a..4aabb116f727 100644 --- a/src/core/pointcloud/qgspointcloudlayereditutils.h +++ b/src/core/pointcloud/qgspointcloudlayereditutils.h @@ -17,6 +17,7 @@ #define QGSPOINTCLOUDLAYEREDITUTILS_H #include "qgis_core.h" +#include "qgspointcloudindex.h" #include #include @@ -24,7 +25,6 @@ #define SIP_NO_FILE class QgsPointCloudLayer; -class QgsPointCloudEditingIndex; class QgsPointCloudNodeId; class QgsPointCloudAttribute; class QgsPointCloudAttributeCollection; @@ -63,7 +63,7 @@ class CORE_EXPORT QgsPointCloudLayerEditUtils static bool isAttributeValueValid( const QgsPointCloudAttribute &attribute, double value ); private: - QgsPointCloudEditingIndex *mIndex = nullptr; + QgsPointCloudIndex mIndex; }; #endif // QGSPOINTCLOUDLAYEREDITUTILS_H diff --git a/tests/src/core/testqgspointcloudediting.cpp b/tests/src/core/testqgspointcloudediting.cpp index 885ad5de2a24..c160c9951ace 100644 --- a/tests/src/core/testqgspointcloudediting.cpp +++ b/tests/src/core/testqgspointcloudediting.cpp @@ -72,25 +72,24 @@ void TestQgsPointCloudEditing::testQgsPointCloudEditingIndex() std::unique_ptr layer = std::make_unique( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QVERIFY( layer->isValid() ); - QgsCopcPointCloudIndex *i = dynamic_cast( layer->index() ); - QVERIFY( i ); - std::unique_ptr e = std::make_unique( layer.get() ); - QVERIFY( e ); - QVERIFY( e->isValid() ); - QCOMPARE( i->accessType(), e->accessType() ); - QCOMPARE( i->crs(), e->crs() ); - QCOMPARE( i->pointCount(), e->pointCount() ); - QCOMPARE( i->originalMetadata(), e->originalMetadata() ); - QCOMPARE( i->attributes().count(), e->attributes().count() ); - QCOMPARE( i->attributes().pointRecordSize(), e->attributes().pointRecordSize() ); - QCOMPARE( i->extent(), e->extent() ); - QCOMPARE( i->offset(), e->offset() ); - QCOMPARE( i->scale(), e->scale() ); - QCOMPARE( i->span(), e->span() ); - QCOMPARE( i->zMax(), e->zMax() ); - QCOMPARE( i->zMin(), e->zMin() ); - QCOMPARE( i->root(), e->root() ); - QCOMPARE( i->rootNodeBounds(), e->rootNodeBounds() ); + auto i = layer->index(); + QVERIFY( i.isValid() ); + QgsPointCloudEditingIndex e = QgsPointCloudEditingIndex( layer.get() ); + QVERIFY( e.isValid() ); + QCOMPARE( i.accessType(), e.accessType() ); + QCOMPARE( i.crs(), e.crs() ); + QCOMPARE( i.pointCount(), e.pointCount() ); + QCOMPARE( i.originalMetadata(), e.originalMetadata() ); + QCOMPARE( i.attributes().count(), e.attributes().count() ); + QCOMPARE( i.attributes().pointRecordSize(), e.attributes().pointRecordSize() ); + QCOMPARE( i.extent(), e.extent() ); + QCOMPARE( i.offset(), e.offset() ); + QCOMPARE( i.scale(), e.scale() ); + QCOMPARE( i.span(), e.span() ); + QCOMPARE( i.zMax(), e.zMax() ); + QCOMPARE( i.zMin(), e.zMin() ); + QCOMPARE( i.root(), e.root() ); + QCOMPARE( i.rootNodeBounds(), e.rootNodeBounds() ); } void TestQgsPointCloudEditing::testStartStopEditing() @@ -102,7 +101,7 @@ void TestQgsPointCloudEditing::testStartStopEditing() QVERIFY( !layer->isEditable() ); QVERIFY( !layer->isModified() ); - QVERIFY( dynamic_cast( layer->index() ) ); + QVERIFY( layer->index() ); QSignalSpy spyStart( layer.get(), &QgsMapLayer::editingStarted ); QSignalSpy spyStop( layer.get(), &QgsMapLayer::editingStopped ); QSignalSpy spyModify( layer.get(), &QgsMapLayer::layerModified ); @@ -112,7 +111,7 @@ void TestQgsPointCloudEditing::testStartStopEditing() QCOMPARE( spyStart.size(), 1 ); QCOMPARE( spyStop.size(), 0 ); QCOMPARE( spyModify.size(), 0 ); - QVERIFY( dynamic_cast( layer->index() ) ); + QVERIFY( dynamic_cast( layer->index().mIndex.get() ) ); // false if already editing QVERIFY( !layer->startEditing() ); @@ -129,7 +128,7 @@ void TestQgsPointCloudEditing::testStartStopEditing() QCOMPARE( spyStart.size(), 1 ); QCOMPARE( spyStop.size(), 1 ); QCOMPARE( spyModify.size(), 0 ); - QVERIFY( dynamic_cast( layer->index() ) ); + QVERIFY( dynamic_cast( layer->index().mIndex.get() ) ); // false if already stopped QVERIFY( !layer->rollBack() ); @@ -146,7 +145,7 @@ void TestQgsPointCloudEditing::testStartStopEditing() QCOMPARE( spyStart.size(), 2 ); QCOMPARE( spyStop.size(), 1 ); QCOMPARE( spyModify.size(), 0 ); - QVERIFY( dynamic_cast( layer->index() ) ); + QVERIFY( dynamic_cast( layer->index().mIndex.get() ) ); // commit and stop editing QVERIFY( layer->commitChanges() ); @@ -155,7 +154,7 @@ void TestQgsPointCloudEditing::testStartStopEditing() QCOMPARE( spyStart.size(), 2 ); QCOMPARE( spyStop.size(), 2 ); QCOMPARE( spyModify.size(), 0 ); - QVERIFY( dynamic_cast( layer->index() ) ); + QVERIFY( dynamic_cast( layer->index().mIndex.get() ) ); } void TestQgsPointCloudEditing::testModifyAttributeValue()