QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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
441 void setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size );
443 bool debugShadowMapEnabled() const;
445 Qt::Corner debugShadowMapCorner() const;
447 double debugShadowMapSize() const;
448
456 void setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size );
458 bool debugDepthMapEnabled() const;
460 Qt::Corner debugDepthMapCorner() const;
462 double debugDepthMapSize() const;
463
469 QList<QgsLightSource *> lightSources() const;
470
479 void setLightSources( const QList<QgsLightSource *> &lights SIP_TRANSFER );
480
485 float fieldOfView() const;
486
491 void setFieldOfView( const float fieldOfView );
492
497 Qt3DRender::QCameraLens::ProjectionType projectionType() const SIP_SKIP;
498
503 void setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType ) SIP_SKIP;
504
505#ifndef SIP_RUN
506
511 Qgis::NavigationMode cameraNavigationMode() const;
512
517 void setCameraNavigationMode( Qgis::NavigationMode navigationMode );
518#endif
519
524 double cameraMovementSpeed() const;
525
530 void setCameraMovementSpeed( double movementSpeed );
531
537 void setOutputDpi( const double dpi );
538
544 double outputDpi() const;
545
550 QgsSkyboxSettings skyboxSettings() const SIP_SKIP;
551
556 QgsShadowSettings shadowSettings() const SIP_SKIP;
557
562 QgsAmbientOcclusionSettings ambientOcclusionSettings() const SIP_SKIP;
563
568 void setSkyboxSettings( const QgsSkyboxSettings &skyboxSettings ) SIP_SKIP;
569
574 void setShadowSettings( const QgsShadowSettings &shadowSettings ) SIP_SKIP;
575
580 void setAmbientOcclusionSettings( const QgsAmbientOcclusionSettings &ambientOcclusionSettings ) SIP_SKIP;
581
587 bool isSkyboxEnabled() const;
588
594 void setIsSkyboxEnabled( bool enabled );
595
601 bool isFpsCounterEnabled() const;
602
608 void setIsFpsCounterEnabled( bool fpsCounterEnabled );
609
615 bool terrainRenderingEnabled() const;
616
622 void setTerrainRenderingEnabled( bool terrainRenderingEnabled );
623
630 Qgis::RendererUsage rendererUsage() const;
631
638 void setRendererUsage( Qgis::RendererUsage rendererUsage );
639
645 Qgis::ViewSyncModeFlags viewSyncMode() const;
646
652 void setViewSyncMode( Qgis::ViewSyncModeFlags mode );
653
659 bool viewFrustumVisualizationEnabled() const;
660
666 void setViewFrustumVisualizationEnabled( bool enabled );
667
672 Qgs3DAxisSettings get3DAxisSettings() const SIP_SKIP;
673
678 void set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force = false ) SIP_SKIP;
679
685 bool isDebugOverlayEnabled() const;
686
695 void setIsDebugOverlayEnabled( bool debugOverlayEnabled );
696
702 bool showExtentIn2DView() const;
703
708 void setShowExtentIn2DView( bool show );
709
710 signals:
711
717 void settingsChanged();
718
720 void backgroundColorChanged();
722 void selectionColorChanged();
723
730 void layersChanged();
731
733 void terrainGeneratorChanged();
735 void terrainVerticalScaleChanged();
737 void mapTileResolutionChanged();
739 void maxTerrainScreenErrorChanged();
741 void maxTerrainGroundErrorChanged();
742
747 void terrainElevationOffsetChanged( float newElevation );
748
753 void terrainShadingChanged();
754
759 void terrainMapThemeChanged();
760
765 void renderersChanged();
766
768 void showTerrainBoundingBoxesChanged();
770 void showTerrainTilesInfoChanged();
771
776 void showCameraViewCenterChanged();
777
782 void showCameraRotationCenterChanged();
783
788 void showLightSourceOriginsChanged();
789
791 void showLabelsChanged();
792
797 void eyeDomeLightingEnabledChanged();
798
803 void eyeDomeLightingStrengthChanged();
804
809 void eyeDomeLightingDistanceChanged();
810
815 void debugShadowMapSettingsChanged();
816
821 void debugDepthMapSettingsChanged();
822
827 void pointLightsChanged();
828
833 void lightSourcesChanged();
834
839 void directionalLightsChanged();
840
845 void fieldOfViewChanged();
846
851 void projectionTypeChanged();
852
857 void cameraNavigationModeChanged();
858
863 void cameraMovementSpeedChanged();
864
869 void skyboxSettingsChanged();
870
875 void shadowSettingsChanged();
876
877
882 void ambientOcclusionSettingsChanged();
883
888 void fpsCounterEnabledChanged( bool fpsCounterEnabled );
889
895 void viewFrustumVisualizationEnabledChanged();
896
901 void axisSettingsChanged();
902
907 void debugOverlayEnabledChanged( bool debugOverlayEnabled );
908
914 void extentChanged();
915
921 void showExtentIn2DViewChanged();
922
923 private:
924#ifdef SIP_RUN
925 Qgs3DMapSettings &operator=( const Qgs3DMapSettings & );
926#endif
927
928 private:
930 void connectChangedSignalsToSettingsChanged();
931
932 private:
934 QgsVector3D mOrigin;
936 QColor mBackgroundColor = Qt::black;
937 QColor mSelectionColor;
938 double mTerrainVerticalScale = 1;
939 std::unique_ptr<QgsTerrainGenerator> mTerrainGenerator;
940 int mMapTileResolution = 512;
941 float mMaxTerrainScreenError = 3.f;
942 float mMaxTerrainGroundError = 1.f;
943 float mTerrainElevationOffset = 0.0f;
944 bool mTerrainShadingEnabled = false;
945 QgsPhongMaterialSettings mTerrainShadingMaterial;
946 QString mTerrainMapTheme;
947 bool mShowTerrainBoundingBoxes = false;
948 bool mShowTerrainTileInfo = false;
949 bool mShowCameraViewCenter = false;
950 bool mShowCameraRotationCenter = false;
951 bool mShowLightSources = false;
952 bool mShowLabels = false;
953 QList< QgsLightSource * > mLightSources;
954 float mFieldOfView = 45.0f; //<! Camera lens field of view value
955 Qt3DRender::QCameraLens::ProjectionType mProjectionType = Qt3DRender::QCameraLens::PerspectiveProjection; //<! Camera lens projection type
957 double mCameraMovementSpeed = 5.0;
958 QList<QgsMapLayerRef> mLayers;
960 QgsCoordinateTransformContext mTransformContext;
961 QgsPathResolver mPathResolver;
962 QgsMapThemeCollection *mMapThemes = nullptr;
963 double mDpi = 96;
964 bool mIsFpsCounterEnabled = false;
965
966 bool mIsSkyboxEnabled = false;
967 QgsSkyboxSettings mSkyboxSettings;
968 QgsShadowSettings mShadowSettings;
969 QgsAmbientOcclusionSettings mAmbientOcclusionSettings;
970
971 bool mEyeDomeLightingEnabled = false;
972 double mEyeDomeLightingStrength = 1000.0;
973 int mEyeDomeLightingDistance = 1;
974
975 Qgis::ViewSyncModeFlags mViewSyncMode;
976 bool mVisualizeViewFrustum = false;
977
978 bool mDebugShadowMapEnabled = false;
979 Qt::Corner mDebugShadowMapCorner = Qt::Corner::TopLeftCorner;
980 double mDebugShadowMapSize = 0.2;
981
982 bool mDebugDepthMapEnabled = false;
983 Qt::Corner mDebugDepthMapCorner = Qt::Corner::TopRightCorner;
984 double mDebugDepthMapSize = 0.2;
985
986 bool mTerrainRenderingEnabled = true;
987
988 Qgis::RendererUsage mRendererUsage;
989
990 Qgs3DAxisSettings m3dAxisSettings;
991
992 bool mIsDebugOverlayEnabled = false;
993
994 QgsRectangle mExtent;
995
996 bool mShowExtentIn2DView = false;
997
998};
999
1000
1001#endif // QGS3DMAPSETTINGS_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
QFlags< ViewSyncModeFlag > ViewSyncModeFlags
Definition qgis.h:3225
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:3864
@ TerrainBased
The default navigation based on the terrain.
RendererUsage
Usage of the renderer.
Definition qgis.h:3188
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