QGIS API Documentation 4.1.0-Master (01362494303)
Loading...
Searching...
No Matches
qgs3dmapsettings.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgs3dmapsettings.cpp
3 --------------------------------------
4 Date : July 2017
5 Copyright : (C) 2017 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgs3dmapsettings.h"
17
18#include "qgs3d.h"
19#include "qgs3drendercontext.h"
21#include "qgs3dutils.h"
23#include "qgscolorutils.h"
26#include "qgslightsource.h"
31#include "qgsrasterlayer.h"
32#include "qgsterrainprovider.h"
33#include "qgsthreadingutils.h"
34
35#include <QDomDocument>
36#include <QDomElement>
37#include <QString>
38
39#include "moc_qgs3dmapsettings.cpp"
40
41using namespace Qt::StringLiterals;
42
44 : QObject( nullptr )
45{
46 connect( this, &Qgs3DMapSettings::settingsChanged, [&]() { QgsProject::instance()->setDirty(); } );
47 connectChangedSignalsToSettingsChanged();
48 mTerrainSettings = std::make_unique<QgsFlatTerrainSettings>();
49}
50
52 : QObject( nullptr )
53 , QgsTemporalRangeObject( other )
54 , mOrigin( other.mOrigin )
55 , mCrs( other.mCrs )
56 , mBackgroundColor( other.mBackgroundColor )
57 , mSelectionColor( other.mSelectionColor )
58 , mTerrainShadingEnabled( other.mTerrainShadingEnabled )
59 , mTerrainShadingMaterial( other.mTerrainShadingMaterial )
60 , mTerrainMapTheme( other.mTerrainMapTheme )
61 , mShowTerrainBoundingBoxes( other.mShowTerrainBoundingBoxes )
62 , mShowTerrainTileInfo( other.mShowTerrainTileInfo )
63 , mShowCameraViewCenter( other.mShowCameraViewCenter )
64 , mShowCameraRotationCenter( other.mShowCameraRotationCenter )
65 , mShowLightSources( other.mShowLightSources )
66 , mShowLabels( other.mShowLabels )
67 , mStopUpdates( other.mStopUpdates )
68 , mShowDebugPanel( other.mShowDebugPanel )
69 , mFieldOfView( other.mFieldOfView )
70 , mProjectionType( other.mProjectionType )
71 , mCameraNavigationMode( other.mCameraNavigationMode )
72 , mCameraMovementSpeed( other.mCameraMovementSpeed )
73 , mLayers( other.mLayers )
74 , mTransformContext( other.mTransformContext )
75 , mPathResolver( other.mPathResolver )
76 , mMapThemes( other.mMapThemes )
77 , mDpi( other.mDpi )
78 , mIsFpsCounterEnabled( other.mIsFpsCounterEnabled )
79 , mBackgroundType( other.mBackgroundType )
80 , mGradientBackgroundTopColor( other.mGradientBackgroundTopColor )
81 , mGradientBackgroundBottomColor( other.mGradientBackgroundBottomColor )
82 , mSkyboxSettings( other.mSkyboxSettings )
83 , mShadowSettings( other.mShadowSettings )
84 , mAmbientOcclusionSettings( other.mAmbientOcclusionSettings )
85 , mEyeDomeLightingEnabled( other.mEyeDomeLightingEnabled )
86 , mEyeDomeLightingStrength( other.mEyeDomeLightingStrength )
87 , mEyeDomeLightingDistance( other.mEyeDomeLightingDistance )
88 , mMsaaEnabled( other.mMsaaEnabled )
89 , mViewSyncMode( other.mViewSyncMode )
90 , mVisualizeViewFrustum( other.mVisualizeViewFrustum )
91 , mDebugShadowMapEnabled( other.mDebugShadowMapEnabled )
92 , mDebugShadowMapCorner( other.mDebugShadowMapCorner )
93 , mDebugShadowMapSize( other.mDebugShadowMapSize )
94 , mDebugDepthMapEnabled( other.mDebugDepthMapEnabled )
95 , mDebugDepthMapCorner( other.mDebugDepthMapCorner )
96 , mDebugDepthMapSize( other.mDebugDepthMapSize )
97 , mTerrainRenderingEnabled( other.mTerrainRenderingEnabled )
98 , mRendererUsage( other.mRendererUsage )
99 , m3dAxisSettings( other.m3dAxisSettings )
100 , mIsDebugOverlayEnabled( other.mIsDebugOverlayEnabled )
101 , mExtent( other.mExtent )
102 , mShowExtentIn2DView( other.mShowExtentIn2DView )
103 , mShow2DMapOverlay( other.mShow2DMapOverlay )
104{
105 setTerrainSettings( other.mTerrainSettings ? other.mTerrainSettings->clone() : new QgsFlatTerrainSettings() );
106
107 for ( QgsLightSource *source : std::as_const( other.mLightSources ) )
108 {
109 if ( source )
110 mLightSources << source->clone();
111 }
112
113 connect( this, &Qgs3DMapSettings::settingsChanged, [&]() { QgsProject::instance()->setDirty(); } );
114 connectChangedSignalsToSettingsChanged();
115}
116
118{
119 qDeleteAll( mLightSources );
120}
121
122void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
123{
125
127 QDomElement elemOrigin = elem.firstChildElement( u"origin"_s );
128 // clang-format off
129 mOrigin = QgsVector3D(
130 elemOrigin.attribute( u"x"_s ).toDouble(),
131 elemOrigin.attribute( u"y"_s ).toDouble(),
132 elemOrigin.attribute( u"z"_s ).toDouble()
133 );
134 // clang-format on
135
136 QDomElement elemExtent = elem.firstChildElement( u"extent"_s );
137 if ( !elemExtent.isNull() )
138 {
139 // clang-format off
140 mExtent = QgsRectangle(
141 elemExtent.attribute( u"xMin"_s ).toDouble(),
142 elemExtent.attribute( u"yMin"_s ).toDouble(),
143 elemExtent.attribute( u"xMax"_s ).toDouble(),
144 elemExtent.attribute( u"yMax"_s ).toDouble()
145 );
146 // clang-format on
147
148 mShowExtentIn2DView = elemExtent.attribute( u"showIn2dView"_s, u"0"_s ).toInt();
149 }
150 else
151 {
153 }
154
155 QDomElement elemCamera = elem.firstChildElement( u"camera"_s );
156 if ( !elemCamera.isNull() )
157 {
158 mFieldOfView = elemCamera.attribute( u"field-of-view"_s, u"45"_s ).toFloat();
159 mProjectionType = static_cast<Qt3DRender::QCameraLens::ProjectionType>( elemCamera.attribute( u"projection-type"_s, u"1"_s ).toInt() );
160 QString cameraNavigationMode = elemCamera.attribute( u"camera-navigation-mode"_s, u"basic-navigation"_s );
161 if ( cameraNavigationMode == "terrain-based-navigation"_L1 )
162 mCameraNavigationMode = Qgis::NavigationMode::TerrainBased;
163 else if ( cameraNavigationMode == "walk-navigation"_L1 )
164 mCameraNavigationMode = Qgis::NavigationMode::Walk;
165 else if ( cameraNavigationMode == "globe-terrain-based-navigation"_L1 )
166 mCameraNavigationMode = Qgis::NavigationMode::GlobeTerrainBased;
167 mCameraMovementSpeed = elemCamera.attribute( u"camera-movement-speed"_s, u"5.0"_s ).toDouble();
168 }
169
170 QDomElement elemColor = elem.firstChildElement( u"color"_s );
171 if ( !elemColor.isNull() )
172 {
173 mBackgroundColor = QgsColorUtils::colorFromString( elemColor.attribute( u"background"_s ) );
174 mSelectionColor = QgsColorUtils::colorFromString( elemColor.attribute( u"selection"_s ) );
175 }
176
177 QDomElement elemCrs = elem.firstChildElement( u"crs"_s );
178 mCrs.readXml( elemCrs );
179
180 QDomElement elemTerrain = elem.firstChildElement( u"terrain"_s );
181 mTerrainRenderingEnabled = elemTerrain.attribute( u"terrain-rendering-enabled"_s, u"1"_s ).toInt();
182 mTerrainShadingEnabled = elemTerrain.attribute( u"shading-enabled"_s, u"0"_s ).toInt();
183
184 QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( u"shading-material"_s );
185 if ( !elemTerrainShadingMaterial.isNull() )
186 mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial, context );
187 mTerrainMapTheme = elemTerrain.attribute( u"map-theme"_s );
188 mShowLabels = elemTerrain.attribute( u"show-labels"_s, u"0"_s ).toInt();
189
190 qDeleteAll( mLightSources );
191 mLightSources.clear();
192 const QDomElement lightsElem = elem.firstChildElement( u"lights"_s );
193 if ( !lightsElem.isNull() )
194 {
195 const QDomNodeList lightNodes = lightsElem.childNodes();
196 for ( int i = 0; i < lightNodes.size(); ++i )
197 {
198 const QDomElement lightElement = lightNodes.at( i ).toElement();
199 if ( QgsLightSource *light = QgsLightSource::createFromXml( lightElement, context ) )
200 mLightSources << light;
201 }
202 }
203 else
204 {
205 // older project format
206 QDomElement elemPointLights = elem.firstChildElement( u"point-lights"_s );
207 if ( !elemPointLights.isNull() )
208 {
209 QDomElement elemPointLight = elemPointLights.firstChildElement( u"point-light"_s );
210 while ( !elemPointLight.isNull() )
211 {
212 auto pointLight = std::make_unique<QgsPointLightSettings>();
213 pointLight->readXml( elemPointLight, context );
214 mLightSources << pointLight.release();
215 elemPointLight = elemPointLight.nextSiblingElement( u"point-light"_s );
216 }
217 }
218 else
219 {
220 // QGIS <= 3.4 did not have light configuration
221 auto defaultLight = std::make_unique<QgsPointLightSettings>();
222 defaultLight->setPosition( QgsVector3D( 0, 1000, 0 ) );
223 mLightSources << defaultLight.release();
224 }
225
226 QDomElement elemDirectionalLights = elem.firstChildElement( u"directional-lights"_s );
227 if ( !elemDirectionalLights.isNull() )
228 {
229 QDomElement elemDirectionalLight = elemDirectionalLights.firstChildElement( u"directional-light"_s );
230 while ( !elemDirectionalLight.isNull() )
231 {
232 auto directionalLight = std::make_unique<QgsDirectionalLightSettings>();
233 directionalLight->readXml( elemDirectionalLight, context );
234 mLightSources << directionalLight.release();
235 elemDirectionalLight = elemDirectionalLight.nextSiblingElement( u"directional-light"_s );
236 }
237 }
238 }
239
240 QDomElement elemMapLayers = elemTerrain.firstChildElement( u"layers"_s );
241 QDomElement elemMapLayer = elemMapLayers.firstChildElement( u"layer"_s );
242 QList<QgsMapLayerRef> mapLayers;
243 while ( !elemMapLayer.isNull() )
244 {
245 mapLayers << QgsMapLayerRef( elemMapLayer.attribute( u"id"_s ) );
246 elemMapLayer = elemMapLayer.nextSiblingElement( u"layer"_s );
247 }
248 mLayers = mapLayers; // needs to resolve refs afterwards
249
250 QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( u"generator"_s );
251 const QString terrainGenType = elemTerrainGenerator.attribute( u"type"_s );
252 std::unique_ptr<QgsAbstractTerrainSettings> terrainSettings( Qgs3D::terrainRegistry()->createTerrainSettings( terrainGenType ) );
253 if ( terrainSettings )
254 {
255 terrainSettings->readXml( elemTerrain, context );
257 }
258
259 QDomElement elemSkybox = elem.firstChildElement( u"skybox"_s );
260 mSkyboxSettings.readXml( elemSkybox, context );
261
262 QDomElement elemGradientBackground = elem.firstChildElement( u"gradient-background"_s );
263 if ( !elemGradientBackground.isNull() )
264 {
265 mGradientBackgroundTopColor = QgsColorUtils::colorFromString( elemGradientBackground.attribute( u"top-color"_s ) );
266 mGradientBackgroundBottomColor = QgsColorUtils::colorFromString( elemGradientBackground.attribute( u"bottom-color"_s ) );
267 }
268
269 const QString bgType = elemSkybox.attribute( u"background-type"_s );
270 if ( bgType == "skybox"_L1 )
271 mBackgroundType = BackgroundType::Skybox;
272 else if ( bgType == "gradient"_L1 && !elemGradientBackground.isNull() )
273 mBackgroundType = BackgroundType::Gradient;
274 else
275 mBackgroundType = BackgroundType::NoBackground;
276
277 QDomElement elemShadows = elem.firstChildElement( u"shadow-rendering"_s );
278 mShadowSettings.readXml( elemShadows, context );
279
280 QDomElement elemAmbientOcclusion = elem.firstChildElement( u"screen-space-ambient-occlusion"_s );
281 mAmbientOcclusionSettings.readXml( elemAmbientOcclusion, context );
282
283 QDomElement elemEyeDomeLighting = elem.firstChildElement( u"eye-dome-lighting"_s );
284 mEyeDomeLightingEnabled = elemEyeDomeLighting.attribute( "enabled", u"0"_s ).toInt();
285 mEyeDomeLightingStrength = elemEyeDomeLighting.attribute( "eye-dome-lighting-strength", u"1000.0"_s ).toDouble();
286 mEyeDomeLightingDistance = elemEyeDomeLighting.attribute( "eye-dome-lighting-distance", u"1"_s ).toInt();
287
288 QDomElement elemNavigationSync = elem.firstChildElement( u"navigation-sync"_s );
289 mViewSyncMode = static_cast<Qgis::ViewSyncModeFlags>( elemNavigationSync.attribute( u"view-sync-mode"_s, u"0"_s ).toInt() );
290 mVisualizeViewFrustum = elemNavigationSync.attribute( u"view-frustum-visualization-enabled"_s, u"0"_s ).toInt();
291
292 QDomElement elemDebugSettings = elem.firstChildElement( u"debug-settings"_s );
293 mDebugShadowMapEnabled = elemDebugSettings.attribute( u"shadowmap-enabled"_s, u"0"_s ).toInt();
294 mDebugShadowMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( u"shadowmap-corner"_s, "0" ).toInt() );
295 mDebugShadowMapSize = elemDebugSettings.attribute( u"shadowmap-size"_s, u"0.2"_s ).toDouble();
296
297 mDebugDepthMapEnabled = elemDebugSettings.attribute( u"depthmap-enabled"_s, u"0"_s ).toInt();
298 mDebugDepthMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( u"depthmap-corner"_s, u"1"_s ).toInt() );
299 mDebugDepthMapSize = elemDebugSettings.attribute( u"depthmap-size"_s, u"0.2"_s ).toDouble();
300
301 QDomElement elemDebug = elem.firstChildElement( u"debug"_s );
302 mShowTerrainBoundingBoxes = elemDebug.attribute( u"bounding-boxes"_s, u"0"_s ).toInt();
303 mShowTerrainTileInfo = elemDebug.attribute( u"terrain-tile-info"_s, u"0"_s ).toInt();
304 mShowCameraViewCenter = elemDebug.attribute( u"camera-view-center"_s, u"0"_s ).toInt();
305 mShowCameraRotationCenter = elemDebug.attribute( u"camera-rotation-center"_s, u"0"_s ).toInt();
306 mShowLightSources = elemDebug.attribute( u"show-light-sources"_s, u"0"_s ).toInt();
307 mIsFpsCounterEnabled = elemDebug.attribute( u"show-fps-counter"_s, u"0"_s ).toInt();
308 mStopUpdates = elemDebug.attribute( u"stop-updates"_s, u"0"_s ).toInt();
309 mShowDebugPanel = elemDebug.attribute( u"debug-panel"_s, u"0"_s ).toInt();
310
311 QDomElement elemTemporalRange = elem.firstChildElement( u"temporal-range"_s );
312 QDateTime start = QDateTime::fromString( elemTemporalRange.attribute( u"start"_s ), Qt::ISODate );
313 QDateTime end = QDateTime::fromString( elemTemporalRange.attribute( u"end"_s ), Qt::ISODate );
314 setTemporalRange( QgsDateTimeRange( start, end ) );
315
316 QDomElement elem3dAxis = elem.firstChildElement( u"axis3d"_s );
317 m3dAxisSettings.readXml( elem3dAxis, context );
318
319 QDomElement elemMapOverlay = elem.firstChildElement( u"map-overlay"_s );
320 if ( !elemMapOverlay.isNull() )
321 {
322 mShow2DMapOverlay = elemMapOverlay.attribute( u"enabled"_s, u"0"_s ).toInt();
323 }
324 else
325 {
326 mShow2DMapOverlay = false;
327 }
328}
329
330QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const
331{
333
334 QDomElement elem = doc.createElement( u"qgis3d"_s );
335
336 QDomElement elemOrigin = doc.createElement( u"origin"_s );
337 elemOrigin.setAttribute( u"x"_s, QString::number( mOrigin.x() ) );
338 elemOrigin.setAttribute( u"y"_s, QString::number( mOrigin.y() ) );
339 elemOrigin.setAttribute( u"z"_s, QString::number( mOrigin.z() ) );
340 elem.appendChild( elemOrigin );
341
342 QDomElement elemExtent = doc.createElement( u"extent"_s );
343 elemExtent.setAttribute( u"xMin"_s, mExtent.xMinimum() );
344 elemExtent.setAttribute( u"yMin"_s, mExtent.yMinimum() );
345 elemExtent.setAttribute( u"xMax"_s, mExtent.xMaximum() );
346 elemExtent.setAttribute( u"yMax"_s, mExtent.yMaximum() );
347 elemExtent.setAttribute( u"showIn2dView"_s, mShowExtentIn2DView );
348 elem.appendChild( elemExtent );
349
350 QDomElement elemCamera = doc.createElement( u"camera"_s );
351 elemCamera.setAttribute( u"field-of-view"_s, mFieldOfView );
352 elemCamera.setAttribute( u"projection-type"_s, static_cast<int>( mProjectionType ) );
353 switch ( mCameraNavigationMode )
354 {
356 elemCamera.setAttribute( u"camera-navigation-mode"_s, u"terrain-based-navigation"_s );
357 break;
359 elemCamera.setAttribute( u"camera-navigation-mode"_s, u"walk-navigation"_s );
360 break;
362 elemCamera.setAttribute( u"camera-navigation-mode"_s, u"globe-terrain-based-navigation"_s );
363 break;
364 }
365 elemCamera.setAttribute( u"camera-movement-speed"_s, mCameraMovementSpeed );
366 elem.appendChild( elemCamera );
367
368 QDomElement elemColor = doc.createElement( u"color"_s );
369 elemColor.setAttribute( u"background"_s, QgsColorUtils::colorToString( mBackgroundColor ) );
370 elemColor.setAttribute( u"selection"_s, QgsColorUtils::colorToString( mSelectionColor ) );
371 elem.appendChild( elemColor );
372
373 QDomElement elemCrs = doc.createElement( u"crs"_s );
374 mCrs.writeXml( elemCrs, doc );
375 elem.appendChild( elemCrs );
376
377 QDomElement elemTerrain = doc.createElement( u"terrain"_s );
378 elemTerrain.setAttribute( u"terrain-rendering-enabled"_s, mTerrainRenderingEnabled ? 1 : 0 );
379 elemTerrain.setAttribute( u"shading-enabled"_s, mTerrainShadingEnabled ? 1 : 0 );
380
381 QDomElement elemTerrainShadingMaterial = doc.createElement( u"shading-material"_s );
382 mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial, context );
383 elemTerrain.appendChild( elemTerrainShadingMaterial );
384 elemTerrain.setAttribute( u"map-theme"_s, mTerrainMapTheme );
385 elemTerrain.setAttribute( u"show-labels"_s, mShowLabels ? 1 : 0 );
386
387 {
388 QDomElement elemLights = doc.createElement( u"lights"_s );
389 for ( const QgsLightSource *light : mLightSources )
390 {
391 const QDomElement elemLight = light->writeXml( doc, context );
392 elemLights.appendChild( elemLight );
393 }
394 elem.appendChild( elemLights );
395 }
396
397 QDomElement elemMapLayers = doc.createElement( u"layers"_s );
398 for ( const QgsMapLayerRef &layerRef : mLayers )
399 {
400 QDomElement elemMapLayer = doc.createElement( u"layer"_s );
401 elemMapLayer.setAttribute( u"id"_s, layerRef.layerId );
402 elemMapLayers.appendChild( elemMapLayer );
403 }
404 elemTerrain.appendChild( elemMapLayers );
405
406 QDomElement elemTerrainGenerator = doc.createElement( u"generator"_s );
407 elemTerrainGenerator.setAttribute( u"type"_s, mTerrainSettings->type() );
408 mTerrainSettings->writeXml( elemTerrain, context );
409 elemTerrain.appendChild( elemTerrainGenerator );
410 elem.appendChild( elemTerrain );
411
412 QDomElement elemSkybox = doc.createElement( u"skybox"_s );
413 QString bgTypeStr;
414 switch ( mBackgroundType )
415 {
417 bgTypeStr = u"skybox"_s;
418 break;
420 bgTypeStr = u"gradient"_s;
421 break;
423 bgTypeStr = u"none"_s;
424 break;
425 }
426 elemSkybox.setAttribute( u"background-type"_s, bgTypeStr );
427 mSkyboxSettings.writeXml( elemSkybox, context );
428 elem.appendChild( elemSkybox );
429
430 QDomElement elemGradientBackground = doc.createElement( u"gradient-background"_s );
431 elemGradientBackground.setAttribute( u"top-color"_s, QgsColorUtils::colorToString( mGradientBackgroundTopColor ) );
432 elemGradientBackground.setAttribute( u"bottom-color"_s, QgsColorUtils::colorToString( mGradientBackgroundBottomColor ) );
433 elem.appendChild( elemGradientBackground );
434
435 QDomElement elemShadows = doc.createElement( u"shadow-rendering"_s );
436 mShadowSettings.writeXml( elemShadows, context );
437 elem.appendChild( elemShadows );
438
439 QDomElement elemAmbientOcclusion = doc.createElement( u"screen-space-ambient-occlusion"_s );
440 mAmbientOcclusionSettings.writeXml( elemAmbientOcclusion, context );
441 elem.appendChild( elemAmbientOcclusion );
442
443 QDomElement elemDebug = doc.createElement( u"debug"_s );
444 elemDebug.setAttribute( u"bounding-boxes"_s, mShowTerrainBoundingBoxes ? 1 : 0 );
445 elemDebug.setAttribute( u"terrain-tile-info"_s, mShowTerrainTileInfo ? 1 : 0 );
446 elemDebug.setAttribute( u"camera-view-center"_s, mShowCameraViewCenter ? 1 : 0 );
447 elemDebug.setAttribute( u"camera-rotation-center"_s, mShowCameraRotationCenter ? 1 : 0 );
448 elemDebug.setAttribute( u"show-light-sources"_s, mShowLightSources ? 1 : 0 );
449 elemDebug.setAttribute( u"show-fps-counter"_s, mIsFpsCounterEnabled ? 1 : 0 );
450 elemDebug.setAttribute( u"stop-updates"_s, mStopUpdates ? 1 : 0 );
451 elemDebug.setAttribute( u"debug-panel"_s, mShowDebugPanel ? 1 : 0 );
452 elem.appendChild( elemDebug );
453
454 QDomElement elemEyeDomeLighting = doc.createElement( u"eye-dome-lighting"_s );
455 elemEyeDomeLighting.setAttribute( u"enabled"_s, mEyeDomeLightingEnabled ? 1 : 0 );
456 elemEyeDomeLighting.setAttribute( u"eye-dome-lighting-strength"_s, mEyeDomeLightingStrength );
457 elemEyeDomeLighting.setAttribute( u"eye-dome-lighting-distance"_s, mEyeDomeLightingDistance );
458 elem.appendChild( elemEyeDomeLighting );
459
460 QDomElement elemNavigationSync = doc.createElement( u"navigation-sync"_s );
461 elemNavigationSync.setAttribute( u"view-sync-mode"_s, ( int ) mViewSyncMode );
462 elemNavigationSync.setAttribute( u"view-frustum-visualization-enabled"_s, mVisualizeViewFrustum ? 1 : 0 );
463 elem.appendChild( elemNavigationSync );
464
465 QDomElement elemDebugSettings = doc.createElement( u"debug-settings"_s );
466 elemDebugSettings.setAttribute( u"shadowmap-enabled"_s, mDebugShadowMapEnabled );
467 elemDebugSettings.setAttribute( u"shadowmap-corner"_s, mDebugShadowMapCorner );
468 elemDebugSettings.setAttribute( u"shadowmap-size"_s, mDebugShadowMapSize );
469 elemDebugSettings.setAttribute( u"depthmap-enabled"_s, mDebugDepthMapEnabled );
470 elemDebugSettings.setAttribute( u"depthmap-corner"_s, mDebugDepthMapCorner );
471 elemDebugSettings.setAttribute( u"depthmap-size"_s, mDebugDepthMapSize );
472 elem.appendChild( elemDebugSettings );
473
474 QDomElement elemTemporalRange = doc.createElement( u"temporal-range"_s );
475 elemTemporalRange.setAttribute( u"start"_s, temporalRange().begin().toString( Qt::ISODate ) );
476 elemTemporalRange.setAttribute( u"end"_s, temporalRange().end().toString( Qt::ISODate ) );
477
478 QDomElement elem3dAxis = doc.createElement( u"axis3d"_s );
479 m3dAxisSettings.writeXml( elem3dAxis, context );
480 elem.appendChild( elem3dAxis );
481
482 if ( mShow2DMapOverlay )
483 {
484 QDomElement elemMapOverlay = doc.createElement( u"map-overlay"_s );
485 elemMapOverlay.setAttribute( u"enabled"_s, 1 );
486 elem.appendChild( elemMapOverlay );
487 }
488
489 return elem;
490}
491
493{
495
496 for ( int i = 0; i < mLayers.count(); ++i )
497 {
498 QgsMapLayerRef &layerRef = mLayers[i];
499 layerRef.setLayer( project.mapLayer( layerRef.layerId ) );
500 }
501
502 if ( mTerrainSettings )
503 {
504 mTerrainSettings->resolveReferences( &project );
505
506 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
507 if ( terrainGenerator )
508 {
510 }
512 }
513}
514
516{
518
520 {
521 QgsDebugError( u"extent() should not be used with globe!"_s );
522 }
523
524 return mExtent;
525}
526
528{
530
531 if ( extent == mExtent )
532 return;
533
535 {
536 QgsDebugError( u"setExtent() should not be used with globe!"_s );
537 }
538
539 mExtent = extent;
540 const QgsPointXY center = mExtent.center();
541 setOrigin( QgsVector3D( center.x(), center.y(), 0 ) );
542 if ( mTerrainGenerator )
543 {
544 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, mTerrainGenerator->crs(), mTransformContext );
545 mTerrainGenerator->setExtent( terrainExtent );
546 }
547 emit extentChanged();
548}
549
551{
553
554 if ( origin == mOrigin )
555 return;
556
557 mOrigin = origin;
558 emit originChanged();
559}
560
562{
564
565 return mOrigin;
566}
567
574
581
583{
585
586 mCrs = crs;
587
588 // for convenience, make sure the navigation mode is consistent with the scene mode
589 if ( sceneMode() == Qgis::SceneMode::Globe && mCameraNavigationMode == Qgis::NavigationMode::TerrainBased )
590 {
592 }
593 else if ( sceneMode() == Qgis::SceneMode::Local && mCameraNavigationMode == Qgis::NavigationMode::GlobeTerrainBased )
594 {
596 }
597}
598
605
612
619
621{
623
624 mTransformContext = context;
625}
626
628{
630
631 return mPathResolver;
632}
633
635{
637
638 mPathResolver = resolver;
639}
640
647
649{
651
652 mMapThemes = mapThemes;
653}
654
655void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
656{
658
659 if ( color == mBackgroundColor )
660 return;
661
662 mBackgroundColor = color;
664}
665
667{
669
670 return mBackgroundColor;
671}
672
679
681{
683
684 if ( type == mBackgroundType )
685 return;
686
687 mBackgroundType = type;
689}
690
692{
694
695 return mGradientBackgroundTopColor;
696}
697
699{
701
702 if ( color == mGradientBackgroundTopColor )
703 return;
704
705 mGradientBackgroundTopColor = color;
707}
708
710{
712
713 return mGradientBackgroundBottomColor;
714}
715
717{
719
720 if ( color == mGradientBackgroundBottomColor )
721 return;
722
723 mGradientBackgroundBottomColor = color;
725}
726
727void Qgs3DMapSettings::setSelectionColor( const QColor &color )
728{
730
731 if ( color == mSelectionColor )
732 return;
733
734 mSelectionColor = color;
736}
737
739{
741
742 return mSelectionColor;
743}
744
746{
748
749 if ( zScale == mTerrainSettings->verticalScale() )
750 return;
751
752 mTerrainSettings->setVerticalScale( zScale );
757}
758
760{
762
763 return mTerrainSettings->verticalScale();
764}
765
766void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
767{
769
770 const QList<QgsMapLayer *> raw = _qgis_listRefToRaw( mLayers );
771
772 if ( layers == raw )
773 return;
774
775 mLayers = _qgis_listRawToRef( layers );
776 emit layersChanged();
777}
778
779QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
780{
782
783 QList<QgsMapLayer *> lst;
784 lst.reserve( mLayers.count() );
785 for ( const QgsMapLayerRef &layerRef : mLayers )
786 {
787 if ( layerRef.layer )
788 lst.append( layerRef.layer );
789 }
790 return lst;
791}
792
794{
796
797 setExtent( fullExtent );
798
799 std::unique_ptr<QgsAbstractTerrainSettings> terrainSettings( Qgs3D::terrainRegistry()->configureTerrainFromProject( properties ) );
800 if ( terrainSettings )
801 {
803 }
804}
805
807{
809
810 return mTerrainSettings.get();
811}
812
814{
816
817 bool hasChanged = false;
818 if ( settings == mTerrainSettings.get() )
819 {
820 // emit signals anyway. We don't know if the caller changed settings on the pointer before calling this..
821 hasChanged = true;
822 }
823 else
824 {
825 // ensure to generate the terrain if the settings have changed or if the terrain has never been generated.
826 hasChanged = !settings->equals( mTerrainSettings.get() ) || !mTerrainGenerator;
827 mTerrainSettings.reset( settings );
828 }
829
830 if ( hasChanged )
831 {
832 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
833 if ( terrainGenerator )
834 {
836 }
837
838 // emit all the signals, we don't know exactly what's changed
843 emit terrainElevationOffsetChanged( mTerrainSettings->elevationOffset() );
846
848 }
849}
850
852{
854
855 if ( mTerrainSettings->mapTileResolution() == res )
856 return;
857
858 mTerrainSettings->setMapTileResolution( res );
863}
864
866{
868
869 return mTerrainSettings->mapTileResolution();
870}
871
873{
875
876 if ( mTerrainSettings->maximumScreenError() == error )
877 return;
878
879 mTerrainSettings->setMaximumScreenError( error );
884}
885
887{
889
890 return mTerrainSettings->maximumScreenError();
891}
892
894{
896
897 if ( mTerrainSettings->maximumGroundError() == error )
898 return;
899
900 mTerrainSettings->setMaximumGroundError( error );
904
906}
907
909{
911
912 if ( mTerrainSettings->elevationOffset() == offset )
913 return;
914 mTerrainSettings->setElevationOffset( offset );
916 emit terrainElevationOffsetChanged( offset );
919}
920
922{
924
925 return mTerrainSettings->elevationOffset();
926}
927
929{
931
932 return mTerrainSettings->maximumGroundError();
933}
934
936{
938
939 if ( mTerrainGenerator )
940 {
941 disconnect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
942 }
943
944 if ( gen->crs().isValid() ) // Don't bother setting an extent rect in the wrong CRS
945 {
946 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, gen->crs(), mTransformContext );
947 gen->setExtent( terrainExtent );
948 }
949 mTerrainGenerator.reset( gen );
950 connect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
951
953}
954
956{
958
959 return mTerrainGenerator.get();
960}
961
963{
965
966 if ( mTerrainShadingEnabled == enabled )
967 return;
968
969 mTerrainShadingEnabled = enabled;
971}
972
974{
976
977 return mTerrainShadingEnabled;
978}
979
981{
983
984 if ( mTerrainShadingMaterial == material )
985 return;
986
987 mTerrainShadingMaterial = material;
989}
990
997
998void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
999{
1001
1002 if ( mTerrainMapTheme == theme )
1003 return;
1004
1005 mTerrainMapTheme = theme;
1007}
1008
1010{
1012
1013 return mTerrainMapTheme;
1014}
1015
1017{
1019
1020 if ( mShowTerrainBoundingBoxes == enabled )
1021 return;
1022
1023 mShowTerrainBoundingBoxes = enabled;
1025}
1026
1028{
1030
1031 return mShowTerrainBoundingBoxes;
1032}
1033
1034
1036{
1038
1039 if ( mShowTerrainTileInfo == enabled )
1040 return;
1041
1042 mShowTerrainTileInfo = enabled;
1044}
1045
1047{
1049
1050 return mShowTerrainTileInfo;
1051}
1052
1054{
1056
1057 if ( mShowCameraViewCenter == enabled )
1058 return;
1059
1060 mShowCameraViewCenter = enabled;
1062}
1063
1065{
1067
1068 return mShowCameraViewCenter;
1069}
1070
1072{
1074
1075 if ( mShowCameraRotationCenter == enabled )
1076 return;
1077
1078 mShowCameraRotationCenter = enabled;
1080}
1081
1083{
1085
1086 return mShowCameraRotationCenter;
1087}
1088
1090{
1092
1093 if ( mShowLightSources == enabled )
1094 return;
1095
1096 mShowLightSources = enabled;
1098}
1099
1101{
1103
1104 return mShowLightSources;
1105}
1106
1108{
1110
1111 if ( mShowLabels == enabled )
1112 return;
1113
1114 mShowLabels = enabled;
1115 emit showLabelsChanged();
1116}
1117
1119{
1121
1122 return mShowLabels;
1123}
1124
1126{
1128
1129 if ( mStopUpdates == enabled )
1130 return;
1131
1132 mStopUpdates = enabled;
1133 emit stopUpdatesChanged();
1134}
1135
1137{
1139
1140 return mStopUpdates;
1141}
1142
1144{
1146
1147 if ( mEyeDomeLightingEnabled == enabled )
1148 return;
1149 mEyeDomeLightingEnabled = enabled;
1151}
1152
1154{
1156
1157 return mEyeDomeLightingEnabled;
1158}
1159
1161{
1163
1164 if ( mEyeDomeLightingStrength == strength )
1165 return;
1166 mEyeDomeLightingStrength = strength;
1168}
1169
1171{
1173
1174 return mEyeDomeLightingStrength;
1175}
1176
1178{
1180
1181 if ( mEyeDomeLightingDistance == distance )
1182 return;
1183 mEyeDomeLightingDistance = distance;
1185}
1186
1188{
1190
1191 return mEyeDomeLightingDistance;
1192}
1193
1195{
1197
1198 if ( mMsaaEnabled == enabled )
1199 return;
1200
1201 mMsaaEnabled = enabled;
1202 emit msaaEnabledChanged();
1203}
1204
1206{
1208
1209 return mMsaaEnabled;
1210}
1211
1212QList<QgsLightSource *> Qgs3DMapSettings::lightSources() const
1213{
1215
1216 return mLightSources;
1217}
1218
1219void Qgs3DMapSettings::setLightSources( const QList<QgsLightSource *> &lights )
1220{
1222
1223 // have lights actually changed?
1224 if ( mLightSources.count() == lights.count() )
1225 {
1226 bool same = true;
1227 for ( int i = 0; i < mLightSources.count(); ++i )
1228 {
1229 if ( mLightSources[i]->type() == lights[i]->type() )
1230 {
1231 switch ( mLightSources[i]->type() )
1232 {
1234 if ( *static_cast<QgsPointLightSettings *>( mLightSources[i] ) == *static_cast<QgsPointLightSettings *>( lights[i] ) )
1235 continue;
1236 break;
1238 if ( *static_cast<QgsDirectionalLightSettings *>( mLightSources[i] ) == *static_cast<QgsDirectionalLightSettings *>( lights[i] ) )
1239 continue;
1240 break;
1241 }
1242 }
1243 same = false;
1244 break;
1245 }
1246 if ( same )
1247 {
1248 qDeleteAll( lights );
1249 return;
1250 }
1251 }
1252
1253 qDeleteAll( mLightSources );
1254 mLightSources = lights;
1255
1257 emit pointLightsChanged();
1258 emit lightSourcesChanged();
1259}
1260
1262{
1264
1265 return mFieldOfView;
1266}
1267
1269{
1271
1272 if ( mFieldOfView == fieldOfView )
1273 return;
1274
1275 mFieldOfView = fieldOfView;
1276 emit fieldOfViewChanged();
1277}
1278
1279Qt3DRender::QCameraLens::ProjectionType Qgs3DMapSettings::projectionType() const
1280{
1282
1283 return mProjectionType;
1284}
1285
1286void Qgs3DMapSettings::setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType )
1287{
1289
1290 if ( mProjectionType == projectionType )
1291 return;
1292
1293 mProjectionType = projectionType;
1294 emit projectionTypeChanged();
1295}
1296
1298{
1300
1301 return mCameraNavigationMode;
1302}
1303
1305{
1307
1308 if ( mCameraNavigationMode == navigationMode )
1309 return;
1310
1311 mCameraNavigationMode = navigationMode;
1313}
1314
1316{
1318
1319 return mCameraMovementSpeed;
1320}
1321
1323{
1325
1326 if ( mCameraMovementSpeed == movementSpeed )
1327 return;
1328
1329 mCameraMovementSpeed = movementSpeed;
1331}
1332
1333void Qgs3DMapSettings::setOutputDpi( const double dpi )
1334{
1336
1337 mDpi = dpi;
1338}
1339
1341{
1343
1344 return mDpi;
1345}
1346
1348{
1350
1351 return mSkyboxSettings;
1352}
1353
1355{
1357
1358 return mShadowSettings;
1359}
1360
1362{
1364
1365 return mAmbientOcclusionSettings;
1366}
1367
1375
1383
1391
1393{
1395
1396 return mBackgroundType == BackgroundType::Skybox;
1397}
1398
1405
1407{
1409
1410 return mIsFpsCounterEnabled;
1411}
1412
1413void Qgs3DMapSettings::setShowDebugPanel( const bool enabled )
1414{
1416
1417 if ( mShowDebugPanel == enabled )
1418 return;
1419
1420 mShowDebugPanel = enabled;
1421 emit showDebugPanelChanged( enabled );
1422}
1423
1425{
1427
1428 return mShowDebugPanel;
1429}
1430
1431void Qgs3DMapSettings::setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size )
1432{
1434
1435 mDebugShadowMapEnabled = enabled;
1436 mDebugShadowMapCorner = corner;
1437 mDebugShadowMapSize = size;
1439}
1440
1442{
1444
1445 return mDebugShadowMapEnabled;
1446}
1447
1449{
1451
1452 return mDebugShadowMapCorner;
1453}
1454
1456{
1458
1459 return mDebugShadowMapSize;
1460}
1461
1462void Qgs3DMapSettings::setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size )
1463{
1465
1466 mDebugDepthMapEnabled = enabled;
1467 mDebugDepthMapCorner = corner;
1468 mDebugDepthMapSize = size;
1470}
1471
1473{
1475
1476 return mDebugDepthMapEnabled;
1477}
1478
1480{
1482
1483 return mDebugDepthMapCorner;
1484}
1485
1487{
1489
1490 return mDebugDepthMapSize;
1491}
1492
1493void Qgs3DMapSettings::setIsFpsCounterEnabled( bool fpsCounterEnabled )
1494{
1496
1497 if ( fpsCounterEnabled == mIsFpsCounterEnabled )
1498 return;
1499 mIsFpsCounterEnabled = fpsCounterEnabled;
1500 emit fpsCounterEnabledChanged( mIsFpsCounterEnabled );
1501}
1502
1504{
1506
1507 return mTerrainRenderingEnabled;
1508}
1509
1511{
1513
1514 if ( terrainRenderingEnabled == mTerrainRenderingEnabled )
1515 return;
1516 mTerrainRenderingEnabled = terrainRenderingEnabled;
1518}
1519
1521{
1523
1524 return mRendererUsage;
1525}
1526
1533
1540
1542{
1544
1545 mViewSyncMode = mode;
1546}
1547
1549{
1551
1552 return mVisualizeViewFrustum;
1553}
1554
1556{
1558
1559 if ( mVisualizeViewFrustum != enabled )
1560 {
1561 mVisualizeViewFrustum = enabled;
1563 }
1564}
1565
1567{
1569
1570 return m3dAxisSettings;
1571}
1572
1573void Qgs3DMapSettings::setIsDebugOverlayEnabled( bool debugOverlayEnabled )
1574{
1576
1577 if ( debugOverlayEnabled == mIsDebugOverlayEnabled )
1578 return;
1579
1580 mIsDebugOverlayEnabled = debugOverlayEnabled;
1581 emit debugOverlayEnabledChanged( mIsDebugOverlayEnabled );
1582}
1583
1585{
1587
1588 return mShowExtentIn2DView;
1589}
1590
1591void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
1592{
1594
1627}
1628
1629
1630void Qgs3DMapSettings::set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force )
1631{
1633
1634 if ( axisSettings == m3dAxisSettings )
1635 {
1636 if ( force )
1637 {
1638 // ie. refresh. We need to disconnect and to reconnect to avoid 'dirty' project
1640 emit axisSettingsChanged();
1642 }
1643 }
1644 else
1645 {
1646 m3dAxisSettings = axisSettings;
1647 emit axisSettingsChanged();
1648 }
1649}
1650
1652{
1654
1655 return mIsDebugOverlayEnabled;
1656}
1657
1659{
1661
1662 if ( show == mShowExtentIn2DView )
1663 return;
1664
1665 mShowExtentIn2DView = show;
1667}
1668
1670{
1672
1673 return mShow2DMapOverlay;
1674}
1675
1677{
1679
1680 if ( mShow2DMapOverlay == enabled )
1681 return;
1682
1683 mShow2DMapOverlay = enabled;
1685}
@ Geocentric
Geocentric CRS.
Definition qgis.h:2465
QFlags< ViewSyncModeFlag > ViewSyncModeFlags
Definition qgis.h:3663
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:4400
@ TerrainBased
The default navigation based on the terrain.
Definition qgis.h:4401
@ Walk
Uses WASD keys or arrows to navigate in walking (first person) manner.
Definition qgis.h:4402
@ GlobeTerrainBased
Navigation similar to TerrainBased, but for use with globe.
Definition qgis.h:4403
RendererUsage
Usage of the renderer.
Definition qgis.h:3626
SceneMode
The 3D scene mode used in 3D map views.
Definition qgis.h:4413
@ Globe
Scene is represented as a globe using a geocentric CRS.
Definition qgis.h:4415
@ Local
Local scene based on a projected CRS.
Definition qgis.h:4414
@ Point
Point light source.
Definition qgis.h:4361
@ Directional
Directional light source.
Definition qgis.h:4362
Contains the configuration of a 3d axis.
void extentChanged()
Emitted when the 3d view's 2d extent has changed.
void setEyeDomeLightingStrength(double strength)
Sets the eye dome lighting strength value.
QColor gradientBackgroundBottomColor() const
Returns the bottom color of the gradient background of the 3D map view.
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.
bool isMsaaEnabled() const
Returns whether multisample anti-aliasing (MSAA) is enabled.
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.
Q_DECL_DEPRECATED 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.
QColor gradientBackgroundTopColor() const
Returns the top color of the gradient background of the 3D map view.
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.
void backgroundTypeChanged()
Emitted when the background type or gradient colors change.
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.
void show2DMapOverlayChanged()
Emitted when the 2D map overlay is enabled or disabled.
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.
Q_DECL_DEPRECATED 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.
BackgroundType backgroundType() const
Returns the background type for the 3D map view.
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 setGradientBackgroundTopColor(const QColor &color)
Sets the top color of the gradient background of the 3D map view.
void msaaEnabledChanged()
Emitted when the MSAA enabled flag has changed.
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.
bool is2DMapOverlayEnabled() const
Returns whether 2D map overlay is enabled.
void setIs2DMapOverlayEnabled(bool enabled)
Sets whether 2D map overlay is enabled.
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.
BackgroundType
Background rendering type for the 3D map 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.
void setMsaaEnabled(bool enabled)
Sets whether multisample anti-aliasing (MSAA) is enabled.
int eyeDomeLightingDistance() const
Returns the eye dome lighting distance value (contributes to the contrast of the image).
void setBackgroundType(BackgroundType type)
Sets the background type for the 3D map view.
void setSelectionColor(const QColor &color)
Sets color used for selected features.
void setGradientBackgroundBottomColor(const QColor &color)
Sets the bottom color of the gradient background of the 3D map view.
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:119
Base class for all terrain settings classes.
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.
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.
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...
Definition of a point light in a 3D map scene.
Represents a 2D point.
Definition qgspointxy.h:62
double y
Definition qgspointxy.h:66
double x
Definition qgspointxy.h:65
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:114
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.
Contains configuration for rendering shadows.
Contains the configuration of a skybox entity.
const QgsDateTimeRange & temporalRange() const
Returns the datetime range for the object.
QgsTemporalRangeObject(bool enabled=false)
Constructor QgsTemporalRangeObject.
void setTemporalRange(const QgsDateTimeRange &range)
Sets the temporal range for the object.
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:33
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:7666
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:7665
#define QgsDebugError(str)
Definition qgslogger.h:59
_LayerRef< QgsMapLayer > QgsMapLayerRef
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:705
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
QString layerId
Original layer ID.