QGIS API Documentation 4.1.0-Master (9af12b5a203)
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"
24#include "qgscolorutils.h"
28#include "qgslightsource.h"
33#include "qgsrasterlayer.h"
34#include "qgsterrainprovider.h"
35#include "qgsthreadingutils.h"
36
37#include <QDomDocument>
38#include <QDomElement>
39#include <QString>
40
41#include "moc_qgs3dmapsettings.cpp"
42
43using namespace Qt::StringLiterals;
44
46 : QObject( nullptr )
47{
48 connect( this, &Qgs3DMapSettings::settingsChanged, [&]() { QgsProject::instance()->setDirty(); } );
49 connectChangedSignalsToSettingsChanged();
50 mTerrainSettings = std::make_unique<QgsFlatTerrainSettings>();
51}
52
54 : QObject( nullptr )
55 , QgsTemporalRangeObject( other )
56 , mOrigin( other.mOrigin )
57 , mCrs( other.mCrs )
58 , mBackgroundColor( other.mBackgroundColor )
59 , mSelectionColor( other.mSelectionColor )
60 , mTerrainShadingEnabled( other.mTerrainShadingEnabled )
61 , mTerrainShadingMaterial( other.mTerrainShadingMaterial )
62 , mTerrainMapTheme( other.mTerrainMapTheme )
63 , mShowTerrainBoundingBoxes( other.mShowTerrainBoundingBoxes )
64 , mShowTerrainTileInfo( other.mShowTerrainTileInfo )
65 , mShowCameraViewCenter( other.mShowCameraViewCenter )
66 , mShowCameraRotationCenter( other.mShowCameraRotationCenter )
67 , mShowLightSources( other.mShowLightSources )
68 , mShowLabels( other.mShowLabels )
69 , mStopUpdates( other.mStopUpdates )
70 , mShowDebugPanel( other.mShowDebugPanel )
71 , mFieldOfView( other.mFieldOfView )
72 , mProjectionType( other.mProjectionType )
73 , mCameraNavigationMode( other.mCameraNavigationMode )
74 , mCameraMovementSpeed( other.mCameraMovementSpeed )
75 , mLayers( other.mLayers )
76 , mTransformContext( other.mTransformContext )
77 , mPathResolver( other.mPathResolver )
78 , mMapThemes( other.mMapThemes )
79 , mDpi( other.mDpi )
80 , mIsFpsCounterEnabled( other.mIsFpsCounterEnabled )
81 , mShadowSettings( other.mShadowSettings )
82 , mAmbientOcclusionSettings( other.mAmbientOcclusionSettings )
83 , mBloomSettings( other.mBloomSettings )
84 , mEyeDomeLightingEnabled( other.mEyeDomeLightingEnabled )
85 , mEyeDomeLightingStrength( other.mEyeDomeLightingStrength )
86 , mEyeDomeLightingDistance( other.mEyeDomeLightingDistance )
87 , mMsaaEnabled( other.mMsaaEnabled )
88 , mTextureFilterQuality( other.mTextureFilterQuality )
89 , mViewSyncMode( other.mViewSyncMode )
90 , mVisualizeViewFrustum( other.mVisualizeViewFrustum )
91 , mTerrainRenderingEnabled( other.mTerrainRenderingEnabled )
92 , mRendererUsage( other.mRendererUsage )
93 , m3dAxisSettings( other.m3dAxisSettings )
94 , mIsDebugOverlayEnabled( other.mIsDebugOverlayEnabled )
95 , mExtent( other.mExtent )
96 , mShowExtentIn2DView( other.mShowExtentIn2DView )
97 , mShow2DMapOverlay( other.mShow2DMapOverlay )
98{
99 setTerrainSettings( other.mTerrainSettings ? other.mTerrainSettings->clone() : new QgsFlatTerrainSettings() );
100
101 if ( other.mBackgroundSettings )
102 mBackgroundSettings.reset( other.mBackgroundSettings->clone() );
103
104 for ( QgsLightSource *source : std::as_const( other.mLightSources ) )
105 {
106 if ( source )
107 mLightSources << source->clone();
108 }
109
110 connect( this, &Qgs3DMapSettings::settingsChanged, [&]() { QgsProject::instance()->setDirty(); } );
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( u"origin"_s );
125 // clang-format off
126 mOrigin = QgsVector3D(
127 elemOrigin.attribute( u"x"_s ).toDouble(),
128 elemOrigin.attribute( u"y"_s ).toDouble(),
129 elemOrigin.attribute( u"z"_s ).toDouble()
130 );
131 // clang-format on
132
133 QDomElement elemExtent = elem.firstChildElement( u"extent"_s );
134 if ( !elemExtent.isNull() )
135 {
136 // clang-format off
137 mExtent = QgsRectangle(
138 elemExtent.attribute( u"xMin"_s ).toDouble(),
139 elemExtent.attribute( u"yMin"_s ).toDouble(),
140 elemExtent.attribute( u"xMax"_s ).toDouble(),
141 elemExtent.attribute( u"yMax"_s ).toDouble()
142 );
143 // clang-format on
144
145 mShowExtentIn2DView = elemExtent.attribute( u"showIn2dView"_s, u"0"_s ).toInt();
146 }
147 else
148 {
150 }
151
152 QDomElement elemCamera = elem.firstChildElement( u"camera"_s );
153 if ( !elemCamera.isNull() )
154 {
155 mFieldOfView = elemCamera.attribute( u"field-of-view"_s, u"45"_s ).toFloat();
156 mProjectionType = static_cast<Qt3DRender::QCameraLens::ProjectionType>( elemCamera.attribute( u"projection-type"_s, u"1"_s ).toInt() );
157 QString cameraNavigationMode = elemCamera.attribute( u"camera-navigation-mode"_s, u"basic-navigation"_s );
158 if ( cameraNavigationMode == "terrain-based-navigation"_L1 )
159 mCameraNavigationMode = Qgis::NavigationMode::TerrainBased;
160 else if ( cameraNavigationMode == "walk-navigation"_L1 )
161 mCameraNavigationMode = Qgis::NavigationMode::Walk;
162 else if ( cameraNavigationMode == "globe-terrain-based-navigation"_L1 )
163 mCameraNavigationMode = Qgis::NavigationMode::GlobeTerrainBased;
164 mCameraMovementSpeed = elemCamera.attribute( u"camera-movement-speed"_s, u"5.0"_s ).toDouble();
165 }
166
167 QDomElement elemColor = elem.firstChildElement( u"color"_s );
168 if ( !elemColor.isNull() )
169 {
170 mBackgroundColor = QgsColorUtils::colorFromString( elemColor.attribute( u"background"_s ) );
171 mSelectionColor = QgsColorUtils::colorFromString( elemColor.attribute( u"selection"_s ) );
172 }
173
174 QDomElement elemCrs = elem.firstChildElement( u"crs"_s );
175 mCrs.readXml( elemCrs );
176
177 QDomElement elemTerrain = elem.firstChildElement( u"terrain"_s );
178 mTerrainRenderingEnabled = elemTerrain.attribute( u"terrain-rendering-enabled"_s, u"1"_s ).toInt();
179 mTerrainShadingEnabled = elemTerrain.attribute( u"shading-enabled"_s, u"0"_s ).toInt();
180
181 QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( u"shading-material"_s );
182 if ( !elemTerrainShadingMaterial.isNull() )
183 mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial, context );
184 mTerrainMapTheme = elemTerrain.attribute( u"map-theme"_s );
185 mShowLabels = elemTerrain.attribute( u"show-labels"_s, u"0"_s ).toInt();
186
187 qDeleteAll( mLightSources );
188 mLightSources.clear();
189 const QDomElement lightsElem = elem.firstChildElement( u"lights"_s );
190 if ( !lightsElem.isNull() )
191 {
192 const QDomNodeList lightNodes = lightsElem.childNodes();
193 for ( int i = 0; i < lightNodes.size(); ++i )
194 {
195 const QDomElement lightElement = lightNodes.at( i ).toElement();
196 if ( QgsLightSource *light = QgsLightSource::createFromXml( lightElement, context ) )
197 mLightSources << light;
198 }
199 }
200 else
201 {
202 // older project format
203 QDomElement elemPointLights = elem.firstChildElement( u"point-lights"_s );
204 if ( !elemPointLights.isNull() )
205 {
206 QDomElement elemPointLight = elemPointLights.firstChildElement( u"point-light"_s );
207 while ( !elemPointLight.isNull() )
208 {
209 auto pointLight = std::make_unique<QgsPointLightSettings>();
210 pointLight->readXml( elemPointLight, context );
211 mLightSources << pointLight.release();
212 elemPointLight = elemPointLight.nextSiblingElement( u"point-light"_s );
213 }
214 }
215 else
216 {
217 // QGIS <= 3.4 did not have light configuration
218 auto defaultLight = std::make_unique<QgsPointLightSettings>();
219 defaultLight->setPosition( QgsVector3D( 0, 1000, 0 ) );
220 mLightSources << defaultLight.release();
221 }
222
223 QDomElement elemDirectionalLights = elem.firstChildElement( u"directional-lights"_s );
224 if ( !elemDirectionalLights.isNull() )
225 {
226 QDomElement elemDirectionalLight = elemDirectionalLights.firstChildElement( u"directional-light"_s );
227 while ( !elemDirectionalLight.isNull() )
228 {
229 auto directionalLight = std::make_unique<QgsDirectionalLightSettings>();
230 directionalLight->readXml( elemDirectionalLight, context );
231 mLightSources << directionalLight.release();
232 elemDirectionalLight = elemDirectionalLight.nextSiblingElement( u"directional-light"_s );
233 }
234 }
235 }
236
237 QDomElement elemMapLayers = elemTerrain.firstChildElement( u"layers"_s );
238 QDomElement elemMapLayer = elemMapLayers.firstChildElement( u"layer"_s );
239 QList<QgsMapLayerRef> mapLayers;
240 while ( !elemMapLayer.isNull() )
241 {
242 mapLayers << QgsMapLayerRef( elemMapLayer.attribute( u"id"_s ) );
243 elemMapLayer = elemMapLayer.nextSiblingElement( u"layer"_s );
244 }
245 mLayers = mapLayers; // needs to resolve refs afterwards
246
247 QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( u"generator"_s );
248 const QString terrainGenType = elemTerrainGenerator.attribute( u"type"_s );
249 std::unique_ptr<QgsAbstractTerrainSettings> terrainSettings( Qgs3D::terrainRegistry()->createTerrainSettings( terrainGenType ) );
250 if ( terrainSettings )
251 {
252 terrainSettings->readXml( elemTerrain, context );
254 }
255
256 mBackgroundSettings.reset();
257 QDomElement elemBackground = elem.firstChildElement( u"background"_s );
258 if ( !elemBackground.isNull() )
259 {
260 switch ( qgsEnumKeyToValue( elemBackground.attribute( u"type"_s ), Qgis::Map3DBackgroundType::NoBackground ) )
261 {
263 {
264 auto skybox = std::make_unique<QgsSkyboxSettings>();
265 skybox->readXml( elemBackground, context );
266 mBackgroundSettings = std::move( skybox );
267 break;
268 }
270 {
271 auto gradient = std::make_unique<QgsFixedGradientBackgroundSettings>();
272 gradient->readXml( elemBackground, context );
273 mBackgroundSettings = std::move( gradient );
274 break;
275 }
277 break;
278 }
279 }
280
281 QDomElement elemShadows = elem.firstChildElement( u"shadow-rendering"_s );
282 mShadowSettings.readXml( elemShadows, context );
283
284 QDomElement elemAmbientOcclusion = elem.firstChildElement( u"screen-space-ambient-occlusion"_s );
285 mAmbientOcclusionSettings.readXml( elemAmbientOcclusion, context );
286
287 {
288 QDomElement elemBloom = elem.firstChildElement( u"bloom"_s );
289 mBloomSettings.readXml( elemBloom, context );
290 }
291
292 QDomElement elemEyeDomeLighting = elem.firstChildElement( u"eye-dome-lighting"_s );
293 mEyeDomeLightingEnabled = elemEyeDomeLighting.attribute( "enabled", u"0"_s ).toInt();
294 mEyeDomeLightingStrength = elemEyeDomeLighting.attribute( "eye-dome-lighting-strength", u"1000.0"_s ).toDouble();
295 mEyeDomeLightingDistance = elemEyeDomeLighting.attribute( "eye-dome-lighting-distance", u"1"_s ).toInt();
296
297 QDomElement elemNavigationSync = elem.firstChildElement( u"navigation-sync"_s );
298 mViewSyncMode = static_cast<Qgis::ViewSyncModeFlags>( elemNavigationSync.attribute( u"view-sync-mode"_s, u"0"_s ).toInt() );
299 mVisualizeViewFrustum = elemNavigationSync.attribute( u"view-frustum-visualization-enabled"_s, u"0"_s ).toInt();
300
301 QDomElement elemDebugSettings = elem.firstChildElement( u"debug-settings"_s );
302
303 mDebugDepthMapEnabled = elemDebugSettings.attribute( u"depthmap-enabled"_s, u"0"_s ).toInt();
304 mDebugDepthMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( u"depthmap-corner"_s, u"1"_s ).toInt() );
305 mDebugDepthMapSize = elemDebugSettings.attribute( u"depthmap-size"_s, u"0.2"_s ).toDouble();
306
307 QDomElement elemDebug = elem.firstChildElement( u"debug"_s );
308 mShowTerrainBoundingBoxes = elemDebug.attribute( u"bounding-boxes"_s, u"0"_s ).toInt();
309 mShowTerrainTileInfo = elemDebug.attribute( u"terrain-tile-info"_s, u"0"_s ).toInt();
310 mShowCameraViewCenter = elemDebug.attribute( u"camera-view-center"_s, u"0"_s ).toInt();
311 mShowCameraRotationCenter = elemDebug.attribute( u"camera-rotation-center"_s, u"0"_s ).toInt();
312 mShowLightSources = elemDebug.attribute( u"show-light-sources"_s, u"0"_s ).toInt();
313 mIsFpsCounterEnabled = elemDebug.attribute( u"show-fps-counter"_s, u"0"_s ).toInt();
314 mStopUpdates = elemDebug.attribute( u"stop-updates"_s, u"0"_s ).toInt();
315 mShowDebugPanel = elemDebug.attribute( u"debug-panel"_s, u"0"_s ).toInt();
316
317 QDomElement elemTemporalRange = elem.firstChildElement( u"temporal-range"_s );
318 QDateTime start = QDateTime::fromString( elemTemporalRange.attribute( u"start"_s ), Qt::ISODate );
319 QDateTime end = QDateTime::fromString( elemTemporalRange.attribute( u"end"_s ), Qt::ISODate );
320 setTemporalRange( QgsDateTimeRange( start, end ) );
321
322 QDomElement elem3dAxis = elem.firstChildElement( u"axis3d"_s );
323 m3dAxisSettings.readXml( elem3dAxis, context );
324
325 QDomElement elemMapOverlay = elem.firstChildElement( u"map-overlay"_s );
326 if ( !elemMapOverlay.isNull() )
327 {
328 mShow2DMapOverlay = elemMapOverlay.attribute( u"enabled"_s, u"0"_s ).toInt();
329 }
330 else
331 {
332 mShow2DMapOverlay = false;
333 }
334}
335
336QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const
337{
339
340 QDomElement elem = doc.createElement( u"qgis3d"_s );
341
342 QDomElement elemOrigin = doc.createElement( u"origin"_s );
343 elemOrigin.setAttribute( u"x"_s, QString::number( mOrigin.x() ) );
344 elemOrigin.setAttribute( u"y"_s, QString::number( mOrigin.y() ) );
345 elemOrigin.setAttribute( u"z"_s, QString::number( mOrigin.z() ) );
346 elem.appendChild( elemOrigin );
347
348 QDomElement elemExtent = doc.createElement( u"extent"_s );
349 elemExtent.setAttribute( u"xMin"_s, mExtent.xMinimum() );
350 elemExtent.setAttribute( u"yMin"_s, mExtent.yMinimum() );
351 elemExtent.setAttribute( u"xMax"_s, mExtent.xMaximum() );
352 elemExtent.setAttribute( u"yMax"_s, mExtent.yMaximum() );
353 elemExtent.setAttribute( u"showIn2dView"_s, mShowExtentIn2DView );
354 elem.appendChild( elemExtent );
355
356 QDomElement elemCamera = doc.createElement( u"camera"_s );
357 elemCamera.setAttribute( u"field-of-view"_s, mFieldOfView );
358 elemCamera.setAttribute( u"projection-type"_s, static_cast<int>( mProjectionType ) );
359 switch ( mCameraNavigationMode )
360 {
362 elemCamera.setAttribute( u"camera-navigation-mode"_s, u"terrain-based-navigation"_s );
363 break;
365 elemCamera.setAttribute( u"camera-navigation-mode"_s, u"walk-navigation"_s );
366 break;
368 elemCamera.setAttribute( u"camera-navigation-mode"_s, u"globe-terrain-based-navigation"_s );
369 break;
370 }
371 elemCamera.setAttribute( u"camera-movement-speed"_s, mCameraMovementSpeed );
372 elem.appendChild( elemCamera );
373
374 QDomElement elemColor = doc.createElement( u"color"_s );
375 elemColor.setAttribute( u"background"_s, QgsColorUtils::colorToString( mBackgroundColor ) );
376 elemColor.setAttribute( u"selection"_s, QgsColorUtils::colorToString( mSelectionColor ) );
377 elem.appendChild( elemColor );
378
379 QDomElement elemCrs = doc.createElement( u"crs"_s );
380 mCrs.writeXml( elemCrs, doc );
381 elem.appendChild( elemCrs );
382
383 QDomElement elemTerrain = doc.createElement( u"terrain"_s );
384 elemTerrain.setAttribute( u"terrain-rendering-enabled"_s, mTerrainRenderingEnabled ? 1 : 0 );
385 elemTerrain.setAttribute( u"shading-enabled"_s, mTerrainShadingEnabled ? 1 : 0 );
386
387 QDomElement elemTerrainShadingMaterial = doc.createElement( u"shading-material"_s );
388 mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial, context );
389 elemTerrain.appendChild( elemTerrainShadingMaterial );
390 elemTerrain.setAttribute( u"map-theme"_s, mTerrainMapTheme );
391 elemTerrain.setAttribute( u"show-labels"_s, mShowLabels ? 1 : 0 );
392
393 {
394 QDomElement elemLights = doc.createElement( u"lights"_s );
395 for ( const QgsLightSource *light : mLightSources )
396 {
397 const QDomElement elemLight = light->writeXml( doc, context );
398 elemLights.appendChild( elemLight );
399 }
400 elem.appendChild( elemLights );
401 }
402
403 QDomElement elemMapLayers = doc.createElement( u"layers"_s );
404 for ( const QgsMapLayerRef &layerRef : mLayers )
405 {
406 QDomElement elemMapLayer = doc.createElement( u"layer"_s );
407 elemMapLayer.setAttribute( u"id"_s, layerRef.layerId );
408 elemMapLayers.appendChild( elemMapLayer );
409 }
410 elemTerrain.appendChild( elemMapLayers );
411
412 QDomElement elemTerrainGenerator = doc.createElement( u"generator"_s );
413 elemTerrainGenerator.setAttribute( u"type"_s, mTerrainSettings->type() );
414 mTerrainSettings->writeXml( elemTerrain, context );
415 elemTerrain.appendChild( elemTerrainGenerator );
416 elem.appendChild( elemTerrain );
417
418 if ( mBackgroundSettings )
419 {
420 QDomElement elemBackground = doc.createElement( u"background"_s );
421 elemBackground.setAttribute( u"type"_s, qgsEnumValueToKey( mBackgroundSettings->type() ) );
422 mBackgroundSettings->writeXml( elemBackground, context );
423 elem.appendChild( elemBackground );
424 }
425
426 QDomElement elemShadows = doc.createElement( u"shadow-rendering"_s );
427 mShadowSettings.writeXml( elemShadows, context );
428 elem.appendChild( elemShadows );
429
430 QDomElement elemAmbientOcclusion = doc.createElement( u"screen-space-ambient-occlusion"_s );
431 mAmbientOcclusionSettings.writeXml( elemAmbientOcclusion, context );
432 elem.appendChild( elemAmbientOcclusion );
433
434 {
435 QDomElement elemBloom = doc.createElement( u"bloom"_s );
436 mBloomSettings.writeXml( elemBloom, context );
437 elem.appendChild( elemBloom );
438 }
439
440 QDomElement elemDebug = doc.createElement( u"debug"_s );
441 elemDebug.setAttribute( u"bounding-boxes"_s, mShowTerrainBoundingBoxes ? 1 : 0 );
442 elemDebug.setAttribute( u"terrain-tile-info"_s, mShowTerrainTileInfo ? 1 : 0 );
443 elemDebug.setAttribute( u"camera-view-center"_s, mShowCameraViewCenter ? 1 : 0 );
444 elemDebug.setAttribute( u"camera-rotation-center"_s, mShowCameraRotationCenter ? 1 : 0 );
445 elemDebug.setAttribute( u"show-light-sources"_s, mShowLightSources ? 1 : 0 );
446 elemDebug.setAttribute( u"show-fps-counter"_s, mIsFpsCounterEnabled ? 1 : 0 );
447 elemDebug.setAttribute( u"stop-updates"_s, mStopUpdates ? 1 : 0 );
448 elemDebug.setAttribute( u"debug-panel"_s, mShowDebugPanel ? 1 : 0 );
449 elem.appendChild( elemDebug );
450
451 QDomElement elemEyeDomeLighting = doc.createElement( u"eye-dome-lighting"_s );
452 elemEyeDomeLighting.setAttribute( u"enabled"_s, mEyeDomeLightingEnabled ? 1 : 0 );
453 elemEyeDomeLighting.setAttribute( u"eye-dome-lighting-strength"_s, mEyeDomeLightingStrength );
454 elemEyeDomeLighting.setAttribute( u"eye-dome-lighting-distance"_s, mEyeDomeLightingDistance );
455 elem.appendChild( elemEyeDomeLighting );
456
457 QDomElement elemNavigationSync = doc.createElement( u"navigation-sync"_s );
458 elemNavigationSync.setAttribute( u"view-sync-mode"_s, ( int ) mViewSyncMode );
459 elemNavigationSync.setAttribute( u"view-frustum-visualization-enabled"_s, mVisualizeViewFrustum ? 1 : 0 );
460 elem.appendChild( elemNavigationSync );
461
462 QDomElement elemDebugSettings = doc.createElement( u"debug-settings"_s );
463 elemDebugSettings.setAttribute( u"depthmap-enabled"_s, mDebugDepthMapEnabled );
464 elemDebugSettings.setAttribute( u"depthmap-corner"_s, mDebugDepthMapCorner );
465 elemDebugSettings.setAttribute( u"depthmap-size"_s, mDebugDepthMapSize );
466 elem.appendChild( elemDebugSettings );
467
468 QDomElement elemTemporalRange = doc.createElement( u"temporal-range"_s );
469 elemTemporalRange.setAttribute( u"start"_s, temporalRange().begin().toString( Qt::ISODate ) );
470 elemTemporalRange.setAttribute( u"end"_s, temporalRange().end().toString( Qt::ISODate ) );
471
472 QDomElement elem3dAxis = doc.createElement( u"axis3d"_s );
473 m3dAxisSettings.writeXml( elem3dAxis, context );
474 elem.appendChild( elem3dAxis );
475
476 if ( mShow2DMapOverlay )
477 {
478 QDomElement elemMapOverlay = doc.createElement( u"map-overlay"_s );
479 elemMapOverlay.setAttribute( u"enabled"_s, 1 );
480 elem.appendChild( elemMapOverlay );
481 }
482
483 return elem;
484}
485
487{
489
490 for ( int i = 0; i < mLayers.count(); ++i )
491 {
492 QgsMapLayerRef &layerRef = mLayers[i];
493 layerRef.setLayer( project.mapLayer( layerRef.layerId ) );
494 }
495
496 if ( mTerrainSettings )
497 {
498 mTerrainSettings->resolveReferences( &project );
499
500 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
501 if ( terrainGenerator )
502 {
504 }
506 }
507}
508
510{
512
514 {
515 QgsDebugError( u"extent() should not be used with globe!"_s );
516 }
517
518 return mExtent;
519}
520
522{
524
525 if ( extent == mExtent )
526 return;
527
529 {
530 QgsDebugError( u"setExtent() should not be used with globe!"_s );
531 }
532
533 mExtent = extent;
534 const QgsPointXY center = mExtent.center();
535 setOrigin( QgsVector3D( center.x(), center.y(), 0 ) );
536 if ( mTerrainGenerator )
537 {
538 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, mTerrainGenerator->crs(), mTransformContext );
539 mTerrainGenerator->setExtent( terrainExtent );
540 }
541 emit extentChanged();
542}
543
545{
547
548 if ( origin == mOrigin )
549 return;
550
551 mOrigin = origin;
552 emit originChanged();
553}
554
556{
558
559 return mOrigin;
560}
561
568
575
577{
579
580 mCrs = crs;
581
582 // for convenience, make sure the navigation mode is consistent with the scene mode
583 if ( sceneMode() == Qgis::SceneMode::Globe && mCameraNavigationMode == Qgis::NavigationMode::TerrainBased )
584 {
586 }
587 else if ( sceneMode() == Qgis::SceneMode::Local && mCameraNavigationMode == Qgis::NavigationMode::GlobeTerrainBased )
588 {
590 }
591}
592
599
606
613
615{
617
618 mTransformContext = context;
619}
620
622{
624
625 return mPathResolver;
626}
627
629{
631
632 mPathResolver = resolver;
633}
634
641
643{
645
646 mMapThemes = mapThemes;
647}
648
649void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
650{
652
653 if ( color == mBackgroundColor )
654 return;
655
656 mBackgroundColor = color;
658}
659
661{
663
664 return mBackgroundColor;
665}
666
668{
670
671 return mBackgroundSettings.get();
672}
673
675{
677
678 mBackgroundSettings.reset( settings );
680}
681
682void Qgs3DMapSettings::setSelectionColor( const QColor &color )
683{
685
686 if ( color == mSelectionColor )
687 return;
688
689 mSelectionColor = color;
691}
692
694{
696
697 return mSelectionColor;
698}
699
701{
703
704 if ( zScale == mTerrainSettings->verticalScale() )
705 return;
706
707 mTerrainSettings->setVerticalScale( zScale );
712}
713
715{
717
718 return mTerrainSettings->verticalScale();
719}
720
721void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
722{
724
725 const QList<QgsMapLayer *> raw = _qgis_listRefToRaw( mLayers );
726
727 if ( layers == raw )
728 return;
729
730 mLayers = _qgis_listRawToRef( layers );
731 emit layersChanged();
732}
733
734QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
735{
737
738 QList<QgsMapLayer *> lst;
739 lst.reserve( mLayers.count() );
740 for ( const QgsMapLayerRef &layerRef : mLayers )
741 {
742 if ( layerRef.layer )
743 lst.append( layerRef.layer );
744 }
745 return lst;
746}
747
749{
751
752 setExtent( fullExtent );
753
754 std::unique_ptr<QgsAbstractTerrainSettings> terrainSettings( Qgs3D::terrainRegistry()->configureTerrainFromProject( properties ) );
755 if ( terrainSettings )
756 {
758 }
759}
760
762{
764
765 return mTerrainSettings.get();
766}
767
769{
771
772 bool hasChanged = false;
773 if ( settings == mTerrainSettings.get() )
774 {
775 // emit signals anyway. We don't know if the caller changed settings on the pointer before calling this..
776 hasChanged = true;
777 }
778 else
779 {
780 // ensure to generate the terrain if the settings have changed or if the terrain has never been generated.
781 hasChanged = !settings->equals( mTerrainSettings.get() ) || !mTerrainGenerator;
782 mTerrainSettings.reset( settings );
783 }
784
785 if ( hasChanged )
786 {
787 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
788 if ( terrainGenerator )
789 {
791 }
792
793 // emit all the signals, we don't know exactly what's changed
798 emit terrainElevationOffsetChanged( mTerrainSettings->elevationOffset() );
801
803 }
804}
805
807{
809
810 if ( mTerrainSettings->mapTileResolution() == res )
811 return;
812
813 mTerrainSettings->setMapTileResolution( res );
818}
819
821{
823
824 return mTerrainSettings->mapTileResolution();
825}
826
828{
830
831 if ( mTerrainSettings->maximumScreenError() == error )
832 return;
833
834 mTerrainSettings->setMaximumScreenError( error );
839}
840
842{
844
845 return mTerrainSettings->maximumScreenError();
846}
847
849{
851
852 if ( mTerrainSettings->maximumGroundError() == error )
853 return;
854
855 mTerrainSettings->setMaximumGroundError( error );
859
861}
862
864{
866
867 if ( mTerrainSettings->elevationOffset() == offset )
868 return;
869 mTerrainSettings->setElevationOffset( offset );
871 emit terrainElevationOffsetChanged( offset );
874}
875
877{
879
880 return mTerrainSettings->elevationOffset();
881}
882
884{
886
887 return mTerrainSettings->maximumGroundError();
888}
889
891{
893
894 if ( mTerrainGenerator )
895 {
896 disconnect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
897 }
898
899 if ( gen->crs().isValid() ) // Don't bother setting an extent rect in the wrong CRS
900 {
901 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, gen->crs(), mTransformContext );
902 gen->setExtent( terrainExtent );
903 }
904 mTerrainGenerator.reset( gen );
905 connect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
906
908}
909
911{
913
914 return mTerrainGenerator.get();
915}
916
918{
920
921 if ( mTerrainShadingEnabled == enabled )
922 return;
923
924 mTerrainShadingEnabled = enabled;
926}
927
929{
931
932 return mTerrainShadingEnabled;
933}
934
936{
938
939 if ( mTerrainShadingMaterial == material )
940 return;
941
942 mTerrainShadingMaterial = material;
944}
945
952
953void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
954{
956
957 if ( mTerrainMapTheme == theme )
958 return;
959
960 mTerrainMapTheme = theme;
962}
963
965{
967
968 return mTerrainMapTheme;
969}
970
972{
974
975 if ( mShowTerrainBoundingBoxes == enabled )
976 return;
977
978 mShowTerrainBoundingBoxes = enabled;
980}
981
983{
985
986 return mShowTerrainBoundingBoxes;
987}
988
989
991{
993
994 if ( mShowTerrainTileInfo == enabled )
995 return;
996
997 mShowTerrainTileInfo = enabled;
999}
1000
1002{
1004
1005 return mShowTerrainTileInfo;
1006}
1007
1009{
1011
1012 if ( mShowCameraViewCenter == enabled )
1013 return;
1014
1015 mShowCameraViewCenter = enabled;
1017}
1018
1020{
1022
1023 return mShowCameraViewCenter;
1024}
1025
1027{
1029
1030 if ( mShowCameraRotationCenter == enabled )
1031 return;
1032
1033 mShowCameraRotationCenter = enabled;
1035}
1036
1038{
1040
1041 return mShowCameraRotationCenter;
1042}
1043
1045{
1047
1048 if ( mShowLightSources == enabled )
1049 return;
1050
1051 mShowLightSources = enabled;
1053}
1054
1056{
1058
1059 return mShowLightSources;
1060}
1061
1063{
1065
1066 if ( mShowLabels == enabled )
1067 return;
1068
1069 mShowLabels = enabled;
1070 emit showLabelsChanged();
1071}
1072
1074{
1076
1077 return mShowLabels;
1078}
1079
1081{
1083
1084 if ( mStopUpdates == enabled )
1085 return;
1086
1087 mStopUpdates = enabled;
1088 emit stopUpdatesChanged();
1089}
1090
1092{
1094
1095 return mStopUpdates;
1096}
1097
1099{
1101
1102 if ( mEyeDomeLightingEnabled == enabled )
1103 return;
1104 mEyeDomeLightingEnabled = enabled;
1106}
1107
1109{
1111
1112 return mEyeDomeLightingEnabled;
1113}
1114
1116{
1118
1119 if ( mEyeDomeLightingStrength == strength )
1120 return;
1121 mEyeDomeLightingStrength = strength;
1123}
1124
1126{
1128
1129 return mEyeDomeLightingStrength;
1130}
1131
1133{
1135
1136 if ( mEyeDomeLightingDistance == distance )
1137 return;
1138 mEyeDomeLightingDistance = distance;
1140}
1141
1143{
1145
1146 return mEyeDomeLightingDistance;
1147}
1148
1150{
1152
1153 if ( mMsaaEnabled == enabled )
1154 return;
1155
1156 mMsaaEnabled = enabled;
1157 emit msaaEnabledChanged();
1158}
1159
1161{
1163
1164 return mMsaaEnabled;
1165}
1166
1167QList<QgsLightSource *> Qgs3DMapSettings::lightSources() const
1168{
1170
1171 return mLightSources;
1172}
1173
1174void Qgs3DMapSettings::setLightSources( const QList<QgsLightSource *> &lights )
1175{
1177
1178 // have lights actually changed?
1179 if ( mLightSources.count() == lights.count() )
1180 {
1181 bool same = true;
1182 for ( int i = 0; i < mLightSources.count(); ++i )
1183 {
1184 if ( mLightSources[i]->type() == lights[i]->type() )
1185 {
1186 switch ( mLightSources[i]->type() )
1187 {
1189 if ( *static_cast<QgsPointLightSettings *>( mLightSources[i] ) == *static_cast<QgsPointLightSettings *>( lights[i] ) )
1190 continue;
1191 break;
1193 if ( *static_cast<QgsDirectionalLightSettings *>( mLightSources[i] ) == *static_cast<QgsDirectionalLightSettings *>( lights[i] ) )
1194 continue;
1195 break;
1196 }
1197 }
1198 same = false;
1199 break;
1200 }
1201 if ( same )
1202 {
1203 qDeleteAll( lights );
1204 return;
1205 }
1206 }
1207
1208 qDeleteAll( mLightSources );
1209 mLightSources = lights;
1210
1212 emit pointLightsChanged();
1213 emit lightSourcesChanged();
1214}
1215
1217{
1219
1220 return mFieldOfView;
1221}
1222
1224{
1226
1227 if ( mFieldOfView == fieldOfView )
1228 return;
1229
1230 mFieldOfView = fieldOfView;
1231 emit fieldOfViewChanged();
1232}
1233
1234Qt3DRender::QCameraLens::ProjectionType Qgs3DMapSettings::projectionType() const
1235{
1237
1238 return mProjectionType;
1239}
1240
1241void Qgs3DMapSettings::setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType )
1242{
1244
1245 if ( mProjectionType == projectionType )
1246 return;
1247
1248 mProjectionType = projectionType;
1249 emit projectionTypeChanged();
1250}
1251
1253{
1255
1256 return mCameraNavigationMode;
1257}
1258
1260{
1262
1263 if ( mCameraNavigationMode == navigationMode )
1264 return;
1265
1266 mCameraNavigationMode = navigationMode;
1268}
1269
1271{
1273
1274 return mCameraMovementSpeed;
1275}
1276
1278{
1280
1281 if ( mCameraMovementSpeed == movementSpeed )
1282 return;
1283
1284 mCameraMovementSpeed = movementSpeed;
1286}
1287
1288void Qgs3DMapSettings::setOutputDpi( const double dpi )
1289{
1291
1292 mDpi = dpi;
1293}
1294
1296{
1298
1299 return mDpi;
1300}
1301
1303{
1305
1306 if ( mBackgroundSettings && mBackgroundSettings->type() == Qgis::Map3DBackgroundType::DistinctTextureSkybox )
1307 return *dynamic_cast<const QgsSkyboxSettings *>( mBackgroundSettings.get() );
1308 return QgsSkyboxSettings();
1309}
1310
1312{
1314
1315 return mShadowSettings;
1316}
1317
1319{
1321
1322 return mAmbientOcclusionSettings;
1323}
1324
1326{
1328
1329 return mBloomSettings;
1330}
1331
1338
1346
1354
1356{
1358
1359 mBloomSettings = settings;
1360 emit bloomSettingsChanged();
1361}
1362
1364{
1366
1367 return mBackgroundSettings && mBackgroundSettings->type() == Qgis::Map3DBackgroundType::DistinctTextureSkybox;
1368}
1369
1371{
1373
1374 if ( enabled )
1375 setBackgroundSettings( ( mBackgroundSettings && mBackgroundSettings->type() == Qgis::Map3DBackgroundType::DistinctTextureSkybox ) ? mBackgroundSettings->clone() : new QgsSkyboxSettings() );
1376 else
1377 setBackgroundSettings( nullptr );
1378}
1379
1381{
1383
1384 return mIsFpsCounterEnabled;
1385}
1386
1387void Qgs3DMapSettings::setShowDebugPanel( const bool enabled )
1388{
1390
1391 if ( mShowDebugPanel == enabled )
1392 return;
1393
1394 mShowDebugPanel = enabled;
1395 emit showDebugPanelChanged( enabled );
1396}
1397
1399{
1401
1402 return mShowDebugPanel;
1403}
1404
1405void Qgs3DMapSettings::setDebugShadowMapSettings( bool, Qt::Corner, double )
1406{}
1407
1409{
1410 return false;
1411}
1412
1414{
1415 return Qt::Corner::TopLeftCorner;
1416}
1417
1419{
1420 return 0;
1421}
1422
1423void Qgs3DMapSettings::setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size )
1424{
1426
1427 mDebugDepthMapEnabled = enabled;
1428 mDebugDepthMapCorner = corner;
1429 mDebugDepthMapSize = size;
1431}
1432
1434{
1436
1437 return mDebugDepthMapEnabled;
1438}
1439
1441{
1443
1444 return mDebugDepthMapCorner;
1445}
1446
1448{
1450
1451 return mDebugDepthMapSize;
1452}
1453
1454void Qgs3DMapSettings::setIsFpsCounterEnabled( bool fpsCounterEnabled )
1455{
1457
1458 if ( fpsCounterEnabled == mIsFpsCounterEnabled )
1459 return;
1460 mIsFpsCounterEnabled = fpsCounterEnabled;
1461 emit fpsCounterEnabledChanged( mIsFpsCounterEnabled );
1462}
1463
1465{
1467
1468 return mTerrainRenderingEnabled;
1469}
1470
1472{
1474
1475 if ( terrainRenderingEnabled == mTerrainRenderingEnabled )
1476 return;
1477 mTerrainRenderingEnabled = terrainRenderingEnabled;
1479}
1480
1482{
1484
1485 return mRendererUsage;
1486}
1487
1494
1501
1503{
1505
1506 mViewSyncMode = mode;
1507}
1508
1510{
1512
1513 return mVisualizeViewFrustum;
1514}
1515
1517{
1519
1520 if ( mVisualizeViewFrustum != enabled )
1521 {
1522 mVisualizeViewFrustum = enabled;
1524 }
1525}
1526
1528{
1530
1531 return m3dAxisSettings;
1532}
1533
1534void Qgs3DMapSettings::setIsDebugOverlayEnabled( bool debugOverlayEnabled )
1535{
1537
1538 if ( debugOverlayEnabled == mIsDebugOverlayEnabled )
1539 return;
1540
1541 mIsDebugOverlayEnabled = debugOverlayEnabled;
1542 emit debugOverlayEnabledChanged( mIsDebugOverlayEnabled );
1543}
1544
1546{
1548
1549 return mShowExtentIn2DView;
1550}
1551
1552void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
1553{
1555
1586}
1587
1588
1589void Qgs3DMapSettings::set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force )
1590{
1592
1593 if ( axisSettings == m3dAxisSettings )
1594 {
1595 if ( force )
1596 {
1597 // ie. refresh. We need to disconnect and to reconnect to avoid 'dirty' project
1599 emit axisSettingsChanged();
1601 }
1602 }
1603 else
1604 {
1605 m3dAxisSettings = axisSettings;
1606 emit axisSettingsChanged();
1607 }
1608}
1609
1611{
1613
1614 return mIsDebugOverlayEnabled;
1615}
1616
1618{
1620
1621 if ( show == mShowExtentIn2DView )
1622 return;
1623
1624 mShowExtentIn2DView = show;
1626}
1627
1629{
1631
1632 return mShow2DMapOverlay;
1633}
1634
1636{
1638
1639 if ( mShow2DMapOverlay == enabled )
1640 return;
1641
1642 mShow2DMapOverlay = enabled;
1644}
@ DistinctTextureSkybox
Skybox with 6 distinct textures for different faces.
Definition qgis.h:4418
@ NoBackground
No background.
Definition qgis.h:4416
@ FixedGradientBackground
Two color gradient, fixed in place.
Definition qgis.h:4417
@ 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:4443
@ TerrainBased
The default navigation based on the terrain.
Definition qgis.h:4444
@ Walk
Uses WASD keys or arrows to navigate in walking (first person) manner.
Definition qgis.h:4445
@ GlobeTerrainBased
Navigation similar to TerrainBased, but for use with globe.
Definition qgis.h:4446
RendererUsage
Usage of the renderer.
Definition qgis.h:3626
SceneMode
The 3D scene mode used in 3D map views.
Definition qgis.h:4456
@ Globe
Scene is represented as a globe using a geocentric CRS.
Definition qgis.h:4458
@ Local
Local scene based on a projected CRS.
Definition qgis.h:4457
@ Point
Point light source.
Definition qgis.h:4405
@ Directional
Directional light source.
Definition qgis.h:4406
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.
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 bloomSettingsChanged()
Emitted when the bloom lighting effect settings are changed.
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.
QgsBloomSettings bloomSettings() const
Returns the current configuration of the bloom lighting effect.
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.
void backgroundSettingsChanged()
Emitted when background settings are changed.
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.
Q_DECL_DEPRECATED 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).
Q_DECL_DEPRECATED void setSkyboxSettings(const QgsSkyboxSettings &skyboxSettings)
Sets the current configuration of the skybox.
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 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.
void setBackgroundSettings(QgsAbstract3DMapBackgroundSettings *settings)
Sets the background settings for the 3D scene.
Qgs3DAxisSettings get3DAxisSettings() const
Returns the current configuration of 3d axis.
void setEyeDomeLightingDistance(int distance)
Sets the eye dome lighting distance value (contributes to the contrast of the image.
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.
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.
Q_DECL_DEPRECATED 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 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.
const QgsAbstract3DMapBackgroundSettings * backgroundSettings() const
Returns the background settings for the 3D scene, or null if no background is set.
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().
Q_DECL_DEPRECATED 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.
Q_DECL_DEPRECATED 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 setBloomSettings(const QgsBloomSettings &settings)
Sets the current configuration of bloom lighting effect.
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.
Q_DECL_DEPRECATED 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 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:130
Base class for all background settings classes used in a 3D map view.
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.
Contains the configuration of the lighting "bloom" effect.
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
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
Definition qgis.h:7423
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:7766
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Definition qgis.h:7404
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:7765
#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.