21 #include "qgsmeshterraingenerator.h" 
   27 #include <QDomDocument> 
   28 #include <QDomElement> 
   36   , mOrigin( other.mOrigin )
 
   38   , mBackgroundColor( other.mBackgroundColor )
 
   39   , mSelectionColor( other.mSelectionColor )
 
   40   , mTerrainVerticalScale( other.mTerrainVerticalScale )
 
   41   , mTerrainGenerator( other.mTerrainGenerator ? other.mTerrainGenerator->clone() : nullptr )
 
   42   , mMapTileResolution( other.mMapTileResolution )
 
   43   , mMaxTerrainScreenError( other.mMaxTerrainScreenError )
 
   44   , mMaxTerrainGroundError( other.mMaxTerrainGroundError )
 
   45   , mTerrainElevationOffset( other.mTerrainElevationOffset )
 
   46   , mTerrainShadingEnabled( other.mTerrainShadingEnabled )
 
   47   , mTerrainShadingMaterial( other.mTerrainShadingMaterial )
 
   48   , mTerrainMapTheme( other.mTerrainMapTheme )
 
   49   , mShowTerrainBoundingBoxes( other.mShowTerrainBoundingBoxes )
 
   50   , mShowTerrainTileInfo( other.mShowTerrainTileInfo )
 
   51   , mShowCameraViewCenter( other.mShowCameraViewCenter )
 
   52   , mShowLightSources( other.mShowLightSources )
 
   53   , mShowLabels( other.mShowLabels )
 
   54   , mPointLights( other.mPointLights )
 
   55   , mDirectionalLights( other.mDirectionalLights )
 
   56   , mFieldOfView( other.mFieldOfView )
 
   57   , mProjectionType( other.mProjectionType )
 
   58   , mCameraNavigationMode( other.mCameraNavigationMode )
 
   59   , mCameraMovementSpeed( other.mCameraMovementSpeed )
 
   60   , mLayers( other.mLayers )
 
   62   , mTransformContext( other.mTransformContext )
 
   63   , mPathResolver( other.mPathResolver )
 
   64   , mMapThemes( other.mMapThemes )
 
   66   , mIsFpsCounterEnabled( other.mIsFpsCounterEnabled )
 
   67   , mIsSkyboxEnabled( other.mIsSkyboxEnabled )
 
   68   , mSkyboxSettings( other.mSkyboxSettings )
 
   69   , mShadowSettings( other.mShadowSettings )
 
   70   , mEyeDomeLightingEnabled( other.mEyeDomeLightingEnabled )
 
   71   , mEyeDomeLightingStrength( other.mEyeDomeLightingStrength )
 
   72   , mEyeDomeLightingDistance( other.mEyeDomeLightingDistance )
 
   73   , mDebugShadowMapEnabled( other.mDebugShadowMapEnabled )
 
   74   , mDebugShadowMapCorner( other.mDebugShadowMapCorner )
 
   75   , mDebugShadowMapSize( other.mDebugShadowMapSize )
 
   76   , mDebugDepthMapEnabled( other.mDebugDepthMapEnabled )
 
   77   , mDebugDepthMapCorner( other.mDebugDepthMapCorner )
 
   78   , mDebugDepthMapSize( other.mDebugDepthMapSize )
 
   79   , mTerrainRenderingEnabled( other.mTerrainRenderingEnabled )
 
   83     mRenderers << renderer->clone();
 
   89   qDeleteAll( mRenderers );
 
   94   QDomElement elemOrigin = elem.firstChildElement( QStringLiteral( 
"origin" ) );
 
   96               elemOrigin.attribute( QStringLiteral( 
"x" ) ).toDouble(),
 
   97               elemOrigin.attribute( QStringLiteral( 
"y" ) ).toDouble(),
 
   98               elemOrigin.attribute( QStringLiteral( 
"z" ) ).toDouble() );
 
  100   QDomElement elemCamera = elem.firstChildElement( QStringLiteral( 
"camera" ) );
 
  101   if ( !elemCamera.isNull() )
 
  103     mFieldOfView = elemCamera.attribute( QStringLiteral( 
"field-of-view" ), QStringLiteral( 
"45" ) ).toFloat();
 
  104     mProjectionType = 
static_cast< Qt3DRender::QCameraLens::ProjectionType 
>( elemCamera.attribute( QStringLiteral( 
"projection-type" ), QStringLiteral( 
"1" ) ).toInt() );
 
  105     QString 
cameraNavigationMode = elemCamera.attribute( QStringLiteral( 
"camera-navigation-mode" ), QStringLiteral( 
"basic-navigation" ) );
 
  107       mCameraNavigationMode = QgsCameraController::NavigationMode::TerrainBasedNavigation;
 
  109       mCameraNavigationMode = QgsCameraController::NavigationMode::WalkNavigation;
 
  110     mCameraMovementSpeed = elemCamera.attribute( QStringLiteral( 
"camera-movement-speed" ), QStringLiteral( 
"5.0" ) ).toDouble();
 
  113   QDomElement elemColor = elem.firstChildElement( QStringLiteral( 
"color" ) );
 
  114   if ( !elemColor.isNull() )
 
  120   QDomElement elemCrs = elem.firstChildElement( QStringLiteral( 
"crs" ) );
 
  123   QDomElement elemTerrain = elem.firstChildElement( QStringLiteral( 
"terrain" ) );
 
  124   mTerrainRenderingEnabled = elemTerrain.attribute( QStringLiteral( 
"terrain-rendering-enabled" ), QStringLiteral( 
"1" ) ).toInt();
 
  125   mTerrainVerticalScale = elemTerrain.attribute( QStringLiteral( 
"exaggeration" ), QStringLiteral( 
"1" ) ).toFloat();
 
  126   mMapTileResolution = elemTerrain.attribute( QStringLiteral( 
"texture-size" ), QStringLiteral( 
"512" ) ).toInt();
 
  127   mMaxTerrainScreenError = elemTerrain.attribute( QStringLiteral( 
"max-terrain-error" ), QStringLiteral( 
"3" ) ).toFloat();
 
  128   mMaxTerrainGroundError = elemTerrain.attribute( QStringLiteral( 
"max-ground-error" ), QStringLiteral( 
"1" ) ).toFloat();
 
  129   mTerrainShadingEnabled = elemTerrain.attribute( QStringLiteral( 
"shading-enabled" ), QStringLiteral( 
"0" ) ).toInt();
 
  130   mTerrainElevationOffset = elemTerrain.attribute( QStringLiteral( 
"elevation-offset" ), QStringLiteral( 
"0.0" ) ).toFloat();
 
  132   QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( QStringLiteral( 
"shading-material" ) );
 
  133   if ( !elemTerrainShadingMaterial.isNull() )
 
  134     mTerrainShadingMaterial.
readXml( elemTerrainShadingMaterial, context );
 
  135   mTerrainMapTheme = elemTerrain.attribute( QStringLiteral( 
"map-theme" ) );
 
  136   mShowLabels = elemTerrain.attribute( QStringLiteral( 
"show-labels" ), QStringLiteral( 
"0" ) ).toInt();
 
  138   mPointLights.clear();
 
  139   QDomElement elemPointLights = elem.firstChildElement( QStringLiteral( 
"point-lights" ) );
 
  140   if ( !elemPointLights.isNull() )
 
  142     QDomElement elemPointLight = elemPointLights.firstChildElement( QStringLiteral( 
"point-light" ) );
 
  143     while ( !elemPointLight.isNull() )
 
  146       pointLight.
readXml( elemPointLight );
 
  147       mPointLights << pointLight;
 
  148       elemPointLight = elemPointLight.nextSiblingElement( QStringLiteral( 
"point-light" ) );
 
  156     mPointLights << defaultLight;
 
  159   mDirectionalLights.clear();
 
  160   QDomElement elemDirectionalLights = elem.firstChildElement( QStringLiteral( 
"directional-lights" ) );
 
  161   if ( !elemDirectionalLights.isNull() )
 
  163     QDomElement elemDirectionalLight = elemDirectionalLights.firstChildElement( QStringLiteral( 
"directional-light" ) );
 
  164     while ( !elemDirectionalLight.isNull() )
 
  167       directionalLight.
readXml( elemDirectionalLight );
 
  168       mDirectionalLights << directionalLight;
 
  169       elemDirectionalLight = elemDirectionalLight.nextSiblingElement( QStringLiteral( 
"directional-light" ) );
 
  173   QDomElement elemMapLayers = elemTerrain.firstChildElement( QStringLiteral( 
"layers" ) );
 
  174   QDomElement elemMapLayer = elemMapLayers.firstChildElement( QStringLiteral( 
"layer" ) );
 
  175   QList<QgsMapLayerRef> mapLayers;
 
  176   while ( !elemMapLayer.isNull() )
 
  178     mapLayers << 
QgsMapLayerRef( elemMapLayer.attribute( QStringLiteral( 
"id" ) ) );
 
  179     elemMapLayer = elemMapLayer.nextSiblingElement( QStringLiteral( 
"layer" ) );
 
  183   QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( QStringLiteral( 
"generator" ) );
 
  184   QString terrainGenType = elemTerrainGenerator.attribute( QStringLiteral( 
"type" ) );
 
  185   if ( terrainGenType == QLatin1String( 
"dem" ) )
 
  188     demTerrainGenerator->
setCrs( mCrs, mTransformContext );
 
  191   else if ( terrainGenType == QLatin1String( 
"online" ) )
 
  194     onlineTerrainGenerator->
setCrs( mCrs, mTransformContext );
 
  197   else if ( terrainGenType == QLatin1String( 
"mesh" ) )
 
  199     QgsMeshTerrainGenerator *meshTerrainGenerator = 
new QgsMeshTerrainGenerator;
 
  200     meshTerrainGenerator->setCrs( mCrs, mTransformContext );
 
  209   mTerrainGenerator->readXml( elemTerrainGenerator );
 
  211   qDeleteAll( mRenderers );
 
  214   QDomElement elemRenderers = elem.firstChildElement( QStringLiteral( 
"renderers" ) );
 
  215   QDomElement elemRenderer = elemRenderers.firstChildElement( QStringLiteral( 
"renderer" ) );
 
  216   while ( !elemRenderer.isNull() )
 
  219     QString type = elemRenderer.attribute( QStringLiteral( 
"type" ) );
 
  220     if ( type == QLatin1String( 
"vector" ) )
 
  224     else if ( type == QLatin1String( 
"mesh" ) )
 
  228     else if ( type == QLatin1String( 
"pointcloud" ) )
 
  235       renderer->
readXml( elemRenderer, context );
 
  236       mRenderers.append( renderer );
 
  238     elemRenderer = elemRenderer.nextSiblingElement( QStringLiteral( 
"renderer" ) );
 
  241   QDomElement elemSkybox = elem.firstChildElement( QStringLiteral( 
"skybox" ) );
 
  242   mIsSkyboxEnabled = elemSkybox.attribute( QStringLiteral( 
"skybox-enabled" ) ).toInt();
 
  243   mSkyboxSettings.
readXml( elemSkybox, context );
 
  245   QDomElement elemShadows = elem.firstChildElement( QStringLiteral( 
"shadow-rendering" ) );
 
  246   mShadowSettings.
readXml( elemShadows, context );
 
  248   QDomElement elemEyeDomeLighting = elem.firstChildElement( QStringLiteral( 
"eye-dome-lighting" ) );
 
  249   mEyeDomeLightingEnabled = elemEyeDomeLighting.attribute( 
"enabled", QStringLiteral( 
"0" ) ).toInt();
 
  250   mEyeDomeLightingStrength = elemEyeDomeLighting.attribute( 
"eye-dome-lighting-strength", QStringLiteral( 
"1000.0" ) ).toDouble();
 
  251   mEyeDomeLightingDistance = elemEyeDomeLighting.attribute( 
"eye-dome-lighting-distance", QStringLiteral( 
"1" ) ).toInt();
 
  253   QDomElement elemDebugSettings = elem.firstChildElement( QStringLiteral( 
"debug-settings" ) );
 
  254   mDebugShadowMapEnabled = elemDebugSettings.attribute( QStringLiteral( 
"shadowmap-enabled" ), QStringLiteral( 
"0" ) ).toInt();
 
  255   mDebugShadowMapCorner = 
static_cast<Qt::Corner
>( elemDebugSettings.attribute( QStringLiteral( 
"shadowmap-corner" ), 
"0" ).toInt() );
 
  256   mDebugShadowMapSize = elemDebugSettings.attribute( QStringLiteral( 
"shadowmap-size" ), QStringLiteral( 
"0.2" ) ).toDouble();
 
  258   mDebugDepthMapEnabled = elemDebugSettings.attribute( QStringLiteral( 
"depthmap-enabled" ), QStringLiteral( 
"0" ) ).toInt();
 
  259   mDebugDepthMapCorner = 
static_cast<Qt::Corner
>( elemDebugSettings.attribute( QStringLiteral( 
"depthmap-corner" ), QStringLiteral( 
"1" ) ).toInt() );
 
  260   mDebugDepthMapSize = elemDebugSettings.attribute( QStringLiteral( 
"depthmap-size" ), QStringLiteral( 
"0.2" ) ).toDouble();
 
  262   QDomElement elemDebug = elem.firstChildElement( QStringLiteral( 
"debug" ) );
 
  263   mShowTerrainBoundingBoxes = elemDebug.attribute( QStringLiteral( 
"bounding-boxes" ), QStringLiteral( 
"0" ) ).toInt();
 
  264   mShowTerrainTileInfo = elemDebug.attribute( QStringLiteral( 
"terrain-tile-info" ), QStringLiteral( 
"0" ) ).toInt();
 
  265   mShowCameraViewCenter = elemDebug.attribute( QStringLiteral( 
"camera-view-center" ), QStringLiteral( 
"0" ) ).toInt();
 
  266   mShowLightSources = elemDebug.attribute( QStringLiteral( 
"show-light-sources" ), QStringLiteral( 
"0" ) ).toInt();
 
  267   mIsFpsCounterEnabled = elemDebug.attribute( QStringLiteral( 
"show-fps-counter" ), QStringLiteral( 
"0" ) ).toInt();
 
  269   QDomElement elemTemporalRange = elem.firstChildElement( QStringLiteral( 
"temporal-range" ) );
 
  270   QDateTime start = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( 
"start" ) ), Qt::ISODate );
 
  271   QDateTime end = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( 
"end" ) ), Qt::ISODate );
 
  277   QDomElement elem = doc.createElement( QStringLiteral( 
"qgis3d" ) );
 
  279   QDomElement elemOrigin = doc.createElement( QStringLiteral( 
"origin" ) );
 
  280   elemOrigin.setAttribute( QStringLiteral( 
"x" ), QString::number( mOrigin.
x() ) );
 
  281   elemOrigin.setAttribute( QStringLiteral( 
"y" ), QString::number( mOrigin.
y() ) );
 
  282   elemOrigin.setAttribute( QStringLiteral( 
"z" ), QString::number( mOrigin.
z() ) );
 
  283   elem.appendChild( elemOrigin );
 
  285   QDomElement elemCamera = doc.createElement( QStringLiteral( 
"camera" ) );
 
  286   elemCamera.setAttribute( QStringLiteral( 
"field-of-view" ), mFieldOfView );
 
  287   elemCamera.setAttribute( QStringLiteral( 
"projection-type" ), 
static_cast< int >( mProjectionType ) );
 
  288   switch ( mCameraNavigationMode )
 
  291       elemCamera.setAttribute( QStringLiteral( 
"camera-navigation-mode" ), QStringLiteral( 
"terrain-based-navigation" ) );
 
  294       elemCamera.setAttribute( QStringLiteral( 
"camera-navigation-mode" ), QStringLiteral( 
"walk-navigation" ) );
 
  297   elemCamera.setAttribute( QStringLiteral( 
"camera-movement-speed" ), mCameraMovementSpeed );
 
  298   elem.appendChild( elemCamera );
 
  300   QDomElement elemColor = doc.createElement( QStringLiteral( 
"color" ) );
 
  303   elem.appendChild( elemColor );
 
  305   QDomElement elemCrs = doc.createElement( QStringLiteral( 
"crs" ) );
 
  307   elem.appendChild( elemCrs );
 
  309   QDomElement elemTerrain = doc.createElement( QStringLiteral( 
"terrain" ) );
 
  310   elemTerrain.setAttribute( QStringLiteral( 
"terrain-rendering-enabled" ), mTerrainRenderingEnabled ? 1 : 0 );
 
  311   elemTerrain.setAttribute( QStringLiteral( 
"exaggeration" ), QString::number( mTerrainVerticalScale ) );
 
  312   elemTerrain.setAttribute( QStringLiteral( 
"texture-size" ), mMapTileResolution );
 
  313   elemTerrain.setAttribute( QStringLiteral( 
"max-terrain-error" ), QString::number( mMaxTerrainScreenError ) );
 
  314   elemTerrain.setAttribute( QStringLiteral( 
"max-ground-error" ), QString::number( mMaxTerrainGroundError ) );
 
  315   elemTerrain.setAttribute( QStringLiteral( 
"shading-enabled" ), mTerrainShadingEnabled ? 1 : 0 );
 
  316   elemTerrain.setAttribute( QStringLiteral( 
"elevation-offset" ), mTerrainElevationOffset );
 
  318   QDomElement elemTerrainShadingMaterial = doc.createElement( QStringLiteral( 
"shading-material" ) );
 
  319   mTerrainShadingMaterial.
writeXml( elemTerrainShadingMaterial, context );
 
  320   elemTerrain.appendChild( elemTerrainShadingMaterial );
 
  321   elemTerrain.setAttribute( QStringLiteral( 
"map-theme" ), mTerrainMapTheme );
 
  322   elemTerrain.setAttribute( QStringLiteral( 
"show-labels" ), mShowLabels ? 1 : 0 );
 
  324   QDomElement elemPointLights = doc.createElement( QStringLiteral( 
"point-lights" ) );
 
  327     QDomElement elemPointLight = pointLight.writeXml( doc );
 
  328     elemPointLights.appendChild( elemPointLight );
 
  330   elem.appendChild( elemPointLights );
 
  332   QDomElement elemDirectionalLights = doc.createElement( QStringLiteral( 
"directional-lights" ) );
 
  335     QDomElement elemDirectionalLight = directionalLight.writeXml( doc );
 
  336     elemDirectionalLights.appendChild( elemDirectionalLight );
 
  338   elem.appendChild( elemDirectionalLights );
 
  340   QDomElement elemMapLayers = doc.createElement( QStringLiteral( 
"layers" ) );
 
  343     QDomElement elemMapLayer = doc.createElement( QStringLiteral( 
"layer" ) );
 
  344     elemMapLayer.setAttribute( QStringLiteral( 
"id" ), layerRef.layerId );
 
  345     elemMapLayers.appendChild( elemMapLayer );
 
  347   elemTerrain.appendChild( elemMapLayers );
 
  349   QDomElement elemTerrainGenerator = doc.createElement( QStringLiteral( 
"generator" ) );
 
  351   mTerrainGenerator->writeXml( elemTerrainGenerator );
 
  352   elemTerrain.appendChild( elemTerrainGenerator );
 
  353   elem.appendChild( elemTerrain );
 
  355   QDomElement elemRenderers = doc.createElement( QStringLiteral( 
"renderers" ) );
 
  358     QDomElement elemRenderer = doc.createElement( QStringLiteral( 
"renderer" ) );
 
  359     elemRenderer.setAttribute( QStringLiteral( 
"type" ), renderer->type() );
 
  360     renderer->writeXml( elemRenderer, context );
 
  361     elemRenderers.appendChild( elemRenderer );
 
  363   elem.appendChild( elemRenderers );
 
  365   QDomElement elemSkybox = doc.createElement( QStringLiteral( 
"skybox" ) );
 
  366   elemSkybox.setAttribute( QStringLiteral( 
"skybox-enabled" ), mIsSkyboxEnabled );
 
  367   mSkyboxSettings.
writeXml( elemSkybox, context );
 
  368   elem.appendChild( elemSkybox );
 
  370   QDomElement elemShadows = doc.createElement( QStringLiteral( 
"shadow-rendering" ) );
 
  371   mShadowSettings.
writeXml( elemShadows, context );
 
  372   elem.appendChild( elemShadows );
 
  374   QDomElement elemDebug = doc.createElement( QStringLiteral( 
"debug" ) );
 
  375   elemDebug.setAttribute( QStringLiteral( 
"bounding-boxes" ), mShowTerrainBoundingBoxes ? 1 : 0 );
 
  376   elemDebug.setAttribute( QStringLiteral( 
"terrain-tile-info" ), mShowTerrainTileInfo ? 1 : 0 );
 
  377   elemDebug.setAttribute( QStringLiteral( 
"camera-view-center" ), mShowCameraViewCenter ? 1 : 0 );
 
  378   elemDebug.setAttribute( QStringLiteral( 
"show-light-sources" ), mShowLightSources ? 1 : 0 );
 
  379   elemDebug.setAttribute( QStringLiteral( 
"show-fps-counter" ), mIsFpsCounterEnabled ? 1 : 0 );
 
  380   elem.appendChild( elemDebug );
 
  382   QDomElement elemEyeDomeLighting = doc.createElement( QStringLiteral( 
"eye-dome-lighting" ) );
 
  383   elemEyeDomeLighting.setAttribute( 
"enabled", mEyeDomeLightingEnabled ? 1 : 0 );
 
  384   elemEyeDomeLighting.setAttribute( 
"eye-dome-lighting-strength", mEyeDomeLightingStrength );
 
  385   elemEyeDomeLighting.setAttribute( 
"eye-dome-lighting-distance", mEyeDomeLightingDistance );
 
  386   elem.appendChild( elemEyeDomeLighting );
 
  389   QDomElement elemDebugSettings = doc.createElement( QStringLiteral( 
"debug-settings" ) );
 
  390   elemDebugSettings.setAttribute( QStringLiteral( 
"shadowmap-enabled" ), mDebugShadowMapEnabled );
 
  391   elemDebugSettings.setAttribute( QStringLiteral( 
"shadowmap-corner" ), mDebugShadowMapCorner );
 
  392   elemDebugSettings.setAttribute( QStringLiteral( 
"shadowmap-size" ), mDebugShadowMapSize );
 
  393   elemDebugSettings.setAttribute( QStringLiteral( 
"depthmap-enabled" ), mDebugDepthMapEnabled );
 
  394   elemDebugSettings.setAttribute( QStringLiteral( 
"depthmap-corner" ), mDebugDepthMapCorner );
 
  395   elemDebugSettings.setAttribute( QStringLiteral( 
"depthmap-size" ), mDebugDepthMapSize );
 
  396   elem.appendChild( elemDebugSettings );
 
  398   QDomElement elemTemporalRange = doc.createElement( QStringLiteral( 
"temporal-range" ) );
 
  399   elemTemporalRange.setAttribute( QStringLiteral( 
"start" ), 
temporalRange().begin().toString( Qt::ISODate ) );
 
  400   elemTemporalRange.setAttribute( QStringLiteral( 
"end" ), 
temporalRange().end().toString( Qt::ISODate ) );
 
  407   for ( 
int i = 0; i < mLayers.count(); ++i )
 
  413   mTerrainGenerator->resolveReferences( project );
 
  415   for ( 
int i = 0; i < mRenderers.count(); ++i )
 
  439   return mTransformContext;
 
  444   mTransformContext = context;
 
  449   if ( color == mBackgroundColor )
 
  452   mBackgroundColor = color;
 
  458   return mBackgroundColor;
 
  463   if ( color == mSelectionColor )
 
  466   mSelectionColor = color;
 
  472   return mSelectionColor;
 
  477   if ( zScale == mTerrainVerticalScale )
 
  480   mTerrainVerticalScale = zScale;
 
  486   return mTerrainVerticalScale;
 
  491   QList<QgsMapLayerRef> lst;
 
  492   lst.reserve( 
layers.count() );
 
  498   if ( mLayers == lst )
 
  507   QList<QgsMapLayer *> lst;
 
  508   lst.reserve( mLayers.count() );
 
  511     if ( layerRef.layer )
 
  512       lst.append( layerRef.layer );
 
  519   if ( mMapTileResolution == res )
 
  522   mMapTileResolution = res;
 
  528   return mMapTileResolution;
 
  533   if ( mMaxTerrainScreenError == error )
 
  536   mMaxTerrainScreenError = error;
 
  542   return mMaxTerrainScreenError;
 
  547   if ( mMaxTerrainGroundError == error )
 
  550   mMaxTerrainGroundError = error;
 
  556   if ( mTerrainElevationOffset == offset )
 
  558   mTerrainElevationOffset = offset;
 
  564   return mMaxTerrainGroundError;
 
  569   if ( mTerrainGenerator )
 
  575   mTerrainGenerator.reset( gen );
 
  584   if ( mTerrainShadingEnabled == enabled )
 
  587   mTerrainShadingEnabled = enabled;
 
  593   if ( mTerrainShadingMaterial == material )
 
  596   mTerrainShadingMaterial = material;
 
  602   if ( mTerrainMapTheme == theme )
 
  605   mTerrainMapTheme = theme;
 
  611   qDeleteAll( mRenderers );
 
  620   if ( mShowTerrainBoundingBoxes == enabled )
 
  623   mShowTerrainBoundingBoxes = enabled;
 
  629   if ( mShowTerrainTileInfo == enabled )
 
  632   mShowTerrainTileInfo = enabled;
 
  638   if ( mShowCameraViewCenter == enabled )
 
  641   mShowCameraViewCenter = enabled;
 
  647   if ( mShowLightSources == enabled )
 
  650   mShowLightSources = enabled;
 
  656   if ( mShowLabels == enabled )
 
  659   mShowLabels = enabled;
 
  665   if ( mEyeDomeLightingEnabled == enabled )
 
  667   mEyeDomeLightingEnabled = enabled;
 
  673   if ( mEyeDomeLightingStrength == strength )
 
  675   mEyeDomeLightingStrength = strength;
 
  681   if ( mEyeDomeLightingDistance == distance )
 
  683   mEyeDomeLightingDistance = distance;
 
  725   if ( mCameraNavigationMode == navigationMode )
 
  728   mCameraNavigationMode = navigationMode;
 
  734   if ( mCameraMovementSpeed == movementSpeed )
 
  737   mCameraMovementSpeed = movementSpeed;
 
  755   mDebugShadowMapEnabled = enabled;
 
  756   mDebugShadowMapCorner = corner;
 
  757   mDebugShadowMapSize = size;
 
  763   mDebugDepthMapEnabled = enabled;
 
  764   mDebugDepthMapCorner = corner;
 
  765   mDebugDepthMapSize = size;
 
  771   if ( fpsCounterEnabled == mIsFpsCounterEnabled )
 
  773   mIsFpsCounterEnabled = fpsCounterEnabled;
 
void setEyeDomeLightingStrength(double strength)
Sets the eye dome lighting strength value.
void mapTileResolutionChanged()
Emitted when the map tile resoulution has changed.
void terrainVerticalScaleChanged()
Emitted when the vertical scale of the terrain has changed.
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which stores various information regarding which datum transfo...
void renderersChanged()
Emitted when the list of map's extra renderers have been modified.
QList< QgsAbstract3DRenderer * > renderers() const
Returns list of extra 3D renderers.
void eyeDomeLightingDistanceChanged()
Emitted when the eye dome lighting distance has changed.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads configuration from a DOM element previously written by writeXml()
void terrainShadingChanged()
Emitted when terrain shading enabled flag or terrain shading material has changed.
void setShowTerrainTilesInfo(bool enabled)
Sets whether to display extra tile info on top of terrain tiles (for debugging)
QgsVector3D mapToWorldCoordinates(const QgsVector3D &mapCoords) const
Converts map coordinates to 3D world coordinates (applies offset and turns (x,y,z) into (x,...
void setRenderers(const QList< QgsAbstract3DRenderer * > &renderers)
Sets list of extra 3D renderers to use in the scene. Takes ownership of the objects.
Qt3DRender::QCameraLens::ProjectionType projectionType() const
Returns the camera lens' projection type.
void setEyeDomeLightingEnabled(bool enabled)
Sets whether eye dome lighting will be used.
void setFieldOfView(const float fieldOfView)
Sets the camera lens' field of view.
void debugDepthMapSettingsChanged()
Emitted when depth map debugging has changed.
QList< QgsDirectionalLightSettings > directionalLights() const
Returns list of directional lights defined in the scene.
void setPointLights(const QList< QgsPointLightSettings > &pointLights)
Sets list of point lights defined in the scene.
void backgroundColorChanged()
Emitted when the background color has changed.
void showTerrainBoundingBoxesChanged()
Emitted when the flag whether terrain's bounding boxes are shown has changed.
void setDirectionalLights(const QList< QgsDirectionalLightSettings > &directionalLights)
Sets list of directional lights defined in the scene.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a DOM element, to be used later with readXml()
void setDebugDepthMapSettings(bool enabled, Qt::Corner corner, double size)
Sets the debugging settings of the depth map.
QColor selectionColor() const
Returns color used for selected features.
void directionalLightsChanged()
Emitted when the list of directional lights changes.
void setTerrainShadingMaterial(const QgsPhongMaterialSettings &material)
Sets terrain shading material.
void cameraNavigationModeChanged()
Emitted when the camera navigation mode was changed.
void shadowSettingsChanged()
Emitted when shadow rendering settings are changed.
float maxTerrainGroundError() const
Returns maximum ground error of terrain tiles in world units.
void eyeDomeLightingEnabledChanged()
Emitted when the flag whether eye dome lighting is used has changed.
void setTerrainVerticalScale(double zScale)
Sets vertical scale (exaggeration) of terrain (1 = true scale, > 1 = hills get more pronounced)
void setShowLabels(bool enabled)
Sets whether to display labels on terrain tiles.
double terrainVerticalScale() const
Returns vertical scale (exaggeration) of terrain.
void setMaxTerrainGroundError(float error)
Returns maximum ground error of terrain tiles in world units.
void setSkyboxSettings(const QgsSkyboxSettings &skyboxSettings)
Sets the current configuration of the skybox.
void skyboxSettingsChanged()
Emitted when skybox settings are changed.
void setMapTileResolution(int res)
Sets resolution (in pixels) of the texture of a terrain tile.
void setLayers(const QList< QgsMapLayer * > &layers)
Sets the list of 3D map layers to be rendered in the scene.
QgsShadowSettings shadowSettings() const
Returns the current configuration of shadows.
void terrainMapThemeChanged()
Emitted when terrain's map theme has changed.
void setShadowSettings(const QgsShadowSettings &shadowSettings)
Sets the current configuration of shadow rendering.
void pointLightsChanged()
Emitted when the list of point lights changes.
void setTerrainElevationOffset(float offset)
Sets the terrain elevation offset (used to move the terrain up or down)
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets coordinate reference system used in the 3D scene.
void setEyeDomeLightingDistance(int distance)
Sets the eye dome lighting distance value (contributes to the contrast of the image.
void setShowLightSourceOrigins(bool enabled)
Sets whether to show light source origins as a sphere (for debugging)
void projectionTypeChanged()
Emitted when the camera lens projection type changes.
float fieldOfView() const
Returns the camera lens' field of view.
void selectionColorChanged()
Emitted when the selection color has changed.
void setTerrainShadingEnabled(bool enabled)
Sets whether terrain shading is enabled.
void setDebugShadowMapSettings(bool enabled, Qt::Corner corner, double size)
Sets the debugging settings of the shadow map.
void setSelectionColor(const QColor &color)
Sets color used for selected features.
void showLightSourceOriginsChanged()
Emitted when the flag whether light source origins are shown has changed.
QColor backgroundColor() const
Returns background color of the 3D map view.
void resolveReferences(const QgsProject &project)
Resolves references to other objects (map layers) after the call to readXml()
QgsVector3D worldToMapCoordinates(const QgsVector3D &worldCoords) const
Converts 3D world coordinates to map coordinates (applies offset and turns (x,y,z) into (x,...
Qgs3DMapSettings()=default
Constructor for Qgs3DMapSettings.
~Qgs3DMapSettings() override
void showLabelsChanged()
Emitted when the flag whether labels are displayed on terrain tiles has changed.
void maxTerrainScreenErrorChanged()
Emitted when the maximum terrain screen error has changed.
void setShowCameraViewCenter(bool enabled)
Sets whether to show camera's view center as a sphere (for debugging)
int mapTileResolution() const
Returns resolution (in pixels) of the texture of a terrain tile.
bool terrainRenderingEnabled()
Returns whether the 2D terrain surface will be rendered.
void setCameraMovementSpeed(double movementSpeed)
Sets the camera movement speed.
void terrainElevationOffsetChanged(float newElevation)
Emitted when the terrain elevation offset is changed.
void setTerrainRenderingEnabled(bool terrainRenderingEnabled)
Sets whether the 2D terrain surface will be rendered in.
void setBackgroundColor(const QColor &color)
Sets background color of the 3D map view.
void fpsCounterEnabledChanged(bool fpsCounterEnabled)
Emitted when the FPS counter is enabled or disabled.
void setProjectionType(const Qt3DRender::QCameraLens::ProjectionType projectionType)
Sets the camera lens' projection type.
void setCameraNavigationMode(QgsCameraController::NavigationMode navigationMode)
Sets the navigation mode for the camera.
void layersChanged()
Emitted when the list of map layers for 3d rendering has changed.
void showTerrainTilesInfoChanged()
Emitted when the flag whether terrain's tile info is shown has changed.
void eyeDomeLightingStrengthChanged()
Emitted when the eye dome lighting strength has changed.
QgsSkyboxSettings skyboxSettings() const
Returns the current configuration of the skybox.
void setMaxTerrainScreenError(float error)
Sets maximum allowed screen error of terrain tiles in pixels.
void cameraMovementSpeedChanged()
Emitted when the camera movement speed was changed.
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used in the 3D scene.
float maxTerrainScreenError() const
Returns maximum allowed screen error of terrain tiles in pixels.
void setShowTerrainBoundingBoxes(bool enabled)
Sets whether to display bounding boxes of terrain tiles (for debugging)
void fieldOfViewChanged()
Emitted when the camera lens field of view changes.
void setIsFpsCounterEnabled(bool fpsCounterEnabled)
Sets whether FPS counter label is enabled.
QList< QgsPointLightSettings > pointLights() const
Returns list of point lights defined in the scene.
QList< QgsMapLayer * > layers() const
Returns the list of 3D map layers to be rendered in the scene.
void setTerrainMapTheme(const QString &theme)
Sets name of the map theme.
QgsCameraController::NavigationMode cameraNavigationMode() const
Returns the navigation mode used by the camera.
void terrainGeneratorChanged()
Emitted when the terrain generator has changed.
void setTerrainGenerator(QgsTerrainGenerator *gen)
Sets terrain generator.
void debugShadowMapSettingsChanged()
Emitted when shadow map debugging has changed.
void showCameraViewCenterChanged()
Emitted when the flag whether camera's view center is shown has changed.
void maxTerrainGroundErrorChanged()
Emitted when the maximum terrain ground error has changed.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
static QgsVector3D worldToMapCoordinates(const QgsVector3D &worldCoords, const QgsVector3D &origin)
Converts 3D world coordinates to map coordinates (applies offset and turns (x,y,z) into (x,...
static QgsVector3D mapToWorldCoordinates(const QgsVector3D &mapCoords, const QgsVector3D &origin)
Converts map coordinates to 3D world coordinates (applies offset and turns (x,y,z) into (x,...
Base class for all renderers that may to participate in 3D view.
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)=0
Reads renderer's properties from given XML element.
virtual void resolveReferences(const QgsProject &project)
Resolves references to other objects - second phase of loading - after readXml()
NavigationMode
The navigation mode used by the camera.
@ WalkNavigation
Uses WASD keys or arrows to navigate in walking (first person) manner.
@ TerrainBasedNavigation
The default navigation based on the terrain.
This class represents a coordinate reference system (CRS).
bool readXml(const QDomNode &node)
Restores state from the given DOM node.
bool writeXml(QDomNode &node, QDomDocument &doc) const
Stores state to the given Dom node in the given document.
Contains information about the context in which a coordinate transform is executed.
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets CRS of the terrain.
void readXml(const QDomElement &elem)
Reads configuration from a DOM element previously written using writeXml()
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets CRS of the terrain.
Base class for all map layer types.
3D renderer that renders all mesh triangles of a mesh layer.
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets CRS of the terrain.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes settings to a DOM element.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads settings from a DOM element.
3D renderer that renders all points from a point cloud layer
void setPosition(const QgsVector3D &pos)
Sets position of the light (in 3D world coordinates)
void readXml(const QDomElement &elem)
Reads configuration from a DOM element previously written using writeXml()
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
The class is used as a container of context for various read/write operations on other objects.
class containing the configuration of shadows rendering 3
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
Contains the configuration of a skybox entity.
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.
static QColor decodeColor(const QString &str)
static QString encodeColor(const QColor &color)
Base class for objects with an associated (optional) temporal range.
const QgsDateTimeRange & temporalRange() const
Returns the datetime range for the object.
void setTemporalRange(const QgsDateTimeRange &range)
Sets the temporal range for the object.
void terrainChanged()
Emitted when the terrain changed (for example, raster DEM or mesh have data changed)
void extentChanged()
Emitted when the terrain extent has changed.
static QString typeToString(Type type)
Converts terrain generator type enumeration into a string.
double y() const
Returns Y coordinate.
double z() const
Returns Z coordinate.
double x() const
Returns X coordinate.
3D renderer that renders all features of a vector layer with the same 3D symbol.
_LayerRef< QgsMapLayer > QgsMapLayerRef
const QgsCoordinateReferenceSystem & crs
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
QString layerId
Original layer ID.