From 2a8cd537fa699f732876cca221556eafb3fa6bf4 Mon Sep 17 00:00:00 2001 From: Withalion Date: Tue, 7 Jan 2025 14:38:42 +0100 Subject: [PATCH] Fix issues introduced by PointCloudIndex refactor --- python/PyQt6/core/auto_additions/qgis.py | 30 +++++++++---------- python/PyQt6/core/auto_generated/qgis.sip.in | 12 ++++---- python/core/auto_additions/qgis.py | 30 +++++++++---------- python/core/auto_generated/qgis.sip.in | 12 ++++---- .../pointcloud/qgspointcloudlayerrenderer.cpp | 7 +++-- .../vpc/qgsvirtualpointcloudprovider.cpp | 8 ++--- .../vpc/qgsvirtualpointcloudprovider.h | 4 +-- 7 files changed, 52 insertions(+), 51 deletions(-) diff --git a/python/PyQt6/core/auto_additions/qgis.py b/python/PyQt6/core/auto_additions/qgis.py index 2cf2dee08ff2..6402003184f9 100644 --- a/python/PyQt6/core/auto_additions/qgis.py +++ b/python/PyQt6/core/auto_additions/qgis.py @@ -11116,21 +11116,6 @@ # -- Qgis.MeshRangeExtent.baseClass = Qgis # monkey patching scoped based enum -Qgis.PointCloudZoomOutRenderBehavior.RenderExtents.__doc__ = "Render only point cloud extents when zoomed out" -Qgis.PointCloudZoomOutRenderBehavior.RenderOverview.__doc__ = "Render overview point cloud when zoomed out" -Qgis.PointCloudZoomOutRenderBehavior.RenderOverviewAndExtents.__doc__ = "Render point cloud extents over overview point cloud" -Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options - -.. versionadded:: 3.42 - -* ``RenderExtents``: Render only point cloud extents when zoomed out -* ``RenderOverview``: Render overview point cloud when zoomed out -* ``RenderOverviewAndExtents``: Render point cloud extents over overview point cloud - -""" -# -- -Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis -# monkey patching scoped based enum Qgis.PointCloudAccessType.Local.__doc__ = "Local means the source is a local file on the machine" Qgis.PointCloudAccessType.Remote.__doc__ = "Remote means it's loaded through a protocol like HTTP" Qgis.PointCloudAccessType.__doc__ = """The access type of the data, local is for local files and remote for remote files (over HTTP). @@ -11145,6 +11130,21 @@ """ # -- Qgis.PointCloudAccessType.baseClass = Qgis +# monkey patching scoped based enum +Qgis.PointCloudZoomOutRenderBehavior.RenderExtents.__doc__ = "Render only point cloud extents when zoomed out" +Qgis.PointCloudZoomOutRenderBehavior.RenderOverview.__doc__ = "Render overview point cloud when zoomed out" +Qgis.PointCloudZoomOutRenderBehavior.RenderOverviewAndExtents.__doc__ = "Render point cloud extents over overview point cloud" +Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options + +.. versionadded:: 3.42 + +* ``RenderExtents``: Render only point cloud extents when zoomed out +* ``RenderOverview``: Render overview point cloud when zoomed out +* ``RenderOverviewAndExtents``: Render point cloud extents over overview point cloud + +""" +# -- +Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis try: Qgis.__attribute_docs__ = {'QGIS_DEV_VERSION': 'The development version', 'DEFAULT_SEARCH_RADIUS_MM': 'Identify search radius in mm', 'DEFAULT_MAPTOPIXEL_THRESHOLD': 'Default threshold between map coordinates and device coordinates for map2pixel simplification', 'DEFAULT_HIGHLIGHT_COLOR': 'Default highlight color. The transparency is expected to only be applied to polygon\nfill. Lines and outlines are rendered opaque.', 'DEFAULT_HIGHLIGHT_BUFFER_MM': 'Default highlight buffer in mm.', 'DEFAULT_HIGHLIGHT_MIN_WIDTH_MM': 'Default highlight line/stroke minimum width in mm.', 'SCALE_PRECISION': 'Fudge factor used to compare two scales. The code is often going from scale to scale\ndenominator. So it looses precision and, when a limit is inclusive, can lead to errors.\nTo avoid that, use this factor instead of using <= or >=.\n\n.. deprecated:: 3.40\n\n No longer used by QGIS and will be removed in QGIS 4.0.', 'DEFAULT_Z_COORDINATE': 'Default Z coordinate value.\nThis value have to be assigned to the Z coordinate for the vertex.', 'DEFAULT_M_COORDINATE': 'Default M coordinate value.\nThis value have to be assigned to the M coordinate for the vertex.\n\n.. versionadded:: 3.20', 'UI_SCALE_FACTOR': 'UI scaling factor. This should be applied to all widget sizes obtained from font metrics,\nto account for differences in the default font sizes across different platforms.', 'DEFAULT_SNAP_TOLERANCE': 'Default snapping distance tolerance.', 'DEFAULT_SNAP_UNITS': 'Default snapping distance units.'} Qgis.version = staticmethod(Qgis.version) diff --git a/python/PyQt6/core/auto_generated/qgis.sip.in b/python/PyQt6/core/auto_generated/qgis.sip.in index ff9c22715712..4d30981e6609 100644 --- a/python/PyQt6/core/auto_generated/qgis.sip.in +++ b/python/PyQt6/core/auto_generated/qgis.sip.in @@ -3249,6 +3249,12 @@ The development version UpdatedCanvas, }; + enum class PointCloudAccessType /BaseType=IntEnum/ + { + Local, + Remote + }; + enum class PointCloudZoomOutRenderBehavior /BaseType=IntEnum/ { RenderExtents, @@ -3256,12 +3262,6 @@ The development version RenderOverviewAndExtents }; - enum class PointCloudAccessType /BaseType=IntEnum/ - { - Local, - Remote - }; - static const double DEFAULT_SEARCH_RADIUS_MM; static const float DEFAULT_MAPTOPIXEL_THRESHOLD; diff --git a/python/core/auto_additions/qgis.py b/python/core/auto_additions/qgis.py index 38c77cf9fe50..0f9f1168ba09 100644 --- a/python/core/auto_additions/qgis.py +++ b/python/core/auto_additions/qgis.py @@ -11026,21 +11026,6 @@ # -- Qgis.MeshRangeExtent.baseClass = Qgis # monkey patching scoped based enum -Qgis.PointCloudZoomOutRenderBehavior.RenderExtents.__doc__ = "Render only point cloud extents when zoomed out" -Qgis.PointCloudZoomOutRenderBehavior.RenderOverview.__doc__ = "Render overview point cloud when zoomed out" -Qgis.PointCloudZoomOutRenderBehavior.RenderOverviewAndExtents.__doc__ = "Render point cloud extents over overview point cloud" -Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options - -.. versionadded:: 3.42 - -* ``RenderExtents``: Render only point cloud extents when zoomed out -* ``RenderOverview``: Render overview point cloud when zoomed out -* ``RenderOverviewAndExtents``: Render point cloud extents over overview point cloud - -""" -# -- -Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis -# monkey patching scoped based enum Qgis.PointCloudAccessType.Local.__doc__ = "Local means the source is a local file on the machine" Qgis.PointCloudAccessType.Remote.__doc__ = "Remote means it's loaded through a protocol like HTTP" Qgis.PointCloudAccessType.__doc__ = """The access type of the data, local is for local files and remote for remote files (over HTTP). @@ -11055,6 +11040,21 @@ """ # -- Qgis.PointCloudAccessType.baseClass = Qgis +# monkey patching scoped based enum +Qgis.PointCloudZoomOutRenderBehavior.RenderExtents.__doc__ = "Render only point cloud extents when zoomed out" +Qgis.PointCloudZoomOutRenderBehavior.RenderOverview.__doc__ = "Render overview point cloud when zoomed out" +Qgis.PointCloudZoomOutRenderBehavior.RenderOverviewAndExtents.__doc__ = "Render point cloud extents over overview point cloud" +Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options + +.. versionadded:: 3.42 + +* ``RenderExtents``: Render only point cloud extents when zoomed out +* ``RenderOverview``: Render overview point cloud when zoomed out +* ``RenderOverviewAndExtents``: Render point cloud extents over overview point cloud + +""" +# -- +Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis from enum import Enum diff --git a/python/core/auto_generated/qgis.sip.in b/python/core/auto_generated/qgis.sip.in index 8a16963ede80..a2b885ed6ddb 100644 --- a/python/core/auto_generated/qgis.sip.in +++ b/python/core/auto_generated/qgis.sip.in @@ -3249,6 +3249,12 @@ The development version UpdatedCanvas, }; + enum class PointCloudAccessType + { + Local, + Remote + }; + enum class PointCloudZoomOutRenderBehavior { RenderExtents, @@ -3256,12 +3262,6 @@ The development version RenderOverviewAndExtents }; - enum class PointCloudAccessType - { - Local, - Remote - }; - static const double DEFAULT_SEARCH_RADIUS_MM; static const float DEFAULT_MAPTOPIXEL_THRESHOLD; diff --git a/src/core/pointcloud/qgspointcloudlayerrenderer.cpp b/src/core/pointcloud/qgspointcloudlayerrenderer.cpp index bdfc7976e808..7194fe818487 100644 --- a/src/core/pointcloud/qgspointcloudlayerrenderer.cpp +++ b/src/core/pointcloud/qgspointcloudlayerrenderer.cpp @@ -209,11 +209,12 @@ bool QgsPointCloudLayerRenderer::render() } const bool zoomedOut = renderExtent.width() > vpcProvider->averageSubIndexWidth() || renderExtent.height() > vpcProvider->averageSubIndexHeight(); + QgsPointCloudIndex overviewIndex = vpcProvider->overview(); // if the overview of virtual point cloud exists, and we are zoomed out, we render just overview if ( vpcProvider->overview() && zoomedOut && mRenderer->zoomOutBehavior() == Qgis::PointCloudZoomOutRenderBehavior::RenderOverview ) { - renderIndex( vpcProvider->overview() ); + renderIndex( overviewIndex ); } else { @@ -222,7 +223,7 @@ bool QgsPointCloudLayerRenderer::render() if ( vpcProvider->overview() && zoomedOut && mRenderer->zoomOutBehavior() == Qgis::PointCloudZoomOutRenderBehavior::RenderOverviewAndExtents ) { - renderIndex( vpcProvider->overview() ); + renderIndex( overviewIndex ); } mSubIndexExtentRenderer->startRender( context ); for ( const QgsPointCloudSubIndex &si : visibleIndexes ) @@ -233,7 +234,7 @@ bool QgsPointCloudLayerRenderer::render() QgsPointCloudIndex pc = si.index(); // if the index of point cloud is invalid, or we are zoomed out and want extents, we render the point cloud extent if ( !pc || !pc.isValid() || ( ( mRenderer->zoomOutBehavior() == Qgis::PointCloudZoomOutRenderBehavior::RenderExtents || mRenderer->zoomOutBehavior() == Qgis::PointCloudZoomOutRenderBehavior::RenderOverviewAndExtents ) && - zoomedOut ) ) + zoomedOut ) ) { mSubIndexExtentRenderer->renderExtent( si.polygonBounds(), context ); if ( mSubIndexExtentRenderer->showLabels() ) diff --git a/src/core/providers/vpc/qgsvirtualpointcloudprovider.cpp b/src/core/providers/vpc/qgsvirtualpointcloudprovider.cpp index 9342c3c37ef5..5d9d2cc19c9f 100644 --- a/src/core/providers/vpc/qgsvirtualpointcloudprovider.cpp +++ b/src/core/providers/vpc/qgsvirtualpointcloudprovider.cpp @@ -213,8 +213,8 @@ void QgsVirtualPointCloudProvider::parseFile() // look for vpc overview reference if ( !mOverview && f["assets"].contains( "overview" ) && f["assets"]["overview"].contains( "href" ) ) { - mOverview = std::make_unique(); - mOverview->load( fInfo.absoluteDir().absoluteFilePath( QString::fromStdString( f["assets"]["overview"]["href"] ) ) ); + mOverview = QgsPointCloudIndex( new QgsCopcPointCloudIndex() ); + mOverview.load( fInfo.absoluteDir().absoluteFilePath( QString::fromStdString( f["assets"]["overview"]["href"] ) ) ); } // if it doesn't exist look for overview file in the directory else if ( !mOverview ) @@ -225,8 +225,8 @@ void QgsVirtualPointCloudProvider::parseFile() vpcDir.setFilter( QDir::Files ); if ( !vpcDir.entryList().empty() ) { - mOverview = std::make_unique(); - mOverview->load( vpcDir.absoluteFilePath( vpcDir.entryList().first() ) ); + mOverview = QgsPointCloudIndex( new QgsCopcPointCloudIndex() );; + mOverview.load( vpcDir.absoluteFilePath( vpcDir.entryList().first() ) ); } } diff --git a/src/core/providers/vpc/qgsvirtualpointcloudprovider.h b/src/core/providers/vpc/qgsvirtualpointcloudprovider.h index 27bf5736c751..c9a49bb674f0 100644 --- a/src/core/providers/vpc/qgsvirtualpointcloudprovider.h +++ b/src/core/providers/vpc/qgsvirtualpointcloudprovider.h @@ -65,7 +65,7 @@ class CORE_EXPORT QgsVirtualPointCloudProvider: public QgsPointCloudDataProvider * Returns pointer to the overview index. May be NULLPTR if it doesn't exist. * \since QGIS 3.42 */ - QgsPointCloudIndex *overview() const { return mOverview.get(); } + QgsPointCloudIndex overview() const { return mOverview; } /** * Returns the calculated average width of point clouds. @@ -90,7 +90,7 @@ class CORE_EXPORT QgsVirtualPointCloudProvider: public QgsPointCloudDataProvider QVector mSubLayers; std::unique_ptr mPolygonBounds; QgsPointCloudAttributeCollection mAttributes; - std::unique_ptr mOverview; + QgsPointCloudIndex mOverview = QgsPointCloudIndex( nullptr ); QStringList mUriList; QgsRectangle mExtent;