QGIS API Documentation 4.1.0-Master (ca2ac17535b)
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 , mShowTerrainBoundingBoxes( other.mShowTerrainBoundingBoxes )
65 , mShowTerrainTileInfo( other.mShowTerrainTileInfo )
66 , mShowCameraViewCenter( other.mShowCameraViewCenter )
67 , mShowCameraRotationCenter( other.mShowCameraRotationCenter )
68 , mShowLightSources( other.mShowLightSources )
69 , mShowLabels( other.mShowLabels )
70 , mStopUpdates( other.mStopUpdates )
71 , mShowDebugPanel( other.mShowDebugPanel )
72 , mFieldOfView( other.mFieldOfView )
73 , mProjectionType( other.mProjectionType )
74 , mCameraNavigationMode( other.mCameraNavigationMode )
75 , mCameraMovementSpeed( other.mCameraMovementSpeed )
76 , mLayers( other.mLayers )
77 , mTransformContext( other.mTransformContext )
78 , mPathResolver( other.mPathResolver )
79 , mMapThemes( other.mMapThemes )
80 , mDpi( other.mDpi )
81 , mIsFpsCounterEnabled( other.mIsFpsCounterEnabled )
82 , mShadowSettings( other.mShadowSettings )
83 , mAmbientOcclusionSettings( other.mAmbientOcclusionSettings )
84 , mBloomSettings( other.mBloomSettings )
85 , mColorGradingSettings( other.mColorGradingSettings )
86 , mEyeDomeLightingEnabled( other.mEyeDomeLightingEnabled )
87 , mEyeDomeLightingStrength( other.mEyeDomeLightingStrength )
88 , mEyeDomeLightingDistance( other.mEyeDomeLightingDistance )
89 , mMsaaEnabled( other.mMsaaEnabled )
90 , mTextureFilterQuality( other.mTextureFilterQuality )
91 , mViewSyncMode( other.mViewSyncMode )
92 , mVisualizeViewFrustum( other.mVisualizeViewFrustum )
93 , mTerrainRenderingEnabled( other.mTerrainRenderingEnabled )
94 , mRendererUsage( other.mRendererUsage )
95 , m3dAxisSettings( other.m3dAxisSettings )
96 , mIsDebugOverlayEnabled( other.mIsDebugOverlayEnabled )
97 , mExtent( other.mExtent )
98 , mShowExtentIn2DView( other.mShowExtentIn2DView )
99 , mShow2DMapOverlay( other.mShow2DMapOverlay )
100{
101 setTerrainSettings( other.mTerrainSettings ? other.mTerrainSettings->clone() : new QgsFlatTerrainSettings() );
102
103 if ( other.mBackgroundSettings )
104 mBackgroundSettings.reset( other.mBackgroundSettings->clone() );
105
106 for ( QgsLightSource *source : std::as_const( other.mLightSources ) )
107 {
108 if ( source )
109 mLightSources << source->clone();
110 }
111
112 connect( this, &Qgs3DMapSettings::settingsChanged, [&]() { QgsProject::instance()->setDirty(); } );
113 connectChangedSignalsToSettingsChanged();
114}
115
117{
118 qDeleteAll( mLightSources );
119}
120
121void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
122{
124
126 QDomElement elemOrigin = elem.firstChildElement( u"origin"_s );
127 // clang-format off
128 mOrigin = QgsVector3D(
129 elemOrigin.attribute( u"x"_s ).toDouble(),
130 elemOrigin.attribute( u"y"_s ).toDouble(),
131 elemOrigin.attribute( u"z"_s ).toDouble()
132 );
133 // clang-format on
134
135 QDomElement elemExtent = elem.firstChildElement( u"extent"_s );
136 if ( !elemExtent.isNull() )
137 {
138 // clang-format off
139 mExtent = QgsRectangle(
140 elemExtent.attribute( u"xMin"_s ).toDouble(),
141 elemExtent.attribute( u"yMin"_s ).toDouble(),
142 elemExtent.attribute( u"xMax"_s ).toDouble(),
143 elemExtent.attribute( u"yMax"_s ).toDouble()
144 );
145 // clang-format on
146
147 mShowExtentIn2DView = elemExtent.attribute( u"showIn2dView"_s, u"0"_s ).toInt();
148 }
149 else
150 {
152 }
153
154 QDomElement elemCamera = elem.firstChildElement( u"camera"_s );
155 if ( !elemCamera.isNull() )
156 {
157 mFieldOfView = elemCamera.attribute( u"field-of-view"_s, u"45"_s ).toDouble();
158 mProjectionType = static_cast<Qt3DRender::QCameraLens::ProjectionType>( elemCamera.attribute( u"projection-type"_s, u"1"_s ).toInt() );
159 QString cameraNavigationMode = elemCamera.attribute( u"camera-navigation-mode"_s, u"basic-navigation"_s );
160 if ( cameraNavigationMode == "terrain-based-navigation"_L1 )
161 mCameraNavigationMode = Qgis::NavigationMode::TerrainBased;
162 else if ( cameraNavigationMode == "walk-navigation"_L1 )
163 mCameraNavigationMode = Qgis::NavigationMode::Walk;
164 else if ( cameraNavigationMode == "globe-terrain-based-navigation"_L1 )
165 mCameraNavigationMode = Qgis::NavigationMode::GlobeTerrainBased;
166 mCameraMovementSpeed = elemCamera.attribute( u"camera-movement-speed"_s, u"5.0"_s ).toDouble();
167 }
168
169 QDomElement elemColor = elem.firstChildElement( u"color"_s );
170 if ( !elemColor.isNull() )
171 {
172 mBackgroundColor = QgsColorUtils::colorFromString( elemColor.attribute( u"background"_s ) );
173 mSelectionColor = QgsColorUtils::colorFromString( elemColor.attribute( u"selection"_s ) );
174 }
175
176 QDomElement elemCrs = elem.firstChildElement( u"crs"_s );
177 mCrs.readXml( elemCrs );
178
179 QDomElement elemTerrain = elem.firstChildElement( u"terrain"_s );
180 mTerrainRenderingEnabled = elemTerrain.attribute( u"terrain-rendering-enabled"_s, u"1"_s ).toInt();
181 mTerrainShadingEnabled = elemTerrain.attribute( u"shading-enabled"_s, u"0"_s ).toInt();
182
183 QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( u"shading-material"_s );
184 if ( !elemTerrainShadingMaterial.isNull() )
185 mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial, context );
186 mTerrainMapTheme = elemTerrain.attribute( u"map-theme"_s );
187 mShowLabels = elemTerrain.attribute( u"show-labels"_s, u"0"_s ).toInt();
188
189 qDeleteAll( mLightSources );
190 mLightSources.clear();
191 const QDomElement lightsElem = elem.firstChildElement( u"lights"_s );
192 if ( !lightsElem.isNull() )
193 {
194 const QDomNodeList lightNodes = lightsElem.childNodes();
195 for ( int i = 0; i < lightNodes.size(); ++i )
196 {
197 const QDomElement lightElement = lightNodes.at( i ).toElement();
198 if ( QgsLightSource *light = QgsLightSource::createFromXml( lightElement, context ) )
199 mLightSources << light;
200 }
201 }
202 else
203 {
204 // older project format
205 QDomElement elemPointLights = elem.firstChildElement( u"point-lights"_s );
206 if ( !elemPointLights.isNull() )
207 {
208 QDomElement elemPointLight = elemPointLights.firstChildElement( u"point-light"_s );
209 while ( !elemPointLight.isNull() )
210 {
211 auto pointLight = std::make_unique<QgsPointLightSettings>();
212 pointLight->readXml( elemPointLight, context );
213 mLightSources << pointLight.release();
214 elemPointLight = elemPointLight.nextSiblingElement( u"point-light"_s );
215 }
216 }
217 else
218 {
219 // QGIS <= 3.4 did not have light configuration
220 auto defaultLight = std::make_unique<QgsPointLightSettings>();
221 defaultLight->setPosition( QgsVector3D( 0, 1000, 0 ) );
222 mLightSources << defaultLight.release();
223 }
224
225 QDomElement elemDirectionalLights = elem.firstChildElement( u"directional-lights"_s );
226 if ( !elemDirectionalLights.isNull() )
227 {
228 QDomElement elemDirectionalLight = elemDirectionalLights.firstChildElement( u"directional-light"_s );
229 while ( !elemDirectionalLight.isNull() )
230 {
231 auto directionalLight = std::make_unique<QgsDirectionalLightSettings>();
232 directionalLight->readXml( elemDirectionalLight, context );
233 mLightSources << directionalLight.release();
234 elemDirectionalLight = elemDirectionalLight.nextSiblingElement( u"directional-light"_s );
235 }
236 }
237 }
238
239 QDomElement elemMapLayers = elemTerrain.firstChildElement( u"layers"_s );
240 QDomElement elemMapLayer = elemMapLayers.firstChildElement( u"layer"_s );
241 QList<QgsMapLayerRef> mapLayers;
242 while ( !elemMapLayer.isNull() )
243 {
244 mapLayers << QgsMapLayerRef( elemMapLayer.attribute( u"id"_s ) );
245 elemMapLayer = elemMapLayer.nextSiblingElement( u"layer"_s );
246 }
247 mLayers = mapLayers; // needs to resolve refs afterwards
248
249 QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( u"generator"_s );
250 const QString terrainGenType = elemTerrainGenerator.attribute( u"type"_s );
251 std::unique_ptr<QgsAbstractTerrainSettings> terrainSettings( Qgs3D::terrainRegistry()->createTerrainSettings( terrainGenType ) );
252 if ( terrainSettings )
253 {
254 terrainSettings->readXml( elemTerrain, context );
256 }
257
258 mBackgroundSettings.reset();
259 QDomElement elemBackground = elem.firstChildElement( u"background"_s );
260 if ( !elemBackground.isNull() )
261 {
262 switch ( qgsEnumKeyToValue( elemBackground.attribute( u"type"_s ), Qgis::Map3DBackgroundType::NoBackground ) )
263 {
265 {
266 auto skybox = std::make_unique<QgsSkyboxSettings>();
267 skybox->readXml( elemBackground, context );
268 mBackgroundSettings = std::move( skybox );
269 break;
270 }
272 {
273 auto gradient = std::make_unique<QgsFixedGradientBackgroundSettings>();
274 gradient->readXml( elemBackground, context );
275 mBackgroundSettings = std::move( gradient );
276 break;
277 }
279 break;
280 }
281 }
282
283 QDomElement elemShadows = elem.firstChildElement( u"shadow-rendering"_s );
284 mShadowSettings.readXml( elemShadows, context );
285
286 QDomElement elemAmbientOcclusion = elem.firstChildElement( u"screen-space-ambient-occlusion"_s );
287 mAmbientOcclusionSettings.readXml( elemAmbientOcclusion, context );
288
289 {
290 QDomElement elemBloom = elem.firstChildElement( u"bloom"_s );
291 mBloomSettings.readXml( elemBloom, context );
292 }
293
294 {
295 QDomElement elemColorGrading = elem.firstChildElement( u"color-grading"_s );
296 mColorGradingSettings.readXml( elemColorGrading, context );
297 }
298
299 QDomElement elemEyeDomeLighting = elem.firstChildElement( u"eye-dome-lighting"_s );
300 mEyeDomeLightingEnabled = elemEyeDomeLighting.attribute( "enabled", u"0"_s ).toInt();
301 mEyeDomeLightingStrength = elemEyeDomeLighting.attribute( "eye-dome-lighting-strength", u"1000.0"_s ).toDouble();
302 mEyeDomeLightingDistance = elemEyeDomeLighting.attribute( "eye-dome-lighting-distance", u"1"_s ).toInt();
303
304 QDomElement elemNavigationSync = elem.firstChildElement( u"navigation-sync"_s );
305 mViewSyncMode = static_cast<Qgis::ViewSyncModeFlags>( elemNavigationSync.attribute( u"view-sync-mode"_s, u"0"_s ).toInt() );
306 mVisualizeViewFrustum = elemNavigationSync.attribute( u"view-frustum-visualization-enabled"_s, u"0"_s ).toInt();
307
308 QDomElement elemDebugSettings = elem.firstChildElement( u"debug-settings"_s );
309
310 mDebugDepthMapEnabled = elemDebugSettings.attribute( u"depthmap-enabled"_s, u"0"_s ).toInt();
311 mDebugDepthMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( u"depthmap-corner"_s, u"1"_s ).toInt() );
312 mDebugDepthMapSize = elemDebugSettings.attribute( u"depthmap-size"_s, u"0.2"_s ).toDouble();
313
314 QDomElement elemDebug = elem.firstChildElement( u"debug"_s );
315 mShowTerrainBoundingBoxes = elemDebug.attribute( u"bounding-boxes"_s, u"0"_s ).toInt();
316 mShowTerrainTileInfo = elemDebug.attribute( u"terrain-tile-info"_s, u"0"_s ).toInt();
317 mShowCameraViewCenter = elemDebug.attribute( u"camera-view-center"_s, u"0"_s ).toInt();
318 mShowCameraRotationCenter = elemDebug.attribute( u"camera-rotation-center"_s, u"0"_s ).toInt();
319 mShowLightSources = elemDebug.attribute( u"show-light-sources"_s, u"0"_s ).toInt();
320 mIsFpsCounterEnabled = elemDebug.attribute( u"show-fps-counter"_s, u"0"_s ).toInt();
321 mStopUpdates = elemDebug.attribute( u"stop-updates"_s, u"0"_s ).toInt();
322 mShowDebugPanel = elemDebug.attribute( u"debug-panel"_s, u"0"_s ).toInt();
323
324 QDomElement elemTemporalRange = elem.firstChildElement( u"temporal-range"_s );
325 QDateTime start = QDateTime::fromString( elemTemporalRange.attribute( u"start"_s ), Qt::ISODate );
326 QDateTime end = QDateTime::fromString( elemTemporalRange.attribute( u"end"_s ), Qt::ISODate );
327 setTemporalRange( QgsDateTimeRange( start, end ) );
328
329 QDomElement elem3dAxis = elem.firstChildElement( u"axis3d"_s );
330 m3dAxisSettings.readXml( elem3dAxis, context );
331
332 QDomElement elemMapOverlay = elem.firstChildElement( u"map-overlay"_s );
333 if ( !elemMapOverlay.isNull() )
334 {
335 mShow2DMapOverlay = elemMapOverlay.attribute( u"enabled"_s, u"0"_s ).toInt();
336 }
337 else
338 {
339 mShow2DMapOverlay = false;
340 }
341}
342
343QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const
344{
346
347 QDomElement elem = doc.createElement( u"qgis3d"_s );
348
349 QDomElement elemOrigin = doc.createElement( u"origin"_s );
350 elemOrigin.setAttribute( u"x"_s, QString::number( mOrigin.x() ) );
351 elemOrigin.setAttribute( u"y"_s, QString::number( mOrigin.y() ) );
352 elemOrigin.setAttribute( u"z"_s, QString::number( mOrigin.z() ) );
353 elem.appendChild( elemOrigin );
354
355 QDomElement elemExtent = doc.createElement( u"extent"_s );
356 elemExtent.setAttribute( u"xMin"_s, mExtent.xMinimum() );
357 elemExtent.setAttribute( u"yMin"_s, mExtent.yMinimum() );
358 elemExtent.setAttribute( u"xMax"_s, mExtent.xMaximum() );
359 elemExtent.setAttribute( u"yMax"_s, mExtent.yMaximum() );
360 elemExtent.setAttribute( u"showIn2dView"_s, mShowExtentIn2DView );
361 elem.appendChild( elemExtent );
362
363 QDomElement elemCamera = doc.createElement( u"camera"_s );
364 elemCamera.setAttribute( u"field-of-view"_s, mFieldOfView );
365 elemCamera.setAttribute( u"projection-type"_s, static_cast<int>( mProjectionType ) );
366 switch ( mCameraNavigationMode )
367 {
369 elemCamera.setAttribute( u"camera-navigation-mode"_s, u"terrain-based-navigation"_s );
370 break;
372 elemCamera.setAttribute( u"camera-navigation-mode"_s, u"walk-navigation"_s );
373 break;
375 elemCamera.setAttribute( u"camera-navigation-mode"_s, u"globe-terrain-based-navigation"_s );
376 break;
377 }
378 elemCamera.setAttribute( u"camera-movement-speed"_s, mCameraMovementSpeed );
379 elem.appendChild( elemCamera );
380
381 QDomElement elemColor = doc.createElement( u"color"_s );
382 elemColor.setAttribute( u"background"_s, QgsColorUtils::colorToString( mBackgroundColor ) );
383 elemColor.setAttribute( u"selection"_s, QgsColorUtils::colorToString( mSelectionColor ) );
384 elem.appendChild( elemColor );
385
386 QDomElement elemCrs = doc.createElement( u"crs"_s );
387 mCrs.writeXml( elemCrs, doc );
388 elem.appendChild( elemCrs );
389
390 QDomElement elemTerrain = doc.createElement( u"terrain"_s );
391 elemTerrain.setAttribute( u"terrain-rendering-enabled"_s, mTerrainRenderingEnabled ? 1 : 0 );
392 elemTerrain.setAttribute( u"shading-enabled"_s, mTerrainShadingEnabled ? 1 : 0 );
393
394 QDomElement elemTerrainShadingMaterial = doc.createElement( u"shading-material"_s );
395 mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial, context );
396 elemTerrain.appendChild( elemTerrainShadingMaterial );
397 elemTerrain.setAttribute( u"map-theme"_s, mTerrainMapTheme );
398 elemTerrain.setAttribute( u"show-labels"_s, mShowLabels ? 1 : 0 );
399
400 {
401 QDomElement elemLights = doc.createElement( u"lights"_s );
402 for ( const QgsLightSource *light : mLightSources )
403 {
404 const QDomElement elemLight = light->writeXml( doc, context );
405 elemLights.appendChild( elemLight );
406 }
407 elem.appendChild( elemLights );
408 }
409
410 QDomElement elemMapLayers = doc.createElement( u"layers"_s );
411 for ( const QgsMapLayerRef &layerRef : mLayers )
412 {
413 QDomElement elemMapLayer = doc.createElement( u"layer"_s );
414 elemMapLayer.setAttribute( u"id"_s, layerRef.layerId );
415 elemMapLayers.appendChild( elemMapLayer );
416 }
417 elemTerrain.appendChild( elemMapLayers );
418
419 QDomElement elemTerrainGenerator = doc.createElement( u"generator"_s );
420 elemTerrainGenerator.setAttribute( u"type"_s, mTerrainSettings->type() );
421 mTerrainSettings->writeXml( elemTerrain, context );
422 elemTerrain.appendChild( elemTerrainGenerator );
423 elem.appendChild( elemTerrain );
424
425 if ( mBackgroundSettings )
426 {
427 QDomElement elemBackground = doc.createElement( u"background"_s );
428 elemBackground.setAttribute( u"type"_s, qgsEnumValueToKey( mBackgroundSettings->type() ) );
429 mBackgroundSettings->writeXml( elemBackground, context );
430 elem.appendChild( elemBackground );
431 }
432
433 QDomElement elemShadows = doc.createElement( u"shadow-rendering"_s );
434 mShadowSettings.writeXml( elemShadows, context );
435 elem.appendChild( elemShadows );
436
437 QDomElement elemAmbientOcclusion = doc.createElement( u"screen-space-ambient-occlusion"_s );
438 mAmbientOcclusionSettings.writeXml( elemAmbientOcclusion, context );
439 elem.appendChild( elemAmbientOcclusion );
440
441 {
442 QDomElement elemBloom = doc.createElement( u"bloom"_s );
443 mBloomSettings.writeXml( elemBloom, context );
444 elem.appendChild( elemBloom );
445 }
446
447 {
448 QDomElement elemColorGrading = doc.createElement( u"color-grading"_s );
449 mColorGradingSettings.writeXml( elemColorGrading, context );
450 elem.appendChild( elemColorGrading );
451 }
452
453 QDomElement elemDebug = doc.createElement( u"debug"_s );
454 elemDebug.setAttribute( u"bounding-boxes"_s, mShowTerrainBoundingBoxes ? 1 : 0 );
455 elemDebug.setAttribute( u"terrain-tile-info"_s, mShowTerrainTileInfo ? 1 : 0 );
456 elemDebug.setAttribute( u"camera-view-center"_s, mShowCameraViewCenter ? 1 : 0 );
457 elemDebug.setAttribute( u"camera-rotation-center"_s, mShowCameraRotationCenter ? 1 : 0 );
458 elemDebug.setAttribute( u"show-light-sources"_s, mShowLightSources ? 1 : 0 );
459 elemDebug.setAttribute( u"show-fps-counter"_s, mIsFpsCounterEnabled ? 1 : 0 );
460 elemDebug.setAttribute( u"stop-updates"_s, mStopUpdates ? 1 : 0 );
461 elemDebug.setAttribute( u"debug-panel"_s, mShowDebugPanel ? 1 : 0 );
462 elem.appendChild( elemDebug );
463
464 QDomElement elemEyeDomeLighting = doc.createElement( u"eye-dome-lighting"_s );
465 elemEyeDomeLighting.setAttribute( u"enabled"_s, mEyeDomeLightingEnabled ? 1 : 0 );
466 elemEyeDomeLighting.setAttribute( u"eye-dome-lighting-strength"_s, mEyeDomeLightingStrength );
467 elemEyeDomeLighting.setAttribute( u"eye-dome-lighting-distance"_s, mEyeDomeLightingDistance );
468 elem.appendChild( elemEyeDomeLighting );
469
470 QDomElement elemNavigationSync = doc.createElement( u"navigation-sync"_s );
471 elemNavigationSync.setAttribute( u"view-sync-mode"_s, ( int ) mViewSyncMode );
472 elemNavigationSync.setAttribute( u"view-frustum-visualization-enabled"_s, mVisualizeViewFrustum ? 1 : 0 );
473 elem.appendChild( elemNavigationSync );
474
475 QDomElement elemDebugSettings = doc.createElement( u"debug-settings"_s );
476 elemDebugSettings.setAttribute( u"depthmap-enabled"_s, mDebugDepthMapEnabled );
477 elemDebugSettings.setAttribute( u"depthmap-corner"_s, mDebugDepthMapCorner );
478 elemDebugSettings.setAttribute( u"depthmap-size"_s, mDebugDepthMapSize );
479 elem.appendChild( elemDebugSettings );
480
481 QDomElement elemTemporalRange = doc.createElement( u"temporal-range"_s );
482 elemTemporalRange.setAttribute( u"start"_s, temporalRange().begin().toString( Qt::ISODate ) );
483 elemTemporalRange.setAttribute( u"end"_s, temporalRange().end().toString( Qt::ISODate ) );
484
485 QDomElement elem3dAxis = doc.createElement( u"axis3d"_s );
486 m3dAxisSettings.writeXml( elem3dAxis, context );
487 elem.appendChild( elem3dAxis );
488
489 if ( mShow2DMapOverlay )
490 {
491 QDomElement elemMapOverlay = doc.createElement( u"map-overlay"_s );
492 elemMapOverlay.setAttribute( u"enabled"_s, 1 );
493 elem.appendChild( elemMapOverlay );
494 }
495
496 return elem;
497}
498
500{
502
503 for ( int i = 0; i < mLayers.count(); ++i )
504 {
505 QgsMapLayerRef &layerRef = mLayers[i];
506 layerRef.setLayer( project.mapLayer( layerRef.layerId ) );
507 }
508
509 if ( mTerrainSettings )
510 {
511 mTerrainSettings->resolveReferences( &project );
512
513 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
514 if ( terrainGenerator )
515 {
517 }
519 }
520}
521
523{
525
527 {
528 QgsDebugError( u"extent() should not be used with globe!"_s );
529 }
530
531 return mExtent;
532}
533
535{
537
538 if ( extent == mExtent )
539 return;
540
542 {
543 QgsDebugError( u"setExtent() should not be used with globe!"_s );
544 }
545
546 mExtent = extent;
547 const QgsPointXY center = mExtent.center();
548 setOrigin( QgsVector3D( center.x(), center.y(), 0 ) );
549 if ( mTerrainGenerator )
550 {
551 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, mTerrainGenerator->crs(), mTransformContext );
552 mTerrainGenerator->setExtent( terrainExtent );
553 }
554 emit extentChanged();
555}
556
558{
560
561 if ( origin == mOrigin )
562 return;
563
564 mOrigin = origin;
565 emit originChanged();
566}
567
569{
571
572 return mOrigin;
573}
574
581
588
590{
592
593 mCrs = crs;
594
595 // for convenience, make sure the navigation mode is consistent with the scene mode
596 if ( sceneMode() == Qgis::SceneMode::Globe && mCameraNavigationMode == Qgis::NavigationMode::TerrainBased )
597 {
599 }
600 else if ( sceneMode() == Qgis::SceneMode::Local && mCameraNavigationMode == Qgis::NavigationMode::GlobeTerrainBased )
601 {
603 }
604}
605
612
619
626
628{
630
631 mTransformContext = context;
632}
633
635{
637
638 return mPathResolver;
639}
640
642{
644
645 mPathResolver = resolver;
646}
647
654
656{
658
659 mMapThemes = mapThemes;
660}
661
662void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
663{
665
666 if ( color == mBackgroundColor )
667 return;
668
669 mBackgroundColor = color;
671}
672
674{
676
677 return mBackgroundColor;
678}
679
681{
683
684 return mBackgroundSettings.get();
685}
686
688{
690
691 mBackgroundSettings.reset( settings );
693}
694
695void Qgs3DMapSettings::setSelectionColor( const QColor &color )
696{
698
699 if ( color == mSelectionColor )
700 return;
701
702 mSelectionColor = color;
704}
705
707{
709
710 return mSelectionColor;
711}
712
714{
716
717 if ( zScale == mTerrainSettings->verticalScale() )
718 return;
719
720 mTerrainSettings->setVerticalScale( zScale );
725}
726
728{
730
731 return mTerrainSettings->verticalScale();
732}
733
734void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
735{
737
738 const QList<QgsMapLayer *> raw = _qgis_listRefToRaw( mLayers );
739
740 if ( layers == raw )
741 return;
742
743 mLayers = _qgis_listRawToRef( layers );
744 emit layersChanged();
745}
746
747QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
748{
750
751 QList<QgsMapLayer *> lst;
752 lst.reserve( mLayers.count() );
753 for ( const QgsMapLayerRef &layerRef : mLayers )
754 {
755 if ( layerRef.layer )
756 lst.append( layerRef.layer );
757 }
758 return lst;
759}
760
762{
764
765 setExtent( fullExtent );
766
767 std::unique_ptr<QgsAbstractTerrainSettings> terrainSettings( Qgs3D::terrainRegistry()->configureTerrainFromProject( properties ) );
768 if ( terrainSettings )
769 {
771 }
772}
773
775{
777
778 return mTerrainSettings.get();
779}
780
782{
784
785 bool hasChanged = false;
786 if ( settings == mTerrainSettings.get() )
787 {
788 // emit signals anyway. We don't know if the caller changed settings on the pointer before calling this..
789 hasChanged = true;
790 }
791 else
792 {
793 // ensure to generate the terrain if the settings have changed or if the terrain has never been generated.
794 hasChanged = !settings->equals( mTerrainSettings.get() ) || !mTerrainGenerator;
795 mTerrainSettings.reset( settings );
796 }
797
798 if ( hasChanged )
799 {
800 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
801 if ( terrainGenerator )
802 {
804 }
805
806 // emit all the signals, we don't know exactly what's changed
811 emit terrainElevationOffsetChanged( mTerrainSettings->elevationOffset() );
814
816 }
817}
818
820{
822
823 if ( mTerrainSettings->mapTileResolution() == res )
824 return;
825
826 mTerrainSettings->setMapTileResolution( res );
831}
832
834{
836
837 return mTerrainSettings->mapTileResolution();
838}
839
841{
843
844 if ( mTerrainSettings->maximumScreenError() == error )
845 return;
846
847 mTerrainSettings->setMaximumScreenError( error );
852}
853
855{
857
858 return mTerrainSettings->maximumScreenError();
859}
860
862{
864
865 if ( mTerrainSettings->maximumGroundError() == error )
866 return;
867
868 mTerrainSettings->setMaximumGroundError( error );
872
874}
875
877{
879
880 if ( mTerrainSettings->elevationOffset() == offset )
881 return;
882 mTerrainSettings->setElevationOffset( offset );
884 emit terrainElevationOffsetChanged( offset );
887}
888
890{
892
893 return mTerrainSettings->elevationOffset();
894}
895
897{
899
900 return mTerrainSettings->maximumGroundError();
901}
902
904{
906
907 if ( mTerrainGenerator )
908 {
909 disconnect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
910 }
911
912 if ( gen->crs().isValid() ) // Don't bother setting an extent rect in the wrong CRS
913 {
914 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, gen->crs(), mTransformContext );
915 gen->setExtent( terrainExtent );
916 }
917 mTerrainGenerator.reset( gen );
918 connect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
919
921}
922
924{
926
927 return mTerrainGenerator.get();
928}
929
931{
933
934 if ( mTerrainShadingEnabled == enabled )
935 return;
936
937 mTerrainShadingEnabled = enabled;
939}
940
942{
944
945 return mTerrainShadingEnabled;
946}
947
949{
951
952 if ( mTerrainShadingMaterial == material )
953 return;
954
955 mTerrainShadingMaterial = material;
957}
958
965
966void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
967{
969
970 if ( mTerrainMapTheme == theme )
971 return;
972
973 mTerrainMapTheme = theme;
975}
976
978{
980
981 return mTerrainMapTheme;
982}
983
985{
987
988 if ( mShowTerrainBoundingBoxes == enabled )
989 return;
990
991 mShowTerrainBoundingBoxes = enabled;
993}
994
996{
998
999 return mShowTerrainBoundingBoxes;
1000}
1001
1002
1004{
1006
1007 if ( mShowTerrainTileInfo == enabled )
1008 return;
1009
1010 mShowTerrainTileInfo = enabled;
1012}
1013
1015{
1017
1018 return mShowTerrainTileInfo;
1019}
1020
1022{
1024
1025 if ( mShowCameraViewCenter == enabled )
1026 return;
1027
1028 mShowCameraViewCenter = enabled;
1030}
1031
1033{
1035
1036 return mShowCameraViewCenter;
1037}
1038
1040{
1042
1043 if ( mShowCameraRotationCenter == enabled )
1044 return;
1045
1046 mShowCameraRotationCenter = enabled;
1048}
1049
1051{
1053
1054 return mShowCameraRotationCenter;
1055}
1056
1058{
1060
1061 if ( mShowLightSources == enabled )
1062 return;
1063
1064 mShowLightSources = enabled;
1066}
1067
1069{
1071
1072 return mShowLightSources;
1073}
1074
1076{
1078
1079 if ( mShowLabels == enabled )
1080 return;
1081
1082 mShowLabels = enabled;
1083 emit showLabelsChanged();
1084}
1085
1087{
1089
1090 return mShowLabels;
1091}
1092
1094{
1096
1097 if ( mStopUpdates == enabled )
1098 return;
1099
1100 mStopUpdates = enabled;
1101 emit stopUpdatesChanged();
1102}
1103
1105{
1107
1108 return mStopUpdates;
1109}
1110
1112{
1114
1115 if ( mEyeDomeLightingEnabled == enabled )
1116 return;
1117 mEyeDomeLightingEnabled = enabled;
1119}
1120
1122{
1124
1125 return mEyeDomeLightingEnabled;
1126}
1127
1129{
1131
1132 if ( mEyeDomeLightingStrength == strength )
1133 return;
1134 mEyeDomeLightingStrength = strength;
1136}
1137
1139{
1141
1142 return mEyeDomeLightingStrength;
1143}
1144
1146{
1148
1149 if ( mEyeDomeLightingDistance == distance )
1150 return;
1151 mEyeDomeLightingDistance = distance;
1153}
1154
1156{
1158
1159 return mEyeDomeLightingDistance;
1160}
1161
1163{
1165
1166 if ( mMsaaEnabled == enabled )
1167 return;
1168
1169 mMsaaEnabled = enabled;
1170 emit msaaEnabledChanged();
1171}
1172
1174{
1176
1177 return mMsaaEnabled;
1178}
1179
1180QList<QgsLightSource *> Qgs3DMapSettings::lightSources() const
1181{
1183
1184 return mLightSources;
1185}
1186
1187void Qgs3DMapSettings::setLightSources( const QList<QgsLightSource *> &lights )
1188{
1190
1191 // have lights actually changed?
1192 if ( mLightSources.count() == lights.count() )
1193 {
1194 bool same = true;
1195 for ( int i = 0; i < mLightSources.count(); ++i )
1196 {
1197 if ( mLightSources[i]->type() == lights[i]->type() )
1198 {
1199 switch ( mLightSources[i]->type() )
1200 {
1202 if ( *static_cast<QgsPointLightSettings *>( mLightSources[i] ) == *static_cast<QgsPointLightSettings *>( lights[i] ) )
1203 continue;
1204 break;
1206 if ( *static_cast<QgsDirectionalLightSettings *>( mLightSources[i] ) == *static_cast<QgsDirectionalLightSettings *>( lights[i] ) )
1207 continue;
1208 break;
1210 if ( *static_cast<QgsSunLightSettings *>( mLightSources[i] ) == *static_cast<QgsSunLightSettings *>( lights[i] ) )
1211 continue;
1212 break;
1213 }
1214 }
1215 same = false;
1216 break;
1217 }
1218 if ( same )
1219 {
1220 qDeleteAll( lights );
1221 return;
1222 }
1223 }
1224
1225 qDeleteAll( mLightSources );
1226 mLightSources = lights;
1227
1229 emit pointLightsChanged();
1230 emit lightSourcesChanged();
1231}
1232
1234{
1236
1237 return mFieldOfView;
1238}
1239
1241{
1243
1244 if ( mFieldOfView == fieldOfView )
1245 return;
1246
1247 mFieldOfView = fieldOfView;
1248 emit fieldOfViewChanged();
1249}
1250
1251Qt3DRender::QCameraLens::ProjectionType Qgs3DMapSettings::projectionType() const
1252{
1254
1255 return mProjectionType;
1256}
1257
1258void Qgs3DMapSettings::setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType )
1259{
1261
1262 if ( mProjectionType == projectionType )
1263 return;
1264
1265 mProjectionType = projectionType;
1266 emit projectionTypeChanged();
1267}
1268
1270{
1272
1273 return mCameraNavigationMode;
1274}
1275
1277{
1279
1280 if ( mCameraNavigationMode == navigationMode )
1281 return;
1282
1283 mCameraNavigationMode = navigationMode;
1285}
1286
1288{
1290
1291 return mCameraMovementSpeed;
1292}
1293
1295{
1297
1298 if ( mCameraMovementSpeed == movementSpeed )
1299 return;
1300
1301 mCameraMovementSpeed = movementSpeed;
1303}
1304
1305void Qgs3DMapSettings::setOutputDpi( const double dpi )
1306{
1308
1309 mDpi = dpi;
1310}
1311
1313{
1315
1316 return mDpi;
1317}
1318
1320{
1322
1323 if ( mBackgroundSettings && mBackgroundSettings->type() == Qgis::Map3DBackgroundType::DistinctTextureSkybox )
1324 return *dynamic_cast<const QgsSkyboxSettings *>( mBackgroundSettings.get() );
1325 return QgsSkyboxSettings();
1326}
1327
1329{
1331
1332 return mShadowSettings;
1333}
1334
1336{
1338
1339 return mAmbientOcclusionSettings;
1340}
1341
1343{
1345
1346 return mBloomSettings;
1347}
1348
1350{
1352
1353 return mColorGradingSettings;
1354}
1355
1362
1370
1378
1380{
1382
1383 mBloomSettings = settings;
1384 emit bloomSettingsChanged();
1385}
1386
1388{
1390
1391 mColorGradingSettings = settings;
1393}
1394
1396{
1398
1399 return mBackgroundSettings && mBackgroundSettings->type() == Qgis::Map3DBackgroundType::DistinctTextureSkybox;
1400}
1401
1403{
1405
1406 if ( enabled )
1407 setBackgroundSettings( ( mBackgroundSettings && mBackgroundSettings->type() == Qgis::Map3DBackgroundType::DistinctTextureSkybox ) ? mBackgroundSettings->clone() : new QgsSkyboxSettings() );
1408 else
1409 setBackgroundSettings( nullptr );
1410}
1411
1413{
1415
1416 return mIsFpsCounterEnabled;
1417}
1418
1419void Qgs3DMapSettings::setShowDebugPanel( const bool enabled )
1420{
1422
1423 if ( mShowDebugPanel == enabled )
1424 return;
1425
1426 mShowDebugPanel = enabled;
1427 emit showDebugPanelChanged( enabled );
1428}
1429
1431{
1433
1434 return mShowDebugPanel;
1435}
1436
1437void Qgs3DMapSettings::setDebugShadowMapSettings( bool, Qt::Corner, double )
1438{}
1439
1441{
1442 return false;
1443}
1444
1446{
1447 return Qt::Corner::TopLeftCorner;
1448}
1449
1451{
1452 return 0;
1453}
1454
1455void Qgs3DMapSettings::setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size )
1456{
1458
1459 mDebugDepthMapEnabled = enabled;
1460 mDebugDepthMapCorner = corner;
1461 mDebugDepthMapSize = size;
1463}
1464
1466{
1468
1469 return mDebugDepthMapEnabled;
1470}
1471
1473{
1475
1476 return mDebugDepthMapCorner;
1477}
1478
1480{
1482
1483 return mDebugDepthMapSize;
1484}
1485
1486void Qgs3DMapSettings::setIsFpsCounterEnabled( bool fpsCounterEnabled )
1487{
1489
1490 if ( fpsCounterEnabled == mIsFpsCounterEnabled )
1491 return;
1492 mIsFpsCounterEnabled = fpsCounterEnabled;
1493 emit fpsCounterEnabledChanged( mIsFpsCounterEnabled );
1494}
1495
1497{
1499
1500 return mTerrainRenderingEnabled;
1501}
1502
1504{
1506
1507 if ( terrainRenderingEnabled == mTerrainRenderingEnabled )
1508 return;
1509 mTerrainRenderingEnabled = terrainRenderingEnabled;
1511}
1512
1514{
1516
1517 return mRendererUsage;
1518}
1519
1526
1533
1535{
1537
1538 mViewSyncMode = mode;
1539}
1540
1542{
1544
1545 return mVisualizeViewFrustum;
1546}
1547
1549{
1551
1552 if ( mVisualizeViewFrustum != enabled )
1553 {
1554 mVisualizeViewFrustum = enabled;
1556 }
1557}
1558
1560{
1562
1563 return m3dAxisSettings;
1564}
1565
1566void Qgs3DMapSettings::setIsDebugOverlayEnabled( bool debugOverlayEnabled )
1567{
1569
1570 if ( debugOverlayEnabled == mIsDebugOverlayEnabled )
1571 return;
1572
1573 mIsDebugOverlayEnabled = debugOverlayEnabled;
1574 emit debugOverlayEnabledChanged( mIsDebugOverlayEnabled );
1575}
1576
1578{
1580
1581 return mShowExtentIn2DView;
1582}
1583
1584void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
1585{
1587
1618}
1619
1620
1621void Qgs3DMapSettings::set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force )
1622{
1624
1625 if ( axisSettings == m3dAxisSettings )
1626 {
1627 if ( force )
1628 {
1629 // ie. refresh. We need to disconnect and to reconnect to avoid 'dirty' project
1631 emit axisSettingsChanged();
1633 }
1634 }
1635 else
1636 {
1637 m3dAxisSettings = axisSettings;
1638 emit axisSettingsChanged();
1639 }
1640}
1641
1643{
1645
1646 return mIsDebugOverlayEnabled;
1647}
1648
1650{
1652
1653 if ( show == mShowExtentIn2DView )
1654 return;
1655
1656 mShowExtentIn2DView = show;
1658}
1659
1661{
1663
1664 return mShow2DMapOverlay;
1665}
1666
1668{
1670
1671 if ( mShow2DMapOverlay == enabled )
1672 return;
1673
1674 mShow2DMapOverlay = enabled;
1676}
@ DistinctTextureSkybox
Skybox with 6 distinct textures for different faces.
Definition qgis.h:4419
@ NoBackground
No background.
Definition qgis.h:4417
@ FixedGradientBackground
Two color gradient, fixed in place.
Definition qgis.h:4418
@ 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:4444
@ TerrainBased
The default navigation based on the terrain.
Definition qgis.h:4445
@ Walk
Uses WASD keys or arrows to navigate in walking (first person) manner.
Definition qgis.h:4446
@ GlobeTerrainBased
Navigation similar to TerrainBased, but for use with globe.
Definition qgis.h:4447
RendererUsage
Usage of the renderer.
Definition qgis.h:3626
SceneMode
The 3D scene mode used in 3D map views.
Definition qgis.h:4457
@ Globe
Scene is represented as a globe using a geocentric CRS.
Definition qgis.h:4459
@ Local
Local scene based on a projected CRS.
Definition qgis.h:4458
@ Point
Point light source.
Definition qgis.h:4405
@ Directional
Directional light source.
Definition qgis.h:4406
@ Sun
Sun based light source.
Definition qgis.h:4407
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.
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.
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.
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).
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.
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().
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 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.
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.
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:7437
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:7780
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Definition qgis.h:7418
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:7779
#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.