QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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
78 QgsRectangle extent() const;
79
89 void setExtent( const QgsRectangle &extent );
90
104 void setOrigin( const QgsVector3D &origin );
105
111 QgsVector3D origin() const;
112
114 QgsVector3D mapToWorldCoordinates( const QgsVector3D &mapCoords ) const;
116 QgsVector3D worldToMapCoordinates( const QgsVector3D &worldCoords ) const;
117
123 void setCrs( const QgsCoordinateReferenceSystem &crs );
124
131
139 QgsCoordinateTransformContext transformContext() const;
140
148 void setTransformContext( const QgsCoordinateTransformContext &context );
149
156 const QgsPathResolver &pathResolver() const;
157
164 void setPathResolver( const QgsPathResolver &resolver );
165
172 QgsMapThemeCollection *mapThemeCollection() const;
173
179 void setMapThemeCollection( QgsMapThemeCollection *mapThemes );
180
182 void setBackgroundColor( const QColor &color );
184 QColor backgroundColor() const;
185
187 void setSelectionColor( const QColor &color );
189 QColor selectionColor() const;
190
199 void setLayers( const QList<QgsMapLayer *> &layers );
200
209 QList<QgsMapLayer *> layers() const;
210
211 //
212 // terrain related config
213 //
214
220 void configureTerrainFromProject( QgsProjectElevationProperties *properties, const QgsRectangle &fullExtent ) SIP_SKIP;
221
231 const QgsAbstractTerrainSettings *terrainSettings() const;
232
239 void setTerrainSettings( QgsAbstractTerrainSettings *settings SIP_TRANSFER );
240
247 Q_DECL_DEPRECATED void setTerrainVerticalScale( double zScale ) SIP_DEPRECATED;
248
254 Q_DECL_DEPRECATED double terrainVerticalScale() const SIP_DEPRECATED;
255
262 Q_DECL_DEPRECATED void setMapTileResolution( int res ) SIP_DEPRECATED;
263
270 Q_DECL_DEPRECATED int mapTileResolution() const SIP_DEPRECATED;
271
278 Q_DECL_DEPRECATED void setMaxTerrainScreenError( double error ) SIP_DEPRECATED;
279
289 Q_DECL_DEPRECATED double maxTerrainScreenError() const SIP_DEPRECATED;
290
297 Q_DECL_DEPRECATED void setMaxTerrainGroundError( double error ) SIP_DEPRECATED;
298
307 Q_DECL_DEPRECATED double maxTerrainGroundError() const SIP_DEPRECATED;
308
314 Q_DECL_DEPRECATED void setTerrainElevationOffset( double offset ) SIP_DEPRECATED;
315
321 Q_DECL_DEPRECATED double terrainElevationOffset() const SIP_DEPRECATED;
322
335 void setTerrainGenerator( QgsTerrainGenerator *gen SIP_TRANSFER ) SIP_SKIP;
336
347 QgsTerrainGenerator *terrainGenerator() const SIP_SKIP;
348
354 void setTerrainShadingEnabled( bool enabled );
355
362 bool isTerrainShadingEnabled() const;
363
369 void setTerrainShadingMaterial( const QgsPhongMaterialSettings &material );
370
376 QgsPhongMaterialSettings terrainShadingMaterial() const;
377
383 void setTerrainMapTheme( const QString &theme );
384
391 QString terrainMapTheme() const;
392
393 //
394 // misc configuration
395 //
396
398 void setShowTerrainBoundingBoxes( bool enabled );
400 bool showTerrainBoundingBoxes() const;
402 void setShowTerrainTilesInfo( bool enabled );
404 bool showTerrainTilesInfo() const;
405
410 void setShowCameraViewCenter( bool enabled );
411
416 bool showCameraViewCenter() const;
417
422 void setShowCameraRotationCenter( bool enabled );
423
428 bool showCameraRotationCenter() const;
429
434 void setShowLightSourceOrigins( bool enabled );
435
440 bool showLightSourceOrigins() const;
441
443 void setShowLabels( bool enabled );
445 bool showLabels() const;
446
452 void setEyeDomeLightingEnabled( bool enabled );
454 bool eyeDomeLightingEnabled() const;
455
461 void setEyeDomeLightingStrength( double strength );
463 double eyeDomeLightingStrength() const;
464
470 void setEyeDomeLightingDistance( int distance );
472 int eyeDomeLightingDistance() const;
473
479 void setStopUpdates( bool enabled );
480
485 bool stopUpdates() const;
486
494 void setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size );
496 bool debugShadowMapEnabled() const;
498 Qt::Corner debugShadowMapCorner() const;
500 double debugShadowMapSize() const;
501
509 void setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size );
511 bool debugDepthMapEnabled() const;
513 Qt::Corner debugDepthMapCorner() const;
515 double debugDepthMapSize() const;
516
522 QList<QgsLightSource *> lightSources() const;
523
532 void setLightSources( const QList<QgsLightSource *> &lights SIP_TRANSFER );
533
538 float fieldOfView() const;
539
544 void setFieldOfView( const float fieldOfView );
545
550 Qt3DRender::QCameraLens::ProjectionType projectionType() const SIP_SKIP;
551
556 void setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType ) SIP_SKIP;
557
558#ifndef SIP_RUN
559
564 Qgis::NavigationMode cameraNavigationMode() const;
565
570 void setCameraNavigationMode( Qgis::NavigationMode navigationMode );
571#endif
572
577 double cameraMovementSpeed() const;
578
583 void setCameraMovementSpeed( double movementSpeed );
584
590 void setOutputDpi( const double dpi );
591
597 double outputDpi() const;
598
603 QgsSkyboxSettings skyboxSettings() const SIP_SKIP;
604
609 QgsShadowSettings shadowSettings() const SIP_SKIP;
610
615 QgsAmbientOcclusionSettings ambientOcclusionSettings() const SIP_SKIP;
616
621 void setSkyboxSettings( const QgsSkyboxSettings &skyboxSettings ) SIP_SKIP;
622
627 void setShadowSettings( const QgsShadowSettings &shadowSettings ) SIP_SKIP;
628
633 void setAmbientOcclusionSettings( const QgsAmbientOcclusionSettings &ambientOcclusionSettings ) SIP_SKIP;
634
640 bool isSkyboxEnabled() const;
641
647 void setIsSkyboxEnabled( bool enabled );
648
654 bool isFpsCounterEnabled() const;
655
661 void setIsFpsCounterEnabled( bool fpsCounterEnabled );
662
668 bool terrainRenderingEnabled() const;
669
675 void setTerrainRenderingEnabled( bool terrainRenderingEnabled );
676
683 Qgis::RendererUsage rendererUsage() const;
684
691 void setRendererUsage( Qgis::RendererUsage rendererUsage );
692
698 Qgis::ViewSyncModeFlags viewSyncMode() const;
699
705 void setViewSyncMode( Qgis::ViewSyncModeFlags mode );
706
712 bool viewFrustumVisualizationEnabled() const;
713
719 void setViewFrustumVisualizationEnabled( bool enabled );
720
725 Qgs3DAxisSettings get3DAxisSettings() const SIP_SKIP;
726
731 void set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force = false ) SIP_SKIP;
732
738 bool isDebugOverlayEnabled() const;
739
748 void setIsDebugOverlayEnabled( bool debugOverlayEnabled );
749
755 bool showExtentIn2DView() const;
756
761 void setShowExtentIn2DView( bool show );
762
767 void setShowDebugPanel( bool enabled );
768
773 bool showDebugPanel() const;
774
775 signals:
776
782 void settingsChanged();
783
785 void backgroundColorChanged();
787 void selectionColorChanged();
788
795 void layersChanged();
796
798 void terrainGeneratorChanged();
799
805 void terrainSettingsChanged();
806
811 Q_DECL_DEPRECATED void terrainVerticalScaleChanged() SIP_DEPRECATED;
812
817 Q_DECL_DEPRECATED void mapTileResolutionChanged() SIP_DEPRECATED;
818
823 Q_DECL_DEPRECATED void maxTerrainScreenErrorChanged() SIP_DEPRECATED;
824
830 Q_DECL_DEPRECATED void maxTerrainGroundErrorChanged() SIP_DEPRECATED;
831
837 Q_DECL_DEPRECATED void terrainElevationOffsetChanged( double newElevation ) SIP_DEPRECATED;
838
843 void terrainShadingChanged();
844
849 void terrainMapThemeChanged();
850
855 void renderersChanged();
856
858 void showTerrainBoundingBoxesChanged();
860 void showTerrainTilesInfoChanged();
861
866 void showCameraViewCenterChanged();
867
872 void showCameraRotationCenterChanged();
873
878 void showLightSourceOriginsChanged();
879
881 void showLabelsChanged();
882
887 void stopUpdatesChanged();
888
893 void eyeDomeLightingEnabledChanged();
894
899 void eyeDomeLightingStrengthChanged();
900
905 void eyeDomeLightingDistanceChanged();
906
911 void debugShadowMapSettingsChanged();
912
917 void debugDepthMapSettingsChanged();
918
923 void pointLightsChanged();
924
929 void lightSourcesChanged();
930
935 void directionalLightsChanged();
936
941 void fieldOfViewChanged();
942
947 void projectionTypeChanged();
948
953 void cameraNavigationModeChanged();
954
959 void cameraMovementSpeedChanged();
960
965 void skyboxSettingsChanged();
966
971 void shadowSettingsChanged();
972
973
978 void ambientOcclusionSettingsChanged();
979
984 void fpsCounterEnabledChanged( bool fpsCounterEnabled );
985
991 void viewFrustumVisualizationEnabledChanged();
992
997 void axisSettingsChanged();
998
1003 void debugOverlayEnabledChanged( bool debugOverlayEnabled );
1004
1010 void extentChanged();
1011
1017 void showExtentIn2DViewChanged();
1018
1024 void showDebugPanelChanged( bool shown );
1025
1031 void originChanged();
1032
1033 private:
1034#ifdef SIP_RUN
1035 Qgs3DMapSettings &operator=( const Qgs3DMapSettings & );
1036#endif
1037
1038 private:
1040 void connectChangedSignalsToSettingsChanged();
1041
1042 private:
1044 QgsVector3D mOrigin;
1046 QColor mBackgroundColor = Qt::black;
1047 QColor mSelectionColor;
1048 std::unique_ptr<QgsTerrainGenerator> mTerrainGenerator;
1049 std::unique_ptr<QgsAbstractTerrainSettings> mTerrainSettings;
1050 bool mTerrainShadingEnabled = false;
1051 QgsPhongMaterialSettings mTerrainShadingMaterial;
1052 QString mTerrainMapTheme;
1053 bool mShowTerrainBoundingBoxes = false;
1054 bool mShowTerrainTileInfo = false;
1055 bool mShowCameraViewCenter = false;
1056 bool mShowCameraRotationCenter = false;
1057 bool mShowLightSources = false;
1058 bool mShowLabels = false;
1059 bool mStopUpdates = false;
1060 bool mShowDebugPanel = false;
1061 QList<QgsLightSource *> mLightSources;
1062 float mFieldOfView = 45.0f; //<! Camera lens field of view value
1063 Qt3DRender::QCameraLens::ProjectionType mProjectionType = Qt3DRender::QCameraLens::PerspectiveProjection; //<! Camera lens projection type
1065 double mCameraMovementSpeed = 5.0;
1066 QList<QgsMapLayerRef> mLayers;
1068 QgsCoordinateTransformContext mTransformContext;
1069 QgsPathResolver mPathResolver;
1070 QgsMapThemeCollection *mMapThemes = nullptr;
1071 double mDpi = 96;
1072 bool mIsFpsCounterEnabled = false;
1073
1074 bool mIsSkyboxEnabled = false;
1075 QgsSkyboxSettings mSkyboxSettings;
1076 QgsShadowSettings mShadowSettings;
1077 QgsAmbientOcclusionSettings mAmbientOcclusionSettings;
1078
1079 bool mEyeDomeLightingEnabled = false;
1080 double mEyeDomeLightingStrength = 1000.0;
1081 int mEyeDomeLightingDistance = 1;
1082
1083 Qgis::ViewSyncModeFlags mViewSyncMode;
1084 bool mVisualizeViewFrustum = false;
1085
1086 bool mDebugShadowMapEnabled = false;
1087 Qt::Corner mDebugShadowMapCorner = Qt::Corner::TopLeftCorner;
1088 double mDebugShadowMapSize = 0.2;
1089
1090 bool mDebugDepthMapEnabled = false;
1091 Qt::Corner mDebugDepthMapCorner = Qt::Corner::BottomLeftCorner;
1092 double mDebugDepthMapSize = 0.2;
1093
1094 bool mTerrainRenderingEnabled = true;
1095
1096 Qgis::RendererUsage mRendererUsage;
1097
1098 Qgs3DAxisSettings m3dAxisSettings;
1099
1100 bool mIsDebugOverlayEnabled = false;
1101
1102 QgsRectangle mExtent;
1103
1104 bool mShowExtentIn2DView = false;
1105};
1106
1107
1108#endif // QGS3DMAPSETTINGS_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
QFlags< ViewSyncModeFlag > ViewSyncModeFlags
Definition qgis.h:3278
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:3917
@ TerrainBased
The default navigation based on the terrain.
RendererUsage
Usage of the renderer.
Definition qgis.h:3241
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