QGIS API Documentation 3.41.0-Master (64d82d4c163)
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#include "moc_qgs3dmapsettings.cpp"
18
19#include "qgs3d.h"
20#include "qgs3dutils.h"
23#include "qgsterrainprovider.h"
24#include "qgslightsource.h"
25#include "qgscolorutils.h"
26#include "qgsrasterlayer.h"
29#include "qgs3drendercontext.h"
30#include "qgsthreadingutils.h"
35
36#include <QDomDocument>
37#include <QDomElement>
38
39
41 : QObject( nullptr )
42{
43 connect( this, &Qgs3DMapSettings::settingsChanged, [&]() {
45 } );
46 connectChangedSignalsToSettingsChanged();
47 mTerrainSettings = std::make_unique<QgsFlatTerrainSettings>();
48}
49
51 : QObject( nullptr )
52 , QgsTemporalRangeObject( other )
53 , mOrigin( other.mOrigin )
54 , mCrs( other.mCrs )
55 , mBackgroundColor( other.mBackgroundColor )
56 , mSelectionColor( other.mSelectionColor )
57 , mTerrainShadingEnabled( other.mTerrainShadingEnabled )
58 , mTerrainShadingMaterial( other.mTerrainShadingMaterial )
59 , mTerrainMapTheme( other.mTerrainMapTheme )
60 , mShowTerrainBoundingBoxes( other.mShowTerrainBoundingBoxes )
61 , mShowTerrainTileInfo( other.mShowTerrainTileInfo )
62 , mShowCameraViewCenter( other.mShowCameraViewCenter )
63 , mShowCameraRotationCenter( other.mShowCameraRotationCenter )
64 , mShowLightSources( other.mShowLightSources )
65 , mShowLabels( other.mShowLabels )
66 , mStopUpdates( other.mStopUpdates )
67 , mShowDebugPanel( other.mShowDebugPanel )
68 , mFieldOfView( other.mFieldOfView )
69 , mProjectionType( other.mProjectionType )
70 , mCameraNavigationMode( other.mCameraNavigationMode )
71 , mCameraMovementSpeed( other.mCameraMovementSpeed )
72 , mLayers( other.mLayers )
73 , mTransformContext( other.mTransformContext )
74 , mPathResolver( other.mPathResolver )
75 , mMapThemes( other.mMapThemes )
76 , mDpi( other.mDpi )
77 , mIsFpsCounterEnabled( other.mIsFpsCounterEnabled )
78 , mIsSkyboxEnabled( other.mIsSkyboxEnabled )
79 , mSkyboxSettings( other.mSkyboxSettings )
80 , mShadowSettings( other.mShadowSettings )
81 , mAmbientOcclusionSettings( other.mAmbientOcclusionSettings )
82 , mEyeDomeLightingEnabled( other.mEyeDomeLightingEnabled )
83 , mEyeDomeLightingStrength( other.mEyeDomeLightingStrength )
84 , mEyeDomeLightingDistance( other.mEyeDomeLightingDistance )
85 , mViewSyncMode( other.mViewSyncMode )
86 , mVisualizeViewFrustum( other.mVisualizeViewFrustum )
87 , mDebugShadowMapEnabled( other.mDebugShadowMapEnabled )
88 , mDebugShadowMapCorner( other.mDebugShadowMapCorner )
89 , mDebugShadowMapSize( other.mDebugShadowMapSize )
90 , mDebugDepthMapEnabled( other.mDebugDepthMapEnabled )
91 , mDebugDepthMapCorner( other.mDebugDepthMapCorner )
92 , mDebugDepthMapSize( other.mDebugDepthMapSize )
93 , mTerrainRenderingEnabled( other.mTerrainRenderingEnabled )
94 , mRendererUsage( other.mRendererUsage )
95 , m3dAxisSettings( other.m3dAxisSettings )
96 , mIsDebugOverlayEnabled( other.mIsDebugOverlayEnabled )
97 , mExtent( other.mExtent )
98 , mShowExtentIn2DView( other.mShowExtentIn2DView )
99{
100 setTerrainSettings( other.mTerrainSettings ? other.mTerrainSettings->clone() : new QgsFlatTerrainSettings() );
101
102 for ( QgsLightSource *source : std::as_const( other.mLightSources ) )
103 {
104 if ( source )
105 mLightSources << source->clone();
106 }
107
108 connect( this, &Qgs3DMapSettings::settingsChanged, [&]() {
110 } );
111 connectChangedSignalsToSettingsChanged();
112}
113
115{
116 qDeleteAll( mLightSources );
117}
118
119void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
120{
122
124 QDomElement elemOrigin = elem.firstChildElement( QStringLiteral( "origin" ) );
125 mOrigin = QgsVector3D(
126 elemOrigin.attribute( QStringLiteral( "x" ) ).toDouble(),
127 elemOrigin.attribute( QStringLiteral( "y" ) ).toDouble(),
128 elemOrigin.attribute( QStringLiteral( "z" ) ).toDouble()
129 );
130
131 QDomElement elemExtent = elem.firstChildElement( QStringLiteral( "extent" ) );
132 if ( !elemExtent.isNull() )
133 {
134 mExtent = QgsRectangle(
135 elemExtent.attribute( QStringLiteral( "xMin" ) ).toDouble(),
136 elemExtent.attribute( QStringLiteral( "yMin" ) ).toDouble(),
137 elemExtent.attribute( QStringLiteral( "xMax" ) ).toDouble(),
138 elemExtent.attribute( QStringLiteral( "yMax" ) ).toDouble()
139 );
140
141 mShowExtentIn2DView = elemExtent.attribute( QStringLiteral( "showIn2dView" ), QStringLiteral( "0" ) ).toInt();
142 }
143 else
144 {
146 }
147
148 QDomElement elemCamera = elem.firstChildElement( QStringLiteral( "camera" ) );
149 if ( !elemCamera.isNull() )
150 {
151 mFieldOfView = elemCamera.attribute( QStringLiteral( "field-of-view" ), QStringLiteral( "45" ) ).toFloat();
152 mProjectionType = static_cast<Qt3DRender::QCameraLens::ProjectionType>( elemCamera.attribute( QStringLiteral( "projection-type" ), QStringLiteral( "1" ) ).toInt() );
153 QString cameraNavigationMode = elemCamera.attribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "basic-navigation" ) );
154 if ( cameraNavigationMode == QLatin1String( "terrain-based-navigation" ) )
155 mCameraNavigationMode = Qgis::NavigationMode::TerrainBased;
156 else if ( cameraNavigationMode == QLatin1String( "walk-navigation" ) )
157 mCameraNavigationMode = Qgis::NavigationMode::Walk;
158 mCameraMovementSpeed = elemCamera.attribute( QStringLiteral( "camera-movement-speed" ), QStringLiteral( "5.0" ) ).toDouble();
159 }
160
161 QDomElement elemColor = elem.firstChildElement( QStringLiteral( "color" ) );
162 if ( !elemColor.isNull() )
163 {
164 mBackgroundColor = QgsColorUtils::colorFromString( elemColor.attribute( QStringLiteral( "background" ) ) );
165 mSelectionColor = QgsColorUtils::colorFromString( elemColor.attribute( QStringLiteral( "selection" ) ) );
166 }
167
168 QDomElement elemCrs = elem.firstChildElement( QStringLiteral( "crs" ) );
169 mCrs.readXml( elemCrs );
170
171 QDomElement elemTerrain = elem.firstChildElement( QStringLiteral( "terrain" ) );
172 mTerrainRenderingEnabled = elemTerrain.attribute( QStringLiteral( "terrain-rendering-enabled" ), QStringLiteral( "1" ) ).toInt();
173 mTerrainShadingEnabled = elemTerrain.attribute( QStringLiteral( "shading-enabled" ), QStringLiteral( "0" ) ).toInt();
174
175 QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( QStringLiteral( "shading-material" ) );
176 if ( !elemTerrainShadingMaterial.isNull() )
177 mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial, context );
178 mTerrainMapTheme = elemTerrain.attribute( QStringLiteral( "map-theme" ) );
179 mShowLabels = elemTerrain.attribute( QStringLiteral( "show-labels" ), QStringLiteral( "0" ) ).toInt();
180
181 qDeleteAll( mLightSources );
182 mLightSources.clear();
183 const QDomElement lightsElem = elem.firstChildElement( QStringLiteral( "lights" ) );
184 if ( !lightsElem.isNull() )
185 {
186 const QDomNodeList lightNodes = lightsElem.childNodes();
187 for ( int i = 0; i < lightNodes.size(); ++i )
188 {
189 const QDomElement lightElement = lightNodes.at( i ).toElement();
190 if ( QgsLightSource *light = QgsLightSource::createFromXml( lightElement, context ) )
191 mLightSources << light;
192 }
193 }
194 else
195 {
196 // older project format
197 QDomElement elemPointLights = elem.firstChildElement( QStringLiteral( "point-lights" ) );
198 if ( !elemPointLights.isNull() )
199 {
200 QDomElement elemPointLight = elemPointLights.firstChildElement( QStringLiteral( "point-light" ) );
201 while ( !elemPointLight.isNull() )
202 {
203 auto pointLight = std::make_unique<QgsPointLightSettings>();
204 pointLight->readXml( elemPointLight, context );
205 mLightSources << pointLight.release();
206 elemPointLight = elemPointLight.nextSiblingElement( QStringLiteral( "point-light" ) );
207 }
208 }
209 else
210 {
211 // QGIS <= 3.4 did not have light configuration
212 auto defaultLight = std::make_unique<QgsPointLightSettings>();
213 defaultLight->setPosition( QgsVector3D( 0, 1000, 0 ) );
214 mLightSources << defaultLight.release();
215 }
216
217 QDomElement elemDirectionalLights = elem.firstChildElement( QStringLiteral( "directional-lights" ) );
218 if ( !elemDirectionalLights.isNull() )
219 {
220 QDomElement elemDirectionalLight = elemDirectionalLights.firstChildElement( QStringLiteral( "directional-light" ) );
221 while ( !elemDirectionalLight.isNull() )
222 {
223 auto directionalLight = std::make_unique<QgsDirectionalLightSettings>();
224 directionalLight->readXml( elemDirectionalLight, context );
225 mLightSources << directionalLight.release();
226 elemDirectionalLight = elemDirectionalLight.nextSiblingElement( QStringLiteral( "directional-light" ) );
227 }
228 }
229 }
230
231 QDomElement elemMapLayers = elemTerrain.firstChildElement( QStringLiteral( "layers" ) );
232 QDomElement elemMapLayer = elemMapLayers.firstChildElement( QStringLiteral( "layer" ) );
233 QList<QgsMapLayerRef> mapLayers;
234 while ( !elemMapLayer.isNull() )
235 {
236 mapLayers << QgsMapLayerRef( elemMapLayer.attribute( QStringLiteral( "id" ) ) );
237 elemMapLayer = elemMapLayer.nextSiblingElement( QStringLiteral( "layer" ) );
238 }
239 mLayers = mapLayers; // needs to resolve refs afterwards
240
241 QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( QStringLiteral( "generator" ) );
242 const QString terrainGenType = elemTerrainGenerator.attribute( QStringLiteral( "type" ) );
243 std::unique_ptr<QgsAbstractTerrainSettings> terrainSettings( Qgs3D::terrainRegistry()->createTerrainSettings( terrainGenType ) );
244 if ( terrainSettings )
245 {
246 terrainSettings->readXml( elemTerrain, context );
248 }
249
250 QDomElement elemSkybox = elem.firstChildElement( QStringLiteral( "skybox" ) );
251 mIsSkyboxEnabled = elemSkybox.attribute( QStringLiteral( "skybox-enabled" ) ).toInt();
252 mSkyboxSettings.readXml( elemSkybox, context );
253
254 QDomElement elemShadows = elem.firstChildElement( QStringLiteral( "shadow-rendering" ) );
255 mShadowSettings.readXml( elemShadows, context );
256
257 QDomElement elemAmbientOcclusion = elem.firstChildElement( QStringLiteral( "screen-space-ambient-occlusion" ) );
258 mAmbientOcclusionSettings.readXml( elemAmbientOcclusion, context );
259
260 QDomElement elemEyeDomeLighting = elem.firstChildElement( QStringLiteral( "eye-dome-lighting" ) );
261 mEyeDomeLightingEnabled = elemEyeDomeLighting.attribute( "enabled", QStringLiteral( "0" ) ).toInt();
262 mEyeDomeLightingStrength = elemEyeDomeLighting.attribute( "eye-dome-lighting-strength", QStringLiteral( "1000.0" ) ).toDouble();
263 mEyeDomeLightingDistance = elemEyeDomeLighting.attribute( "eye-dome-lighting-distance", QStringLiteral( "1" ) ).toInt();
264
265 QDomElement elemNavigationSync = elem.firstChildElement( QStringLiteral( "navigation-sync" ) );
266 mViewSyncMode = ( Qgis::ViewSyncModeFlags )( elemNavigationSync.attribute( QStringLiteral( "view-sync-mode" ), QStringLiteral( "0" ) ).toInt() );
267 mVisualizeViewFrustum = elemNavigationSync.attribute( QStringLiteral( "view-frustum-visualization-enabled" ), QStringLiteral( "0" ) ).toInt();
268
269 QDomElement elemDebugSettings = elem.firstChildElement( QStringLiteral( "debug-settings" ) );
270 mDebugShadowMapEnabled = elemDebugSettings.attribute( QStringLiteral( "shadowmap-enabled" ), QStringLiteral( "0" ) ).toInt();
271 mDebugShadowMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( QStringLiteral( "shadowmap-corner" ), "0" ).toInt() );
272 mDebugShadowMapSize = elemDebugSettings.attribute( QStringLiteral( "shadowmap-size" ), QStringLiteral( "0.2" ) ).toDouble();
273
274 mDebugDepthMapEnabled = elemDebugSettings.attribute( QStringLiteral( "depthmap-enabled" ), QStringLiteral( "0" ) ).toInt();
275 mDebugDepthMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( QStringLiteral( "depthmap-corner" ), QStringLiteral( "1" ) ).toInt() );
276 mDebugDepthMapSize = elemDebugSettings.attribute( QStringLiteral( "depthmap-size" ), QStringLiteral( "0.2" ) ).toDouble();
277
278 QDomElement elemDebug = elem.firstChildElement( QStringLiteral( "debug" ) );
279 mShowTerrainBoundingBoxes = elemDebug.attribute( QStringLiteral( "bounding-boxes" ), QStringLiteral( "0" ) ).toInt();
280 mShowTerrainTileInfo = elemDebug.attribute( QStringLiteral( "terrain-tile-info" ), QStringLiteral( "0" ) ).toInt();
281 mShowCameraViewCenter = elemDebug.attribute( QStringLiteral( "camera-view-center" ), QStringLiteral( "0" ) ).toInt();
282 mShowCameraRotationCenter = elemDebug.attribute( QStringLiteral( "camera-rotation-center" ), QStringLiteral( "0" ) ).toInt();
283 mShowLightSources = elemDebug.attribute( QStringLiteral( "show-light-sources" ), QStringLiteral( "0" ) ).toInt();
284 mIsFpsCounterEnabled = elemDebug.attribute( QStringLiteral( "show-fps-counter" ), QStringLiteral( "0" ) ).toInt();
285 mStopUpdates = elemDebug.attribute( QStringLiteral( "stop-updates" ), QStringLiteral( "0" ) ).toInt();
286 mShowDebugPanel = elemDebug.attribute( QStringLiteral( "debug-panel" ), QStringLiteral( "0" ) ).toInt();
287
288 QDomElement elemTemporalRange = elem.firstChildElement( QStringLiteral( "temporal-range" ) );
289 QDateTime start = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "start" ) ), Qt::ISODate );
290 QDateTime end = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "end" ) ), Qt::ISODate );
291 setTemporalRange( QgsDateTimeRange( start, end ) );
292
293 QDomElement elem3dAxis = elem.firstChildElement( QStringLiteral( "axis3d" ) );
294 m3dAxisSettings.readXml( elem3dAxis, context );
295}
296
297QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const
298{
300
301 QDomElement elem = doc.createElement( QStringLiteral( "qgis3d" ) );
302
303 QDomElement elemOrigin = doc.createElement( QStringLiteral( "origin" ) );
304 elemOrigin.setAttribute( QStringLiteral( "x" ), QString::number( mOrigin.x() ) );
305 elemOrigin.setAttribute( QStringLiteral( "y" ), QString::number( mOrigin.y() ) );
306 elemOrigin.setAttribute( QStringLiteral( "z" ), QString::number( mOrigin.z() ) );
307 elem.appendChild( elemOrigin );
308
309 QDomElement elemExtent = doc.createElement( QStringLiteral( "extent" ) );
310 elemExtent.setAttribute( QStringLiteral( "xMin" ), mExtent.xMinimum() );
311 elemExtent.setAttribute( QStringLiteral( "yMin" ), mExtent.yMinimum() );
312 elemExtent.setAttribute( QStringLiteral( "xMax" ), mExtent.xMaximum() );
313 elemExtent.setAttribute( QStringLiteral( "yMax" ), mExtent.yMaximum() );
314 elemExtent.setAttribute( QStringLiteral( "showIn2dView" ), mShowExtentIn2DView );
315 elem.appendChild( elemExtent );
316
317 QDomElement elemCamera = doc.createElement( QStringLiteral( "camera" ) );
318 elemCamera.setAttribute( QStringLiteral( "field-of-view" ), mFieldOfView );
319 elemCamera.setAttribute( QStringLiteral( "projection-type" ), static_cast<int>( mProjectionType ) );
320 switch ( mCameraNavigationMode )
321 {
323 elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "terrain-based-navigation" ) );
324 break;
326 elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "walk-navigation" ) );
327 break;
328 }
329 elemCamera.setAttribute( QStringLiteral( "camera-movement-speed" ), mCameraMovementSpeed );
330 elem.appendChild( elemCamera );
331
332 QDomElement elemColor = doc.createElement( QStringLiteral( "color" ) );
333 elemColor.setAttribute( QStringLiteral( "background" ), QgsColorUtils::colorToString( mBackgroundColor ) );
334 elemColor.setAttribute( QStringLiteral( "selection" ), QgsColorUtils::colorToString( mSelectionColor ) );
335 elem.appendChild( elemColor );
336
337 QDomElement elemCrs = doc.createElement( QStringLiteral( "crs" ) );
338 mCrs.writeXml( elemCrs, doc );
339 elem.appendChild( elemCrs );
340
341 QDomElement elemTerrain = doc.createElement( QStringLiteral( "terrain" ) );
342 elemTerrain.setAttribute( QStringLiteral( "terrain-rendering-enabled" ), mTerrainRenderingEnabled ? 1 : 0 );
343 elemTerrain.setAttribute( QStringLiteral( "shading-enabled" ), mTerrainShadingEnabled ? 1 : 0 );
344
345 QDomElement elemTerrainShadingMaterial = doc.createElement( QStringLiteral( "shading-material" ) );
346 mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial, context );
347 elemTerrain.appendChild( elemTerrainShadingMaterial );
348 elemTerrain.setAttribute( QStringLiteral( "map-theme" ), mTerrainMapTheme );
349 elemTerrain.setAttribute( QStringLiteral( "show-labels" ), mShowLabels ? 1 : 0 );
350
351 {
352 QDomElement elemLights = doc.createElement( QStringLiteral( "lights" ) );
353 for ( const QgsLightSource *light : mLightSources )
354 {
355 const QDomElement elemLight = light->writeXml( doc, context );
356 elemLights.appendChild( elemLight );
357 }
358 elem.appendChild( elemLights );
359 }
360
361 QDomElement elemMapLayers = doc.createElement( QStringLiteral( "layers" ) );
362 for ( const QgsMapLayerRef &layerRef : mLayers )
363 {
364 QDomElement elemMapLayer = doc.createElement( QStringLiteral( "layer" ) );
365 elemMapLayer.setAttribute( QStringLiteral( "id" ), layerRef.layerId );
366 elemMapLayers.appendChild( elemMapLayer );
367 }
368 elemTerrain.appendChild( elemMapLayers );
369
370 QDomElement elemTerrainGenerator = doc.createElement( QStringLiteral( "generator" ) );
371 elemTerrainGenerator.setAttribute( QStringLiteral( "type" ), mTerrainSettings->type() );
372 mTerrainSettings->writeXml( elemTerrain, context );
373 elemTerrain.appendChild( elemTerrainGenerator );
374 elem.appendChild( elemTerrain );
375
376 QDomElement elemSkybox = doc.createElement( QStringLiteral( "skybox" ) );
377 elemSkybox.setAttribute( QStringLiteral( "skybox-enabled" ), mIsSkyboxEnabled );
378 mSkyboxSettings.writeXml( elemSkybox, context );
379 elem.appendChild( elemSkybox );
380
381 QDomElement elemShadows = doc.createElement( QStringLiteral( "shadow-rendering" ) );
382 mShadowSettings.writeXml( elemShadows, context );
383 elem.appendChild( elemShadows );
384
385 QDomElement elemAmbientOcclusion = doc.createElement( QStringLiteral( "screen-space-ambient-occlusion" ) );
386 mAmbientOcclusionSettings.writeXml( elemAmbientOcclusion, context );
387 elem.appendChild( elemAmbientOcclusion );
388
389 QDomElement elemDebug = doc.createElement( QStringLiteral( "debug" ) );
390 elemDebug.setAttribute( QStringLiteral( "bounding-boxes" ), mShowTerrainBoundingBoxes ? 1 : 0 );
391 elemDebug.setAttribute( QStringLiteral( "terrain-tile-info" ), mShowTerrainTileInfo ? 1 : 0 );
392 elemDebug.setAttribute( QStringLiteral( "camera-view-center" ), mShowCameraViewCenter ? 1 : 0 );
393 elemDebug.setAttribute( QStringLiteral( "camera-rotation-center" ), mShowCameraRotationCenter ? 1 : 0 );
394 elemDebug.setAttribute( QStringLiteral( "show-light-sources" ), mShowLightSources ? 1 : 0 );
395 elemDebug.setAttribute( QStringLiteral( "show-fps-counter" ), mIsFpsCounterEnabled ? 1 : 0 );
396 elemDebug.setAttribute( QStringLiteral( "stop-updates" ), mStopUpdates ? 1 : 0 );
397 elemDebug.setAttribute( QStringLiteral( "debug-panel" ), mShowDebugPanel ? 1 : 0 );
398 elem.appendChild( elemDebug );
399
400 QDomElement elemEyeDomeLighting = doc.createElement( QStringLiteral( "eye-dome-lighting" ) );
401 elemEyeDomeLighting.setAttribute( QStringLiteral( "enabled" ), mEyeDomeLightingEnabled ? 1 : 0 );
402 elemEyeDomeLighting.setAttribute( QStringLiteral( "eye-dome-lighting-strength" ), mEyeDomeLightingStrength );
403 elemEyeDomeLighting.setAttribute( QStringLiteral( "eye-dome-lighting-distance" ), mEyeDomeLightingDistance );
404 elem.appendChild( elemEyeDomeLighting );
405
406 QDomElement elemNavigationSync = doc.createElement( QStringLiteral( "navigation-sync" ) );
407 elemNavigationSync.setAttribute( QStringLiteral( "view-sync-mode" ), ( int ) mViewSyncMode );
408 elemNavigationSync.setAttribute( QStringLiteral( "view-frustum-visualization-enabled" ), mVisualizeViewFrustum ? 1 : 0 );
409 elem.appendChild( elemNavigationSync );
410
411 QDomElement elemDebugSettings = doc.createElement( QStringLiteral( "debug-settings" ) );
412 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-enabled" ), mDebugShadowMapEnabled );
413 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-corner" ), mDebugShadowMapCorner );
414 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-size" ), mDebugShadowMapSize );
415 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-enabled" ), mDebugDepthMapEnabled );
416 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-corner" ), mDebugDepthMapCorner );
417 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-size" ), mDebugDepthMapSize );
418 elem.appendChild( elemDebugSettings );
419
420 QDomElement elemTemporalRange = doc.createElement( QStringLiteral( "temporal-range" ) );
421 elemTemporalRange.setAttribute( QStringLiteral( "start" ), temporalRange().begin().toString( Qt::ISODate ) );
422 elemTemporalRange.setAttribute( QStringLiteral( "end" ), temporalRange().end().toString( Qt::ISODate ) );
423
424 QDomElement elem3dAxis = doc.createElement( QStringLiteral( "axis3d" ) );
425 m3dAxisSettings.writeXml( elem3dAxis, context );
426 elem.appendChild( elem3dAxis );
427
428 return elem;
429}
430
432{
434
435 for ( int i = 0; i < mLayers.count(); ++i )
436 {
437 QgsMapLayerRef &layerRef = mLayers[i];
438 layerRef.setLayer( project.mapLayer( layerRef.layerId ) );
439 }
440
441 if ( mTerrainSettings )
442 {
443 mTerrainSettings->resolveReferences( &project );
444
445 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
446 if ( terrainGenerator )
447 {
449 }
451 }
452}
453
460
462{
464
465 if ( extent == mExtent )
466 return;
467
468 mExtent = extent;
469 const QgsPointXY center = mExtent.center();
470 setOrigin( QgsVector3D( center.x(), center.y(), 0 ) );
471 if ( mTerrainGenerator )
472 {
473 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, mTerrainGenerator->crs(), mTransformContext );
474 mTerrainGenerator->setExtent( terrainExtent );
475 }
476 emit extentChanged();
477}
478
480{
482
483 if ( origin == mOrigin )
484 return;
485
486 mOrigin = origin;
487 emit originChanged();
488}
489
491{
493
494 return mOrigin;
495}
496
503
510
517
524
531
533{
535
536 mTransformContext = context;
537}
538
540{
542
543 return mPathResolver;
544}
545
547{
549
550 mPathResolver = resolver;
551}
552
559
561{
563
564 mMapThemes = mapThemes;
565}
566
567void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
568{
570
571 if ( color == mBackgroundColor )
572 return;
573
574 mBackgroundColor = color;
576}
577
579{
581
582 return mBackgroundColor;
583}
584
585void Qgs3DMapSettings::setSelectionColor( const QColor &color )
586{
588
589 if ( color == mSelectionColor )
590 return;
591
592 mSelectionColor = color;
594}
595
597{
599
600 return mSelectionColor;
601}
602
604{
606
607 if ( zScale == mTerrainSettings->verticalScale() )
608 return;
609
610 mTerrainSettings->setVerticalScale( zScale );
615}
616
618{
620
621 return mTerrainSettings->verticalScale();
622}
623
624void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
625{
627
628 const QList<QgsMapLayer *> raw = _qgis_listRefToRaw( mLayers );
629
630 if ( layers == raw )
631 return;
632
633 mLayers = _qgis_listRawToRef( layers );
634 emit layersChanged();
635}
636
637QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
638{
640
641 QList<QgsMapLayer *> lst;
642 lst.reserve( mLayers.count() );
643 for ( const QgsMapLayerRef &layerRef : mLayers )
644 {
645 if ( layerRef.layer )
646 lst.append( layerRef.layer );
647 }
648 return lst;
649}
650
652{
654
655 setExtent( fullExtent );
656
657 std::unique_ptr<QgsAbstractTerrainSettings> terrainSettings( Qgs3D::terrainRegistry()->configureTerrainFromProject( properties ) );
658 if ( terrainSettings )
659 {
661 }
662}
663
665{
667
668 return mTerrainSettings.get();
669}
670
672{
674
675 bool hasChanged = false;
676 if ( settings == mTerrainSettings.get() )
677 {
678 // emit signals anyway. We don't know if the caller changed settings on the pointer before calling this..
679 hasChanged = true;
680 }
681 else
682 {
683 // ensure to generate the terrain if the settings have changed or if the terrain has never been generated.
684 hasChanged = !settings->equals( mTerrainSettings.get() ) || !mTerrainGenerator;
685 mTerrainSettings.reset( settings );
686 }
687
688 if ( hasChanged )
689 {
690 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
691 if ( terrainGenerator )
692 {
694 }
695
696 // emit all the signals, we don't know exactly what's changed
701 emit terrainElevationOffsetChanged( mTerrainSettings->elevationOffset() );
704
706 }
707}
708
710{
712
713 if ( mTerrainSettings->mapTileResolution() == res )
714 return;
715
716 mTerrainSettings->setMapTileResolution( res );
721}
722
724{
726
727 return mTerrainSettings->mapTileResolution();
728}
729
731{
733
734 if ( mTerrainSettings->maximumScreenError() == error )
735 return;
736
737 mTerrainSettings->setMaximumScreenError( error );
742}
743
745{
747
748 return mTerrainSettings->maximumScreenError();
749}
750
752{
754
755 if ( mTerrainSettings->maximumGroundError() == error )
756 return;
757
758 mTerrainSettings->setMaximumGroundError( error );
762
764}
765
767{
769
770 if ( mTerrainSettings->elevationOffset() == offset )
771 return;
772 mTerrainSettings->setElevationOffset( offset );
774 emit terrainElevationOffsetChanged( offset );
777}
778
780{
782
783 return mTerrainSettings->elevationOffset();
784}
785
787{
789
790 return mTerrainSettings->maximumGroundError();
791}
792
794{
796
797 if ( mTerrainGenerator )
798 {
799 disconnect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
800 }
801
802 if ( gen->crs().isValid() ) // Don't bother setting an extent rect in the wrong CRS
803 {
804 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, gen->crs(), mTransformContext );
805 gen->setExtent( terrainExtent );
806 }
807 mTerrainGenerator.reset( gen );
808 connect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
809
811}
812
814{
816
817 return mTerrainGenerator.get();
818}
819
821{
823
824 if ( mTerrainShadingEnabled == enabled )
825 return;
826
827 mTerrainShadingEnabled = enabled;
829}
830
832{
834
835 return mTerrainShadingEnabled;
836}
837
839{
841
842 if ( mTerrainShadingMaterial == material )
843 return;
844
845 mTerrainShadingMaterial = material;
847}
848
855
856void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
857{
859
860 if ( mTerrainMapTheme == theme )
861 return;
862
863 mTerrainMapTheme = theme;
865}
866
868{
870
871 return mTerrainMapTheme;
872}
873
875{
877
878 if ( mShowTerrainBoundingBoxes == enabled )
879 return;
880
881 mShowTerrainBoundingBoxes = enabled;
883}
884
886{
888
889 return mShowTerrainBoundingBoxes;
890}
891
892
894{
896
897 if ( mShowTerrainTileInfo == enabled )
898 return;
899
900 mShowTerrainTileInfo = enabled;
902}
903
905{
907
908 return mShowTerrainTileInfo;
909}
910
912{
914
915 if ( mShowCameraViewCenter == enabled )
916 return;
917
918 mShowCameraViewCenter = enabled;
920}
921
923{
925
926 return mShowCameraViewCenter;
927}
928
930{
932
933 if ( mShowCameraRotationCenter == enabled )
934 return;
935
936 mShowCameraRotationCenter = enabled;
938}
939
941{
943
944 return mShowCameraRotationCenter;
945}
946
948{
950
951 if ( mShowLightSources == enabled )
952 return;
953
954 mShowLightSources = enabled;
956}
957
959{
961
962 return mShowLightSources;
963}
964
966{
968
969 if ( mShowLabels == enabled )
970 return;
971
972 mShowLabels = enabled;
973 emit showLabelsChanged();
974}
975
977{
979
980 return mShowLabels;
981}
982
984{
986
987 if ( mStopUpdates == enabled )
988 return;
989
990 mStopUpdates = enabled;
991 emit stopUpdatesChanged();
992}
993
995{
997
998 return mStopUpdates;
999}
1000
1002{
1004
1005 if ( mEyeDomeLightingEnabled == enabled )
1006 return;
1007 mEyeDomeLightingEnabled = enabled;
1009}
1010
1012{
1014
1015 return mEyeDomeLightingEnabled;
1016}
1017
1019{
1021
1022 if ( mEyeDomeLightingStrength == strength )
1023 return;
1024 mEyeDomeLightingStrength = strength;
1026}
1027
1029{
1031
1032 return mEyeDomeLightingStrength;
1033}
1034
1036{
1038
1039 if ( mEyeDomeLightingDistance == distance )
1040 return;
1041 mEyeDomeLightingDistance = distance;
1043}
1044
1046{
1048
1049 return mEyeDomeLightingDistance;
1050}
1051
1052QList<QgsLightSource *> Qgs3DMapSettings::lightSources() const
1053{
1055
1056 return mLightSources;
1057}
1058
1059void Qgs3DMapSettings::setLightSources( const QList<QgsLightSource *> &lights )
1060{
1062
1063 // have lights actually changed?
1064 if ( mLightSources.count() == lights.count() )
1065 {
1066 bool same = true;
1067 for ( int i = 0; i < mLightSources.count(); ++i )
1068 {
1069 if ( mLightSources[i]->type() == lights[i]->type() )
1070 {
1071 switch ( mLightSources[i]->type() )
1072 {
1074 if ( *static_cast<QgsPointLightSettings *>( mLightSources[i] ) == *static_cast<QgsPointLightSettings *>( lights[i] ) )
1075 continue;
1076 break;
1078 if ( *static_cast<QgsDirectionalLightSettings *>( mLightSources[i] ) == *static_cast<QgsDirectionalLightSettings *>( lights[i] ) )
1079 continue;
1080 break;
1081 }
1082 }
1083 same = false;
1084 break;
1085 }
1086 if ( same )
1087 {
1088 qDeleteAll( lights );
1089 return;
1090 }
1091 }
1092
1093 qDeleteAll( mLightSources );
1094 mLightSources = lights;
1095
1097 emit pointLightsChanged();
1098 emit lightSourcesChanged();
1099}
1100
1102{
1104
1105 return mFieldOfView;
1106}
1107
1108void Qgs3DMapSettings::setFieldOfView( const float fieldOfView )
1109{
1111
1112 if ( mFieldOfView == fieldOfView )
1113 return;
1114
1115 mFieldOfView = fieldOfView;
1116 emit fieldOfViewChanged();
1117}
1118
1119Qt3DRender::QCameraLens::ProjectionType Qgs3DMapSettings::projectionType() const
1120{
1122
1123 return mProjectionType;
1124}
1125
1126void Qgs3DMapSettings::setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType )
1127{
1129
1130 if ( mProjectionType == projectionType )
1131 return;
1132
1133 mProjectionType = projectionType;
1134 emit projectionTypeChanged();
1135}
1136
1138{
1140
1141 return mCameraNavigationMode;
1142}
1143
1145{
1147
1148 if ( mCameraNavigationMode == navigationMode )
1149 return;
1150
1151 mCameraNavigationMode = navigationMode;
1153}
1154
1156{
1158
1159 return mCameraMovementSpeed;
1160}
1161
1163{
1165
1166 if ( mCameraMovementSpeed == movementSpeed )
1167 return;
1168
1169 mCameraMovementSpeed = movementSpeed;
1171}
1172
1173void Qgs3DMapSettings::setOutputDpi( const double dpi )
1174{
1176
1177 mDpi = dpi;
1178}
1179
1181{
1183
1184 return mDpi;
1185}
1186
1188{
1190
1191 return mSkyboxSettings;
1192}
1193
1195{
1197
1198 return mShadowSettings;
1199}
1200
1202{
1204
1205 return mAmbientOcclusionSettings;
1206}
1207
1209{
1211
1212 mSkyboxSettings = skyboxSettings;
1213 emit skyboxSettingsChanged();
1214}
1215
1217{
1219
1220 mShadowSettings = shadowSettings;
1221 emit shadowSettingsChanged();
1222}
1223
1225{
1227
1228 mAmbientOcclusionSettings = ambientOcclusionSettings;
1230}
1231
1233{
1235
1236 return mIsSkyboxEnabled;
1237}
1238
1240{
1242
1243 mIsSkyboxEnabled = enabled;
1244}
1245
1247{
1249
1250 return mIsFpsCounterEnabled;
1251}
1252
1253void Qgs3DMapSettings::setShowDebugPanel( const bool enabled )
1254{
1256
1257 if ( mShowDebugPanel == enabled )
1258 return;
1259
1260 mShowDebugPanel = enabled;
1261 emit showDebugPanelChanged( enabled );
1262}
1263
1265{
1267
1268 return mShowDebugPanel;
1269}
1270
1271void Qgs3DMapSettings::setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size )
1272{
1274
1275 mDebugShadowMapEnabled = enabled;
1276 mDebugShadowMapCorner = corner;
1277 mDebugShadowMapSize = size;
1279}
1280
1282{
1284
1285 return mDebugShadowMapEnabled;
1286}
1287
1289{
1291
1292 return mDebugShadowMapCorner;
1293}
1294
1296{
1298
1299 return mDebugShadowMapSize;
1300}
1301
1302void Qgs3DMapSettings::setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size )
1303{
1305
1306 mDebugDepthMapEnabled = enabled;
1307 mDebugDepthMapCorner = corner;
1308 mDebugDepthMapSize = size;
1310}
1311
1313{
1315
1316 return mDebugDepthMapEnabled;
1317}
1318
1320{
1322
1323 return mDebugDepthMapCorner;
1324}
1325
1327{
1329
1330 return mDebugDepthMapSize;
1331}
1332
1333void Qgs3DMapSettings::setIsFpsCounterEnabled( bool fpsCounterEnabled )
1334{
1336
1337 if ( fpsCounterEnabled == mIsFpsCounterEnabled )
1338 return;
1339 mIsFpsCounterEnabled = fpsCounterEnabled;
1340 emit fpsCounterEnabledChanged( mIsFpsCounterEnabled );
1341}
1342
1344{
1346
1347 return mTerrainRenderingEnabled;
1348}
1349
1350void Qgs3DMapSettings::setTerrainRenderingEnabled( bool terrainRenderingEnabled )
1351{
1353
1354 if ( terrainRenderingEnabled == mTerrainRenderingEnabled )
1355 return;
1356 mTerrainRenderingEnabled = terrainRenderingEnabled;
1358}
1359
1361{
1363
1364 return mRendererUsage;
1365}
1366
1368{
1370
1371 mRendererUsage = rendererUsage;
1372}
1373
1380
1382{
1384
1385 mViewSyncMode = mode;
1386}
1387
1389{
1391
1392 return mVisualizeViewFrustum;
1393}
1394
1396{
1398
1399 if ( mVisualizeViewFrustum != enabled )
1400 {
1401 mVisualizeViewFrustum = enabled;
1403 }
1404}
1405
1407{
1409
1410 return m3dAxisSettings;
1411}
1412
1413void Qgs3DMapSettings::setIsDebugOverlayEnabled( bool debugOverlayEnabled )
1414{
1416
1417 if ( debugOverlayEnabled == mIsDebugOverlayEnabled )
1418 return;
1419
1420 mIsDebugOverlayEnabled = debugOverlayEnabled;
1421 emit debugOverlayEnabledChanged( mIsDebugOverlayEnabled );
1422}
1423
1425{
1427
1428 return mShowExtentIn2DView;
1429}
1430
1431void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
1432{
1434
1466}
1467
1468
1469void Qgs3DMapSettings::set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force )
1470{
1472
1473 if ( axisSettings == m3dAxisSettings )
1474 {
1475 if ( force )
1476 {
1477 // ie. refresh. We need to disconnect and to reconnect to avoid 'dirty' project
1479 emit axisSettingsChanged();
1481 }
1482 }
1483 else
1484 {
1485 m3dAxisSettings = axisSettings;
1486 emit axisSettingsChanged();
1487 }
1488}
1489
1491{
1493
1494 return mIsDebugOverlayEnabled;
1495}
1496
1498{
1500
1501 if ( show == mShowExtentIn2DView )
1502 return;
1503
1504 mShowExtentIn2DView = show;
1506}
QFlags< ViewSyncModeFlag > ViewSyncModeFlags
Definition qgis.h:3316
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:3955
@ TerrainBased
The default navigation based on the terrain.
@ Walk
Uses WASD keys or arrows to navigate in walking (first person) manner.
RendererUsage
Usage of the renderer.
Definition qgis.h:3279
@ Point
Point light source.
@ Directional
Directional light source.
Contains the configuration of a 3d axis.
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.
void extentChanged()
Emitted when the 3d view's 2d extent has changed.
void setEyeDomeLightingStrength(double strength)
Sets the eye dome lighting strength value.
bool isDebugOverlayEnabled() const
Returns whether debug overlay is enabled.
Qt::Corner debugDepthMapCorner() const
Returns the corner where the shadow map preview is displayed.
void originChanged()
Emitted when the world's origin point has been shifted.
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which stores various information regarding which datum transfo...
void settingsChanged()
Emitted when one of the configuration settings has changed.
void renderersChanged()
Emitted when the list of map's extra renderers have been modified.
void eyeDomeLightingDistanceChanged()
Emitted when the eye dome lighting distance has changed.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads configuration from a DOM element previously written by writeXml()
void terrainShadingChanged()
Emitted when terrain shading enabled flag or terrain shading material has changed.
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
void setAmbientOcclusionSettings(const QgsAmbientOcclusionSettings &ambientOcclusionSettings)
Sets the current configuration of screen space ambient occlusion.
void setShowTerrainTilesInfo(bool enabled)
Sets whether to display extra tile info on top of terrain tiles (for debugging)
QgsVector3D mapToWorldCoordinates(const QgsVector3D &mapCoords) const
Converts map coordinates to 3D world coordinates (applies offset and turns (x,y,z) into (x,...
bool showExtentIn2DView() const
Returns whether the extent is displayed on the main 2D map canvas.
double cameraMovementSpeed() const
Returns the camera movement speed.
Qt3DRender::QCameraLens::ProjectionType projectionType() const
Returns the camera lens' projection type.
void setEyeDomeLightingEnabled(bool enabled)
Sets whether eye dome lighting will be used.
void showDebugPanelChanged(bool shown)
Emitted when the Show debug panel checkbox changes value.
bool debugDepthMapEnabled() const
Returns whether the shadow map debugging is enabled.
bool isSkyboxEnabled() const
Returns whether the skybox is enabled.
void setFieldOfView(const float fieldOfView)
Sets the camera lens' field of view.
void debugDepthMapSettingsChanged()
Emitted when depth map debugging has changed.
Q_DECL_DEPRECATED double terrainElevationOffset() const
Returns the elevation offset of the terrain (used to move the terrain up or down)
void setLightSources(const QList< QgsLightSource * > &lights)
Sets the list of light sources defined in the scene.
double outputDpi() const
Returns DPI used for conversion between real world units (e.g.
Qgis::NavigationMode cameraNavigationMode() const
Returns the navigation mode used by the camera.
double eyeDomeLightingStrength() const
Returns the eye dome lighting strength value.
void backgroundColorChanged()
Emitted when the background color has changed.
void showTerrainBoundingBoxesChanged()
Emitted when the flag whether terrain's bounding boxes are shown has changed.
Q_DECL_DEPRECATED void setMaxTerrainGroundError(double error)
Sets the maximum ground error of terrain tiles in world units.
Q_DECL_DEPRECATED void terrainElevationOffsetChanged(double newElevation)
Emitted when the terrain elevation offset is changed.
Qt::Corner debugShadowMapCorner() const
Returns the corner where the shadow map preview is displayed.
void setMapThemeCollection(QgsMapThemeCollection *mapThemes)
Sets pointer to the collection of map themes.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a DOM element, to be used later with readXml()
void setDebugDepthMapSettings(bool enabled, Qt::Corner corner, double size)
Sets the debugging settings of the depth map.
bool showCameraViewCenter() const
Returns whether to show camera's view center as a sphere (for debugging)
void showCameraRotationCenterChanged()
Emitted when the flag whether camera's rotation center is shown has changed.
QColor selectionColor() const
Returns color used for selected features.
void directionalLightsChanged()
Emitted when the list of directional lights changes.
void setTerrainShadingMaterial(const QgsPhongMaterialSettings &material)
Sets terrain shading material.
const QgsAbstractTerrainSettings * terrainSettings() const
Returns the terrain settings.
Q_DECL_DEPRECATED void maxTerrainScreenErrorChanged()
Emitted when the maximum terrain screen error has changed.
void cameraNavigationModeChanged()
Emitted when the camera navigation mode was changed.
void shadowSettingsChanged()
Emitted when shadow rendering settings are changed.
bool stopUpdates() const
Returns whether the scene updates on camera movement.
void setViewFrustumVisualizationEnabled(bool enabled)
Sets whether the camera's view frustum is visualized on the 2D map canvas.
void setShowCameraRotationCenter(bool enabled)
Sets whether to show camera's rotation center as a sphere (for debugging)
void setExtent(const QgsRectangle &extent)
Sets the 3D scene's 2D extent in the 3D scene's CRS, while also setting the scene's origin to the ext...
void eyeDomeLightingEnabledChanged()
Emitted when the flag whether eye dome lighting is used has changed.
Q_DECL_DEPRECATED void setTerrainVerticalScale(double zScale)
Sets vertical scale (exaggeration) of terrain (1 = true scale, > 1 = hills get more pronounced)
void debugOverlayEnabledChanged(bool debugOverlayEnabled)
Emitted when the debug overaly is enabled or disabled.
void setOutputDpi(const double dpi)
Sets DPI used for conversion between real world units (e.g.
void setIsSkyboxEnabled(bool enabled)
Sets whether the skybox is enabled.
void setShowLabels(bool enabled)
Sets whether to display labels on terrain tiles.
Q_DECL_DEPRECATED double terrainVerticalScale() const
Returns vertical scale (exaggeration) of terrain.
void setViewSyncMode(Qgis::ViewSyncModeFlags mode)
Sets the view sync mode (used to synchronize the 2D main map canvas and the 3D camera navigation)
void setOrigin(const QgsVector3D &origin)
Sets coordinates in map CRS at which our 3D world has origin (0,0,0)
void setSkyboxSettings(const QgsSkyboxSettings &skyboxSettings)
Sets the current configuration of the skybox.
void skyboxSettingsChanged()
Emitted when skybox settings are changed.
Q_DECL_DEPRECATED void setMapTileResolution(int res)
Sets resolution (in pixels) of the texture of a terrain tile.
void setLayers(const QList< QgsMapLayer * > &layers)
Sets the list of 3D map layers to be rendered in the scene.
void setShowDebugPanel(bool enabled)
Sets whether the debug side panel is shown.
QgsShadowSettings shadowSettings() const
Returns the current configuration of shadows.
void terrainMapThemeChanged()
Emitted when terrain's map theme has changed.
void setShadowSettings(const QgsShadowSettings &shadowSettings)
Sets the current configuration of shadow rendering.
void setIsDebugOverlayEnabled(bool debugOverlayEnabled)
Sets whether debug overlay is enabled The debug overlay displays some debugging and profiling informa...
void pointLightsChanged()
Emitted when the list of point lights changes.
QList< QgsLightSource * > lightSources() const
Returns list of directional light sources defined in the scene.
double debugDepthMapSize() const
Returns the size of the shadow map preview.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets coordinate reference system used in the 3D scene.
Q_DECL_DEPRECATED double maxTerrainScreenError() const
Returns maximum allowed screen error of terrain tiles in pixels.
Qgs3DAxisSettings get3DAxisSettings() const
Returns the current configuration of 3d axis.
void setEyeDomeLightingDistance(int distance)
Sets the eye dome lighting distance value (contributes to the contrast of the image.
Q_DECL_DEPRECATED void maxTerrainGroundErrorChanged()
Emitted when the maximum terrain ground error has changed.
bool viewFrustumVisualizationEnabled() const
Returns whether the camera's view frustum is visualized on the 2D map canvas.
void setShowLightSourceOrigins(bool enabled)
Sets whether to show light source origins as a sphere (for debugging)
bool showDebugPanel() const
Returns whether the debug side panel is shown.
void setShowExtentIn2DView(bool show)
Sets whether the extent is displayed on the main 2D map canvas.
void projectionTypeChanged()
Emitted when the camera lens projection type changes.
float fieldOfView() const
Returns the camera lens' field of view.
void selectionColorChanged()
Emitted when the selection color has changed.
QgsAmbientOcclusionSettings ambientOcclusionSettings() const
Returns the current configuration of screen space ambient occlusion.
QgsRectangle extent() const
Returns the 3D scene's 2D extent in the 3D scene's CRS.
void setTerrainShadingEnabled(bool enabled)
Sets whether terrain shading is enabled.
Qgis::ViewSyncModeFlags viewSyncMode() const
Returns the view sync mode (used to synchronize the 2D main map canvas and the 3D camera navigation)
Q_DECL_DEPRECATED void mapTileResolutionChanged()
Emitted when the map tile resoulution has changed.
void stopUpdatesChanged()
Emitted when the flag whether to keep updating scene has changed.
void setDebugShadowMapSettings(bool enabled, Qt::Corner corner, double size)
Sets the debugging settings of the shadow map.
int eyeDomeLightingDistance() const
Returns the eye dome lighting distance value (contributes to the contrast of the image)
void setSelectionColor(const QColor &color)
Sets color used for selected features.
void lightSourcesChanged()
Emitted when any of the light source settings in the map changes.
void showLightSourceOriginsChanged()
Emitted when the flag whether light source origins are shown has changed.
QgsTerrainGenerator * terrainGenerator() const
Returns the terrain generator.
void setCameraNavigationMode(Qgis::NavigationMode navigationMode)
Sets the navigation mode for the camera.
QColor backgroundColor() const
Returns background color of the 3D map view.
void terrainSettingsChanged()
Emitted when the terrain settings are changed.
void resolveReferences(const QgsProject &project)
Resolves references to other objects (map layers) after the call to readXml()
double debugShadowMapSize() const
Returns the size of the shadow map preview.
void setPathResolver(const QgsPathResolver &resolver)
Sets the path resolver for conversion between relative and absolute paths during rendering operations...
QgsVector3D worldToMapCoordinates(const QgsVector3D &worldCoords) const
Converts 3D world coordinates to map coordinates (applies offset and turns (x,y,z) into (x,...
bool showTerrainBoundingBoxes() const
Returns whether to display bounding boxes of terrain tiles (for debugging)
void showLabelsChanged()
Emitted when the flag whether labels are displayed on terrain tiles has changed.
void setStopUpdates(bool enabled)
Sets whether scene updates on camera movement should be enabled.
void setShowCameraViewCenter(bool enabled)
Sets whether to show camera's view center as a sphere (for debugging)
Q_DECL_DEPRECATED int mapTileResolution() const
Returns resolution (in pixels) of the texture of a terrain tile.
bool showLabels() const
Returns whether to display labels on terrain tiles.
void setTerrainSettings(QgsAbstractTerrainSettings *settings)
Sets the terrain settings.
void set3DAxisSettings(const Qgs3DAxisSettings &axisSettings, bool force=false)
Sets the current configuration of 3d axis.
void setCameraMovementSpeed(double movementSpeed)
Sets the camera movement speed.
void setTerrainRenderingEnabled(bool terrainRenderingEnabled)
Sets whether the 2D terrain surface will be rendered in.
bool debugShadowMapEnabled() const
Returns whether the shadow map debugging is enabled.
Q_DECL_DEPRECATED void setMaxTerrainScreenError(double error)
Sets maximum allowed screen error of terrain tiles in pixels.
void setBackgroundColor(const QColor &color)
Sets background color of the 3D map view.
bool terrainRenderingEnabled() const
Returns whether the 2D terrain surface will be rendered.
void fpsCounterEnabledChanged(bool fpsCounterEnabled)
Emitted when the FPS counter is enabled or disabled.
void axisSettingsChanged()
Emitted when 3d axis rendering settings are changed.
void viewFrustumVisualizationEnabledChanged()
Emitted when the camera's view frustum visualization on the main 2D map canvas is enabled or disabled...
void setProjectionType(const Qt3DRender::QCameraLens::ProjectionType projectionType)
Sets the camera lens' projection type.
void ambientOcclusionSettingsChanged()
Emitted when ambient occlusion rendering settings are changed.
bool showTerrainTilesInfo() const
Returns whether to display extra tile info on top of terrain tiles (for debugging)
void showExtentIn2DViewChanged()
Emitted when the parameter to display 3d view's extent in the 2D canvas has changed.
void configureTerrainFromProject(QgsProjectElevationProperties *properties, const QgsRectangle &fullExtent)
Configures the map's terrain settings directly from a project's elevation properties.
void layersChanged()
Emitted when the list of map layers for 3d rendering has changed.
void showTerrainTilesInfoChanged()
Emitted when the flag whether terrain's tile info is shown has changed.
void eyeDomeLightingStrengthChanged()
Emitted when the eye dome lighting strength has changed.
QgsSkyboxSettings skyboxSettings() const
Returns the current configuration of the skybox.
Q_DECL_DEPRECATED double maxTerrainGroundError() const
Returns maximum ground error of terrain tiles in world units.
bool isTerrainShadingEnabled() const
Returns whether terrain shading is enabled.
void cameraMovementSpeedChanged()
Emitted when the camera movement speed was changed.
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used in the 3D scene.
bool eyeDomeLightingEnabled() const
Returns whether eye dome lighting is used.
QgsPhongMaterialSettings terrainShadingMaterial() const
Returns terrain shading material.
void setRendererUsage(Qgis::RendererUsage rendererUsage)
Sets the renderer usage.
bool isFpsCounterEnabled() const
Returns whether FPS counter label is enabled.
QString terrainMapTheme() const
Returns name of the map theme (from the active project) that will be used for terrain's texture.
void setShowTerrainBoundingBoxes(bool enabled)
Sets whether to display bounding boxes of terrain tiles (for debugging)
void fieldOfViewChanged()
Emitted when the camera lens field of view changes.
Qgis::RendererUsage rendererUsage() const
Returns the renderer usage.
void setIsFpsCounterEnabled(bool fpsCounterEnabled)
Sets whether FPS counter label is enabled.
QgsMapThemeCollection * mapThemeCollection() const
Returns pointer to the collection of map themes.
QList< QgsMapLayer * > layers() const
Returns the list of 3D map layers to be rendered in the scene.
void setTerrainMapTheme(const QString &theme)
Sets name of the map theme.
Q_DECL_DEPRECATED void setTerrainElevationOffset(double offset)
Sets the terrain elevation offset (used to move the terrain up or down)
Q_DECL_DEPRECATED void terrainVerticalScaleChanged()
Emitted when the vertical scale of the terrain has changed.
void terrainGeneratorChanged()
Emitted when the terrain generator has changed.
bool showLightSourceOrigins() const
Returns whether to show light source origins as a sphere (for debugging)
void setTerrainGenerator(QgsTerrainGenerator *gen)
Sets terrain generator and sets extent() as the generator's extent.
void debugShadowMapSettingsChanged()
Emitted when shadow map debugging has changed.
void showCameraViewCenterChanged()
Emitted when the flag whether camera's view center is shown has changed.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
QgsVector3D origin() const
Returns coordinates in map CRS at which 3D scene has origin (0,0,0).
bool showCameraRotationCenter() const
Returns whether to show camera's rotation center as a sphere (for debugging)
static Qgs3DRenderContext fromMapSettings(const Qgs3DMapSettings *mapSettings)
Creates an initialized Qgs3DRenderContext instance from given Qgs3DMapSettings.
static QgsRectangle tryReprojectExtent2D(const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs1, const QgsCoordinateReferenceSystem &crs2, const QgsCoordinateTransformContext &context)
Reprojects extent from crs1 to crs2 coordinate reference system with context context.
static QgsVector3D worldToMapCoordinates(const QgsVector3D &worldCoords, const QgsVector3D &origin)
Converts 3D world coordinates to map coordinates (applies offset)
static QgsVector3D mapToWorldCoordinates(const QgsVector3D &mapCoords, const QgsVector3D &origin)
Converts map coordinates to 3D world coordinates (applies offset)
static Qgs3DTerrainRegistry * terrainRegistry()
Returns the terrain registry, used for managing 3D terrains.
Definition qgs3d.cpp:93
virtual void readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads settings from a DOM element.
virtual bool equals(const QgsAbstractTerrainSettings *other) const =0
Returns true if this settings is exactly equal to another other settings.
class containing the configuration of ambient occlusion rendering 3
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
static QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
bool readXml(const QDomNode &node)
Restores state from the given DOM node.
bool writeXml(QDomNode &node, QDomDocument &doc) const
Stores state to the given Dom node in the given document.
Contains information about the context in which a coordinate transform is executed.
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.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes settings to a DOM element.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads settings from a DOM element.
A class to represent a 2D point.
Definition qgspointxy.h:60
double y
Definition qgspointxy.h:64
double x
Definition qgspointxy.h:63
Temporarily blocks QgsProject "dirtying" for the lifetime of the object.
Contains elevation properties for a QgsProject.
QgsReferencedRectangle fullExtent() const
Returns the full extent of the project, which represents the maximal limits of the project.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
static QgsProject * instance()
Returns the QgsProject singleton instance.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
void setDirty(bool b=true)
Flag the project as dirty (modified).
const QgsProjectViewSettings * viewSettings() const
Returns the project's view settings, which contains settings and properties relating to how a QgsProj...
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
double xMinimum
double yMinimum
double xMaximum
double yMaximum
QgsPointXY center
class containing the configuration of shadows rendering 3
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
Contains the configuration of a skybox entity.
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.
Base class for objects with an associated (optional) temporal range.
const QgsDateTimeRange & temporalRange() const
Returns the datetime range for the object.
void setTemporalRange(const QgsDateTimeRange &range)
Sets the temporal range for the object.
T begin() const
Returns the beginning of the range.
Definition qgsrange.h:446
T end() const
Returns the upper bound of the range.
Definition qgsrange.h:453
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.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition qgsvector3d.h:31
double y() const
Returns Y coordinate.
Definition qgsvector3d.h:50
double z() const
Returns Z coordinate.
Definition qgsvector3d.h:52
double x() const
Returns X coordinate.
Definition qgsvector3d.h:48
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:6702
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:6701
_LayerRef< QgsMapLayer > QgsMapLayerRef
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:760
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
const QgsCoordinateReferenceSystem & crs
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
QString layerId
Original layer ID.