QGIS API Documentation 3.41.0-Master (3440c17df1d)
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"
36
37class QgsMapLayer;
38class QgsRasterLayer;
39class QgsLightSource;
42class QgsProject;
43
44class QDomElement;
45
54class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObject
55{
56 Q_OBJECT
57 public:
58
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
226 void setTerrainVerticalScale( double zScale );
228 double terrainVerticalScale() const;
229
234 void setMapTileResolution( int res );
235
240 int mapTileResolution() const;
241
246 void setMaxTerrainScreenError( float error );
247
255 float maxTerrainScreenError() const;
256
261 void setMaxTerrainGroundError( float error );
262
269 float maxTerrainGroundError() const;
270
276 void setTerrainElevationOffset( float offset );
277
281 float terrainElevationOffset() const;
282
295 void setTerrainGenerator( QgsTerrainGenerator *gen SIP_TRANSFER ) SIP_SKIP;
296
307 QgsTerrainGenerator *terrainGenerator() const SIP_SKIP;
308
314 void setTerrainShadingEnabled( bool enabled );
315
322 bool isTerrainShadingEnabled() const;
323
329 void setTerrainShadingMaterial( const QgsPhongMaterialSettings &material );
330
336 QgsPhongMaterialSettings terrainShadingMaterial() const;
337
343 void setTerrainMapTheme( const QString &theme );
344
351 QString terrainMapTheme() const;
352
353 //
354 // misc configuration
355 //
356
358 void setShowTerrainBoundingBoxes( bool enabled );
360 bool showTerrainBoundingBoxes() const;
362 void setShowTerrainTilesInfo( bool enabled );
364 bool showTerrainTilesInfo() const;
365
370 void setShowCameraViewCenter( bool enabled );
371
376 bool showCameraViewCenter() const;
377
382 void setShowCameraRotationCenter( bool enabled );
383
388 bool showCameraRotationCenter() const;
389
394 void setShowLightSourceOrigins( bool enabled );
395
400 bool showLightSourceOrigins() const;
401
403 void setShowLabels( bool enabled );
405 bool showLabels() const;
406
412 void setEyeDomeLightingEnabled( bool enabled );
414 bool eyeDomeLightingEnabled() const;
415
421 void setEyeDomeLightingStrength( double strength );
423 double eyeDomeLightingStrength() const;
424
430 void setEyeDomeLightingDistance( int distance );
432 int eyeDomeLightingDistance() const;
433
439 void setStopUpdates( bool enabled );
440
445 bool stopUpdates() const;
446
454 void setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size );
456 bool debugShadowMapEnabled() const;
458 Qt::Corner debugShadowMapCorner() const;
460 double debugShadowMapSize() const;
461
469 void setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size );
471 bool debugDepthMapEnabled() const;
473 Qt::Corner debugDepthMapCorner() const;
475 double debugDepthMapSize() const;
476
482 QList<QgsLightSource *> lightSources() const;
483
492 void setLightSources( const QList<QgsLightSource *> &lights SIP_TRANSFER );
493
498 float fieldOfView() const;
499
504 void setFieldOfView( const float fieldOfView );
505
510 Qt3DRender::QCameraLens::ProjectionType projectionType() const SIP_SKIP;
511
516 void setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType ) SIP_SKIP;
517
518#ifndef SIP_RUN
519
524 Qgis::NavigationMode cameraNavigationMode() const;
525
530 void setCameraNavigationMode( Qgis::NavigationMode navigationMode );
531#endif
532
537 double cameraMovementSpeed() const;
538
543 void setCameraMovementSpeed( double movementSpeed );
544
550 void setOutputDpi( const double dpi );
551
557 double outputDpi() const;
558
563 QgsSkyboxSettings skyboxSettings() const SIP_SKIP;
564
569 QgsShadowSettings shadowSettings() const SIP_SKIP;
570
575 QgsAmbientOcclusionSettings ambientOcclusionSettings() const SIP_SKIP;
576
581 void setSkyboxSettings( const QgsSkyboxSettings &skyboxSettings ) SIP_SKIP;
582
587 void setShadowSettings( const QgsShadowSettings &shadowSettings ) SIP_SKIP;
588
593 void setAmbientOcclusionSettings( const QgsAmbientOcclusionSettings &ambientOcclusionSettings ) SIP_SKIP;
594
600 bool isSkyboxEnabled() const;
601
607 void setIsSkyboxEnabled( bool enabled );
608
614 bool isFpsCounterEnabled() const;
615
621 void setIsFpsCounterEnabled( bool fpsCounterEnabled );
622
628 bool terrainRenderingEnabled() const;
629
635 void setTerrainRenderingEnabled( bool terrainRenderingEnabled );
636
643 Qgis::RendererUsage rendererUsage() const;
644
651 void setRendererUsage( Qgis::RendererUsage rendererUsage );
652
658 Qgis::ViewSyncModeFlags viewSyncMode() const;
659
665 void setViewSyncMode( Qgis::ViewSyncModeFlags mode );
666
672 bool viewFrustumVisualizationEnabled() const;
673
679 void setViewFrustumVisualizationEnabled( bool enabled );
680
685 Qgs3DAxisSettings get3DAxisSettings() const SIP_SKIP;
686
691 void set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force = false ) SIP_SKIP;
692
698 bool isDebugOverlayEnabled() const;
699
708 void setIsDebugOverlayEnabled( bool debugOverlayEnabled );
709
715 bool showExtentIn2DView() const;
716
721 void setShowExtentIn2DView( bool show );
722
727 void setShowDebugPanel( bool enabled );
728
733 bool showDebugPanel() const;
734
735 signals:
736
742 void settingsChanged();
743
745 void backgroundColorChanged();
747 void selectionColorChanged();
748
755 void layersChanged();
756
758 void terrainGeneratorChanged();
760 void terrainVerticalScaleChanged();
762 void mapTileResolutionChanged();
764 void maxTerrainScreenErrorChanged();
766 void maxTerrainGroundErrorChanged();
767
772 void terrainElevationOffsetChanged( float newElevation );
773
778 void terrainShadingChanged();
779
784 void terrainMapThemeChanged();
785
790 void renderersChanged();
791
793 void showTerrainBoundingBoxesChanged();
795 void showTerrainTilesInfoChanged();
796
801 void showCameraViewCenterChanged();
802
807 void showCameraRotationCenterChanged();
808
813 void showLightSourceOriginsChanged();
814
816 void showLabelsChanged();
817
822 void stopUpdatesChanged();
823
828 void eyeDomeLightingEnabledChanged();
829
834 void eyeDomeLightingStrengthChanged();
835
840 void eyeDomeLightingDistanceChanged();
841
846 void debugShadowMapSettingsChanged();
847
852 void debugDepthMapSettingsChanged();
853
858 void pointLightsChanged();
859
864 void lightSourcesChanged();
865
870 void directionalLightsChanged();
871
876 void fieldOfViewChanged();
877
882 void projectionTypeChanged();
883
888 void cameraNavigationModeChanged();
889
894 void cameraMovementSpeedChanged();
895
900 void skyboxSettingsChanged();
901
906 void shadowSettingsChanged();
907
908
913 void ambientOcclusionSettingsChanged();
914
919 void fpsCounterEnabledChanged( bool fpsCounterEnabled );
920
926 void viewFrustumVisualizationEnabledChanged();
927
932 void axisSettingsChanged();
933
938 void debugOverlayEnabledChanged( bool debugOverlayEnabled );
939
945 void extentChanged();
946
952 void showExtentIn2DViewChanged();
953
959 void showDebugPanelChanged( bool shown );
960
961 private:
962#ifdef SIP_RUN
963 Qgs3DMapSettings &operator=( const Qgs3DMapSettings & );
964#endif
965
966 private:
968 void connectChangedSignalsToSettingsChanged();
969
970 private:
972 QgsVector3D mOrigin;
974 QColor mBackgroundColor = Qt::black;
975 QColor mSelectionColor;
976 double mTerrainVerticalScale = 1;
977 std::unique_ptr<QgsTerrainGenerator> mTerrainGenerator;
978 int mMapTileResolution = 512;
979 float mMaxTerrainScreenError = 3.f;
980 float mMaxTerrainGroundError = 1.f;
981 float mTerrainElevationOffset = 0.0f;
982 bool mTerrainShadingEnabled = false;
983 QgsPhongMaterialSettings mTerrainShadingMaterial;
984 QString mTerrainMapTheme;
985 bool mShowTerrainBoundingBoxes = false;
986 bool mShowTerrainTileInfo = false;
987 bool mShowCameraViewCenter = false;
988 bool mShowCameraRotationCenter = false;
989 bool mShowLightSources = false;
990 bool mShowLabels = false;
991 bool mStopUpdates = false;
992 bool mShowDebugPanel = false;
993 QList< QgsLightSource * > mLightSources;
994 float mFieldOfView = 45.0f; //<! Camera lens field of view value
995 Qt3DRender::QCameraLens::ProjectionType mProjectionType = Qt3DRender::QCameraLens::PerspectiveProjection; //<! Camera lens projection type
997 double mCameraMovementSpeed = 5.0;
998 QList<QgsMapLayerRef> mLayers;
1000 QgsCoordinateTransformContext mTransformContext;
1001 QgsPathResolver mPathResolver;
1002 QgsMapThemeCollection *mMapThemes = nullptr;
1003 double mDpi = 96;
1004 bool mIsFpsCounterEnabled = false;
1005
1006 bool mIsSkyboxEnabled = false;
1007 QgsSkyboxSettings mSkyboxSettings;
1008 QgsShadowSettings mShadowSettings;
1009 QgsAmbientOcclusionSettings mAmbientOcclusionSettings;
1010
1011 bool mEyeDomeLightingEnabled = false;
1012 double mEyeDomeLightingStrength = 1000.0;
1013 int mEyeDomeLightingDistance = 1;
1014
1015 Qgis::ViewSyncModeFlags mViewSyncMode;
1016 bool mVisualizeViewFrustum = false;
1017
1018 bool mDebugShadowMapEnabled = false;
1019 Qt::Corner mDebugShadowMapCorner = Qt::Corner::TopLeftCorner;
1020 double mDebugShadowMapSize = 0.2;
1021
1022 bool mDebugDepthMapEnabled = false;
1023 Qt::Corner mDebugDepthMapCorner = Qt::Corner::BottomLeftCorner;
1024 double mDebugDepthMapSize = 0.2;
1025
1026 bool mTerrainRenderingEnabled = true;
1027
1028 Qgis::RendererUsage mRendererUsage;
1029
1030 Qgs3DAxisSettings m3dAxisSettings;
1031
1032 bool mIsDebugOverlayEnabled = false;
1033
1034 QgsRectangle mExtent;
1035
1036 bool mShowExtentIn2DView = false;
1037
1038};
1039
1040
1041#endif // QGS3DMAPSETTINGS_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
QFlags< ViewSyncModeFlag > ViewSyncModeFlags
Definition qgis.h:3233
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:3872
@ TerrainBased
The default navigation based on the terrain.
RendererUsage
Usage of the renderer.
Definition qgis.h:3196
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_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36
const QgsCoordinateReferenceSystem & crs