QGIS API Documentation 4.1.0-Master (26185ffb827)
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 "qgssunlightsettings.h"
35#include "qgsterrainprovider.h"
36#include "qgsthreadingutils.h"
37
38#include <QDomDocument>
39#include <QDomElement>
40#include <QString>
41
42#include "moc_qgs3dmapsettings.cpp"
43
44using namespace Qt::StringLiterals;
45
47 : QObject( nullptr )
48{
49 connect( this, &Qgs3DMapSettings::settingsChanged, [&]() { QgsProject::instance()->setDirty(); } );
50 connectChangedSignalsToSettingsChanged();
51 mTerrainSettings = std::make_unique<QgsFlatTerrainSettings>();
52}
53
55 : QObject( nullptr )
56 , QgsTemporalRangeObject( other )
57 , mOrigin( other.mOrigin )
58 , mCrs( other.mCrs )
59 , mBackgroundColor( other.mBackgroundColor )
60 , mSelectionColor( other.mSelectionColor )
61 , mTerrainShadingEnabled( other.mTerrainShadingEnabled )
62 , mTerrainShadingMaterial( other.mTerrainShadingMaterial )
63 , mTerrainMapTheme( other.mTerrainMapTheme )
64 , mDebugFlags( other.mDebugFlags )
65 , mShowLabels( other.mShowLabels )
66 , mStopUpdates( other.mStopUpdates )
67 , mFieldOfView( other.mFieldOfView )
68 , mProjectionType( other.mProjectionType )
69 , mCameraNavigationMode( other.mCameraNavigationMode )
70 , mCameraMovementSpeed( other.mCameraMovementSpeed )
71 , mLayers( other.mLayers )
72 , mTransformContext( other.mTransformContext )
73 , mPathResolver( other.mPathResolver )
74 , mMapThemes( other.mMapThemes )
75 , mDpi( other.mDpi )
76 , mShadowSettings( other.mShadowSettings )
77 , mAmbientOcclusionSettings( other.mAmbientOcclusionSettings )
78 , mBloomSettings( other.mBloomSettings )
79 , mColorGradingSettings( other.mColorGradingSettings )
80 , mEyeDomeLightingEnabled( other.mEyeDomeLightingEnabled )
81 , mEyeDomeLightingStrength( other.mEyeDomeLightingStrength )
82 , mEyeDomeLightingDistance( other.mEyeDomeLightingDistance )
83 , mMsaaEnabled( other.mMsaaEnabled )
84 , mTextureFilterQuality( other.mTextureFilterQuality )
85 , mViewSyncMode( other.mViewSyncMode )
86 , mVisualizeViewFrustum( other.mVisualizeViewFrustum )
87 , mTerrainRenderingEnabled( other.mTerrainRenderingEnabled )
88 , mRendererUsage( other.mRendererUsage )
89 , m3dAxisSettings( other.m3dAxisSettings )
90 , mIsDebugOverlayEnabled( other.mIsDebugOverlayEnabled )
91 , mExtent( other.mExtent )
92 , mShowExtentIn2DView( other.mShowExtentIn2DView )
93 , mShow2DMapOverlay( other.mShow2DMapOverlay )
94{
95 setTerrainSettings( other.mTerrainSettings ? other.mTerrainSettings->clone() : new QgsFlatTerrainSettings() );
96
97 if ( other.mBackgroundSettings )
98 mBackgroundSettings.reset( other.mBackgroundSettings->clone() );
99
100 for ( QgsLightSource *source : std::as_const( other.mLightSources ) )
101 {
102 if ( source )
103 mLightSources << source->clone();
104 }
105
106 connect( this, &Qgs3DMapSettings::settingsChanged, [&]() { QgsProject::instance()->setDirty(); } );
107 connectChangedSignalsToSettingsChanged();
108}
109
111{
112 qDeleteAll( mLightSources );
113}
114
115void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
116{
118
120 QDomElement elemOrigin = elem.firstChildElement( u"origin"_s );
121 // clang-format off
122 mOrigin = QgsVector3D(
123 elemOrigin.attribute( u"x"_s ).toDouble(),
124 elemOrigin.attribute( u"y"_s ).toDouble(),
125 elemOrigin.attribute( u"z"_s ).toDouble()
126 );
127 // clang-format on
128
129 QDomElement elemExtent = elem.firstChildElement( u"extent"_s );
130 if ( !elemExtent.isNull() )
131 {
132 // clang-format off
133 mExtent = QgsRectangle(
134 elemExtent.attribute( u"xMin"_s ).toDouble(),
135 elemExtent.attribute( u"yMin"_s ).toDouble(),
136 elemExtent.attribute( u"xMax"_s ).toDouble(),
137 elemExtent.attribute( u"yMax"_s ).toDouble()
138 );
139 // clang-format on
140
141 mShowExtentIn2DView = elemExtent.attribute( u"showIn2dView"_s, u"0"_s ).toInt();
142 }
143 else
144 {
146 }
147
148 QDomElement elemCamera = elem.firstChildElement( u"camera"_s );
149 if ( !elemCamera.isNull() )
150 {
151 mFieldOfView = elemCamera.attribute( u"field-of-view"_s, u"45"_s ).toDouble();
152 mProjectionType = static_cast<Qt3DRender::QCameraLens::ProjectionType>( elemCamera.attribute( u"projection-type"_s, u"1"_s ).toInt() );
153 QString cameraNavigationMode = elemCamera.attribute( u"camera-navigation-mode"_s, u"basic-navigation"_s );
154 if ( cameraNavigationMode == "terrain-based-navigation"_L1 )
155 mCameraNavigationMode = Qgis::NavigationMode::TerrainBased;
156 else if ( cameraNavigationMode == "walk-navigation"_L1 )
157 mCameraNavigationMode = Qgis::NavigationMode::Walk;
158 else if ( cameraNavigationMode == "globe-terrain-based-navigation"_L1 )
159 mCameraNavigationMode = Qgis::NavigationMode::GlobeTerrainBased;
160 mCameraMovementSpeed = elemCamera.attribute( u"camera-movement-speed"_s, u"5.0"_s ).toDouble();
161 }
162
163 QDomElement elemColor = elem.firstChildElement( u"color"_s );
164 if ( !elemColor.isNull() )
165 {
166 mBackgroundColor = QgsColorUtils::colorFromString( elemColor.attribute( u"background"_s ) );
167 mSelectionColor = QgsColorUtils::colorFromString( elemColor.attribute( u"selection"_s ) );
168 }
169
170 QDomElement elemCrs = elem.firstChildElement( u"crs"_s );
171 mCrs.readXml( elemCrs );
172
173 QDomElement elemTerrain = elem.firstChildElement( u"terrain"_s );
174 mTerrainRenderingEnabled = elemTerrain.attribute( u"terrain-rendering-enabled"_s, u"1"_s ).toInt();
175 mTerrainShadingEnabled = elemTerrain.attribute( u"shading-enabled"_s, u"0"_s ).toInt();
176
177 QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( u"shading-material"_s );
178 if ( !elemTerrainShadingMaterial.isNull() )
179 mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial, context );
180 mTerrainMapTheme = elemTerrain.attribute( u"map-theme"_s );
181 mShowLabels = elemTerrain.attribute( u"show-labels"_s, u"0"_s ).toInt();
182
183 qDeleteAll( mLightSources );
184 mLightSources.clear();
185 const QDomElement lightsElem = elem.firstChildElement( u"lights"_s );
186 if ( !lightsElem.isNull() )
187 {
188 const QDomNodeList lightNodes = lightsElem.childNodes();
189 for ( int i = 0; i < lightNodes.size(); ++i )
190 {
191 const QDomElement lightElement = lightNodes.at( i ).toElement();
192 if ( QgsLightSource *light = QgsLightSource::createFromXml( lightElement, context ) )
193 mLightSources << light;
194 }
195 }
196 else
197 {
198 // older project format
199 QDomElement elemPointLights = elem.firstChildElement( u"point-lights"_s );
200 if ( !elemPointLights.isNull() )
201 {
202 QDomElement elemPointLight = elemPointLights.firstChildElement( u"point-light"_s );
203 while ( !elemPointLight.isNull() )
204 {
205 auto pointLight = std::make_unique<QgsPointLightSettings>();
206 pointLight->readXml( elemPointLight, context );
207 mLightSources << pointLight.release();
208 elemPointLight = elemPointLight.nextSiblingElement( u"point-light"_s );
209 }
210 }
211 else
212 {
213 // QGIS <= 3.4 did not have light configuration
214 auto defaultLight = std::make_unique<QgsPointLightSettings>();
215 defaultLight->setPosition( QgsVector3D( 0, 1000, 0 ) );
216 mLightSources << defaultLight.release();
217 }
218
219 QDomElement elemDirectionalLights = elem.firstChildElement( u"directional-lights"_s );
220 if ( !elemDirectionalLights.isNull() )
221 {
222 QDomElement elemDirectionalLight = elemDirectionalLights.firstChildElement( u"directional-light"_s );
223 while ( !elemDirectionalLight.isNull() )
224 {
225 auto directionalLight = std::make_unique<QgsDirectionalLightSettings>();
226 directionalLight->readXml( elemDirectionalLight, context );
227 mLightSources << directionalLight.release();
228 elemDirectionalLight = elemDirectionalLight.nextSiblingElement( u"directional-light"_s );
229 }
230 }
231 }
232
233 QDomElement elemMapLayers = elemTerrain.firstChildElement( u"layers"_s );
234 QDomElement elemMapLayer = elemMapLayers.firstChildElement( u"layer"_s );
235 QList<QgsMapLayerRef> mapLayers;
236 while ( !elemMapLayer.isNull() )
237 {
238 mapLayers << QgsMapLayerRef( elemMapLayer.attribute( u"id"_s ) );
239 elemMapLayer = elemMapLayer.nextSiblingElement( u"layer"_s );
240 }
241 mLayers = mapLayers; // needs to resolve refs afterwards
242
243 QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( u"generator"_s );
244 const QString terrainGenType = elemTerrainGenerator.attribute( u"type"_s );
245 std::unique_ptr<QgsAbstractTerrainSettings> terrainSettings( Qgs3D::terrainRegistry()->createTerrainSettings( terrainGenType ) );
246 if ( terrainSettings )
247 {
248 terrainSettings->readXml( elemTerrain, context );
250 }
251
252 mBackgroundSettings.reset();
253 QDomElement elemBackground = elem.firstChildElement( u"background"_s );
254 if ( !elemBackground.isNull() )
255 {
256 switch ( qgsEnumKeyToValue( elemBackground.attribute( u"type"_s ), Qgis::Map3DBackgroundType::NoBackground ) )
257 {
259 {
260 auto skybox = std::make_unique<QgsSkyboxSettings>();
261 skybox->readXml( elemBackground, context );
262 mBackgroundSettings = std::move( skybox );
263 break;
264 }
266 {
267 auto gradient = std::make_unique<QgsFixedGradientBackgroundSettings>();
268 gradient->readXml( elemBackground, context );
269 mBackgroundSettings = std::move( gradient );
270 break;
271 }
273 break;
274 }
275 }
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 {
284 QDomElement elemBloom = elem.firstChildElement( u"bloom"_s );
285 mBloomSettings.readXml( elemBloom, context );
286 }
287
288 {
289 QDomElement elemColorGrading = elem.firstChildElement( u"color-grading"_s );
290 mColorGradingSettings.readXml( elemColorGrading, context );
291 }
292
293 QDomElement elemEyeDomeLighting = elem.firstChildElement( u"eye-dome-lighting"_s );
294 mEyeDomeLightingEnabled = elemEyeDomeLighting.attribute( "enabled", u"0"_s ).toInt();
295 mEyeDomeLightingStrength = elemEyeDomeLighting.attribute( "eye-dome-lighting-strength", u"1000.0"_s ).toDouble();
296 mEyeDomeLightingDistance = elemEyeDomeLighting.attribute( "eye-dome-lighting-distance", u"1"_s ).toInt();
297
298 QDomElement elemNavigationSync = elem.firstChildElement( u"navigation-sync"_s );
299 mViewSyncMode = static_cast<Qgis::ViewSyncModeFlags>( elemNavigationSync.attribute( u"view-sync-mode"_s, u"0"_s ).toInt() );
300 mVisualizeViewFrustum = elemNavigationSync.attribute( u"view-frustum-visualization-enabled"_s, u"0"_s ).toInt();
301
302 QDomElement elemDebugSettings = elem.firstChildElement( u"debug-settings"_s );
303
304 mDebugDepthMapEnabled = elemDebugSettings.attribute( u"depthmap-enabled"_s, u"0"_s ).toInt();
305 mDebugDepthMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( u"depthmap-corner"_s, u"1"_s ).toInt() );
306 mDebugDepthMapSize = elemDebugSettings.attribute( u"depthmap-size"_s, u"0.2"_s ).toDouble();
307
308 QDomElement elemDebug = elem.firstChildElement( u"debug"_s );
309 mDebugFlags = qgsFlagKeysToValue( elemDebug.attribute( u"flags"_s ), Qgis::Map3DDebugFlags() );
310 mStopUpdates = elemDebug.attribute( u"stop-updates"_s, u"0"_s ).toInt();
311
312 QDomElement elemTemporalRange = elem.firstChildElement( u"temporal-range"_s );
313 QDateTime start = QDateTime::fromString( elemTemporalRange.attribute( u"start"_s ), Qt::ISODate );
314 QDateTime end = QDateTime::fromString( elemTemporalRange.attribute( u"end"_s ), Qt::ISODate );
315 setTemporalRange( QgsDateTimeRange( start, end ) );
316
317 QDomElement elem3dAxis = elem.firstChildElement( u"axis3d"_s );
318 m3dAxisSettings.readXml( elem3dAxis, context );
319
320 QDomElement elemMapOverlay = elem.firstChildElement( u"map-overlay"_s );
321 if ( !elemMapOverlay.isNull() )
322 {
323 mShow2DMapOverlay = elemMapOverlay.attribute( u"enabled"_s, u"0"_s ).toInt();
324 }
325 else
326 {
327 mShow2DMapOverlay = false;
328 }
329}
330
331QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const
332{
334
335 QDomElement elem = doc.createElement( u"qgis3d"_s );
336
337 QDomElement elemOrigin = doc.createElement( u"origin"_s );
338 elemOrigin.setAttribute( u"x"_s, QString::number( mOrigin.x() ) );
339 elemOrigin.setAttribute( u"y"_s, QString::number( mOrigin.y() ) );
340 elemOrigin.setAttribute( u"z"_s, QString::number( mOrigin.z() ) );
341 elem.appendChild( elemOrigin );
342
343 QDomElement elemExtent = doc.createElement( u"extent"_s );
344 elemExtent.setAttribute( u"xMin"_s, mExtent.xMinimum() );
345 elemExtent.setAttribute( u"yMin"_s, mExtent.yMinimum() );
346 elemExtent.setAttribute( u"xMax"_s, mExtent.xMaximum() );
347 elemExtent.setAttribute( u"yMax"_s, mExtent.yMaximum() );
348 elemExtent.setAttribute( u"showIn2dView"_s, mShowExtentIn2DView );
349 elem.appendChild( elemExtent );
350
351 QDomElement elemCamera = doc.createElement( u"camera"_s );
352 elemCamera.setAttribute( u"field-of-view"_s, mFieldOfView );
353 elemCamera.setAttribute( u"projection-type"_s, static_cast<int>( mProjectionType ) );
354 switch ( mCameraNavigationMode )
355 {
357 elemCamera.setAttribute( u"camera-navigation-mode"_s, u"terrain-based-navigation"_s );
358 break;
360 elemCamera.setAttribute( u"camera-navigation-mode"_s, u"walk-navigation"_s );
361 break;
363 elemCamera.setAttribute( u"camera-navigation-mode"_s, u"globe-terrain-based-navigation"_s );
364 break;
365 }
366 elemCamera.setAttribute( u"camera-movement-speed"_s, mCameraMovementSpeed );
367 elem.appendChild( elemCamera );
368
369 QDomElement elemColor = doc.createElement( u"color"_s );
370 elemColor.setAttribute( u"background"_s, QgsColorUtils::colorToString( mBackgroundColor ) );
371 elemColor.setAttribute( u"selection"_s, QgsColorUtils::colorToString( mSelectionColor ) );
372 elem.appendChild( elemColor );
373
374 QDomElement elemCrs = doc.createElement( u"crs"_s );
375 mCrs.writeXml( elemCrs, doc );
376 elem.appendChild( elemCrs );
377
378 QDomElement elemTerrain = doc.createElement( u"terrain"_s );
379 elemTerrain.setAttribute( u"terrain-rendering-enabled"_s, mTerrainRenderingEnabled ? 1 : 0 );
380 elemTerrain.setAttribute( u"shading-enabled"_s, mTerrainShadingEnabled ? 1 : 0 );
381
382 QDomElement elemTerrainShadingMaterial = doc.createElement( u"shading-material"_s );
383 mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial, context );
384 elemTerrain.appendChild( elemTerrainShadingMaterial );
385 elemTerrain.setAttribute( u"map-theme"_s, mTerrainMapTheme );
386 elemTerrain.setAttribute( u"show-labels"_s, mShowLabels ? 1 : 0 );
387
388 {
389 QDomElement elemLights = doc.createElement( u"lights"_s );
390 for ( const QgsLightSource *light : mLightSources )
391 {
392 const QDomElement elemLight = light->writeXml( doc, context );
393 elemLights.appendChild( elemLight );
394 }
395 elem.appendChild( elemLights );
396 }
397
398 QDomElement elemMapLayers = doc.createElement( u"layers"_s );
399 for ( const QgsMapLayerRef &layerRef : mLayers )
400 {
401 QDomElement elemMapLayer = doc.createElement( u"layer"_s );
402 elemMapLayer.setAttribute( u"id"_s, layerRef.layerId );
403 elemMapLayers.appendChild( elemMapLayer );
404 }
405 elemTerrain.appendChild( elemMapLayers );
406
407 QDomElement elemTerrainGenerator = doc.createElement( u"generator"_s );
408 elemTerrainGenerator.setAttribute( u"type"_s, mTerrainSettings->type() );
409 mTerrainSettings->writeXml( elemTerrain, context );
410 elemTerrain.appendChild( elemTerrainGenerator );
411 elem.appendChild( elemTerrain );
412
413 if ( mBackgroundSettings )
414 {
415 QDomElement elemBackground = doc.createElement( u"background"_s );
416 elemBackground.setAttribute( u"type"_s, qgsEnumValueToKey( mBackgroundSettings->type() ) );
417 mBackgroundSettings->writeXml( elemBackground, context );
418 elem.appendChild( elemBackground );
419 }
420
421 QDomElement elemShadows = doc.createElement( u"shadow-rendering"_s );
422 mShadowSettings.writeXml( elemShadows, context );
423 elem.appendChild( elemShadows );
424
425 QDomElement elemAmbientOcclusion = doc.createElement( u"screen-space-ambient-occlusion"_s );
426 mAmbientOcclusionSettings.writeXml( elemAmbientOcclusion, context );
427 elem.appendChild( elemAmbientOcclusion );
428
429 {
430 QDomElement elemBloom = doc.createElement( u"bloom"_s );
431 mBloomSettings.writeXml( elemBloom, context );
432 elem.appendChild( elemBloom );
433 }
434
435 {
436 QDomElement elemColorGrading = doc.createElement( u"color-grading"_s );
437 mColorGradingSettings.writeXml( elemColorGrading, context );
438 elem.appendChild( elemColorGrading );
439 }
440
441 QDomElement elemDebug = doc.createElement( u"debug"_s );
442 elemDebug.setAttribute( u"flags"_s, qgsFlagValueToKeys( mDebugFlags ) );
443 elemDebug.setAttribute( u"stop-updates"_s, mStopUpdates ? 1 : 0 );
444 elem.appendChild( elemDebug );
445
446 QDomElement elemEyeDomeLighting = doc.createElement( u"eye-dome-lighting"_s );
447 elemEyeDomeLighting.setAttribute( u"enabled"_s, mEyeDomeLightingEnabled ? 1 : 0 );
448 elemEyeDomeLighting.setAttribute( u"eye-dome-lighting-strength"_s, mEyeDomeLightingStrength );
449 elemEyeDomeLighting.setAttribute( u"eye-dome-lighting-distance"_s, mEyeDomeLightingDistance );
450 elem.appendChild( elemEyeDomeLighting );
451
452 QDomElement elemNavigationSync = doc.createElement( u"navigation-sync"_s );
453 elemNavigationSync.setAttribute( u"view-sync-mode"_s, ( int ) mViewSyncMode );
454 elemNavigationSync.setAttribute( u"view-frustum-visualization-enabled"_s, mVisualizeViewFrustum ? 1 : 0 );
455 elem.appendChild( elemNavigationSync );
456
457 QDomElement elemDebugSettings = doc.createElement( u"debug-settings"_s );
458 elemDebugSettings.setAttribute( u"depthmap-enabled"_s, mDebugDepthMapEnabled );
459 elemDebugSettings.setAttribute( u"depthmap-corner"_s, mDebugDepthMapCorner );
460 elemDebugSettings.setAttribute( u"depthmap-size"_s, mDebugDepthMapSize );
461 elem.appendChild( elemDebugSettings );
462
463 QDomElement elemTemporalRange = doc.createElement( u"temporal-range"_s );
464 elemTemporalRange.setAttribute( u"start"_s, temporalRange().begin().toString( Qt::ISODate ) );
465 elemTemporalRange.setAttribute( u"end"_s, temporalRange().end().toString( Qt::ISODate ) );
466
467 QDomElement elem3dAxis = doc.createElement( u"axis3d"_s );
468 m3dAxisSettings.writeXml( elem3dAxis, context );
469 elem.appendChild( elem3dAxis );
470
471 if ( mShow2DMapOverlay )
472 {
473 QDomElement elemMapOverlay = doc.createElement( u"map-overlay"_s );
474 elemMapOverlay.setAttribute( u"enabled"_s, 1 );
475 elem.appendChild( elemMapOverlay );
476 }
477
478 return elem;
479}
480
482{
484
485 for ( int i = 0; i < mLayers.count(); ++i )
486 {
487 QgsMapLayerRef &layerRef = mLayers[i];
488 layerRef.setLayer( project.mapLayer( layerRef.layerId ) );
489 }
490
491 if ( mTerrainSettings )
492 {
493 mTerrainSettings->resolveReferences( &project );
494
495 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
496 if ( terrainGenerator )
497 {
499 }
501 }
502}
503
505{
507
509 {
510 QgsDebugError( u"extent() should not be used with globe!"_s );
511 }
512
513 return mExtent;
514}
515
517{
519
520 if ( extent == mExtent )
521 return;
522
524 {
525 QgsDebugError( u"setExtent() should not be used with globe!"_s );
526 }
527
528 mExtent = extent;
529 const QgsPointXY center = mExtent.center();
530 setOrigin( QgsVector3D( center.x(), center.y(), 0 ) );
531 if ( mTerrainGenerator )
532 {
533 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, mTerrainGenerator->crs(), mTransformContext );
534 mTerrainGenerator->setExtent( terrainExtent );
535 }
536 emit extentChanged();
537}
538
540{
542
543 if ( origin == mOrigin )
544 return;
545
546 mOrigin = origin;
547 emit originChanged();
548}
549
551{
553
554 return mOrigin;
555}
556
563
570
572{
574
575 mCrs = crs;
576
577 // for convenience, make sure the navigation mode is consistent with the scene mode
578 if ( sceneMode() == Qgis::SceneMode::Globe && mCameraNavigationMode == Qgis::NavigationMode::TerrainBased )
579 {
581 }
582 else if ( sceneMode() == Qgis::SceneMode::Local && mCameraNavigationMode == Qgis::NavigationMode::GlobeTerrainBased )
583 {
585 }
586}
587
594
601
608
610{
612
613 mTransformContext = context;
614}
615
617{
619
620 return mPathResolver;
621}
622
624{
626
627 mPathResolver = resolver;
628}
629
636
638{
640
641 mMapThemes = mapThemes;
642}
643
644void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
645{
647
648 if ( color == mBackgroundColor )
649 return;
650
651 mBackgroundColor = color;
653}
654
656{
658
659 return mBackgroundColor;
660}
661
663{
665
666 return mBackgroundSettings.get();
667}
668
670{
672
673 mBackgroundSettings.reset( settings );
675}
676
677void Qgs3DMapSettings::setSelectionColor( const QColor &color )
678{
680
681 if ( color == mSelectionColor )
682 return;
683
684 mSelectionColor = color;
686}
687
689{
691
692 return mSelectionColor;
693}
694
696{
698
699 if ( zScale == mTerrainSettings->verticalScale() )
700 return;
701
702 mTerrainSettings->setVerticalScale( zScale );
707}
708
710{
712
713 return mTerrainSettings->verticalScale();
714}
715
716void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
717{
719
720 const QList<QgsMapLayer *> raw = _qgis_listRefToRaw( mLayers );
721
722 if ( layers == raw )
723 return;
724
725 mLayers = _qgis_listRawToRef( layers );
726 emit layersChanged();
727}
728
729QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
730{
732
733 QList<QgsMapLayer *> lst;
734 lst.reserve( mLayers.count() );
735 for ( const QgsMapLayerRef &layerRef : mLayers )
736 {
737 if ( layerRef.layer )
738 lst.append( layerRef.layer );
739 }
740 return lst;
741}
742
744{
746
747 setExtent( fullExtent );
748
749 std::unique_ptr<QgsAbstractTerrainSettings> terrainSettings( Qgs3D::terrainRegistry()->configureTerrainFromProject( properties ) );
750 if ( terrainSettings )
751 {
753 }
754}
755
757{
759
760 return mTerrainSettings.get();
761}
762
764{
766
767 bool hasChanged = false;
768 if ( settings == mTerrainSettings.get() )
769 {
770 // emit signals anyway. We don't know if the caller changed settings on the pointer before calling this..
771 hasChanged = true;
772 }
773 else
774 {
775 // ensure to generate the terrain if the settings have changed or if the terrain has never been generated.
776 hasChanged = !settings->equals( mTerrainSettings.get() ) || !mTerrainGenerator;
777 mTerrainSettings.reset( settings );
778 }
779
780 if ( hasChanged )
781 {
782 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
783 if ( terrainGenerator )
784 {
786 }
787
788 // emit all the signals, we don't know exactly what's changed
793 emit terrainElevationOffsetChanged( mTerrainSettings->elevationOffset() );
796
798 }
799}
800
802{
804
805 if ( mTerrainSettings->mapTileResolution() == res )
806 return;
807
808 mTerrainSettings->setMapTileResolution( res );
813}
814
816{
818
819 return mTerrainSettings->mapTileResolution();
820}
821
823{
825
826 if ( mTerrainSettings->maximumScreenError() == error )
827 return;
828
829 mTerrainSettings->setMaximumScreenError( error );
834}
835
837{
839
840 return mTerrainSettings->maximumScreenError();
841}
842
844{
846
847 if ( mTerrainSettings->maximumGroundError() == error )
848 return;
849
850 mTerrainSettings->setMaximumGroundError( error );
854
856}
857
859{
861
862 if ( mTerrainSettings->elevationOffset() == offset )
863 return;
864 mTerrainSettings->setElevationOffset( offset );
866 emit terrainElevationOffsetChanged( offset );
869}
870
872{
874
875 return mTerrainSettings->elevationOffset();
876}
877
879{
881
882 return mTerrainSettings->maximumGroundError();
883}
884
886{
888
889 if ( mTerrainGenerator )
890 {
891 disconnect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
892 }
893
894 if ( gen->crs().isValid() ) // Don't bother setting an extent rect in the wrong CRS
895 {
896 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, gen->crs(), mTransformContext );
897 gen->setExtent( terrainExtent );
898 }
899 mTerrainGenerator.reset( gen );
900 connect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
901
903}
904
906{
908
909 return mTerrainGenerator.get();
910}
911
913{
915
916 if ( mTerrainShadingEnabled == enabled )
917 return;
918
919 mTerrainShadingEnabled = enabled;
921}
922
924{
926
927 return mTerrainShadingEnabled;
928}
929
931{
933
934 if ( mTerrainShadingMaterial == material )
935 return;
936
937 mTerrainShadingMaterial = material;
939}
940
947
948void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
949{
951
952 if ( mTerrainMapTheme == theme )
953 return;
954
955 mTerrainMapTheme = theme;
957}
958
960{
962
963 return mTerrainMapTheme;
964}
965
967{
969
970 if ( mDebugFlags == flags )
971 return;
972
973 const bool hasShowTerrainBoundingBoxesChanged = mDebugFlags.testFlag( Qgis::Map3DDebugFlag::ShowTerrainBoundingBoxes ) != flags.testFlag( Qgis::Map3DDebugFlag::ShowTerrainBoundingBoxes );
974 const bool hasShowTerrainTileInfoChanged = mDebugFlags.testFlag( Qgis::Map3DDebugFlag::ShowTerrainTileInfo ) != flags.testFlag( Qgis::Map3DDebugFlag::ShowTerrainTileInfo );
975 const bool hasShowCameraViewCenterChanged = mDebugFlags.testFlag( Qgis::Map3DDebugFlag::ShowCameraViewCenter ) != flags.testFlag( Qgis::Map3DDebugFlag::ShowCameraViewCenter );
976 const bool hasShowCameraRotationCenterChanged = mDebugFlags.testFlag( Qgis::Map3DDebugFlag::ShowCameraRotationCenter ) != flags.testFlag( Qgis::Map3DDebugFlag::ShowCameraRotationCenter );
977 const bool hasShowLightSourcesChanged = mDebugFlags.testFlag( Qgis::Map3DDebugFlag::ShowLightSourceOrigins ) != flags.testFlag( Qgis::Map3DDebugFlag::ShowLightSourceOrigins );
978 const bool hasShowFpsChanged = mDebugFlags.testFlag( Qgis::Map3DDebugFlag::ShowFPS ) != flags.testFlag( Qgis::Map3DDebugFlag::ShowFPS );
979 const bool hasShowDebugPanelChanged = mDebugFlags.testFlag( Qgis::Map3DDebugFlag::ShowDebugPanel ) != flags.testFlag( Qgis::Map3DDebugFlag::ShowDebugPanel );
980
981 mDebugFlags = flags;
982 if ( hasShowTerrainBoundingBoxesChanged )
983 {
985 }
986 if ( hasShowTerrainTileInfoChanged )
987 {
989 }
990 if ( hasShowCameraViewCenterChanged )
991 {
993 }
994 if ( hasShowCameraRotationCenterChanged )
995 {
997 }
998 if ( hasShowLightSourcesChanged )
999 {
1001 }
1002 if ( hasShowFpsChanged )
1003 {
1004 emit fpsCounterEnabledChanged( mDebugFlags.testFlag( Qgis::Map3DDebugFlag::ShowFPS ) );
1005 }
1006 if ( hasShowDebugPanelChanged )
1007 {
1008 emit showDebugPanelChanged( mDebugFlags.testFlag( Qgis::Map3DDebugFlag::ShowDebugPanel ) );
1009 }
1010}
1011
1018
1020{
1022 Qgis::Map3DDebugFlags flags = mDebugFlags;
1023 flags.setFlag( Qgis::Map3DDebugFlag::ShowTerrainBoundingBoxes, enabled );
1024 setDebugFlags( flags );
1025}
1026
1033
1035{
1037 Qgis::Map3DDebugFlags flags = mDebugFlags;
1038 flags.setFlag( Qgis::Map3DDebugFlag::ShowTerrainTileInfo, enabled );
1039 setDebugFlags( flags );
1040}
1041
1048
1050{
1052 Qgis::Map3DDebugFlags flags = mDebugFlags;
1053 flags.setFlag( Qgis::Map3DDebugFlag::ShowCameraViewCenter, enabled );
1054 setDebugFlags( flags );
1055}
1056
1063
1065{
1067 Qgis::Map3DDebugFlags flags = mDebugFlags;
1068 flags.setFlag( Qgis::Map3DDebugFlag::ShowCameraRotationCenter, enabled );
1069 setDebugFlags( flags );
1070}
1071
1078
1080{
1082 Qgis::Map3DDebugFlags flags = mDebugFlags;
1083 flags.setFlag( Qgis::Map3DDebugFlag::ShowLightSourceOrigins, enabled );
1084 setDebugFlags( flags );
1085}
1086
1093
1095{
1097
1098 if ( mShowLabels == enabled )
1099 return;
1100
1101 mShowLabels = enabled;
1102 emit showLabelsChanged();
1103}
1104
1106{
1108
1109 return mShowLabels;
1110}
1111
1113{
1115
1116 if ( mStopUpdates == enabled )
1117 return;
1118
1119 mStopUpdates = enabled;
1120 emit stopUpdatesChanged();
1121}
1122
1124{
1126
1127 return mStopUpdates;
1128}
1129
1131{
1133
1134 if ( mEyeDomeLightingEnabled == enabled )
1135 return;
1136 mEyeDomeLightingEnabled = enabled;
1138}
1139
1141{
1143
1144 return mEyeDomeLightingEnabled;
1145}
1146
1148{
1150
1151 if ( mEyeDomeLightingStrength == strength )
1152 return;
1153 mEyeDomeLightingStrength = strength;
1155}
1156
1158{
1160
1161 return mEyeDomeLightingStrength;
1162}
1163
1165{
1167
1168 if ( mEyeDomeLightingDistance == distance )
1169 return;
1170 mEyeDomeLightingDistance = distance;
1172}
1173
1175{
1177
1178 return mEyeDomeLightingDistance;
1179}
1180
1182{
1184
1185 if ( mMsaaEnabled == enabled )
1186 return;
1187
1188 mMsaaEnabled = enabled;
1189 emit msaaEnabledChanged();
1190}
1191
1193{
1195
1196 return mMsaaEnabled;
1197}
1198
1199QList<QgsLightSource *> Qgs3DMapSettings::lightSources() const
1200{
1202
1203 return mLightSources;
1204}
1205
1206void Qgs3DMapSettings::setLightSources( const QList<QgsLightSource *> &lights )
1207{
1209
1210 // have lights actually changed?
1211 if ( mLightSources.count() == lights.count() )
1212 {
1213 bool same = true;
1214 for ( int i = 0; i < mLightSources.count(); ++i )
1215 {
1216 if ( mLightSources[i]->type() == lights[i]->type() )
1217 {
1218 switch ( mLightSources[i]->type() )
1219 {
1221 if ( *static_cast<QgsPointLightSettings *>( mLightSources[i] ) == *static_cast<QgsPointLightSettings *>( lights[i] ) )
1222 continue;
1223 break;
1225 if ( *static_cast<QgsDirectionalLightSettings *>( mLightSources[i] ) == *static_cast<QgsDirectionalLightSettings *>( lights[i] ) )
1226 continue;
1227 break;
1229 if ( *static_cast<QgsSunLightSettings *>( mLightSources[i] ) == *static_cast<QgsSunLightSettings *>( lights[i] ) )
1230 continue;
1231 break;
1232 }
1233 }
1234 same = false;
1235 break;
1236 }
1237 if ( same )
1238 {
1239 qDeleteAll( lights );
1240 return;
1241 }
1242 }
1243
1244 qDeleteAll( mLightSources );
1245 mLightSources = lights;
1246
1248 emit pointLightsChanged();
1249 emit lightSourcesChanged();
1250}
1251
1253{
1255
1256 return mFieldOfView;
1257}
1258
1260{
1262
1263 if ( mFieldOfView == fieldOfView )
1264 return;
1265
1266 mFieldOfView = fieldOfView;
1267 emit fieldOfViewChanged();
1268}
1269
1270Qt3DRender::QCameraLens::ProjectionType Qgs3DMapSettings::projectionType() const
1271{
1273
1274 return mProjectionType;
1275}
1276
1277void Qgs3DMapSettings::setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType )
1278{
1280
1281 if ( mProjectionType == projectionType )
1282 return;
1283
1284 mProjectionType = projectionType;
1285 emit projectionTypeChanged();
1286}
1287
1289{
1291
1292 return mCameraNavigationMode;
1293}
1294
1296{
1298
1299 if ( mCameraNavigationMode == navigationMode )
1300 return;
1301
1302 mCameraNavigationMode = navigationMode;
1304}
1305
1307{
1309
1310 return mCameraMovementSpeed;
1311}
1312
1314{
1316
1317 if ( mCameraMovementSpeed == movementSpeed )
1318 return;
1319
1320 mCameraMovementSpeed = movementSpeed;
1322}
1323
1324void Qgs3DMapSettings::setOutputDpi( const double dpi )
1325{
1327
1328 mDpi = dpi;
1329}
1330
1332{
1334
1335 return mDpi;
1336}
1337
1339{
1341
1342 if ( mBackgroundSettings && mBackgroundSettings->type() == Qgis::Map3DBackgroundType::DistinctTextureSkybox )
1343 return *dynamic_cast<const QgsSkyboxSettings *>( mBackgroundSettings.get() );
1344 return QgsSkyboxSettings();
1345}
1346
1348{
1350
1351 return mShadowSettings;
1352}
1353
1355{
1357
1358 return mAmbientOcclusionSettings;
1359}
1360
1362{
1364
1365 return mBloomSettings;
1366}
1367
1369{
1371
1372 return mColorGradingSettings;
1373}
1374
1381
1389
1397
1399{
1401
1402 mBloomSettings = settings;
1403 emit bloomSettingsChanged();
1404}
1405
1407{
1409
1410 mColorGradingSettings = settings;
1412}
1413
1415{
1417
1418 return mBackgroundSettings && mBackgroundSettings->type() == Qgis::Map3DBackgroundType::DistinctTextureSkybox;
1419}
1420
1422{
1424
1425 if ( enabled )
1426 setBackgroundSettings( ( mBackgroundSettings && mBackgroundSettings->type() == Qgis::Map3DBackgroundType::DistinctTextureSkybox ) ? mBackgroundSettings->clone() : new QgsSkyboxSettings() );
1427 else
1428 setBackgroundSettings( nullptr );
1429}
1430
1432{
1434
1435 return mDebugFlags.testFlag( Qgis::Map3DDebugFlag::ShowFPS );
1436}
1437
1438void Qgs3DMapSettings::setShowDebugPanel( const bool enabled )
1439{
1441 Qgis::Map3DDebugFlags flags = mDebugFlags;
1442 flags.setFlag( Qgis::Map3DDebugFlag::ShowDebugPanel, enabled );
1443 setDebugFlags( flags );
1444}
1445
1447{
1449
1450 return mDebugFlags.testFlag( Qgis::Map3DDebugFlag::ShowDebugPanel );
1451}
1452
1453void Qgs3DMapSettings::setDebugShadowMapSettings( bool, Qt::Corner, double )
1454{}
1455
1457{
1458 return false;
1459}
1460
1462{
1463 return Qt::Corner::TopLeftCorner;
1464}
1465
1467{
1468 return 0;
1469}
1470
1471void Qgs3DMapSettings::setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size )
1472{
1474
1475 mDebugDepthMapEnabled = enabled;
1476 mDebugDepthMapCorner = corner;
1477 mDebugDepthMapSize = size;
1479}
1480
1482{
1484
1485 return mDebugDepthMapEnabled;
1486}
1487
1489{
1491
1492 return mDebugDepthMapCorner;
1493}
1494
1496{
1498
1499 return mDebugDepthMapSize;
1500}
1501
1502void Qgs3DMapSettings::setIsFpsCounterEnabled( bool fpsCounterEnabled )
1503{
1505 Qgis::Map3DDebugFlags flags = mDebugFlags;
1506 flags.setFlag( Qgis::Map3DDebugFlag::ShowFPS, fpsCounterEnabled );
1507 setDebugFlags( flags );
1508}
1509
1511{
1513
1514 return mTerrainRenderingEnabled;
1515}
1516
1518{
1520
1521 if ( terrainRenderingEnabled == mTerrainRenderingEnabled )
1522 return;
1523 mTerrainRenderingEnabled = terrainRenderingEnabled;
1525}
1526
1528{
1530
1531 return mRendererUsage;
1532}
1533
1540
1547
1549{
1551
1552 mViewSyncMode = mode;
1553}
1554
1556{
1558
1559 return mVisualizeViewFrustum;
1560}
1561
1563{
1565
1566 if ( mVisualizeViewFrustum != enabled )
1567 {
1568 mVisualizeViewFrustum = enabled;
1570 }
1571}
1572
1574{
1576
1577 return m3dAxisSettings;
1578}
1579
1580void Qgs3DMapSettings::setIsDebugOverlayEnabled( bool debugOverlayEnabled )
1581{
1583
1584 if ( debugOverlayEnabled == mIsDebugOverlayEnabled )
1585 return;
1586
1587 mIsDebugOverlayEnabled = debugOverlayEnabled;
1588 emit debugOverlayEnabledChanged( mIsDebugOverlayEnabled );
1589}
1590
1592{
1594
1595 return mShowExtentIn2DView;
1596}
1597
1598void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
1599{
1601
1632}
1633
1634
1635void Qgs3DMapSettings::set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force )
1636{
1638
1639 if ( axisSettings == m3dAxisSettings )
1640 {
1641 if ( force )
1642 {
1643 // ie. refresh. We need to disconnect and to reconnect to avoid 'dirty' project
1645 emit axisSettingsChanged();
1647 }
1648 }
1649 else
1650 {
1651 m3dAxisSettings = axisSettings;
1652 emit axisSettingsChanged();
1653 }
1654}
1655
1657{
1659
1660 return mIsDebugOverlayEnabled;
1661}
1662
1664{
1666
1667 if ( show == mShowExtentIn2DView )
1668 return;
1669
1670 mShowExtentIn2DView = show;
1672}
1673
1675{
1677
1678 return mShow2DMapOverlay;
1679}
1680
1682{
1684
1685 if ( mShow2DMapOverlay == enabled )
1686 return;
1687
1688 mShow2DMapOverlay = enabled;
1690}
@ DistinctTextureSkybox
Skybox with 6 distinct textures for different faces.
Definition qgis.h:4439
@ NoBackground
No background.
Definition qgis.h:4437
@ FixedGradientBackground
Two color gradient, fixed in place.
Definition qgis.h:4438
@ ShowLightSourceOrigins
Shows the light source origins as a sphere.
Definition qgis.h:4324
@ ShowDebugPanel
Shows the debug panel next to the map.
Definition qgis.h:4326
@ ShowTerrainTileInfo
Displays extra tile info on top of terrain tiles.
Definition qgis.h:4321
@ ShowCameraViewCenter
Shows the camera's view center as a sphere.
Definition qgis.h:4322
@ ShowFPS
Shows the frames per second (FPS).
Definition qgis.h:4325
@ ShowCameraRotationCenter
Shows the camera's rotation center as a sphere.
Definition qgis.h:4323
@ ShowTerrainBoundingBoxes
Displays bounding boxes of terrain tiles.
Definition qgis.h:4320
@ 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:4464
@ TerrainBased
The default navigation based on the terrain.
Definition qgis.h:4465
@ Walk
Uses WASD keys or arrows to navigate in walking (first person) manner.
Definition qgis.h:4466
@ GlobeTerrainBased
Navigation similar to TerrainBased, but for use with globe.
Definition qgis.h:4467
QFlags< Map3DDebugFlag > Map3DDebugFlags
Definition qgis.h:4329
RendererUsage
Usage of the renderer.
Definition qgis.h:3626
SceneMode
The 3D scene mode used in 3D map views.
Definition qgis.h:4477
@ Globe
Scene is represented as a globe using a geocentric CRS.
Definition qgis.h:4479
@ Local
Local scene based on a projected CRS.
Definition qgis.h:4478
@ Point
Point light source.
Definition qgis.h:4425
@ Directional
Directional light source.
Definition qgis.h:4426
@ Sun
Sun based light source.
Definition qgis.h:4427
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 setColorGradingSettings(const QgsColorGradingSettings &settings)
Sets the current color grading settings.
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.
Q_DECL_DEPRECATED 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 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.
Q_DECL_DEPRECATED 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.
Q_DECL_DEPRECATED void setShowCameraRotationCenter(bool enabled)
Sets whether to show camera's rotation center as a sphere (for debugging).
void setExtent(const QgsRectangle &extent)
Sets the 3D scene's 2D extent in the 3D scene's CRS, while also setting the scene's origin to the ext...
void eyeDomeLightingEnabledChanged()
Emitted when the flag whether eye dome lighting is used has changed.
Q_DECL_DEPRECATED void setTerrainVerticalScale(double zScale)
Sets vertical scale (exaggeration) of terrain (1 = true scale, > 1 = hills get more pronounced).
void debugOverlayEnabledChanged(bool debugOverlayEnabled)
Emitted when the debug overaly is enabled or disabled.
void setOutputDpi(const double dpi)
Sets DPI used for conversion between real world units (e.g.
void setFieldOfView(double fieldOfView)
Sets the camera lens' field of view.
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 setDebugFlags(Qgis::Map3DDebugFlags flags)
Sets flags that control debugging options for the map.
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.
Q_DECL_DEPRECATED 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.
Q_DECL_DEPRECATED void setShowLightSourceOrigins(bool enabled)
Sets whether to show light source origins as a sphere (for debugging).
Q_DECL_DEPRECATED bool showDebugPanel() const
Returns whether the debug side panel is shown.
double fieldOfView() const
Returns the camera lens' field of view.
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.
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.
QgsColorGradingSettings colorGradingSettings() const
Returns the current color grading settings for the map.
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().
Qgis::Map3DDebugFlags debugFlags() const
Returns the flags that control debugging options for the map.
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,...
Q_DECL_DEPRECATED 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.
Q_DECL_DEPRECATED 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 colorGradingSettingsChanged()
Emitted when the color grading settings are changed.
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.
Q_DECL_DEPRECATED 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.
Q_DECL_DEPRECATED 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.
Q_DECL_DEPRECATED 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.
Q_DECL_DEPRECATED 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.
Q_DECL_DEPRECATED 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).
Q_DECL_DEPRECATED 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.
Contains the configuration of the scene's color grading settings, such as exposure and tone mapping.
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.
Definition of a sun light in a 3D map scene.
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:7458
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:7801
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Definition qgis.h:7439
QString qgsFlagValueToKeys(const T &value, bool *returnOk=nullptr)
Returns the value for the given keys of a flag.
Definition qgis.h:7497
T qgsFlagKeysToValue(const QString &keys, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given keys of a flag.
Definition qgis.h:7526
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:7800
#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.