From db2aded6ff8130d0d244d1ad75cd1326667328cf Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Sun, 16 Jul 2023 08:46:01 +1000 Subject: [PATCH] Node experiment --- .../tiledmesh/qgstiledmeshdataprovider.sip.in | 55 +++++++++++++++++++ .../tiledmesh/qgstiledmeshdataprovider.cpp | 31 +++++++++++ src/core/tiledmesh/qgstiledmeshdataprovider.h | 51 +++++++++++++++++ 3 files changed, 137 insertions(+) diff --git a/python/core/auto_generated/tiledmesh/qgstiledmeshdataprovider.sip.in b/python/core/auto_generated/tiledmesh/qgstiledmeshdataprovider.sip.in index 27d3774bbbb4..34ab684794d2 100644 --- a/python/core/auto_generated/tiledmesh/qgstiledmeshdataprovider.sip.in +++ b/python/core/auto_generated/tiledmesh/qgstiledmeshdataprovider.sip.in @@ -9,6 +9,61 @@ + +class QgsTiledMeshNode +{ +%Docstring(signature="appended") +************************************************************************* + +This program is free software; you can redistribute it and/or modify * +it under the terms of the GNU General Public License as published by * +the Free Software Foundation; either version 2 of the License, or * +(at your option) any later version. * + +************************************************************************** +%End + +%TypeHeaderCode +#include "qgstiledmeshdataprovider.h" +%End + public: + + QgsTiledMeshNode(); +%Docstring +Constructor for an invalid node. +%End + + QgsTiledMeshNode( const QgsTiledMeshNode &other ); + + QgsTiledMeshNode( QgsTiledMeshNode *parent ); +%Docstring +Constructor for a valid node. +%End + + bool isValid() const; +%Docstring +Returns ``True`` if the node is valid. +%End + + bool operator==( QgsTiledMeshNode other ) const; + + QgsTiledMeshNode *parentNode() const; +%Docstring +Returns the parent of the node. +%End + + QList< QgsTiledMeshNode * > children() const; +%Docstring +Returns the child nodes. +%End + + const QgsAbstractTiledMeshNodeBoundingVolume *boundingVolume() const; +%Docstring +Returns the bounding volume for the node. +%End + +}; + class QgsTiledMeshDataProvider: QgsDataProvider { %Docstring(signature="appended") diff --git a/src/core/tiledmesh/qgstiledmeshdataprovider.cpp b/src/core/tiledmesh/qgstiledmeshdataprovider.cpp index 226164d7e0f9..58dcafb77820 100644 --- a/src/core/tiledmesh/qgstiledmeshdataprovider.cpp +++ b/src/core/tiledmesh/qgstiledmeshdataprovider.cpp @@ -17,6 +17,7 @@ #include "qgstiledmeshdataprovider.h" #include "qgsthreadingutils.h" +#include "qgstiledmeshboundingvolume.h" QgsTiledMeshDataProvider::QgsTiledMeshDataProvider( const QString &uri, @@ -47,3 +48,33 @@ QString QgsTiledMeshDataProvider::htmlMetadata() const return QString(); } + +QgsTiledMeshNode::QgsTiledMeshNode( const QgsTiledMeshNode &other ) + : mParent( other.mParent ) +{ + for ( const QgsTiledMeshNode *node : other.mChildren ) + { + // clone + } + mBoundingVolume.reset( other.mBoundingVolume ? other.mBoundingVolume->clone() : nullptr ); +} + +bool QgsTiledMeshNode::isValid() const +{ + +} + +const QgsAbstractTiledMeshNodeBoundingVolume *QgsTiledMeshNode::boundingVolume() const +{ + return mBoundingVolume.get(); +} + +QgsTiledMeshNode &QgsTiledMeshNode::operator=( const QgsTiledMeshNode &other ) +{ + mParent = other.mParent; + for ( const QgsTiledMeshNode *node : other.mChildren ) + { + // clone + } + mBoundingVolume.reset( other.mBoundingVolume ? other.mBoundingVolume->clone() : nullptr ); +} diff --git a/src/core/tiledmesh/qgstiledmeshdataprovider.h b/src/core/tiledmesh/qgstiledmeshdataprovider.h index 2d7b4e804a53..6517a716d14c 100644 --- a/src/core/tiledmesh/qgstiledmeshdataprovider.h +++ b/src/core/tiledmesh/qgstiledmeshdataprovider.h @@ -23,6 +23,57 @@ #include "qgsdataprovider.h" #include "qgis.h" +class QgsAbstractTiledMeshNodeBoundingVolume; + +class CORE_EXPORT QgsTiledMeshNode +{ + public: + + /** + * Constructor for an invalid node. + */ + QgsTiledMeshNode(); + + QgsTiledMeshNode( const QgsTiledMeshNode &other ); + QgsTiledMeshNode &operator=( const QgsTiledMeshNode &other ); + + /** + * Constructor for a valid node. + */ + QgsTiledMeshNode( QgsTiledMeshNode *parent ); + + /** + * Returns TRUE if the node is valid. + */ + bool isValid() const; + + bool operator==( QgsTiledMeshNode other ) const + { + return false; + } + + /** + * Returns the parent of the node. + */ + QgsTiledMeshNode *parentNode() const { return mParent; } + + /** + * Returns the child nodes. + */ + QList< QgsTiledMeshNode * > children() const { return mChildren; } + + /** + * Returns the bounding volume for the node. + */ + const QgsAbstractTiledMeshNodeBoundingVolume *boundingVolume() const; + + private: + QgsTiledMeshNode *mParent = nullptr; + QList< QgsTiledMeshNode * > mChildren; + std::unique_ptr< QgsAbstractTiledMeshNodeBoundingVolume > mBoundingVolume; + +}; + /** * \ingroup core * \brief Base class for data providers for QgsTiledMeshLayer