QGIS API Documentation 3.39.0-Master (9ea1ddbe645)
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 setDebugShadowMapSettings( bool enabled, Qt::Corner corner, double size );
441 bool debugShadowMapEnabled() const;
443 Qt::Corner debugShadowMapCorner() const;
445 double debugShadowMapSize() const;
446
452 void setDebugDepthMapSettings( bool enabled, Qt::Corner corner, double size );
454 bool debugDepthMapEnabled() const;
456 Qt::Corner debugDepthMapCorner() const;
458 double debugDepthMapSize() const;
459
465 QList<QgsLightSource *> lightSources() const;
466
475 void setLightSources( const QList<QgsLightSource *> &lights SIP_TRANSFER );
476
481 float fieldOfView() const;
482
487 void setFieldOfView( const float fieldOfView );
488
493 Qt3DRender::QCameraLens::ProjectionType projectionType() const SIP_SKIP;
494
499 void setProjectionType( const Qt3DRender::QCameraLens::ProjectionType projectionType ) SIP_SKIP;
500
501#ifndef SIP_RUN
502
507 Qgis::NavigationMode cameraNavigationMode() const;
508
513 void setCameraNavigationMode( Qgis::NavigationMode navigationMode );
514#endif
515
520 double cameraMovementSpeed() const;
521
526 void setCameraMovementSpeed( double movementSpeed );
527
533 void setOutputDpi( const double dpi );
534
540 double outputDpi() const;
541
546 QgsSkyboxSettings skyboxSettings() const SIP_SKIP;
547
552 QgsShadowSettings shadowSettings() const SIP_SKIP;
553
558 QgsAmbientOcclusionSettings ambientOcclusionSettings() const SIP_SKIP;
559
564 void setSkyboxSettings( const QgsSkyboxSettings &skyboxSettings ) SIP_SKIP;
565
570 void setShadowSettings( const QgsShadowSettings &shadowSettings ) SIP_SKIP;
571
576 void setAmbientOcclusionSettings( const QgsAmbientOcclusionSettings &ambientOcclusionSettings ) SIP_SKIP;
577
583 bool isSkyboxEnabled() const;
584
590 void setIsSkyboxEnabled( bool enabled );
591
597 bool isFpsCounterEnabled() const;
598
604 void setIsFpsCounterEnabled( bool fpsCounterEnabled );
605
611 bool terrainRenderingEnabled() const;
612
618 void setTerrainRenderingEnabled( bool terrainRenderingEnabled );
619
626 Qgis::RendererUsage rendererUsage() const;
627
634 void setRendererUsage( Qgis::RendererUsage rendererUsage );
635
641 Qgis::ViewSyncModeFlags viewSyncMode() const;
642
648 void setViewSyncMode( Qgis::ViewSyncModeFlags mode );
649
655 bool viewFrustumVisualizationEnabled() const;
656
662 void setViewFrustumVisualizationEnabled( bool enabled );
663
668 Qgs3DAxisSettings get3DAxisSettings() const SIP_SKIP;
669
674 void set3DAxisSettings( const Qgs3DAxisSettings &axisSettings, bool force = false ) SIP_SKIP;
675
681 bool isDebugOverlayEnabled() const;
682
691 void setIsDebugOverlayEnabled( bool debugOverlayEnabled );
692
698 bool showExtentIn2DView() const;
699
704 void setShowExtentIn2DView( bool show );
705
706 signals:
707
713 void settingsChanged();
714
716 void backgroundColorChanged();
718 void selectionColorChanged();
719
726 void layersChanged();
727
729 void terrainGeneratorChanged();
731 void terrainVerticalScaleChanged();
733 void mapTileResolutionChanged();
735 void maxTerrainScreenErrorChanged();
737 void maxTerrainGroundErrorChanged();
738
743 void terrainElevationOffsetChanged( float newElevation );
744
749 void terrainShadingChanged();
750
755 void terrainMapThemeChanged();
756
761 void renderersChanged();
762
764 void showTerrainBoundingBoxesChanged();
766 void showTerrainTilesInfoChanged();
767
772 void showCameraViewCenterChanged();
773
778 void showCameraRotationCenterChanged();
779
784 void showLightSourceOriginsChanged();
785
787 void showLabelsChanged();
788
793 void eyeDomeLightingEnabledChanged();
794
799 void eyeDomeLightingStrengthChanged();
800
805 void eyeDomeLightingDistanceChanged();
806
811 void debugShadowMapSettingsChanged();
812
817 void debugDepthMapSettingsChanged();
818
823 void pointLightsChanged();
824
829 void lightSourcesChanged();
830
835 void directionalLightsChanged();
836
841 void fieldOfViewChanged();
842
847 void projectionTypeChanged();
848
853 void cameraNavigationModeChanged();
854
859 void cameraMovementSpeedChanged();
860
865 void skyboxSettingsChanged();
866
871 void shadowSettingsChanged();
872
873
878 void ambientOcclusionSettingsChanged();
879
884 void fpsCounterEnabledChanged( bool fpsCounterEnabled );
885
891 void viewFrustumVisualizationEnabledChanged();
892
897 void axisSettingsChanged();
898
903 void debugOverlayEnabledChanged( bool debugOverlayEnabled );
904
910 void extentChanged();
911
917 void showExtentIn2DViewChanged();
918
919 private:
920#ifdef SIP_RUN
921 Qgs3DMapSettings &operator=( const Qgs3DMapSettings & );
922#endif
923
924 private:
926 void connectChangedSignalsToSettingsChanged();
927
928 private:
930 QgsVector3D mOrigin;
932 QColor mBackgroundColor = Qt::black;
933 QColor mSelectionColor;
934 double mTerrainVerticalScale = 1;
935 std::unique_ptr<QgsTerrainGenerator> mTerrainGenerator;
936 int mMapTileResolution = 512;
937 float mMaxTerrainScreenError = 3.f;
938 float mMaxTerrainGroundError = 1.f;
939 float mTerrainElevationOffset = 0.0f;
940 bool mTerrainShadingEnabled = false;
941 QgsPhongMaterialSettings mTerrainShadingMaterial;
942 QString mTerrainMapTheme;
943 bool mShowTerrainBoundingBoxes = false;
944 bool mShowTerrainTileInfo = false;
945 bool mShowCameraViewCenter = false;
946 bool mShowCameraRotationCenter = false;
947 bool mShowLightSources = false;
948 bool mShowLabels = false;
949 QList< QgsLightSource * > mLightSources;
950 float mFieldOfView = 45.0f; //<! Camera lens field of view value
951 Qt3DRender::QCameraLens::ProjectionType mProjectionType = Qt3DRender::QCameraLens::PerspectiveProjection; //<! Camera lens projection type
953 double mCameraMovementSpeed = 5.0;
954 QList<QgsMapLayerRef> mLayers;
956 QgsCoordinateTransformContext mTransformContext;
957 QgsPathResolver mPathResolver;
958 QgsMapThemeCollection *mMapThemes = nullptr;
959 double mDpi = 96;
960 bool mIsFpsCounterEnabled = false;
961
962 bool mIsSkyboxEnabled = false;
963 QgsSkyboxSettings mSkyboxSettings;
964 QgsShadowSettings mShadowSettings;
965 QgsAmbientOcclusionSettings mAmbientOcclusionSettings;
966
967 bool mEyeDomeLightingEnabled = false;
968 double mEyeDomeLightingStrength = 1000.0;
969 int mEyeDomeLightingDistance = 1;
970
971 Qgis::ViewSyncModeFlags mViewSyncMode;
972 bool mVisualizeViewFrustum = false;
973
974 bool mDebugShadowMapEnabled = false;
975 Qt::Corner mDebugShadowMapCorner = Qt::Corner::TopLeftCorner;
976 double mDebugShadowMapSize = 0.2;
977
978 bool mDebugDepthMapEnabled = false;
979 Qt::Corner mDebugDepthMapCorner = Qt::Corner::TopRightCorner;
980 double mDebugDepthMapSize = 0.2;
981
982 bool mTerrainRenderingEnabled = true;
983
984 Qgis::RendererUsage mRendererUsage;
985
986 Qgs3DAxisSettings m3dAxisSettings;
987
988 bool mIsDebugOverlayEnabled = false;
989
990 QgsRectangle mExtent;
991
992 bool mShowExtentIn2DView = false;
993
994};
995
996
997#endif // QGS3DMAPSETTINGS_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
QFlags< ViewSyncModeFlag > ViewSyncModeFlags
Definition qgis.h:3061
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:3699
@ TerrainBased
The default navigation based on the terrain.
RendererUsage
Usage of the renderer.
Definition qgis.h:3043
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:75
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