QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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"
20 #include "qgsdemterraingenerator.h"
21 #include "qgsmeshterraingenerator.h"
24 #include "qgsmeshlayer3drenderer.h"
25 
26 #include <QDomDocument>
27 #include <QDomElement>
28 
29 #include "qgssymbollayerutils.h"
30 #include "qgsrasterlayer.h"
31 
33  : QObject( nullptr )
34  , QgsTemporalRangeObject( other )
35  , mOrigin( other.mOrigin )
36  , mCrs( other.mCrs )
37  , mBackgroundColor( other.mBackgroundColor )
38  , mSelectionColor( other.mSelectionColor )
39  , mTerrainVerticalScale( other.mTerrainVerticalScale )
40  , mTerrainGenerator( other.mTerrainGenerator ? other.mTerrainGenerator->clone() : nullptr )
41  , mMapTileResolution( other.mMapTileResolution )
42  , mMaxTerrainScreenError( other.mMaxTerrainScreenError )
43  , mMaxTerrainGroundError( other.mMaxTerrainGroundError )
44  , mTerrainShadingEnabled( other.mTerrainShadingEnabled )
45  , mTerrainShadingMaterial( other.mTerrainShadingMaterial )
46  , mTerrainMapTheme( other.mTerrainMapTheme )
47  , mShowTerrainBoundingBoxes( other.mShowTerrainBoundingBoxes )
48  , mShowTerrainTileInfo( other.mShowTerrainTileInfo )
49  , mShowCameraViewCenter( other.mShowCameraViewCenter )
50  , mShowLabels( other.mShowLabels )
51  , mPointLights( other.mPointLights )
52  , mFieldOfView( other.mFieldOfView )
53  , mLayers( other.mLayers )
54  , mRenderers() // initialized in body
55  , mSkyboxEnabled( other.mSkyboxEnabled )
56  , mSkyboxFileBase( other.mSkyboxFileBase )
57  , mSkyboxFileExtension( other.mSkyboxFileExtension )
58  , mTransformContext( other.mTransformContext )
59  , mPathResolver( other.mPathResolver )
60  , mMapThemes( other.mMapThemes )
61 {
62  Q_FOREACH ( QgsAbstract3DRenderer *renderer, other.mRenderers )
63  {
64  mRenderers << renderer->clone();
65  }
66 }
67 
69 {
70  qDeleteAll( mRenderers );
71 }
72 
73 void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
74 {
75  QDomElement elemOrigin = elem.firstChildElement( QStringLiteral( "origin" ) );
76  mOrigin = QgsVector3D(
77  elemOrigin.attribute( QStringLiteral( "x" ) ).toDouble(),
78  elemOrigin.attribute( QStringLiteral( "y" ) ).toDouble(),
79  elemOrigin.attribute( QStringLiteral( "z" ) ).toDouble() );
80 
81  QDomElement elemCamera = elem.firstChildElement( QStringLiteral( "camera" ) );
82  if ( !elemCamera.isNull() )
83  {
84  mFieldOfView = elemCamera.attribute( QStringLiteral( "field-of-view" ), QStringLiteral( "45" ) ).toFloat();
85  }
86 
87  QDomElement elemColor = elem.firstChildElement( QStringLiteral( "color" ) );
88  if ( !elemColor.isNull() )
89  {
90  mBackgroundColor = QgsSymbolLayerUtils::decodeColor( elemColor.attribute( QStringLiteral( "background" ) ) );
91  mSelectionColor = QgsSymbolLayerUtils::decodeColor( elemColor.attribute( QStringLiteral( "selection" ) ) );
92  }
93 
94  QDomElement elemCrs = elem.firstChildElement( QStringLiteral( "crs" ) );
95  mCrs.readXml( elemCrs );
96 
97  QDomElement elemTerrain = elem.firstChildElement( QStringLiteral( "terrain" ) );
98  mTerrainVerticalScale = elemTerrain.attribute( QStringLiteral( "exaggeration" ), QStringLiteral( "1" ) ).toFloat();
99  mMapTileResolution = elemTerrain.attribute( QStringLiteral( "texture-size" ), QStringLiteral( "512" ) ).toInt();
100  mMaxTerrainScreenError = elemTerrain.attribute( QStringLiteral( "max-terrain-error" ), QStringLiteral( "3" ) ).toFloat();
101  mMaxTerrainGroundError = elemTerrain.attribute( QStringLiteral( "max-ground-error" ), QStringLiteral( "1" ) ).toFloat();
102  mTerrainShadingEnabled = elemTerrain.attribute( QStringLiteral( "shading-enabled" ), QStringLiteral( "0" ) ).toInt();
103  QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( QStringLiteral( "shading-material" ) );
104  if ( !elemTerrainShadingMaterial.isNull() )
105  mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial );
106  mTerrainMapTheme = elemTerrain.attribute( QStringLiteral( "map-theme" ) );
107  mShowLabels = elemTerrain.attribute( QStringLiteral( "show-labels" ), QStringLiteral( "0" ) ).toInt();
108 
109  mPointLights.clear();
110  QDomElement elemPointLights = elem.firstChildElement( QStringLiteral( "point-lights" ) );
111  if ( !elemPointLights.isNull() )
112  {
113  QDomElement elemPointLight = elemPointLights.firstChildElement( QStringLiteral( "point-light" ) );
114  while ( !elemPointLight.isNull() )
115  {
116  QgsPointLightSettings pointLight;
117  pointLight.readXml( elemPointLight );
118  mPointLights << pointLight;
119  elemPointLight = elemPointLight.nextSiblingElement( QStringLiteral( "point-light" ) );
120  }
121  }
122  else
123  {
124  // QGIS <= 3.4 did not have light configuration
125  QgsPointLightSettings defaultLight;
126  defaultLight.setPosition( QgsVector3D( 0, 1000, 0 ) );
127  mPointLights << defaultLight;
128  }
129 
130  QDomElement elemMapLayers = elemTerrain.firstChildElement( QStringLiteral( "layers" ) );
131  QDomElement elemMapLayer = elemMapLayers.firstChildElement( QStringLiteral( "layer" ) );
132  QList<QgsMapLayerRef> mapLayers;
133  while ( !elemMapLayer.isNull() )
134  {
135  mapLayers << QgsMapLayerRef( elemMapLayer.attribute( QStringLiteral( "id" ) ) );
136  elemMapLayer = elemMapLayer.nextSiblingElement( QStringLiteral( "layer" ) );
137  }
138  mLayers = mapLayers; // needs to resolve refs afterwards
139 
140  QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( QStringLiteral( "generator" ) );
141  QString terrainGenType = elemTerrainGenerator.attribute( QStringLiteral( "type" ) );
142  if ( terrainGenType == QLatin1String( "dem" ) )
143  {
144  QgsDemTerrainGenerator *demTerrainGenerator = new QgsDemTerrainGenerator;
145  demTerrainGenerator->setCrs( mCrs, mTransformContext );
146  mTerrainGenerator.reset( demTerrainGenerator );
147  }
148  else if ( terrainGenType == QLatin1String( "online" ) )
149  {
150  QgsOnlineTerrainGenerator *onlineTerrainGenerator = new QgsOnlineTerrainGenerator;
151  onlineTerrainGenerator->setCrs( mCrs, mTransformContext );
152  mTerrainGenerator.reset( onlineTerrainGenerator );
153  }
154  else if ( terrainGenType == QLatin1String( "mesh" ) )
155  {
156  QgsMeshTerrainGenerator *meshTerrainGenerator = new QgsMeshTerrainGenerator;
157  meshTerrainGenerator->setCrs( mCrs, mTransformContext );
158  mTerrainGenerator.reset( meshTerrainGenerator );
159  }
160  else // "flat"
161  {
163  flatGen->setCrs( mCrs );
164  mTerrainGenerator.reset( flatGen );
165  }
166  mTerrainGenerator->readXml( elemTerrainGenerator );
167 
168  qDeleteAll( mRenderers );
169  mRenderers.clear();
170 
171  QDomElement elemRenderers = elem.firstChildElement( QStringLiteral( "renderers" ) );
172  QDomElement elemRenderer = elemRenderers.firstChildElement( QStringLiteral( "renderer" ) );
173  while ( !elemRenderer.isNull() )
174  {
175  QgsAbstract3DRenderer *renderer = nullptr;
176  QString type = elemRenderer.attribute( QStringLiteral( "type" ) );
177  if ( type == QLatin1String( "vector" ) )
178  {
179  renderer = new QgsVectorLayer3DRenderer;
180  }
181  else if ( type == QLatin1String( "mesh" ) )
182  {
183  renderer = new QgsMeshLayer3DRenderer;
184  }
185 
186  if ( renderer )
187  {
188  renderer->readXml( elemRenderer, context );
189  mRenderers.append( renderer );
190  }
191  elemRenderer = elemRenderer.nextSiblingElement( QStringLiteral( "renderer" ) );
192  }
193 
194  QDomElement elemSkybox = elem.firstChildElement( QStringLiteral( "skybox" ) );
195  mSkyboxEnabled = elemSkybox.attribute( QStringLiteral( "enabled" ), QStringLiteral( "0" ) ).toInt();
196  mSkyboxFileBase = elemSkybox.attribute( QStringLiteral( "file-base" ) );
197  mSkyboxFileExtension = elemSkybox.attribute( QStringLiteral( "file-ext" ) );
198 
199  QDomElement elemDebug = elem.firstChildElement( QStringLiteral( "debug" ) );
200  mShowTerrainBoundingBoxes = elemDebug.attribute( QStringLiteral( "bounding-boxes" ), QStringLiteral( "0" ) ).toInt();
201  mShowTerrainTileInfo = elemDebug.attribute( QStringLiteral( "terrain-tile-info" ), QStringLiteral( "0" ) ).toInt();
202  mShowCameraViewCenter = elemDebug.attribute( QStringLiteral( "camera-view-center" ), QStringLiteral( "0" ) ).toInt();
203 
204  QDomElement elemTemporalRange = elem.firstChildElement( QStringLiteral( "temporal-range" ) );
205  QDateTime start = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "start" ) ), Qt::ISODate );
206  QDateTime end = QDateTime::fromString( elemTemporalRange.attribute( QStringLiteral( "end" ) ), Qt::ISODate );
207  setTemporalRange( QgsDateTimeRange( start, end ) );
208 }
209 
210 QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const
211 {
212  QDomElement elem = doc.createElement( QStringLiteral( "qgis3d" ) );
213 
214  QDomElement elemOrigin = doc.createElement( QStringLiteral( "origin" ) );
215  elemOrigin.setAttribute( QStringLiteral( "x" ), QString::number( mOrigin.x() ) );
216  elemOrigin.setAttribute( QStringLiteral( "y" ), QString::number( mOrigin.y() ) );
217  elemOrigin.setAttribute( QStringLiteral( "z" ), QString::number( mOrigin.z() ) );
218  elem.appendChild( elemOrigin );
219 
220  QDomElement elemCamera = doc.createElement( QStringLiteral( "camera" ) );
221  elemCamera.setAttribute( QStringLiteral( "field-of-view" ), mFieldOfView );
222  elem.appendChild( elemCamera );
223 
224  QDomElement elemColor = doc.createElement( QStringLiteral( "color" ) );
225  elemColor.setAttribute( QStringLiteral( "background" ), QgsSymbolLayerUtils::encodeColor( mBackgroundColor ) );
226  elemColor.setAttribute( QStringLiteral( "selection" ), QgsSymbolLayerUtils::encodeColor( mSelectionColor ) );
227  elem.appendChild( elemColor );
228 
229  QDomElement elemCrs = doc.createElement( QStringLiteral( "crs" ) );
230  mCrs.writeXml( elemCrs, doc );
231  elem.appendChild( elemCrs );
232 
233  QDomElement elemTerrain = doc.createElement( QStringLiteral( "terrain" ) );
234  elemTerrain.setAttribute( QStringLiteral( "exaggeration" ), QString::number( mTerrainVerticalScale ) );
235  elemTerrain.setAttribute( QStringLiteral( "texture-size" ), mMapTileResolution );
236  elemTerrain.setAttribute( QStringLiteral( "max-terrain-error" ), QString::number( mMaxTerrainScreenError ) );
237  elemTerrain.setAttribute( QStringLiteral( "max-ground-error" ), QString::number( mMaxTerrainGroundError ) );
238  elemTerrain.setAttribute( QStringLiteral( "shading-enabled" ), mTerrainShadingEnabled ? 1 : 0 );
239  QDomElement elemTerrainShadingMaterial = doc.createElement( QStringLiteral( "shading-material" ) );
240  mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial );
241  elemTerrain.appendChild( elemTerrainShadingMaterial );
242  elemTerrain.setAttribute( QStringLiteral( "map-theme" ), mTerrainMapTheme );
243  elemTerrain.setAttribute( QStringLiteral( "show-labels" ), mShowLabels ? 1 : 0 );
244 
245  QDomElement elemPointLights = doc.createElement( QStringLiteral( "point-lights" ) );
246  for ( const QgsPointLightSettings &pointLight : qgis::as_const( mPointLights ) )
247  {
248  QDomElement elemPointLight = pointLight.writeXml( doc );
249  elemPointLights.appendChild( elemPointLight );
250  }
251  elem.appendChild( elemPointLights );
252 
253  QDomElement elemMapLayers = doc.createElement( QStringLiteral( "layers" ) );
254  Q_FOREACH ( const QgsMapLayerRef &layerRef, mLayers )
255  {
256  QDomElement elemMapLayer = doc.createElement( QStringLiteral( "layer" ) );
257  elemMapLayer.setAttribute( QStringLiteral( "id" ), layerRef.layerId );
258  elemMapLayers.appendChild( elemMapLayer );
259  }
260  elemTerrain.appendChild( elemMapLayers );
261  QDomElement elemTerrainGenerator = doc.createElement( QStringLiteral( "generator" ) );
262  elemTerrainGenerator.setAttribute( QStringLiteral( "type" ), QgsTerrainGenerator::typeToString( mTerrainGenerator->type() ) );
263  mTerrainGenerator->writeXml( elemTerrainGenerator );
264  elemTerrain.appendChild( elemTerrainGenerator );
265  elem.appendChild( elemTerrain );
266 
267  QDomElement elemRenderers = doc.createElement( QStringLiteral( "renderers" ) );
268  Q_FOREACH ( const QgsAbstract3DRenderer *renderer, mRenderers )
269  {
270  QDomElement elemRenderer = doc.createElement( QStringLiteral( "renderer" ) );
271  elemRenderer.setAttribute( QStringLiteral( "type" ), renderer->type() );
272  renderer->writeXml( elemRenderer, context );
273  elemRenderers.appendChild( elemRenderer );
274  }
275  elem.appendChild( elemRenderers );
276 
277  QDomElement elemSkybox = doc.createElement( QStringLiteral( "skybox" ) );
278  elemSkybox.setAttribute( QStringLiteral( "enabled" ), mSkyboxEnabled ? 1 : 0 );
279  // TODO: use context for relative paths, maybe explicitly list all files(?)
280  elemSkybox.setAttribute( QStringLiteral( "file-base" ), mSkyboxFileBase );
281  elemSkybox.setAttribute( QStringLiteral( "file-ext" ), mSkyboxFileExtension );
282  elem.appendChild( elemSkybox );
283 
284  QDomElement elemDebug = doc.createElement( QStringLiteral( "debug" ) );
285  elemDebug.setAttribute( QStringLiteral( "bounding-boxes" ), mShowTerrainBoundingBoxes ? 1 : 0 );
286  elemDebug.setAttribute( QStringLiteral( "terrain-tile-info" ), mShowTerrainTileInfo ? 1 : 0 );
287  elemDebug.setAttribute( QStringLiteral( "camera-view-center" ), mShowCameraViewCenter ? 1 : 0 );
288  elem.appendChild( elemDebug );
289 
290  QDomElement elemTemporalRange = doc.createElement( QStringLiteral( "temporal-range" ) );
291  elemTemporalRange.setAttribute( QStringLiteral( "start" ), temporalRange().begin().toString( Qt::ISODate ) );
292  elemTemporalRange.setAttribute( QStringLiteral( "end" ), temporalRange().end().toString( Qt::ISODate ) );
293 
294  return elem;
295 }
296 
298 {
299  for ( int i = 0; i < mLayers.count(); ++i )
300  {
301  QgsMapLayerRef &layerRef = mLayers[i];
302  layerRef.setLayer( project.mapLayer( layerRef.layerId ) );
303  }
304 
305  mTerrainGenerator->resolveReferences( project );
306 
307  for ( int i = 0; i < mRenderers.count(); ++i )
308  {
309  QgsAbstract3DRenderer *renderer = mRenderers[i];
310  renderer->resolveReferences( project );
311  }
312 }
313 
315 {
316  return Qgs3DUtils::mapToWorldCoordinates( mapCoords, mOrigin );
317 }
318 
320 {
321  return Qgs3DUtils::worldToMapCoordinates( worldCoords, mOrigin );
322 }
323 
325 {
326  mCrs = crs;
327 }
328 
330 {
331  return mTransformContext;
332 }
333 
335 {
336  mTransformContext = context;
337 }
338 
339 void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
340 {
341  if ( color == mBackgroundColor )
342  return;
343 
344  mBackgroundColor = color;
345  emit backgroundColorChanged();
346 }
347 
349 {
350  return mBackgroundColor;
351 }
352 
353 void Qgs3DMapSettings::setSelectionColor( const QColor &color )
354 {
355  if ( color == mSelectionColor )
356  return;
357 
358  mSelectionColor = color;
359  emit selectionColorChanged();
360 }
361 
363 {
364  return mSelectionColor;
365 }
366 
368 {
369  if ( zScale == mTerrainVerticalScale )
370  return;
371 
372  mTerrainVerticalScale = zScale;
374 }
375 
377 {
378  return mTerrainVerticalScale;
379 }
380 
381 void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
382 {
383  QList<QgsMapLayerRef> lst;
384  lst.reserve( layers.count() );
385  Q_FOREACH ( QgsMapLayer *layer, layers )
386  {
387  lst.append( layer );
388  }
389 
390  if ( mLayers == lst )
391  return;
392 
393  mLayers = lst;
394  emit layersChanged();
395 }
396 
397 QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
398 {
399  QList<QgsMapLayer *> lst;
400  lst.reserve( mLayers.count() );
401  Q_FOREACH ( const QgsMapLayerRef &layerRef, mLayers )
402  {
403  if ( layerRef.layer )
404  lst.append( layerRef.layer );
405  }
406  return lst;
407 }
408 
410 {
411  if ( mMapTileResolution == res )
412  return;
413 
414  mMapTileResolution = res;
416 }
417 
419 {
420  return mMapTileResolution;
421 }
422 
424 {
425  if ( mMaxTerrainScreenError == error )
426  return;
427 
428  mMaxTerrainScreenError = error;
430 }
431 
433 {
434  return mMaxTerrainScreenError;
435 }
436 
438 {
439  if ( mMaxTerrainGroundError == error )
440  return;
441 
442  mMaxTerrainGroundError = error;
444 }
445 
447 {
448  return mMaxTerrainGroundError;
449 }
450 
452 {
453  mTerrainGenerator.reset( gen );
455 }
456 
458 {
459  if ( mTerrainShadingEnabled == enabled )
460  return;
461 
462  mTerrainShadingEnabled = enabled;
463  emit terrainShadingChanged();
464 }
465 
467 {
468  if ( mTerrainShadingMaterial == material )
469  return;
470 
471  mTerrainShadingMaterial = material;
472  emit terrainShadingChanged();
473 }
474 
475 void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
476 {
477  if ( mTerrainMapTheme == theme )
478  return;
479 
480  mTerrainMapTheme = theme;
481  emit terrainMapThemeChanged();
482 }
483 
484 void Qgs3DMapSettings::setRenderers( const QList<QgsAbstract3DRenderer *> &renderers )
485 {
486  qDeleteAll( mRenderers );
487 
488  mRenderers = renderers;
489 
490  emit renderersChanged();
491 }
492 
494 {
495  if ( mShowTerrainBoundingBoxes == enabled )
496  return;
497 
498  mShowTerrainBoundingBoxes = enabled;
500 }
501 
503 {
504  if ( mShowTerrainTileInfo == enabled )
505  return;
506 
507  mShowTerrainTileInfo = enabled;
509 }
510 
512 {
513  if ( mShowCameraViewCenter == enabled )
514  return;
515 
516  mShowCameraViewCenter = enabled;
518 }
519 
521 {
522  if ( mShowLabels == enabled )
523  return;
524 
525  mShowLabels = enabled;
526  emit showLabelsChanged();
527 }
528 
529 void Qgs3DMapSettings::setPointLights( const QList<QgsPointLightSettings> &pointLights )
530 {
531  if ( mPointLights == pointLights )
532  return;
533 
534  mPointLights = pointLights;
535  emit pointLightsChanged();
536 }
537 
538 void Qgs3DMapSettings::setFieldOfView( const float fieldOfView )
539 {
540  if ( mFieldOfView == fieldOfView )
541  return;
542 
543  mFieldOfView = fieldOfView;
544  emit fieldOfViewChanged();
545 }
546 
547 void Qgs3DMapSettings::setSkybox( bool enabled, const QString &fileBase, const QString &fileExtension )
548 {
549  mSkyboxEnabled = enabled;
550  mSkyboxFileBase = fileBase;
551  mSkyboxFileExtension = fileExtension;
552 }
Qgs3DMapSettings::backgroundColorChanged
void backgroundColorChanged()
Emitted when the background color has changed.
Qgs3DMapSettings::crs
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used in the 3D scene.
Definition: qgs3dmapsettings.h:94
QgsSymbolLayerUtils::encodeColor
static QString encodeColor(const QColor &color)
Definition: qgssymbollayerutils.cpp:52
QgsCoordinateTransformContext
Definition: qgscoordinatetransformcontext.h:57
qgsrasterlayer.h
Qgs3DMapSettings::setLayers
void setLayers(const QList< QgsMapLayer * > &layers)
Sets the list of map layers to be rendered as a texture of the terrain.
Definition: qgs3dmapsettings.cpp:381
QgsVectorLayer3DRenderer
Definition: qgsvectorlayer3drenderer.h:60
Qgs3DUtils::mapToWorldCoordinates
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,...
Definition: qgs3dutils.cpp:430
Qgs3DMapSettings::setTerrainShadingMaterial
void setTerrainShadingMaterial(const QgsPhongMaterialSettings &material)
Sets terrain shading material.
Definition: qgs3dmapsettings.cpp:466
QgsReadWriteContext
Definition: qgsreadwritecontext.h:34
Qgs3DMapSettings::worldToMapCoordinates
QgsVector3D worldToMapCoordinates(const QgsVector3D &worldCoords) const
Converts 3D world coordinates to map coordinates (applies offset and turns (x,y,z) into (x,...
Definition: qgs3dmapsettings.cpp:319
Qgs3DMapSettings::selectionColor
QColor selectionColor() const
Returns color used for selected features.
Definition: qgs3dmapsettings.cpp:362
Qgs3DMapSettings::setTerrainGenerator
void setTerrainGenerator(QgsTerrainGenerator *gen)
Sets terrain generator.
Definition: qgs3dmapsettings.cpp:451
Qgs3DMapSettings::maxTerrainGroundError
float maxTerrainGroundError() const
Returns maximum ground error of terrain tiles in world units.
Definition: qgs3dmapsettings.cpp:446
QgsAbstract3DRenderer::type
virtual QString type() const =0
Returns unique identifier of the renderer class (used to identify subclass)
QgsVector3D::y
double y() const
Returns Y coordinate.
Definition: qgsvector3d.h:64
QgsAbstract3DRenderer
Definition: qgsabstract3drenderer.h:48
QgsVector3D
Definition: qgsvector3d.h:31
QgsPointLightSettings::setPosition
void setPosition(const QgsVector3D &pos)
Sets position of the light (in 3D world coordinates)
Definition: qgspointlightsettings.h:47
Qgs3DMapSettings::mapTileResolution
int mapTileResolution() const
Returns resolution (in pixels) of the texture of a terrain tile.
Definition: qgs3dmapsettings.cpp:418
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
Qgs3DMapSettings::showCameraViewCenterChanged
void showCameraViewCenterChanged()
Emitted when the flag whether camera's view center is shown has changed.
qgssymbollayerutils.h
QgsTemporalRangeObject::temporalRange
const QgsDateTimeRange & temporalRange() const
Returns the datetime range for the object.
Definition: qgstemporalrangeobject.cpp:43
Qgs3DMapSettings::mapTileResolutionChanged
void mapTileResolutionChanged()
Emitted when the map tile resoulution has changed.
qgsdemterraingenerator.h
QgsMapLayerRef
_LayerRef< QgsMapLayer > QgsMapLayerRef
Definition: qgsmaplayerref.h:294
Qgs3DMapSettings::resolveReferences
void resolveReferences(const QgsProject &project)
Resolves references to other objects (map layers) after the call to readXml()
Definition: qgs3dmapsettings.cpp:297
Qgs3DMapSettings::terrainGeneratorChanged
void terrainGeneratorChanged()
Emitted when the terrain generator has changed.
QgsProject::mapLayer
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
Definition: qgsproject.cpp:3124
Qgs3DMapSettings::setSelectionColor
void setSelectionColor(const QColor &color)
Sets color used for selected features.
Definition: qgs3dmapsettings.cpp:353
QgsCoordinateReferenceSystem::readXml
bool readXml(const QDomNode &node)
Restores state from the given DOM node.
Definition: qgscoordinatereferencesystem.cpp:1995
QgsSymbolLayerUtils::decodeColor
static QColor decodeColor(const QString &str)
Definition: qgssymbollayerutils.cpp:57
_LayerRef::layer
QPointer< TYPE > layer
Weak pointer to map layer.
Definition: qgsmaplayerref.h:113
Qgs3DMapSettings::transformContext
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
Definition: qgs3dmapsettings.cpp:329
Qgs3DMapSettings::renderersChanged
void renderersChanged()
Emitted when the list of map's extra renderers have been modified.
Qgs3DMapSettings::setTerrainVerticalScale
void setTerrainVerticalScale(double zScale)
Sets vertical scale (exaggeration) of terrain (1 = true scale, > 1 = hills get more pronounced)
Definition: qgs3dmapsettings.cpp:367
QgsProject
Definition: qgsproject.h:92
QgsPhongMaterialSettings
Definition: qgsphongmaterialsettings.h:35
Qgs3DMapSettings::maxTerrainScreenErrorChanged
void maxTerrainScreenErrorChanged()
Emitted when the maximum terrain screen error has changed.
Qgs3DMapSettings::maxTerrainScreenError
float maxTerrainScreenError() const
Returns maximum allowed screen error of terrain tiles in pixels.
Definition: qgs3dmapsettings.cpp:432
QgsAbstract3DRenderer::readXml
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)=0
Reads renderer's properties from given XML element.
_LayerRef::layerId
QString layerId
Original layer ID.
Definition: qgsmaplayerref.h:116
QgsAbstract3DRenderer::resolveReferences
virtual void resolveReferences(const QgsProject &project)
Resolves references to other objects - second phase of loading - after readXml()
Definition: qgsabstract3drenderer.cpp:19
Qgs3DMapSettings::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets coordinate reference system used in the 3D scene.
Definition: qgs3dmapsettings.cpp:324
qgsonlineterraingenerator.h
qgsmeshlayer3drenderer.h
QgsTerrainGenerator
Definition: qgsterraingenerator.h:47
Qgs3DMapSettings::setPointLights
void setPointLights(const QList< QgsPointLightSettings > &pointLights)
Sets list of point lights defined in the scene.
Definition: qgs3dmapsettings.cpp:529
_LayerRef::setLayer
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
Definition: qgsmaplayerref.h:77
Qgs3DMapSettings::setMaxTerrainGroundError
void setMaxTerrainGroundError(float error)
Returns maximum ground error of terrain tiles in world units.
Definition: qgs3dmapsettings.cpp:437
QgsCoordinateReferenceSystem::writeXml
bool writeXml(QDomNode &node, QDomDocument &doc) const
Stores state to the given Dom node in the given document.
Definition: qgscoordinatereferencesystem.cpp:2094
QgsPointLightSettings::readXml
void readXml(const QDomElement &elem)
Reads configuration from a DOM element previously written using writeXml()
Definition: qgspointlightsettings.cpp:37
QgsVector3D::z
double z() const
Returns Z coordinate.
Definition: qgsvector3d.h:66
qgs3dutils.h
Qgs3DMapSettings::setTerrainShadingEnabled
void setTerrainShadingEnabled(bool enabled)
Sets whether terrain shading is enabled.
Definition: qgs3dmapsettings.cpp:457
QgsAbstract3DRenderer::writeXml
virtual void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const =0
Writes renderer's properties to given XML element.
QgsPointLightSettings
Definition: qgspointlightsettings.h:38
Qgs3DMapSettings::backgroundColor
QColor backgroundColor() const
Returns background color of the 3D map view.
Definition: qgs3dmapsettings.cpp:348
QgsTerrainGenerator::typeToString
static QString typeToString(Type type)
Converts terrain generator type enumeration into a string.
Definition: qgsterraingenerator.cpp:59
Qgs3DMapSettings::terrainVerticalScaleChanged
void terrainVerticalScaleChanged()
Emitted when the vertical scale of the terrain has changed.
Qgs3DMapSettings::setMapTileResolution
void setMapTileResolution(int res)
Sets resolution (in pixels) of the texture of a terrain tile.
Definition: qgs3dmapsettings.cpp:409
QgsOnlineTerrainGenerator::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets CRS of the terrain.
Definition: qgsonlineterraingenerator.cpp:91
QgsMeshLayer3DRenderer
Definition: qgsmeshlayer3drenderer.h:59
Qgs3DMapSettings
Definition: qgs3dmapsettings.h:51
Qgs3DMapSettings::setTransformContext
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which stores various information regarding which datum transfo...
Definition: qgs3dmapsettings.cpp:334
Qgs3DMapSettings::fieldOfView
float fieldOfView() const
Returns the camera lens' field of view.
Definition: qgs3dmapsettings.h:338
Qgs3DMapSettings::fieldOfViewChanged
void fieldOfViewChanged()
Emitted when the camera lens field of view changes.
QgsFlatTerrainGenerator
Definition: qgsflatterraingenerator.h:53
Qgs3DMapSettings::pointLightsChanged
void pointLightsChanged()
Emitted when the list of point lights changes.
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsPhongMaterialSettings::readXml
void readXml(const QDomElement &elem)
Reads settings from a DOM element.
Definition: qgsphongmaterialsettings.cpp:21
QgsDemTerrainGenerator
Definition: qgsdemterraingenerator.h:41
Qgs3DMapSettings::setFieldOfView
void setFieldOfView(const float fieldOfView)
Sets the camera lens' field of view.
Definition: qgs3dmapsettings.cpp:538
Qgs3DMapSettings::terrainShadingChanged
void terrainShadingChanged()
Emitted when terrain shading enabled flag or terrain shading material has changed.
Qgs3DMapSettings::Qgs3DMapSettings
Qgs3DMapSettings()=default
Constructor for Qgs3DMapSettings.
qgs3dmapsettings.h
Qgs3DMapSettings::showTerrainBoundingBoxesChanged
void showTerrainBoundingBoxesChanged()
Emitted when the flag whether terrain's bounding boxes are shown has changed.
QgsDemTerrainGenerator::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets CRS of the terrain.
Definition: qgsdemterraingenerator.cpp:38
Qgs3DMapSettings::~Qgs3DMapSettings
~Qgs3DMapSettings() override
Definition: qgs3dmapsettings.cpp:68
Qgs3DMapSettings::setShowCameraViewCenter
void setShowCameraViewCenter(bool enabled)
Sets whether to show camera's view center as a sphere (for debugging)
Definition: qgs3dmapsettings.cpp:511
Qgs3DMapSettings::setShowLabels
void setShowLabels(bool enabled)
Sets whether to display labels on terrain tiles.
Definition: qgs3dmapsettings.cpp:520
QgsAbstract3DRenderer::clone
virtual QgsAbstract3DRenderer * clone() const =0
Returns a cloned instance.
QgsFlatTerrainGenerator::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets CRS of the terrain.
Definition: qgsflatterraingenerator.cpp:136
QgsMapLayer
Definition: qgsmaplayer.h:81
Qgs3DMapSettings::layers
QList< QgsMapLayer * > layers() const
Returns the list of map layers to be rendered as a texture of the terrain.
Definition: qgs3dmapsettings.cpp:397
QgsOnlineTerrainGenerator
Definition: qgsonlineterraingenerator.h:37
Qgs3DMapSettings::setRenderers
void setRenderers(const QList< QgsAbstract3DRenderer * > &renderers)
Sets list of extra 3D renderers to use in the scene. Takes ownership of the objects.
Definition: qgs3dmapsettings.cpp:484
Qgs3DMapSettings::renderers
QList< QgsAbstract3DRenderer * > renderers() const
Returns list of extra 3D renderers.
Definition: qgs3dmapsettings.h:281
Qgs3DMapSettings::writeXml
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a DOM element, to be used later with readXml()
Definition: qgs3dmapsettings.cpp:210
Qgs3DMapSettings::selectionColorChanged
void selectionColorChanged()
Emitted when the selection color has changed.
qgsvectorlayer3drenderer.h
Qgs3DMapSettings::setShowTerrainTilesInfo
void setShowTerrainTilesInfo(bool enabled)
Sets whether to display extra tile info on top of terrain tiles (for debugging)
Definition: qgs3dmapsettings.cpp:502
QgsTemporalRangeObject::setTemporalRange
void setTemporalRange(const QgsDateTimeRange &range)
Sets the temporal range for the object.
Definition: qgstemporalrangeobject.cpp:35
Qgs3DMapSettings::terrainMapThemeChanged
void terrainMapThemeChanged()
Emitted when terrain's map theme has changed.
Qgs3DMapSettings::mapToWorldCoordinates
QgsVector3D mapToWorldCoordinates(const QgsVector3D &mapCoords) const
Converts map coordinates to 3D world coordinates (applies offset and turns (x,y,z) into (x,...
Definition: qgs3dmapsettings.cpp:314
Qgs3DUtils::worldToMapCoordinates
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,...
Definition: qgs3dutils.cpp:438
_LayerRef< QgsMapLayer >
Qgs3DMapSettings::setTerrainMapTheme
void setTerrainMapTheme(const QString &theme)
Sets name of the map theme.
Definition: qgs3dmapsettings.cpp:475
QgsPhongMaterialSettings::writeXml
void writeXml(QDomElement &elem) const
Writes settings to a DOM element.
Definition: qgsphongmaterialsettings.cpp:29
Qgs3DMapSettings::readXml
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads configuration from a DOM element previously written by writeXml()
Definition: qgs3dmapsettings.cpp:73
Qgs3DMapSettings::setMaxTerrainScreenError
void setMaxTerrainScreenError(float error)
Sets maximum allowed screen error of terrain tiles in pixels.
Definition: qgs3dmapsettings.cpp:423
QgsVector3D::x
double x() const
Returns X coordinate.
Definition: qgsvector3d.h:62
qgsflatterraingenerator.h
Qgs3DMapSettings::maxTerrainGroundErrorChanged
void maxTerrainGroundErrorChanged()
Emitted when the maximum terrain ground error has changed.
Qgs3DMapSettings::setShowTerrainBoundingBoxes
void setShowTerrainBoundingBoxes(bool enabled)
Sets whether to display bounding boxes of terrain tiles (for debugging)
Definition: qgs3dmapsettings.cpp:493
QgsTemporalRangeObject
Definition: qgstemporalrangeobject.h:33
Qgs3DMapSettings::pointLights
QList< QgsPointLightSettings > pointLights() const
Returns list of point lights defined in the scene.
Definition: qgs3dmapsettings.h:326
Qgs3DMapSettings::setSkybox
void setSkybox(bool enabled, const QString &fileBase=QString(), const QString &fileExtension=QString())
Sets skybox configuration.
Definition: qgs3dmapsettings.cpp:547
Qgs3DMapSettings::showLabelsChanged
void showLabelsChanged()
Emitted when the flag whether labels are displayed on terrain tiles has changed.
Qgs3DMapSettings::terrainVerticalScale
double terrainVerticalScale() const
Returns vertical scale (exaggeration) of terrain.
Definition: qgs3dmapsettings.cpp:376
Qgs3DMapSettings::layersChanged
void layersChanged()
Emitted when the list of map layers for terrain texture has changed.
Qgs3DMapSettings::showTerrainTilesInfoChanged
void showTerrainTilesInfoChanged()
Emitted when the flag whether terrain's tile info is shown has changed.
Qgs3DMapSettings::setBackgroundColor
void setBackgroundColor(const QColor &color)
Sets background color of the 3D map view.
Definition: qgs3dmapsettings.cpp:339