QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgs3dmapsettings.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgs3dmapsettings.cpp
3  --------------------------------------
4  Date : July 2017
5  Copyright : (C) 2017 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgs3dmapsettings.h"
17 
18 #include "qgs3dutils.h"
20 #include "qgsdemterraingenerator.h"
21 #include "qgsmeshterraingenerator.h"
24 #include "qgsmeshlayer3drenderer.h"
27 #include "qgsterrainprovider.h"
28 
29 #include <QDomDocument>
30 #include <QDomElement>
31 
32 #include "qgssymbollayerutils.h"
33 #include "qgsrasterlayer.h"
34 
36  : QObject( nullptr )
37 {
38  connect( this, &Qgs3DMapSettings::settingsChanged, [&]()
39  {
41  } );
42  connectChangedSignalsToSettingsChanged();
43 }
44 
46  : QObject( nullptr )
47  , QgsTemporalRangeObject( other )
48  , mOrigin( other.mOrigin )
49  , mCrs( other.mCrs )
50  , mBackgroundColor( other.mBackgroundColor )
51  , mSelectionColor( other.mSelectionColor )
52  , mTerrainVerticalScale( other.mTerrainVerticalScale )
53  , mTerrainGenerator( other.mTerrainGenerator ? other.mTerrainGenerator->clone() : nullptr )
54  , mMapTileResolution( other.mMapTileResolution )
55  , mMaxTerrainScreenError( other.mMaxTerrainScreenError )
56  , mMaxTerrainGroundError( other.mMaxTerrainGroundError )
57  , mTerrainElevationOffset( other.mTerrainElevationOffset )
58  , mTerrainShadingEnabled( other.mTerrainShadingEnabled )
59  , mTerrainShadingMaterial( other.mTerrainShadingMaterial )
60  , mTerrainMapTheme( other.mTerrainMapTheme )
61  , mShowTerrainBoundingBoxes( other.mShowTerrainBoundingBoxes )
62  , mShowTerrainTileInfo( other.mShowTerrainTileInfo )
63  , mShowCameraViewCenter( other.mShowCameraViewCenter )
64  , mShowCameraRotationCenter( other.mShowCameraRotationCenter )
65  , mShowLightSources( other.mShowLightSources )
66  , mShowLabels( other.mShowLabels )
67  , mFieldOfView( other.mFieldOfView )
68  , mProjectionType( other.mProjectionType )
69  , mCameraNavigationMode( other.mCameraNavigationMode )
70  , mCameraMovementSpeed( other.mCameraMovementSpeed )
71  , mLayers( other.mLayers )
72  , mRenderers() // initialized in body
73  , mTransformContext( other.mTransformContext )
74  , mPathResolver( other.mPathResolver )
75  , mMapThemes( other.mMapThemes )
76  , mDpi( other.mDpi )
77  , mIsFpsCounterEnabled( other.mIsFpsCounterEnabled )
78  , mIsSkyboxEnabled( other.mIsSkyboxEnabled )
79  , mSkyboxSettings( other.mSkyboxSettings )
80  , mShadowSettings( other.mShadowSettings )
81  , mEyeDomeLightingEnabled( other.mEyeDomeLightingEnabled )
82  , mEyeDomeLightingStrength( other.mEyeDomeLightingStrength )
83  , mEyeDomeLightingDistance( other.mEyeDomeLightingDistance )
84  , mViewSyncMode( other.mViewSyncMode )
85  , mVisualizeViewFrustum( other.mVisualizeViewFrustum )
86  , mDebugShadowMapEnabled( other.mDebugShadowMapEnabled )
87  , mDebugShadowMapCorner( other.mDebugShadowMapCorner )
88  , mDebugShadowMapSize( other.mDebugShadowMapSize )
89  , mDebugDepthMapEnabled( other.mDebugDepthMapEnabled )
90  , mDebugDepthMapCorner( other.mDebugDepthMapCorner )
91  , mDebugDepthMapSize( other.mDebugDepthMapSize )
92  , mTerrainRenderingEnabled( other.mTerrainRenderingEnabled )
93  , mRendererUsage( other.mRendererUsage )
94  , m3dAxisSettings( other.m3dAxisSettings )
95  , mIsDebugOverlayEnabled( other.mIsDebugOverlayEnabled )
96 {
97  for ( QgsAbstract3DRenderer *renderer : std::as_const( other.mRenderers ) )
98  {
99  mRenderers << renderer->clone();
100  }
101 
102  for ( QgsLightSource *source : std::as_const( other.mLightSources ) )
103  {
104  if ( source )
105  mLightSources << source->clone();
106  }
107 
108  connect( this, &Qgs3DMapSettings::settingsChanged, [&]()
109  {
111  } );
112  connectChangedSignalsToSettingsChanged();
113 }
114 
116 {
117  qDeleteAll( mRenderers );
118  qDeleteAll( mLightSources );
119 }
120 
121 void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
122 {
124  QDomElement elemOrigin = elem.firstChildElement( QStringLiteral( "origin" ) );
125  mOrigin = QgsVector3D(
126  elemOrigin.attribute( QStringLiteral( "x" ) ).toDouble(),
127  elemOrigin.attribute( QStringLiteral( "y" ) ).toDouble(),
128  elemOrigin.attribute( QStringLiteral( "z" ) ).toDouble() );
129 
130  QDomElement elemCamera = elem.firstChildElement( QStringLiteral( "camera" ) );
131  if ( !elemCamera.isNull() )
132  {
133  mFieldOfView = elemCamera.attribute( QStringLiteral( "field-of-view" ), QStringLiteral( "45" ) ).toFloat();
134  mProjectionType = static_cast< Qt3DRender::QCameraLens::ProjectionType >( elemCamera.attribute( QStringLiteral( "projection-type" ), QStringLiteral( "1" ) ).toInt() );
135  QString cameraNavigationMode = elemCamera.attribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "basic-navigation" ) );
136  if ( cameraNavigationMode == QLatin1String( "terrain-based-navigation" ) )
137  mCameraNavigationMode = QgsCameraController::NavigationMode::TerrainBasedNavigation;
138  else if ( cameraNavigationMode == QLatin1String( "walk-navigation" ) )
139  mCameraNavigationMode = QgsCameraController::NavigationMode::WalkNavigation;
140  mCameraMovementSpeed = elemCamera.attribute( QStringLiteral( "camera-movement-speed" ), QStringLiteral( "5.0" ) ).toDouble();
141  }
142 
143  QDomElement elemColor = elem.firstChildElement( QStringLiteral( "color" ) );
144  if ( !elemColor.isNull() )
145  {
146  mBackgroundColor = QgsSymbolLayerUtils::decodeColor( elemColor.attribute( QStringLiteral( "background" ) ) );
147  mSelectionColor = QgsSymbolLayerUtils::decodeColor( elemColor.attribute( QStringLiteral( "selection" ) ) );
148  }
149 
150  QDomElement elemCrs = elem.firstChildElement( QStringLiteral( "crs" ) );
151  mCrs.readXml( elemCrs );
152 
153  QDomElement elemTerrain = elem.firstChildElement( QStringLiteral( "terrain" ) );
154  mTerrainRenderingEnabled = elemTerrain.attribute( QStringLiteral( "terrain-rendering-enabled" ), QStringLiteral( "1" ) ).toInt();
155  mTerrainVerticalScale = elemTerrain.attribute( QStringLiteral( "exaggeration" ), QStringLiteral( "1" ) ).toFloat();
156  mMapTileResolution = elemTerrain.attribute( QStringLiteral( "texture-size" ), QStringLiteral( "512" ) ).toInt();
157  mMaxTerrainScreenError = elemTerrain.attribute( QStringLiteral( "max-terrain-error" ), QStringLiteral( "3" ) ).toFloat();
158  mMaxTerrainGroundError = elemTerrain.attribute( QStringLiteral( "max-ground-error" ), QStringLiteral( "1" ) ).toFloat();
159  mTerrainShadingEnabled = elemTerrain.attribute( QStringLiteral( "shading-enabled" ), QStringLiteral( "0" ) ).toInt();
160  mTerrainElevationOffset = elemTerrain.attribute( QStringLiteral( "elevation-offset" ), QStringLiteral( "0.0" ) ).toFloat();
161 
162  QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( QStringLiteral( "shading-material" ) );
163  if ( !elemTerrainShadingMaterial.isNull() )
164  mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial, context );
165  mTerrainMapTheme = elemTerrain.attribute( QStringLiteral( "map-theme" ) );
166  mShowLabels = elemTerrain.attribute( QStringLiteral( "show-labels" ), QStringLiteral( "0" ) ).toInt();
167 
168  qDeleteAll( mLightSources );
169  mLightSources.clear();
170  const QDomElement lightsElem = elem.firstChildElement( QStringLiteral( "lights" ) );
171  if ( !lightsElem.isNull() )
172  {
173  const QDomNodeList lightNodes = lightsElem.childNodes();
174  for ( int i = 0; i < lightNodes.size(); ++i )
175  {
176  const QDomElement lightElement = lightNodes.at( i ).toElement();
177  if ( QgsLightSource *light = QgsLightSource::createFromXml( lightElement, context ) )
178  mLightSources << light;
179  }
180  }
181  else
182  {
183  // older project format
184  QDomElement elemPointLights = elem.firstChildElement( QStringLiteral( "point-lights" ) );
185  if ( !elemPointLights.isNull() )
186  {
187  QDomElement elemPointLight = elemPointLights.firstChildElement( QStringLiteral( "point-light" ) );
188  while ( !elemPointLight.isNull() )
189  {
190  std::unique_ptr< QgsPointLightSettings > pointLight = std::make_unique< QgsPointLightSettings >();
191  pointLight->readXml( elemPointLight, context );
192  mLightSources << pointLight.release();
193  elemPointLight = elemPointLight.nextSiblingElement( QStringLiteral( "point-light" ) );
194  }
195  }
196  else
197  {
198  // QGIS <= 3.4 did not have light configuration
199  std::unique_ptr< QgsPointLightSettings > defaultLight = std::make_unique< QgsPointLightSettings >();
200  defaultLight->setPosition( QgsVector3D( 0, 1000, 0 ) );
201  mLightSources << defaultLight.release();
202  }
203 
204  QDomElement elemDirectionalLights = elem.firstChildElement( QStringLiteral( "directional-lights" ) );
205  if ( !elemDirectionalLights.isNull() )
206  {
207  QDomElement elemDirectionalLight = elemDirectionalLights.firstChildElement( QStringLiteral( "directional-light" ) );
208  while ( !elemDirectionalLight.isNull() )
209  {
210  std::unique_ptr< QgsDirectionalLightSettings > directionalLight = std::make_unique< QgsDirectionalLightSettings >();
211  directionalLight->readXml( elemDirectionalLight, context );
212  mLightSources << directionalLight.release();
213  elemDirectionalLight = elemDirectionalLight.nextSiblingElement( QStringLiteral( "directional-light" ) );
214  }
215  }
216  }
217 
218  QDomElement elemMapLayers = elemTerrain.firstChildElement( QStringLiteral( "layers" ) );
219  QDomElement elemMapLayer = elemMapLayers.firstChildElement( QStringLiteral( "layer" ) );
220  QList<QgsMapLayerRef> mapLayers;
221  while ( !elemMapLayer.isNull() )
222  {
223  mapLayers << QgsMapLayerRef( elemMapLayer.attribute( QStringLiteral( "id" ) ) );
224  elemMapLayer = elemMapLayer.nextSiblingElement( QStringLiteral( "layer" ) );
225  }
226  mLayers = mapLayers; // needs to resolve refs afterwards
227 
228  QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( QStringLiteral( "generator" ) );
229  QString terrainGenType = elemTerrainGenerator.attribute( QStringLiteral( "type" ) );
230  if ( terrainGenType == QLatin1String( "dem" ) )
231  {
232  QgsDemTerrainGenerator *demTerrainGenerator = new QgsDemTerrainGenerator;
233  demTerrainGenerator->setCrs( mCrs, mTransformContext );
234  setTerrainGenerator( demTerrainGenerator );
235  }
236  else if ( terrainGenType == QLatin1String( "online" ) )
237  {
238  QgsOnlineTerrainGenerator *onlineTerrainGenerator = new QgsOnlineTerrainGenerator;
239  onlineTerrainGenerator->setCrs( mCrs, mTransformContext );
240  setTerrainGenerator( onlineTerrainGenerator );
241  }
242  else if ( terrainGenType == QLatin1String( "mesh" ) )
243  {
244  QgsMeshTerrainGenerator *meshTerrainGenerator = new QgsMeshTerrainGenerator;
245  meshTerrainGenerator->setCrs( mCrs, mTransformContext );
246  setTerrainGenerator( meshTerrainGenerator );
247  }
248  else // "flat"
249  {
251  flatGen->setCrs( mCrs );
252  setTerrainGenerator( flatGen );
253  }
254  mTerrainGenerator->readXml( elemTerrainGenerator );
255 
256  qDeleteAll( mRenderers );
257  mRenderers.clear();
258 
259  QDomElement elemRenderers = elem.firstChildElement( QStringLiteral( "renderers" ) );
260  QDomElement elemRenderer = elemRenderers.firstChildElement( QStringLiteral( "renderer" ) );
261  while ( !elemRenderer.isNull() )
262  {
263  QgsAbstract3DRenderer *renderer = nullptr;
264  QString type = elemRenderer.attribute( QStringLiteral( "type" ) );
265  if ( type == QLatin1String( "vector" ) )
266  {
267  renderer = new QgsVectorLayer3DRenderer;
268  }
269  else if ( type == QLatin1String( "mesh" ) )
270  {
271  renderer = new QgsMeshLayer3DRenderer;
272  }
273  else if ( type == QLatin1String( "pointcloud" ) )
274  {
275  renderer = new QgsPointCloudLayer3DRenderer;
276  }
277 
278  if ( renderer )
279  {
280  renderer->readXml( elemRenderer, context );
281  mRenderers.append( renderer );
282  }
283  elemRenderer = elemRenderer.nextSiblingElement( QStringLiteral( "renderer" ) );
284  }
285 
286  QDomElement elemSkybox = elem.firstChildElement( QStringLiteral( "skybox" ) );
287  mIsSkyboxEnabled = elemSkybox.attribute( QStringLiteral( "skybox-enabled" ) ).toInt();
288  mSkyboxSettings.readXml( elemSkybox, context );
289 
290  QDomElement elemShadows = elem.firstChildElement( QStringLiteral( "shadow-rendering" ) );
291  mShadowSettings.readXml( elemShadows, context );
292 
293  QDomElement elemEyeDomeLighting = elem.firstChildElement( QStringLiteral( "eye-dome-lighting" ) );
294  mEyeDomeLightingEnabled = elemEyeDomeLighting.attribute( "enabled", QStringLiteral( "0" ) ).toInt();
295  mEyeDomeLightingStrength = elemEyeDomeLighting.attribute( "eye-dome-lighting-strength", QStringLiteral( "1000.0" ) ).toDouble();
296  mEyeDomeLightingDistance = elemEyeDomeLighting.attribute( "eye-dome-lighting-distance", QStringLiteral( "1" ) ).toInt();
297 
298  QDomElement elemNavigationSync = elem.firstChildElement( QStringLiteral( "navigation-sync" ) );
299  mViewSyncMode = ( Qgis::ViewSyncModeFlags )( elemNavigationSync.attribute( QStringLiteral( "view-sync-mode" ), QStringLiteral( "0" ) ).toInt() );
300  mVisualizeViewFrustum = elemNavigationSync.attribute( QStringLiteral( "view-frustum-visualization-enabled" ), QStringLiteral( "0" ) ).toInt();
301 
302  QDomElement elemDebugSettings = elem.firstChildElement( QStringLiteral( "debug-settings" ) );
303  mDebugShadowMapEnabled = elemDebugSettings.attribute( QStringLiteral( "shadowmap-enabled" ), QStringLiteral( "0" ) ).toInt();
304  mDebugShadowMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( QStringLiteral( "shadowmap-corner" ), "0" ).toInt() );
305  mDebugShadowMapSize = elemDebugSettings.attribute( QStringLiteral( "shadowmap-size" ), QStringLiteral( "0.2" ) ).toDouble();
306 
307  mDebugDepthMapEnabled = elemDebugSettings.attribute( QStringLiteral( "depthmap-enabled" ), QStringLiteral( "0" ) ).toInt();
308  mDebugDepthMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( QStringLiteral( "depthmap-corner" ), QStringLiteral( "1" ) ).toInt() );
309  mDebugDepthMapSize = elemDebugSettings.attribute( QStringLiteral( "depthmap-size" ), QStringLiteral( "0.2" ) ).toDouble();
310 
311  QDomElement elemDebug = elem.firstChildElement( QStringLiteral( "debug" ) );
312  mShowTerrainBoundingBoxes = elemDebug.attribute( QStringLiteral( "bounding-boxes" ), QStringLiteral( "0" ) ).toInt();
313  mShowTerrainTileInfo = elemDebug.attribute( QStringLiteral( "terrain-tile-info" ), QStringLiteral( "0" ) ).toInt();
314  mShowCameraViewCenter = elemDebug.attribute( QStringLiteral( "camera-view-center" ), QStringLiteral( "0" ) ).toInt();
315  mShowCameraRotationCenter = elemDebug.attribute( QStringLiteral( "camera-rotation-center" ), QStringLiteral( "0" ) ).toInt();
316  mShowLightSources = elemDebug.attribute( QStringLiteral( "show-light-sources" ), QStringLiteral( "0" ) ).toInt();
317  mIsFpsCounterEnabled = elemDebug.attribute( QStringLiteral( "show-fps-counter" ), QStringLiteral( "0" ) ).toInt();
318 
319  QDomElement elemTemporalRange = elem.firstChildElement( QStringLiteral( "temporal-range" ) );
320  QDateTime start = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "start" ) ), Qt::ISODate );
321  QDateTime end = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "end" ) ), Qt::ISODate );
322  setTemporalRange( QgsDateTimeRange( start, end ) );
323 
324  QDomElement elem3dAxis = elem.firstChildElement( QStringLiteral( "axis3d" ) );
325  m3dAxisSettings.readXml( elem3dAxis, context );
326 
327 }
328 
329 QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const
330 {
331  QDomElement elem = doc.createElement( QStringLiteral( "qgis3d" ) );
332 
333  QDomElement elemOrigin = doc.createElement( QStringLiteral( "origin" ) );
334  elemOrigin.setAttribute( QStringLiteral( "x" ), QString::number( mOrigin.x() ) );
335  elemOrigin.setAttribute( QStringLiteral( "y" ), QString::number( mOrigin.y() ) );
336  elemOrigin.setAttribute( QStringLiteral( "z" ), QString::number( mOrigin.z() ) );
337  elem.appendChild( elemOrigin );
338 
339  QDomElement elemCamera = doc.createElement( QStringLiteral( "camera" ) );
340  elemCamera.setAttribute( QStringLiteral( "field-of-view" ), mFieldOfView );
341  elemCamera.setAttribute( QStringLiteral( "projection-type" ), static_cast< int >( mProjectionType ) );
342  switch ( mCameraNavigationMode )
343  {
345  elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "terrain-based-navigation" ) );
346  break;
348  elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "walk-navigation" ) );
349  break;
350  }
351  elemCamera.setAttribute( QStringLiteral( "camera-movement-speed" ), mCameraMovementSpeed );
352  elem.appendChild( elemCamera );
353 
354  QDomElement elemColor = doc.createElement( QStringLiteral( "color" ) );
355  elemColor.setAttribute( QStringLiteral( "background" ), QgsSymbolLayerUtils::encodeColor( mBackgroundColor ) );
356  elemColor.setAttribute( QStringLiteral( "selection" ), QgsSymbolLayerUtils::encodeColor( mSelectionColor ) );
357  elem.appendChild( elemColor );
358 
359  QDomElement elemCrs = doc.createElement( QStringLiteral( "crs" ) );
360  mCrs.writeXml( elemCrs, doc );
361  elem.appendChild( elemCrs );
362 
363  QDomElement elemTerrain = doc.createElement( QStringLiteral( "terrain" ) );
364  elemTerrain.setAttribute( QStringLiteral( "terrain-rendering-enabled" ), mTerrainRenderingEnabled ? 1 : 0 );
365  elemTerrain.setAttribute( QStringLiteral( "exaggeration" ), QString::number( mTerrainVerticalScale ) );
366  elemTerrain.setAttribute( QStringLiteral( "texture-size" ), mMapTileResolution );
367  elemTerrain.setAttribute( QStringLiteral( "max-terrain-error" ), QString::number( mMaxTerrainScreenError ) );
368  elemTerrain.setAttribute( QStringLiteral( "max-ground-error" ), QString::number( mMaxTerrainGroundError ) );
369  elemTerrain.setAttribute( QStringLiteral( "shading-enabled" ), mTerrainShadingEnabled ? 1 : 0 );
370  elemTerrain.setAttribute( QStringLiteral( "elevation-offset" ), mTerrainElevationOffset );
371 
372  QDomElement elemTerrainShadingMaterial = doc.createElement( QStringLiteral( "shading-material" ) );
373  mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial, context );
374  elemTerrain.appendChild( elemTerrainShadingMaterial );
375  elemTerrain.setAttribute( QStringLiteral( "map-theme" ), mTerrainMapTheme );
376  elemTerrain.setAttribute( QStringLiteral( "show-labels" ), mShowLabels ? 1 : 0 );
377 
378  {
379  QDomElement elemLights = doc.createElement( QStringLiteral( "lights" ) );
380  for ( const QgsLightSource *light : mLightSources )
381  {
382  const QDomElement elemLight = light->writeXml( doc, context );
383  elemLights.appendChild( elemLight );
384  }
385  elem.appendChild( elemLights );
386  }
387 
388  QDomElement elemMapLayers = doc.createElement( QStringLiteral( "layers" ) );
389  for ( const QgsMapLayerRef &layerRef : mLayers )
390  {
391  QDomElement elemMapLayer = doc.createElement( QStringLiteral( "layer" ) );
392  elemMapLayer.setAttribute( QStringLiteral( "id" ), layerRef.layerId );
393  elemMapLayers.appendChild( elemMapLayer );
394  }
395  elemTerrain.appendChild( elemMapLayers );
396 
397  QDomElement elemTerrainGenerator = doc.createElement( QStringLiteral( "generator" ) );
398  elemTerrainGenerator.setAttribute( QStringLiteral( "type" ), QgsTerrainGenerator::typeToString( mTerrainGenerator->type() ) );
399  mTerrainGenerator->writeXml( elemTerrainGenerator );
400  elemTerrain.appendChild( elemTerrainGenerator );
401  elem.appendChild( elemTerrain );
402 
403  QDomElement elemRenderers = doc.createElement( QStringLiteral( "renderers" ) );
404  for ( const QgsAbstract3DRenderer *renderer : mRenderers )
405  {
406  QDomElement elemRenderer = doc.createElement( QStringLiteral( "renderer" ) );
407  elemRenderer.setAttribute( QStringLiteral( "type" ), renderer->type() );
408  renderer->writeXml( elemRenderer, context );
409  elemRenderers.appendChild( elemRenderer );
410  }
411  elem.appendChild( elemRenderers );
412 
413  QDomElement elemSkybox = doc.createElement( QStringLiteral( "skybox" ) );
414  elemSkybox.setAttribute( QStringLiteral( "skybox-enabled" ), mIsSkyboxEnabled );
415  mSkyboxSettings.writeXml( elemSkybox, context );
416  elem.appendChild( elemSkybox );
417 
418  QDomElement elemShadows = doc.createElement( QStringLiteral( "shadow-rendering" ) );
419  mShadowSettings.writeXml( elemShadows, context );
420  elem.appendChild( elemShadows );
421 
422  QDomElement elemDebug = doc.createElement( QStringLiteral( "debug" ) );
423  elemDebug.setAttribute( QStringLiteral( "bounding-boxes" ), mShowTerrainBoundingBoxes ? 1 : 0 );
424  elemDebug.setAttribute( QStringLiteral( "terrain-tile-info" ), mShowTerrainTileInfo ? 1 : 0 );
425  elemDebug.setAttribute( QStringLiteral( "camera-view-center" ), mShowCameraViewCenter ? 1 : 0 );
426  elemDebug.setAttribute( QStringLiteral( "camera-rotation-center" ), mShowCameraRotationCenter ? 1 : 0 );
427  elemDebug.setAttribute( QStringLiteral( "show-light-sources" ), mShowLightSources ? 1 : 0 );
428  elemDebug.setAttribute( QStringLiteral( "show-fps-counter" ), mIsFpsCounterEnabled ? 1 : 0 );
429  elem.appendChild( elemDebug );
430 
431  QDomElement elemEyeDomeLighting = doc.createElement( QStringLiteral( "eye-dome-lighting" ) );
432  elemEyeDomeLighting.setAttribute( QStringLiteral( "enabled" ), mEyeDomeLightingEnabled ? 1 : 0 );
433  elemEyeDomeLighting.setAttribute( QStringLiteral( "eye-dome-lighting-strength" ), mEyeDomeLightingStrength );
434  elemEyeDomeLighting.setAttribute( QStringLiteral( "eye-dome-lighting-distance" ), mEyeDomeLightingDistance );
435  elem.appendChild( elemEyeDomeLighting );
436 
437  QDomElement elemNavigationSync = doc.createElement( QStringLiteral( "navigation-sync" ) );
438  elemNavigationSync.setAttribute( QStringLiteral( "view-sync-mode" ), ( int )mViewSyncMode );
439  elemNavigationSync.setAttribute( QStringLiteral( "view-frustum-visualization-enabled" ), mVisualizeViewFrustum ? 1 : 0 );
440  elem.appendChild( elemNavigationSync );
441 
442  QDomElement elemDebugSettings = doc.createElement( QStringLiteral( "debug-settings" ) );
443  elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-enabled" ), mDebugShadowMapEnabled );
444  elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-corner" ), mDebugShadowMapCorner );
445  elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-size" ), mDebugShadowMapSize );
446  elemDebugSettings.setAttribute( QStringLiteral( "depthmap-enabled" ), mDebugDepthMapEnabled );
447  elemDebugSettings.setAttribute( QStringLiteral( "depthmap-corner" ), mDebugDepthMapCorner );
448  elemDebugSettings.setAttribute( QStringLiteral( "depthmap-size" ), mDebugDepthMapSize );
449  elem.appendChild( elemDebugSettings );
450 
451  QDomElement elemTemporalRange = doc.createElement( QStringLiteral( "temporal-range" ) );
452  elemTemporalRange.setAttribute( QStringLiteral( "start" ), temporalRange().begin().toString( Qt::ISODate ) );
453  elemTemporalRange.setAttribute( QStringLiteral( "end" ), temporalRange().end().toString( Qt::ISODate ) );
454 
455  QDomElement elem3dAxis = doc.createElement( QStringLiteral( "axis3d" ) );
456  m3dAxisSettings.writeXml( elem3dAxis, context );
457  elem.appendChild( elem3dAxis );
458 
459  return elem;
460 }
461 
463 {
464  for ( int i = 0; i < mLayers.count(); ++i )
465  {
466  QgsMapLayerRef &layerRef = mLayers[i];
467  layerRef.setLayer( project.mapLayer( layerRef.layerId ) );
468  }
469 
470  mTerrainGenerator->resolveReferences( project );
471 
472  for ( int i = 0; i < mRenderers.count(); ++i )
473  {
474  QgsAbstract3DRenderer *renderer = mRenderers[i];
475  renderer->resolveReferences( project );
476  }
477 }
478 
480 {
481  return Qgs3DUtils::mapToWorldCoordinates( mapCoords, mOrigin );
482 }
483 
485 {
486  return Qgs3DUtils::worldToMapCoordinates( worldCoords, mOrigin );
487 }
488 
490 {
491  mCrs = crs;
492 }
493 
495 {
496  return mTransformContext;
497 }
498 
500 {
501  mTransformContext = context;
502 }
503 
504 void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
505 {
506  if ( color == mBackgroundColor )
507  return;
508 
509  mBackgroundColor = color;
510  emit backgroundColorChanged();
511 }
512 
514 {
515  return mBackgroundColor;
516 }
517 
518 void Qgs3DMapSettings::setSelectionColor( const QColor &color )
519 {
520  if ( color == mSelectionColor )
521  return;
522 
523  mSelectionColor = color;
524  emit selectionColorChanged();
525 }
526 
528 {
529  return mSelectionColor;
530 }
531 
533 {
534  if ( zScale == mTerrainVerticalScale )
535  return;
536 
537  mTerrainVerticalScale = zScale;
539 }
540 
542 {
543  return mTerrainVerticalScale;
544 }
545 
546 void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
547 {
548  QList<QgsMapLayerRef> lst;
549  lst.reserve( layers.count() );
550  for ( QgsMapLayer *layer : layers )
551  {
552  lst.append( layer );
553  }
554 
555  if ( mLayers == lst )
556  return;
557 
558  mLayers = lst;
559  emit layersChanged();
560 }
561 
562 QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
563 {
564  QList<QgsMapLayer *> lst;
565  lst.reserve( mLayers.count() );
566  for ( const QgsMapLayerRef &layerRef : mLayers )
567  {
568  if ( layerRef.layer )
569  lst.append( layerRef.layer );
570  }
571  return lst;
572 }
573 
575 {
576  if ( properties->terrainProvider()->type() == QLatin1String( "flat" ) )
577  {
579  flatTerrain->setCrs( crs() );
580  flatTerrain->setExtent( fullExtent );
581  setTerrainGenerator( flatTerrain );
582 
584  }
585  else if ( properties->terrainProvider()->type() == QLatin1String( "raster" ) )
586  {
587  QgsRasterDemTerrainProvider *rasterProvider = qgis::down_cast< QgsRasterDemTerrainProvider * >( properties->terrainProvider() );
588 
589  QgsDemTerrainGenerator *demTerrainGen = new QgsDemTerrainGenerator;
590  demTerrainGen->setCrs( crs(), QgsProject::instance()->transformContext() );
591  demTerrainGen->setLayer( rasterProvider->layer() );
592  setTerrainGenerator( demTerrainGen );
593 
595  setTerrainVerticalScale( properties->terrainProvider()->scale() );
596  }
597  else if ( properties->terrainProvider()->type() == QLatin1String( "mesh" ) )
598  {
599  QgsMeshTerrainProvider *meshProvider = qgis::down_cast< QgsMeshTerrainProvider * >( properties->terrainProvider() );
600 
601  QgsMeshTerrainGenerator *newTerrainGenerator = new QgsMeshTerrainGenerator;
602  newTerrainGenerator->setCrs( crs(), QgsProject::instance()->transformContext() );
603  newTerrainGenerator->setLayer( meshProvider->layer() );
604  std::unique_ptr< QgsMesh3DSymbol > symbol( newTerrainGenerator->symbol()->clone() );
605  symbol->setVerticalScale( properties->terrainProvider()->scale() );
606  newTerrainGenerator->setSymbol( symbol.release() );
607  setTerrainGenerator( newTerrainGenerator );
608 
610  setTerrainVerticalScale( properties->terrainProvider()->scale() );
611  }
612  else
613  {
615  flatTerrain->setCrs( crs() );
616  flatTerrain->setExtent( fullExtent );
617  setTerrainGenerator( flatTerrain );
618  }
619 }
620 
622 {
623  if ( mMapTileResolution == res )
624  return;
625 
626  mMapTileResolution = res;
628 }
629 
631 {
632  return mMapTileResolution;
633 }
634 
636 {
637  if ( mMaxTerrainScreenError == error )
638  return;
639 
640  mMaxTerrainScreenError = error;
642 }
643 
645 {
646  return mMaxTerrainScreenError;
647 }
648 
650 {
651  if ( mMaxTerrainGroundError == error )
652  return;
653 
654  mMaxTerrainGroundError = error;
656 }
657 
659 {
660  if ( mTerrainElevationOffset == offset )
661  return;
662  mTerrainElevationOffset = offset;
663  emit terrainElevationOffsetChanged( mTerrainElevationOffset );
664 }
665 
667 {
668  return mMaxTerrainGroundError;
669 }
670 
672 {
673  if ( mTerrainGenerator )
674  {
675  disconnect( mTerrainGenerator.get(), &QgsTerrainGenerator::extentChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
676  disconnect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
677  }
678 
679  mTerrainGenerator.reset( gen );
680  connect( mTerrainGenerator.get(), &QgsTerrainGenerator::extentChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
681  connect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
682 
684 }
685 
687 {
688  if ( mTerrainShadingEnabled == enabled )
689  return;
690 
691  mTerrainShadingEnabled = enabled;
692  emit terrainShadingChanged();
693 }
694 
696 {
697  if ( mTerrainShadingMaterial == material )
698  return;
699 
700  mTerrainShadingMaterial = material;
701  emit terrainShadingChanged();
702 }
703 
704 void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
705 {
706  if ( mTerrainMapTheme == theme )
707  return;
708 
709  mTerrainMapTheme = theme;
710  emit terrainMapThemeChanged();
711 }
712 
713 void Qgs3DMapSettings::setRenderers( const QList<QgsAbstract3DRenderer *> &renderers )
714 {
715  qDeleteAll( mRenderers );
716 
717  mRenderers = renderers;
718 
719  emit renderersChanged();
720 }
721 
723 {
724  if ( mShowTerrainBoundingBoxes == enabled )
725  return;
726 
727  mShowTerrainBoundingBoxes = enabled;
729 }
730 
732 {
733  if ( mShowTerrainTileInfo == enabled )
734  return;
735 
736  mShowTerrainTileInfo = enabled;
738 }
739 
741 {
742  if ( mShowCameraViewCenter == enabled )
743  return;
744 
745  mShowCameraViewCenter = enabled;
747 }
748 
750 {
751  if ( mShowCameraRotationCenter == enabled )
752  return;
753 
754  mShowCameraRotationCenter = enabled;
756 }
757 
758 
760 {
761  if ( mShowLightSources == enabled )
762  return;
763 
764  mShowLightSources = enabled;
766 }
767 
769 {
770  if ( mShowLabels == enabled )
771  return;
772 
773  mShowLabels = enabled;
774  emit showLabelsChanged();
775 }
776 
778 {
779  if ( mEyeDomeLightingEnabled == enabled )
780  return;
781  mEyeDomeLightingEnabled = enabled;
783 }
784 
786 {
787  if ( mEyeDomeLightingStrength == strength )
788  return;
789  mEyeDomeLightingStrength = strength;
791 }
792 
794 {
795  if ( mEyeDomeLightingDistance == distance )
796  return;
797  mEyeDomeLightingDistance = distance;
799 }
800 
801 QList<QgsLightSource *> Qgs3DMapSettings::lightSources() const
802 {
803  return mLightSources;
804 }
805 
806 void Qgs3DMapSettings::setLightSources( const QList<QgsLightSource *> &lights )
807 {
808  qDeleteAll( mLightSources );
809  mLightSources = lights;
810 
812  emit pointLightsChanged();
813  emit lightSourcesChanged();
814 }
815 
816 void Qgs3DMapSettings::setFieldOfView( const float fieldOfView )
817 {
818  if ( mFieldOfView == fieldOfView )
819  return;
820 
821  mFieldOfView = fieldOfView;
822  emit fieldOfViewChanged();
823 }
824 
825 void Qgs3DMapSettings::setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType )
826 {
827  if ( mProjectionType == projectionType )
828  return;
829 
830  mProjectionType = projectionType;
831  emit projectionTypeChanged();
832 }
833 
835 {
836  if ( mCameraNavigationMode == navigationMode )
837  return;
838 
839  mCameraNavigationMode = navigationMode;
841 }
842 
843 void Qgs3DMapSettings::setCameraMovementSpeed( double movementSpeed )
844 {
845  if ( mCameraMovementSpeed == movementSpeed )
846  return;
847 
848  mCameraMovementSpeed = movementSpeed;
850 }
851 
853 {
854  mSkyboxSettings = skyboxSettings;
855  emit skyboxSettingsChanged();
856 }
857 
859 {
860  mShadowSettings = shadowSettings;
861  emit shadowSettingsChanged();
862 }
863 
864 void Qgs3DMapSettings::setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size )
865 {
866  mDebugShadowMapEnabled = enabled;
867  mDebugShadowMapCorner = corner;
868  mDebugShadowMapSize = size;
870 }
871 
872 void Qgs3DMapSettings::setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size )
873 {
874  mDebugDepthMapEnabled = enabled;
875  mDebugDepthMapCorner = corner;
876  mDebugDepthMapSize = size;
878 }
879 
880 void Qgs3DMapSettings::setIsFpsCounterEnabled( bool fpsCounterEnabled )
881 {
882  if ( fpsCounterEnabled == mIsFpsCounterEnabled )
883  return;
884  mIsFpsCounterEnabled = fpsCounterEnabled;
885  emit fpsCounterEnabledChanged( mIsFpsCounterEnabled );
886 }
887 
888 void Qgs3DMapSettings::setTerrainRenderingEnabled( bool terrainRenderingEnabled )
889 {
890  if ( terrainRenderingEnabled == mTerrainRenderingEnabled )
891  return;
892  mTerrainRenderingEnabled = terrainRenderingEnabled;
894 }
895 
897 {
898  return mRendererUsage;
899 }
900 
902 {
903  mRendererUsage = rendererUsage;
904 }
905 
906 void Qgs3DMapSettings::setViewSyncMode( Qgis::ViewSyncModeFlags mode )
907 {
908  mViewSyncMode = mode;
909 }
910 
912 {
913  if ( mVisualizeViewFrustum != enabled )
914  {
915  mVisualizeViewFrustum = enabled;
917  }
918 }
919 
920 void Qgs3DMapSettings::setIsDebugOverlayEnabled( bool debugOverlayEnabled )
921 {
922  if ( debugOverlayEnabled == mIsDebugOverlayEnabled )
923  return;
924 
925  mIsDebugOverlayEnabled = debugOverlayEnabled;
926  emit debugOverlayEnabledChanged( mIsDebugOverlayEnabled );
927 }
928 
929 
930 void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
931 {
962 }
963 
964 
966 {
967  m3dAxisSettings = axisSettings;
968  emit axisSettingsChanged();
969 }
Qgs3DMapSettings::backgroundColorChanged
void backgroundColorChanged()
Emitted when the background color has changed.
Qgs3DMapSettings::cameraMovementSpeedChanged
void cameraMovementSpeedChanged()
Emitted when the camera movement speed was changed.
Qgs3DMapSettings::crs
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used in the 3D scene.
Definition: qgs3dmapsettings.h:99
QgsSymbolLayerUtils::encodeColor
static QString encodeColor(const QColor &color)
Definition: qgssymbollayerutils.cpp:64
Qgs3DMapSettings::setEyeDomeLightingStrength
void setEyeDomeLightingStrength(double strength)
Sets the eye dome lighting strength value.
Definition: qgs3dmapsettings.cpp:785
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:57
qgsrasterlayer.h
Qgs3DMapSettings::setLayers
void setLayers(const QList< QgsMapLayer * > &layers)
Sets the list of 3D map layers to be rendered in the scene.
Definition: qgs3dmapsettings.cpp:546
QgsVectorLayer3DRenderer
3D renderer that renders all features of a vector layer with the same 3D symbol. The appearance is co...
Definition: qgsvectorlayer3drenderer.h:59
Qgs3DMapSettings::directionalLightsChanged
void directionalLightsChanged()
Emitted when the list of directional lights changes.
Qgs3DUtils::mapToWorldCoordinates
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,...
Definition: qgs3dutils.cpp:540
Qgs3DMapSettings::lightSources
QList< QgsLightSource * > lightSources() const
Returns list of directional light sources defined in the scene.
Definition: qgs3dmapsettings.cpp:801
QgsPhongMaterialSettings::writeXml
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes settings to a DOM element.
Definition: qgsphongmaterialsettings.cpp:76
Qgs3DMapSettings::setTerrainShadingMaterial
void setTerrainShadingMaterial(const QgsPhongMaterialSettings &material)
Sets terrain shading material.
Definition: qgs3dmapsettings.cpp:695
Qgs3DMapSettings::projectionTypeChanged
void projectionTypeChanged()
Emitted when the camera lens projection type changes.
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
Qgs3DMapSettings::worldToMapCoordinates
QgsVector3D worldToMapCoordinates(const QgsVector3D &worldCoords) const
Converts 3D world coordinates to map coordinates (applies offset and turns (x,y,z) into (x,...
Definition: qgs3dmapsettings.cpp:484
Qgs3DMapSettings::selectionColor
QColor selectionColor() const
Returns color used for selected features.
Definition: qgs3dmapsettings.cpp:527
Qgs3DMapSettings::setProjectionType
void setProjectionType(const Qt3DRender::QCameraLens::ProjectionType projectionType)
Sets the camera lens' projection type.
Definition: qgs3dmapsettings.cpp:825
QgsFlatTerrainGenerator::setExtent
void setExtent(const QgsRectangle &extent) override
sets the extent of the terrain in terrain's CRS
Definition: qgsflatterraingenerator.cpp:143
Qgs3DMapSettings::setTerrainGenerator
void setTerrainGenerator(QgsTerrainGenerator *gen)
Sets terrain generator.
Definition: qgs3dmapsettings.cpp:671
Qgs3DMapSettings::maxTerrainGroundError
float maxTerrainGroundError() const
Returns maximum ground error of terrain tiles in world units.
Definition: qgs3dmapsettings.cpp:666
Qgs3DAxisSettings::readXml
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
Definition: qgs3daxissettings.cpp:53
QgsMeshTerrainProvider::layer
QgsMeshLayer * layer() const
Returns the mesh layer to be used as the terrain source.
Definition: qgsterrainprovider.cpp:320
QgsTerrainGenerator::extentChanged
void extentChanged()
Emitted when the terrain extent has changed.
QgsVector3D::y
double y() const
Returns Y coordinate.
Definition: qgsvector3d.h:64
Qgs3DMapSettings::terrainRenderingEnabled
bool terrainRenderingEnabled() const
Returns whether the 2D terrain surface will be rendered.
Definition: qgs3dmapsettings.h:578
QgsAbstract3DRenderer
Base class for all renderers that may to participate in 3D view.
Definition: qgsabstract3drenderer.h:48
QgsVector3D
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition: qgsvector3d.h:31
Qgs3DMapSettings::rendererUsage
Qgis::RendererUsage rendererUsage() const
Returns the renderer usage.
Definition: qgs3dmapsettings.cpp:896
Qgs3DMapSettings::showLightSourceOriginsChanged
void showLightSourceOriginsChanged()
Emitted when the flag whether light source origins are shown has changed.
Qgs3DMapSettings::mapTileResolution
int mapTileResolution() const
Returns resolution (in pixels) of the texture of a terrain tile.
Definition: qgs3dmapsettings.cpp:630
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsCameraController::WalkNavigation
@ WalkNavigation
Uses WASD keys or arrows to navigate in walking (first person) manner.
Definition: qgscameracontroller.h:72
Qgs3DMapSettings::setEyeDomeLightingDistance
void setEyeDomeLightingDistance(int distance)
Sets the eye dome lighting distance value (contributes to the contrast of the image.
Definition: qgs3dmapsettings.cpp:793
Qgs3DMapSettings::showCameraViewCenterChanged
void showCameraViewCenterChanged()
Emitted when the flag whether camera's view center is shown has changed.
qgssymbollayerutils.h
Qgs3DMapSettings::setCameraMovementSpeed
void setCameraMovementSpeed(double movementSpeed)
Sets the camera movement speed.
Definition: qgs3dmapsettings.cpp:843
QgsTemporalRangeObject::temporalRange
const QgsDateTimeRange & temporalRange() const
Returns the datetime range for the object.
Definition: qgstemporalrangeobject.cpp:43
QgsSkyboxSettings
Contains the configuration of a skybox entity.
Definition: qgsskyboxsettings.h:36
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:480
Qgs3DMapSettings::mapTileResolutionChanged
void mapTileResolutionChanged()
Emitted when the map tile resoulution has changed.
qgsdemterraingenerator.h
Qgs3DMapSettings::fpsCounterEnabledChanged
void fpsCounterEnabledChanged(bool fpsCounterEnabled)
Emitted when the FPS counter is enabled or disabled.
QgsMapLayerRef
_LayerRef< QgsMapLayer > QgsMapLayerRef
Definition: qgsmaplayerref.h:295
Qgs3DMapSettings::debugOverlayEnabledChanged
void debugOverlayEnabledChanged(bool debugOverlayEnabled)
Emitted when the debug overaly is enabled or disabled.
Qgs3DMapSettings::resolveReferences
void resolveReferences(const QgsProject &project)
Resolves references to other objects (map layers) after the call to readXml()
Definition: qgs3dmapsettings.cpp:462
QgsProjectElevationProperties
Contains elevation properties for a QgsProject.
Definition: qgsprojectelevationproperties.h:38
Qgs3DMapSettings::terrainGeneratorChanged
void terrainGeneratorChanged()
Emitted when the terrain generator has changed.
QgsProject::mapLayer
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
Definition: qgsproject.cpp:3680
Qgs3DMapSettings::setSelectionColor
void setSelectionColor(const QColor &color)
Sets color used for selected features.
Definition: qgs3dmapsettings.cpp:518
Qgs3DMapSettings::configureTerrainFromProject
void configureTerrainFromProject(QgsProjectElevationProperties *properties, const QgsRectangle &fullExtent)
Configures the map's terrain settings directly from a project's elevation properties.
Definition: qgs3dmapsettings.cpp:574
QgsCoordinateReferenceSystem::readXml
bool readXml(const QDomNode &node)
Restores state from the given DOM node.
Definition: qgscoordinatereferencesystem.cpp:1860
QgsSymbolLayerUtils::decodeColor
static QColor decodeColor(const QString &str)
Definition: qgssymbollayerutils.cpp:69
Qgs3DMapSettings::skyboxSettingsChanged
void skyboxSettingsChanged()
Emitted when skybox settings are changed.
Qgs3DMapSettings::transformContext
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
Definition: qgs3dmapsettings.cpp:494
Qgs3DMapSettings::setIsDebugOverlayEnabled
void setIsDebugOverlayEnabled(bool debugOverlayEnabled)
Sets whether debug overlay is enabled The debug overlay displays some debugging and profiling informa...
Definition: qgs3dmapsettings.cpp:920
Qgs3DMapSettings::renderersChanged
void renderersChanged()
Emitted when the list of map's extra renderers have been modified.
QgsMeshTerrainProvider
A terrain provider that uses the Z values of a mesh layer to build a terrain surface.
Definition: qgsterrainprovider.h:284
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Qgs3DMapSettings::setTerrainVerticalScale
void setTerrainVerticalScale(double zScale)
Sets vertical scale (exaggeration) of terrain (1 = true scale, > 1 = hills get more pronounced)
Definition: qgs3dmapsettings.cpp:532
QgsLightSource
Base class for light sources in 3d scenes.
Definition: qgslightsource.h:46
Qgs3DMapSettings::settingsChanged
void settingsChanged()
Emitted when one of the configuration settings has changed.
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:103
Qgs3DMapSettings::debugShadowMapSettingsChanged
void debugShadowMapSettingsChanged()
Emitted when shadow map debugging has changed.
QgsSkyboxSettings::writeXml
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.
Definition: qgsskyboxsettings.cpp:57
Qgs3DMapSettings::setLightSources
void setLightSources(const QList< QgsLightSource * > &lights)
Sets the list of light sources defined in the scene.
Definition: qgs3dmapsettings.cpp:806
QgsPhongMaterialSettings
Basic shading material used for rendering based on the Phong shading model with three color component...
Definition: qgsphongmaterialsettings.h:44
Qgs3DMapSettings::maxTerrainScreenErrorChanged
void maxTerrainScreenErrorChanged()
Emitted when the maximum terrain screen error has changed.
Qgs3DMapSettings::maxTerrainScreenError
float maxTerrainScreenError() const
Returns maximum allowed screen error of terrain tiles in pixels.
Definition: qgs3dmapsettings.cpp:644
QgsAbstract3DRenderer::readXml
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)=0
Reads renderer's properties from given XML element.
_LayerRef::layerId
QString layerId
Original layer ID.
Definition: qgsmaplayerref.h:117
QgsAbstractTerrainProvider::type
virtual QString type() const =0
Returns the unique type ID string for the provider.
Qgs3DMapSettings::projectionType
Qt3DRender::QCameraLens::ProjectionType projectionType() const
Returns the camera lens' projection type.
Definition: qgs3dmapsettings.h:471
QgsAbstract3DRenderer::resolveReferences
virtual void resolveReferences(const QgsProject &project)
Resolves references to other objects - second phase of loading - after readXml()
Definition: qgsabstract3drenderer.cpp:19
Qgs3DMapSettings::setIsFpsCounterEnabled
void setIsFpsCounterEnabled(bool fpsCounterEnabled)
Sets whether FPS counter label is enabled.
Definition: qgs3dmapsettings.cpp:880
Qgs3DMapSettings::debugDepthMapSettingsChanged
void debugDepthMapSettingsChanged()
Emitted when depth map debugging has changed.
Qgs3DMapSettings::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets coordinate reference system used in the 3D scene.
Definition: qgs3dmapsettings.cpp:489
qgsonlineterraingenerator.h
qgsmeshlayer3drenderer.h
QgsTerrainGenerator
Base class for generators of terrain.
Definition: qgsterraingenerator.h:49
_LayerRef::setLayer
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
Definition: qgsmaplayerref.h:78
Qgs3DMapSettings::setMaxTerrainGroundError
void setMaxTerrainGroundError(float error)
Returns maximum ground error of terrain tiles in world units.
Definition: qgs3dmapsettings.cpp:649
QgsCoordinateReferenceSystem::writeXml
bool writeXml(QDomNode &node, QDomDocument &doc) const
Stores state to the given Dom node in the given document.
Definition: qgscoordinatereferencesystem.cpp:1980
QgsSkyboxSettings::readXml
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
Definition: qgsskyboxsettings.cpp:39
QgsVector3D::z
double z() const
Returns Z coordinate.
Definition: qgsvector3d.h:66
qgs3dutils.h
Qgs3DMapSettings::setTerrainShadingEnabled
void setTerrainShadingEnabled(bool enabled)
Sets whether terrain shading is enabled.
Definition: qgs3dmapsettings.cpp:686
Qgs3DMapSettings::setDebugShadowMapSettings
void setDebugShadowMapSettings(bool enabled, Qt::Corner corner, double size)
Sets the debugging settings of the shadow map.
Definition: qgs3dmapsettings.cpp:864
Qgs3DMapSettings::setDebugDepthMapSettings
void setDebugDepthMapSettings(bool enabled, Qt::Corner corner, double size)
Sets the debugging settings of the depth map.
Definition: qgs3dmapsettings.cpp:872
Qgs3DMapSettings::backgroundColor
QColor backgroundColor() const
Returns background color of the 3D map view.
Definition: qgs3dmapsettings.cpp:513
QgsTerrainGenerator::typeToString
static QString typeToString(Type type)
Converts terrain generator type enumeration into a string.
Definition: qgsterraingenerator.cpp:61
Qgs3DMapSettings::terrainVerticalScaleChanged
void terrainVerticalScaleChanged()
Emitted when the vertical scale of the terrain has changed.
Qgs3DMapSettings::showCameraRotationCenterChanged
void showCameraRotationCenterChanged()
Emitted when the flag whether camera's rotation center is shown has changed.
Qgs3DMapSettings::setMapTileResolution
void setMapTileResolution(int res)
Sets resolution (in pixels) of the texture of a terrain tile.
Definition: qgs3dmapsettings.cpp:621
Qgs3DMapSettings::setTerrainRenderingEnabled
void setTerrainRenderingEnabled(bool terrainRenderingEnabled)
Sets whether the 2D terrain surface will be rendered in.
Definition: qgs3dmapsettings.cpp:888
QgsOnlineTerrainGenerator::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets CRS of the terrain.
Definition: qgsonlineterraingenerator.cpp:93
QgsPhongMaterialSettings::readXml
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads settings from a DOM element.
Definition: qgsphongmaterialsettings.cpp:65
Qgs3DMapSettings::eyeDomeLightingDistanceChanged
void eyeDomeLightingDistanceChanged()
Emitted when the eye dome lighting distance has changed.
QgsMeshLayer3DRenderer
3D renderer that renders all mesh triangles of a mesh layer.
Definition: qgsmeshlayer3drenderer.h:59
Qgs3DMapSettings::setRendererUsage
void setRendererUsage(Qgis::RendererUsage rendererUsage)
Sets the renderer usage.
Definition: qgs3dmapsettings.cpp:901
Qgs3DMapSettings
Definition of the world.
Definition: qgs3dmapsettings.h:57
Qgs3DAxisSettings
Contains the configuration of a 3d axis.
Definition: qgs3daxissettings.h:35
Qgs3DMapSettings::setViewSyncMode
void setViewSyncMode(Qgis::ViewSyncModeFlags mode)
Sets the view sync mode (used to synchronize the 2D main map canvas and the 3D camera navigation)
Definition: qgs3dmapsettings.cpp:906
QgsProject::setDirty
void setDirty(bool b=true)
Flag the project as dirty (modified).
Definition: qgsproject.cpp:576
Qgs3DMapSettings::setTransformContext
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which stores various information regarding which datum transfo...
Definition: qgs3dmapsettings.cpp:499
Qgs3DMapSettings::fieldOfView
float fieldOfView() const
Returns the camera lens' field of view.
Definition: qgs3dmapsettings.h:459
Qgs3DMapSettings::fieldOfViewChanged
void fieldOfViewChanged()
Emitted when the camera lens field of view changes.
Qgs3DMapSettings::eyeDomeLightingEnabledChanged
void eyeDomeLightingEnabledChanged()
Emitted when the flag whether eye dome lighting is used has changed.
QgsFlatTerrainGenerator
Terrain generator that creates a simple square flat area.
Definition: qgsflatterraingenerator.h:53
Qgs3DMapSettings::pointLightsChanged
void pointLightsChanged()
Emitted when the list of point lights changes.
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsShadowSettings::readXml
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
Definition: qgsshadowsettings.cpp:43
QgsProjectElevationProperties::terrainProvider
QgsAbstractTerrainProvider * terrainProvider()
Returns the project's terrain provider.
Definition: qgsprojectelevationproperties.cpp:84
Qgs3DMapSettings::shadowSettingsChanged
void shadowSettingsChanged()
Emitted when shadow rendering settings are changed.
QgsDemTerrainGenerator
Implementation of terrain generator that uses a raster layer with DEM to build terrain.
Definition: qgsdemterraingenerator.h:41
Qgs3DMapSettings::setFieldOfView
void setFieldOfView(const float fieldOfView)
Sets the camera lens' field of view.
Definition: qgs3dmapsettings.cpp:816
Qgs3DMapSettings::terrainShadingChanged
void terrainShadingChanged()
Emitted when terrain shading enabled flag or terrain shading material has changed.
qgs3dmapsettings.h
Qgs3DMapSettings::showTerrainBoundingBoxesChanged
void showTerrainBoundingBoxesChanged()
Emitted when the flag whether terrain's bounding boxes are shown has changed.
Qgs3DMapSettings::terrainElevationOffsetChanged
void terrainElevationOffsetChanged(float newElevation)
Emitted when the terrain elevation offset is changed.
QgsDemTerrainGenerator::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets CRS of the terrain.
Definition: qgsdemterraingenerator.cpp:39
Qgs3DMapSettings::shadowSettings
QgsShadowSettings shadowSettings() const
Returns the current configuration of shadows.
Definition: qgs3dmapsettings.h:531
QgsDemTerrainGenerator::setLayer
void setLayer(QgsRasterLayer *layer)
Sets raster layer with elevation model to be used for terrain generation.
Definition: qgsdemterraingenerator.cpp:28
Qgs3DAxisSettings::writeXml
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.
Definition: qgs3daxissettings.cpp:80
Qgs3DMapSettings::eyeDomeLightingStrengthChanged
void eyeDomeLightingStrengthChanged()
Emitted when the eye dome lighting strength has changed.
Qgs3DMapSettings::~Qgs3DMapSettings
~Qgs3DMapSettings() override
Definition: qgs3dmapsettings.cpp:115
QgsShadowSettings::writeXml
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.
Definition: qgsshadowsettings.cpp:53
Qgs3DMapSettings::setShowCameraViewCenter
void setShowCameraViewCenter(bool enabled)
Sets whether to show camera's view center as a sphere (for debugging)
Definition: qgs3dmapsettings.cpp:740
Qgs3DMapSettings::setShowLabels
void setShowLabels(bool enabled)
Sets whether to display labels on terrain tiles.
Definition: qgs3dmapsettings.cpp:768
Qgs3DMapSettings::setTerrainElevationOffset
void setTerrainElevationOffset(float offset)
Sets the terrain elevation offset (used to move the terrain up or down)
Definition: qgs3dmapsettings.cpp:658
QgsProjectDirtyBlocker
Temporarily blocks QgsProject "dirtying" for the lifetime of the object.
Definition: qgsproject.h:2319
Qgs3DMapSettings::setShowCameraRotationCenter
void setShowCameraRotationCenter(bool enabled)
Sets whether to show camera's rotation center as a sphere (for debugging)
Definition: qgs3dmapsettings.cpp:749
QgsFlatTerrainGenerator::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets CRS of the terrain.
Definition: qgsflatterraingenerator.cpp:137
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
Qgs3DMapSettings::layers
QList< QgsMapLayer * > layers() const
Returns the list of 3D map layers to be rendered in the scene.
Definition: qgs3dmapsettings.cpp:562
Qgs3DMapSettings::viewFrustumVisualizationEnabledChanged
void viewFrustumVisualizationEnabledChanged()
Emitted when the camera's view frustum visualization on the main 2D map canvas is enabled or disabled...
QgsOnlineTerrainGenerator
Implementation of terrain generator that uses online resources to download heightmaps.
Definition: qgsonlineterraingenerator.h:37
Qgs3DMapSettings::setRenderers
void setRenderers(const QList< QgsAbstract3DRenderer * > &renderers)
Sets list of extra 3D renderers to use in the scene. Takes ownership of the objects.
Definition: qgs3dmapsettings.cpp:713
Qgs3DMapSettings::renderers
QList< QgsAbstract3DRenderer * > renderers() const
Returns list of extra 3D renderers.
Definition: qgs3dmapsettings.h:333
Qgs3DMapSettings::writeXml
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a DOM element, to be used later with readXml()
Definition: qgs3dmapsettings.cpp:329
QgsRasterDemTerrainProvider
A terrain provider where the terrain source is a raster DEM layer.
Definition: qgsterrainprovider.h:230
QgsLightSource::createFromXml
static QgsLightSource * createFromXml(const QDomElement &element, const QgsReadWriteContext &context)
Creates a new light source from an XML element.
Definition: qgslightsource.cpp:30
Qgs3DMapSettings::selectionColorChanged
void selectionColorChanged()
Emitted when the selection color has changed.
QgsShadowSettings
class containing the configuration of shadows rendering
Definition: qgsshadowsettings.h:34
qgsvectorlayer3drenderer.h
Qgs3DMapSettings::Qgs3DMapSettings
Qgs3DMapSettings()
Constructor for Qgs3DMapSettings.
Definition: qgs3dmapsettings.cpp:35
Qgs3DMapSettings::setShowTerrainTilesInfo
void setShowTerrainTilesInfo(bool enabled)
Sets whether to display extra tile info on top of terrain tiles (for debugging)
Definition: qgs3dmapsettings.cpp:731
Qgis::RendererUsage
RendererUsage
Usage of the renderer.
Definition: qgis.h:1647
QgsTemporalRangeObject::setTemporalRange
void setTemporalRange(const QgsDateTimeRange &range)
Sets the temporal range for the object.
Definition: qgstemporalrangeobject.cpp:35
Qgs3DMapSettings::terrainMapThemeChanged
void terrainMapThemeChanged()
Emitted when terrain's map theme has changed.
qgsterrainprovider.h
Qgs3DMapSettings::mapToWorldCoordinates
QgsVector3D mapToWorldCoordinates(const QgsVector3D &mapCoords) const
Converts map coordinates to 3D world coordinates (applies offset and turns (x,y,z) into (x,...
Definition: qgs3dmapsettings.cpp:479
Qgs3DMapSettings::setViewFrustumVisualizationEnabled
void setViewFrustumVisualizationEnabled(bool enabled)
Sets whether the camera's view frustum is visualized on the 2D map canvas.
Definition: qgs3dmapsettings.cpp:911
Qgs3DUtils::worldToMapCoordinates
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,...
Definition: qgs3dutils.cpp:548
Qgs3DMapSettings::cameraNavigationModeChanged
void cameraNavigationModeChanged()
Emitted when the camera navigation mode was changed.
_LayerRef< QgsMapLayer >
Qgs3DMapSettings::axisSettingsChanged
void axisSettingsChanged()
Emitted when 3d axis rendering settings are changed.
Qgs3DMapSettings::setShadowSettings
void setShadowSettings(const QgsShadowSettings &shadowSettings)
Sets the current configuration of shadow rendering.
Definition: qgs3dmapsettings.cpp:858
Qgs3DMapSettings::skyboxSettings
QgsSkyboxSettings skyboxSettings() const
Returns the current configuration of the skybox.
Definition: qgs3dmapsettings.h:525
QgsRasterDemTerrainProvider::layer
QgsRasterLayer * layer() const
Returns the raster layer with elevation model to be used as the terrain source.
Definition: qgsterrainprovider.cpp:212
Qgs3DMapSettings::setTerrainMapTheme
void setTerrainMapTheme(const QString &theme)
Sets name of the map theme.
Definition: qgs3dmapsettings.cpp:704
QgsPointCloudLayer3DRenderer
3D renderer that renders all points from a point cloud layer
Definition: qgspointcloudlayer3drenderer.h:228
Qgs3DMapSettings::readXml
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads configuration from a DOM element previously written by writeXml()
Definition: qgs3dmapsettings.cpp:121
Qgs3DMapSettings::setMaxTerrainScreenError
void setMaxTerrainScreenError(float error)
Sets maximum allowed screen error of terrain tiles in pixels.
Definition: qgs3dmapsettings.cpp:635
QgsVector3D::x
double x() const
Returns X coordinate.
Definition: qgsvector3d.h:62
qgsflatterraingenerator.h
Qgs3DMapSettings::lightSourcesChanged
void lightSourcesChanged()
Emitted when any of the light source settings in the map changes.
Qgs3DMapSettings::maxTerrainGroundErrorChanged
void maxTerrainGroundErrorChanged()
Emitted when the maximum terrain ground error has changed.
Qgs3DMapSettings::setShowTerrainBoundingBoxes
void setShowTerrainBoundingBoxes(bool enabled)
Sets whether to display bounding boxes of terrain tiles (for debugging)
Definition: qgs3dmapsettings.cpp:722
QgsTemporalRangeObject
Base class for objects with an associated (optional) temporal range.
Definition: qgstemporalrangeobject.h:33
qgspointcloudlayer3drenderer.h
Qgs3DMapSettings::setCameraNavigationMode
void setCameraNavigationMode(QgsCameraController::NavigationMode navigationMode)
Sets the navigation mode for the camera.
Definition: qgs3dmapsettings.cpp:834
Qgs3DMapSettings::showLabelsChanged
void showLabelsChanged()
Emitted when the flag whether labels are displayed on terrain tiles has changed.
QgsAbstractTerrainProvider::scale
double scale() const
Returns the vertical scale factor, which can be used to exaggerate vertical heights.
Definition: qgsterrainprovider.h:133
QgsCameraController::NavigationMode
NavigationMode
The navigation mode used by the camera.
Definition: qgscameracontroller.h:69
Qgs3DMapSettings::cameraNavigationMode
QgsCameraController::NavigationMode cameraNavigationMode() const
Returns the navigation mode used by the camera.
Definition: qgs3dmapsettings.h:485
Qgs3DMapSettings::setEyeDomeLightingEnabled
void setEyeDomeLightingEnabled(bool enabled)
Sets whether eye dome lighting will be used.
Definition: qgs3dmapsettings.cpp:777
QgsAbstractTerrainProvider::offset
double offset() const
Returns the vertical offset value, used for adjusting the heights from the terrain provider.
Definition: qgsterrainprovider.h:149
Qgs3DMapSettings::set3dAxisSettings
void set3dAxisSettings(const Qgs3DAxisSettings &axisSettings)
Sets the current configuration of 3d axis.
Definition: qgs3dmapsettings.cpp:965
qgsprojectelevationproperties.h
Qgs3DMapSettings::setSkyboxSettings
void setSkyboxSettings(const QgsSkyboxSettings &skyboxSettings)
Sets the current configuration of the skybox.
Definition: qgs3dmapsettings.cpp:852
Qgs3DMapSettings::terrainVerticalScale
double terrainVerticalScale() const
Returns vertical scale (exaggeration) of terrain.
Definition: qgs3dmapsettings.cpp:541
QgsCameraController::TerrainBasedNavigation
@ TerrainBasedNavigation
The default navigation based on the terrain.
Definition: qgscameracontroller.h:71
Qgs3DMapSettings::setShowLightSourceOrigins
void setShowLightSourceOrigins(bool enabled)
Sets whether to show light source origins as a sphere (for debugging)
Definition: qgs3dmapsettings.cpp:759
Qgs3DMapSettings::layersChanged
void layersChanged()
Emitted when the list of map layers for 3d rendering has changed.
Qgs3DMapSettings::showTerrainTilesInfoChanged
void showTerrainTilesInfoChanged()
Emitted when the flag whether terrain's tile info is shown has changed.
QgsTerrainGenerator::terrainChanged
void terrainChanged()
Emitted when the terrain changed (for example, raster DEM or mesh have data changed)
Qgs3DMapSettings::setBackgroundColor
void setBackgroundColor(const QColor &color)
Sets background color of the 3D map view.
Definition: qgs3dmapsettings.cpp:504