QGIS API Documentation 3.43.0-Master (b60ef06885e)
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 "qgs3d.h"
20#include "qgs3dutils.h"
23#include "qgsterrainprovider.h"
24#include "qgslightsource.h"
25#include "qgscolorutils.h"
26#include "qgsrasterlayer.h"
29#include "qgs3drendercontext.h"
30#include "qgsthreadingutils.h"
35
36#include <QDomDocument>
37#include <QDomElement>
38
39
41 : QObject( nullptr )
42{
43 connect( this, &Qgs3DMapSettings::settingsChanged, [&]() {
45 } );
46 connectChangedSignalsToSettingsChanged();
47 mTerrainSettings = std::make_unique<QgsFlatTerrainSettings>();
48}
49
51 : QObject( nullptr )
52 , QgsTemporalRangeObject( other )
53 , mOrigin( other.mOrigin )
54 , mCrs( other.mCrs )
55 , mBackgroundColor( other.mBackgroundColor )
56 , mSelectionColor( other.mSelectionColor )
57 , mTerrainShadingEnabled( other.mTerrainShadingEnabled )
58 , mTerrainShadingMaterial( other.mTerrainShadingMaterial )
59 , mTerrainMapTheme( other.mTerrainMapTheme )
60 , mShowTerrainBoundingBoxes( other.mShowTerrainBoundingBoxes )
61 , mShowTerrainTileInfo( other.mShowTerrainTileInfo )
62 , mShowCameraViewCenter( other.mShowCameraViewCenter )
63 , mShowCameraRotationCenter( other.mShowCameraRotationCenter )
64 , mShowLightSources( other.mShowLightSources )
65 , mShowLabels( other.mShowLabels )
66 , mStopUpdates( other.mStopUpdates )
67 , mShowDebugPanel( other.mShowDebugPanel )
68 , mFieldOfView( other.mFieldOfView )
69 , mProjectionType( other.mProjectionType )
70 , mCameraNavigationMode( other.mCameraNavigationMode )
71 , mCameraMovementSpeed( other.mCameraMovementSpeed )
72 , mLayers( other.mLayers )
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 , mAmbientOcclusionSettings( other.mAmbientOcclusionSettings )
82 , mEyeDomeLightingEnabled( other.mEyeDomeLightingEnabled )
83 , mEyeDomeLightingStrength( other.mEyeDomeLightingStrength )
84 , mEyeDomeLightingDistance( other.mEyeDomeLightingDistance )
85 , mViewSyncMode( other.mViewSyncMode )
86 , mVisualizeViewFrustum( other.mVisualizeViewFrustum )
87 , mDebugShadowMapEnabled( other.mDebugShadowMapEnabled )
88 , mDebugShadowMapCorner( other.mDebugShadowMapCorner )
89 , mDebugShadowMapSize( other.mDebugShadowMapSize )
90 , mDebugDepthMapEnabled( other.mDebugDepthMapEnabled )
91 , mDebugDepthMapCorner( other.mDebugDepthMapCorner )
92 , mDebugDepthMapSize( other.mDebugDepthMapSize )
93 , mTerrainRenderingEnabled( other.mTerrainRenderingEnabled )
94 , mRendererUsage( other.mRendererUsage )
95 , m3dAxisSettings( other.m3dAxisSettings )
96 , mIsDebugOverlayEnabled( other.mIsDebugOverlayEnabled )
97 , mExtent( other.mExtent )
98 , mShowExtentIn2DView( other.mShowExtentIn2DView )
99{
100 setTerrainSettings( other.mTerrainSettings ? other.mTerrainSettings->clone() : new QgsFlatTerrainSettings() );
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, [&]() {
110 } );
111 connectChangedSignalsToSettingsChanged();
112}
113
115{
116 qDeleteAll( mLightSources );
117}
118
119void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
120{
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
131 QDomElement elemExtent = elem.firstChildElement( QStringLiteral( "extent" ) );
132 if ( !elemExtent.isNull() )
133 {
134 mExtent = QgsRectangle(
135 elemExtent.attribute( QStringLiteral( "xMin" ) ).toDouble(),
136 elemExtent.attribute( QStringLiteral( "yMin" ) ).toDouble(),
137 elemExtent.attribute( QStringLiteral( "xMax" ) ).toDouble(),
138 elemExtent.attribute( QStringLiteral( "yMax" ) ).toDouble()
139 );
140
141 mShowExtentIn2DView = elemExtent.attribute( QStringLiteral( "showIn2dView" ), QStringLiteral( "0" ) ).toInt();
142 }
143 else
144 {
146 }
147
148 QDomElement elemCamera = elem.firstChildElement( QStringLiteral( "camera" ) );
149 if ( !elemCamera.isNull() )
150 {
151 mFieldOfView = elemCamera.attribute( QStringLiteral( "field-of-view" ), QStringLiteral( "45" ) ).toFloat();
152 mProjectionType = static_cast<Qt3DRender::QCameraLens::ProjectionType>( elemCamera.attribute( QStringLiteral( "projection-type" ), QStringLiteral( "1" ) ).toInt() );
153 QString cameraNavigationMode = elemCamera.attribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "basic-navigation" ) );
154 if ( cameraNavigationMode == QLatin1String( "terrain-based-navigation" ) )
155 mCameraNavigationMode = Qgis::NavigationMode::TerrainBased;
156 else if ( cameraNavigationMode == QLatin1String( "walk-navigation" ) )
157 mCameraNavigationMode = Qgis::NavigationMode::Walk;
158 else if ( cameraNavigationMode == QLatin1String( "globe-terrain-based-navigation" ) )
159 mCameraNavigationMode = Qgis::NavigationMode::GlobeTerrainBased;
160 mCameraMovementSpeed = elemCamera.attribute( QStringLiteral( "camera-movement-speed" ), QStringLiteral( "5.0" ) ).toDouble();
161 }
162
163 QDomElement elemColor = elem.firstChildElement( QStringLiteral( "color" ) );
164 if ( !elemColor.isNull() )
165 {
166 mBackgroundColor = QgsColorUtils::colorFromString( elemColor.attribute( QStringLiteral( "background" ) ) );
167 mSelectionColor = QgsColorUtils::colorFromString( elemColor.attribute( QStringLiteral( "selection" ) ) );
168 }
169
170 QDomElement elemCrs = elem.firstChildElement( QStringLiteral( "crs" ) );
171 mCrs.readXml( elemCrs );
172
173 QDomElement elemTerrain = elem.firstChildElement( QStringLiteral( "terrain" ) );
174 mTerrainRenderingEnabled = elemTerrain.attribute( QStringLiteral( "terrain-rendering-enabled" ), QStringLiteral( "1" ) ).toInt();
175 mTerrainShadingEnabled = elemTerrain.attribute( QStringLiteral( "shading-enabled" ), QStringLiteral( "0" ) ).toInt();
176
177 QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( QStringLiteral( "shading-material" ) );
178 if ( !elemTerrainShadingMaterial.isNull() )
179 mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial, context );
180 mTerrainMapTheme = elemTerrain.attribute( QStringLiteral( "map-theme" ) );
181 mShowLabels = elemTerrain.attribute( QStringLiteral( "show-labels" ), QStringLiteral( "0" ) ).toInt();
182
183 qDeleteAll( mLightSources );
184 mLightSources.clear();
185 const QDomElement lightsElem = elem.firstChildElement( QStringLiteral( "lights" ) );
186 if ( !lightsElem.isNull() )
187 {
188 const QDomNodeList lightNodes = lightsElem.childNodes();
189 for ( int i = 0; i < lightNodes.size(); ++i )
190 {
191 const QDomElement lightElement = lightNodes.at( i ).toElement();
192 if ( QgsLightSource *light = QgsLightSource::createFromXml( lightElement, context ) )
193 mLightSources << light;
194 }
195 }
196 else
197 {
198 // older project format
199 QDomElement elemPointLights = elem.firstChildElement( QStringLiteral( "point-lights" ) );
200 if ( !elemPointLights.isNull() )
201 {
202 QDomElement elemPointLight = elemPointLights.firstChildElement( QStringLiteral( "point-light" ) );
203 while ( !elemPointLight.isNull() )
204 {
205 auto pointLight = std::make_unique<QgsPointLightSettings>();
206 pointLight->readXml( elemPointLight, context );
207 mLightSources << pointLight.release();
208 elemPointLight = elemPointLight.nextSiblingElement( QStringLiteral( "point-light" ) );
209 }
210 }
211 else
212 {
213 // QGIS <= 3.4 did not have light configuration
214 auto defaultLight = std::make_unique<QgsPointLightSettings>();
215 defaultLight->setPosition( QgsVector3D( 0, 1000, 0 ) );
216 mLightSources << defaultLight.release();
217 }
218
219 QDomElement elemDirectionalLights = elem.firstChildElement( QStringLiteral( "directional-lights" ) );
220 if ( !elemDirectionalLights.isNull() )
221 {
222 QDomElement elemDirectionalLight = elemDirectionalLights.firstChildElement( QStringLiteral( "directional-light" ) );
223 while ( !elemDirectionalLight.isNull() )
224 {
225 auto directionalLight = std::make_unique<QgsDirectionalLightSettings>();
226 directionalLight->readXml( elemDirectionalLight, context );
227 mLightSources << directionalLight.release();
228 elemDirectionalLight = elemDirectionalLight.nextSiblingElement( QStringLiteral( "directional-light" ) );
229 }
230 }
231 }
232
233 QDomElement elemMapLayers = elemTerrain.firstChildElement( QStringLiteral( "layers" ) );
234 QDomElement elemMapLayer = elemMapLayers.firstChildElement( QStringLiteral( "layer" ) );
235 QList<QgsMapLayerRef> mapLayers;
236 while ( !elemMapLayer.isNull() )
237 {
238 mapLayers << QgsMapLayerRef( elemMapLayer.attribute( QStringLiteral( "id" ) ) );
239 elemMapLayer = elemMapLayer.nextSiblingElement( QStringLiteral( "layer" ) );
240 }
241 mLayers = mapLayers; // needs to resolve refs afterwards
242
243 QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( QStringLiteral( "generator" ) );
244 const QString terrainGenType = elemTerrainGenerator.attribute( QStringLiteral( "type" ) );
245 std::unique_ptr<QgsAbstractTerrainSettings> terrainSettings( Qgs3D::terrainRegistry()->createTerrainSettings( terrainGenType ) );
246 if ( terrainSettings )
247 {
248 terrainSettings->readXml( elemTerrain, context );
250 }
251
252 QDomElement elemSkybox = elem.firstChildElement( QStringLiteral( "skybox" ) );
253 mIsSkyboxEnabled = elemSkybox.attribute( QStringLiteral( "skybox-enabled" ) ).toInt();
254 mSkyboxSettings.readXml( elemSkybox, context );
255
256 QDomElement elemShadows = elem.firstChildElement( QStringLiteral( "shadow-rendering" ) );
257 mShadowSettings.readXml( elemShadows, context );
258
259 QDomElement elemAmbientOcclusion = elem.firstChildElement( QStringLiteral( "screen-space-ambient-occlusion" ) );
260 mAmbientOcclusionSettings.readXml( elemAmbientOcclusion, context );
261
262 QDomElement elemEyeDomeLighting = elem.firstChildElement( QStringLiteral( "eye-dome-lighting" ) );
263 mEyeDomeLightingEnabled = elemEyeDomeLighting.attribute( "enabled", QStringLiteral( "0" ) ).toInt();
264 mEyeDomeLightingStrength = elemEyeDomeLighting.attribute( "eye-dome-lighting-strength", QStringLiteral( "1000.0" ) ).toDouble();
265 mEyeDomeLightingDistance = elemEyeDomeLighting.attribute( "eye-dome-lighting-distance", QStringLiteral( "1" ) ).toInt();
266
267 QDomElement elemNavigationSync = elem.firstChildElement( QStringLiteral( "navigation-sync" ) );
268 mViewSyncMode = ( Qgis::ViewSyncModeFlags )( elemNavigationSync.attribute( QStringLiteral( "view-sync-mode" ), QStringLiteral( "0" ) ).toInt() );
269 mVisualizeViewFrustum = elemNavigationSync.attribute( QStringLiteral( "view-frustum-visualization-enabled" ), QStringLiteral( "0" ) ).toInt();
270
271 QDomElement elemDebugSettings = elem.firstChildElement( QStringLiteral( "debug-settings" ) );
272 mDebugShadowMapEnabled = elemDebugSettings.attribute( QStringLiteral( "shadowmap-enabled" ), QStringLiteral( "0" ) ).toInt();
273 mDebugShadowMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( QStringLiteral( "shadowmap-corner" ), "0" ).toInt() );
274 mDebugShadowMapSize = elemDebugSettings.attribute( QStringLiteral( "shadowmap-size" ), QStringLiteral( "0.2" ) ).toDouble();
275
276 mDebugDepthMapEnabled = elemDebugSettings.attribute( QStringLiteral( "depthmap-enabled" ), QStringLiteral( "0" ) ).toInt();
277 mDebugDepthMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( QStringLiteral( "depthmap-corner" ), QStringLiteral( "1" ) ).toInt() );
278 mDebugDepthMapSize = elemDebugSettings.attribute( QStringLiteral( "depthmap-size" ), QStringLiteral( "0.2" ) ).toDouble();
279
280 QDomElement elemDebug = elem.firstChildElement( QStringLiteral( "debug" ) );
281 mShowTerrainBoundingBoxes = elemDebug.attribute( QStringLiteral( "bounding-boxes" ), QStringLiteral( "0" ) ).toInt();
282 mShowTerrainTileInfo = elemDebug.attribute( QStringLiteral( "terrain-tile-info" ), QStringLiteral( "0" ) ).toInt();
283 mShowCameraViewCenter = elemDebug.attribute( QStringLiteral( "camera-view-center" ), QStringLiteral( "0" ) ).toInt();
284 mShowCameraRotationCenter = elemDebug.attribute( QStringLiteral( "camera-rotation-center" ), QStringLiteral( "0" ) ).toInt();
285 mShowLightSources = elemDebug.attribute( QStringLiteral( "show-light-sources" ), QStringLiteral( "0" ) ).toInt();
286 mIsFpsCounterEnabled = elemDebug.attribute( QStringLiteral( "show-fps-counter" ), QStringLiteral( "0" ) ).toInt();
287 mStopUpdates = elemDebug.attribute( QStringLiteral( "stop-updates" ), QStringLiteral( "0" ) ).toInt();
288 mShowDebugPanel = elemDebug.attribute( QStringLiteral( "debug-panel" ), QStringLiteral( "0" ) ).toInt();
289
290 QDomElement elemTemporalRange = elem.firstChildElement( QStringLiteral( "temporal-range" ) );
291 QDateTime start = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "start" ) ), Qt::ISODate );
292 QDateTime end = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "end" ) ), Qt::ISODate );
293 setTemporalRange( QgsDateTimeRange( start, end ) );
294
295 QDomElement elem3dAxis = elem.firstChildElement( QStringLiteral( "axis3d" ) );
296 m3dAxisSettings.readXml( elem3dAxis, context );
297}
298
299QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const
300{
302
303 QDomElement elem = doc.createElement( QStringLiteral( "qgis3d" ) );
304
305 QDomElement elemOrigin = doc.createElement( QStringLiteral( "origin" ) );
306 elemOrigin.setAttribute( QStringLiteral( "x" ), QString::number( mOrigin.x() ) );
307 elemOrigin.setAttribute( QStringLiteral( "y" ), QString::number( mOrigin.y() ) );
308 elemOrigin.setAttribute( QStringLiteral( "z" ), QString::number( mOrigin.z() ) );
309 elem.appendChild( elemOrigin );
310
311 QDomElement elemExtent = doc.createElement( QStringLiteral( "extent" ) );
312 elemExtent.setAttribute( QStringLiteral( "xMin" ), mExtent.xMinimum() );
313 elemExtent.setAttribute( QStringLiteral( "yMin" ), mExtent.yMinimum() );
314 elemExtent.setAttribute( QStringLiteral( "xMax" ), mExtent.xMaximum() );
315 elemExtent.setAttribute( QStringLiteral( "yMax" ), mExtent.yMaximum() );
316 elemExtent.setAttribute( QStringLiteral( "showIn2dView" ), mShowExtentIn2DView );
317 elem.appendChild( elemExtent );
318
319 QDomElement elemCamera = doc.createElement( QStringLiteral( "camera" ) );
320 elemCamera.setAttribute( QStringLiteral( "field-of-view" ), mFieldOfView );
321 elemCamera.setAttribute( QStringLiteral( "projection-type" ), static_cast<int>( mProjectionType ) );
322 switch ( mCameraNavigationMode )
323 {
325 elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "terrain-based-navigation" ) );
326 break;
328 elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "walk-navigation" ) );
329 break;
331 elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "globe-terrain-based-navigation" ) );
332 break;
333 }
334 elemCamera.setAttribute( QStringLiteral( "camera-movement-speed" ), mCameraMovementSpeed );
335 elem.appendChild( elemCamera );
336
337 QDomElement elemColor = doc.createElement( QStringLiteral( "color" ) );
338 elemColor.setAttribute( QStringLiteral( "background" ), QgsColorUtils::colorToString( mBackgroundColor ) );
339 elemColor.setAttribute( QStringLiteral( "selection" ), QgsColorUtils::colorToString( mSelectionColor ) );
340 elem.appendChild( elemColor );
341
342 QDomElement elemCrs = doc.createElement( QStringLiteral( "crs" ) );
343 mCrs.writeXml( elemCrs, doc );
344 elem.appendChild( elemCrs );
345
346 QDomElement elemTerrain = doc.createElement( QStringLiteral( "terrain" ) );
347 elemTerrain.setAttribute( QStringLiteral( "terrain-rendering-enabled" ), mTerrainRenderingEnabled ? 1 : 0 );
348 elemTerrain.setAttribute( QStringLiteral( "shading-enabled" ), mTerrainShadingEnabled ? 1 : 0 );
349
350 QDomElement elemTerrainShadingMaterial = doc.createElement( QStringLiteral( "shading-material" ) );
351 mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial, context );
352 elemTerrain.appendChild( elemTerrainShadingMaterial );
353 elemTerrain.setAttribute( QStringLiteral( "map-theme" ), mTerrainMapTheme );
354 elemTerrain.setAttribute( QStringLiteral( "show-labels" ), mShowLabels ? 1 : 0 );
355
356 {
357 QDomElement elemLights = doc.createElement( QStringLiteral( "lights" ) );
358 for ( const QgsLightSource *light : mLightSources )
359 {
360 const QDomElement elemLight = light->writeXml( doc, context );
361 elemLights.appendChild( elemLight );
362 }
363 elem.appendChild( elemLights );
364 }
365
366 QDomElement elemMapLayers = doc.createElement( QStringLiteral( "layers" ) );
367 for ( const QgsMapLayerRef &layerRef : mLayers )
368 {
369 QDomElement elemMapLayer = doc.createElement( QStringLiteral( "layer" ) );
370 elemMapLayer.setAttribute( QStringLiteral( "id" ), layerRef.layerId );
371 elemMapLayers.appendChild( elemMapLayer );
372 }
373 elemTerrain.appendChild( elemMapLayers );
374
375 QDomElement elemTerrainGenerator = doc.createElement( QStringLiteral( "generator" ) );
376 elemTerrainGenerator.setAttribute( QStringLiteral( "type" ), mTerrainSettings->type() );
377 mTerrainSettings->writeXml( elemTerrain, context );
378 elemTerrain.appendChild( elemTerrainGenerator );
379 elem.appendChild( elemTerrain );
380
381 QDomElement elemSkybox = doc.createElement( QStringLiteral( "skybox" ) );
382 elemSkybox.setAttribute( QStringLiteral( "skybox-enabled" ), mIsSkyboxEnabled );
383 mSkyboxSettings.writeXml( elemSkybox, context );
384 elem.appendChild( elemSkybox );
385
386 QDomElement elemShadows = doc.createElement( QStringLiteral( "shadow-rendering" ) );
387 mShadowSettings.writeXml( elemShadows, context );
388 elem.appendChild( elemShadows );
389
390 QDomElement elemAmbientOcclusion = doc.createElement( QStringLiteral( "screen-space-ambient-occlusion" ) );
391 mAmbientOcclusionSettings.writeXml( elemAmbientOcclusion, context );
392 elem.appendChild( elemAmbientOcclusion );
393
394 QDomElement elemDebug = doc.createElement( QStringLiteral( "debug" ) );
395 elemDebug.setAttribute( QStringLiteral( "bounding-boxes" ), mShowTerrainBoundingBoxes ? 1 : 0 );
396 elemDebug.setAttribute( QStringLiteral( "terrain-tile-info" ), mShowTerrainTileInfo ? 1 : 0 );
397 elemDebug.setAttribute( QStringLiteral( "camera-view-center" ), mShowCameraViewCenter ? 1 : 0 );
398 elemDebug.setAttribute( QStringLiteral( "camera-rotation-center" ), mShowCameraRotationCenter ? 1 : 0 );
399 elemDebug.setAttribute( QStringLiteral( "show-light-sources" ), mShowLightSources ? 1 : 0 );
400 elemDebug.setAttribute( QStringLiteral( "show-fps-counter" ), mIsFpsCounterEnabled ? 1 : 0 );
401 elemDebug.setAttribute( QStringLiteral( "stop-updates" ), mStopUpdates ? 1 : 0 );
402 elemDebug.setAttribute( QStringLiteral( "debug-panel" ), mShowDebugPanel ? 1 : 0 );
403 elem.appendChild( elemDebug );
404
405 QDomElement elemEyeDomeLighting = doc.createElement( QStringLiteral( "eye-dome-lighting" ) );
406 elemEyeDomeLighting.setAttribute( QStringLiteral( "enabled" ), mEyeDomeLightingEnabled ? 1 : 0 );
407 elemEyeDomeLighting.setAttribute( QStringLiteral( "eye-dome-lighting-strength" ), mEyeDomeLightingStrength );
408 elemEyeDomeLighting.setAttribute( QStringLiteral( "eye-dome-lighting-distance" ), mEyeDomeLightingDistance );
409 elem.appendChild( elemEyeDomeLighting );
410
411 QDomElement elemNavigationSync = doc.createElement( QStringLiteral( "navigation-sync" ) );
412 elemNavigationSync.setAttribute( QStringLiteral( "view-sync-mode" ), ( int ) mViewSyncMode );
413 elemNavigationSync.setAttribute( QStringLiteral( "view-frustum-visualization-enabled" ), mVisualizeViewFrustum ? 1 : 0 );
414 elem.appendChild( elemNavigationSync );
415
416 QDomElement elemDebugSettings = doc.createElement( QStringLiteral( "debug-settings" ) );
417 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-enabled" ), mDebugShadowMapEnabled );
418 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-corner" ), mDebugShadowMapCorner );
419 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-size" ), mDebugShadowMapSize );
420 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-enabled" ), mDebugDepthMapEnabled );
421 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-corner" ), mDebugDepthMapCorner );
422 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-size" ), mDebugDepthMapSize );
423 elem.appendChild( elemDebugSettings );
424
425 QDomElement elemTemporalRange = doc.createElement( QStringLiteral( "temporal-range" ) );
426 elemTemporalRange.setAttribute( QStringLiteral( "start" ), temporalRange().begin().toString( Qt::ISODate ) );
427 elemTemporalRange.setAttribute( QStringLiteral( "end" ), temporalRange().end().toString( Qt::ISODate ) );
428
429 QDomElement elem3dAxis = doc.createElement( QStringLiteral( "axis3d" ) );
430 m3dAxisSettings.writeXml( elem3dAxis, context );
431 elem.appendChild( elem3dAxis );
432
433 return elem;
434}
435
437{
439
440 for ( int i = 0; i < mLayers.count(); ++i )
441 {
442 QgsMapLayerRef &layerRef = mLayers[i];
443 layerRef.setLayer( project.mapLayer( layerRef.layerId ) );
444 }
445
446 if ( mTerrainSettings )
447 {
448 mTerrainSettings->resolveReferences( &project );
449
450 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
451 if ( terrainGenerator )
452 {
454 }
456 }
457}
458
465
467{
469
470 if ( extent == mExtent )
471 return;
472
473 mExtent = extent;
474 const QgsPointXY center = mExtent.center();
475 setOrigin( QgsVector3D( center.x(), center.y(), 0 ) );
476 if ( mTerrainGenerator )
477 {
478 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, mTerrainGenerator->crs(), mTransformContext );
479 mTerrainGenerator->setExtent( terrainExtent );
480 }
481 emit extentChanged();
482}
483
485{
487
488 if ( origin == mOrigin )
489 return;
490
491 mOrigin = origin;
492 emit originChanged();
493}
494
496{
498
499 return mOrigin;
500}
501
508
515
517{
519
520 mCrs = crs;
521
522 // for convenience, make sure the navigation mode is consistent with the scene mode
523 if ( sceneMode() == Qgis::SceneMode::Globe && mCameraNavigationMode == Qgis::NavigationMode::TerrainBased )
524 {
526 }
527 else if ( sceneMode() == Qgis::SceneMode::Local && mCameraNavigationMode == Qgis::NavigationMode::GlobeTerrainBased )
528 {
530 }
531}
532
539
546
553
555{
557
558 mTransformContext = context;
559}
560
562{
564
565 return mPathResolver;
566}
567
569{
571
572 mPathResolver = resolver;
573}
574
581
583{
585
586 mMapThemes = mapThemes;
587}
588
589void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
590{
592
593 if ( color == mBackgroundColor )
594 return;
595
596 mBackgroundColor = color;
598}
599
601{
603
604 return mBackgroundColor;
605}
606
607void Qgs3DMapSettings::setSelectionColor( const QColor &color )
608{
610
611 if ( color == mSelectionColor )
612 return;
613
614 mSelectionColor = color;
616}
617
619{
621
622 return mSelectionColor;
623}
624
626{
628
629 if ( zScale == mTerrainSettings->verticalScale() )
630 return;
631
632 mTerrainSettings->setVerticalScale( zScale );
637}
638
640{
642
643 return mTerrainSettings->verticalScale();
644}
645
646void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
647{
649
650 const QList<QgsMapLayer *> raw = _qgis_listRefToRaw( mLayers );
651
652 if ( layers == raw )
653 return;
654
655 mLayers = _qgis_listRawToRef( layers );
656 emit layersChanged();
657}
658
659QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
660{
662
663 QList<QgsMapLayer *> lst;
664 lst.reserve( mLayers.count() );
665 for ( const QgsMapLayerRef &layerRef : mLayers )
666 {
667 if ( layerRef.layer )
668 lst.append( layerRef.layer );
669 }
670 return lst;
671}
672
674{
676
677 setExtent( fullExtent );
678
679 std::unique_ptr<QgsAbstractTerrainSettings> terrainSettings( Qgs3D::terrainRegistry()->configureTerrainFromProject( properties ) );
680 if ( terrainSettings )
681 {
683 }
684}
685
687{
689
690 return mTerrainSettings.get();
691}
692
694{
696
697 bool hasChanged = false;
698 if ( settings == mTerrainSettings.get() )
699 {
700 // emit signals anyway. We don't know if the caller changed settings on the pointer before calling this..
701 hasChanged = true;
702 }
703 else
704 {
705 // ensure to generate the terrain if the settings have changed or if the terrain has never been generated.
706 hasChanged = !settings->equals( mTerrainSettings.get() ) || !mTerrainGenerator;
707 mTerrainSettings.reset( settings );
708 }
709
710 if ( hasChanged )
711 {
712 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
713 if ( terrainGenerator )
714 {
716 }
717
718 // emit all the signals, we don't know exactly what's changed
723 emit terrainElevationOffsetChanged( mTerrainSettings->elevationOffset() );
726
728 }
729}
730
732{
734
735 if ( mTerrainSettings->mapTileResolution() == res )
736 return;
737
738 mTerrainSettings->setMapTileResolution( res );
743}
744
746{
748
749 return mTerrainSettings->mapTileResolution();
750}
751
753{
755
756 if ( mTerrainSettings->maximumScreenError() == error )
757 return;
758
759 mTerrainSettings->setMaximumScreenError( error );
764}
765
767{
769
770 return mTerrainSettings->maximumScreenError();
771}
772
774{
776
777 if ( mTerrainSettings->maximumGroundError() == error )
778 return;
779
780 mTerrainSettings->setMaximumGroundError( error );
784
786}
787
789{
791
792 if ( mTerrainSettings->elevationOffset() == offset )
793 return;
794 mTerrainSettings->setElevationOffset( offset );
796 emit terrainElevationOffsetChanged( offset );
799}
800
802{
804
805 return mTerrainSettings->elevationOffset();
806}
807
809{
811
812 return mTerrainSettings->maximumGroundError();
813}
814
816{
818
819 if ( mTerrainGenerator )
820 {
821 disconnect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
822 }
823
824 if ( gen->crs().isValid() ) // Don't bother setting an extent rect in the wrong CRS
825 {
826 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, gen->crs(), mTransformContext );
827 gen->setExtent( terrainExtent );
828 }
829 mTerrainGenerator.reset( gen );
830 connect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
831
833}
834
836{
838
839 return mTerrainGenerator.get();
840}
841
843{
845
846 if ( mTerrainShadingEnabled == enabled )
847 return;
848
849 mTerrainShadingEnabled = enabled;
851}
852
854{
856
857 return mTerrainShadingEnabled;
858}
859
861{
863
864 if ( mTerrainShadingMaterial == material )
865 return;
866
867 mTerrainShadingMaterial = material;
869}
870
877
878void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
879{
881
882 if ( mTerrainMapTheme == theme )
883 return;
884
885 mTerrainMapTheme = theme;
887}
888
890{
892
893 return mTerrainMapTheme;
894}
895
897{
899
900 if ( mShowTerrainBoundingBoxes == enabled )
901 return;
902
903 mShowTerrainBoundingBoxes = enabled;
905}
906
908{
910
911 return mShowTerrainBoundingBoxes;
912}
913
914
916{
918
919 if ( mShowTerrainTileInfo == enabled )
920 return;
921
922 mShowTerrainTileInfo = enabled;
924}
925
927{
929
930 return mShowTerrainTileInfo;
931}
932
934{
936
937 if ( mShowCameraViewCenter == enabled )
938 return;
939
940 mShowCameraViewCenter = enabled;
942}
943
945{
947
948 return mShowCameraViewCenter;
949}
950
952{
954
955 if ( mShowCameraRotationCenter == enabled )
956 return;
957
958 mShowCameraRotationCenter = enabled;
960}
961
963{
965
966 return mShowCameraRotationCenter;
967}
968
970{
972
973 if ( mShowLightSources == enabled )
974 return;
975
976 mShowLightSources = enabled;
978}
979
981{
983
984 return mShowLightSources;
985}
986
988{
990
991 if ( mShowLabels == enabled )
992 return;
993
994 mShowLabels = enabled;
995 emit showLabelsChanged();
996}
997
999{
1001
1002 return mShowLabels;
1003}
1004
1006{
1008
1009 if ( mStopUpdates == enabled )
1010 return;
1011
1012 mStopUpdates = enabled;
1013 emit stopUpdatesChanged();
1014}
1015
1017{
1019
1020 return mStopUpdates;
1021}
1022
1024{
1026
1027 if ( mEyeDomeLightingEnabled == enabled )
1028 return;
1029 mEyeDomeLightingEnabled = enabled;
1031}
1032
1034{
1036
1037 return mEyeDomeLightingEnabled;
1038}
1039
1041{
1043
1044 if ( mEyeDomeLightingStrength == strength )
1045 return;
1046 mEyeDomeLightingStrength = strength;
1048}
1049
1051{
1053
1054 return mEyeDomeLightingStrength;
1055}
1056
1058{
1060
1061 if ( mEyeDomeLightingDistance == distance )
1062 return;
1063 mEyeDomeLightingDistance = distance;
1065}
1066
1068{
1070
1071 return mEyeDomeLightingDistance;
1072}
1073
1074QList<QgsLightSource *> Qgs3DMapSettings::lightSources() const
1075{
1077
1078 return mLightSources;
1079}
1080
1081void Qgs3DMapSettings::setLightSources( const QList<QgsLightSource *> &lights )
1082{
1084
1085 // have lights actually changed?
1086 if ( mLightSources.count() == lights.count() )
1087 {
1088 bool same = true;
1089 for ( int i = 0; i < mLightSources.count(); ++i )
1090 {
1091 if ( mLightSources[i]->type() == lights[i]->type() )
1092 {
1093 switch ( mLightSources[i]->type() )
1094 {
1096 if ( *static_cast<QgsPointLightSettings *>( mLightSources[i] ) == *static_cast<QgsPointLightSettings *>( lights[i] ) )
1097 continue;
1098 break;
1100 if ( *static_cast<QgsDirectionalLightSettings *>( mLightSources[i] ) == *static_cast<QgsDirectionalLightSettings *>( lights[i] ) )
1101 continue;
1102 break;
1103 }
1104 }
1105 same = false;
1106 break;
1107 }
1108 if ( same )
1109 {
1110 qDeleteAll( lights );
1111 return;
1112 }
1113 }
1114
1115 qDeleteAll( mLightSources );
1116 mLightSources = lights;
1117
1119 emit pointLightsChanged();
1120 emit lightSourcesChanged();
1121}
1122
1124{
1126
1127 return mFieldOfView;
1128}
1129
1130void Qgs3DMapSettings::setFieldOfView( const float fieldOfView )
1131{
1133
1134 if ( mFieldOfView == fieldOfView )
1135 return;
1136
1137 mFieldOfView = fieldOfView;
1138 emit fieldOfViewChanged();
1139}
1140
1141Qt3DRender::QCameraLens::ProjectionType Qgs3DMapSettings::projectionType() const
1142{
1144
1145 return mProjectionType;
1146}
1147
1148void Qgs3DMapSettings::setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType )
1149{
1151
1152 if ( mProjectionType == projectionType )
1153 return;
1154
1155 mProjectionType = projectionType;
1156 emit projectionTypeChanged();
1157}
1158
1160{
1162
1163 return mCameraNavigationMode;
1164}
1165
1167{
1169
1170 if ( mCameraNavigationMode == navigationMode )
1171 return;
1172
1173 mCameraNavigationMode = navigationMode;
1175}
1176
1178{
1180
1181 return mCameraMovementSpeed;
1182}
1183
1185{
1187
1188 if ( mCameraMovementSpeed == movementSpeed )
1189 return;
1190
1191 mCameraMovementSpeed = movementSpeed;
1193}
1194
1195void Qgs3DMapSettings::setOutputDpi( const double dpi )
1196{
1198
1199 mDpi = dpi;
1200}
1201
1203{
1205
1206 return mDpi;
1207}
1208
1210{
1212
1213 return mSkyboxSettings;
1214}
1215
1217{
1219
1220 return mShadowSettings;
1221}
1222
1224{
1226
1227 return mAmbientOcclusionSettings;
1228}
1229
1231{
1233
1234 mSkyboxSettings = skyboxSettings;
1235 emit skyboxSettingsChanged();
1236}
1237
1239{
1241
1242 mShadowSettings = shadowSettings;
1243 emit shadowSettingsChanged();
1244}
1245
1247{
1249
1250 mAmbientOcclusionSettings = ambientOcclusionSettings;
1252}
1253
1255{
1257
1258 return mIsSkyboxEnabled;
1259}
1260
1262{
1264
1265 mIsSkyboxEnabled = enabled;
1266}
1267
1269{
1271
1272 return mIsFpsCounterEnabled;
1273}
1274
1275void Qgs3DMapSettings::setShowDebugPanel( const bool enabled )
1276{
1278
1279 if ( mShowDebugPanel == enabled )
1280 return;
1281
1282 mShowDebugPanel = enabled;
1283 emit showDebugPanelChanged( enabled );
1284}
1285
1287{
1289
1290 return mShowDebugPanel;
1291}
1292
1293void Qgs3DMapSettings::setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size )
1294{
1296
1297 mDebugShadowMapEnabled = enabled;
1298 mDebugShadowMapCorner = corner;
1299 mDebugShadowMapSize = size;
1301}
1302
1304{
1306
1307 return mDebugShadowMapEnabled;
1308}
1309
1311{
1313
1314 return mDebugShadowMapCorner;
1315}
1316
1318{
1320
1321 return mDebugShadowMapSize;
1322}
1323
1324void Qgs3DMapSettings::setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size )
1325{
1327
1328 mDebugDepthMapEnabled = enabled;
1329 mDebugDepthMapCorner = corner;
1330 mDebugDepthMapSize = size;
1332}
1333
1335{
1337
1338 return mDebugDepthMapEnabled;
1339}
1340
1342{
1344
1345 return mDebugDepthMapCorner;
1346}
1347
1349{
1351
1352 return mDebugDepthMapSize;
1353}
1354
1355void Qgs3DMapSettings::setIsFpsCounterEnabled( bool fpsCounterEnabled )
1356{
1358
1359 if ( fpsCounterEnabled == mIsFpsCounterEnabled )
1360 return;
1361 mIsFpsCounterEnabled = fpsCounterEnabled;
1362 emit fpsCounterEnabledChanged( mIsFpsCounterEnabled );
1363}
1364
1366{
1368
1369 return mTerrainRenderingEnabled;
1370}
1371
1372void Qgs3DMapSettings::setTerrainRenderingEnabled( bool terrainRenderingEnabled )
1373{
1375
1376 if ( terrainRenderingEnabled == mTerrainRenderingEnabled )
1377 return;
1378 mTerrainRenderingEnabled = terrainRenderingEnabled;
1380}
1381
1383{
1385
1386 return mRendererUsage;
1387}
1388
1390{
1392
1393 mRendererUsage = rendererUsage;
1394}
1395
1402
1404{
1406
1407 mViewSyncMode = mode;
1408}
1409
1411{
1413
1414 return mVisualizeViewFrustum;
1415}
1416
1418{
1420
1421 if ( mVisualizeViewFrustum != enabled )
1422 {
1423 mVisualizeViewFrustum = enabled;
1425 }
1426}
1427
1429{
1431
1432 return m3dAxisSettings;
1433}
1434
1435void Qgs3DMapSettings::setIsDebugOverlayEnabled( bool debugOverlayEnabled )
1436{
1438
1439 if ( debugOverlayEnabled == mIsDebugOverlayEnabled )
1440 return;
1441
1442 mIsDebugOverlayEnabled = debugOverlayEnabled;
1443 emit debugOverlayEnabledChanged( mIsDebugOverlayEnabled );
1444}
1445
1447{
1449
1450 return mShowExtentIn2DView;
1451}
1452
1453void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
1454{
1456
1488}
1489
1490
1491void Qgs3DMapSettings::set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force )
1492{
1494
1495 if ( axisSettings == m3dAxisSettings )
1496 {
1497 if ( force )
1498 {
1499 // ie. refresh. We need to disconnect and to reconnect to avoid 'dirty' project
1501 emit axisSettingsChanged();
1503 }
1504 }
1505 else
1506 {
1507 m3dAxisSettings = axisSettings;
1508 emit axisSettingsChanged();
1509 }
1510}
1511
1513{
1515
1516 return mIsDebugOverlayEnabled;
1517}
1518
1520{
1522
1523 if ( show == mShowExtentIn2DView )
1524 return;
1525
1526 mShowExtentIn2DView = show;
1528}
@ Geocentric
Geocentric CRS.
QFlags< ViewSyncModeFlag > ViewSyncModeFlags
Definition qgis.h:3350
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:4006
@ TerrainBased
The default navigation based on the terrain.
@ Walk
Uses WASD keys or arrows to navigate in walking (first person) manner.
@ GlobeTerrainBased
Navigation similar to TerrainBased, but for use with globe.
RendererUsage
Usage of the renderer.
Definition qgis.h:3313
SceneMode
The 3D scene mode used in 3D map views.
Definition qgis.h:4019
@ Globe
Scene is represented as a globe using a geocentric CRS.
@ Local
Local scene based on a projected CRS.
@ 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.
Definition of the world.
void extentChanged()
Emitted when the 3d view's 2d extent has changed.
void setEyeDomeLightingStrength(double strength)
Sets the eye dome lighting strength value.
bool isDebugOverlayEnabled() const
Returns whether debug overlay is enabled.
Qt::Corner debugDepthMapCorner() const
Returns the corner where the shadow map preview is displayed.
void originChanged()
Emitted when the world's origin point has been shifted.
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.
Q_DECL_DEPRECATED double terrainElevationOffset() const
Returns the elevation offset of the terrain (used to move the terrain up or down)
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.
Q_DECL_DEPRECATED void setMaxTerrainGroundError(double error)
Sets the maximum ground error of terrain tiles in world units.
Q_DECL_DEPRECATED void terrainElevationOffsetChanged(double newElevation)
Emitted when the terrain elevation offset is 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.
const QgsAbstractTerrainSettings * terrainSettings() const
Returns the terrain settings.
Q_DECL_DEPRECATED void maxTerrainScreenErrorChanged()
Emitted when the maximum terrain screen error has changed.
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)
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.
Q_DECL_DEPRECATED 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.
Qgis::SceneMode sceneMode() const
Returns mode of the 3D scene - whether it is represented as a globe (when using Geocentric CRS such a...
void setShowLabels(bool enabled)
Sets whether to display labels on terrain tiles.
Q_DECL_DEPRECATED 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 setSkyboxSettings(const QgsSkyboxSettings &skyboxSettings)
Sets the current configuration of the skybox.
void skyboxSettingsChanged()
Emitted when skybox settings are changed.
Q_DECL_DEPRECATED 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.
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.
Q_DECL_DEPRECATED double maxTerrainScreenError() const
Returns maximum allowed screen error of terrain tiles in pixels.
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.
Q_DECL_DEPRECATED void maxTerrainGroundErrorChanged()
Emitted when the maximum terrain ground error has changed.
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)
Q_DECL_DEPRECATED void mapTileResolutionChanged()
Emitted when the map tile resoulution has changed.
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.
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 terrainSettingsChanged()
Emitted when the terrain settings are changed.
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 setShowCameraViewCenter(bool enabled)
Sets whether to show camera's view center as a sphere (for debugging)
Q_DECL_DEPRECATED 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 setTerrainSettings(QgsAbstractTerrainSettings *settings)
Sets the terrain settings.
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 setTerrainRenderingEnabled(bool terrainRenderingEnabled)
Sets whether the 2D terrain surface will be rendered in.
bool debugShadowMapEnabled() const
Returns whether the shadow map debugging is enabled.
Q_DECL_DEPRECATED void setMaxTerrainScreenError(double error)
Sets maximum allowed screen error of terrain tiles in pixels.
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.
Q_DECL_DEPRECATED double maxTerrainGroundError() const
Returns maximum ground error of terrain tiles in world units.
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.
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.
Q_DECL_DEPRECATED void setTerrainElevationOffset(double offset)
Sets the terrain elevation offset (used to move the terrain up or down)
Q_DECL_DEPRECATED void terrainVerticalScaleChanged()
Emitted when the vertical scale of the terrain has changed.
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.
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 Qgs3DRenderContext fromMapSettings(const Qgs3DMapSettings *mapSettings)
Creates an initialized Qgs3DRenderContext instance from given Qgs3DMapSettings.
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)
static Qgs3DTerrainRegistry * terrainRegistry()
Returns the terrain registry, used for managing 3D terrains.
Definition qgs3d.cpp:93
Base class for all terrain settings classes.
virtual void readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads settings from a DOM element.
virtual bool equals(const QgsAbstractTerrainSettings *other) const =0
Returns true if this settings is exactly equal to another other settings.
Contains the configuration of ambient occlusion rendering.
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.
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.
Qgis::CrsType type() const
Returns the type of the CRS.
Contains information about the context in which a coordinate transform is executed.
Definition of a directional light in a 3D map scene.
Terrain settings for a simple flat area terrain.
Base class for light sources in 3d scenes.
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.
Resolves relative paths into absolute paths and vice versa.
Basic shading material used for rendering based on the Phong shading model with three color component...
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.
Definition of a point light in a 3D map scene.
Represents 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.
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 container for the context for various read/write operations on objects.
A rectangle specified with double values.
double xMinimum
double yMinimum
double xMaximum
double yMaximum
QgsPointXY center
Contains configuration for rendering shadows.
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:446
T end() const
Returns the upper bound of the range.
Definition qgsrange.h:453
Base class for generators of terrain.
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
virtual QgsCoordinateReferenceSystem crs() const
Returns CRS of the terrain.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:30
double y() const
Returns Y coordinate.
Definition qgsvector3d.h:49
double z() const
Returns Z coordinate.
Definition qgsvector3d.h:51
double x() const
Returns X coordinate.
Definition qgsvector3d.h:47
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:6819
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:6818
_LayerRef< QgsMapLayer > QgsMapLayerRef
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:760
#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.