QGIS API Documentation 3.43.0-Master (3ee7834ace6)
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#include <Qt3DRender/QCamera>
25
27#include "qgsmaplayerref.h"
29#include "qgsterraingenerator.h"
30#include "qgsvector3d.h"
31#include "qgs3daxissettings.h"
32#include "qgsskyboxsettings.h"
33#include "qgsshadowsettings.h"
37
38class QgsMapLayer;
39class QgsRasterLayer;
40class QgsLightSource;
43class QgsProject;
44
45class QDomElement;
46
55class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObject
56{
57 Q_OBJECT
58 public:
60 Qgs3DMapSettings( const Qgs3DMapSettings &other );
61 ~Qgs3DMapSettings() override;
62
64
66 void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
68 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
70 void resolveReferences( const QgsProject &project );
71
80 QgsRectangle extent() const;
81
94 void setExtent( const QgsRectangle &extent );
95
109 void setOrigin( const QgsVector3D &origin );
110
116 QgsVector3D origin() const;
117
119 QgsVector3D mapToWorldCoordinates( const QgsVector3D &mapCoords ) const;
121 QgsVector3D worldToMapCoordinates( const QgsVector3D &worldCoords ) const;
122
128 void setCrs( const QgsCoordinateReferenceSystem &crs );
129
136
145 Qgis::SceneMode sceneMode() const;
146
154 QgsCoordinateTransformContext transformContext() const;
155
163 void setTransformContext( const QgsCoordinateTransformContext &context );
164
171 const QgsPathResolver &pathResolver() const;
172
179 void setPathResolver( const QgsPathResolver &resolver );
180
187 QgsMapThemeCollection *mapThemeCollection() const;
188
194 void setMapThemeCollection( QgsMapThemeCollection *mapThemes );
195
197 void setBackgroundColor( const QColor &color );
199 QColor backgroundColor() const;
200
202 void setSelectionColor( const QColor &color );
204 QColor selectionColor() const;
205
214 void setLayers( const QList<QgsMapLayer *> &layers );
215
224 QList<QgsMapLayer *> layers() const;
225
226 //
227 // terrain related config
228 //
229
235 void configureTerrainFromProject( QgsProjectElevationProperties *properties, const QgsRectangle &fullExtent ) SIP_SKIP;
236
246 const QgsAbstractTerrainSettings *terrainSettings() const;
247
254 void setTerrainSettings( QgsAbstractTerrainSettings *settings SIP_TRANSFER );
255
262 Q_DECL_DEPRECATED void setTerrainVerticalScale( double zScale ) SIP_DEPRECATED;
263
269 Q_DECL_DEPRECATED double terrainVerticalScale() const SIP_DEPRECATED;
270
277 Q_DECL_DEPRECATED void setMapTileResolution( int res ) SIP_DEPRECATED;
278
285 Q_DECL_DEPRECATED int mapTileResolution() const SIP_DEPRECATED;
286
293 Q_DECL_DEPRECATED void setMaxTerrainScreenError( double error ) SIP_DEPRECATED;
294
304 Q_DECL_DEPRECATED double maxTerrainScreenError() const SIP_DEPRECATED;
305
312 Q_DECL_DEPRECATED void setMaxTerrainGroundError( double error ) SIP_DEPRECATED;
313
322 Q_DECL_DEPRECATED double maxTerrainGroundError() const SIP_DEPRECATED;
323
329 Q_DECL_DEPRECATED void setTerrainElevationOffset( double offset ) SIP_DEPRECATED;
330
336 Q_DECL_DEPRECATED double terrainElevationOffset() const SIP_DEPRECATED;
337
350 void setTerrainGenerator( QgsTerrainGenerator *gen SIP_TRANSFER ) SIP_SKIP;
351
362 QgsTerrainGenerator *terrainGenerator() const SIP_SKIP;
363
369 void setTerrainShadingEnabled( bool enabled );
370
377 bool isTerrainShadingEnabled() const;
378
384 void setTerrainShadingMaterial( const QgsPhongMaterialSettings &material );
385
391 QgsPhongMaterialSettings terrainShadingMaterial() const;
392
398 void setTerrainMapTheme( const QString &theme );
399
406 QString terrainMapTheme() const;
407
408 //
409 // misc configuration
410 //
411
413 void setShowTerrainBoundingBoxes( bool enabled );
415 bool showTerrainBoundingBoxes() const;
417 void setShowTerrainTilesInfo( bool enabled );
419 bool showTerrainTilesInfo() const;
420
425 void setShowCameraViewCenter( bool enabled );
426
431 bool showCameraViewCenter() const;
432
437 void setShowCameraRotationCenter( bool enabled );
438
443 bool showCameraRotationCenter() const;
444
449 void setShowLightSourceOrigins( bool enabled );
450
455 bool showLightSourceOrigins() const;
456
458 void setShowLabels( bool enabled );
460 bool showLabels() const;
461
467 void setEyeDomeLightingEnabled( bool enabled );
469 bool eyeDomeLightingEnabled() const;
470
476 void setEyeDomeLightingStrength( double strength );
478 double eyeDomeLightingStrength() const;
479
485 void setEyeDomeLightingDistance( int distance );
487 int eyeDomeLightingDistance() const;
488
494 void setStopUpdates( bool enabled );
495
500 bool stopUpdates() const;
501
509 void setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size );
511 bool debugShadowMapEnabled() const;
513 Qt::Corner debugShadowMapCorner() const;
515 double debugShadowMapSize() const;
516
524 void setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size );
526 bool debugDepthMapEnabled() const;
528 Qt::Corner debugDepthMapCorner() const;
530 double debugDepthMapSize() const;
531
537 QList<QgsLightSource *> lightSources() const;
538
547 void setLightSources( const QList<QgsLightSource *> &lights SIP_TRANSFER );
548
553 float fieldOfView() const;
554
559 void setFieldOfView( const float fieldOfView );
560
565 Qt3DRender::QCameraLens::ProjectionType projectionType() const SIP_SKIP;
566
571 void setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType ) SIP_SKIP;
572
573#ifndef SIP_RUN
574
579 Qgis::NavigationMode cameraNavigationMode() const;
580
585 void setCameraNavigationMode( Qgis::NavigationMode navigationMode );
586#endif
587
592 double cameraMovementSpeed() const;
593
598 void setCameraMovementSpeed( double movementSpeed );
599
605 void setOutputDpi( const double dpi );
606
612 double outputDpi() const;
613
618 QgsSkyboxSettings skyboxSettings() const SIP_SKIP;
619
624 QgsShadowSettings shadowSettings() const SIP_SKIP;
625
630 QgsAmbientOcclusionSettings ambientOcclusionSettings() const SIP_SKIP;
631
636 void setSkyboxSettings( const QgsSkyboxSettings &skyboxSettings ) SIP_SKIP;
637
642 void setShadowSettings( const QgsShadowSettings &shadowSettings ) SIP_SKIP;
643
648 void setAmbientOcclusionSettings( const QgsAmbientOcclusionSettings &ambientOcclusionSettings ) SIP_SKIP;
649
655 bool isSkyboxEnabled() const;
656
662 void setIsSkyboxEnabled( bool enabled );
663
669 bool isFpsCounterEnabled() const;
670
676 void setIsFpsCounterEnabled( bool fpsCounterEnabled );
677
683 bool terrainRenderingEnabled() const;
684
690 void setTerrainRenderingEnabled( bool terrainRenderingEnabled );
691
698 Qgis::RendererUsage rendererUsage() const;
699
706 void setRendererUsage( Qgis::RendererUsage rendererUsage );
707
713 Qgis::ViewSyncModeFlags viewSyncMode() const;
714
720 void setViewSyncMode( Qgis::ViewSyncModeFlags mode );
721
727 bool viewFrustumVisualizationEnabled() const;
728
734 void setViewFrustumVisualizationEnabled( bool enabled );
735
740 Qgs3DAxisSettings get3DAxisSettings() const SIP_SKIP;
741
746 void set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force = false ) SIP_SKIP;
747
753 bool isDebugOverlayEnabled() const;
754
763 void setIsDebugOverlayEnabled( bool debugOverlayEnabled );
764
770 bool showExtentIn2DView() const;
771
776 void setShowExtentIn2DView( bool show );
777
782 void setShowDebugPanel( bool enabled );
783
788 bool showDebugPanel() const;
789
790 signals:
791
797 void settingsChanged();
798
800 void backgroundColorChanged();
802 void selectionColorChanged();
803
810 void layersChanged();
811
813 void terrainGeneratorChanged();
814
820 void terrainSettingsChanged();
821
826 Q_DECL_DEPRECATED void terrainVerticalScaleChanged() SIP_DEPRECATED;
827
832 Q_DECL_DEPRECATED void mapTileResolutionChanged() SIP_DEPRECATED;
833
838 Q_DECL_DEPRECATED void maxTerrainScreenErrorChanged() SIP_DEPRECATED;
839
845 Q_DECL_DEPRECATED void maxTerrainGroundErrorChanged() SIP_DEPRECATED;
846
852 Q_DECL_DEPRECATED void terrainElevationOffsetChanged( double newElevation ) SIP_DEPRECATED;
853
858 void terrainShadingChanged();
859
864 void terrainMapThemeChanged();
865
870 void renderersChanged();
871
873 void showTerrainBoundingBoxesChanged();
875 void showTerrainTilesInfoChanged();
876
881 void showCameraViewCenterChanged();
882
887 void showCameraRotationCenterChanged();
888
893 void showLightSourceOriginsChanged();
894
896 void showLabelsChanged();
897
902 void stopUpdatesChanged();
903
908 void eyeDomeLightingEnabledChanged();
909
914 void eyeDomeLightingStrengthChanged();
915
920 void eyeDomeLightingDistanceChanged();
921
926 void debugShadowMapSettingsChanged();
927
932 void debugDepthMapSettingsChanged();
933
938 void pointLightsChanged();
939
944 void lightSourcesChanged();
945
950 void directionalLightsChanged();
951
956 void fieldOfViewChanged();
957
962 void projectionTypeChanged();
963
968 void cameraNavigationModeChanged();
969
974 void cameraMovementSpeedChanged();
975
980 void skyboxSettingsChanged();
981
986 void shadowSettingsChanged();
987
988
993 void ambientOcclusionSettingsChanged();
994
999 void fpsCounterEnabledChanged( bool fpsCounterEnabled );
1000
1006 void viewFrustumVisualizationEnabledChanged();
1007
1012 void axisSettingsChanged();
1013
1018 void debugOverlayEnabledChanged( bool debugOverlayEnabled );
1019
1025 void extentChanged();
1026
1032 void showExtentIn2DViewChanged();
1033
1039 void showDebugPanelChanged( bool shown );
1040
1046 void originChanged();
1047
1048 private:
1049#ifdef SIP_RUN
1050 Qgs3DMapSettings &operator=( const Qgs3DMapSettings & );
1051#endif
1052
1053 private:
1055 void connectChangedSignalsToSettingsChanged();
1056
1057 private:
1059 QgsVector3D mOrigin;
1061 QColor mBackgroundColor = Qt::black;
1062 QColor mSelectionColor;
1063 std::unique_ptr<QgsTerrainGenerator> mTerrainGenerator;
1064 std::unique_ptr<QgsAbstractTerrainSettings> mTerrainSettings;
1065 bool mTerrainShadingEnabled = false;
1066 QgsPhongMaterialSettings mTerrainShadingMaterial;
1067 QString mTerrainMapTheme;
1068 bool mShowTerrainBoundingBoxes = false;
1069 bool mShowTerrainTileInfo = false;
1070 bool mShowCameraViewCenter = false;
1071 bool mShowCameraRotationCenter = false;
1072 bool mShowLightSources = false;
1073 bool mShowLabels = false;
1074 bool mStopUpdates = false;
1075 bool mShowDebugPanel = false;
1076 QList<QgsLightSource *> mLightSources;
1077 float mFieldOfView = 45.0f; //<! Camera lens field of view value
1078 Qt3DRender::QCameraLens::ProjectionType mProjectionType = Qt3DRender::QCameraLens::PerspectiveProjection; //<! Camera lens projection type
1080 double mCameraMovementSpeed = 5.0;
1081 QList<QgsMapLayerRef> mLayers;
1083 QgsCoordinateTransformContext mTransformContext;
1084 QgsPathResolver mPathResolver;
1085 QgsMapThemeCollection *mMapThemes = nullptr;
1086 double mDpi = 96;
1087 bool mIsFpsCounterEnabled = false;
1088
1089 bool mIsSkyboxEnabled = false;
1090 QgsSkyboxSettings mSkyboxSettings;
1091 QgsShadowSettings mShadowSettings;
1092 QgsAmbientOcclusionSettings mAmbientOcclusionSettings;
1093
1094 bool mEyeDomeLightingEnabled = false;
1095 double mEyeDomeLightingStrength = 1000.0;
1096 int mEyeDomeLightingDistance = 1;
1097
1098 Qgis::ViewSyncModeFlags mViewSyncMode;
1099 bool mVisualizeViewFrustum = false;
1100
1101 bool mDebugShadowMapEnabled = false;
1102 Qt::Corner mDebugShadowMapCorner = Qt::Corner::TopLeftCorner;
1103 double mDebugShadowMapSize = 0.2;
1104
1105 bool mDebugDepthMapEnabled = false;
1106 Qt::Corner mDebugDepthMapCorner = Qt::Corner::BottomLeftCorner;
1107 double mDebugDepthMapSize = 0.2;
1108
1109 bool mTerrainRenderingEnabled = true;
1110
1111 Qgis::RendererUsage mRendererUsage;
1112
1113 Qgs3DAxisSettings m3dAxisSettings;
1114
1115 bool mIsDebugOverlayEnabled = false;
1116
1117 QgsRectangle mExtent;
1118
1119 bool mShowExtentIn2DView = false;
1120};
1121
1122
1123#endif // QGS3DMAPSETTINGS_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
QFlags< ViewSyncModeFlag > ViewSyncModeFlags
Definition qgis.h:3350
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:4001
@ TerrainBased
The default navigation based on the terrain.
RendererUsage
Usage of the renderer.
Definition qgis.h:3313
SceneMode
The 3D scene mode used in 3D map views.
Definition qgis.h:4014
Contains the configuration of a 3d axis.
Qgs3DMapSettings & operator=(Qgs3DMapSettings const &)=delete
Base class for all renderers that may to participate in 3D view.
class containing the configuration of ambient occlusion rendering 3
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Base class for all map layer types.
Definition qgsmaplayer.h:76
Container class that allows storage of map themes consisting of visible map layers and layer styles.
Resolves relative paths into absolute paths and vice versa.
Contains elevation properties for a QgsProject.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
Represents a raster layer.
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
class containing the configuration of shadows rendering 3
Contains the configuration of a skybox entity.
Base class for objects with an associated (optional) temporal range.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition qgsvector3d.h:31
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36
const QgsCoordinateReferenceSystem & crs