QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgs3dmapsettings.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgs3dmapsettings.h
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 #ifndef QGS3DMAPSETTINGS_H
17 #define QGS3DMAPSETTINGS_H
18 
19 #include "qgis_3d.h"
20 
21 #include <memory>
22 #include <QColor>
23 #include <QMatrix4x4>
24 
26 #include "qgsmaplayerref.h"
27 #include "qgsterraingenerator.h"
28 #include "qgsvector3d.h"
29 
30 class QgsMapLayer;
31 class QgsRasterLayer;
32 
34 
35 
37 class QgsProject;
38 
39 class QDomElement;
40 
41 
48 class _3D_EXPORT Qgs3DMapSettings : public QObject
49 {
50  Q_OBJECT
51  public:
52 
54  Qgs3DMapSettings() = default;
56  Qgs3DMapSettings( const Qgs3DMapSettings &other );
57  ~Qgs3DMapSettings() override;
58 
60  void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
62  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
64  void resolveReferences( const QgsProject &project );
65 
77  void setOrigin( const QgsVector3D &origin ) { mOrigin = origin; }
79  QgsVector3D origin() const { return mOrigin; }
80 
82  QgsVector3D mapToWorldCoordinates( const QgsVector3D &mapCoords ) const;
84  QgsVector3D worldToMapCoordinates( const QgsVector3D &worldCoords ) const;
85 
87  void setCrs( const QgsCoordinateReferenceSystem &crs );
89  QgsCoordinateReferenceSystem crs() const { return mCrs; }
90 
98  QgsCoordinateTransformContext transformContext() const;
99 
107  void setTransformContext( const QgsCoordinateTransformContext &context );
108 
116  const QgsPathResolver &pathResolver() const { return mPathResolver; }
117 
125  void setPathResolver( const QgsPathResolver &resolver ) { mPathResolver = resolver; }
126 
128  void setBackgroundColor( const QColor &color );
130  QColor backgroundColor() const;
131 
133  void setSelectionColor( const QColor &color );
135  QColor selectionColor() const;
136 
137  //
138  // terrain related config
139  //
140 
145  void setTerrainVerticalScale( double zScale );
147  double terrainVerticalScale() const;
148 
150  void setLayers( const QList<QgsMapLayer *> &layers );
152  QList<QgsMapLayer *> layers() const;
153 
158  void setMapTileResolution( int res );
159 
164  int mapTileResolution() const;
165 
170  void setMaxTerrainScreenError( float error );
171 
179  float maxTerrainScreenError() const;
180 
185  void setMaxTerrainGroundError( float error );
186 
193  float maxTerrainGroundError() const;
194 
199  void setTerrainGenerator( QgsTerrainGenerator *gen SIP_TRANSFER );
201  QgsTerrainGenerator *terrainGenerator() const { return mTerrainGenerator.get(); }
202 
204  void setRenderers( const QList<QgsAbstract3DRenderer *> &renderers SIP_TRANSFER );
206  QList<QgsAbstract3DRenderer *> renderers() const { return mRenderers; }
207 
214  void setSkybox( bool enabled, const QString &fileBase = QString(), const QString &fileExtension = QString() );
216  bool hasSkyboxEnabled() const { return mSkyboxEnabled; }
218  QString skyboxFileBase() const { return mSkyboxFileBase; }
220  QString skyboxFileExtension() const { return mSkyboxFileExtension; }
221 
223  void setShowTerrainBoundingBoxes( bool enabled );
225  bool showTerrainBoundingBoxes() const { return mShowTerrainBoundingBoxes; }
227  void setShowTerrainTilesInfo( bool enabled );
229  bool showTerrainTilesInfo() const { return mShowTerrainTileInfo; }
230 
235  void setShowCameraViewCenter( bool enabled );
236 
241  bool showCameraViewCenter() const { return mShowCameraViewCenter; }
243  void setShowLabels( bool enabled );
245  bool showLabels() const { return mShowLabels; }
246 
247  signals:
249  void backgroundColorChanged();
251  void selectionColorChanged();
253  void layersChanged();
255  void terrainGeneratorChanged();
257  void terrainVerticalScaleChanged();
259  void mapTileResolutionChanged();
261  void maxTerrainScreenErrorChanged();
263  void maxTerrainGroundErrorChanged();
265  void showTerrainBoundingBoxesChanged();
267  void showTerrainTilesInfoChanged();
268 
273  void showCameraViewCenterChanged();
275  void showLabelsChanged();
276 
277  private:
279  QgsVector3D mOrigin;
281  QColor mBackgroundColor = Qt::black;
282  QColor mSelectionColor;
283  double mTerrainVerticalScale = 1;
284  std::unique_ptr<QgsTerrainGenerator> mTerrainGenerator;
285  int mMapTileResolution = 512;
286  float mMaxTerrainScreenError = 3.f;
287  float mMaxTerrainGroundError = 1.f;
288  bool mShowTerrainBoundingBoxes = false;
289  bool mShowTerrainTileInfo = false;
290  bool mShowCameraViewCenter = false;
291  bool mShowLabels = false;
292  QList<QgsMapLayerRef> mLayers;
293  QList<QgsAbstract3DRenderer *> mRenderers;
294  bool mSkyboxEnabled = false;
295  QString mSkyboxFileBase;
296  QString mSkyboxFileExtension;
297  QgsCoordinateTransformContext mTransformContext;
299  QgsPathResolver mPathResolver;
300 };
301 
302 
303 #endif // QGS3DMAPSETTINGS_H
The class is used as a container of context for various read/write operations on other objects...
3 Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double preci...
Definition: qgsvector3d.h:31
Base class for all map layer types.
Definition: qgsmaplayer.h:63
Base class for all renderers that may to participate in 3D view.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
bool showLabels() const
Returns whether to display labels on terrain tiles.
const QgsCoordinateReferenceSystem & crs
QString skyboxFileBase() const
Returns base part of filenames of skybox (see setSkybox())
3 Definition of the world
bool hasSkyboxEnabled() const
Returns whether skybox is enabled.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Reads and writes project states.
Definition: qgsproject.h:89
Contains information about the context in which a coordinate transform is executed.
bool showCameraViewCenter() const
Returns whether to show camera&#39;s view center as a sphere (for debugging)
void setOrigin(const QgsVector3D &origin)
Sets coordinates in map CRS at which our 3D world has origin (0,0,0)
void setPathResolver(const QgsPathResolver &resolver)
Sets the path resolver for conversion between relative and absolute paths during rendering operations...
3 Base class for generators of terrain.
QgsVector3D origin() const
Returns coordinates in map CRS at which 3D scene has origin (0,0,0)
QList< QgsAbstract3DRenderer * > renderers() const
Returns list of extra 3D renderers.
This class represents a coordinate reference system (CRS).
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used in the 3D scene.
QString skyboxFileExtension() const
Returns extension part of filenames of skybox (see setSkybox())
Resolves relative paths into absolute paths and vice versa.
bool showTerrainTilesInfo() const
Returns whether to display extra tile info on top of terrain tiles (for debugging) ...
QgsTerrainGenerator * terrainGenerator() const
Returns terrain generator. It takes care of producing terrain tiles from the input data...
bool showTerrainBoundingBoxes() const
Returns whether to display bounding boxes of terrain tiles (for debugging)