QGIS API Documentation  3.6.0-Noosa (5873452)
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 "quantizedmeshterraingenerator.h"
23 #include "qgsmeshlayer3drenderer.h"
24 
25 #include <QDomDocument>
26 #include <QDomElement>
27 
28 #include "qgssymbollayerutils.h"
29 #include "qgsrasterlayer.h"
30 
32  : QObject( nullptr )
33  , mOrigin( other.mOrigin )
34  , mCrs( other.mCrs )
35  , mBackgroundColor( other.mBackgroundColor )
36  , mTerrainVerticalScale( other.mTerrainVerticalScale )
37  , mTerrainGenerator( other.mTerrainGenerator ? other.mTerrainGenerator->clone() : nullptr )
38  , mMapTileResolution( other.mMapTileResolution )
39  , mMaxTerrainScreenError( other.mMaxTerrainScreenError )
40  , mMaxTerrainGroundError( other.mMaxTerrainGroundError )
41  , mTerrainShadingEnabled( other.mTerrainShadingEnabled )
42  , mTerrainShadingMaterial( other.mTerrainShadingMaterial )
43  , mTerrainMapTheme( other.mTerrainMapTheme )
44  , mShowTerrainBoundingBoxes( other.mShowTerrainBoundingBoxes )
45  , mShowTerrainTileInfo( other.mShowTerrainTileInfo )
46  , mShowCameraViewCenter( other.mShowCameraViewCenter )
47  , mShowLabels( other.mShowLabels )
48  , mPointLights( other.mPointLights )
49  , mLayers( other.mLayers )
50  , mSkyboxEnabled( other.mSkyboxEnabled )
51  , mSkyboxFileBase( other.mSkyboxFileBase )
52  , mSkyboxFileExtension( other.mSkyboxFileExtension )
53  , mTransformContext( other.mTransformContext )
54  , mPathResolver( other.mPathResolver )
55  , mMapThemes( other.mMapThemes )
56 {
57  Q_FOREACH ( QgsAbstract3DRenderer *renderer, other.mRenderers )
58  {
59  mRenderers << renderer->clone();
60  }
61 }
62 
64 {
65  qDeleteAll( mRenderers );
66 }
67 
68 void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
69 {
70  QDomElement elemOrigin = elem.firstChildElement( QStringLiteral( "origin" ) );
71  mOrigin = QgsVector3D(
72  elemOrigin.attribute( QStringLiteral( "x" ) ).toDouble(),
73  elemOrigin.attribute( QStringLiteral( "y" ) ).toDouble(),
74  elemOrigin.attribute( QStringLiteral( "z" ) ).toDouble() );
75 
76  QDomElement elemColor = elem.firstChildElement( QStringLiteral( "color" ) );
77  if ( !elemColor.isNull() )
78  {
79  mBackgroundColor = QgsSymbolLayerUtils::decodeColor( elemColor.attribute( QStringLiteral( "background" ) ) );
80  mSelectionColor = QgsSymbolLayerUtils::decodeColor( elemColor.attribute( QStringLiteral( "selection" ) ) );
81  }
82 
83  QDomElement elemCrs = elem.firstChildElement( QStringLiteral( "crs" ) );
84  mCrs.readXml( elemCrs );
85 
86  QDomElement elemTerrain = elem.firstChildElement( QStringLiteral( "terrain" ) );
87  mTerrainVerticalScale = elemTerrain.attribute( QStringLiteral( "exaggeration" ), QStringLiteral( "1" ) ).toFloat();
88  mMapTileResolution = elemTerrain.attribute( QStringLiteral( "texture-size" ), QStringLiteral( "512" ) ).toInt();
89  mMaxTerrainScreenError = elemTerrain.attribute( QStringLiteral( "max-terrain-error" ), QStringLiteral( "3" ) ).toFloat();
90  mMaxTerrainGroundError = elemTerrain.attribute( QStringLiteral( "max-ground-error" ), QStringLiteral( "1" ) ).toFloat();
91  mTerrainShadingEnabled = elemTerrain.attribute( QStringLiteral( "shading-enabled" ), QStringLiteral( "0" ) ).toInt();
92  QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( QStringLiteral( "shading-material" ) );
93  if ( !elemTerrainShadingMaterial.isNull() )
94  mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial );
95  mTerrainMapTheme = elemTerrain.attribute( QStringLiteral( "map-theme" ) );
96  mShowLabels = elemTerrain.attribute( QStringLiteral( "show-labels" ), QStringLiteral( "0" ) ).toInt();
97 
98  mPointLights.clear();
99  QDomElement elemPointLights = elem.firstChildElement( QStringLiteral( "point-lights" ) );
100  if ( !elemPointLights.isNull() )
101  {
102  QDomElement elemPointLight = elemPointLights.firstChildElement( QStringLiteral( "point-light" ) );
103  while ( !elemPointLight.isNull() )
104  {
105  QgsPointLightSettings pointLight;
106  pointLight.readXml( elemPointLight );
107  mPointLights << pointLight;
108  elemPointLight = elemPointLight.nextSiblingElement( QStringLiteral( "point-light" ) );
109  }
110  }
111  else
112  {
113  // QGIS <= 3.4 did not have light configuration
114  QgsPointLightSettings defaultLight;
115  defaultLight.setPosition( QgsVector3D( 0, 1000, 0 ) );
116  mPointLights << defaultLight;
117  }
118 
119  QDomElement elemMapLayers = elemTerrain.firstChildElement( QStringLiteral( "layers" ) );
120  QDomElement elemMapLayer = elemMapLayers.firstChildElement( QStringLiteral( "layer" ) );
121  QList<QgsMapLayerRef> mapLayers;
122  while ( !elemMapLayer.isNull() )
123  {
124  mapLayers << QgsMapLayerRef( elemMapLayer.attribute( QStringLiteral( "id" ) ) );
125  elemMapLayer = elemMapLayer.nextSiblingElement( QStringLiteral( "layer" ) );
126  }
127  mLayers = mapLayers; // needs to resolve refs afterwards
128 
129  QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( QStringLiteral( "generator" ) );
130  QString terrainGenType = elemTerrainGenerator.attribute( QStringLiteral( "type" ) );
131  if ( terrainGenType == QLatin1String( "dem" ) )
132  {
133  QgsDemTerrainGenerator *demTerrainGenerator = new QgsDemTerrainGenerator;
134  demTerrainGenerator->setCrs( mCrs, mTransformContext );
135  mTerrainGenerator.reset( demTerrainGenerator );
136  }
137  else if ( terrainGenType == QLatin1String( "quantized-mesh" ) )
138  {
139 #if 0
141 #endif
142  Q_ASSERT( false ); // currently disabled
143  }
144  else // "flat"
145  {
147  flatGen->setCrs( mCrs );
148  mTerrainGenerator.reset( flatGen );
149  }
150  mTerrainGenerator->readXml( elemTerrainGenerator );
151 
152  qDeleteAll( mRenderers );
153  mRenderers.clear();
154 
155  QDomElement elemRenderers = elem.firstChildElement( QStringLiteral( "renderers" ) );
156  QDomElement elemRenderer = elemRenderers.firstChildElement( QStringLiteral( "renderer" ) );
157  while ( !elemRenderer.isNull() )
158  {
159  QgsAbstract3DRenderer *renderer = nullptr;
160  QString type = elemRenderer.attribute( QStringLiteral( "type" ) );
161  if ( type == QLatin1String( "vector" ) )
162  {
163  renderer = new QgsVectorLayer3DRenderer;
164  }
165  else if ( type == QLatin1String( "mesh" ) )
166  {
167  renderer = new QgsMeshLayer3DRenderer;
168  }
169 
170  if ( renderer )
171  {
172  renderer->readXml( elemRenderer, context );
173  mRenderers.append( renderer );
174  }
175  elemRenderer = elemRenderer.nextSiblingElement( QStringLiteral( "renderer" ) );
176  }
177 
178  QDomElement elemSkybox = elem.firstChildElement( QStringLiteral( "skybox" ) );
179  mSkyboxEnabled = elemSkybox.attribute( QStringLiteral( "enabled" ), QStringLiteral( "0" ) ).toInt();
180  mSkyboxFileBase = elemSkybox.attribute( QStringLiteral( "file-base" ) );
181  mSkyboxFileExtension = elemSkybox.attribute( QStringLiteral( "file-ext" ) );
182 
183  QDomElement elemDebug = elem.firstChildElement( QStringLiteral( "debug" ) );
184  mShowTerrainBoundingBoxes = elemDebug.attribute( QStringLiteral( "bounding-boxes" ), QStringLiteral( "0" ) ).toInt();
185  mShowTerrainTileInfo = elemDebug.attribute( QStringLiteral( "terrain-tile-info" ), QStringLiteral( "0" ) ).toInt();
186  mShowCameraViewCenter = elemDebug.attribute( QStringLiteral( "camera-view-center" ), QStringLiteral( "0" ) ).toInt();
187 }
188 
189 QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const
190 {
191  QDomElement elem = doc.createElement( QStringLiteral( "qgis3d" ) );
192 
193  QDomElement elemOrigin = doc.createElement( QStringLiteral( "origin" ) );
194  elemOrigin.setAttribute( QStringLiteral( "x" ), QString::number( mOrigin.x() ) );
195  elemOrigin.setAttribute( QStringLiteral( "y" ), QString::number( mOrigin.y() ) );
196  elemOrigin.setAttribute( QStringLiteral( "z" ), QString::number( mOrigin.z() ) );
197  elem.appendChild( elemOrigin );
198 
199  QDomElement elemColor = doc.createElement( QStringLiteral( "color" ) );
200  elemColor.setAttribute( QStringLiteral( "background" ), QgsSymbolLayerUtils::encodeColor( mBackgroundColor ) );
201  elemColor.setAttribute( QStringLiteral( "selection" ), QgsSymbolLayerUtils::encodeColor( mSelectionColor ) );
202  elem.appendChild( elemColor );
203 
204  QDomElement elemCrs = doc.createElement( QStringLiteral( "crs" ) );
205  mCrs.writeXml( elemCrs, doc );
206  elem.appendChild( elemCrs );
207 
208  QDomElement elemTerrain = doc.createElement( QStringLiteral( "terrain" ) );
209  elemTerrain.setAttribute( QStringLiteral( "exaggeration" ), QString::number( mTerrainVerticalScale ) );
210  elemTerrain.setAttribute( QStringLiteral( "texture-size" ), mMapTileResolution );
211  elemTerrain.setAttribute( QStringLiteral( "max-terrain-error" ), QString::number( mMaxTerrainScreenError ) );
212  elemTerrain.setAttribute( QStringLiteral( "max-ground-error" ), QString::number( mMaxTerrainGroundError ) );
213  elemTerrain.setAttribute( QStringLiteral( "shading-enabled" ), mTerrainShadingEnabled ? 1 : 0 );
214  QDomElement elemTerrainShadingMaterial = doc.createElement( QStringLiteral( "shading-material" ) );
215  mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial );
216  elemTerrain.appendChild( elemTerrainShadingMaterial );
217  elemTerrain.setAttribute( QStringLiteral( "map-theme" ), mTerrainMapTheme );
218  elemTerrain.setAttribute( QStringLiteral( "show-labels" ), mShowLabels ? 1 : 0 );
219 
220  QDomElement elemPointLights = doc.createElement( QStringLiteral( "point-lights" ) );
221  for ( const QgsPointLightSettings &pointLight : qgis::as_const( mPointLights ) )
222  {
223  QDomElement elemPointLight = pointLight.writeXml( doc );
224  elemPointLights.appendChild( elemPointLight );
225  }
226  elem.appendChild( elemPointLights );
227 
228  QDomElement elemMapLayers = doc.createElement( QStringLiteral( "layers" ) );
229  Q_FOREACH ( const QgsMapLayerRef &layerRef, mLayers )
230  {
231  QDomElement elemMapLayer = doc.createElement( QStringLiteral( "layer" ) );
232  elemMapLayer.setAttribute( QStringLiteral( "id" ), layerRef.layerId );
233  elemMapLayers.appendChild( elemMapLayer );
234  }
235  elemTerrain.appendChild( elemMapLayers );
236  QDomElement elemTerrainGenerator = doc.createElement( QStringLiteral( "generator" ) );
237  elemTerrainGenerator.setAttribute( QStringLiteral( "type" ), QgsTerrainGenerator::typeToString( mTerrainGenerator->type() ) );
238  mTerrainGenerator->writeXml( elemTerrainGenerator );
239  elemTerrain.appendChild( elemTerrainGenerator );
240  elem.appendChild( elemTerrain );
241 
242  QDomElement elemRenderers = doc.createElement( QStringLiteral( "renderers" ) );
243  Q_FOREACH ( const QgsAbstract3DRenderer *renderer, mRenderers )
244  {
245  QDomElement elemRenderer = doc.createElement( QStringLiteral( "renderer" ) );
246  elemRenderer.setAttribute( QStringLiteral( "type" ), renderer->type() );
247  renderer->writeXml( elemRenderer, context );
248  elemRenderers.appendChild( elemRenderer );
249  }
250  elem.appendChild( elemRenderers );
251 
252  QDomElement elemSkybox = doc.createElement( QStringLiteral( "skybox" ) );
253  elemSkybox.setAttribute( QStringLiteral( "enabled" ), mSkyboxEnabled ? 1 : 0 );
254  // TODO: use context for relative paths, maybe explicitly list all files(?)
255  elemSkybox.setAttribute( QStringLiteral( "file-base" ), mSkyboxFileBase );
256  elemSkybox.setAttribute( QStringLiteral( "file-ext" ), mSkyboxFileExtension );
257  elem.appendChild( elemSkybox );
258 
259  QDomElement elemDebug = doc.createElement( QStringLiteral( "debug" ) );
260  elemDebug.setAttribute( QStringLiteral( "bounding-boxes" ), mShowTerrainBoundingBoxes ? 1 : 0 );
261  elemDebug.setAttribute( QStringLiteral( "terrain-tile-info" ), mShowTerrainTileInfo ? 1 : 0 );
262  elemDebug.setAttribute( QStringLiteral( "camera-view-center" ), mShowCameraViewCenter ? 1 : 0 );
263  elem.appendChild( elemDebug );
264 
265  return elem;
266 }
267 
269 {
270  for ( int i = 0; i < mLayers.count(); ++i )
271  {
272  QgsMapLayerRef &layerRef = mLayers[i];
273  layerRef.setLayer( project.mapLayer( layerRef.layerId ) );
274  }
275 
276  mTerrainGenerator->resolveReferences( project );
277 
278  for ( int i = 0; i < mRenderers.count(); ++i )
279  {
280  QgsAbstract3DRenderer *renderer = mRenderers[i];
281  renderer->resolveReferences( project );
282  }
283 }
284 
286 {
287  return Qgs3DUtils::mapToWorldCoordinates( mapCoords, mOrigin );
288 }
289 
291 {
292  return Qgs3DUtils::worldToMapCoordinates( worldCoords, mOrigin );
293 }
294 
296 {
297  mCrs = crs;
298 }
299 
301 {
302  return mTransformContext;
303 }
304 
306 {
307  mTransformContext = context;
308 }
309 
310 void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
311 {
312  if ( color == mBackgroundColor )
313  return;
314 
315  mBackgroundColor = color;
316  emit backgroundColorChanged();
317 }
318 
320 {
321  return mBackgroundColor;
322 }
323 
324 void Qgs3DMapSettings::setSelectionColor( const QColor &color )
325 {
326  if ( color == mSelectionColor )
327  return;
328 
329  mSelectionColor = color;
330  emit selectionColorChanged();
331 }
332 
334 {
335  return mSelectionColor;
336 }
337 
339 {
340  if ( zScale == mTerrainVerticalScale )
341  return;
342 
343  mTerrainVerticalScale = zScale;
345 }
346 
348 {
349  return mTerrainVerticalScale;
350 }
351 
352 void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
353 {
354  QList<QgsMapLayerRef> lst;
355  lst.reserve( layers.count() );
356  Q_FOREACH ( QgsMapLayer *layer, layers )
357  {
358  lst.append( layer );
359  }
360 
361  if ( mLayers == lst )
362  return;
363 
364  mLayers = lst;
365  emit layersChanged();
366 }
367 
368 QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
369 {
370  QList<QgsMapLayer *> lst;
371  lst.reserve( mLayers.count() );
372  Q_FOREACH ( const QgsMapLayerRef &layerRef, mLayers )
373  {
374  if ( layerRef.layer )
375  lst.append( layerRef.layer );
376  }
377  return lst;
378 }
379 
381 {
382  if ( mMapTileResolution == res )
383  return;
384 
385  mMapTileResolution = res;
387 }
388 
390 {
391  return mMapTileResolution;
392 }
393 
395 {
396  if ( mMaxTerrainScreenError == error )
397  return;
398 
399  mMaxTerrainScreenError = error;
401 }
402 
404 {
405  return mMaxTerrainScreenError;
406 }
407 
409 {
410  if ( mMaxTerrainGroundError == error )
411  return;
412 
413  mMaxTerrainGroundError = error;
415 }
416 
418 {
419  return mMaxTerrainGroundError;
420 }
421 
423 {
424  mTerrainGenerator.reset( gen );
426 }
427 
429 {
430  if ( mTerrainShadingEnabled == enabled )
431  return;
432 
433  mTerrainShadingEnabled = enabled;
434  emit terrainShadingChanged();
435 }
436 
438 {
439  if ( mTerrainShadingMaterial == material )
440  return;
441 
442  mTerrainShadingMaterial = material;
443  emit terrainShadingChanged();
444 }
445 
446 void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
447 {
448  if ( mTerrainMapTheme == theme )
449  return;
450 
451  mTerrainMapTheme = theme;
452  emit terrainMapThemeChanged();
453 }
454 
455 void Qgs3DMapSettings::setRenderers( const QList<QgsAbstract3DRenderer *> &renderers )
456 {
457  mRenderers = renderers;
458 }
459 
461 {
462  if ( mShowTerrainBoundingBoxes == enabled )
463  return;
464 
465  mShowTerrainBoundingBoxes = enabled;
467 }
468 
470 {
471  if ( mShowTerrainTileInfo == enabled )
472  return;
473 
474  mShowTerrainTileInfo = enabled;
476 }
477 
479 {
480  if ( mShowCameraViewCenter == enabled )
481  return;
482 
483  mShowCameraViewCenter = enabled;
485 }
486 
488 {
489  if ( mShowLabels == enabled )
490  return;
491 
492  mShowLabels = enabled;
493  emit showLabelsChanged();
494 }
495 
496 void Qgs3DMapSettings::setPointLights( const QList<QgsPointLightSettings> &pointLights )
497 {
498  if ( mPointLights == pointLights )
499  return;
500 
501  mPointLights = pointLights;
502  emit pointLightsChanged();
503 }
float maxTerrainScreenError() const
Returns maximum allowed screen error of terrain tiles in pixels.
QList< QgsMapLayer * > layers() const
Returns the list of map layers to be rendered as a texture of the terrain.
The class is used as a container of context for various read/write operations on other objects...
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a DOM element, to be used later with readXml()
3 Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double preci...
Definition: qgsvector3d.h:31
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets coordinate reference system used in the 3D scene.
3 Terrain generator that creates a simple square flat area.
Base class for all map layer types.
Definition: qgsmaplayer.h:64
void maxTerrainGroundErrorChanged()
Emitted when the maximum terrain ground error has changed.
void setTerrainShadingMaterial(const QgsPhongMaterialSettings &material)
Sets terrain shading material.
void setShowCameraViewCenter(bool enabled)
Sets whether to show camera&#39;s view center as a sphere (for debugging)
virtual void resolveReferences(const QgsProject &project)
Resolves references to other objects - second phase of loading - after readXml()
void setTerrainGenerator(QgsTerrainGenerator *gen)
Sets terrain generator.
QColor selectionColor() const
Returns color used for selected features.
_LayerRef< QgsMapLayer > QgsMapLayerRef
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used in the 3D scene.
Base class for all renderers that may to participate in 3D view.
void layersChanged()
Emitted when the list of map layers for terrain texture has changed.
void setShowTerrainTilesInfo(bool enabled)
Sets whether to display extra tile info on top of terrain tiles (for debugging)
void setPointLights(const QList< QgsPointLightSettings > &pointLights)
Sets list of point lights defined in the scene.
3D renderer that renders all mesh triangles of a mesh layer.
void setTerrainShadingEnabled(bool enabled)
Sets whether terrain shading is enabled.
QList< QgsPointLightSettings > pointLights() const
Returns list of point lights defined in the scene.
QgsVector3D worldToMapCoordinates(const QgsVector3D &worldCoords) const
Converts 3D world coordinates to map coordinates (applies offset and turns (x,y,z) into (x...
void terrainVerticalScaleChanged()
Emitted when the vertical scale of the terrain has changed.
3 Basic shading material used for rendering based on the Phong shading model with three color compone...
double y() const
Returns Y coordinate.
Definition: qgsvector3d.h:51
3 Definition of the world
3 Terrain generator using downloaded terrain tiles using quantized mesh specification ...
static QString encodeColor(const QColor &color)
3 Definition of a point light in a 3D map scene
void pointLightsChanged()
Emitted when the list of point lights changes.
float maxTerrainGroundError() const
Returns maximum ground error of terrain tiles in world units.
virtual void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const =0
Writes renderer&#39;s properties to given XML element.
double z() const
Returns Z coordinate.
Definition: qgsvector3d.h:53
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:345
QString layerId
Original layer ID.
void setRenderers(const QList< QgsAbstract3DRenderer *> &renderers)
Sets list of extra 3D renderers to use in the scene. Takes ownership of the objects.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
virtual QString type() const =0
Returns unique identifier of the renderer class (used to identify subclass)
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets CRS of the terrain.
QPointer< TYPE > layer
Weak pointer to map layer.
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which stores various information regarding which datum transfo...
void terrainMapThemeChanged()
Emitted when terrain&#39;s map theme has changed.
void readXml(const QDomElement &elem)
Reads settings from a DOM element.
void showCameraViewCenterChanged()
Emitted when the flag whether camera&#39;s view center is shown has changed.
int mapTileResolution() const
Returns resolution (in pixels) of the texture of a terrain tile.
void selectionColorChanged()
Emitted when the selection color has changed.
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:337
void terrainGeneratorChanged()
Emitted when the terrain generator has changed.
Reads and writes project states.
Definition: qgsproject.h:89
QColor backgroundColor() const
Returns background color of the 3D map view.
void showTerrainBoundingBoxesChanged()
Emitted when the flag whether terrain&#39;s bounding boxes are shown has changed.
Contains information about the context in which a coordinate transform is executed.
static QString typeToString(Type type)
Converts terrain generator type enumeration into a string.
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
void setMaxTerrainGroundError(float error)
Returns maximum ground error of terrain tiles in world units.
void mapTileResolutionChanged()
Emitted when the map tile resoulution has changed.
void setTerrainVerticalScale(double zScale)
Sets vertical scale (exaggeration) of terrain (1 = true scale, > 1 = hills get more pronounced) ...
QgsVector3D mapToWorldCoordinates(const QgsVector3D &mapCoords) const
Converts map coordinates to 3D world coordinates (applies offset and turns (x,y,z) into (x...
3D renderer that renders all features of a vector layer with the same 3D symbol.
void showTerrainTilesInfoChanged()
Emitted when the flag whether terrain&#39;s tile info is shown has changed.
double terrainVerticalScale() const
Returns vertical scale (exaggeration) of terrain.
void writeXml(QDomElement &elem) const
Writes settings to a DOM element.
void setMapTileResolution(int res)
Sets resolution (in pixels) of the texture of a terrain tile.
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)=0
Reads renderer&#39;s properties from given XML element.
Qgs3DMapSettings()=default
Constructor for Qgs3DMapSettings.
void setPosition(const QgsVector3D &pos)
Sets position of the light (in 3D world coordinates)
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.
3 Base class for generators of terrain.
QList< QgsAbstract3DRenderer * > renderers() const
Returns list of extra 3D renderers.
void setBackgroundColor(const QColor &color)
Sets background color of the 3D map view.
3 Implementation of terrain generator that uses a raster layer with DEM to build terrain.
This class represents a coordinate reference system (CRS).
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets CRS of the terrain.
bool readXml(const QDomNode &node)
Restores state from the given DOM node.
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
~Qgs3DMapSettings() override
void setShowLabels(bool enabled)
Sets whether to display labels on terrain tiles.
virtual QgsAbstract3DRenderer * clone() const =0
Returns a cloned instance.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads configuration from a DOM element previously written by writeXml()
void backgroundColorChanged()
Emitted when the background color has changed.
void setLayers(const QList< QgsMapLayer *> &layers)
Sets the list of map layers to be rendered as a texture of the terrain.
void setMaxTerrainScreenError(float error)
Sets maximum allowed screen error of terrain tiles in pixels.
bool writeXml(QDomNode &node, QDomDocument &doc) const
Stores state to the given Dom node in the given document.
void resolveReferences(const QgsProject &project)
Resolves references to other objects (map layers) after the call to readXml()
void setShowTerrainBoundingBoxes(bool enabled)
Sets whether to display bounding boxes of terrain tiles (for debugging)
void setSelectionColor(const QColor &color)
Sets color used for selected features.
void setTerrainMapTheme(const QString &theme)
Sets name of the map theme.
void terrainShadingChanged()
Emitted when terrain shading enabled flag or terrain shading material has changed.
double x() const
Returns X coordinate.
Definition: qgsvector3d.h:49
static QColor decodeColor(const QString &str)
void readXml(const QDomElement &elem)
Reads configuration from a DOM element previously written using writeXml()
QgsTerrainGenerator * terrainGenerator() const
Returns terrain generator. It takes care of producing terrain tiles from the input data...