QGIS API Documentation 3.39.0-Master (d85f3c2a281)
Loading...
Searching...
No Matches
qgs3dmapsettings.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgs3dmapsettings.cpp
3 --------------------------------------
4 Date : July 2017
5 Copyright : (C) 2017 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgs3dmapsettings.h"
17
18#include "qgs3dutils.h"
21#include "qgsmeshterraingenerator.h"
26#include "qgsterrainprovider.h"
27#include "qgslightsource.h"
28#include "qgscolorutils.h"
29#include "qgsrasterlayer.h"
32#include "qgs3drendercontext.h"
33#include "qgsthreadingutils.h"
34
35#include <QDomDocument>
36#include <QDomElement>
37
38
40 : QObject( nullptr )
41{
42 connect( this, &Qgs3DMapSettings::settingsChanged, [&]()
43 {
45 } );
46 connectChangedSignalsToSettingsChanged();
47}
48
50 : QObject( nullptr )
51 , QgsTemporalRangeObject( other )
52 , mOrigin( other.mOrigin )
53 , mCrs( other.mCrs )
54 , mBackgroundColor( other.mBackgroundColor )
55 , mSelectionColor( other.mSelectionColor )
56 , mTerrainVerticalScale( other.mTerrainVerticalScale )
57 , mTerrainGenerator( other.mTerrainGenerator ? other.mTerrainGenerator->clone() : nullptr )
58 , mMapTileResolution( other.mMapTileResolution )
59 , mMaxTerrainScreenError( other.mMaxTerrainScreenError )
60 , mMaxTerrainGroundError( other.mMaxTerrainGroundError )
61 , mTerrainElevationOffset( other.mTerrainElevationOffset )
62 , mTerrainShadingEnabled( other.mTerrainShadingEnabled )
63 , mTerrainShadingMaterial( other.mTerrainShadingMaterial )
64 , mTerrainMapTheme( other.mTerrainMapTheme )
65 , mShowTerrainBoundingBoxes( other.mShowTerrainBoundingBoxes )
66 , mShowTerrainTileInfo( other.mShowTerrainTileInfo )
67 , mShowCameraViewCenter( other.mShowCameraViewCenter )
68 , mShowCameraRotationCenter( other.mShowCameraRotationCenter )
69 , mShowLightSources( other.mShowLightSources )
70 , mShowLabels( other.mShowLabels )
71 , mFieldOfView( other.mFieldOfView )
72 , mProjectionType( other.mProjectionType )
73 , mCameraNavigationMode( other.mCameraNavigationMode )
74 , mCameraMovementSpeed( other.mCameraMovementSpeed )
75 , mLayers( other.mLayers )
76 , mTransformContext( other.mTransformContext )
77 , mPathResolver( other.mPathResolver )
78 , mMapThemes( other.mMapThemes )
79 , mDpi( other.mDpi )
80 , mIsFpsCounterEnabled( other.mIsFpsCounterEnabled )
81 , mIsSkyboxEnabled( other.mIsSkyboxEnabled )
82 , mSkyboxSettings( other.mSkyboxSettings )
83 , mShadowSettings( other.mShadowSettings )
84 , mAmbientOcclusionSettings( other.mAmbientOcclusionSettings )
85 , mEyeDomeLightingEnabled( other.mEyeDomeLightingEnabled )
86 , mEyeDomeLightingStrength( other.mEyeDomeLightingStrength )
87 , mEyeDomeLightingDistance( other.mEyeDomeLightingDistance )
88 , mViewSyncMode( other.mViewSyncMode )
89 , mVisualizeViewFrustum( other.mVisualizeViewFrustum )
90 , mDebugShadowMapEnabled( other.mDebugShadowMapEnabled )
91 , mDebugShadowMapCorner( other.mDebugShadowMapCorner )
92 , mDebugShadowMapSize( other.mDebugShadowMapSize )
93 , mDebugDepthMapEnabled( other.mDebugDepthMapEnabled )
94 , mDebugDepthMapCorner( other.mDebugDepthMapCorner )
95 , mDebugDepthMapSize( other.mDebugDepthMapSize )
96 , mTerrainRenderingEnabled( other.mTerrainRenderingEnabled )
97 , mRendererUsage( other.mRendererUsage )
98 , m3dAxisSettings( other.m3dAxisSettings )
99 , mIsDebugOverlayEnabled( other.mIsDebugOverlayEnabled )
100 , mExtent( other.mExtent )
101 , mShowExtentIn2DView( other.mShowExtentIn2DView )
102{
103 for ( QgsLightSource *source : std::as_const( other.mLightSources ) )
104 {
105 if ( source )
106 mLightSources << source->clone();
107 }
108
109 connect( this, &Qgs3DMapSettings::settingsChanged, [&]()
110 {
112 } );
113 connectChangedSignalsToSettingsChanged();
114}
115
117{
118 qDeleteAll( mLightSources );
119}
120
121void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
122{
124
126 QDomElement elemOrigin = elem.firstChildElement( QStringLiteral( "origin" ) );
127 mOrigin = QgsVector3D(
128 elemOrigin.attribute( QStringLiteral( "x" ) ).toDouble(),
129 elemOrigin.attribute( QStringLiteral( "y" ) ).toDouble(),
130 elemOrigin.attribute( QStringLiteral( "z" ) ).toDouble() );
131
132 QDomElement elemExtent = elem.firstChildElement( QStringLiteral( "extent" ) );
133 if ( !elemExtent.isNull() )
134 {
135 mExtent = QgsRectangle(
136 elemExtent.attribute( QStringLiteral( "xMin" ) ).toDouble(),
137 elemExtent.attribute( QStringLiteral( "yMin" ) ).toDouble(),
138 elemExtent.attribute( QStringLiteral( "xMax" ) ).toDouble(),
139 elemExtent.attribute( QStringLiteral( "yMax" ) ).toDouble() );
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 mTerrainVerticalScale = elemTerrain.attribute( QStringLiteral( "exaggeration" ), QStringLiteral( "1" ) ).toFloat();
174 mMapTileResolution = elemTerrain.attribute( QStringLiteral( "texture-size" ), QStringLiteral( "512" ) ).toInt();
175 mMaxTerrainScreenError = elemTerrain.attribute( QStringLiteral( "max-terrain-error" ), QStringLiteral( "3" ) ).toFloat();
176 mMaxTerrainGroundError = elemTerrain.attribute( QStringLiteral( "max-ground-error" ), QStringLiteral( "1" ) ).toFloat();
177 mTerrainShadingEnabled = elemTerrain.attribute( QStringLiteral( "shading-enabled" ), QStringLiteral( "0" ) ).toInt();
178 mTerrainElevationOffset = elemTerrain.attribute( QStringLiteral( "elevation-offset" ), QStringLiteral( "0.0" ) ).toFloat();
179
180 QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( QStringLiteral( "shading-material" ) );
181 if ( !elemTerrainShadingMaterial.isNull() )
182 mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial, context );
183 mTerrainMapTheme = elemTerrain.attribute( QStringLiteral( "map-theme" ) );
184 mShowLabels = elemTerrain.attribute( QStringLiteral( "show-labels" ), QStringLiteral( "0" ) ).toInt();
185
186 qDeleteAll( mLightSources );
187 mLightSources.clear();
188 const QDomElement lightsElem = elem.firstChildElement( QStringLiteral( "lights" ) );
189 if ( !lightsElem.isNull() )
190 {
191 const QDomNodeList lightNodes = lightsElem.childNodes();
192 for ( int i = 0; i < lightNodes.size(); ++i )
193 {
194 const QDomElement lightElement = lightNodes.at( i ).toElement();
195 if ( QgsLightSource *light = QgsLightSource::createFromXml( lightElement, context ) )
196 mLightSources << light;
197 }
198 }
199 else
200 {
201 // older project format
202 QDomElement elemPointLights = elem.firstChildElement( QStringLiteral( "point-lights" ) );
203 if ( !elemPointLights.isNull() )
204 {
205 QDomElement elemPointLight = elemPointLights.firstChildElement( QStringLiteral( "point-light" ) );
206 while ( !elemPointLight.isNull() )
207 {
208 std::unique_ptr< QgsPointLightSettings > pointLight = std::make_unique< QgsPointLightSettings >();
209 pointLight->readXml( elemPointLight, context );
210 mLightSources << pointLight.release();
211 elemPointLight = elemPointLight.nextSiblingElement( QStringLiteral( "point-light" ) );
212 }
213 }
214 else
215 {
216 // QGIS <= 3.4 did not have light configuration
217 std::unique_ptr< QgsPointLightSettings > defaultLight = std::make_unique< QgsPointLightSettings >();
218 defaultLight->setPosition( QgsVector3D( 0, 1000, 0 ) );
219 mLightSources << defaultLight.release();
220 }
221
222 QDomElement elemDirectionalLights = elem.firstChildElement( QStringLiteral( "directional-lights" ) );
223 if ( !elemDirectionalLights.isNull() )
224 {
225 QDomElement elemDirectionalLight = elemDirectionalLights.firstChildElement( QStringLiteral( "directional-light" ) );
226 while ( !elemDirectionalLight.isNull() )
227 {
228 std::unique_ptr< QgsDirectionalLightSettings > directionalLight = std::make_unique< QgsDirectionalLightSettings >();
229 directionalLight->readXml( elemDirectionalLight, context );
230 mLightSources << directionalLight.release();
231 elemDirectionalLight = elemDirectionalLight.nextSiblingElement( QStringLiteral( "directional-light" ) );
232 }
233 }
234 }
235
236 QDomElement elemMapLayers = elemTerrain.firstChildElement( QStringLiteral( "layers" ) );
237 QDomElement elemMapLayer = elemMapLayers.firstChildElement( QStringLiteral( "layer" ) );
238 QList<QgsMapLayerRef> mapLayers;
239 while ( !elemMapLayer.isNull() )
240 {
241 mapLayers << QgsMapLayerRef( elemMapLayer.attribute( QStringLiteral( "id" ) ) );
242 elemMapLayer = elemMapLayer.nextSiblingElement( QStringLiteral( "layer" ) );
243 }
244 mLayers = mapLayers; // needs to resolve refs afterwards
245
246 QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( QStringLiteral( "generator" ) );
247 QString terrainGenType = elemTerrainGenerator.attribute( QStringLiteral( "type" ) );
248 if ( terrainGenType == QLatin1String( "dem" ) )
249 {
250 QgsDemTerrainGenerator *demTerrainGenerator = new QgsDemTerrainGenerator;
251 demTerrainGenerator->setCrs( mCrs, mTransformContext );
252 setTerrainGenerator( demTerrainGenerator );
253 }
254 else if ( terrainGenType == QLatin1String( "online" ) )
255 {
256 QgsOnlineTerrainGenerator *onlineTerrainGenerator = new QgsOnlineTerrainGenerator;
257 onlineTerrainGenerator->setCrs( mCrs, mTransformContext );
258 setTerrainGenerator( onlineTerrainGenerator );
259 }
260 else if ( terrainGenType == QLatin1String( "mesh" ) )
261 {
262 QgsMeshTerrainGenerator *meshTerrainGenerator = new QgsMeshTerrainGenerator;
263 meshTerrainGenerator->setCrs( mCrs, mTransformContext );
264 setTerrainGenerator( meshTerrainGenerator );
265 }
266 else if ( terrainGenType == QLatin1String( "quantizedmesh" ) )
267 {
269 setTerrainGenerator( qmTerrainGenerator );
270 }
271 else // "flat"
272 {
274 flatGen->setCrs( mCrs );
275 setTerrainGenerator( flatGen );
276 }
277 mTerrainGenerator->readXml( elemTerrainGenerator );
278
279 QDomElement elemSkybox = elem.firstChildElement( QStringLiteral( "skybox" ) );
280 mIsSkyboxEnabled = elemSkybox.attribute( QStringLiteral( "skybox-enabled" ) ).toInt();
281 mSkyboxSettings.readXml( elemSkybox, context );
282
283 QDomElement elemShadows = elem.firstChildElement( QStringLiteral( "shadow-rendering" ) );
284 mShadowSettings.readXml( elemShadows, context );
285
286 QDomElement elemAmbientOcclusion = elem.firstChildElement( QStringLiteral( "screen-space-ambient-occlusion" ) );
287 mAmbientOcclusionSettings.readXml( elemAmbientOcclusion, context );
288
289 QDomElement elemEyeDomeLighting = elem.firstChildElement( QStringLiteral( "eye-dome-lighting" ) );
290 mEyeDomeLightingEnabled = elemEyeDomeLighting.attribute( "enabled", QStringLiteral( "0" ) ).toInt();
291 mEyeDomeLightingStrength = elemEyeDomeLighting.attribute( "eye-dome-lighting-strength", QStringLiteral( "1000.0" ) ).toDouble();
292 mEyeDomeLightingDistance = elemEyeDomeLighting.attribute( "eye-dome-lighting-distance", QStringLiteral( "1" ) ).toInt();
293
294 QDomElement elemNavigationSync = elem.firstChildElement( QStringLiteral( "navigation-sync" ) );
295 mViewSyncMode = ( Qgis::ViewSyncModeFlags )( elemNavigationSync.attribute( QStringLiteral( "view-sync-mode" ), QStringLiteral( "0" ) ).toInt() );
296 mVisualizeViewFrustum = elemNavigationSync.attribute( QStringLiteral( "view-frustum-visualization-enabled" ), QStringLiteral( "0" ) ).toInt();
297
298 QDomElement elemDebugSettings = elem.firstChildElement( QStringLiteral( "debug-settings" ) );
299 mDebugShadowMapEnabled = elemDebugSettings.attribute( QStringLiteral( "shadowmap-enabled" ), QStringLiteral( "0" ) ).toInt();
300 mDebugShadowMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( QStringLiteral( "shadowmap-corner" ), "0" ).toInt() );
301 mDebugShadowMapSize = elemDebugSettings.attribute( QStringLiteral( "shadowmap-size" ), QStringLiteral( "0.2" ) ).toDouble();
302
303 mDebugDepthMapEnabled = elemDebugSettings.attribute( QStringLiteral( "depthmap-enabled" ), QStringLiteral( "0" ) ).toInt();
304 mDebugDepthMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( QStringLiteral( "depthmap-corner" ), QStringLiteral( "1" ) ).toInt() );
305 mDebugDepthMapSize = elemDebugSettings.attribute( QStringLiteral( "depthmap-size" ), QStringLiteral( "0.2" ) ).toDouble();
306
307 QDomElement elemDebug = elem.firstChildElement( QStringLiteral( "debug" ) );
308 mShowTerrainBoundingBoxes = elemDebug.attribute( QStringLiteral( "bounding-boxes" ), QStringLiteral( "0" ) ).toInt();
309 mShowTerrainTileInfo = elemDebug.attribute( QStringLiteral( "terrain-tile-info" ), QStringLiteral( "0" ) ).toInt();
310 mShowCameraViewCenter = elemDebug.attribute( QStringLiteral( "camera-view-center" ), QStringLiteral( "0" ) ).toInt();
311 mShowCameraRotationCenter = elemDebug.attribute( QStringLiteral( "camera-rotation-center" ), QStringLiteral( "0" ) ).toInt();
312 mShowLightSources = elemDebug.attribute( QStringLiteral( "show-light-sources" ), QStringLiteral( "0" ) ).toInt();
313 mIsFpsCounterEnabled = elemDebug.attribute( QStringLiteral( "show-fps-counter" ), QStringLiteral( "0" ) ).toInt();
314
315 QDomElement elemTemporalRange = elem.firstChildElement( QStringLiteral( "temporal-range" ) );
316 QDateTime start = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "start" ) ), Qt::ISODate );
317 QDateTime end = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "end" ) ), Qt::ISODate );
318 setTemporalRange( QgsDateTimeRange( start, end ) );
319
320 QDomElement elem3dAxis = elem.firstChildElement( QStringLiteral( "axis3d" ) );
321 m3dAxisSettings.readXml( elem3dAxis, context );
322
323}
324
325QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const
326{
328
329 QDomElement elem = doc.createElement( QStringLiteral( "qgis3d" ) );
330
331 QDomElement elemOrigin = doc.createElement( QStringLiteral( "origin" ) );
332 elemOrigin.setAttribute( QStringLiteral( "x" ), QString::number( mOrigin.x() ) );
333 elemOrigin.setAttribute( QStringLiteral( "y" ), QString::number( mOrigin.y() ) );
334 elemOrigin.setAttribute( QStringLiteral( "z" ), QString::number( mOrigin.z() ) );
335 elem.appendChild( elemOrigin );
336
337 QDomElement elemExtent = doc.createElement( QStringLiteral( "extent" ) );
338 elemExtent.setAttribute( QStringLiteral( "xMin" ), mExtent.xMinimum() );
339 elemExtent.setAttribute( QStringLiteral( "yMin" ), mExtent.yMinimum() );
340 elemExtent.setAttribute( QStringLiteral( "xMax" ), mExtent.xMaximum() );
341 elemExtent.setAttribute( QStringLiteral( "yMax" ), mExtent.yMaximum() );
342 elemExtent.setAttribute( QStringLiteral( "showIn2dView" ), mShowExtentIn2DView );
343 elem.appendChild( elemExtent );
344
345 QDomElement elemCamera = doc.createElement( QStringLiteral( "camera" ) );
346 elemCamera.setAttribute( QStringLiteral( "field-of-view" ), mFieldOfView );
347 elemCamera.setAttribute( QStringLiteral( "projection-type" ), static_cast< int >( mProjectionType ) );
348 switch ( mCameraNavigationMode )
349 {
351 elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "terrain-based-navigation" ) );
352 break;
354 elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "walk-navigation" ) );
355 break;
356 }
357 elemCamera.setAttribute( QStringLiteral( "camera-movement-speed" ), mCameraMovementSpeed );
358 elem.appendChild( elemCamera );
359
360 QDomElement elemColor = doc.createElement( QStringLiteral( "color" ) );
361 elemColor.setAttribute( QStringLiteral( "background" ), QgsColorUtils::colorToString( mBackgroundColor ) );
362 elemColor.setAttribute( QStringLiteral( "selection" ), QgsColorUtils::colorToString( mSelectionColor ) );
363 elem.appendChild( elemColor );
364
365 QDomElement elemCrs = doc.createElement( QStringLiteral( "crs" ) );
366 mCrs.writeXml( elemCrs, doc );
367 elem.appendChild( elemCrs );
368
369 QDomElement elemTerrain = doc.createElement( QStringLiteral( "terrain" ) );
370 elemTerrain.setAttribute( QStringLiteral( "terrain-rendering-enabled" ), mTerrainRenderingEnabled ? 1 : 0 );
371 elemTerrain.setAttribute( QStringLiteral( "exaggeration" ), QString::number( mTerrainVerticalScale ) );
372 elemTerrain.setAttribute( QStringLiteral( "texture-size" ), mMapTileResolution );
373 elemTerrain.setAttribute( QStringLiteral( "max-terrain-error" ), QString::number( mMaxTerrainScreenError ) );
374 elemTerrain.setAttribute( QStringLiteral( "max-ground-error" ), QString::number( mMaxTerrainGroundError ) );
375 elemTerrain.setAttribute( QStringLiteral( "shading-enabled" ), mTerrainShadingEnabled ? 1 : 0 );
376 elemTerrain.setAttribute( QStringLiteral( "elevation-offset" ), mTerrainElevationOffset );
377
378 QDomElement elemTerrainShadingMaterial = doc.createElement( QStringLiteral( "shading-material" ) );
379 mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial, context );
380 elemTerrain.appendChild( elemTerrainShadingMaterial );
381 elemTerrain.setAttribute( QStringLiteral( "map-theme" ), mTerrainMapTheme );
382 elemTerrain.setAttribute( QStringLiteral( "show-labels" ), mShowLabels ? 1 : 0 );
383
384 {
385 QDomElement elemLights = doc.createElement( QStringLiteral( "lights" ) );
386 for ( const QgsLightSource *light : mLightSources )
387 {
388 const QDomElement elemLight = light->writeXml( doc, context );
389 elemLights.appendChild( elemLight );
390 }
391 elem.appendChild( elemLights );
392 }
393
394 QDomElement elemMapLayers = doc.createElement( QStringLiteral( "layers" ) );
395 for ( const QgsMapLayerRef &layerRef : mLayers )
396 {
397 QDomElement elemMapLayer = doc.createElement( QStringLiteral( "layer" ) );
398 elemMapLayer.setAttribute( QStringLiteral( "id" ), layerRef.layerId );
399 elemMapLayers.appendChild( elemMapLayer );
400 }
401 elemTerrain.appendChild( elemMapLayers );
402
403 QDomElement elemTerrainGenerator = doc.createElement( QStringLiteral( "generator" ) );
404 elemTerrainGenerator.setAttribute( QStringLiteral( "type" ), QgsTerrainGenerator::typeToString( mTerrainGenerator->type() ) );
405 mTerrainGenerator->writeXml( elemTerrainGenerator );
406 elemTerrain.appendChild( elemTerrainGenerator );
407 elem.appendChild( elemTerrain );
408
409 QDomElement elemSkybox = doc.createElement( QStringLiteral( "skybox" ) );
410 elemSkybox.setAttribute( QStringLiteral( "skybox-enabled" ), mIsSkyboxEnabled );
411 mSkyboxSettings.writeXml( elemSkybox, context );
412 elem.appendChild( elemSkybox );
413
414 QDomElement elemShadows = doc.createElement( QStringLiteral( "shadow-rendering" ) );
415 mShadowSettings.writeXml( elemShadows, context );
416 elem.appendChild( elemShadows );
417
418 QDomElement elemAmbientOcclusion = doc.createElement( QStringLiteral( "screen-space-ambient-occlusion" ) );
419 mAmbientOcclusionSettings.writeXml( elemAmbientOcclusion, context );
420 elem.appendChild( elemAmbientOcclusion );
421
422 QDomElement elemDebug = doc.createElement( QStringLiteral( "debug" ) );
423 elemDebug.setAttribute( QStringLiteral( "bounding-boxes" ), mShowTerrainBoundingBoxes ? 1 : 0 );
424 elemDebug.setAttribute( QStringLiteral( "terrain-tile-info" ), mShowTerrainTileInfo ? 1 : 0 );
425 elemDebug.setAttribute( QStringLiteral( "camera-view-center" ), mShowCameraViewCenter ? 1 : 0 );
426 elemDebug.setAttribute( QStringLiteral( "camera-rotation-center" ), mShowCameraRotationCenter ? 1 : 0 );
427 elemDebug.setAttribute( QStringLiteral( "show-light-sources" ), mShowLightSources ? 1 : 0 );
428 elemDebug.setAttribute( QStringLiteral( "show-fps-counter" ), mIsFpsCounterEnabled ? 1 : 0 );
429 elem.appendChild( elemDebug );
430
431 QDomElement elemEyeDomeLighting = doc.createElement( QStringLiteral( "eye-dome-lighting" ) );
432 elemEyeDomeLighting.setAttribute( QStringLiteral( "enabled" ), mEyeDomeLightingEnabled ? 1 : 0 );
433 elemEyeDomeLighting.setAttribute( QStringLiteral( "eye-dome-lighting-strength" ), mEyeDomeLightingStrength );
434 elemEyeDomeLighting.setAttribute( QStringLiteral( "eye-dome-lighting-distance" ), mEyeDomeLightingDistance );
435 elem.appendChild( elemEyeDomeLighting );
436
437 QDomElement elemNavigationSync = doc.createElement( QStringLiteral( "navigation-sync" ) );
438 elemNavigationSync.setAttribute( QStringLiteral( "view-sync-mode" ), ( int )mViewSyncMode );
439 elemNavigationSync.setAttribute( QStringLiteral( "view-frustum-visualization-enabled" ), mVisualizeViewFrustum ? 1 : 0 );
440 elem.appendChild( elemNavigationSync );
441
442 QDomElement elemDebugSettings = doc.createElement( QStringLiteral( "debug-settings" ) );
443 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-enabled" ), mDebugShadowMapEnabled );
444 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-corner" ), mDebugShadowMapCorner );
445 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-size" ), mDebugShadowMapSize );
446 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-enabled" ), mDebugDepthMapEnabled );
447 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-corner" ), mDebugDepthMapCorner );
448 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-size" ), mDebugDepthMapSize );
449 elem.appendChild( elemDebugSettings );
450
451 QDomElement elemTemporalRange = doc.createElement( QStringLiteral( "temporal-range" ) );
452 elemTemporalRange.setAttribute( QStringLiteral( "start" ), temporalRange().begin().toString( Qt::ISODate ) );
453 elemTemporalRange.setAttribute( QStringLiteral( "end" ), temporalRange().end().toString( Qt::ISODate ) );
454
455 QDomElement elem3dAxis = doc.createElement( QStringLiteral( "axis3d" ) );
456 m3dAxisSettings.writeXml( elem3dAxis, context );
457 elem.appendChild( elem3dAxis );
458
459 return elem;
460}
461
463{
465
466 for ( int i = 0; i < mLayers.count(); ++i )
467 {
468 QgsMapLayerRef &layerRef = mLayers[i];
469 layerRef.setLayer( project.mapLayer( layerRef.layerId ) );
470 }
471
472 mTerrainGenerator->resolveReferences( project );
473}
474
481
483{
485
486 if ( extent == mExtent )
487 return;
488
489 mExtent = extent;
490 const QgsPointXY center = mExtent.center();
491 setOrigin( QgsVector3D( center.x(), center.y(), 0 ) );
492 if ( mTerrainGenerator )
493 {
494 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, mTerrainGenerator->crs(), mTransformContext );
495 mTerrainGenerator->setExtent( terrainExtent );
496 }
497 emit extentChanged();
498}
499
501{
503
504 mOrigin = origin;
505}
506
508{
510
511 return mOrigin;
512}
513
520
527
534
541
548
550{
552
553 mTransformContext = context;
554}
555
557{
559
560 return mPathResolver;
561}
562
564{
566
567 mPathResolver = resolver;
568}
569
576
578{
580
581 mMapThemes = mapThemes;
582}
583
584void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
585{
587
588 if ( color == mBackgroundColor )
589 return;
590
591 mBackgroundColor = color;
593}
594
596{
598
599 return mBackgroundColor;
600}
601
602void Qgs3DMapSettings::setSelectionColor( const QColor &color )
603{
605
606 if ( color == mSelectionColor )
607 return;
608
609 mSelectionColor = color;
611}
612
614{
616
617 return mSelectionColor;
618}
619
621{
623
624 if ( zScale == mTerrainVerticalScale )
625 return;
626
627 mTerrainVerticalScale = zScale;
629}
630
632{
634
635 return mTerrainVerticalScale;
636}
637
638void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
639{
641
642 QList<QgsMapLayerRef> lst;
643 lst.reserve( layers.count() );
644 for ( QgsMapLayer *layer : layers )
645 {
646 lst.append( layer );
647 }
648
649 if ( mLayers == lst )
650 return;
651
652 mLayers = lst;
653 emit layersChanged();
654}
655
656QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
657{
659
660 QList<QgsMapLayer *> lst;
661 lst.reserve( mLayers.count() );
662 for ( const QgsMapLayerRef &layerRef : mLayers )
663 {
664 if ( layerRef.layer )
665 lst.append( layerRef.layer );
666 }
667 return lst;
668}
669
671{
673
674 setExtent( fullExtent );
675 if ( properties->terrainProvider()->type() == QLatin1String( "flat" ) )
676 {
678 flatTerrain->setCrs( crs() );
679 setTerrainGenerator( flatTerrain );
680
682 }
683 else if ( properties->terrainProvider()->type() == QLatin1String( "raster" ) )
684 {
685 QgsRasterDemTerrainProvider *rasterProvider = qgis::down_cast< QgsRasterDemTerrainProvider * >( properties->terrainProvider() );
686
688 demTerrainGen->setCrs( crs(), QgsProject::instance()->transformContext() );
689 demTerrainGen->setLayer( rasterProvider->layer() );
690 setTerrainGenerator( demTerrainGen );
691
694 }
695 else if ( properties->terrainProvider()->type() == QLatin1String( "mesh" ) )
696 {
697 QgsMeshTerrainProvider *meshProvider = qgis::down_cast< QgsMeshTerrainProvider * >( properties->terrainProvider() );
698
699 QgsMeshTerrainGenerator *newTerrainGenerator = new QgsMeshTerrainGenerator;
700 newTerrainGenerator->setCrs( crs(), QgsProject::instance()->transformContext() );
701 newTerrainGenerator->setLayer( meshProvider->layer() );
702 std::unique_ptr< QgsMesh3DSymbol > symbol( newTerrainGenerator->symbol()->clone() );
703 symbol->setVerticalScale( properties->terrainProvider()->scale() );
704 newTerrainGenerator->setSymbol( symbol.release() );
705 setTerrainGenerator( newTerrainGenerator );
706
709 }
710 else
711 {
713 flatTerrain->setCrs( crs() );
714 setTerrainGenerator( flatTerrain );
715 }
716}
717
719{
721
722 if ( mMapTileResolution == res )
723 return;
724
725 mMapTileResolution = res;
727}
728
730{
732
733 return mMapTileResolution;
734}
735
737{
739
740 if ( mMaxTerrainScreenError == error )
741 return;
742
743 mMaxTerrainScreenError = error;
745}
746
748{
750
751 return mMaxTerrainScreenError;
752}
753
755{
757
758 if ( mMaxTerrainGroundError == error )
759 return;
760
761 mMaxTerrainGroundError = error;
763}
764
766{
768
769 if ( mTerrainElevationOffset == offset )
770 return;
771 mTerrainElevationOffset = offset;
772 emit terrainElevationOffsetChanged( mTerrainElevationOffset );
773}
774
776{
778
779 return mTerrainElevationOffset;
780}
781
783{
785
786 return mMaxTerrainGroundError;
787}
788
790{
792
793 if ( mTerrainGenerator )
794 {
795 disconnect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
796 }
797
798 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, gen->crs(), mTransformContext );
799 gen->setExtent( terrainExtent );
800 mTerrainGenerator.reset( gen );
801 connect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
802
804}
805
807{
809
810 return mTerrainGenerator.get();
811}
812
814{
816
817 if ( mTerrainShadingEnabled == enabled )
818 return;
819
820 mTerrainShadingEnabled = enabled;
822}
823
825{
827
828 return mTerrainShadingEnabled;
829}
830
832{
834
835 if ( mTerrainShadingMaterial == material )
836 return;
837
838 mTerrainShadingMaterial = material;
840}
841
848
849void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
850{
852
853 if ( mTerrainMapTheme == theme )
854 return;
855
856 mTerrainMapTheme = theme;
858}
859
861{
863
864 return mTerrainMapTheme;
865}
866
868{
870
871 if ( mShowTerrainBoundingBoxes == enabled )
872 return;
873
874 mShowTerrainBoundingBoxes = enabled;
876}
877
879{
881
882 return mShowTerrainBoundingBoxes;
883}
884
885
887{
889
890 if ( mShowTerrainTileInfo == enabled )
891 return;
892
893 mShowTerrainTileInfo = enabled;
895}
896
898{
900
901 return mShowTerrainTileInfo;
902}
903
905{
907
908 if ( mShowCameraViewCenter == enabled )
909 return;
910
911 mShowCameraViewCenter = enabled;
913}
914
916{
918
919 return mShowCameraViewCenter;
920}
921
923{
925
926 if ( mShowCameraRotationCenter == enabled )
927 return;
928
929 mShowCameraRotationCenter = enabled;
931}
932
934{
936
937 return mShowCameraRotationCenter;
938}
939
941{
943
944 if ( mShowLightSources == enabled )
945 return;
946
947 mShowLightSources = enabled;
949}
950
952{
954
955 return mShowLightSources;
956}
957
959{
961
962 if ( mShowLabels == enabled )
963 return;
964
965 mShowLabels = enabled;
966 emit showLabelsChanged();
967}
968
970{
972
973 return mShowLabels;
974}
975
977{
979
980 if ( mEyeDomeLightingEnabled == enabled )
981 return;
982 mEyeDomeLightingEnabled = enabled;
984}
985
987{
989
990 return mEyeDomeLightingEnabled;
991}
992
994{
996
997 if ( mEyeDomeLightingStrength == strength )
998 return;
999 mEyeDomeLightingStrength = strength;
1001}
1002
1004{
1006
1007 return mEyeDomeLightingStrength;
1008}
1009
1011{
1013
1014 if ( mEyeDomeLightingDistance == distance )
1015 return;
1016 mEyeDomeLightingDistance = distance;
1018}
1019
1021{
1023
1024 return mEyeDomeLightingDistance;
1025}
1026
1027QList<QgsLightSource *> Qgs3DMapSettings::lightSources() const
1028{
1030
1031 return mLightSources;
1032}
1033
1034void Qgs3DMapSettings::setLightSources( const QList<QgsLightSource *> &lights )
1035{
1037
1038 // have lights actually changed?
1039 if ( mLightSources.count() == lights.count() )
1040 {
1041 bool same = true;
1042 for ( int i = 0; i < mLightSources.count(); ++i )
1043 {
1044 if ( mLightSources[i]->type() == lights[i]->type() )
1045 {
1046 switch ( mLightSources[i]->type() )
1047 {
1049 if ( *static_cast< QgsPointLightSettings * >( mLightSources[i] ) == *static_cast< QgsPointLightSettings * >( lights[i] ) )
1050 continue;
1051 break;
1053 if ( *static_cast< QgsDirectionalLightSettings * >( mLightSources[i] ) == *static_cast< QgsDirectionalLightSettings * >( lights[i] ) )
1054 continue;
1055 break;
1056 }
1057 }
1058 same = false;
1059 break;
1060 }
1061 if ( same )
1062 {
1063 qDeleteAll( lights );
1064 return;
1065 }
1066 }
1067
1068 qDeleteAll( mLightSources );
1069 mLightSources = lights;
1070
1072 emit pointLightsChanged();
1073 emit lightSourcesChanged();
1074}
1075
1077{
1079
1080 return mFieldOfView;
1081}
1082
1083void Qgs3DMapSettings::setFieldOfView( const float fieldOfView )
1084{
1086
1087 if ( mFieldOfView == fieldOfView )
1088 return;
1089
1090 mFieldOfView = fieldOfView;
1091 emit fieldOfViewChanged();
1092}
1093
1094Qt3DRender::QCameraLens::ProjectionType Qgs3DMapSettings::projectionType() const
1095{
1097
1098 return mProjectionType;
1099}
1100
1101void Qgs3DMapSettings::setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType )
1102{
1104
1105 if ( mProjectionType == projectionType )
1106 return;
1107
1108 mProjectionType = projectionType;
1109 emit projectionTypeChanged();
1110}
1111
1113{
1115
1116 return mCameraNavigationMode;
1117}
1118
1120{
1122
1123 if ( mCameraNavigationMode == navigationMode )
1124 return;
1125
1126 mCameraNavigationMode = navigationMode;
1128}
1129
1131{
1133
1134 return mCameraMovementSpeed;
1135}
1136
1138{
1140
1141 if ( mCameraMovementSpeed == movementSpeed )
1142 return;
1143
1144 mCameraMovementSpeed = movementSpeed;
1146}
1147
1148void Qgs3DMapSettings::setOutputDpi( const double dpi )
1149{
1151
1152 mDpi = dpi;
1153}
1154
1156{
1158
1159 return mDpi;
1160}
1161
1163{
1165
1166 return mSkyboxSettings;
1167}
1168
1170{
1172
1173 return mShadowSettings;
1174}
1175
1177{
1179
1180 return mAmbientOcclusionSettings;
1181}
1182
1184{
1186
1187 mSkyboxSettings = skyboxSettings;
1188 emit skyboxSettingsChanged();
1189}
1190
1192{
1194
1195 mShadowSettings = shadowSettings;
1196 emit shadowSettingsChanged();
1197}
1198
1200{
1202
1203 mAmbientOcclusionSettings = ambientOcclusionSettings;
1205}
1206
1208{
1210
1211 return mIsSkyboxEnabled;
1212}
1213
1215{
1217
1218 mIsSkyboxEnabled = enabled;
1219}
1220
1222{
1224
1225 return mIsFpsCounterEnabled;
1226}
1227
1228void Qgs3DMapSettings::setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size )
1229{
1231
1232 mDebugShadowMapEnabled = enabled;
1233 mDebugShadowMapCorner = corner;
1234 mDebugShadowMapSize = size;
1236}
1237
1239{
1241
1242 return mDebugShadowMapEnabled;
1243}
1244
1246{
1248
1249 return mDebugShadowMapCorner;
1250}
1251
1253{
1255
1256 return mDebugShadowMapSize;
1257}
1258
1259void Qgs3DMapSettings::setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size )
1260{
1262
1263 mDebugDepthMapEnabled = enabled;
1264 mDebugDepthMapCorner = corner;
1265 mDebugDepthMapSize = size;
1267}
1268
1270{
1272
1273 return mDebugDepthMapEnabled;
1274}
1275
1277{
1279
1280 return mDebugDepthMapCorner;
1281}
1282
1284{
1286
1287 return mDebugDepthMapSize;
1288}
1289
1290void Qgs3DMapSettings::setIsFpsCounterEnabled( bool fpsCounterEnabled )
1291{
1293
1294 if ( fpsCounterEnabled == mIsFpsCounterEnabled )
1295 return;
1296 mIsFpsCounterEnabled = fpsCounterEnabled;
1297 emit fpsCounterEnabledChanged( mIsFpsCounterEnabled );
1298}
1299
1301{
1303
1304 return mTerrainRenderingEnabled;
1305}
1306
1307void Qgs3DMapSettings::setTerrainRenderingEnabled( bool terrainRenderingEnabled )
1308{
1310
1311 if ( terrainRenderingEnabled == mTerrainRenderingEnabled )
1312 return;
1313 mTerrainRenderingEnabled = terrainRenderingEnabled;
1315}
1316
1318{
1320
1321 return mRendererUsage;
1322}
1323
1325{
1327
1328 mRendererUsage = rendererUsage;
1329}
1330
1337
1339{
1341
1342 mViewSyncMode = mode;
1343}
1344
1346{
1348
1349 return mVisualizeViewFrustum;
1350}
1351
1353{
1355
1356 if ( mVisualizeViewFrustum != enabled )
1357 {
1358 mVisualizeViewFrustum = enabled;
1360 }
1361}
1362
1364{
1366
1367 return m3dAxisSettings;
1368}
1369
1370void Qgs3DMapSettings::setIsDebugOverlayEnabled( bool debugOverlayEnabled )
1371{
1373
1374 if ( debugOverlayEnabled == mIsDebugOverlayEnabled )
1375 return;
1376
1377 mIsDebugOverlayEnabled = debugOverlayEnabled;
1378 emit debugOverlayEnabledChanged( mIsDebugOverlayEnabled );
1379}
1380
1382{
1384
1385 return mShowExtentIn2DView;
1386}
1387
1388void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
1389{
1391
1425}
1426
1427
1428void Qgs3DMapSettings::set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force )
1429{
1431
1432 if ( axisSettings == m3dAxisSettings )
1433 {
1434 if ( force )
1435 {
1436 // ie. refresh. We need to disconnect and to reconnect to avoid 'dirty' project
1438 emit axisSettingsChanged();
1440 }
1441 }
1442 else
1443 {
1444 m3dAxisSettings = axisSettings;
1445 emit axisSettingsChanged();
1446 }
1447}
1448
1450{
1452
1453 return mIsDebugOverlayEnabled;
1454}
1455
1457{
1459
1460 if ( show == mShowExtentIn2DView )
1461 return;
1462
1463 mShowExtentIn2DView = show;
1465}
QFlags< ViewSyncModeFlag > ViewSyncModeFlags
Definition qgis.h:3204
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:3842
@ 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:3186
@ 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.
void mapTileResolutionChanged()
Emitted when the map tile resoulution has changed.
void terrainVerticalScaleChanged()
Emitted when the vertical scale of the terrain has changed.
bool isDebugOverlayEnabled() const
Returns whether debug overlay is enabled.
Qt::Corner debugDepthMapCorner() const
Returns the corner where the shadow map preview is displayed.
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.
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.
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.
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.
void cameraNavigationModeChanged()
Emitted when the camera navigation mode was changed.
void shadowSettingsChanged()
Emitted when shadow rendering settings are changed.
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)
float maxTerrainGroundError() const
Returns maximum ground error of terrain tiles in world units.
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.
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.
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 setMaxTerrainGroundError(float error)
Returns maximum ground error of terrain tiles in world units.
void setSkyboxSettings(const QgsSkyboxSettings &skyboxSettings)
Sets the current configuration of the skybox.
void skyboxSettingsChanged()
Emitted when skybox settings are changed.
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.
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.
void setTerrainElevationOffset(float offset)
Sets the terrain elevation offset (used to move the terrain up or down)
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.
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.
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)
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)
void setDebugShadowMapSettings(bool enabled, Qt::Corner corner, double size)
Sets the debugging settings of the shadow map.
float terrainElevationOffset() const
Returns the elevation offset of the terrain (used to move the terrain up or down)
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 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 maxTerrainScreenErrorChanged()
Emitted when the maximum terrain screen error has changed.
void setShowCameraViewCenter(bool enabled)
Sets whether to show camera's view center as a sphere (for debugging)
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 set3DAxisSettings(const Qgs3DAxisSettings &axisSettings, bool force=false)
Sets the current configuration of 3d axis.
void setCameraMovementSpeed(double movementSpeed)
Sets the camera movement speed.
void terrainElevationOffsetChanged(float newElevation)
Emitted when the terrain elevation offset is changed.
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.
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.
void setMaxTerrainScreenError(float error)
Sets maximum allowed screen error of terrain tiles in pixels.
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.
float maxTerrainScreenError() const
Returns maximum allowed screen error of terrain tiles in pixels.
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.
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.
void maxTerrainGroundErrorChanged()
Emitted when the maximum terrain ground error 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 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 and turns (x,y,z) into (x,...
static QgsVector3D mapToWorldCoordinates(const QgsVector3D &mapCoords, const QgsVector3D &origin)
Converts map coordinates to 3D world coordinates (applies offset and turns (x,y,z) into (x,...
virtual QString type() const =0
Returns the unique type ID string for the provider.
double offset() const
Returns the vertical offset value, used for adjusting the heights from the terrain provider.
double scale() const
Returns the vertical scale factor, which can be used to exaggerate vertical heights.
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 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.
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets CRS of the terrain.
void setLayer(QgsRasterLayer *layer)
Sets raster layer with elevation model to be used for terrain generation.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets CRS of the terrain.
static QgsLightSource * createFromXml(const QDomElement &element, const QgsReadWriteContext &context)
Creates a new light source from an XML element.
Base class for all map layer types.
Definition qgsmaplayer.h:76
Container class that allows storage of map themes consisting of visible map layers and layer styles.
A terrain provider that uses the Z values of a mesh layer to build a terrain surface.
QgsMeshLayer * layer() const
Returns the mesh layer to be used as the terrain source.
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets CRS of the terrain.
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.
QgsAbstractTerrainProvider * terrainProvider()
Returns the project's terrain provider.
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...
A terrain provider where the terrain source is a raster DEM layer.
QgsRasterLayer * layer() const
Returns the raster layer with elevation model to be used as the terrain source.
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() const
Returns the x minimum value (left side of rectangle).
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QgsPointXY center() const
Returns the center point of the rectangle.
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)
QgsCoordinateReferenceSystem crs() const
Returns CRS of the terrain.
virtual void setExtent(const QgsRectangle &extent)
sets the extent of the terrain in terrain's CRS
static QString typeToString(Type type)
Converts terrain generator type enumeration into a string.
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
_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.