QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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"
28#include "qgsterrainprovider.h"
29#include "qgslightsource.h"
30#include "qgssymbollayerutils.h"
31#include "qgsrasterlayer.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 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 QDomElement elemExtent = elem.firstChildElement( QStringLiteral( "extent" ) );
131 if ( !elemExtent.isNull() )
132 {
133 mExtent = QgsRectangle(
134 elemExtent.attribute( QStringLiteral( "xMin" ) ).toDouble(),
135 elemExtent.attribute( QStringLiteral( "yMin" ) ).toDouble(),
136 elemExtent.attribute( QStringLiteral( "xMax" ) ).toDouble(),
137 elemExtent.attribute( QStringLiteral( "yMax" ) ).toDouble() );
138
139 mShowExtentIn2DView = elemExtent.attribute( QStringLiteral( "showIn2dView" ), QStringLiteral( "0" ) ).toInt();
140 }
141 else
142 {
144 }
145
146 QDomElement elemCamera = elem.firstChildElement( QStringLiteral( "camera" ) );
147 if ( !elemCamera.isNull() )
148 {
149 mFieldOfView = elemCamera.attribute( QStringLiteral( "field-of-view" ), QStringLiteral( "45" ) ).toFloat();
150 mProjectionType = static_cast< Qt3DRender::QCameraLens::ProjectionType >( elemCamera.attribute( QStringLiteral( "projection-type" ), QStringLiteral( "1" ) ).toInt() );
151 QString cameraNavigationMode = elemCamera.attribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "basic-navigation" ) );
152 if ( cameraNavigationMode == QLatin1String( "terrain-based-navigation" ) )
153 mCameraNavigationMode = Qgis::NavigationMode::TerrainBased;
154 else if ( cameraNavigationMode == QLatin1String( "walk-navigation" ) )
155 mCameraNavigationMode = Qgis::NavigationMode::Walk;
156 mCameraMovementSpeed = elemCamera.attribute( QStringLiteral( "camera-movement-speed" ), QStringLiteral( "5.0" ) ).toDouble();
157 }
158
159 QDomElement elemColor = elem.firstChildElement( QStringLiteral( "color" ) );
160 if ( !elemColor.isNull() )
161 {
162 mBackgroundColor = QgsSymbolLayerUtils::decodeColor( elemColor.attribute( QStringLiteral( "background" ) ) );
163 mSelectionColor = QgsSymbolLayerUtils::decodeColor( elemColor.attribute( QStringLiteral( "selection" ) ) );
164 }
165
166 QDomElement elemCrs = elem.firstChildElement( QStringLiteral( "crs" ) );
167 mCrs.readXml( elemCrs );
168
169 QDomElement elemTerrain = elem.firstChildElement( QStringLiteral( "terrain" ) );
170 mTerrainRenderingEnabled = elemTerrain.attribute( QStringLiteral( "terrain-rendering-enabled" ), QStringLiteral( "1" ) ).toInt();
171 mTerrainVerticalScale = elemTerrain.attribute( QStringLiteral( "exaggeration" ), QStringLiteral( "1" ) ).toFloat();
172 mMapTileResolution = elemTerrain.attribute( QStringLiteral( "texture-size" ), QStringLiteral( "512" ) ).toInt();
173 mMaxTerrainScreenError = elemTerrain.attribute( QStringLiteral( "max-terrain-error" ), QStringLiteral( "3" ) ).toFloat();
174 mMaxTerrainGroundError = elemTerrain.attribute( QStringLiteral( "max-ground-error" ), QStringLiteral( "1" ) ).toFloat();
175 mTerrainShadingEnabled = elemTerrain.attribute( QStringLiteral( "shading-enabled" ), QStringLiteral( "0" ) ).toInt();
176 mTerrainElevationOffset = elemTerrain.attribute( QStringLiteral( "elevation-offset" ), QStringLiteral( "0.0" ) ).toFloat();
177
178 QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( QStringLiteral( "shading-material" ) );
179 if ( !elemTerrainShadingMaterial.isNull() )
180 mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial, context );
181 mTerrainMapTheme = elemTerrain.attribute( QStringLiteral( "map-theme" ) );
182 mShowLabels = elemTerrain.attribute( QStringLiteral( "show-labels" ), QStringLiteral( "0" ) ).toInt();
183
184 qDeleteAll( mLightSources );
185 mLightSources.clear();
186 const QDomElement lightsElem = elem.firstChildElement( QStringLiteral( "lights" ) );
187 if ( !lightsElem.isNull() )
188 {
189 const QDomNodeList lightNodes = lightsElem.childNodes();
190 for ( int i = 0; i < lightNodes.size(); ++i )
191 {
192 const QDomElement lightElement = lightNodes.at( i ).toElement();
193 if ( QgsLightSource *light = QgsLightSource::createFromXml( lightElement, context ) )
194 mLightSources << light;
195 }
196 }
197 else
198 {
199 // older project format
200 QDomElement elemPointLights = elem.firstChildElement( QStringLiteral( "point-lights" ) );
201 if ( !elemPointLights.isNull() )
202 {
203 QDomElement elemPointLight = elemPointLights.firstChildElement( QStringLiteral( "point-light" ) );
204 while ( !elemPointLight.isNull() )
205 {
206 std::unique_ptr< QgsPointLightSettings > pointLight = std::make_unique< QgsPointLightSettings >();
207 pointLight->readXml( elemPointLight, context );
208 mLightSources << pointLight.release();
209 elemPointLight = elemPointLight.nextSiblingElement( QStringLiteral( "point-light" ) );
210 }
211 }
212 else
213 {
214 // QGIS <= 3.4 did not have light configuration
215 std::unique_ptr< QgsPointLightSettings > defaultLight = std::make_unique< QgsPointLightSettings >();
216 defaultLight->setPosition( QgsVector3D( 0, 1000, 0 ) );
217 mLightSources << defaultLight.release();
218 }
219
220 QDomElement elemDirectionalLights = elem.firstChildElement( QStringLiteral( "directional-lights" ) );
221 if ( !elemDirectionalLights.isNull() )
222 {
223 QDomElement elemDirectionalLight = elemDirectionalLights.firstChildElement( QStringLiteral( "directional-light" ) );
224 while ( !elemDirectionalLight.isNull() )
225 {
226 std::unique_ptr< QgsDirectionalLightSettings > directionalLight = std::make_unique< QgsDirectionalLightSettings >();
227 directionalLight->readXml( elemDirectionalLight, context );
228 mLightSources << directionalLight.release();
229 elemDirectionalLight = elemDirectionalLight.nextSiblingElement( QStringLiteral( "directional-light" ) );
230 }
231 }
232 }
233
234 QDomElement elemMapLayers = elemTerrain.firstChildElement( QStringLiteral( "layers" ) );
235 QDomElement elemMapLayer = elemMapLayers.firstChildElement( QStringLiteral( "layer" ) );
236 QList<QgsMapLayerRef> mapLayers;
237 while ( !elemMapLayer.isNull() )
238 {
239 mapLayers << QgsMapLayerRef( elemMapLayer.attribute( QStringLiteral( "id" ) ) );
240 elemMapLayer = elemMapLayer.nextSiblingElement( QStringLiteral( "layer" ) );
241 }
242 mLayers = mapLayers; // needs to resolve refs afterwards
243
244 QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( QStringLiteral( "generator" ) );
245 QString terrainGenType = elemTerrainGenerator.attribute( QStringLiteral( "type" ) );
246 if ( terrainGenType == QLatin1String( "dem" ) )
247 {
248 QgsDemTerrainGenerator *demTerrainGenerator = new QgsDemTerrainGenerator;
249 demTerrainGenerator->setCrs( mCrs, mTransformContext );
250 setTerrainGenerator( demTerrainGenerator );
251 }
252 else if ( terrainGenType == QLatin1String( "online" ) )
253 {
254 QgsOnlineTerrainGenerator *onlineTerrainGenerator = new QgsOnlineTerrainGenerator;
255 onlineTerrainGenerator->setCrs( mCrs, mTransformContext );
256 setTerrainGenerator( onlineTerrainGenerator );
257 }
258 else if ( terrainGenType == QLatin1String( "mesh" ) )
259 {
260 QgsMeshTerrainGenerator *meshTerrainGenerator = new QgsMeshTerrainGenerator;
261 meshTerrainGenerator->setCrs( mCrs, mTransformContext );
262 setTerrainGenerator( meshTerrainGenerator );
263 }
264 else // "flat"
265 {
267 flatGen->setCrs( mCrs );
268 setTerrainGenerator( flatGen );
269 }
270 mTerrainGenerator->readXml( elemTerrainGenerator );
271
272 QDomElement elemSkybox = elem.firstChildElement( QStringLiteral( "skybox" ) );
273 mIsSkyboxEnabled = elemSkybox.attribute( QStringLiteral( "skybox-enabled" ) ).toInt();
274 mSkyboxSettings.readXml( elemSkybox, context );
275
276 QDomElement elemShadows = elem.firstChildElement( QStringLiteral( "shadow-rendering" ) );
277 mShadowSettings.readXml( elemShadows, context );
278
279 QDomElement elemAmbientOcclusion = elem.firstChildElement( QStringLiteral( "screen-space-ambient-occlusion" ) );
280 mAmbientOcclusionSettings.readXml( elemAmbientOcclusion, context );
281
282 QDomElement elemEyeDomeLighting = elem.firstChildElement( QStringLiteral( "eye-dome-lighting" ) );
283 mEyeDomeLightingEnabled = elemEyeDomeLighting.attribute( "enabled", QStringLiteral( "0" ) ).toInt();
284 mEyeDomeLightingStrength = elemEyeDomeLighting.attribute( "eye-dome-lighting-strength", QStringLiteral( "1000.0" ) ).toDouble();
285 mEyeDomeLightingDistance = elemEyeDomeLighting.attribute( "eye-dome-lighting-distance", QStringLiteral( "1" ) ).toInt();
286
287 QDomElement elemNavigationSync = elem.firstChildElement( QStringLiteral( "navigation-sync" ) );
288 mViewSyncMode = ( Qgis::ViewSyncModeFlags )( elemNavigationSync.attribute( QStringLiteral( "view-sync-mode" ), QStringLiteral( "0" ) ).toInt() );
289 mVisualizeViewFrustum = elemNavigationSync.attribute( QStringLiteral( "view-frustum-visualization-enabled" ), QStringLiteral( "0" ) ).toInt();
290
291 QDomElement elemDebugSettings = elem.firstChildElement( QStringLiteral( "debug-settings" ) );
292 mDebugShadowMapEnabled = elemDebugSettings.attribute( QStringLiteral( "shadowmap-enabled" ), QStringLiteral( "0" ) ).toInt();
293 mDebugShadowMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( QStringLiteral( "shadowmap-corner" ), "0" ).toInt() );
294 mDebugShadowMapSize = elemDebugSettings.attribute( QStringLiteral( "shadowmap-size" ), QStringLiteral( "0.2" ) ).toDouble();
295
296 mDebugDepthMapEnabled = elemDebugSettings.attribute( QStringLiteral( "depthmap-enabled" ), QStringLiteral( "0" ) ).toInt();
297 mDebugDepthMapCorner = static_cast<Qt::Corner>( elemDebugSettings.attribute( QStringLiteral( "depthmap-corner" ), QStringLiteral( "1" ) ).toInt() );
298 mDebugDepthMapSize = elemDebugSettings.attribute( QStringLiteral( "depthmap-size" ), QStringLiteral( "0.2" ) ).toDouble();
299
300 QDomElement elemDebug = elem.firstChildElement( QStringLiteral( "debug" ) );
301 mShowTerrainBoundingBoxes = elemDebug.attribute( QStringLiteral( "bounding-boxes" ), QStringLiteral( "0" ) ).toInt();
302 mShowTerrainTileInfo = elemDebug.attribute( QStringLiteral( "terrain-tile-info" ), QStringLiteral( "0" ) ).toInt();
303 mShowCameraViewCenter = elemDebug.attribute( QStringLiteral( "camera-view-center" ), QStringLiteral( "0" ) ).toInt();
304 mShowCameraRotationCenter = elemDebug.attribute( QStringLiteral( "camera-rotation-center" ), QStringLiteral( "0" ) ).toInt();
305 mShowLightSources = elemDebug.attribute( QStringLiteral( "show-light-sources" ), QStringLiteral( "0" ) ).toInt();
306 mIsFpsCounterEnabled = elemDebug.attribute( QStringLiteral( "show-fps-counter" ), QStringLiteral( "0" ) ).toInt();
307
308 QDomElement elemTemporalRange = elem.firstChildElement( QStringLiteral( "temporal-range" ) );
309 QDateTime start = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "start" ) ), Qt::ISODate );
310 QDateTime end = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "end" ) ), Qt::ISODate );
311 setTemporalRange( QgsDateTimeRange( start, end ) );
312
313 QDomElement elem3dAxis = elem.firstChildElement( QStringLiteral( "axis3d" ) );
314 m3dAxisSettings.readXml( elem3dAxis, context );
315
316}
317
318QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const
319{
320 QDomElement elem = doc.createElement( QStringLiteral( "qgis3d" ) );
321
322 QDomElement elemOrigin = doc.createElement( QStringLiteral( "origin" ) );
323 elemOrigin.setAttribute( QStringLiteral( "x" ), QString::number( mOrigin.x() ) );
324 elemOrigin.setAttribute( QStringLiteral( "y" ), QString::number( mOrigin.y() ) );
325 elemOrigin.setAttribute( QStringLiteral( "z" ), QString::number( mOrigin.z() ) );
326 elem.appendChild( elemOrigin );
327
328 QDomElement elemExtent = doc.createElement( QStringLiteral( "extent" ) );
329 elemExtent.setAttribute( QStringLiteral( "xMin" ), mExtent.xMinimum() );
330 elemExtent.setAttribute( QStringLiteral( "yMin" ), mExtent.yMinimum() );
331 elemExtent.setAttribute( QStringLiteral( "xMax" ), mExtent.xMaximum() );
332 elemExtent.setAttribute( QStringLiteral( "yMax" ), mExtent.yMaximum() );
333 elemExtent.setAttribute( QStringLiteral( "showIn2dView" ), mShowExtentIn2DView );
334 elem.appendChild( elemExtent );
335
336 QDomElement elemCamera = doc.createElement( QStringLiteral( "camera" ) );
337 elemCamera.setAttribute( QStringLiteral( "field-of-view" ), mFieldOfView );
338 elemCamera.setAttribute( QStringLiteral( "projection-type" ), static_cast< int >( mProjectionType ) );
339 switch ( mCameraNavigationMode )
340 {
342 elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "terrain-based-navigation" ) );
343 break;
345 elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "walk-navigation" ) );
346 break;
347 }
348 elemCamera.setAttribute( QStringLiteral( "camera-movement-speed" ), mCameraMovementSpeed );
349 elem.appendChild( elemCamera );
350
351 QDomElement elemColor = doc.createElement( QStringLiteral( "color" ) );
352 elemColor.setAttribute( QStringLiteral( "background" ), QgsSymbolLayerUtils::encodeColor( mBackgroundColor ) );
353 elemColor.setAttribute( QStringLiteral( "selection" ), QgsSymbolLayerUtils::encodeColor( mSelectionColor ) );
354 elem.appendChild( elemColor );
355
356 QDomElement elemCrs = doc.createElement( QStringLiteral( "crs" ) );
357 mCrs.writeXml( elemCrs, doc );
358 elem.appendChild( elemCrs );
359
360 QDomElement elemTerrain = doc.createElement( QStringLiteral( "terrain" ) );
361 elemTerrain.setAttribute( QStringLiteral( "terrain-rendering-enabled" ), mTerrainRenderingEnabled ? 1 : 0 );
362 elemTerrain.setAttribute( QStringLiteral( "exaggeration" ), QString::number( mTerrainVerticalScale ) );
363 elemTerrain.setAttribute( QStringLiteral( "texture-size" ), mMapTileResolution );
364 elemTerrain.setAttribute( QStringLiteral( "max-terrain-error" ), QString::number( mMaxTerrainScreenError ) );
365 elemTerrain.setAttribute( QStringLiteral( "max-ground-error" ), QString::number( mMaxTerrainGroundError ) );
366 elemTerrain.setAttribute( QStringLiteral( "shading-enabled" ), mTerrainShadingEnabled ? 1 : 0 );
367 elemTerrain.setAttribute( QStringLiteral( "elevation-offset" ), mTerrainElevationOffset );
368
369 QDomElement elemTerrainShadingMaterial = doc.createElement( QStringLiteral( "shading-material" ) );
370 mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial, context );
371 elemTerrain.appendChild( elemTerrainShadingMaterial );
372 elemTerrain.setAttribute( QStringLiteral( "map-theme" ), mTerrainMapTheme );
373 elemTerrain.setAttribute( QStringLiteral( "show-labels" ), mShowLabels ? 1 : 0 );
374
375 {
376 QDomElement elemLights = doc.createElement( QStringLiteral( "lights" ) );
377 for ( const QgsLightSource *light : mLightSources )
378 {
379 const QDomElement elemLight = light->writeXml( doc, context );
380 elemLights.appendChild( elemLight );
381 }
382 elem.appendChild( elemLights );
383 }
384
385 QDomElement elemMapLayers = doc.createElement( QStringLiteral( "layers" ) );
386 for ( const QgsMapLayerRef &layerRef : mLayers )
387 {
388 QDomElement elemMapLayer = doc.createElement( QStringLiteral( "layer" ) );
389 elemMapLayer.setAttribute( QStringLiteral( "id" ), layerRef.layerId );
390 elemMapLayers.appendChild( elemMapLayer );
391 }
392 elemTerrain.appendChild( elemMapLayers );
393
394 QDomElement elemTerrainGenerator = doc.createElement( QStringLiteral( "generator" ) );
395 elemTerrainGenerator.setAttribute( QStringLiteral( "type" ), QgsTerrainGenerator::typeToString( mTerrainGenerator->type() ) );
396 mTerrainGenerator->writeXml( elemTerrainGenerator );
397 elemTerrain.appendChild( elemTerrainGenerator );
398 elem.appendChild( elemTerrain );
399
400 QDomElement elemSkybox = doc.createElement( QStringLiteral( "skybox" ) );
401 elemSkybox.setAttribute( QStringLiteral( "skybox-enabled" ), mIsSkyboxEnabled );
402 mSkyboxSettings.writeXml( elemSkybox, context );
403 elem.appendChild( elemSkybox );
404
405 QDomElement elemShadows = doc.createElement( QStringLiteral( "shadow-rendering" ) );
406 mShadowSettings.writeXml( elemShadows, context );
407 elem.appendChild( elemShadows );
408
409 QDomElement elemAmbientOcclusion = doc.createElement( QStringLiteral( "screen-space-ambient-occlusion" ) );
410 mAmbientOcclusionSettings.writeXml( elemAmbientOcclusion, context );
411 elem.appendChild( elemAmbientOcclusion );
412
413 QDomElement elemDebug = doc.createElement( QStringLiteral( "debug" ) );
414 elemDebug.setAttribute( QStringLiteral( "bounding-boxes" ), mShowTerrainBoundingBoxes ? 1 : 0 );
415 elemDebug.setAttribute( QStringLiteral( "terrain-tile-info" ), mShowTerrainTileInfo ? 1 : 0 );
416 elemDebug.setAttribute( QStringLiteral( "camera-view-center" ), mShowCameraViewCenter ? 1 : 0 );
417 elemDebug.setAttribute( QStringLiteral( "camera-rotation-center" ), mShowCameraRotationCenter ? 1 : 0 );
418 elemDebug.setAttribute( QStringLiteral( "show-light-sources" ), mShowLightSources ? 1 : 0 );
419 elemDebug.setAttribute( QStringLiteral( "show-fps-counter" ), mIsFpsCounterEnabled ? 1 : 0 );
420 elem.appendChild( elemDebug );
421
422 QDomElement elemEyeDomeLighting = doc.createElement( QStringLiteral( "eye-dome-lighting" ) );
423 elemEyeDomeLighting.setAttribute( QStringLiteral( "enabled" ), mEyeDomeLightingEnabled ? 1 : 0 );
424 elemEyeDomeLighting.setAttribute( QStringLiteral( "eye-dome-lighting-strength" ), mEyeDomeLightingStrength );
425 elemEyeDomeLighting.setAttribute( QStringLiteral( "eye-dome-lighting-distance" ), mEyeDomeLightingDistance );
426 elem.appendChild( elemEyeDomeLighting );
427
428 QDomElement elemNavigationSync = doc.createElement( QStringLiteral( "navigation-sync" ) );
429 elemNavigationSync.setAttribute( QStringLiteral( "view-sync-mode" ), ( int )mViewSyncMode );
430 elemNavigationSync.setAttribute( QStringLiteral( "view-frustum-visualization-enabled" ), mVisualizeViewFrustum ? 1 : 0 );
431 elem.appendChild( elemNavigationSync );
432
433 QDomElement elemDebugSettings = doc.createElement( QStringLiteral( "debug-settings" ) );
434 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-enabled" ), mDebugShadowMapEnabled );
435 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-corner" ), mDebugShadowMapCorner );
436 elemDebugSettings.setAttribute( QStringLiteral( "shadowmap-size" ), mDebugShadowMapSize );
437 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-enabled" ), mDebugDepthMapEnabled );
438 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-corner" ), mDebugDepthMapCorner );
439 elemDebugSettings.setAttribute( QStringLiteral( "depthmap-size" ), mDebugDepthMapSize );
440 elem.appendChild( elemDebugSettings );
441
442 QDomElement elemTemporalRange = doc.createElement( QStringLiteral( "temporal-range" ) );
443 elemTemporalRange.setAttribute( QStringLiteral( "start" ), temporalRange().begin().toString( Qt::ISODate ) );
444 elemTemporalRange.setAttribute( QStringLiteral( "end" ), temporalRange().end().toString( Qt::ISODate ) );
445
446 QDomElement elem3dAxis = doc.createElement( QStringLiteral( "axis3d" ) );
447 m3dAxisSettings.writeXml( elem3dAxis, context );
448 elem.appendChild( elem3dAxis );
449
450 return elem;
451}
452
454{
455 for ( int i = 0; i < mLayers.count(); ++i )
456 {
457 QgsMapLayerRef &layerRef = mLayers[i];
458 layerRef.setLayer( project.mapLayer( layerRef.layerId ) );
459 }
460
461 mTerrainGenerator->resolveReferences( project );
462}
463
465{
466 if ( extent == mExtent )
467 return;
468
469 mExtent = extent;
470 const QgsPointXY center = mExtent.center();
471 setOrigin( QgsVector3D( center.x(), center.y(), 0 ) );
472 if ( mTerrainGenerator )
473 {
474 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, mTerrainGenerator->crs(), mTransformContext );
475 mTerrainGenerator->setExtent( terrainExtent );
476 }
477 emit extentChanged();
478}
479
481{
482 return Qgs3DUtils::mapToWorldCoordinates( mapCoords, mOrigin );
483}
484
486{
487 return Qgs3DUtils::worldToMapCoordinates( worldCoords, mOrigin );
488}
489
494
496{
497 return mTransformContext;
498}
499
501{
502 mTransformContext = context;
503}
504
505void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
506{
507 if ( color == mBackgroundColor )
508 return;
509
510 mBackgroundColor = color;
512}
513
515{
516 return mBackgroundColor;
517}
518
519void Qgs3DMapSettings::setSelectionColor( const QColor &color )
520{
521 if ( color == mSelectionColor )
522 return;
523
524 mSelectionColor = color;
526}
527
529{
530 return mSelectionColor;
531}
532
534{
535 if ( zScale == mTerrainVerticalScale )
536 return;
537
538 mTerrainVerticalScale = zScale;
540}
541
543{
544 return mTerrainVerticalScale;
545}
546
547void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
548{
549 QList<QgsMapLayerRef> lst;
550 lst.reserve( layers.count() );
551 for ( QgsMapLayer *layer : layers )
552 {
553 lst.append( layer );
554 }
555
556 if ( mLayers == lst )
557 return;
558
559 mLayers = lst;
560 emit layersChanged();
561}
562
563QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
564{
565 QList<QgsMapLayer *> lst;
566 lst.reserve( mLayers.count() );
567 for ( const QgsMapLayerRef &layerRef : mLayers )
568 {
569 if ( layerRef.layer )
570 lst.append( layerRef.layer );
571 }
572 return lst;
573}
574
576{
577 setExtent( fullExtent );
578 if ( properties->terrainProvider()->type() == QLatin1String( "flat" ) )
579 {
581 flatTerrain->setCrs( crs() );
582 setTerrainGenerator( flatTerrain );
583
585 }
586 else if ( properties->terrainProvider()->type() == QLatin1String( "raster" ) )
587 {
588 QgsRasterDemTerrainProvider *rasterProvider = qgis::down_cast< QgsRasterDemTerrainProvider * >( properties->terrainProvider() );
589
591 demTerrainGen->setCrs( crs(), QgsProject::instance()->transformContext() );
592 demTerrainGen->setLayer( rasterProvider->layer() );
593 setTerrainGenerator( demTerrainGen );
594
597 }
598 else if ( properties->terrainProvider()->type() == QLatin1String( "mesh" ) )
599 {
600 QgsMeshTerrainProvider *meshProvider = qgis::down_cast< QgsMeshTerrainProvider * >( properties->terrainProvider() );
601
602 QgsMeshTerrainGenerator *newTerrainGenerator = new QgsMeshTerrainGenerator;
603 newTerrainGenerator->setCrs( crs(), QgsProject::instance()->transformContext() );
604 newTerrainGenerator->setLayer( meshProvider->layer() );
605 std::unique_ptr< QgsMesh3DSymbol > symbol( newTerrainGenerator->symbol()->clone() );
606 symbol->setVerticalScale( properties->terrainProvider()->scale() );
607 newTerrainGenerator->setSymbol( symbol.release() );
608 setTerrainGenerator( newTerrainGenerator );
609
612 }
613 else
614 {
616 flatTerrain->setCrs( crs() );
617 setTerrainGenerator( flatTerrain );
618 }
619}
620
622{
623 if ( mMapTileResolution == res )
624 return;
625
626 mMapTileResolution = res;
628}
629
631{
632 return mMapTileResolution;
633}
634
636{
637 if ( mMaxTerrainScreenError == error )
638 return;
639
640 mMaxTerrainScreenError = error;
642}
643
645{
646 return mMaxTerrainScreenError;
647}
648
650{
651 if ( mMaxTerrainGroundError == error )
652 return;
653
654 mMaxTerrainGroundError = error;
656}
657
659{
660 if ( mTerrainElevationOffset == offset )
661 return;
662 mTerrainElevationOffset = offset;
663 emit terrainElevationOffsetChanged( mTerrainElevationOffset );
664}
665
667{
668 return mMaxTerrainGroundError;
669}
670
672{
673 if ( mTerrainGenerator )
674 {
675 disconnect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
676 }
677
678 QgsRectangle terrainExtent = Qgs3DUtils::tryReprojectExtent2D( mExtent, mCrs, gen->crs(), mTransformContext );
679 gen->setExtent( terrainExtent );
680 mTerrainGenerator.reset( gen );
681 connect( mTerrainGenerator.get(), &QgsTerrainGenerator::terrainChanged, this, &Qgs3DMapSettings::terrainGeneratorChanged );
682
684}
685
687{
688 if ( mTerrainShadingEnabled == enabled )
689 return;
690
691 mTerrainShadingEnabled = enabled;
693}
694
696{
697 if ( mTerrainShadingMaterial == material )
698 return;
699
700 mTerrainShadingMaterial = material;
702}
703
704void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
705{
706 if ( mTerrainMapTheme == theme )
707 return;
708
709 mTerrainMapTheme = theme;
711}
712
714{
715 if ( mShowTerrainBoundingBoxes == enabled )
716 return;
717
718 mShowTerrainBoundingBoxes = enabled;
720}
721
723{
724 if ( mShowTerrainTileInfo == enabled )
725 return;
726
727 mShowTerrainTileInfo = enabled;
729}
730
732{
733 if ( mShowCameraViewCenter == enabled )
734 return;
735
736 mShowCameraViewCenter = enabled;
738}
739
741{
742 if ( mShowCameraRotationCenter == enabled )
743 return;
744
745 mShowCameraRotationCenter = enabled;
747}
748
749
751{
752 if ( mShowLightSources == enabled )
753 return;
754
755 mShowLightSources = enabled;
757}
758
760{
761 if ( mShowLabels == enabled )
762 return;
763
764 mShowLabels = enabled;
765 emit showLabelsChanged();
766}
767
769{
770 if ( mEyeDomeLightingEnabled == enabled )
771 return;
772 mEyeDomeLightingEnabled = enabled;
774}
775
777{
778 if ( mEyeDomeLightingStrength == strength )
779 return;
780 mEyeDomeLightingStrength = strength;
782}
783
785{
786 if ( mEyeDomeLightingDistance == distance )
787 return;
788 mEyeDomeLightingDistance = distance;
790}
791
792QList<QgsLightSource *> Qgs3DMapSettings::lightSources() const
793{
794 return mLightSources;
795}
796
797void Qgs3DMapSettings::setLightSources( const QList<QgsLightSource *> &lights )
798{
799 qDeleteAll( mLightSources );
800 mLightSources = lights;
801
803 emit pointLightsChanged();
804 emit lightSourcesChanged();
805}
806
807void Qgs3DMapSettings::setFieldOfView( const float fieldOfView )
808{
809 if ( mFieldOfView == fieldOfView )
810 return;
811
812 mFieldOfView = fieldOfView;
813 emit fieldOfViewChanged();
814}
815
816void Qgs3DMapSettings::setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType )
817{
818 if ( mProjectionType == projectionType )
819 return;
820
821 mProjectionType = projectionType;
823}
824
826{
827 if ( mCameraNavigationMode == navigationMode )
828 return;
829
830 mCameraNavigationMode = navigationMode;
832}
833
835{
836 if ( mCameraMovementSpeed == movementSpeed )
837 return;
838
839 mCameraMovementSpeed = movementSpeed;
841}
842
844{
845 mSkyboxSettings = skyboxSettings;
847}
848
850{
851 mShadowSettings = shadowSettings;
853}
854
856{
857 mAmbientOcclusionSettings = ambientOcclusionSettings;
859}
860
861void Qgs3DMapSettings::setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size )
862{
863 mDebugShadowMapEnabled = enabled;
864 mDebugShadowMapCorner = corner;
865 mDebugShadowMapSize = size;
867}
868
869void Qgs3DMapSettings::setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size )
870{
871 mDebugDepthMapEnabled = enabled;
872 mDebugDepthMapCorner = corner;
873 mDebugDepthMapSize = size;
875}
876
877void Qgs3DMapSettings::setIsFpsCounterEnabled( bool fpsCounterEnabled )
878{
879 if ( fpsCounterEnabled == mIsFpsCounterEnabled )
880 return;
881 mIsFpsCounterEnabled = fpsCounterEnabled;
882 emit fpsCounterEnabledChanged( mIsFpsCounterEnabled );
883}
884
885void Qgs3DMapSettings::setTerrainRenderingEnabled( bool terrainRenderingEnabled )
886{
887 if ( terrainRenderingEnabled == mTerrainRenderingEnabled )
888 return;
889 mTerrainRenderingEnabled = terrainRenderingEnabled;
891}
892
894{
895 return mRendererUsage;
896}
897
899{
900 mRendererUsage = rendererUsage;
901}
902
903void Qgs3DMapSettings::setViewSyncMode( Qgis::ViewSyncModeFlags mode )
904{
905 mViewSyncMode = mode;
906}
907
909{
910 if ( mVisualizeViewFrustum != enabled )
911 {
912 mVisualizeViewFrustum = enabled;
914 }
915}
916
917void Qgs3DMapSettings::setIsDebugOverlayEnabled( bool debugOverlayEnabled )
918{
919 if ( debugOverlayEnabled == mIsDebugOverlayEnabled )
920 return;
921
922 mIsDebugOverlayEnabled = debugOverlayEnabled;
923 emit debugOverlayEnabledChanged( mIsDebugOverlayEnabled );
924}
925
926
927void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
928{
962}
963
964
965void Qgs3DMapSettings::set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force )
966{
967 if ( axisSettings == m3dAxisSettings )
968 {
969 if ( force )
970 {
971 // ie. refresh. We need to disconnect and to reconnect to avoid 'dirty' project
973 emit axisSettingsChanged();
975 }
976 }
977 else
978 {
979 m3dAxisSettings = axisSettings;
980 emit axisSettingsChanged();
981 }
982}
983
985{
986 if ( show == mShowExtentIn2DView )
987 return;
988
989 mShowExtentIn2DView = show;
991}
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:2798
@ 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:2548
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.
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.
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,...
Qt3DRender::QCameraLens::ProjectionType projectionType() const
Returns the camera lens' projection type.
void setEyeDomeLightingEnabled(bool enabled)
Sets whether eye dome lighting will be used.
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.
Qgis::NavigationMode cameraNavigationMode() const
Returns the navigation mode used by the camera.
void backgroundColorChanged()
Emitted when the background color has changed.
void showTerrainBoundingBoxesChanged()
Emitted when the flag whether terrain's bounding boxes are shown has changed.
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.
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 project's CRS, while also setting the scene's origin to the extent's...
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 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.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets coordinate reference system used in the 3D scene.
void setEyeDomeLightingDistance(int distance)
Sets the eye dome lighting distance value (contributes to the contrast of the image.
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 project's CRS.
void setTerrainShadingEnabled(bool enabled)
Sets whether terrain shading is enabled.
void setDebugShadowMapSettings(bool enabled, Qt::Corner corner, double size)
Sets the debugging settings of the shadow map.
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.
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()
QgsVector3D worldToMapCoordinates(const QgsVector3D &worldCoords) const
Converts 3D world coordinates to map coordinates (applies offset and turns (x,y,z) into (x,...
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.
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.
Qgs3DMapSettings()
Constructor for Qgs3DMapSettings.
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.
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.
void cameraMovementSpeedChanged()
Emitted when the camera movement speed was changed.
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used in the 3D scene.
void setRendererUsage(Qgis::RendererUsage rendererUsage)
Sets the renderer usage.
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.
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.
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...
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.
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:74
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.
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:59
double y
Definition qgspointxy.h:63
double x
Definition qgspointxy.h:62
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.
static QColor decodeColor(const QString &str)
static QString encodeColor(const QColor &color)
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:394
T end() const
Returns the upper bound of the range.
Definition qgsrange.h:401
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:32
double y() const
Returns Y coordinate.
Definition qgsvector3d.h:51
double z() const
Returns Z coordinate.
Definition qgsvector3d.h:53
double x() const
Returns X coordinate.
Definition qgsvector3d.h:49
_LayerRef< QgsMapLayer > QgsMapLayerRef
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:694
const QgsCoordinateReferenceSystem & crs
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
QString layerId
Original layer ID.