Skip to content

Commit

Permalink
Fix review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Withalion committed Jan 17, 2025
1 parent 72f6178 commit 9f68016
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/3d/qgspointcloudlayer3drenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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 );
Expand Down
19 changes: 5 additions & 14 deletions src/3d/qgsvirtualpointcloudentity_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,10 @@ void QgsVirtualPointCloudEntity::handleSceneUpdate( const SceneContext &sceneCon
}
updateBboxEntity();

if ( provider()->overview() )
const QgsPointCloudLayer3DRenderer *rendererBehavior = dynamic_cast<QgsPointCloudLayer3DRenderer *>( 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<QgsPointCloudLayer3DRenderer *>( mLayer->renderer3D() )->zoomOutBehavior();
if ( !displayAsBbox && ( rendererBehavior == Qgis::PointCloudZoomOutRenderBehavior::RenderOverview || rendererBehavior == Qgis::PointCloudZoomOutRenderBehavior::RenderOverviewAndExtents ) )
{
mOverviewEntity->handleSceneUpdate( sceneContext );
}
mOverviewEntity->handleSceneUpdate( sceneContext );
}
}

Expand Down Expand Up @@ -224,7 +214,8 @@ void QgsVirtualPointCloudEntity::updateBboxEntity()
{
QList<QgsAABB> bboxes;
// we want to render bounding boxes only when zoomOutBehavior is RenderExtents or RenderOverviewAndExtents
if ( dynamic_cast<QgsPointCloudLayer3DRenderer *>( mLayer->renderer3D() )->zoomOutBehavior() != Qgis::PointCloudZoomOutRenderBehavior::RenderOverview )
const QgsPointCloudLayer3DRenderer *renderer = dynamic_cast<QgsPointCloudLayer3DRenderer *>( mLayer->renderer3D() );
if ( renderer && renderer->zoomOutBehavior() != Qgis::PointCloudZoomOutRenderBehavior::RenderOverview )
{
const QVector<QgsPointCloudSubIndex> subIndexes = provider()->subIndexes();
for ( int i = 0; i < subIndexes.size(); ++i )
Expand Down
2 changes: 1 addition & 1 deletion src/app/layers/qgsapplayerhandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QgsVirtualPointCloudProvider *>( 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() );
}
Expand Down

0 comments on commit 9f68016

Please sign in to comment.