From 9f68016117dd9a2669c9fe0f9b5f6445acf0c6d4 Mon Sep 17 00:00:00 2001 From: Withalion Date: Fri, 17 Jan 2025 16:26:05 +0100 Subject: [PATCH] Fix review issues --- src/3d/qgspointcloudlayer3drenderer.cpp | 4 ++-- src/3d/qgsvirtualpointcloudentity_p.cpp | 19 +++++-------------- src/app/layers/qgsapplayerhandling.cpp | 2 +- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/3d/qgspointcloudlayer3drenderer.cpp b/src/3d/qgspointcloudlayer3drenderer.cpp index f73117d3063f..757d13c986b7 100644 --- a/src/3d/qgspointcloudlayer3drenderer.cpp +++ b/src/3d/qgspointcloudlayer3drenderer.cpp @@ -186,7 +186,7 @@ void QgsPointCloudLayer3DRenderer::writeXml( QDomElement &elem, const QgsReadWri elem.setAttribute( QStringLiteral( "max-screen-error" ), maximumScreenError() ); elem.setAttribute( QStringLiteral( "show-bounding-boxes" ), showBoundingBoxes() ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ); elem.setAttribute( QStringLiteral( "point-budget" ), mPointBudget ); - elem.setAttribute( QStringLiteral( "zoomOutBehavior" ), qgsEnumValueToKey( mZoomOutBehavior ) ); + elem.setAttribute( QStringLiteral( "zoom-out-behavior" ), qgsEnumValueToKey( mZoomOutBehavior ) ); QDomElement elemSymbol = doc.createElement( QStringLiteral( "symbol" ) ); if ( mSymbol ) @@ -207,7 +207,7 @@ void QgsPointCloudLayer3DRenderer::readXml( const QDomElement &elem, const QgsRe mShowBoundingBoxes = elem.attribute( QStringLiteral( "show-bounding-boxes" ), QStringLiteral( "0" ) ).toInt(); mMaximumScreenError = elem.attribute( QStringLiteral( "max-screen-error" ), QStringLiteral( "3.0" ) ).toDouble(); mPointBudget = elem.attribute( QStringLiteral( "point-budget" ), QStringLiteral( "5000000" ) ).toInt(); - mZoomOutBehavior = qgsEnumKeyToValue( elem.attribute( QStringLiteral( "zoomOutBehavior" ) ), Qgis::PointCloudZoomOutRenderBehavior::RenderExtents ); + mZoomOutBehavior = qgsEnumKeyToValue( elem.attribute( QStringLiteral( "zoom-out-behavior" ) ), Qgis::PointCloudZoomOutRenderBehavior::RenderExtents ); if ( symbolType == QLatin1String( "single-color" ) ) mSymbol.reset( new QgsSingleColorPointCloud3DSymbol ); diff --git a/src/3d/qgsvirtualpointcloudentity_p.cpp b/src/3d/qgsvirtualpointcloudentity_p.cpp index 914b83f7c13c..61f368771c06 100644 --- a/src/3d/qgsvirtualpointcloudentity_p.cpp +++ b/src/3d/qgsvirtualpointcloudentity_p.cpp @@ -151,20 +151,10 @@ void QgsVirtualPointCloudEntity::handleSceneUpdate( const SceneContext &sceneCon } updateBboxEntity(); - if ( provider()->overview() ) + const QgsPointCloudLayer3DRenderer *rendererBehavior = dynamic_cast( mLayer->renderer3D() ); + if ( provider()->overview() && rendererBehavior && ( rendererBehavior->zoomOutBehavior() == Qgis::PointCloudZoomOutRenderBehavior::RenderOverview || rendererBehavior->zoomOutBehavior() == Qgis::PointCloudZoomOutRenderBehavior::RenderOverviewAndExtents ) ) { - // reuse the same logic for showing bounding boxes as above - const QgsRectangle mapExtent = Qgs3DUtils::tryReprojectExtent2D( mMapSettings->extent(), mMapSettings->crs(), mLayer->crs(), mMapSettings->transformContext() ); - const QgsAABB overviewBBox = Qgs3DUtils::mapToWorldExtent( provider()->overview().extent().intersect( mapExtent ), provider()->overview().zMin(), provider()->overview().zMax(), mMapSettings->origin() ); - const float epsilon = std::min( overviewBBox.xExtent(), overviewBBox.yExtent() ) / 256; - const float distance = overviewBBox.distanceFromPoint( sceneContext.cameraPos ); - const float sse = Qgs3DUtils::screenSpaceError( epsilon, distance, sceneContext.screenSizePx, sceneContext.cameraFov ); - const bool displayAsBbox = sceneContext.cameraPos.isNull() || sse < .2; - const auto rendererBehavior = dynamic_cast( mLayer->renderer3D() )->zoomOutBehavior(); - if ( !displayAsBbox && ( rendererBehavior == Qgis::PointCloudZoomOutRenderBehavior::RenderOverview || rendererBehavior == Qgis::PointCloudZoomOutRenderBehavior::RenderOverviewAndExtents ) ) - { - mOverviewEntity->handleSceneUpdate( sceneContext ); - } + mOverviewEntity->handleSceneUpdate( sceneContext ); } } @@ -224,7 +214,8 @@ void QgsVirtualPointCloudEntity::updateBboxEntity() { QList bboxes; // we want to render bounding boxes only when zoomOutBehavior is RenderExtents or RenderOverviewAndExtents - if ( dynamic_cast( mLayer->renderer3D() )->zoomOutBehavior() != Qgis::PointCloudZoomOutRenderBehavior::RenderOverview ) + const QgsPointCloudLayer3DRenderer *renderer = dynamic_cast( mLayer->renderer3D() ); + if ( renderer && renderer->zoomOutBehavior() != Qgis::PointCloudZoomOutRenderBehavior::RenderOverview ) { const QVector subIndexes = provider()->subIndexes(); for ( int i = 0; i < subIndexes.size(); ++i ) diff --git a/src/app/layers/qgsapplayerhandling.cpp b/src/app/layers/qgsapplayerhandling.cpp index 138e7af5aa84..65c547a3fed7 100644 --- a/src/app/layers/qgsapplayerhandling.cpp +++ b/src/app/layers/qgsapplayerhandling.cpp @@ -200,7 +200,7 @@ void QgsAppLayerHandling::postProcessAddedLayer( QgsMapLayer *layer ) // if overview of the virtual point cloud exists set the zoom out behavior to show it if ( const QgsVirtualPointCloudProvider *vpcProvider = dynamic_cast( pcLayer->dataProvider() ) ) { - vpcProvider->overview() ? renderer3D->setZoomOutBehavior( Qgis::PointCloudZoomOutRenderBehavior::RenderOverview ) : renderer3D->setZoomOutBehavior( Qgis::PointCloudZoomOutRenderBehavior::RenderExtents ); + renderer3D->setZoomOutBehavior( vpcProvider->overview() ? Qgis::PointCloudZoomOutRenderBehavior::RenderOverview : Qgis::PointCloudZoomOutRenderBehavior::RenderExtents ); } layer->setRenderer3D( renderer3D.release() ); }