QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 std::unique_ptr<QgsPointLightSettings> 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 std::unique_ptr<QgsPointLightSettings> 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 std::unique_ptr<QgsDirectionalLightSettings> 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 hasChanged = !settings->equals( mTerrainSettings.get() );
684 mTerrainSettings.reset( settings );
685 }
686
687 if ( hasChanged )
688 {
689 std::unique_ptr<QgsTerrainGenerator> terrainGenerator = mTerrainSettings->createTerrainGenerator( Qgs3DRenderContext::fromMapSettings( this ) );
690 if ( terrainGenerator )
691 {
693 }
694
695 // emit all the signals, we don't know exactly what's changed
700 emit terrainElevationOffsetChanged( mTerrainSettings->elevationOffset() );
703
705 }
706}
707
709{
711
712 if ( mTerrainSettings->mapTileResolution() == res )
713 return;
714
715 mTerrainSettings->setMapTileResolution( res );
720}
721
723{
725
726 return mTerrainSettings->mapTileResolution();
727}
728
730{
732
733 if ( mTerrainSettings->maximumScreenError() == error )
734 return;
735
736 mTerrainSettings->setMaximumScreenError( error );
741}
742
744{
746
747 return mTerrainSettings->maximumScreenError();
748}
749
751{
753
754 if ( mTerrainSettings->maximumGroundError() == error )
755 return;
756
757 mTerrainSettings->setMaximumGroundError( error );
761
763}
764
766{
768
769 if ( mTerrainSettings->elevationOffset() == offset )
770 return;
771 mTerrainSettings->setElevationOffset( offset );
773 emit terrainElevationOffsetChanged( offset );
776}
777
779{
781
782 return mTerrainSettings->elevationOffset();
783}
784
786{
788
789 return mTerrainSettings->maximumGroundError();
790}
791
793{
795
796 if ( mTerrainGenerator )
797 {
798 disconnect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
799 }
800
801 if ( gen->crs().isValid() ) // Don't bother setting an extent rect in the wrong CRS
802 {
803 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, gen->crs(), mTransformContext );
804 gen->setExtent( terrainExtent );
805 }
806 mTerrainGenerator.reset( gen );
807 connect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
808
810}
811
813{
815
816 return mTerrainGenerator.get();
817}
818
820{
822
823 if ( mTerrainShadingEnabled == enabled )
824 return;
825
826 mTerrainShadingEnabled = enabled;
828}
829
831{
833
834 return mTerrainShadingEnabled;
835}
836
838{
840
841 if ( mTerrainShadingMaterial == material )
842 return;
843
844 mTerrainShadingMaterial = material;
846}
847
854
855void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
856{
858
859 if ( mTerrainMapTheme == theme )
860 return;
861
862 mTerrainMapTheme = theme;
864}
865
867{
869
870 return mTerrainMapTheme;
871}
872
874{
876
877 if ( mShowTerrainBoundingBoxes == enabled )
878 return;
879
880 mShowTerrainBoundingBoxes = enabled;
882}
883
885{
887
888 return mShowTerrainBoundingBoxes;
889}
890
891
893{
895
896 if ( mShowTerrainTileInfo == enabled )
897 return;
898
899 mShowTerrainTileInfo = enabled;
901}
902
904{
906
907 return mShowTerrainTileInfo;
908}
909
911{
913
914 if ( mShowCameraViewCenter == enabled )
915 return;
916
917 mShowCameraViewCenter = enabled;
919}
920
922{
924
925 return mShowCameraViewCenter;
926}
927
929{
931
932 if ( mShowCameraRotationCenter == enabled )
933 return;
934
935 mShowCameraRotationCenter = enabled;
937}
938
940{
942
943 return mShowCameraRotationCenter;
944}
945
947{
949
950 if ( mShowLightSources == enabled )
951 return;
952
953 mShowLightSources = enabled;
955}
956
958{
960
961 return mShowLightSources;
962}
963
965{
967
968 if ( mShowLabels == enabled )
969 return;
970
971 mShowLabels = enabled;
972 emit showLabelsChanged();
973}
974
976{
978
979 return mShowLabels;
980}
981
983{
985
986 if ( mStopUpdates == enabled )
987 return;
988
989 mStopUpdates = enabled;
990 emit stopUpdatesChanged();
991}
992
994{
996
997 return mStopUpdates;
998}
999
1001{
1003
1004 if ( mEyeDomeLightingEnabled == enabled )
1005 return;
1006 mEyeDomeLightingEnabled = enabled;
1008}
1009
1011{
1013
1014 return mEyeDomeLightingEnabled;
1015}
1016
1018{
1020
1021 if ( mEyeDomeLightingStrength == strength )
1022 return;
1023 mEyeDomeLightingStrength = strength;
1025}
1026
1028{
1030
1031 return mEyeDomeLightingStrength;
1032}
1033
1035{
1037
1038 if ( mEyeDomeLightingDistance == distance )
1039 return;
1040 mEyeDomeLightingDistance = distance;
1042}
1043
1045{
1047
1048 return mEyeDomeLightingDistance;
1049}
1050
1051QList<QgsLightSource *> Qgs3DMapSettings::lightSources() const
1052{
1054
1055 return mLightSources;
1056}
1057
1058void Qgs3DMapSettings::setLightSources( const QList<QgsLightSource *> &lights )
1059{
1061
1062 // have lights actually changed?
1063 if ( mLightSources.count() == lights.count() )
1064 {
1065 bool same = true;
1066 for ( int i = 0; i < mLightSources.count(); ++i )
1067 {
1068 if ( mLightSources[i]->type() == lights[i]->type() )
1069 {
1070 switch ( mLightSources[i]->type() )
1071 {
1073 if ( *static_cast<QgsPointLightSettings *>( mLightSources[i] ) == *static_cast<QgsPointLightSettings *>( lights[i] ) )
1074 continue;
1075 break;
1077 if ( *static_cast<QgsDirectionalLightSettings *>( mLightSources[i] ) == *static_cast<QgsDirectionalLightSettings *>( lights[i] ) )
1078 continue;
1079 break;
1080 }
1081 }
1082 same = false;
1083 break;
1084 }
1085 if ( same )
1086 {
1087 qDeleteAll( lights );
1088 return;
1089 }
1090 }
1091
1092 qDeleteAll( mLightSources );
1093 mLightSources = lights;
1094
1096 emit pointLightsChanged();
1097 emit lightSourcesChanged();
1098}
1099
1101{
1103
1104 return mFieldOfView;
1105}
1106
1107void Qgs3DMapSettings::setFieldOfView( const float fieldOfView )
1108{
1110
1111 if ( mFieldOfView == fieldOfView )
1112 return;
1113
1114 mFieldOfView = fieldOfView;
1115 emit fieldOfViewChanged();
1116}
1117
1118Qt3DRender::QCameraLens::ProjectionType Qgs3DMapSettings::projectionType() const
1119{
1121
1122 return mProjectionType;
1123}
1124
1125void Qgs3DMapSettings::setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType )
1126{
1128
1129 if ( mProjectionType == projectionType )
1130 return;
1131
1132 mProjectionType = projectionType;
1133 emit projectionTypeChanged();
1134}
1135
1137{
1139
1140 return mCameraNavigationMode;
1141}
1142
1144{
1146
1147 if ( mCameraNavigationMode == navigationMode )
1148 return;
1149
1150 mCameraNavigationMode = navigationMode;
1152}
1153
1155{
1157
1158 return mCameraMovementSpeed;
1159}
1160
1162{
1164
1165 if ( mCameraMovementSpeed == movementSpeed )
1166 return;
1167
1168 mCameraMovementSpeed = movementSpeed;
1170}
1171
1172void Qgs3DMapSettings::setOutputDpi( const double dpi )
1173{
1175
1176 mDpi = dpi;
1177}
1178
1180{
1182
1183 return mDpi;
1184}
1185
1187{
1189
1190 return mSkyboxSettings;
1191}
1192
1194{
1196
1197 return mShadowSettings;
1198}
1199
1201{
1203
1204 return mAmbientOcclusionSettings;
1205}
1206
1208{
1210
1211 mSkyboxSettings = skyboxSettings;
1212 emit skyboxSettingsChanged();
1213}
1214
1216{
1218
1219 mShadowSettings = shadowSettings;
1220 emit shadowSettingsChanged();
1221}
1222
1224{
1226
1227 mAmbientOcclusionSettings = ambientOcclusionSettings;
1229}
1230
1232{
1234
1235 return mIsSkyboxEnabled;
1236}
1237
1239{
1241
1242 mIsSkyboxEnabled = enabled;
1243}
1244
1246{
1248
1249 return mIsFpsCounterEnabled;
1250}
1251
1252void Qgs3DMapSettings::setShowDebugPanel( const bool enabled )
1253{
1255
1256 if ( mShowDebugPanel == enabled )
1257 return;
1258
1259 mShowDebugPanel = enabled;
1260 emit showDebugPanelChanged( enabled );
1261}
1262
1264{
1266
1267 return mShowDebugPanel;
1268}
1269
1270void Qgs3DMapSettings::setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size )
1271{
1273
1274 mDebugShadowMapEnabled = enabled;
1275 mDebugShadowMapCorner = corner;
1276 mDebugShadowMapSize = size;
1278}
1279
1281{
1283
1284 return mDebugShadowMapEnabled;
1285}
1286
1288{
1290
1291 return mDebugShadowMapCorner;
1292}
1293
1295{
1297
1298 return mDebugShadowMapSize;
1299}
1300
1301void Qgs3DMapSettings::setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size )
1302{
1304
1305 mDebugDepthMapEnabled = enabled;
1306 mDebugDepthMapCorner = corner;
1307 mDebugDepthMapSize = size;
1309}
1310
1312{
1314
1315 return mDebugDepthMapEnabled;
1316}
1317
1319{
1321
1322 return mDebugDepthMapCorner;
1323}
1324
1326{
1328
1329 return mDebugDepthMapSize;
1330}
1331
1332void Qgs3DMapSettings::setIsFpsCounterEnabled( bool fpsCounterEnabled )
1333{
1335
1336 if ( fpsCounterEnabled == mIsFpsCounterEnabled )
1337 return;
1338 mIsFpsCounterEnabled = fpsCounterEnabled;
1339 emit fpsCounterEnabledChanged( mIsFpsCounterEnabled );
1340}
1341
1343{
1345
1346 return mTerrainRenderingEnabled;
1347}
1348
1349void Qgs3DMapSettings::setTerrainRenderingEnabled( bool terrainRenderingEnabled )
1350{
1352
1353 if ( terrainRenderingEnabled == mTerrainRenderingEnabled )
1354 return;
1355 mTerrainRenderingEnabled = terrainRenderingEnabled;
1357}
1358
1360{
1362
1363 return mRendererUsage;
1364}
1365
1367{
1369
1370 mRendererUsage = rendererUsage;
1371}
1372
1379
1381{
1383
1384 mViewSyncMode = mode;
1385}
1386
1388{
1390
1391 return mVisualizeViewFrustum;
1392}
1393
1395{
1397
1398 if ( mVisualizeViewFrustum != enabled )
1399 {
1400 mVisualizeViewFrustum = enabled;
1402 }
1403}
1404
1406{
1408
1409 return m3dAxisSettings;
1410}
1411
1412void Qgs3DMapSettings::setIsDebugOverlayEnabled( bool debugOverlayEnabled )
1413{
1415
1416 if ( debugOverlayEnabled == mIsDebugOverlayEnabled )
1417 return;
1418
1419 mIsDebugOverlayEnabled = debugOverlayEnabled;
1420 emit debugOverlayEnabledChanged( mIsDebugOverlayEnabled );
1421}
1422
1424{
1426
1427 return mShowExtentIn2DView;
1428}
1429
1430void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
1431{
1433
1465}
1466
1467
1468void Qgs3DMapSettings::set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force )
1469{
1471
1472 if ( axisSettings == m3dAxisSettings )
1473 {
1474 if ( force )
1475 {
1476 // ie. refresh. We need to disconnect and to reconnect to avoid 'dirty' project
1478 emit axisSettingsChanged();
1480 }
1481 }
1482 else
1483 {
1484 m3dAxisSettings = axisSettings;
1485 emit axisSettingsChanged();
1486 }
1487}
1488
1490{
1492
1493 return mIsDebugOverlayEnabled;
1494}
1495
1497{
1499
1500 if ( show == mShowExtentIn2DView )
1501 return;
1502
1503 mShowExtentIn2DView = show;
1505}
QFlags< ViewSyncModeFlag > ViewSyncModeFlags
Definition qgis.h:3296
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:3935
@ 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:3259
@ 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:444
T end() const
Returns the upper bound of the range.
Definition qgsrange.h:451
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:6643
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:6642
_LayerRef< QgsMapLayer > QgsMapLayerRef
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:742
#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.