QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
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#include "moc_qgs3dmapsettings.cpp"
18
19#include "qgs3dutils.h"
22#include "qgsmeshterraingenerator.h"
27#include "qgsterrainprovider.h"
28#include "qgslightsource.h"
29#include "qgscolorutils.h"
30#include "qgsrasterlayer.h"
33#include "qgs3drendercontext.h"
34#include "qgsthreadingutils.h"
36
37#include <QDomDocument>
38#include <QDomElement>
39
40
42 : QObject( nullptr )
43{
44 connect( this, &Qgs3DMapSettings::settingsChanged, [&]()
45 {
47 } );
48 connectChangedSignalsToSettingsChanged();
49}
50
52 : QObject( nullptr )
53 , QgsTemporalRangeObject( other )
54 , mOrigin( other.mOrigin )
55 , mCrs( other.mCrs )
56 , mBackgroundColor( other.mBackgroundColor )
57 , mSelectionColor( other.mSelectionColor )
58 , mTerrainVerticalScale( other.mTerrainVerticalScale )
59 , mTerrainGenerator( other.mTerrainGenerator ? other.mTerrainGenerator->clone() : nullptr )
60 , mMapTileResolution( other.mMapTileResolution )
61 , mMaxTerrainScreenError( other.mMaxTerrainScreenError )
62 , mMaxTerrainGroundError( other.mMaxTerrainGroundError )
63 , mTerrainElevationOffset( other.mTerrainElevationOffset )
64 , mTerrainShadingEnabled( other.mTerrainShadingEnabled )
65 , mTerrainShadingMaterial( other.mTerrainShadingMaterial )
66 , mTerrainMapTheme( other.mTerrainMapTheme )
67 , mShowTerrainBoundingBoxes( other.mShowTerrainBoundingBoxes )
68 , mShowTerrainTileInfo( other.mShowTerrainTileInfo )
69 , mShowCameraViewCenter( other.mShowCameraViewCenter )
70 , mShowCameraRotationCenter( other.mShowCameraRotationCenter )
71 , mShowLightSources( other.mShowLightSources )
72 , mShowLabels( other.mShowLabels )
73 , mStopUpdates( other.mStopUpdates )
74 , mShowDebugPanel( other.mShowDebugPanel )
75 , mFieldOfView( other.mFieldOfView )
76 , mProjectionType( other.mProjectionType )
77 , mCameraNavigationMode( other.mCameraNavigationMode )
78 , mCameraMovementSpeed( other.mCameraMovementSpeed )
79 , mLayers( other.mLayers )
80 , mTransformContext( other.mTransformContext )
81 , mPathResolver( other.mPathResolver )
82 , mMapThemes( other.mMapThemes )
83 , mDpi( other.mDpi )
84 , mIsFpsCounterEnabled( other.mIsFpsCounterEnabled )
85 , mIsSkyboxEnabled( other.mIsSkyboxEnabled )
86 , mSkyboxSettings( other.mSkyboxSettings )
87 , mShadowSettings( other.mShadowSettings )
88 , mAmbientOcclusionSettings( other.mAmbientOcclusionSettings )
89 , mEyeDomeLightingEnabled( other.mEyeDomeLightingEnabled )
90 , mEyeDomeLightingStrength( other.mEyeDomeLightingStrength )
91 , mEyeDomeLightingDistance( other.mEyeDomeLightingDistance )
92 , mViewSyncMode( other.mViewSyncMode )
93 , mVisualizeViewFrustum( other.mVisualizeViewFrustum )
94 , mDebugShadowMapEnabled( other.mDebugShadowMapEnabled )
95 , mDebugShadowMapCorner( other.mDebugShadowMapCorner )
96 , mDebugShadowMapSize( other.mDebugShadowMapSize )
97 , mDebugDepthMapEnabled( other.mDebugDepthMapEnabled )
98 , mDebugDepthMapCorner( other.mDebugDepthMapCorner )
99 , mDebugDepthMapSize( other.mDebugDepthMapSize )
100 , mTerrainRenderingEnabled( other.mTerrainRenderingEnabled )
101 , mRendererUsage( other.mRendererUsage )
102 , m3dAxisSettings( other.m3dAxisSettings )
103 , mIsDebugOverlayEnabled( other.mIsDebugOverlayEnabled )
104 , mExtent( other.mExtent )
105 , mShowExtentIn2DView( other.mShowExtentIn2DView )
106{
107 for ( QgsLightSource *source : std::as_const( other.mLightSources ) )
108 {
109 if ( source )
110 mLightSources << source->clone();
111 }
112
113 connect( this, &Qgs3DMapSettings::settingsChanged, [&]()
114 {
116 } );
117 connectChangedSignalsToSettingsChanged();
118}
119
121{
122 qDeleteAll( mLightSources );
123}
124
125void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
126{
128
130 QDomElement elemOrigin = elem.firstChildElement( QStringLiteral( "origin" ) );
131 mOrigin = QgsVector3D(
132 elemOrigin.attribute( QStringLiteral( "x" ) ).toDouble(),
133 elemOrigin.attribute( QStringLiteral( "y" ) ).toDouble(),
134 elemOrigin.attribute( QStringLiteral( "z" ) ).toDouble() );
135
136 QDomElement elemExtent = elem.firstChildElement( QStringLiteral( "extent" ) );
137 if ( !elemExtent.isNull() )
138 {
139 mExtent = QgsRectangle(
140 elemExtent.attribute( QStringLiteral( "xMin" ) ).toDouble(),
141 elemExtent.attribute( QStringLiteral( "yMin" ) ).toDouble(),
142 elemExtent.attribute( QStringLiteral( "xMax" ) ).toDouble(),
143 elemExtent.attribute( QStringLiteral( "yMax" ) ).toDouble() );
144
145 mShowExtentIn2DView = elemExtent.attribute( QStringLiteral( "showIn2dView" ), QStringLiteral( "0" ) ).toInt();
146 }
147 else
148 {
150 }
151
152 QDomElement elemCamera = elem.firstChildElement( QStringLiteral( "camera" ) );
153 if ( !elemCamera.isNull() )
154 {
155 mFieldOfView = elemCamera.attribute( QStringLiteral( "field-of-view" ), QStringLiteral( "45" ) ).toFloat();
156 mProjectionType = static_cast< Qt3DRender::QCameraLens::ProjectionType >( elemCamera.attribute( QStringLiteral( "projection-type" ), QStringLiteral( "1" ) ).toInt() );
157 QString cameraNavigationMode = elemCamera.attribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "basic-navigation" ) );
158 if ( cameraNavigationMode == QLatin1String( "terrain-based-navigation" ) )
159 mCameraNavigationMode = Qgis::NavigationMode::TerrainBased;
160 else if ( cameraNavigationMode == QLatin1String( "walk-navigation" ) )
161 mCameraNavigationMode = Qgis::NavigationMode::Walk;
162 mCameraMovementSpeed = elemCamera.attribute( QStringLiteral( "camera-movement-speed" ), QStringLiteral( "5.0" ) ).toDouble();
163 }
164
165 QDomElement elemColor = elem.firstChildElement( QStringLiteral( "color" ) );
166 if ( !elemColor.isNull() )
167 {
168 mBackgroundColor = QgsColorUtils::colorFromString( elemColor.attribute( QStringLiteral( "background" ) ) );
169 mSelectionColor = QgsColorUtils::colorFromString( elemColor.attribute( QStringLiteral( "selection" ) ) );
170 }
171
172 QDomElement elemCrs = elem.firstChildElement( QStringLiteral( "crs" ) );
173 mCrs.readXml( elemCrs );
174
175 QDomElement elemTerrain = elem.firstChildElement( QStringLiteral( "terrain" ) );
176 mTerrainRenderingEnabled = elemTerrain.attribute( QStringLiteral( "terrain-rendering-enabled" ), QStringLiteral( "1" ) ).toInt();
177 mTerrainVerticalScale = elemTerrain.attribute( QStringLiteral( "exaggeration" ), QStringLiteral( "1" ) ).toFloat();
178 mMapTileResolution = elemTerrain.attribute( QStringLiteral( "texture-size" ), QStringLiteral( "512" ) ).toInt();
179 mMaxTerrainScreenError = elemTerrain.attribute( QStringLiteral( "max-terrain-error" ), QStringLiteral( "3" ) ).toFloat();
180 mMaxTerrainGroundError = elemTerrain.attribute( QStringLiteral( "max-ground-error" ), QStringLiteral( "1" ) ).toFloat();
181 mTerrainShadingEnabled = elemTerrain.attribute( QStringLiteral( "shading-enabled" ), QStringLiteral( "0" ) ).toInt();
182 mTerrainElevationOffset = elemTerrain.attribute( QStringLiteral( "elevation-offset" ), QStringLiteral( "0.0" ) ).toFloat();
183
184 QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( QStringLiteral( "shading-material" ) );
185 if ( !elemTerrainShadingMaterial.isNull() )
186 mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial, context );
187 mTerrainMapTheme = elemTerrain.attribute( QStringLiteral( "map-theme" ) );
188 mShowLabels = elemTerrain.attribute( QStringLiteral( "show-labels" ), QStringLiteral( "0" ) ).toInt();
189
190 qDeleteAll( mLightSources );
191 mLightSources.clear();
192 const QDomElement lightsElem = elem.firstChildElement( QStringLiteral( "lights" ) );
193 if ( !lightsElem.isNull() )
194 {
195 const QDomNodeList lightNodes = lightsElem.childNodes();
196 for ( int i = 0; i < lightNodes.size(); ++i )
197 {
198 const QDomElement lightElement = lightNodes.at( i ).toElement();
199 if ( QgsLightSource *light = QgsLightSource::createFromXml( lightElement, context ) )
200 mLightSources << light;
201 }
202 }
203 else
204 {
205 // older project format
206 QDomElement elemPointLights = elem.firstChildElement( QStringLiteral( "point-lights" ) );
207 if ( !elemPointLights.isNull() )
208 {
209 QDomElement elemPointLight = elemPointLights.firstChildElement( QStringLiteral( "point-light" ) );
210 while ( !elemPointLight.isNull() )
211 {
212 std::unique_ptr< QgsPointLightSettings > pointLight = std::make_unique< QgsPointLightSettings >();
213 pointLight->readXml( elemPointLight, context );
214 mLightSources << pointLight.release();
215 elemPointLight = elemPointLight.nextSiblingElement( QStringLiteral( "point-light" ) );
216 }
217 }
218 else
219 {
220 // QGIS <= 3.4 did not have light configuration
221 std::unique_ptr< QgsPointLightSettings > defaultLight = std::make_unique< QgsPointLightSettings >();
222 defaultLight->setPosition( QgsVector3D( 0, 1000, 0 ) );
223 mLightSources << defaultLight.release();
224 }
225
226 QDomElement elemDirectionalLights = elem.firstChildElement( QStringLiteral( "directional-lights" ) );
227 if ( !elemDirectionalLights.isNull() )
228 {
229 QDomElement elemDirectionalLight = elemDirectionalLights.firstChildElement( QStringLiteral( "directional-light" ) );
230 while ( !elemDirectionalLight.isNull() )
231 {
232 std::unique_ptr< QgsDirectionalLightSettings > directionalLight = std::make_unique< QgsDirectionalLightSettings >();
233 directionalLight->readXml( elemDirectionalLight, context );
234 mLightSources << directionalLight.release();
235 elemDirectionalLight = elemDirectionalLight.nextSiblingElement( QStringLiteral( "directional-light" ) );
236 }
237 }
238 }
239
240 QDomElement elemMapLayers = elemTerrain.firstChildElement( QStringLiteral( "layers" ) );
241 QDomElement elemMapLayer = elemMapLayers.firstChildElement( QStringLiteral( "layer" ) );
242 QList<QgsMapLayerRef> mapLayers;
243 while ( !elemMapLayer.isNull() )
244 {
245 mapLayers << QgsMapLayerRef( elemMapLayer.attribute( QStringLiteral( "id" ) ) );
246 elemMapLayer = elemMapLayer.nextSiblingElement( QStringLiteral( "layer" ) );
247 }
248 mLayers = mapLayers; // needs to resolve refs afterwards
249
250 QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( QStringLiteral( "generator" ) );
251 QString terrainGenType = elemTerrainGenerator.attribute( QStringLiteral( "type" ) );
252 if ( terrainGenType == QLatin1String( "dem" ) )
253 {
254 QgsDemTerrainGenerator *demTerrainGenerator = new QgsDemTerrainGenerator;
255 demTerrainGenerator->setCrs( mCrs, mTransformContext );
256 setTerrainGenerator( demTerrainGenerator );
257 }
258 else if ( terrainGenType == QLatin1String( "online" ) )
259 {
260 QgsOnlineTerrainGenerator *onlineTerrainGenerator = new QgsOnlineTerrainGenerator;
261 onlineTerrainGenerator->setCrs( mCrs, mTransformContext );
262 setTerrainGenerator( onlineTerrainGenerator );
263 }
264 else if ( terrainGenType == QLatin1String( "mesh" ) )
265 {
266 QgsMeshTerrainGenerator *meshTerrainGenerator = new QgsMeshTerrainGenerator;
267 meshTerrainGenerator->setCrs( mCrs, mTransformContext );
268 setTerrainGenerator( meshTerrainGenerator );
269 }
270 else if ( terrainGenType == QLatin1String( "quantizedmesh" ) )
271 {
273 setTerrainGenerator( qmTerrainGenerator );
274 }
275 else // "flat"
276 {
278 flatGen->setCrs( mCrs );
279 setTerrainGenerator( flatGen );
280 }
281 mTerrainGenerator->readXml( elemTerrainGenerator );
282
283 QDomElement elemSkybox = elem.firstChildElement( QStringLiteral( "skybox" ) );
284 mIsSkyboxEnabled = elemSkybox.attribute( QStringLiteral( "skybox-enabled" ) ).toInt();
285 mSkyboxSettings.readXml( elemSkybox, context );
286
287 QDomElement elemShadows = elem.firstChildElement( QStringLiteral( "shadow-rendering" ) );
288 mShadowSettings.readXml( elemShadows, context );
289
290 QDomElement elemAmbientOcclusion = elem.firstChildElement( QStringLiteral( "screen-space-ambient-occlusion" ) );
291 mAmbientOcclusionSettings.readXml( elemAmbientOcclusion, 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 mStopUpdates = elemDebug.attribute( QStringLiteral( "stop-updates" ), QStringLiteral( "0" ) ).toInt();
319 mShowDebugPanel = elemDebug.attribute( QStringLiteral( "debug-panel" ), QStringLiteral( "0" ) ).toInt();
320
321 QDomElement elemTemporalRange = elem.firstChildElement( QStringLiteral( "temporal-range" ) );
322 QDateTime start = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "start" ) ), Qt::ISODate );
323 QDateTime end = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "end" ) ), Qt::ISODate );
324 setTemporalRange( QgsDateTimeRange( start, end ) );
325
326 QDomElement elem3dAxis = elem.firstChildElement( QStringLiteral( "axis3d" ) );
327 m3dAxisSettings.readXml( elem3dAxis, context );
328
329}
330
331QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const
332{
334
335 QDomElement elem = doc.createElement( QStringLiteral( "qgis3d" ) );
336
337 QDomElement elemOrigin = doc.createElement( QStringLiteral( "origin" ) );
338 elemOrigin.setAttribute( QStringLiteral( "x" ), QString::number( mOrigin.x() ) );
339 elemOrigin.setAttribute( QStringLiteral( "y" ), QString::number( mOrigin.y() ) );
340 elemOrigin.setAttribute( QStringLiteral( "z" ), QString::number( mOrigin.z() ) );
341 elem.appendChild( elemOrigin );
342
343 QDomElement elemExtent = doc.createElement( QStringLiteral( "extent" ) );
344 elemExtent.setAttribute( QStringLiteral( "xMin" ), mExtent.xMinimum() );
345 elemExtent.setAttribute( QStringLiteral( "yMin" ), mExtent.yMinimum() );
346 elemExtent.setAttribute( QStringLiteral( "xMax" ), mExtent.xMaximum() );
347 elemExtent.setAttribute( QStringLiteral( "yMax" ), mExtent.yMaximum() );
348 elemExtent.setAttribute( QStringLiteral( "showIn2dView" ), mShowExtentIn2DView );
349 elem.appendChild( elemExtent );
350
351 QDomElement elemCamera = doc.createElement( QStringLiteral( "camera" ) );
352 elemCamera.setAttribute( QStringLiteral( "field-of-view" ), mFieldOfView );
353 elemCamera.setAttribute( QStringLiteral( "projection-type" ), static_cast< int >( mProjectionType ) );
354 switch ( mCameraNavigationMode )
355 {
357 elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "terrain-based-navigation" ) );
358 break;
360 elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "walk-navigation" ) );
361 break;
362 }
363 elemCamera.setAttribute( QStringLiteral( "camera-movement-speed" ), mCameraMovementSpeed );
364 elem.appendChild( elemCamera );
365
366 QDomElement elemColor = doc.createElement( QStringLiteral( "color" ) );
367 elemColor.setAttribute( QStringLiteral( "background" ), QgsColorUtils::colorToString( mBackgroundColor ) );
368 elemColor.setAttribute( QStringLiteral( "selection" ), QgsColorUtils::colorToString( mSelectionColor ) );
369 elem.appendChild( elemColor );
370
371 QDomElement elemCrs = doc.createElement( QStringLiteral( "crs" ) );
372 mCrs.writeXml( elemCrs, doc );
373 elem.appendChild( elemCrs );
374
375 QDomElement elemTerrain = doc.createElement( QStringLiteral( "terrain" ) );
376 elemTerrain.setAttribute( QStringLiteral( "terrain-rendering-enabled" ), mTerrainRenderingEnabled ? 1 : 0 );
377 elemTerrain.setAttribute( QStringLiteral( "exaggeration" ), QString::number( mTerrainVerticalScale ) );
378 elemTerrain.setAttribute( QStringLiteral( "texture-size" ), mMapTileResolution );
379 elemTerrain.setAttribute( QStringLiteral( "max-terrain-error" ), QString::number( mMaxTerrainScreenError ) );
380 elemTerrain.setAttribute( QStringLiteral( "max-ground-error" ), QString::number( mMaxTerrainGroundError ) );
381 elemTerrain.setAttribute( QStringLiteral( "shading-enabled" ), mTerrainShadingEnabled ? 1 : 0 );
382 elemTerrain.setAttribute( QStringLiteral( "elevation-offset" ), mTerrainElevationOffset );
383
384 QDomElement elemTerrainShadingMaterial = doc.createElement( QStringLiteral( "shading-material" ) );
385 mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial, context );
386 elemTerrain.appendChild( elemTerrainShadingMaterial );
387 elemTerrain.setAttribute( QStringLiteral( "map-theme" ), mTerrainMapTheme );
388 elemTerrain.setAttribute( QStringLiteral( "show-labels" ), mShowLabels ? 1 : 0 );
389
390 {
391 QDomElement elemLights = doc.createElement( QStringLiteral( "lights" ) );
392 for ( const QgsLightSource *light : mLightSources )
393 {
394 const QDomElement elemLight = light->writeXml( doc, context );
395 elemLights.appendChild( elemLight );
396 }
397 elem.appendChild( elemLights );
398 }
399
400 QDomElement elemMapLayers = doc.createElement( QStringLiteral( "layers" ) );
401 for ( const QgsMapLayerRef &layerRef : mLayers )
402 {
403 QDomElement elemMapLayer = doc.createElement( QStringLiteral( "layer" ) );
404 elemMapLayer.setAttribute( QStringLiteral( "id" ), layerRef.layerId );
405 elemMapLayers.appendChild( elemMapLayer );
406 }
407 elemTerrain.appendChild( elemMapLayers );
408
409 QDomElement elemTerrainGenerator = doc.createElement( QStringLiteral( "generator" ) );
410 elemTerrainGenerator.setAttribute( QStringLiteral( "type" ), QgsTerrainGenerator::typeToString( mTerrainGenerator->type() ) );
411 mTerrainGenerator->writeXml( elemTerrainGenerator );
412 elemTerrain.appendChild( elemTerrainGenerator );
413 elem.appendChild( elemTerrain );
414
415 QDomElement elemSkybox = doc.createElement( QStringLiteral( "skybox" ) );
416 elemSkybox.setAttribute( QStringLiteral( "skybox-enabled" ), mIsSkyboxEnabled );
417 mSkyboxSettings.writeXml( elemSkybox, context );
418 elem.appendChild( elemSkybox );
419
420 QDomElement elemShadows = doc.createElement( QStringLiteral( "shadow-rendering" ) );
421 mShadowSettings.writeXml( elemShadows, context );
422 elem.appendChild( elemShadows );
423
424 QDomElement elemAmbientOcclusion = doc.createElement( QStringLiteral( "screen-space-ambient-occlusion" ) );
425 mAmbientOcclusionSettings.writeXml( elemAmbientOcclusion, context );
426 elem.appendChild( elemAmbientOcclusion );
427
428 QDomElement elemDebug = doc.createElement( QStringLiteral( "debug" ) );
429 elemDebug.setAttribute( QStringLiteral( "bounding-boxes" ), mShowTerrainBoundingBoxes ? 1 : 0 );
430 elemDebug.setAttribute( QStringLiteral( "terrain-tile-info" ), mShowTerrainTileInfo ? 1 : 0 );
431 elemDebug.setAttribute( QStringLiteral( "camera-view-center" ), mShowCameraViewCenter ? 1 : 0 );
432 elemDebug.setAttribute( QStringLiteral( "camera-rotation-center" ), mShowCameraRotationCenter ? 1 : 0 );
433 elemDebug.setAttribute( QStringLiteral( "show-light-sources" ), mShowLightSources ? 1 : 0 );
434 elemDebug.setAttribute( QStringLiteral( "show-fps-counter" ), mIsFpsCounterEnabled ? 1 : 0 );
435 elemDebug.setAttribute( QStringLiteral( "stop-updates" ), mStopUpdates ? 1 : 0 );
436 elemDebug.setAttribute( QStringLiteral( "debug-panel" ), mShowDebugPanel ? 1 : 0 );
437 elem.appendChild( elemDebug );
438
439 QDomElement elemEyeDomeLighting = doc.createElement( QStringLiteral( "eye-dome-lighting" ) );
440 elemEyeDomeLighting.setAttribute( QStringLiteral( "enabled" ), mEyeDomeLightingEnabled ? 1 : 0 );
441 elemEyeDomeLighting.setAttribute( QStringLiteral( "eye-dome-lighting-strength" ), mEyeDomeLightingStrength );
442 elemEyeDomeLighting.setAttribute( QStringLiteral( "eye-dome-lighting-distance" ), mEyeDomeLightingDistance );
443 elem.appendChild( elemEyeDomeLighting );
444
445 QDomElement elemNavigationSync = doc.createElement( QStringLiteral( "navigation-sync" ) );
446 elemNavigationSync.setAttribute( QStringLiteral( "view-sync-mode" ), ( int )mViewSyncMode );
447 elemNavigationSync.setAttribute( QStringLiteral( "view-frustum-visualization-enabled" ), mVisualizeViewFrustum ? 1 : 0 );
448 elem.appendChild( elemNavigationSync );
449
450 QDomElement elemDebugSettings = doc.createElement( QStringLiteral( "debug-settings" ) );
451 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-enabled" ), mDebugShadowMapEnabled );
452 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-corner" ), mDebugShadowMapCorner );
453 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-size" ), mDebugShadowMapSize );
454 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-enabled" ), mDebugDepthMapEnabled );
455 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-corner" ), mDebugDepthMapCorner );
456 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-size" ), mDebugDepthMapSize );
457 elem.appendChild( elemDebugSettings );
458
459 QDomElement elemTemporalRange = doc.createElement( QStringLiteral( "temporal-range" ) );
460 elemTemporalRange.setAttribute( QStringLiteral( "start" ), temporalRange().begin().toString( Qt::ISODate ) );
461 elemTemporalRange.setAttribute( QStringLiteral( "end" ), temporalRange().end().toString( Qt::ISODate ) );
462
463 QDomElement elem3dAxis = doc.createElement( QStringLiteral( "axis3d" ) );
464 m3dAxisSettings.writeXml( elem3dAxis, context );
465 elem.appendChild( elem3dAxis );
466
467 return elem;
468}
469
471{
473
474 for ( int i = 0; i < mLayers.count(); ++i )
475 {
476 QgsMapLayerRef &layerRef = mLayers[i];
477 layerRef.setLayer( project.mapLayer( layerRef.layerId ) );
478 }
479
480 mTerrainGenerator->resolveReferences( project );
481
482 // Set extent now that layer-based generators actually have a chance to know their CRS
483 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, mTerrainGenerator->crs(), mTransformContext );
484 mTerrainGenerator->setExtent( terrainExtent );
485}
486
493
495{
497
498 if ( extent == mExtent )
499 return;
500
501 mExtent = extent;
502 const QgsPointXY center = mExtent.center();
503 setOrigin( QgsVector3D( center.x(), center.y(), 0 ) );
504 if ( mTerrainGenerator )
505 {
506 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, mTerrainGenerator->crs(), mTransformContext );
507 mTerrainGenerator->setExtent( terrainExtent );
508 }
509 emit extentChanged();
510}
511
513{
515
516 mOrigin = origin;
517}
518
520{
522
523 return mOrigin;
524}
525
532
539
546
553
560
562{
564
565 mTransformContext = context;
566}
567
569{
571
572 return mPathResolver;
573}
574
576{
578
579 mPathResolver = resolver;
580}
581
588
590{
592
593 mMapThemes = mapThemes;
594}
595
596void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
597{
599
600 if ( color == mBackgroundColor )
601 return;
602
603 mBackgroundColor = color;
605}
606
608{
610
611 return mBackgroundColor;
612}
613
614void Qgs3DMapSettings::setSelectionColor( const QColor &color )
615{
617
618 if ( color == mSelectionColor )
619 return;
620
621 mSelectionColor = color;
623}
624
626{
628
629 return mSelectionColor;
630}
631
633{
635
636 if ( zScale == mTerrainVerticalScale )
637 return;
638
639 mTerrainVerticalScale = zScale;
641}
642
644{
646
647 return mTerrainVerticalScale;
648}
649
650void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
651{
653
654 const QList<QgsMapLayer *> raw = _qgis_listRefToRaw( mLayers );
655
656 if ( layers == raw )
657 return;
658
659 mLayers = _qgis_listRawToRef( layers );
660 emit layersChanged();
661}
662
663QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
664{
666
667 QList<QgsMapLayer *> lst;
668 lst.reserve( mLayers.count() );
669 for ( const QgsMapLayerRef &layerRef : mLayers )
670 {
671 if ( layerRef.layer )
672 lst.append( layerRef.layer );
673 }
674 return lst;
675}
676
678{
680
681 setExtent( fullExtent );
682 if ( properties->terrainProvider()->type() == QLatin1String( "flat" ) )
683 {
685 flatTerrain->setCrs( crs() );
686 setTerrainGenerator( flatTerrain );
687
689 }
690 else if ( properties->terrainProvider()->type() == QLatin1String( "raster" ) )
691 {
692 QgsRasterDemTerrainProvider *rasterProvider = qgis::down_cast< QgsRasterDemTerrainProvider * >( properties->terrainProvider() );
693
695 demTerrainGen->setCrs( crs(), QgsProject::instance()->transformContext() );
696 demTerrainGen->setLayer( rasterProvider->layer() );
697 setTerrainGenerator( demTerrainGen );
698
701 }
702 else if ( properties->terrainProvider()->type() == QLatin1String( "mesh" ) )
703 {
704 QgsMeshTerrainProvider *meshProvider = qgis::down_cast< QgsMeshTerrainProvider * >( properties->terrainProvider() );
705
706 QgsMeshTerrainGenerator *newTerrainGenerator = new QgsMeshTerrainGenerator;
707 newTerrainGenerator->setCrs( crs(), QgsProject::instance()->transformContext() );
708 newTerrainGenerator->setLayer( meshProvider->layer() );
709 std::unique_ptr< QgsMesh3DSymbol > symbol( newTerrainGenerator->symbol()->clone() );
710 symbol->setVerticalScale( properties->terrainProvider()->scale() );
711 newTerrainGenerator->setSymbol( symbol.release() );
712 setTerrainGenerator( newTerrainGenerator );
713
716 }
717 else
718 {
720 flatTerrain->setCrs( crs() );
721 setTerrainGenerator( flatTerrain );
722 }
723}
724
726{
728
729 if ( mMapTileResolution == res )
730 return;
731
732 mMapTileResolution = res;
734}
735
737{
739
740 return mMapTileResolution;
741}
742
744{
746
747 if ( mMaxTerrainScreenError == error )
748 return;
749
750 mMaxTerrainScreenError = error;
752}
753
755{
757
758 return mMaxTerrainScreenError;
759}
760
762{
764
765 if ( mMaxTerrainGroundError == error )
766 return;
767
768 mMaxTerrainGroundError = error;
770}
771
773{
775
776 if ( mTerrainElevationOffset == offset )
777 return;
778 mTerrainElevationOffset = offset;
779 emit terrainElevationOffsetChanged( mTerrainElevationOffset );
780}
781
783{
785
786 return mTerrainElevationOffset;
787}
788
790{
792
793 return mMaxTerrainGroundError;
794}
795
797{
799
800 if ( mTerrainGenerator )
801 {
802 disconnect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
803 }
804
805 if ( gen->crs().isValid() ) // Don't bother setting an extent rect in the wrong CRS
806 {
807 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, gen->crs(), mTransformContext );
808 gen->setExtent( terrainExtent );
809 }
810 mTerrainGenerator.reset( gen );
811 connect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
812
814}
815
817{
819
820 return mTerrainGenerator.get();
821}
822
824{
826
827 if ( mTerrainShadingEnabled == enabled )
828 return;
829
830 mTerrainShadingEnabled = enabled;
832}
833
835{
837
838 return mTerrainShadingEnabled;
839}
840
842{
844
845 if ( mTerrainShadingMaterial == material )
846 return;
847
848 mTerrainShadingMaterial = material;
850}
851
858
859void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
860{
862
863 if ( mTerrainMapTheme == theme )
864 return;
865
866 mTerrainMapTheme = theme;
868}
869
871{
873
874 return mTerrainMapTheme;
875}
876
878{
880
881 if ( mShowTerrainBoundingBoxes == enabled )
882 return;
883
884 mShowTerrainBoundingBoxes = enabled;
886}
887
889{
891
892 return mShowTerrainBoundingBoxes;
893}
894
895
897{
899
900 if ( mShowTerrainTileInfo == enabled )
901 return;
902
903 mShowTerrainTileInfo = enabled;
905}
906
908{
910
911 return mShowTerrainTileInfo;
912}
913
915{
917
918 if ( mShowCameraViewCenter == enabled )
919 return;
920
921 mShowCameraViewCenter = enabled;
923}
924
926{
928
929 return mShowCameraViewCenter;
930}
931
933{
935
936 if ( mShowCameraRotationCenter == enabled )
937 return;
938
939 mShowCameraRotationCenter = enabled;
941}
942
944{
946
947 return mShowCameraRotationCenter;
948}
949
951{
953
954 if ( mShowLightSources == enabled )
955 return;
956
957 mShowLightSources = enabled;
959}
960
962{
964
965 return mShowLightSources;
966}
967
969{
971
972 if ( mShowLabels == enabled )
973 return;
974
975 mShowLabels = enabled;
976 emit showLabelsChanged();
977}
978
980{
982
983 return mShowLabels;
984}
985
987{
989
990 if ( mStopUpdates == enabled )
991 return;
992
993 mStopUpdates = enabled;
994 emit stopUpdatesChanged();
995}
996
998{
1000
1001 return mStopUpdates;
1002}
1003
1005{
1007
1008 if ( mEyeDomeLightingEnabled == enabled )
1009 return;
1010 mEyeDomeLightingEnabled = enabled;
1012}
1013
1015{
1017
1018 return mEyeDomeLightingEnabled;
1019}
1020
1022{
1024
1025 if ( mEyeDomeLightingStrength == strength )
1026 return;
1027 mEyeDomeLightingStrength = strength;
1029}
1030
1032{
1034
1035 return mEyeDomeLightingStrength;
1036}
1037
1039{
1041
1042 if ( mEyeDomeLightingDistance == distance )
1043 return;
1044 mEyeDomeLightingDistance = distance;
1046}
1047
1049{
1051
1052 return mEyeDomeLightingDistance;
1053}
1054
1055QList<QgsLightSource *> Qgs3DMapSettings::lightSources() const
1056{
1058
1059 return mLightSources;
1060}
1061
1062void Qgs3DMapSettings::setLightSources( const QList<QgsLightSource *> &lights )
1063{
1065
1066 // have lights actually changed?
1067 if ( mLightSources.count() == lights.count() )
1068 {
1069 bool same = true;
1070 for ( int i = 0; i < mLightSources.count(); ++i )
1071 {
1072 if ( mLightSources[i]->type() == lights[i]->type() )
1073 {
1074 switch ( mLightSources[i]->type() )
1075 {
1077 if ( *static_cast< QgsPointLightSettings * >( mLightSources[i] ) == *static_cast< QgsPointLightSettings * >( lights[i] ) )
1078 continue;
1079 break;
1081 if ( *static_cast< QgsDirectionalLightSettings * >( mLightSources[i] ) == *static_cast< QgsDirectionalLightSettings * >( lights[i] ) )
1082 continue;
1083 break;
1084 }
1085 }
1086 same = false;
1087 break;
1088 }
1089 if ( same )
1090 {
1091 qDeleteAll( lights );
1092 return;
1093 }
1094 }
1095
1096 qDeleteAll( mLightSources );
1097 mLightSources = lights;
1098
1100 emit pointLightsChanged();
1101 emit lightSourcesChanged();
1102}
1103
1105{
1107
1108 return mFieldOfView;
1109}
1110
1111void Qgs3DMapSettings::setFieldOfView( const float fieldOfView )
1112{
1114
1115 if ( mFieldOfView == fieldOfView )
1116 return;
1117
1118 mFieldOfView = fieldOfView;
1119 emit fieldOfViewChanged();
1120}
1121
1122Qt3DRender::QCameraLens::ProjectionType Qgs3DMapSettings::projectionType() const
1123{
1125
1126 return mProjectionType;
1127}
1128
1129void Qgs3DMapSettings::setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType )
1130{
1132
1133 if ( mProjectionType == projectionType )
1134 return;
1135
1136 mProjectionType = projectionType;
1137 emit projectionTypeChanged();
1138}
1139
1141{
1143
1144 return mCameraNavigationMode;
1145}
1146
1148{
1150
1151 if ( mCameraNavigationMode == navigationMode )
1152 return;
1153
1154 mCameraNavigationMode = navigationMode;
1156}
1157
1159{
1161
1162 return mCameraMovementSpeed;
1163}
1164
1166{
1168
1169 if ( mCameraMovementSpeed == movementSpeed )
1170 return;
1171
1172 mCameraMovementSpeed = movementSpeed;
1174}
1175
1176void Qgs3DMapSettings::setOutputDpi( const double dpi )
1177{
1179
1180 mDpi = dpi;
1181}
1182
1184{
1186
1187 return mDpi;
1188}
1189
1191{
1193
1194 return mSkyboxSettings;
1195}
1196
1198{
1200
1201 return mShadowSettings;
1202}
1203
1205{
1207
1208 return mAmbientOcclusionSettings;
1209}
1210
1212{
1214
1215 mSkyboxSettings = skyboxSettings;
1216 emit skyboxSettingsChanged();
1217}
1218
1220{
1222
1223 mShadowSettings = shadowSettings;
1224 emit shadowSettingsChanged();
1225}
1226
1228{
1230
1231 mAmbientOcclusionSettings = ambientOcclusionSettings;
1233}
1234
1236{
1238
1239 return mIsSkyboxEnabled;
1240}
1241
1243{
1245
1246 mIsSkyboxEnabled = enabled;
1247}
1248
1250{
1252
1253 return mIsFpsCounterEnabled;
1254}
1255
1256void Qgs3DMapSettings::setShowDebugPanel( const bool enabled )
1257{
1259
1260 if ( mShowDebugPanel == enabled )
1261 return;
1262
1263 mShowDebugPanel = enabled;
1264 emit showDebugPanelChanged( enabled );
1265}
1266
1268{
1270
1271 return mShowDebugPanel;
1272}
1273
1274void Qgs3DMapSettings::setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size )
1275{
1277
1278 mDebugShadowMapEnabled = enabled;
1279 mDebugShadowMapCorner = corner;
1280 mDebugShadowMapSize = size;
1282}
1283
1285{
1287
1288 return mDebugShadowMapEnabled;
1289}
1290
1292{
1294
1295 return mDebugShadowMapCorner;
1296}
1297
1299{
1301
1302 return mDebugShadowMapSize;
1303}
1304
1305void Qgs3DMapSettings::setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size )
1306{
1308
1309 mDebugDepthMapEnabled = enabled;
1310 mDebugDepthMapCorner = corner;
1311 mDebugDepthMapSize = size;
1313}
1314
1316{
1318
1319 return mDebugDepthMapEnabled;
1320}
1321
1323{
1325
1326 return mDebugDepthMapCorner;
1327}
1328
1330{
1332
1333 return mDebugDepthMapSize;
1334}
1335
1336void Qgs3DMapSettings::setIsFpsCounterEnabled( bool fpsCounterEnabled )
1337{
1339
1340 if ( fpsCounterEnabled == mIsFpsCounterEnabled )
1341 return;
1342 mIsFpsCounterEnabled = fpsCounterEnabled;
1343 emit fpsCounterEnabledChanged( mIsFpsCounterEnabled );
1344}
1345
1347{
1349
1350 return mTerrainRenderingEnabled;
1351}
1352
1353void Qgs3DMapSettings::setTerrainRenderingEnabled( bool terrainRenderingEnabled )
1354{
1356
1357 if ( terrainRenderingEnabled == mTerrainRenderingEnabled )
1358 return;
1359 mTerrainRenderingEnabled = terrainRenderingEnabled;
1361}
1362
1364{
1366
1367 return mRendererUsage;
1368}
1369
1371{
1373
1374 mRendererUsage = rendererUsage;
1375}
1376
1383
1385{
1387
1388 mViewSyncMode = mode;
1389}
1390
1392{
1394
1395 return mVisualizeViewFrustum;
1396}
1397
1399{
1401
1402 if ( mVisualizeViewFrustum != enabled )
1403 {
1404 mVisualizeViewFrustum = enabled;
1406 }
1407}
1408
1410{
1412
1413 return m3dAxisSettings;
1414}
1415
1416void Qgs3DMapSettings::setIsDebugOverlayEnabled( bool debugOverlayEnabled )
1417{
1419
1420 if ( debugOverlayEnabled == mIsDebugOverlayEnabled )
1421 return;
1422
1423 mIsDebugOverlayEnabled = debugOverlayEnabled;
1424 emit debugOverlayEnabledChanged( mIsDebugOverlayEnabled );
1425}
1426
1428{
1430
1431 return mShowExtentIn2DView;
1432}
1433
1434void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
1435{
1437
1473}
1474
1475
1476void Qgs3DMapSettings::set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force )
1477{
1479
1480 if ( axisSettings == m3dAxisSettings )
1481 {
1482 if ( force )
1483 {
1484 // ie. refresh. We need to disconnect and to reconnect to avoid 'dirty' project
1486 emit axisSettingsChanged();
1488 }
1489 }
1490 else
1491 {
1492 m3dAxisSettings = axisSettings;
1493 emit axisSettingsChanged();
1494 }
1495}
1496
1498{
1500
1501 return mIsDebugOverlayEnabled;
1502}
1503
1505{
1507
1508 if ( show == mShowExtentIn2DView )
1509 return;
1510
1511 mShowExtentIn2DView = show;
1513}
QFlags< ViewSyncModeFlag > ViewSyncModeFlags
Definition qgis.h:3233
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:3872
@ TerrainBased
The default navigation based on the terrain.
@ Walk
Uses WASD keys or arrows to navigate in walking (first person) manner.
RendererUsage
Usage of the renderer.
Definition qgis.h:3196
@ Point
Point light source.
@ Directional
Directional light source.
Contains the configuration of a 3d axis.
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.
void extentChanged()
Emitted when the 3d view's 2d extent has changed.
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.
bool isDebugOverlayEnabled() const
Returns whether debug overlay is enabled.
Qt::Corner debugDepthMapCorner() const
Returns the corner where the shadow map preview is displayed.
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which stores various information regarding which datum transfo...
void settingsChanged()
Emitted when one of the configuration settings has changed.
void renderersChanged()
Emitted when the list of map's extra renderers have been modified.
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.
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
void setAmbientOcclusionSettings(const QgsAmbientOcclusionSettings &ambientOcclusionSettings)
Sets the current configuration of screen space ambient occlusion.
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,...
bool showExtentIn2DView() const
Returns whether the extent is displayed on the main 2D map canvas.
double cameraMovementSpeed() const
Returns the camera movement speed.
Qt3DRender::QCameraLens::ProjectionType projectionType() const
Returns the camera lens' projection type.
void setEyeDomeLightingEnabled(bool enabled)
Sets whether eye dome lighting will be used.
void showDebugPanelChanged(bool shown)
Emitted when the Show debug panel checkbox changes value.
bool debugDepthMapEnabled() const
Returns whether the shadow map debugging is enabled.
bool isSkyboxEnabled() const
Returns whether the skybox is enabled.
void setFieldOfView(const float fieldOfView)
Sets the camera lens' field of view.
void debugDepthMapSettingsChanged()
Emitted when depth map debugging has changed.
void setLightSources(const QList< QgsLightSource * > &lights)
Sets the list of light sources defined in the scene.
double outputDpi() const
Returns DPI used for conversion between real world units (e.g.
Qgis::NavigationMode cameraNavigationMode() const
Returns the navigation mode used by the camera.
double eyeDomeLightingStrength() const
Returns the eye dome lighting strength value.
void backgroundColorChanged()
Emitted when the background color has changed.
void showTerrainBoundingBoxesChanged()
Emitted when the flag whether terrain's bounding boxes are shown has changed.
Qt::Corner debugShadowMapCorner() const
Returns the corner where the shadow map preview is displayed.
void setMapThemeCollection(QgsMapThemeCollection *mapThemes)
Sets pointer to the collection of map themes.
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.
bool showCameraViewCenter() const
Returns whether to show camera's view center as a sphere (for debugging)
void showCameraRotationCenterChanged()
Emitted when the flag whether camera's rotation center is shown has changed.
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.
bool stopUpdates() const
Returns whether the scene updates on camera movement.
void setViewFrustumVisualizationEnabled(bool enabled)
Sets whether the camera's view frustum is visualized on the 2D map canvas.
void setShowCameraRotationCenter(bool enabled)
Sets whether to show camera's rotation center as a sphere (for debugging)
float maxTerrainGroundError() const
Returns maximum ground error of terrain tiles in world units.
void setExtent(const QgsRectangle &extent)
Sets the 3D scene's 2D extent in the 3D scene's CRS, while also setting the scene's origin to the ext...
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 debugOverlayEnabledChanged(bool debugOverlayEnabled)
Emitted when the debug overaly is enabled or disabled.
void setOutputDpi(const double dpi)
Sets DPI used for conversion between real world units (e.g.
void setIsSkyboxEnabled(bool enabled)
Sets whether the skybox is enabled.
void setShowLabels(bool enabled)
Sets whether to display labels on terrain tiles.
double terrainVerticalScale() const
Returns vertical scale (exaggeration) of terrain.
void setViewSyncMode(Qgis::ViewSyncModeFlags mode)
Sets the view sync mode (used to synchronize the 2D main map canvas and the 3D camera navigation)
void setOrigin(const QgsVector3D &origin)
Sets coordinates in map CRS at which our 3D world has origin (0,0,0)
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.
void setShowDebugPanel(bool enabled)
Sets whether the debug side panel is shown.
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 setIsDebugOverlayEnabled(bool debugOverlayEnabled)
Sets whether debug overlay is enabled The debug overlay displays some debugging and profiling informa...
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)
QList< QgsLightSource * > lightSources() const
Returns list of directional light sources defined in the scene.
double debugDepthMapSize() const
Returns the size of the shadow map preview.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets coordinate reference system used in the 3D scene.
Qgs3DAxisSettings get3DAxisSettings() const
Returns the current configuration of 3d axis.
void setEyeDomeLightingDistance(int distance)
Sets the eye dome lighting distance value (contributes to the contrast of the image.
bool viewFrustumVisualizationEnabled() const
Returns whether the camera's view frustum is visualized on the 2D map canvas.
void setShowLightSourceOrigins(bool enabled)
Sets whether to show light source origins as a sphere (for debugging)
bool showDebugPanel() const
Returns whether the debug side panel is shown.
void setShowExtentIn2DView(bool show)
Sets whether the extent is displayed on the main 2D map canvas.
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.
QgsAmbientOcclusionSettings ambientOcclusionSettings() const
Returns the current configuration of screen space ambient occlusion.
QgsRectangle extent() const
Returns the 3D scene's 2D extent in the 3D scene's CRS.
void setTerrainShadingEnabled(bool enabled)
Sets whether terrain shading is enabled.
Qgis::ViewSyncModeFlags viewSyncMode() const
Returns the view sync mode (used to synchronize the 2D main map canvas and the 3D camera navigation)
void stopUpdatesChanged()
Emitted when the flag whether to keep updating scene has changed.
void setDebugShadowMapSettings(bool enabled, Qt::Corner corner, double size)
Sets the debugging settings of the shadow map.
float terrainElevationOffset() const
Returns the elevation offset of the terrain (used to move the terrain up or down)
int eyeDomeLightingDistance() const
Returns the eye dome lighting distance value (contributes to the contrast of the image)
void setSelectionColor(const QColor &color)
Sets color used for selected features.
void lightSourcesChanged()
Emitted when any of the light source settings in the map changes.
void showLightSourceOriginsChanged()
Emitted when the flag whether light source origins are shown has changed.
QgsTerrainGenerator * terrainGenerator() const
Returns the terrain generator.
void setCameraNavigationMode(Qgis::NavigationMode navigationMode)
Sets the navigation mode for the camera.
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()
double debugShadowMapSize() const
Returns the size of the shadow map preview.
void setPathResolver(const QgsPathResolver &resolver)
Sets the path resolver for conversion between relative and absolute paths during rendering operations...
QgsVector3D worldToMapCoordinates(const QgsVector3D &worldCoords) const
Converts 3D world coordinates to map coordinates (applies offset and turns (x,y,z) into (x,...
bool showTerrainBoundingBoxes() const
Returns whether to display bounding boxes of terrain tiles (for debugging)
void showLabelsChanged()
Emitted when the flag whether labels are displayed on terrain tiles has changed.
void setStopUpdates(bool enabled)
Sets whether scene updates on camera movement should be enabled.
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 showLabels() const
Returns whether to display labels on terrain tiles.
void set3DAxisSettings(const Qgs3DAxisSettings &axisSettings, bool force=false)
Sets the current configuration of 3d axis.
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.
bool debugShadowMapEnabled() const
Returns whether the shadow map debugging is enabled.
void setBackgroundColor(const QColor &color)
Sets background color of the 3D map view.
bool terrainRenderingEnabled() const
Returns whether the 2D terrain surface will be rendered.
void fpsCounterEnabledChanged(bool fpsCounterEnabled)
Emitted when the FPS counter is enabled or disabled.
void axisSettingsChanged()
Emitted when 3d axis rendering settings are changed.
void viewFrustumVisualizationEnabledChanged()
Emitted when the camera's view frustum visualization on the main 2D map canvas is enabled or disabled...
void setProjectionType(const Qt3DRender::QCameraLens::ProjectionType projectionType)
Sets the camera lens' projection type.
void ambientOcclusionSettingsChanged()
Emitted when ambient occlusion rendering settings are changed.
bool showTerrainTilesInfo() const
Returns whether to display extra tile info on top of terrain tiles (for debugging)
void showExtentIn2DViewChanged()
Emitted when the parameter to display 3d view's extent in the 2D canvas has changed.
void configureTerrainFromProject(QgsProjectElevationProperties *properties, const QgsRectangle &fullExtent)
Configures the map's terrain settings directly from a project's elevation properties.
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.
bool isTerrainShadingEnabled() const
Returns whether terrain shading is enabled.
void cameraMovementSpeedChanged()
Emitted when the camera movement speed was changed.
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used in the 3D scene.
bool eyeDomeLightingEnabled() const
Returns whether eye dome lighting is used.
QgsPhongMaterialSettings terrainShadingMaterial() const
Returns terrain shading material.
void setRendererUsage(Qgis::RendererUsage rendererUsage)
Sets the renderer usage.
bool isFpsCounterEnabled() const
Returns whether FPS counter label is enabled.
QString terrainMapTheme() const
Returns name of the map theme (from the active project) that will be used for terrain's texture.
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.
Qgis::RendererUsage rendererUsage() const
Returns the renderer usage.
void setIsFpsCounterEnabled(bool fpsCounterEnabled)
Sets whether FPS counter label is enabled.
QgsMapThemeCollection * mapThemeCollection() const
Returns pointer to the collection of map themes.
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.
void terrainGeneratorChanged()
Emitted when the terrain generator has changed.
bool showLightSourceOrigins() const
Returns whether to show light source origins as a sphere (for debugging)
void setTerrainGenerator(QgsTerrainGenerator *gen)
Sets terrain generator and sets extent() as the generator's extent.
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...
QgsVector3D origin() const
Returns coordinates in map CRS at which 3D scene has origin (0,0,0).
bool showCameraRotationCenter() const
Returns whether to show camera's rotation center as a sphere (for debugging)
static QgsRectangle tryReprojectExtent2D(const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs1, const QgsCoordinateReferenceSystem &crs2, const QgsCoordinateTransformContext &context)
Reprojects extent from crs1 to crs2 coordinate reference system with context context.
static QgsVector3D worldToMapCoordinates(const QgsVector3D &worldCoords, const QgsVector3D &origin)
Converts 3D world coordinates to map coordinates (applies offset)
static QgsVector3D mapToWorldCoordinates(const QgsVector3D &mapCoords, const QgsVector3D &origin)
Converts map coordinates to 3D world coordinates (applies offset)
virtual QString type() const =0
Returns the unique type ID string for the provider.
double offset() const
Returns the vertical offset value, used for adjusting the heights from the terrain provider.
double scale() const
Returns the vertical scale factor, which can be used to exaggerate vertical heights.
class containing the configuration of ambient occlusion 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.
static QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
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 setLayer(QgsRasterLayer *layer)
Sets raster layer with elevation model to be used for terrain generation.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets CRS of the terrain.
static QgsLightSource * createFromXml(const QDomElement &element, const QgsReadWriteContext &context)
Creates a new light source from an XML element.
Container class that allows storage of map themes consisting of visible map layers and layer styles.
A terrain provider that uses the Z values of a mesh layer to build a terrain surface.
QgsMeshLayer * layer() const
Returns the mesh layer to be used as the terrain source.
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets CRS of the terrain.
Resolves relative paths into absolute paths and vice versa.
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.
A class to represent a 2D point.
Definition qgspointxy.h:60
double y
Definition qgspointxy.h:64
double x
Definition qgspointxy.h:63
Temporarily blocks QgsProject "dirtying" for the lifetime of the object.
Contains elevation properties for a QgsProject.
QgsAbstractTerrainProvider * terrainProvider()
Returns the project's terrain provider.
QgsReferencedRectangle fullExtent() const
Returns the full extent of the project, which represents the maximal limits of the project.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
static QgsProject * instance()
Returns the QgsProject singleton instance.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
void setDirty(bool b=true)
Flag the project as dirty (modified).
const QgsProjectViewSettings * viewSettings() const
Returns the project's view settings, which contains settings and properties relating to how a QgsProj...
A terrain provider where the terrain source is a raster DEM layer.
QgsRasterLayer * layer() const
Returns the raster layer with elevation model to be used as the terrain source.
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
double xMinimum
double yMinimum
double xMaximum
double yMaximum
QgsPointXY center
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.
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.
T begin() const
Returns the beginning of the range.
Definition qgsrange.h:444
T end() const
Returns the upper bound of the range.
Definition qgsrange.h:451
void terrainChanged()
Emitted when the terrain changed (for example, raster DEM or mesh have data changed)
virtual void setExtent(const QgsRectangle &extent)
sets the extent of the terrain in terrain's CRS
static QString typeToString(Type type)
Converts terrain generator type enumeration into a string.
virtual QgsCoordinateReferenceSystem crs() const
Returns CRS of the terrain.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition qgsvector3d.h:31
double y() const
Returns Y coordinate.
Definition qgsvector3d.h:50
double z() const
Returns Z coordinate.
Definition qgsvector3d.h:52
double x() const
Returns X coordinate.
Definition qgsvector3d.h:48
_LayerRef< QgsMapLayer > QgsMapLayerRef
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:742
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
const QgsCoordinateReferenceSystem & crs
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
QString layerId
Original layer ID.