QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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"
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  , mFieldOfView( other.mFieldOfView )
50  , mLayers( other.mLayers )
51  , mSkyboxEnabled( other.mSkyboxEnabled )
52  , mSkyboxFileBase( other.mSkyboxFileBase )
53  , mSkyboxFileExtension( other.mSkyboxFileExtension )
54  , mTransformContext( other.mTransformContext )
55  , mPathResolver( other.mPathResolver )
56  , mMapThemes( other.mMapThemes )
57 {
58  Q_FOREACH ( QgsAbstract3DRenderer *renderer, other.mRenderers )
59  {
60  mRenderers << renderer->clone();
61  }
62 }
63 
65 {
66  qDeleteAll( mRenderers );
67 }
68 
69 void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
70 {
71  QDomElement elemOrigin = elem.firstChildElement( QStringLiteral( "origin" ) );
72  mOrigin = QgsVector3D(
73  elemOrigin.attribute( QStringLiteral( "x" ) ).toDouble(),
74  elemOrigin.attribute( QStringLiteral( "y" ) ).toDouble(),
75  elemOrigin.attribute( QStringLiteral( "z" ) ).toDouble() );
76 
77  QDomElement elemCamera = elem.firstChildElement( QStringLiteral( "camera" ) );
78  if ( !elemCamera.isNull() )
79  {
80  mFieldOfView = elemCamera.attribute( QStringLiteral( "field-of-view" ), QStringLiteral( "45" ) ).toFloat();
81  }
82 
83  QDomElement elemColor = elem.firstChildElement( QStringLiteral( "color" ) );
84  if ( !elemColor.isNull() )
85  {
86  mBackgroundColor = QgsSymbolLayerUtils::decodeColor( elemColor.attribute( QStringLiteral( "background" ) ) );
87  mSelectionColor = QgsSymbolLayerUtils::decodeColor( elemColor.attribute( QStringLiteral( "selection" ) ) );
88  }
89 
90  QDomElement elemCrs = elem.firstChildElement( QStringLiteral( "crs" ) );
91  mCrs.readXml( elemCrs );
92 
93  QDomElement elemTerrain = elem.firstChildElement( QStringLiteral( "terrain" ) );
94  mTerrainVerticalScale = elemTerrain.attribute( QStringLiteral( "exaggeration" ), QStringLiteral( "1" ) ).toFloat();
95  mMapTileResolution = elemTerrain.attribute( QStringLiteral( "texture-size" ), QStringLiteral( "512" ) ).toInt();
96  mMaxTerrainScreenError = elemTerrain.attribute( QStringLiteral( "max-terrain-error" ), QStringLiteral( "3" ) ).toFloat();
97  mMaxTerrainGroundError = elemTerrain.attribute( QStringLiteral( "max-ground-error" ), QStringLiteral( "1" ) ).toFloat();
98  mTerrainShadingEnabled = elemTerrain.attribute( QStringLiteral( "shading-enabled" ), QStringLiteral( "0" ) ).toInt();
99  QDomElement elemTerrainShadingMaterial = elemTerrain.firstChildElement( QStringLiteral( "shading-material" ) );
100  if ( !elemTerrainShadingMaterial.isNull() )
101  mTerrainShadingMaterial.readXml( elemTerrainShadingMaterial );
102  mTerrainMapTheme = elemTerrain.attribute( QStringLiteral( "map-theme" ) );
103  mShowLabels = elemTerrain.attribute( QStringLiteral( "show-labels" ), QStringLiteral( "0" ) ).toInt();
104 
105  mPointLights.clear();
106  QDomElement elemPointLights = elem.firstChildElement( QStringLiteral( "point-lights" ) );
107  if ( !elemPointLights.isNull() )
108  {
109  QDomElement elemPointLight = elemPointLights.firstChildElement( QStringLiteral( "point-light" ) );
110  while ( !elemPointLight.isNull() )
111  {
112  QgsPointLightSettings pointLight;
113  pointLight.readXml( elemPointLight );
114  mPointLights << pointLight;
115  elemPointLight = elemPointLight.nextSiblingElement( QStringLiteral( "point-light" ) );
116  }
117  }
118  else
119  {
120  // QGIS <= 3.4 did not have light configuration
121  QgsPointLightSettings defaultLight;
122  defaultLight.setPosition( QgsVector3D( 0, 1000, 0 ) );
123  mPointLights << defaultLight;
124  }
125 
126  QDomElement elemMapLayers = elemTerrain.firstChildElement( QStringLiteral( "layers" ) );
127  QDomElement elemMapLayer = elemMapLayers.firstChildElement( QStringLiteral( "layer" ) );
128  QList<QgsMapLayerRef> mapLayers;
129  while ( !elemMapLayer.isNull() )
130  {
131  mapLayers << QgsMapLayerRef( elemMapLayer.attribute( QStringLiteral( "id" ) ) );
132  elemMapLayer = elemMapLayer.nextSiblingElement( QStringLiteral( "layer" ) );
133  }
134  mLayers = mapLayers; // needs to resolve refs afterwards
135 
136  QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( QStringLiteral( "generator" ) );
137  QString terrainGenType = elemTerrainGenerator.attribute( QStringLiteral( "type" ) );
138  if ( terrainGenType == QLatin1String( "dem" ) )
139  {
140  QgsDemTerrainGenerator *demTerrainGenerator = new QgsDemTerrainGenerator;
141  demTerrainGenerator->setCrs( mCrs, mTransformContext );
142  mTerrainGenerator.reset( demTerrainGenerator );
143  }
144  else if ( terrainGenType == QLatin1String( "online" ) )
145  {
146  QgsOnlineTerrainGenerator *onlineTerrainGenerator = new QgsOnlineTerrainGenerator;
147  onlineTerrainGenerator->setCrs( mCrs, mTransformContext );
148  mTerrainGenerator.reset( onlineTerrainGenerator );
149  }
150  else // "flat"
151  {
153  flatGen->setCrs( mCrs );
154  mTerrainGenerator.reset( flatGen );
155  }
156  mTerrainGenerator->readXml( elemTerrainGenerator );
157 
158  qDeleteAll( mRenderers );
159  mRenderers.clear();
160 
161  QDomElement elemRenderers = elem.firstChildElement( QStringLiteral( "renderers" ) );
162  QDomElement elemRenderer = elemRenderers.firstChildElement( QStringLiteral( "renderer" ) );
163  while ( !elemRenderer.isNull() )
164  {
165  QgsAbstract3DRenderer *renderer = nullptr;
166  QString type = elemRenderer.attribute( QStringLiteral( "type" ) );
167  if ( type == QLatin1String( "vector" ) )
168  {
169  renderer = new QgsVectorLayer3DRenderer;
170  }
171  else if ( type == QLatin1String( "mesh" ) )
172  {
173  renderer = new QgsMeshLayer3DRenderer;
174  }
175 
176  if ( renderer )
177  {
178  renderer->readXml( elemRenderer, context );
179  mRenderers.append( renderer );
180  }
181  elemRenderer = elemRenderer.nextSiblingElement( QStringLiteral( "renderer" ) );
182  }
183 
184  QDomElement elemSkybox = elem.firstChildElement( QStringLiteral( "skybox" ) );
185  mSkyboxEnabled = elemSkybox.attribute( QStringLiteral( "enabled" ), QStringLiteral( "0" ) ).toInt();
186  mSkyboxFileBase = elemSkybox.attribute( QStringLiteral( "file-base" ) );
187  mSkyboxFileExtension = elemSkybox.attribute( QStringLiteral( "file-ext" ) );
188 
189  QDomElement elemDebug = elem.firstChildElement( QStringLiteral( "debug" ) );
190  mShowTerrainBoundingBoxes = elemDebug.attribute( QStringLiteral( "bounding-boxes" ), QStringLiteral( "0" ) ).toInt();
191  mShowTerrainTileInfo = elemDebug.attribute( QStringLiteral( "terrain-tile-info" ), QStringLiteral( "0" ) ).toInt();
192  mShowCameraViewCenter = elemDebug.attribute( QStringLiteral( "camera-view-center" ), QStringLiteral( "0" ) ).toInt();
193 }
194 
195 QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const
196 {
197  QDomElement elem = doc.createElement( QStringLiteral( "qgis3d" ) );
198 
199  QDomElement elemOrigin = doc.createElement( QStringLiteral( "origin" ) );
200  elemOrigin.setAttribute( QStringLiteral( "x" ), QString::number( mOrigin.x() ) );
201  elemOrigin.setAttribute( QStringLiteral( "y" ), QString::number( mOrigin.y() ) );
202  elemOrigin.setAttribute( QStringLiteral( "z" ), QString::number( mOrigin.z() ) );
203  elem.appendChild( elemOrigin );
204 
205  QDomElement elemCamera = doc.createElement( QStringLiteral( "camera" ) );
206  elemCamera.setAttribute( QStringLiteral( "field-of-view" ), mFieldOfView );
207  elem.appendChild( elemCamera );
208 
209  QDomElement elemColor = doc.createElement( QStringLiteral( "color" ) );
210  elemColor.setAttribute( QStringLiteral( "background" ), QgsSymbolLayerUtils::encodeColor( mBackgroundColor ) );
211  elemColor.setAttribute( QStringLiteral( "selection" ), QgsSymbolLayerUtils::encodeColor( mSelectionColor ) );
212  elem.appendChild( elemColor );
213 
214  QDomElement elemCrs = doc.createElement( QStringLiteral( "crs" ) );
215  mCrs.writeXml( elemCrs, doc );
216  elem.appendChild( elemCrs );
217 
218  QDomElement elemTerrain = doc.createElement( QStringLiteral( "terrain" ) );
219  elemTerrain.setAttribute( QStringLiteral( "exaggeration" ), QString::number( mTerrainVerticalScale ) );
220  elemTerrain.setAttribute( QStringLiteral( "texture-size" ), mMapTileResolution );
221  elemTerrain.setAttribute( QStringLiteral( "max-terrain-error" ), QString::number( mMaxTerrainScreenError ) );
222  elemTerrain.setAttribute( QStringLiteral( "max-ground-error" ), QString::number( mMaxTerrainGroundError ) );
223  elemTerrain.setAttribute( QStringLiteral( "shading-enabled" ), mTerrainShadingEnabled ? 1 : 0 );
224  QDomElement elemTerrainShadingMaterial = doc.createElement( QStringLiteral( "shading-material" ) );
225  mTerrainShadingMaterial.writeXml( elemTerrainShadingMaterial );
226  elemTerrain.appendChild( elemTerrainShadingMaterial );
227  elemTerrain.setAttribute( QStringLiteral( "map-theme" ), mTerrainMapTheme );
228  elemTerrain.setAttribute( QStringLiteral( "show-labels" ), mShowLabels ? 1 : 0 );
229 
230  QDomElement elemPointLights = doc.createElement( QStringLiteral( "point-lights" ) );
231  for ( const QgsPointLightSettings &pointLight : qgis::as_const( mPointLights ) )
232  {
233  QDomElement elemPointLight = pointLight.writeXml( doc );
234  elemPointLights.appendChild( elemPointLight );
235  }
236  elem.appendChild( elemPointLights );
237 
238  QDomElement elemMapLayers = doc.createElement( QStringLiteral( "layers" ) );
239  Q_FOREACH ( const QgsMapLayerRef &layerRef, mLayers )
240  {
241  QDomElement elemMapLayer = doc.createElement( QStringLiteral( "layer" ) );
242  elemMapLayer.setAttribute( QStringLiteral( "id" ), layerRef.layerId );
243  elemMapLayers.appendChild( elemMapLayer );
244  }
245  elemTerrain.appendChild( elemMapLayers );
246  QDomElement elemTerrainGenerator = doc.createElement( QStringLiteral( "generator" ) );
247  elemTerrainGenerator.setAttribute( QStringLiteral( "type" ), QgsTerrainGenerator::typeToString( mTerrainGenerator->type() ) );
248  mTerrainGenerator->writeXml( elemTerrainGenerator );
249  elemTerrain.appendChild( elemTerrainGenerator );
250  elem.appendChild( elemTerrain );
251 
252  QDomElement elemRenderers = doc.createElement( QStringLiteral( "renderers" ) );
253  Q_FOREACH ( const QgsAbstract3DRenderer *renderer, mRenderers )
254  {
255  QDomElement elemRenderer = doc.createElement( QStringLiteral( "renderer" ) );
256  elemRenderer.setAttribute( QStringLiteral( "type" ), renderer->type() );
257  renderer->writeXml( elemRenderer, context );
258  elemRenderers.appendChild( elemRenderer );
259  }
260  elem.appendChild( elemRenderers );
261 
262  QDomElement elemSkybox = doc.createElement( QStringLiteral( "skybox" ) );
263  elemSkybox.setAttribute( QStringLiteral( "enabled" ), mSkyboxEnabled ? 1 : 0 );
264  // TODO: use context for relative paths, maybe explicitly list all files(?)
265  elemSkybox.setAttribute( QStringLiteral( "file-base" ), mSkyboxFileBase );
266  elemSkybox.setAttribute( QStringLiteral( "file-ext" ), mSkyboxFileExtension );
267  elem.appendChild( elemSkybox );
268 
269  QDomElement elemDebug = doc.createElement( QStringLiteral( "debug" ) );
270  elemDebug.setAttribute( QStringLiteral( "bounding-boxes" ), mShowTerrainBoundingBoxes ? 1 : 0 );
271  elemDebug.setAttribute( QStringLiteral( "terrain-tile-info" ), mShowTerrainTileInfo ? 1 : 0 );
272  elemDebug.setAttribute( QStringLiteral( "camera-view-center" ), mShowCameraViewCenter ? 1 : 0 );
273  elem.appendChild( elemDebug );
274 
275  return elem;
276 }
277 
279 {
280  for ( int i = 0; i < mLayers.count(); ++i )
281  {
282  QgsMapLayerRef &layerRef = mLayers[i];
283  layerRef.setLayer( project.mapLayer( layerRef.layerId ) );
284  }
285 
286  mTerrainGenerator->resolveReferences( project );
287 
288  for ( int i = 0; i < mRenderers.count(); ++i )
289  {
290  QgsAbstract3DRenderer *renderer = mRenderers[i];
291  renderer->resolveReferences( project );
292  }
293 }
294 
296 {
297  return Qgs3DUtils::mapToWorldCoordinates( mapCoords, mOrigin );
298 }
299 
301 {
302  return Qgs3DUtils::worldToMapCoordinates( worldCoords, mOrigin );
303 }
304 
306 {
307  mCrs = crs;
308 }
309 
311 {
312  return mTransformContext;
313 }
314 
316 {
317  mTransformContext = context;
318 }
319 
320 void Qgs3DMapSettings::setBackgroundColor( const QColor &color )
321 {
322  if ( color == mBackgroundColor )
323  return;
324 
325  mBackgroundColor = color;
326  emit backgroundColorChanged();
327 }
328 
330 {
331  return mBackgroundColor;
332 }
333 
334 void Qgs3DMapSettings::setSelectionColor( const QColor &color )
335 {
336  if ( color == mSelectionColor )
337  return;
338 
339  mSelectionColor = color;
340  emit selectionColorChanged();
341 }
342 
344 {
345  return mSelectionColor;
346 }
347 
349 {
350  if ( zScale == mTerrainVerticalScale )
351  return;
352 
353  mTerrainVerticalScale = zScale;
355 }
356 
358 {
359  return mTerrainVerticalScale;
360 }
361 
362 void Qgs3DMapSettings::setLayers( const QList<QgsMapLayer *> &layers )
363 {
364  QList<QgsMapLayerRef> lst;
365  lst.reserve( layers.count() );
366  Q_FOREACH ( QgsMapLayer *layer, layers )
367  {
368  lst.append( layer );
369  }
370 
371  if ( mLayers == lst )
372  return;
373 
374  mLayers = lst;
375  emit layersChanged();
376 }
377 
378 QList<QgsMapLayer *> Qgs3DMapSettings::layers() const
379 {
380  QList<QgsMapLayer *> lst;
381  lst.reserve( mLayers.count() );
382  Q_FOREACH ( const QgsMapLayerRef &layerRef, mLayers )
383  {
384  if ( layerRef.layer )
385  lst.append( layerRef.layer );
386  }
387  return lst;
388 }
389 
391 {
392  if ( mMapTileResolution == res )
393  return;
394 
395  mMapTileResolution = res;
397 }
398 
400 {
401  return mMapTileResolution;
402 }
403 
405 {
406  if ( mMaxTerrainScreenError == error )
407  return;
408 
409  mMaxTerrainScreenError = error;
411 }
412 
414 {
415  return mMaxTerrainScreenError;
416 }
417 
419 {
420  if ( mMaxTerrainGroundError == error )
421  return;
422 
423  mMaxTerrainGroundError = error;
425 }
426 
428 {
429  return mMaxTerrainGroundError;
430 }
431 
433 {
434  mTerrainGenerator.reset( gen );
436 }
437 
439 {
440  if ( mTerrainShadingEnabled == enabled )
441  return;
442 
443  mTerrainShadingEnabled = enabled;
444  emit terrainShadingChanged();
445 }
446 
448 {
449  if ( mTerrainShadingMaterial == material )
450  return;
451 
452  mTerrainShadingMaterial = material;
453  emit terrainShadingChanged();
454 }
455 
456 void Qgs3DMapSettings::setTerrainMapTheme( const QString &theme )
457 {
458  if ( mTerrainMapTheme == theme )
459  return;
460 
461  mTerrainMapTheme = theme;
462  emit terrainMapThemeChanged();
463 }
464 
465 void Qgs3DMapSettings::setRenderers( const QList<QgsAbstract3DRenderer *> &renderers )
466 {
467  qDeleteAll( mRenderers );
468 
469  mRenderers = renderers;
470 
471  emit renderersChanged();
472 }
473 
475 {
476  if ( mShowTerrainBoundingBoxes == enabled )
477  return;
478 
479  mShowTerrainBoundingBoxes = enabled;
481 }
482 
484 {
485  if ( mShowTerrainTileInfo == enabled )
486  return;
487 
488  mShowTerrainTileInfo = enabled;
490 }
491 
493 {
494  if ( mShowCameraViewCenter == enabled )
495  return;
496 
497  mShowCameraViewCenter = enabled;
499 }
500 
502 {
503  if ( mShowLabels == enabled )
504  return;
505 
506  mShowLabels = enabled;
507  emit showLabelsChanged();
508 }
509 
510 void Qgs3DMapSettings::setPointLights( const QList<QgsPointLightSettings> &pointLights )
511 {
512  if ( mPointLights == pointLights )
513  return;
514 
515  mPointLights = pointLights;
516  emit pointLightsChanged();
517 }
518 
520 {
521  if ( mFieldOfView == fieldOfView )
522  return;
523 
524  mFieldOfView = fieldOfView;
525  emit fieldOfViewChanged();
526 }
float maxTerrainScreenError() const
Returns maximum allowed screen error of terrain tiles in pixels.
void setFieldOfView(const float fieldOfView)
Sets the camera lens&#39; field of view.
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.
void renderersChanged()
Emitted when the list of map&#39;s extra renderers have been modified.
Base class for all map layer types.
Definition: qgsmaplayer.h:79
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.
3 Implementation of terrain generator that uses online resources to download heightmaps.
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
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:438
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.
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 fieldOfViewChanged()
Emitted when the camera lens field of view changes.
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:430
void terrainGeneratorChanged()
Emitted when the terrain generator has changed.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
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.
Q_INVOKABLE 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.
float fieldOfView() const
Returns the camera lens&#39; field of view.
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()