77#include <QOpenGLContext>
78#include <QOpenGLFunctions>
83#include <Qt3DExtras/QDiffuseSpecularMaterial>
84#include <Qt3DExtras/QForwardRenderer>
85#include <Qt3DExtras/QSphereMesh>
86#include <Qt3DLogic/QFrameAction>
87#include <Qt3DRender/QCamera>
88#include <Qt3DRender/QCullFace>
89#include <Qt3DRender/QDepthTest>
90#include <Qt3DRender/QEffect>
91#include <Qt3DRender/QMaterial>
92#include <Qt3DRender/QMesh>
93#include <Qt3DRender/QRenderPass>
94#include <Qt3DRender/QRenderSettings>
95#include <Qt3DRender/QRenderState>
96#include <Qt3DRender/QSceneLoader>
97#include <Qt3DRender/QTechnique>
101#include "tracy/Tracy.hpp"
104#include "moc_qgs3dmapscene.cpp"
106using namespace Qt::StringLiterals;
115 onBackgroundColorChanged();
120 mEngine->renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::OnDemand );
122 QRect viewportRect( QPoint( 0, 0 ), mEngine->size() );
128 float aspectRatio = ( float ) viewportRect.width() / viewportRect.height();
129 mEngine->camera()->lens()->setPerspectiveProjection(
static_cast< float >( mMap.fieldOfView() ), aspectRatio, 10.f, 10000.0f );
131 mFrameAction =
new Qt3DLogic::QFrameAction();
132 connect( mFrameAction, &Qt3DLogic::QFrameAction::triggered,
this, &Qgs3DMapScene::onFrameTriggered );
133 addComponent( mFrameAction );
139 mCameraController->resetGlobe( 10'000'000 );
141 mCameraController->resetView( 1000 );
143 addCameraViewCenterEntity( mEngine->camera() );
144 addCameraRotationCenterEntity( mCameraController );
149 createTerrainDeferred();
182 const QList<QgsMapLayer *> modelVectorLayers = mModelVectorLayers;
188 if ( renderer->
type() ==
"vector"_L1 )
191 if ( pointSymbol && pointSymbol->
shapeProperty( u
"model"_s ).toString() == url )
193 removeLayerEntity( layer );
194 addLayerEntity( layer );
197 else if ( renderer->
type() ==
"rulebased"_L1 )
203 if ( pointSymbol && pointSymbol->
shapeProperty( u
"model"_s ).toString() == url )
205 removeLayerEntity( layer );
206 addLayerEntity( layer );
225 onBackgroundSettingsChanged();
230 onEyeDomeShadingSettingsChanged();
232 onDebugDepthMapSettingsChanged();
234 onAmbientOcclusionSettingsChanged();
236 onMsaaEnabledChanged();
238 onBloomSettingsChanged();
240 onColorGradingSettingsChanged();
245 mOverlayUpdateTimer =
new QTimer(
this );
246 mOverlayUpdateTimer->setSingleShot(
true );
247 mOverlayUpdateTimer->setInterval( 250 );
248 connect( mOverlayUpdateTimer, &QTimer::timeout,
this, &Qgs3DMapScene::applyPendingOverlayUpdate );
251 onShowMapOverlayChanged();
253 onCameraMovementSpeedChanged();
255 on3DAxisSettingsChanged();
257 mDepthBufferRefreshTimer =
new QTimer(
this );
258 mDepthBufferRefreshTimer->setSingleShot(
true );
259 mDepthBufferRefreshTimer->setInterval( 100 );
267 mCameraController->resetGlobe( 10'000'000 );
273 const double side = std::max( extent.
width(), extent.
height() );
274 double d = side / 2 / std::tan(
cameraController()->camera()->fieldOfView() / 2 * M_PI / 180 );
276 mCameraController->resetView(
static_cast<float>( d ) );
287 const double xSide = std::abs( p1.
x() - p2.
x() );
288 const double ySide = std::abs( p1.
y() - p2.
y() );
289 const double side = std::max( xSide, ySide );
291 const double fov = qDegreesToRadians(
cameraController()->camera()->fieldOfView() );
292 double distance = side / 2.0f / std::tan( fov / 2.0f );
297 distance += zRange.
upper();
301 mCameraController->setViewFromTop(
302 static_cast<float>( center.
x() - origin.
x() ),
303 static_cast<float>( center.
y() - origin.
y() ),
304 static_cast<float>( distance )
311 Qt3DRender::QCamera *camera = mCameraController->camera();
312 QVector<QgsPointXY> extent;
314 const QSize size = mEngine->size();
316 const QPoint center( size.width() / 2, size.height() / 2 );
319 const float centerZ = centerWorldPos.z();
320 const QVector3D cameraPosition = camera->position();
322 QVector<int> pointsOrder = { 0, 1, 3, 2 };
323 for (
int i : pointsOrder )
325 const QPoint p( ( ( i >> 0 ) & 1 ) ? 0 : size.width(), ( ( i >> 1 ) & 1 ) ? 0 : size.height() );
328 const QVector3D rayDir = ( edgePoint - cameraPosition ).normalized();
331 if ( std::abs( rayDir.z() ) > 0 )
333 float t = ( centerZ - cameraPosition.z() ) / rayDir.z();
335 t = camera->farPlane();
337 t = std::min<float>( t, camera->farPlane() );
338 worldPos = cameraPosition + t * rayDir;
342 worldPos = cameraPosition + camera->farPlane() * rayDir;
343 worldPos.setZ( centerZ );
346 QgsVector3D mapPos = mMap.worldToMapCoordinates( worldPos );
347 extent.push_back(
QgsPointXY( mapPos.
x(), mapPos.
y() ) );
355 for ( Qgs3DMapSceneEntity *entity : std::as_const( mSceneEntities ) )
356 count += entity->pendingJobsCount();
362 Qt3DRender::QCamera *camera = mCameraController->camera();
363 const double fov = camera->fieldOfView();
364 const QSize size = mEngine->size();
365 const int screenSizePx = std::max( size.width(), size.height() );
369 const double frustumWidthAtDistance = 2 * distance * tan( fov / 2 );
370 const double err = frustumWidthAtDistance * epsilon / screenSizePx;
374void Qgs3DMapScene::onCameraChanged()
376 if ( mDepthBufferRefreshTimer )
377 mDepthBufferRefreshTimer->start();
380 updateCameraNearFarPlanes();
382 onShadowSettingsChanged();
386 schedule2DMapOverlayUpdate();
394 constexpr float ORIGIN_SHIFT_THRESHOLD = 10'000;
395 if ( mSceneOriginShiftEnabled && mEngine->
camera()->position().length() > ORIGIN_SHIFT_THRESHOLD )
403void Qgs3DMapScene::onViewed2DExtentFrom3DChanged()
405 const QSize size = mEngine->size();
406 const QPoint center( size.width() / 2, size.height() / 2 );
408 const double sampledDepth = mCameraController->sampleDepthBuffer( center.x(), center.y() );
410 if ( sampledDepth != 1.0 )
411 mLastCenterDepth = sampledDepth;
417bool Qgs3DMapScene::updateScene(
bool forceUpdate )
419 if ( !mSceneUpdatesEnabled )
425 QgsScopedEvent traceEvent( u
"3D"_s, forceUpdate ? u
"Force update scene"_s : u
"Update scene"_s );
427 Qgs3DMapSceneEntity::SceneContext sceneContext;
428 Qt3DRender::QCamera *camera = mEngine->camera();
429 sceneContext.cameraFov = camera->fieldOfView();
430 sceneContext.cameraPos = camera->position();
431 const QSize size = mEngine->size();
432 sceneContext.screenSizePx = std::max( size.width(), size.height() );
440 QMatrix4x4 projMatrix;
441 switch ( mMap.projectionType() )
445 float fovRadians = ( camera->fieldOfView() / 2.0f ) *
static_cast<float>( M_PI ) / 180.0f;
446 float fovCotan = std::cos( fovRadians ) / std::sin( fovRadians );
449 fovCotan / camera->aspectRatio(), 0, 0, 0,
459 Qt3DRender::QCameraLens *lens = camera->lens();
462 2.0f / ( lens->right() - lens->left() ), 0, 0, 0,
463 0, 2.0f / ( lens->top() - lens->bottom() ), 0, 0,
465 -( lens->left() + lens->right() ) / ( lens->right() - lens->left() ), -( lens->top() + lens->bottom() ) / ( lens->top() - lens->bottom() ), -1.0f, 1.0f
472 projMatrix = camera->projectionMatrix();
474 sceneContext.viewProjectionMatrix = projMatrix * camera->viewMatrix();
477 bool anyUpdated =
false;
478 for ( Qgs3DMapSceneEntity *entity : std::as_const( mSceneEntities ) )
480 if ( forceUpdate || ( entity->isEnabled() && entity->needsUpdate() ) )
483 entity->handleSceneUpdate( sceneContext );
484 if ( entity->hasReachedGpuMemoryLimit() )
494bool Qgs3DMapScene::updateCameraNearFarPlanes()
509 QMatrix4x4 viewMatrix = camera->viewMatrix();
515 for ( Qgs3DMapSceneEntity *se : std::as_const( mSceneEntities ) )
517 const QgsRange<float> depthRange = se->getNearFarPlaneRange( viewMatrix );
519 fnear = std::min( fnear, depthRange.
lower() );
520 ffar = std::max( ffar, depthRange.
upper() );
529 if ( fnear == 1e9 && ffar == 0 )
532 sceneZRange = sceneZRange.
isInfinite() ? QgsDoubleRange( 0.0, 0.0 ) : sceneZRange;
539 std::swap( fnear, ffar );
542 float newFar = ffar * 2;
543 float newNear = fnear / 2;
546 camera->setFarPlane( newFar );
547 camera->setNearPlane( newNear );
554void Qgs3DMapScene::onFrameTriggered(
float dt )
559 QgsEventTracing::addEventToQgisTrace( QgsEventTracing::EventType::Instant, u
"3D"_s, u
"Frame begins"_s );
561 mCameraController->frameTriggered( dt );
566 updateCameraNearFarPlanes();
569 static int frameCount = 0;
570 static float accumulatedTime = 0.0f;
580 accumulatedTime += dt;
581 if ( accumulatedTime >= 0.2f )
583 float fps = ( float ) frameCount / accumulatedTime;
585 accumulatedTime = 0.0f;
590void Qgs3DMapScene::update2DMapOverlay(
const QVector<QgsPointXY> &extent2DAsPoints )
592 QgsFrameGraph *frameGraph = mEngine->frameGraph();
595 if ( !mMap.is2DMapOverlayEnabled() )
597 if ( mMapOverlayEntity )
599 mMapOverlayEntity.reset();
601 overlayRenderView.
setEnabled( mMap.debugDepthMapEnabled() );
605 if ( !mMapOverlayEntity )
607 QgsWindow3DEngine *
engine = qobject_cast<QgsWindow3DEngine *>( mEngine );
609 mMapOverlayEntity->setEnabled(
true );
614 Qt3DRender::QCamera *camera = mEngine->camera();
615 const QgsVector3D extentCenter3D = mMap.worldToMapCoordinates( camera->position() );
616 const QgsPointXY extentCenter2D( extentCenter3D.
x(), extentCenter3D.
y() );
623 double minHalfExtent = std::numeric_limits<double>::max();
624 double maxHalfExtent = 0.0;
625 for (
const QgsPointXY &extentPoint : extent2DAsPoints )
627 const double distance = extentCenter2D.distance( extentPoint );
628 minHalfExtent = std::min( minHalfExtent, distance );
629 maxHalfExtent = std::max( maxHalfExtent, distance );
633 const double sceneHalfExtent = 0.6 * std::max( fullExtent.
width(), fullExtent.
height() );
635 minHalfExtent = std::min( 50., minHalfExtent );
636 maxHalfExtent = std::min( 100., maxHalfExtent );
637 const double smoothFactor = std::sin( mCameraController->pitch() / 90.0 * M_PI_2 );
640 const double adjustedHalfExtent = std::min( 3.0 * ( minHalfExtent + smoothFactor * maxHalfExtent ), sceneHalfExtent );
643 const bool showFrustum = mMap.viewFrustumVisualizationEnabled();
644 mMapOverlayEntity->update( overviewExtent, extent2DAsPoints, mCameraController->yaw(), showFrustum );
647void Qgs3DMapScene::createTerrain()
651 mSceneEntities.removeOne( mTerrain );
659 mSceneEntities.removeOne( mGlobe );
665 if ( !mTerrainUpdateScheduled )
668 QTimer::singleShot( 0,
this, &Qgs3DMapScene::createTerrainDeferred );
669 mTerrainUpdateScheduled =
true;
678void Qgs3DMapScene::createTerrainDeferred()
680 QgsChunkedEntity *terrainOrGlobe =
nullptr;
684 mGlobe =
new QgsGlobeEntity( &mMap );
685 terrainOrGlobe = mGlobe;
687 else if ( mMap.sceneMode() ==
Qgis::SceneMode::Local && mMap.terrainRenderingEnabled() && mMap.terrainGenerator() )
689 double tile0width = mMap.terrainGenerator()->rootChunkExtent().width();
690 int maxZoomLevel =
Qgs3DUtils::maxZoomLevel( tile0width, mMap.terrainSettings()->mapTileResolution(), mMap.terrainSettings()->maximumGroundError() );
691 const QgsBox3D rootBox3D = mMap.terrainGenerator()->rootChunkBox3D( mMap );
692 float rootError = mMap.terrainGenerator()->rootChunkError( mMap );
693 const QgsBox3D clippingBox3D( mMap.extent(), rootBox3D.
zMinimum(), rootBox3D.
zMaximum() );
694 mMap.terrainGenerator()->setupQuadtree( rootBox3D, rootError, maxZoomLevel, clippingBox3D );
696 mTerrain =
new QgsTerrainEntity( &mMap );
697 mTerrain->setObjectName( u
"Terrain"_s );
698 terrainOrGlobe = mTerrain;
701 if ( terrainOrGlobe )
704 QgsFrameGraph *frameGraph = mEngine->frameGraph();
708 terrainOrGlobe->setParent(
this );
711 mSceneEntities << terrainOrGlobe;
714 connect( terrainOrGlobe, &Qgs3DMapSceneEntity::newEntityCreated,
this, [
this]( Qt3DCore::QEntity *entity ) {
716 const QList<QgsGeoTransform *> transforms = entity->findChildren<QgsGeoTransform *>();
717 for ( QgsGeoTransform *transform : transforms )
719 transform->setOrigin( mMap.origin() );
723 handleClippingOnEntity( entity );
728 const QList<QgsMapLayer *>
layers = mMap.layers();
729 for ( QgsMapLayer *layer :
layers )
732 removeLayerEntity( layer );
735 addLayerEntity( layer );
740 mTerrainUpdateScheduled =
false;
743void Qgs3DMapScene::onBackgroundColorChanged()
745 mEngine->setClearColor( mMap.backgroundColor() );
748void Qgs3DMapScene::updateLights()
750 for ( Qt3DCore::QEntity *entity : std::as_const( mLightEntities ) )
751 entity->deleteLater();
752 mLightEntities.clear();
754 QgsFrameGraph *frameGraph = mEngine->frameGraph();
755 const QList<QgsLightSource *> newLights = mMap.lightSources();
756 for (
const QgsLightSource *source : newLights )
758 Qt3DCore::QEntity *entity = source->createEntity( mMap,
this );
760 mLightEntities.append( entity );
763 onShadowSettingsChanged();
766void Qgs3DMapScene::updateCameraLens()
768 mEngine->camera()->lens()->setFieldOfView(
static_cast< float >( mMap.fieldOfView() ) );
769 mEngine->camera()->lens()->setProjectionType(
static_cast<Qt3DRender::QCameraLens::ProjectionType
>( mMap.projectionType() ) );
773void Qgs3DMapScene::onLayerRenderer3DChanged()
775 QgsMapLayer *layer = qobject_cast<QgsMapLayer *>( sender() );
779 removeLayerEntity( layer );
782 addLayerEntity( layer );
785void Qgs3DMapScene::onLayersChanged()
787 QSet<QgsMapLayer *> layersBefore = qgis::listToSet( mLayerEntities.keys() );
788 QList<QgsMapLayer *> layersAdded;
789 const QList<QgsMapLayer *>
layers = mMap.layers();
790 for ( QgsMapLayer *layer :
layers )
792 if ( !layersBefore.contains( layer ) )
794 layersAdded << layer;
798 layersBefore.remove( layer );
803 for ( QgsMapLayer *layer : std::as_const( layersBefore ) )
805 removeLayerEntity( layer );
808 for ( QgsMapLayer *layer : std::as_const( layersAdded ) )
810 addLayerEntity( layer );
816 const QList<QgsMapLayer *>
layers = mLayerEntities.keys();
821 if ( temporalProperties->isActive() )
823 removeLayerEntity( layer );
824 addLayerEntity( layer );
832 Q_ASSERT( sceneNewEntity );
834 mSceneEntities.append( sceneNewEntity );
836 sceneNewEntity->setParent(
this );
838 finalizeNewEntity( sceneNewEntity );
840 connect( sceneNewEntity, &Qgs3DMapSceneEntity::newEntityCreated,
this, [
this]( Qt3DCore::QEntity *entity ) {
841 finalizeNewEntity( entity );
843 updateCameraNearFarPlanes();
853 Q_ASSERT( sceneEntity );
855 mSceneEntities.removeOne( sceneEntity );
857 sceneEntity->deleteLater();
861void Qgs3DMapScene::addLayerEntity(
QgsMapLayer *layer )
873 if ( renderer->
type() ==
"vector"_L1 )
881 mModelVectorLayers.append( layer );
885 else if ( renderer->
type() ==
"rulebased"_L1 )
888 for (
auto rule : rules )
890 const QgsPoint3DSymbol *pointSymbol =
dynamic_cast<const QgsPoint3DSymbol *
>( rule->symbol() );
893 mModelVectorLayers.append( layer );
898 else if ( renderer->
type() ==
"categorized"_L1 )
900 const Qgs3DCategoryList categories =
static_cast<QgsCategorized3DRenderer *
>( renderer )->categories();
901 for (
const Qgs3DRendererCategory &category : categories )
903 const QgsPoint3DSymbol *pointSymbol =
dynamic_cast<const QgsPoint3DSymbol *
>( category.symbol() );
906 mModelVectorLayers.append( layer );
914 QgsMeshLayer3DRenderer *meshRenderer =
static_cast<QgsMeshLayer3DRenderer *
>( renderer );
915 meshRenderer->
setLayer(
static_cast<QgsMeshLayer *
>( layer ) );
919 QgsMesh3DSymbol *sym = meshRenderer->
symbol()->
clone();
925 QgsPointCloudLayer3DRenderer *pointCloudRenderer =
static_cast<QgsPointCloudLayer3DRenderer *
>( renderer );
926 pointCloudRenderer->
setLayer(
static_cast<QgsPointCloudLayer *
>( layer ) );
930 QgsTiledSceneLayer3DRenderer *tiledSceneRenderer =
static_cast<QgsTiledSceneLayer3DRenderer *
>( renderer );
931 tiledSceneRenderer->
setLayer(
static_cast<QgsTiledSceneLayer *
>( layer ) );
935 auto annotationLayerRenderer = qgis::down_cast<QgsAnnotationLayer3DRenderer *>( renderer );
936 annotationLayerRenderer->setLayer( qobject_cast<QgsAnnotationLayer *>( layer ) );
939 Qt3DCore::QEntity *newEntity = renderer->
createEntity( &mMap );
943 newEntity->setObjectName( u
"%1 3D entity"_s.arg( layer->
name() ) );
945 mLayerEntities.insert( layer, newEntity );
947 if ( Qgs3DMapSceneEntity *sceneNewEntity = qobject_cast<Qgs3DMapSceneEntity *>( newEntity ) )
954 newEntity->setParent(
this );
955 finalizeNewEntity( newEntity );
964 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
977 QgsPointCloudLayer *pclayer = qobject_cast<QgsPointCloudLayer *>( layer );
983void Qgs3DMapScene::removeLayerEntity(
QgsMapLayer *layer )
985 Qt3DCore::QEntity *entity = mLayerEntities.take( layer );
987 if ( Qgs3DMapSceneEntity *sceneEntity = qobject_cast<Qgs3DMapSceneEntity *>( entity ) )
995 entity->deleteLater();
1002 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
1006 mModelVectorLayers.removeAll( layer );
1016 QgsPointCloudLayer *pclayer = qobject_cast<QgsPointCloudLayer *>( layer );
1023void Qgs3DMapScene::finalizeNewEntity( Qt3DCore::QEntity *newEntity )
1026 const QList<QgsGeoTransform *> transforms = newEntity->findChildren<QgsGeoTransform *>();
1027 for ( QgsGeoTransform *transform : transforms )
1029 transform->setOrigin( mMap.origin() );
1033 handleClippingOnEntity( newEntity );
1037 const QList<Qt3DRender::QMaterial *> childMaterials = newEntity->findChildren<Qt3DRender::QMaterial *>();
1041 for ( Qt3DRender::QMaterial *material : childMaterials )
1043 if (
auto lm = qobject_cast< QgsLineMaterial * >( material ) )
1046 lm->setViewportSize( mEngine->size() );
1048 else if (
auto bm = qobject_cast< QgsPoint3DBillboardMaterial * >( material ) )
1051 bm->setViewportSize( mEngine->size() );
1055 QgsFrameGraph *frameGraph = mEngine->frameGraph();
1059 const QVector<Qt3DRender::QLayer *>
layers = newEntity->componentsOfType<Qt3DRender::QLayer>();
1068 for ( Qt3DRender::QMaterial *material : childMaterials )
1072 auto materialEntity = qobject_cast<Qt3DCore::QEntity *>( material->parent() );
1073 if ( !materialEntity )
1076 bool materialCastsShadows =
false;
1077 if (
auto qgsMaterial = qobject_cast< QgsMaterial * >( material ) )
1079 if ( qgsMaterial->castsShadows() )
1081 materialCastsShadows =
true;
1087 materialCastsShadows =
true;
1090 if ( materialCastsShadows && !materialEntity->components().contains( shadowCastingEntityLayer ) )
1092 materialEntity->addComponent( shadowCastingEntityLayer );
1098 if (
auto ph = qobject_cast<Qt3DExtras::QDiffuseSpecularMaterial *>( material ) )
1100 if ( ph->diffuse().value<QColor>().alphaF() != 1.0f )
1102 if ( !materialEntity->components().contains( transparentLayer ) )
1104 materialEntity->addComponent( transparentLayer );
1125 else if (
auto billboardMaterial = qobject_cast<QgsPoint3DBillboardMaterial *>( material ) )
1127 Qt3DCore::QEntity *entity = qobject_cast<Qt3DCore::QEntity *>( billboardMaterial->parent() );
1128 if ( !materialEntity->components().contains( transparentLayer ) )
1130 materialEntity->addComponent( transparentLayer );
1137 if ( Qt3DRender::QEffect *effect = material->effect() )
1139 const QVector<Qt3DRender::QParameter *> parameters = effect->parameters();
1140 for (
const Qt3DRender::QParameter *parameter : parameters )
1142 if ( parameter->name() ==
"opacity" && parameter->value() != 1.0f )
1144 if ( !materialEntity->components().contains( transparentLayer ) )
1146 materialEntity->addComponent( transparentLayer );
1155 if ( childMaterials.empty() )
1158 newEntity->addComponent( shadowCastingEntityLayer );
1162int Qgs3DMapScene::maximumTextureSize()
const
1164 QSurface *surface = mEngine->surface();
1165 QOpenGLContext context;
1167 bool success = context.makeCurrent( surface );
1171 QOpenGLFunctions openglFunctions = QOpenGLFunctions( &context );
1174 openglFunctions.initializeOpenGLFunctions();
1175 openglFunctions.glGetIntegerv( GL_MAX_TEXTURE_SIZE, &size );
1184void Qgs3DMapScene::addCameraViewCenterEntity( Qt3DRender::QCamera *camera )
1186 mEntityCameraViewCenter =
new Qt3DCore::QEntity;
1188 Qt3DCore::QTransform *trCameraViewCenter =
new Qt3DCore::QTransform;
1189 mEntityCameraViewCenter->addComponent( trCameraViewCenter );
1190 connect( camera, &Qt3DRender::QCamera::viewCenterChanged,
this, [trCameraViewCenter, camera] { trCameraViewCenter->setTranslation( camera->viewCenter() ); } );
1192 auto materialCameraViewCenter =
new QgsUnlitMaterial();
1193 materialCameraViewCenter->setColor( Qt::red );
1194 materialCameraViewCenter->setCastsShadows(
false );
1195 mEntityCameraViewCenter->addComponent( materialCameraViewCenter );
1197 Qt3DExtras::QSphereMesh *rendererCameraViewCenter =
new Qt3DExtras::QSphereMesh;
1198 rendererCameraViewCenter->setRadius( 10 );
1199 mEntityCameraViewCenter->addComponent( rendererCameraViewCenter );
1202 mEntityCameraViewCenter->setParent(
this );
1204 QgsFrameGraph *frameGraph = mEngine->frameGraph();
1212 if ( mSceneState == state )
1214 mSceneState = state;
1218void Qgs3DMapScene::updateSceneState()
1220 if ( mTerrainUpdateScheduled )
1226 for ( Qgs3DMapSceneEntity *entity : std::as_const( mSceneEntities ) )
1228 if ( entity->isEnabled() && entity->pendingJobsCount() > 0 )
1235 setSceneState(
Ready );
1238void Qgs3DMapScene::onBackgroundSettingsChanged()
1240 if ( mBackgroundEntity )
1242 mBackgroundEntity->deleteLater();
1243 mBackgroundEntity =
nullptr;
1246 const QgsAbstract3DMapBackgroundSettings *settings = mMap.backgroundSettings();
1253 QgsFrameGraph *frameGraph = mEngine->frameGraph();
1257 const QgsSkyboxSettings *skyboxSettings =
dynamic_cast<const QgsSkyboxSettings *
>( settings );
1260 =
new QgsCubeFacesSkyboxEntity( skyboxSettings->
cubeMapping(), faces[u
"posX"_s], faces[u
"posY"_s], faces[u
"posZ"_s], faces[u
"negX"_s], faces[u
"negY"_s], faces[u
"negZ"_s], skyboxSettings->
environmentalLightingEnabled(),
this );
1261 qgis::down_cast< QgsSkyboxEntity * >( mBackgroundEntity )->updateEnvironmentLight( mEnvironmentLight );
1266 const QgsFixedGradientBackgroundSettings *gradientSettings =
dynamic_cast<const QgsFixedGradientBackgroundSettings *
>( settings );
1267 mBackgroundEntity =
new QgsGradientBackgroundEntity( gradientSettings->
topColor(), gradientSettings->
bottomColor(),
this );
1279void Qgs3DMapScene::onShadowSettingsChanged()
1284void Qgs3DMapScene::onAmbientOcclusionSettingsChanged()
1286 mEngine->frameGraph()->updateAmbientOcclusionSettings( mMap.ambientOcclusionSettings() );
1289void Qgs3DMapScene::onBloomSettingsChanged()
1291 mEngine->frameGraph()->updateBloomSettings( mMap.bloomSettings() );
1294void Qgs3DMapScene::onColorGradingSettingsChanged()
1296 mEngine->frameGraph()->updateColorGradingSettings( mMap.colorGradingSettings() );
1299void Qgs3DMapScene::onDebugDepthMapSettingsChanged()
1301 mEngine->frameGraph()->updateDebugDepthMapSettings( mMap );
1304void Qgs3DMapScene::onDebugOverlayEnabledChanged()
1306 mEngine->frameGraph()->setDebugOverlayEnabled( mMap.isDebugOverlayEnabled() );
1307 mEngine->renderSettings()->setRenderPolicy( mMap.isDebugOverlayEnabled() ? Qt3DRender::QRenderSettings::Always : Qt3DRender::QRenderSettings::OnDemand );
1310void Qgs3DMapScene::onEyeDomeShadingSettingsChanged()
1312 mEngine->frameGraph()->updateEyeDomeSettings( mMap );
1315void Qgs3DMapScene::onMsaaEnabledChanged()
1317 mEngine->frameGraph()->setMsaaEnabled( mMap.isMsaaEnabled() );
1320void Qgs3DMapScene::onShowMapOverlayChanged()
1323 update2DMapOverlay( extent2D );
1326void Qgs3DMapScene::onCameraMovementSpeedChanged()
1328 mCameraController->setCameraMovementSpeed( mMap.cameraMovementSpeed() );
1331void Qgs3DMapScene::onCameraNavigationModeChanged()
1333 mCameraController->setCameraNavigationMode( mMap.cameraNavigationMode() );
1338 QVector<QString> notParsedLayers;
1349 for (
auto it = mLayerEntities.constBegin(); it != mLayerEntities.constEnd(); ++it )
1352 Qt3DCore::QEntity *rootEntity = it.value();
1354 switch ( layerType )
1358 notParsedLayers.push_back( layer->
name() );
1368 notParsedLayers.push_back( layer->
name() );
1382 if ( !notParsedLayers.empty() )
1384 QString message = tr(
"The following layers were not exported:" ) +
"\n";
1385 for (
const QString &layerName : notParsedLayers )
1386 message += layerName +
"\n";
1395 QVector<const QgsChunkNode *> chunks;
1396 if ( !mLayerEntities.contains( layer ) )
1398 if ( QgsChunkedEntity *
c = qobject_cast<QgsChunkedEntity *>( mLayerEntities[layer] ) )
1400 const QList<QgsChunkNode *> activeNodes =
c->activeNodes();
1401 for ( QgsChunkNode *n : activeNodes )
1402 chunks.push_back( n );
1409 return mMap.extent();
1414 double zMin = std::numeric_limits<double>::max();
1415 double zMax = std::numeric_limits<double>::lowest();
1416 if ( mMap.terrainRenderingEnabled() && mTerrain && !ignoreTerrain )
1418 const QgsBox3D box3D = mTerrain->rootNode()->box3D();
1419 zMin = std::min( zMin, box3D.
zMinimum() );
1420 zMax = std::max( zMax, box3D.
zMaximum() );
1423 for (
auto it = mLayerEntities.constBegin(); it != mLayerEntities.constEnd(); it++ )
1426 switch ( layer->
type() )
1432 zMin = std::min( zMin, zRange.
lower() );
1433 zMax = std::max( zMax, zRange.
upper() );
1438 QgsMeshLayer *meshLayer = qobject_cast<QgsMeshLayer *>( layer );
1446 zMin = std::min( zMin, verticalGroupMetadata.
minimum() * verticalScale );
1447 zMax = std::max( zMax, verticalGroupMetadata.
maximum() * verticalScale );
1457 zMin = std::min( zMin, zRange.
lower() );
1458 zMax = std::max( zMax, zRange.
upper() );
1471 const QgsDoubleRange zRange( std::min( zMin, std::numeric_limits<double>::max() ), std::max( zMax, std::numeric_limits<double>::lowest() ) );
1482 mEntityRotationCenter =
new Qt3DCore::QEntity;
1484 Qt3DCore::QTransform *trRotationCenter =
new Qt3DCore::QTransform;
1485 mEntityRotationCenter->addComponent( trRotationCenter );
1487 auto materialRotationCenter =
new QgsUnlitMaterial();
1488 materialRotationCenter->setColor( Qt::blue );
1489 materialRotationCenter->setCastsShadows(
false );
1491 mEntityRotationCenter->addComponent( materialRotationCenter );
1492 Qt3DExtras::QSphereMesh *rendererRotationCenter =
new Qt3DExtras::QSphereMesh;
1493 rendererRotationCenter->setRadius( 10 );
1494 mEntityRotationCenter->addComponent( rendererRotationCenter );
1495 mEntityRotationCenter->setEnabled(
false );
1496 mEntityRotationCenter->setParent(
this );
1508void Qgs3DMapScene::on3DAxisSettingsChanged()
1512 m3DAxis->onAxisSettingsChanged();
1516 if ( QgsWindow3DEngine *
engine =
dynamic_cast<QgsWindow3DEngine *
>( mEngine ) )
1518 m3DAxis =
new Qgs3DAxis(
static_cast<Qgs3DMapCanvas *
>(
engine->window() ),
engine->root(),
this, mCameraController, &mMap );
1523void Qgs3DMapScene::onOriginChanged()
1525 const QList<QgsGeoTransform *> geoTransforms = findChildren<QgsGeoTransform *>();
1526 for ( QgsGeoTransform *transform : geoTransforms )
1528 transform->setOrigin( mMap.origin() );
1531 Qt3DCore::QEntity *parentEntity = mEngine->frameGraph()->rubberBandRenderView().rubberBandEntity();
1532 const QList<QgsGeoTransform *> rubberBandGeoTransforms = parentEntity->findChildren<QgsGeoTransform *>();
1533 for ( QgsGeoTransform *transform : rubberBandGeoTransforms )
1535 transform->setOrigin( mMap.origin() );
1538 const QgsVector3D oldOrigin = mCameraController->origin();
1539 mCameraController->setOrigin( mMap.origin() );
1541 if ( !mClipPlanesEquations.isEmpty() )
1550 QList<QVector4D> newPlanes;
1551 QgsVector3D originShift = mMap.origin() - oldOrigin;
1552 for ( QVector4D plane : std::as_const( mClipPlanesEquations ) )
1554 plane.setW( originShift.
x() * plane.x() + originShift.
y() * plane.y() + originShift.
z() * plane.z() + plane.w() );
1555 newPlanes.append( plane );
1561void Qgs3DMapScene::handleClippingOnEntity( QEntity *entity )
const
1563 if ( mClipPlanesEquations.isEmpty() )
1565 for ( QgsMaterial *material : entity->componentsOfType<QgsMaterial>() )
1567 material->disableClipping();
1572 for ( QgsMaterial *material : entity->componentsOfType<QgsMaterial>() )
1574 material->enableClipping( mClipPlanesEquations );
1580 for ( QObject *child : entity->children() )
1582 Qt3DCore::QEntity *childEntity = qobject_cast<Qt3DCore::QEntity *>( child );
1585 handleClippingOnEntity( childEntity );
1590void Qgs3DMapScene::handleClippingOnAllEntities()
const
1594 for (
auto it = mLayerEntities.constBegin(); it != mLayerEntities.constEnd(); ++it )
1596 handleClippingOnEntity( it.value() );
1600 handleClippingOnEntity( mTerrain );
1604 handleClippingOnEntity( mGlobe );
1612 QgsDebugMsgLevel( u
"Qgs3DMapScene::enableClipping: it is not possible to use more than %1 clipping planes."_s.arg( mMaxClipPlanes ), 2 );
1620 handleClippingOnAllEntities();
1625 mClipPlanesEquations.clear();
1628 mEngine->frameGraph()->removeClipPlanes();
1631 handleClippingOnAllEntities();
1634void Qgs3DMapScene::onStopUpdatesChanged()
1639void Qgs3DMapScene::schedule2DMapOverlayUpdate()
1642 if ( mMap.is2DMapOverlayEnabled() && mOverlayUpdateTimer && !mOverlayUpdateTimer->isActive() )
1644 mOverlayUpdateTimer->start();
1648void Qgs3DMapScene::applyPendingOverlayUpdate()
1650 if ( mMap.is2DMapOverlayEnabled() )
1653 update2DMapOverlay( extent2D );
@ DistinctTextureSkybox
Skybox with 6 distinct textures for different faces.
@ FixedGradientBackground
Two color gradient, fixed in place.
@ ShowCameraViewCenter
Shows the camera's view center as a sphere.
@ ShowFPS
Shows the frames per second (FPS).
@ ShowCameraRotationCenter
Shows the camera's rotation center as a sphere.
@ ShowTerrainBoundingBoxes
Displays bounding boxes of terrain tiles.
LayerType
Types of layers that can be added to a map.
@ Group
Composite group layer. Added in QGIS 3.24.
@ Plugin
Plugin based layer.
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
@ Mesh
Mesh layer. Added in QGIS 3.2.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
@ Orthographic
Orthogonal projection.
@ Perspective
Perspective projection.
@ Globe
Scene is represented as a globe using a geocentric CRS.
@ Local
Local scene based on a projected CRS.
Manages the various settings the user can choose from when exporting a 3D scene.
bool exportNormals() const
Returns whether normals will be exported.
int terrrainResolution() const
Returns the terrain resolution.
QString sceneFolderPath() const
Returns the scene folder path.
float scale() const
Returns the scale of the exported model.
int terrainTextureResolution() const
Returns the terrain texture resolution.
bool terrainExportEnabled() const
Returns whether terrain export is enabled.
QString sceneName() const
Returns the scene name.
bool smoothEdges() const
Returns whether triangles edges will look smooth.
bool exportTextures() const
Returns whether textures will be exported.
Qgis::Export3DSceneFormat exportFormat() const
Returns the export format for the 3D scene.
void viewed2DExtentFrom3DChanged(QVector< QgsPointXY > extent)
Emitted when the viewed 2D extent seen by the 3D camera has changed.
QList< QVector4D > clipPlaneEquations() const
Returns list of clipping planes if clipping is enabled, otherwise an empty list.
static std::function< QMap< QString, Qgs3DMapScene * >()> sOpenScenesFunction
Static function for returning open 3D map scenes.
void fpsCountChanged(float fpsCount)
Emitted when the FPS count changes.
void setViewFrom2DExtent(const QgsRectangle &extent)
Resets camera view to show the extent extent (top view).
void disableClipping()
Disables OpenGL clipping.
QVector< const QgsChunkNode * > getLayerActiveChunkNodes(QgsMapLayer *layer) SIP_SKIP
Returns the active chunk nodes of layer.
void gpuMemoryLimitReached()
Emitted when one of the entities reaches its GPU memory limit and it is not possible to lower the GPU...
static Q_DECL_DEPRECATED QMap< QString, Qgs3DMapScene * > openScenes() SIP_DEPRECATED
Returns a map of 3D map scenes (by name) open in the QGIS application.
QgsCameraController * cameraController() const
Returns camera controller.
SceneState
Enumeration of possible states of the 3D scene.
@ Ready
The scene is fully loaded/updated.
@ Updating
The scene is still being loaded/updated.
bool exportScene(const Qgs3DMapExportSettings &exportSettings)
Exports the scene according to the scene export settings Returns false if the operation failed.
int totalPendingJobsCount() const
Returns number of pending jobs for all chunked entities.
QList< QgsMapLayer * > layers() const SIP_SKIP
Returns the layers that contain chunked entities.
void addSceneEntity(Qgs3DMapSceneEntity *entity) SIP_SKIP
Adds a 3D map scene entity to the scene.
void updateTemporal()
Updates the temporale entities.
void totalPendingJobsCountChanged()
Emitted when the total number of pending jobs changes.
Qgs3DMapScene(Qgs3DMapSettings &map, QgsAbstract3DEngine *engine) SIP_SKIP
Constructs a 3D scene based on map settings and Qt 3D renderer configuration.
void fpsCounterEnabledChanged(bool fpsCounterEnabled)
Emitted when the FPS counter is activated or deactivated.
void removeSceneEntity(Qgs3DMapSceneEntity *entity) SIP_SKIP
Removes a 3D scene entity for the scene.
QgsDoubleRange elevationRange(bool ignoreTerrain=false) const
Returns the scene's elevation range.
QgsRectangle sceneExtent() const
Returns the scene extent in the map's CRS.
void sceneStateChanged()
Emitted when the scene's state has changed.
QgsAbstract3DEngine * engine() const SIP_SKIP
Returns the abstract 3D engine.
QVector< QgsPointXY > viewFrustum2DExtent() const
Calculates the 2D extent viewed by the 3D camera as the vertices of the viewed trapezoid.
void enableClipping(const QList< QVector4D > &clipPlaneEquations)
Enables OpenGL clipping based on the planes equations defined in clipPlaneEquations.
void terrainEntityChanged()
Emitted when the current terrain entity is replaced by a new one.
void viewZoomFull()
Resets camera view to show the whole scene (top view).
double worldSpaceError(double epsilon, double distance) const
Given screen error (in pixels) and distance from camera (in 3D world coordinates),...
void extentChanged()
Emitted when the 3d view's 2d extent has changed.
void originChanged()
Emitted when the world's origin point has been shifted.
void eyeDomeLightingDistanceChanged()
Emitted when the eye dome lighting distance has changed.
void terrainShadingChanged()
Emitted when terrain shading enabled flag or terrain shading material has changed.
void bloomSettingsChanged()
Emitted when the bloom lighting effect settings are changed.
void debugDepthMapSettingsChanged()
Emitted when depth map debugging has changed.
void backgroundSettingsChanged()
Emitted when background settings are changed.
void backgroundColorChanged()
Emitted when the background color has changed.
void showCameraRotationCenterChanged()
Emitted when the flag whether camera's rotation center is shown has changed.
void cameraNavigationModeChanged()
Emitted when the camera navigation mode was changed.
void shadowSettingsChanged()
Emitted when shadow rendering settings are changed.
void show2DMapOverlayChanged()
Emitted when the 2D map overlay is enabled or disabled.
bool stopUpdates() const
Returns whether the scene updates on camera movement.
void eyeDomeLightingEnabledChanged()
Emitted when the flag whether eye dome lighting is used has changed.
void debugOverlayEnabledChanged(bool debugOverlayEnabled)
Emitted when the debug overaly is enabled or disabled.
void setOrigin(const QgsVector3D &origin)
Sets coordinates in map CRS at which our 3D world has origin (0,0,0).
void msaaEnabledChanged()
Emitted when the MSAA enabled flag has changed.
void projectionTypeChanged()
Emitted when the camera lens projection type changes.
void stopUpdatesChanged()
Emitted when the flag whether to keep updating scene has changed.
void lightSourcesChanged()
Emitted when any of the light source settings in the map changes.
void showLightSourceOriginsChanged()
Emitted when the flag whether light source origins are shown has changed.
void terrainSettingsChanged()
Emitted when the terrain settings are changed.
void colorGradingSettingsChanged()
Emitted when the color grading settings are changed.
void fpsCounterEnabledChanged(bool fpsCounterEnabled)
Emitted when the FPS counter is enabled or disabled.
void axisSettingsChanged()
Emitted when 3d axis rendering settings are changed.
void viewFrustumVisualizationEnabledChanged()
Emitted when the camera's view frustum visualization on the main 2D map canvas is enabled or disabled...
void ambientOcclusionSettingsChanged()
Emitted when ambient occlusion rendering settings are changed.
void layersChanged()
Emitted when the list of map layers for 3d rendering has changed.
void eyeDomeLightingStrengthChanged()
Emitted when the eye dome lighting strength has changed.
void cameraMovementSpeedChanged()
Emitted when the camera movement speed was changed.
void fieldOfViewChanged()
Emitted when the camera lens field of view changes.
void terrainGeneratorChanged()
Emitted when the terrain generator has changed.
void showCameraViewCenterChanged()
Emitted when the flag whether camera's view center is shown has changed.
QgsVector3D origin() const
Returns coordinates in map CRS at which 3D scene has origin (0,0,0).
Entity that handles the exporting of 3D scenes.
void setExportTextures(bool exportTextures)
Sets whether the textures will be exported.
void parseTerrain(QgsTerrainEntity *terrain, const QString &layer)
Creates terrain export objects from the terrain entity.
void setTerrainResolution(int resolution)
Sets the terrain resolution.
void setTerrainTextureResolution(int resolution)
Sets the terrain texture resolution.
bool parseVectorLayerEntity(Qt3DCore::QEntity *entity, QgsVectorLayer *layer)
Creates necessary export objects from entity if it represents valid vector layer entity Returns false...
void setScale(float scale)
Sets the scale of the exported 3D model.
bool save(QString sceneName, QString sceneFolderPath, const Qgis::Export3DSceneFormat &exportFormat=Qgis::Export3DSceneFormat::Obj, int precision=6) const
Saves the scene to a file Returns false if the operation failed.
void setExportNormals(bool exportNormals)
Sets whether the normals will be exported.
void setSmoothEdges(bool smoothEdges)
Sets whether the triangles will look smooth.
void setTerrainExportEnabled(bool enabled)
Sets whether terrain export is enabled.
static int maxZoomLevel(double tile0width, double tileResolution, double maxError)
Calculates the highest needed zoom level for tiles in quad-tree given width of the base tile (zoom le...
static QgsAABB mapToWorldExtent(const QgsRectangle &extent, double zMin, double zMax, const QgsVector3D &mapOrigin)
Converts map extent to axis aligned bounding box in 3D world coordinates.
static void computeBoundingBoxNearFarPlanes(const QgsAABB &bbox, const QMatrix4x4 &viewMatrix, float &fnear, float &ffar)
This routine computes nearPlane farPlane from the closest and farthest corners point of bounding box ...
static QVector3D screenPointToWorldPos(const QPoint &screenPoint, double depth, const QSize &screenSize, Qt3DRender::QCamera *camera)
Converts the clicked mouse position to the corresponding 3D world coordinates.
static int openGlMaxClipPlanes(QSurface *surface)
Gets the maximum number of clip planes that can be used.
Base class for 3D engine implementation.
void sizeChanged()
Emitted after a call to setSize().
virtual Qt3DRender::QCamera * camera()=0
Returns pointer to the engine's camera entity.
QgsFrameGraph * frameGraph()
Returns the shadow rendering frame graph object used to render the scene.
virtual Qgis::Map3DBackgroundType type() const =0
Returns the unique type for this background settings class.
Base class for all renderers that participate in 3D views.
virtual QString type() const =0
Returns unique identifier of the renderer class (used to identify subclass).
virtual Qt3DCore::QEntity * createEntity(Qgs3DMapSettings *map) const =0
Returns a 3D entity that will be used to show renderer's data in 3D scene.
virtual void setEnabled(bool enable)
Enable or disable via enable the render view sub tree.
Base class for 3D renderers that are based on vector layers.
static QgsSourceCache * sourceCache()
Returns the application's source cache, used for caching embedded and remote source strings as local ...
A 3-dimensional box composed of x, y, z coordinates.
double zMaximum() const
Returns the maximum z value.
double zMinimum() const
Returns the minimum z value.
Object that controls camera movement based on user input.
Qt3DRender::QCamera * camera() const
Returns camera that is being controlled.
void requestDepthBufferCapture()
Emitted to ask for the depth buffer image.
void cameraChanged()
Emitted when camera has been updated.
void depthBufferReady()
Emitted after the depth buffer has been captured and is ready to sample.
void cameraRotationCenterChanged(QVector3D position)
Emitted when the camera rotation center changes.
QgsRange which stores a range of double values.
bool isInfinite() const
Returns true if the range consists of all possible values.
An environment light entity.
@ Disabled
No environment lighting.
QColor topColor() const
Returns the color at the top of the gradient.
QColor bottomColor() const
Returns the color at the bottom of the gradient.
Qt3DRender::QLayer * renderLayer()
Returns a layer object used to indicate that the object is transparent.
Qt3DRender::QLayer * transparentObjectLayer()
Returns a layer object used to indicate that the object is transparent.
Qt3DRender::QLayer * backgroundLayer()
Returns a layer object used for skybox and background gradient entities.
Container class that holds different objects related to frame graphs of 3D scenes.
void updateShadowSettings(const Qgs3DMapSettings &mapSettings)
Updates shadow bias, light and texture size according to shadowSettings and lightSources.
QgsHighlightsRenderView & highlightsRenderView()
Returns the highlights renderview, used for rendering highlight overlays of identified features.
QgsForwardRenderView & forwardRenderView()
Returns forward renderview.
QgsOverlayTextureRenderView & overlayTextureRenderView()
Returns overlay texture renderview.
QgsShadowRenderView & shadowRenderView()
Returns shadow renderview.
Qt3DRender::QLayer * highlightsLayer()
Returns a layer that should be attached to entities meant to be rendered by QgsHighlightsRenderView.
virtual QgsDoubleRange calculateZRange(QgsMapLayer *layer) const
Attempts to calculate the overall elevation or z range for the specified layer, using the settings de...
Base class for storage of map layer temporal properties.
Base class for all map layer types.
QgsAbstract3DRenderer * renderer3D() const
Returns 3D renderer associated with the layer.
void request3DUpdate()
Signal emitted when a layer requires an update in any 3D maps.
void renderer3DChanged()
Signal emitted when 3D renderer associated with the layer has changed.
void rendererChanged()
Signal emitted when renderer is changed.
virtual QgsMapLayerTemporalProperties * temporalProperties()
Returns the layer's temporal properties.
void layerModified()
Emitted when modifications has been done on layer.
double verticalScale() const
Returns mesh vertical scale.
int verticalDatasetGroupIndex() const
Returns the index of the dataset group that will be used to render the vertical component of the 3D m...
void setMaximumTextureSize(int maximumTextureSize)
Sets the maximum texture size supported by the hardware Used to store the GL_MAX_TEXTURE_SIZE value t...
QgsMesh3DSymbol * clone() const override SIP_FACTORY
Returns a new instance of the symbol with the same settings.
3D renderer that renders all mesh triangles of a mesh layer.
void setSymbol(QgsMesh3DSymbol *symbol)
Sets 3D symbol associated with the renderer.
const QgsMesh3DSymbol * symbol() const
Returns 3D symbol associated with the renderer.
void setLayer(QgsMeshLayer *layer)
Sets vector layer associated with the renderer.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
QgsMeshDatasetGroupMetadata datasetGroupMetadata(const QgsMeshDatasetIndex &index) const
Returns the dataset groups metadata.
virtual void showMessage(bool blocking=true)=0
display the message to the user and deletes itself
3D symbol that draws point geometries as 3D objects using one of the predefined shapes.
Qgis::Point3DShape shape() const
Returns 3D shape for points.
QVariant shapeProperty(const QString &property) const
Returns the value for a specific shape property.
void setLayer(QgsPointCloudLayer *layer)
Sets point cloud layer associated with the renderer.
Represents a map layer supporting display of point clouds.
QgsMapLayerElevationProperties * elevationProperties() override
Returns the layer's elevation properties.
void subsetStringChanged()
Emitted when the layer's subset string has changed.
T lower() const
Returns the lower bound of the range.
T upper() const
Returns the upper bound of the range.
bool isEmpty() const
Returns true if the range is empty, ie the lower bound equals (or exceeds) the upper bound and either...
A rectangle specified with double values.
static QgsRectangle fromCenterAndSize(const QgsPointXY ¢er, double width, double height)
Creates a new rectangle, given the specified center point and width and height.
A child rule for a QgsRuleBased3DRenderer.
QList< QgsRuleBased3DRenderer::Rule * > RuleList
Qt3DRender::QLayer * entityCastingShadowsLayer() const
Returns the layer to be used by entities to be included in this renderview.
bool environmentalLightingEnabled() const
Returns true if the skybox should generate environmental lighting effects.
QMap< QString, QString > cubeMapFacesPaths() const
Returns a map containing the path of each texture specified by the user.
double environmentalLightStrength() const
Returns the environmental light strength, as a factor between 0 and 1.
Qgis::SkyboxCubeMapping cubeMapping() const
Returns the cube face mapping scheme.
void remoteSourceFetched(const QString &url)
Emitted when the cache has finished retrieving a 3D model from a remote url.
void setLayer(QgsTiledSceneLayer *layer)
Sets tiled scene layer associated with the renderer.
Represents a map layer supporting display of tiled scene objects.
QgsMapLayerElevationProperties * elevationProperties() override
Returns the layer's elevation properties.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
double y() const
Returns Y coordinate.
double z() const
Returns Z coordinate.
QString toString(int precision=17) const
Returns a string representation of the 3D vector.
double x() const
Returns X coordinate.
3D renderer that renders all features of a vector layer with the same 3D symbol.
const QgsAbstract3DSymbol * symbol() const
Returns 3D symbol associated with the renderer.
Represents a vector layer which manages a vector based dataset.
void subsetStringChanged()
Emitted when the layer's subset string has changed.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
void selectionChanged(const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect)
Emitted when selection was changed.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
bool qgsFloatNear(float a, float b, float epsilon=4 *FLT_EPSILON)
Compare two floats (but allow some difference).
QList< Qgs3DRendererCategory > Qgs3DCategoryList
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
constexpr QObjectUniquePtr< Tp > make_qobject_unique(Args &&...args)
Create an object owned by a QObjectUniquePtr.