QGIS API Documentation 3.43.0-Master (0bee5d6404c)
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
460{
462
464 {
465 QgsDebugError( QStringLiteral( "extent() should not be used with globe!" ) );
466 }
467
468 return mExtent;
469}
470
472{
474
475 if ( extent == mExtent )
476 return;
477
479 {
480 QgsDebugError( QStringLiteral( "setExtent() should not be used with globe!" ) );
481 }
482
483 mExtent = extent;
484 const QgsPointXY center = mExtent.center();
485 setOrigin( QgsVector3D( center.x(), center.y(), 0 ) );
486 if ( mTerrainGenerator )
487 {
488 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, mTerrainGenerator->crs(), mTransformContext );
489 mTerrainGenerator->setExtent( terrainExtent );
490 }
491 emit extentChanged();
492}
493
495{
497
498 if ( origin == mOrigin )
499 return;
500
501 mOrigin = origin;
502 emit originChanged();
503}
504
506{
508
509 return mOrigin;
510}
511
518
525
527{
529
530 mCrs = crs;
531
532 // for convenience, make sure the navigation mode is consistent with the scene mode
533 if ( sceneMode() == Qgis::SceneMode::Globe && mCameraNavigationMode == Qgis::NavigationMode::TerrainBased )
534 {
536 }
537 else if ( sceneMode() == Qgis::SceneMode::Local && mCameraNavigationMode == Qgis::NavigationMode::GlobeTerrainBased )
538 {
540 }
541}
542
549
556
563
565{
567
568 mTransformContext = context;
569}
570
572{
574
575 return mPathResolver;
576}
577
579{
581
582 mPathResolver = resolver;
583}
584
591
593{
595
596 mMapThemes = mapThemes;
597}
598
599void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
600{
602
603 if ( color == mBackgroundColor )
604 return;
605
606 mBackgroundColor = color;
608}
609
611{
613
614 return mBackgroundColor;
615}
616
617void Qgs3DMapSettings::setSelectionColor( const QColor &color )
618{
620
621 if ( color == mSelectionColor )
622 return;
623
624 mSelectionColor = color;
626}
627
629{
631
632 return mSelectionColor;
633}
634
636{
638
639 if ( zScale == mTerrainSettings->verticalScale() )
640 return;
641
642 mTerrainSettings->setVerticalScale( zScale );
647}
648
650{
652
653 return mTerrainSettings->verticalScale();
654}
655
656void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
657{
659
660 const QList<QgsMapLayer *> raw = _qgis_listRefToRaw( mLayers );
661
662 if ( layers == raw )
663 return;
664
665 mLayers = _qgis_listRawToRef( layers );
666 emit layersChanged();
667}
668
669QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
670{
672
673 QList<QgsMapLayer *> lst;
674 lst.reserve( mLayers.count() );
675 for ( const QgsMapLayerRef &layerRef : mLayers )
676 {
677 if ( layerRef.layer )
678 lst.append( layerRef.layer );
679 }
680 return lst;
681}
682
684{
686
687 setExtent( fullExtent );
688
689 std::unique_ptr<QgsAbstractTerrainSettings> terrainSettings( Qgs3D::terrainRegistry()->configureTerrainFromProject( properties ) );
690 if ( terrainSettings )
691 {
693 }
694}
695
697{
699
700 return mTerrainSettings.get();
701}
702
704{
706
707 bool hasChanged = false;
708 if ( settings == mTerrainSettings.get() )
709 {
710 // emit signals anyway. We don't know if the caller changed settings on the pointer before calling this..
711 hasChanged = true;
712 }
713 else
714 {
715 // ensure to generate the terrain if the settings have changed or if the terrain has never been generated.
716 hasChanged = !settings->equals( mTerrainSettings.get() ) || !mTerrainGenerator;
717 mTerrainSettings.reset( settings );
718 }
719
720 if ( hasChanged )
721 {
722 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
723 if ( terrainGenerator )
724 {
726 }
727
728 // emit all the signals, we don't know exactly what's changed
733 emit terrainElevationOffsetChanged( mTerrainSettings->elevationOffset() );
736
738 }
739}
740
742{
744
745 if ( mTerrainSettings->mapTileResolution() == res )
746 return;
747
748 mTerrainSettings->setMapTileResolution( res );
753}
754
756{
758
759 return mTerrainSettings->mapTileResolution();
760}
761
763{
765
766 if ( mTerrainSettings->maximumScreenError() == error )
767 return;
768
769 mTerrainSettings->setMaximumScreenError( error );
774}
775
777{
779
780 return mTerrainSettings->maximumScreenError();
781}
782
784{
786
787 if ( mTerrainSettings->maximumGroundError() == error )
788 return;
789
790 mTerrainSettings->setMaximumGroundError( error );
794
796}
797
799{
801
802 if ( mTerrainSettings->elevationOffset() == offset )
803 return;
804 mTerrainSettings->setElevationOffset( offset );
806 emit terrainElevationOffsetChanged( offset );
809}
810
812{
814
815 return mTerrainSettings->elevationOffset();
816}
817
819{
821
822 return mTerrainSettings->maximumGroundError();
823}
824
826{
828
829 if ( mTerrainGenerator )
830 {
831 disconnect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
832 }
833
834 if ( gen->crs().isValid() ) // Don't bother setting an extent rect in the wrong CRS
835 {
836 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, gen->crs(), mTransformContext );
837 gen->setExtent( terrainExtent );
838 }
839 mTerrainGenerator.reset( gen );
840 connect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
841
843}
844
846{
848
849 return mTerrainGenerator.get();
850}
851
853{
855
856 if ( mTerrainShadingEnabled == enabled )
857 return;
858
859 mTerrainShadingEnabled = enabled;
861}
862
864{
866
867 return mTerrainShadingEnabled;
868}
869
871{
873
874 if ( mTerrainShadingMaterial == material )
875 return;
876
877 mTerrainShadingMaterial = material;
879}
880
887
888void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
889{
891
892 if ( mTerrainMapTheme == theme )
893 return;
894
895 mTerrainMapTheme = theme;
897}
898
900{
902
903 return mTerrainMapTheme;
904}
905
907{
909
910 if ( mShowTerrainBoundingBoxes == enabled )
911 return;
912
913 mShowTerrainBoundingBoxes = enabled;
915}
916
918{
920
921 return mShowTerrainBoundingBoxes;
922}
923
924
926{
928
929 if ( mShowTerrainTileInfo == enabled )
930 return;
931
932 mShowTerrainTileInfo = enabled;
934}
935
937{
939
940 return mShowTerrainTileInfo;
941}
942
944{
946
947 if ( mShowCameraViewCenter == enabled )
948 return;
949
950 mShowCameraViewCenter = enabled;
952}
953
955{
957
958 return mShowCameraViewCenter;
959}
960
962{
964
965 if ( mShowCameraRotationCenter == enabled )
966 return;
967
968 mShowCameraRotationCenter = enabled;
970}
971
973{
975
976 return mShowCameraRotationCenter;
977}
978
980{
982
983 if ( mShowLightSources == enabled )
984 return;
985
986 mShowLightSources = enabled;
988}
989
991{
993
994 return mShowLightSources;
995}
996
998{
1000
1001 if ( mShowLabels == enabled )
1002 return;
1003
1004 mShowLabels = enabled;
1005 emit showLabelsChanged();
1006}
1007
1009{
1011
1012 return mShowLabels;
1013}
1014
1016{
1018
1019 if ( mStopUpdates == enabled )
1020 return;
1021
1022 mStopUpdates = enabled;
1023 emit stopUpdatesChanged();
1024}
1025
1027{
1029
1030 return mStopUpdates;
1031}
1032
1034{
1036
1037 if ( mEyeDomeLightingEnabled == enabled )
1038 return;
1039 mEyeDomeLightingEnabled = enabled;
1041}
1042
1044{
1046
1047 return mEyeDomeLightingEnabled;
1048}
1049
1051{
1053
1054 if ( mEyeDomeLightingStrength == strength )
1055 return;
1056 mEyeDomeLightingStrength = strength;
1058}
1059
1061{
1063
1064 return mEyeDomeLightingStrength;
1065}
1066
1068{
1070
1071 if ( mEyeDomeLightingDistance == distance )
1072 return;
1073 mEyeDomeLightingDistance = distance;
1075}
1076
1078{
1080
1081 return mEyeDomeLightingDistance;
1082}
1083
1084QList<QgsLightSource *> Qgs3DMapSettings::lightSources() const
1085{
1087
1088 return mLightSources;
1089}
1090
1091void Qgs3DMapSettings::setLightSources( const QList<QgsLightSource *> &lights )
1092{
1094
1095 // have lights actually changed?
1096 if ( mLightSources.count() == lights.count() )
1097 {
1098 bool same = true;
1099 for ( int i = 0; i < mLightSources.count(); ++i )
1100 {
1101 if ( mLightSources[i]->type() == lights[i]->type() )
1102 {
1103 switch ( mLightSources[i]->type() )
1104 {
1106 if ( *static_cast<QgsPointLightSettings *>( mLightSources[i] ) == *static_cast<QgsPointLightSettings *>( lights[i] ) )
1107 continue;
1108 break;
1110 if ( *static_cast<QgsDirectionalLightSettings *>( mLightSources[i] ) == *static_cast<QgsDirectionalLightSettings *>( lights[i] ) )
1111 continue;
1112 break;
1113 }
1114 }
1115 same = false;
1116 break;
1117 }
1118 if ( same )
1119 {
1120 qDeleteAll( lights );
1121 return;
1122 }
1123 }
1124
1125 qDeleteAll( mLightSources );
1126 mLightSources = lights;
1127
1129 emit pointLightsChanged();
1130 emit lightSourcesChanged();
1131}
1132
1134{
1136
1137 return mFieldOfView;
1138}
1139
1140void Qgs3DMapSettings::setFieldOfView( const float fieldOfView )
1141{
1143
1144 if ( mFieldOfView == fieldOfView )
1145 return;
1146
1147 mFieldOfView = fieldOfView;
1148 emit fieldOfViewChanged();
1149}
1150
1151Qt3DRender::QCameraLens::ProjectionType Qgs3DMapSettings::projectionType() const
1152{
1154
1155 return mProjectionType;
1156}
1157
1158void Qgs3DMapSettings::setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType )
1159{
1161
1162 if ( mProjectionType == projectionType )
1163 return;
1164
1165 mProjectionType = projectionType;
1166 emit projectionTypeChanged();
1167}
1168
1170{
1172
1173 return mCameraNavigationMode;
1174}
1175
1177{
1179
1180 if ( mCameraNavigationMode == navigationMode )
1181 return;
1182
1183 mCameraNavigationMode = navigationMode;
1185}
1186
1188{
1190
1191 return mCameraMovementSpeed;
1192}
1193
1195{
1197
1198 if ( mCameraMovementSpeed == movementSpeed )
1199 return;
1200
1201 mCameraMovementSpeed = movementSpeed;
1203}
1204
1205void Qgs3DMapSettings::setOutputDpi( const double dpi )
1206{
1208
1209 mDpi = dpi;
1210}
1211
1213{
1215
1216 return mDpi;
1217}
1218
1220{
1222
1223 return mSkyboxSettings;
1224}
1225
1227{
1229
1230 return mShadowSettings;
1231}
1232
1234{
1236
1237 return mAmbientOcclusionSettings;
1238}
1239
1241{
1243
1244 mSkyboxSettings = skyboxSettings;
1245 emit skyboxSettingsChanged();
1246}
1247
1249{
1251
1252 mShadowSettings = shadowSettings;
1253 emit shadowSettingsChanged();
1254}
1255
1257{
1259
1260 mAmbientOcclusionSettings = ambientOcclusionSettings;
1262}
1263
1265{
1267
1268 return mIsSkyboxEnabled;
1269}
1270
1272{
1274
1275 mIsSkyboxEnabled = enabled;
1276}
1277
1279{
1281
1282 return mIsFpsCounterEnabled;
1283}
1284
1285void Qgs3DMapSettings::setShowDebugPanel( const bool enabled )
1286{
1288
1289 if ( mShowDebugPanel == enabled )
1290 return;
1291
1292 mShowDebugPanel = enabled;
1293 emit showDebugPanelChanged( enabled );
1294}
1295
1297{
1299
1300 return mShowDebugPanel;
1301}
1302
1303void Qgs3DMapSettings::setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size )
1304{
1306
1307 mDebugShadowMapEnabled = enabled;
1308 mDebugShadowMapCorner = corner;
1309 mDebugShadowMapSize = size;
1311}
1312
1314{
1316
1317 return mDebugShadowMapEnabled;
1318}
1319
1321{
1323
1324 return mDebugShadowMapCorner;
1325}
1326
1328{
1330
1331 return mDebugShadowMapSize;
1332}
1333
1334void Qgs3DMapSettings::setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size )
1335{
1337
1338 mDebugDepthMapEnabled = enabled;
1339 mDebugDepthMapCorner = corner;
1340 mDebugDepthMapSize = size;
1342}
1343
1345{
1347
1348 return mDebugDepthMapEnabled;
1349}
1350
1352{
1354
1355 return mDebugDepthMapCorner;
1356}
1357
1359{
1361
1362 return mDebugDepthMapSize;
1363}
1364
1365void Qgs3DMapSettings::setIsFpsCounterEnabled( bool fpsCounterEnabled )
1366{
1368
1369 if ( fpsCounterEnabled == mIsFpsCounterEnabled )
1370 return;
1371 mIsFpsCounterEnabled = fpsCounterEnabled;
1372 emit fpsCounterEnabledChanged( mIsFpsCounterEnabled );
1373}
1374
1376{
1378
1379 return mTerrainRenderingEnabled;
1380}
1381
1382void Qgs3DMapSettings::setTerrainRenderingEnabled( bool terrainRenderingEnabled )
1383{
1385
1386 if ( terrainRenderingEnabled == mTerrainRenderingEnabled )
1387 return;
1388 mTerrainRenderingEnabled = terrainRenderingEnabled;
1390}
1391
1393{
1395
1396 return mRendererUsage;
1397}
1398
1400{
1402
1403 mRendererUsage = rendererUsage;
1404}
1405
1412
1414{
1416
1417 mViewSyncMode = mode;
1418}
1419
1421{
1423
1424 return mVisualizeViewFrustum;
1425}
1426
1428{
1430
1431 if ( mVisualizeViewFrustum != enabled )
1432 {
1433 mVisualizeViewFrustum = enabled;
1435 }
1436}
1437
1439{
1441
1442 return m3dAxisSettings;
1443}
1444
1445void Qgs3DMapSettings::setIsDebugOverlayEnabled( bool debugOverlayEnabled )
1446{
1448
1449 if ( debugOverlayEnabled == mIsDebugOverlayEnabled )
1450 return;
1451
1452 mIsDebugOverlayEnabled = debugOverlayEnabled;
1453 emit debugOverlayEnabledChanged( mIsDebugOverlayEnabled );
1454}
1455
1457{
1459
1460 return mShowExtentIn2DView;
1461}
1462
1463void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
1464{
1466
1498}
1499
1500
1501void Qgs3DMapSettings::set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force )
1502{
1504
1505 if ( axisSettings == m3dAxisSettings )
1506 {
1507 if ( force )
1508 {
1509 // ie. refresh. We need to disconnect and to reconnect to avoid 'dirty' project
1511 emit axisSettingsChanged();
1513 }
1514 }
1515 else
1516 {
1517 m3dAxisSettings = axisSettings;
1518 emit axisSettingsChanged();
1519 }
1520}
1521
1523{
1525
1526 return mIsDebugOverlayEnabled;
1527}
1528
1530{
1532
1533 if ( show == mShowExtentIn2DView )
1534 return;
1535
1536 mShowExtentIn2DView = show;
1538}
@ 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:6820
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:6819
#define QgsDebugError(str)
Definition qgslogger.h:40
_LayerRef< QgsMapLayer > QgsMapLayerRef
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:761
#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.