From eef2e2045f0130dcf9843175a06f449240b66556 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Tue, 10 Dec 2024 14:22:51 +0100 Subject: [PATCH 1/4] add server and 3d to clang-format --- .pre-commit-config.yaml | 2 -- scripts/prepare_commit.sh | 2 +- scripts/verify_indentation.sh | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4a49a929c9e..b3194e97210 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,8 +17,6 @@ repos: exclude: | (?x)^( src/core/.*| - src/3d/.*| - src/server/.*| tests/code_layout/sipify/sipifyheader.h )$ diff --git a/scripts/prepare_commit.sh b/scripts/prepare_commit.sh index e16baf2e105..82f7b2c3053 100755 --- a/scripts/prepare_commit.sh +++ b/scripts/prepare_commit.sh @@ -120,7 +120,7 @@ for f in $MODIFIED; do esac # only run astyle on sipified directories, others are handled by clang-format (see .pre-commit-config.yaml) - if [[ $f =~ ^src/(core|3d|server) ]]; then + if [[ $f =~ ^src/(core) ]]; then m=$f.$REV.prepare cp "$f" "$m" ASTYLEPROGRESS=" [$i/$N]" astyle.sh "$f" diff --git a/scripts/verify_indentation.sh b/scripts/verify_indentation.sh index 70510ade58d..bac8b052ce1 100755 --- a/scripts/verify_indentation.sh +++ b/scripts/verify_indentation.sh @@ -40,7 +40,7 @@ for f in $FILES; do esac # only run astyle on sipified directories, others are handled by clang-format (see .pre-commit-config.yaml) - if [[ $f =~ ^src/(core|3d|server) ]]; then + if [[ $f =~ ^src/(core) ]]; then m="$f.prepare" cp "$f" "$m" astyle.sh "$f" From 3a4f8bcdad4f843d7217116ac1cb94b6b6c3fb8b Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Tue, 10 Dec 2024 14:41:57 +0100 Subject: [PATCH 2/4] run clang-format on 3d + server --- src/3d/chunks/qgschunkedentity.cpp | 64 +- src/3d/chunks/qgschunkedentity.h | 6 +- src/3d/chunks/qgschunklist_p.cpp | 2 +- src/3d/chunks/qgschunklist_p.h | 16 +- src/3d/chunks/qgschunkloader.h | 12 +- src/3d/chunks/qgschunknode.cpp | 28 +- src/3d/chunks/qgschunknode.h | 104 +- src/3d/lights/qgsdirectionallightsettings.cpp | 4 +- src/3d/lights/qgslightsource.cpp | 7 +- src/3d/lights/qgslightsource.h | 2 - src/3d/lights/qgspointlightsettings.cpp | 8 +- .../materials/qgsabstractmaterialsettings.cpp | 17 +- .../materials/qgsabstractmaterialsettings.h | 33 +- src/3d/materials/qgsgoochmaterialsettings.cpp | 7 +- src/3d/materials/qgsgoochmaterialsettings.h | 20 +- src/3d/materials/qgsmaterial.cpp | 5 +- src/3d/materials/qgsmaterial.h | 3 - src/3d/materials/qgsmaterialregistry.h | 10 +- src/3d/materials/qgsmetalroughmaterial.cpp | 18 +- src/3d/materials/qgsmetalroughmaterial.h | 2 - .../qgsmetalroughmaterialsettings.cpp | 5 +- .../materials/qgsmetalroughmaterialsettings.h | 8 +- src/3d/materials/qgsnullmaterialsettings.cpp | 2 +- src/3d/materials/qgsnullmaterialsettings.h | 2 - src/3d/materials/qgsphongmaterialsettings.cpp | 66 +- src/3d/materials/qgsphongmaterialsettings.h | 19 +- src/3d/materials/qgsphongtexturedmaterial.cpp | 18 +- src/3d/materials/qgsphongtexturedmaterial.h | 1 - .../qgsphongtexturedmaterialsettings.cpp | 13 +- .../qgsphongtexturedmaterialsettings.h | 18 +- .../qgssimplelinematerialsettings.cpp | 6 +- .../materials/qgssimplelinematerialsettings.h | 9 +- src/3d/materials/qgstexturematerial.cpp | 3 +- src/3d/materials/qgstexturematerial.h | 2 - src/3d/mesh/qgsmesh3dentity_p.cpp | 20 +- src/3d/mesh/qgsmesh3dentity_p.h | 23 +- src/3d/mesh/qgsmesh3dgeometry_p.cpp | 81 +- src/3d/mesh/qgsmesh3dgeometry_p.h | 81 +- src/3d/mesh/qgsmesh3dmaterial_p.cpp | 55 +- src/3d/mesh/qgsmesh3dmaterial_p.h | 10 +- src/3d/mesh/qgsmeshterraingenerator.cpp | 7 +- src/3d/mesh/qgsmeshterraingenerator.h | 6 +- src/3d/mesh/qgsmeshterraintileloader_p.h | 9 +- src/3d/processing/qgs3dalgorithms.cpp | 3 - src/3d/processing/qgs3dalgorithms.h | 7 +- src/3d/processing/qgsalgorithmtessellate.cpp | 12 +- src/3d/processing/qgsalgorithmtessellate.h | 5 - src/3d/qgs3d.cpp | 27 +- src/3d/qgs3d.h | 4 - src/3d/qgs3danimationsettings.cpp | 8 +- src/3d/qgs3danimationsettings.h | 11 +- src/3d/qgs3daxis.cpp | 185 +-- src/3d/qgs3daxis.h | 16 +- src/3d/qgs3daxissettings.cpp | 3 +- src/3d/qgs3daxissettings.h | 12 +- src/3d/qgs3dexportobject.cpp | 31 +- src/3d/qgs3dexportobject.h | 7 +- src/3d/qgs3dmapcanvas.cpp | 19 +- src/3d/qgs3dmapcanvas.h | 9 +- src/3d/qgs3dmapscene.cpp | 117 +- src/3d/qgs3dmapscene.h | 14 +- src/3d/qgs3dmapsceneentity.h | 14 +- src/3d/qgs3dmapsettings.cpp | 47 +- src/3d/qgs3dmapsettings.h | 60 +- src/3d/qgs3dmaptool.cpp | 1 - src/3d/qgs3drendercontext.h | 12 +- src/3d/qgs3dsceneexporter.cpp | 38 +- src/3d/qgs3dsceneexporter.h | 5 +- src/3d/qgs3dtypes.h | 15 +- src/3d/qgs3dutils.cpp | 153 ++- src/3d/qgs3dutils.h | 16 +- src/3d/qgs3dwiredmesh_p.cpp | 2 +- src/3d/qgs3dwiredmesh_p.h | 5 +- src/3d/qgsaabb.cpp | 8 +- src/3d/qgsabstract3dengine.cpp | 13 +- src/3d/qgsabstract3dengine.h | 4 +- src/3d/qgsabstractvectorlayer3drenderer.cpp | 1 - src/3d/qgsabstractvectorlayer3drenderer.h | 5 +- src/3d/qgsambientocclusionblurentity.h | 1 + src/3d/qgsambientocclusionrenderentity.cpp | 17 +- src/3d/qgsambientocclusionrenderentity.h | 1 - src/3d/qgsambientocclusionsettings.cpp | 1 - src/3d/qgsambientocclusionsettings.h | 1 - src/3d/qgscameracontroller.cpp | 68 +- src/3d/qgscameracontroller.h | 10 +- src/3d/qgscamerapose.cpp | 5 +- src/3d/qgscamerapose.h | 8 +- src/3d/qgscolorramptexture.cpp | 7 +- src/3d/qgscolorramptexture.h | 7 +- src/3d/qgsfgutils.cpp | 30 +- src/3d/qgsfgutils.h | 3 +- src/3d/qgsframegraph.cpp | 48 +- src/3d/qgsgltf3dutils.cpp | 12 +- src/3d/qgsgltf3dutils.h | 26 +- src/3d/qgsimagetexture.h | 2 - src/3d/qgslayoutitem3dmap.cpp | 4 +- src/3d/qgslayoutitem3dmap.h | 7 +- src/3d/qgsmeshlayer3drenderer.cpp | 5 +- src/3d/qgsmeshlayer3drenderer.h | 4 +- src/3d/qgsoffscreen3dengine.cpp | 3 +- src/3d/qgsoffscreen3dengine.h | 15 +- src/3d/qgspointcloudlayer3drenderer.cpp | 16 +- src/3d/qgspointcloudlayer3drenderer.h | 26 +- src/3d/qgspointcloudlayerchunkloader_p.cpp | 50 +- src/3d/qgspointcloudlayerchunkloader_p.h | 15 +- src/3d/qgspostprocessingentity.cpp | 20 +- src/3d/qgspreviewquad.cpp | 12 +- src/3d/qgspreviewquad.h | 4 +- src/3d/qgsraycastingutils.cpp | 106 +- src/3d/qgsraycastingutils.h | 44 +- src/3d/qgsraycastingutils_p.h | 17 +- src/3d/qgsrenderpassquad.cpp | 4 +- src/3d/qgsrubberband3d.cpp | 19 +- src/3d/qgsrubberband3d.h | 16 +- src/3d/qgsrulebased3drenderer.cpp | 4 +- src/3d/qgsrulebased3drenderer.h | 8 +- src/3d/qgsrulebasedchunkloader_p.cpp | 7 +- src/3d/qgsrulebasedchunkloader_p.h | 1 + src/3d/qgsshadowsettings.cpp | 1 - src/3d/qgsshadowsettings.h | 1 - src/3d/qgsskyboxentity.h | 3 + src/3d/qgsskyboxsettings.cpp | 25 +- src/3d/qgsskyboxsettings.h | 1 - src/3d/qgstessellatedpolygongeometry.cpp | 12 +- src/3d/qgstessellatedpolygongeometry.h | 10 +- src/3d/qgstiledscenechunkloader_p.cpp | 38 +- src/3d/qgstiledscenechunkloader_p.h | 6 +- src/3d/qgstiledscenelayer3drenderer.cpp | 7 +- src/3d/qgstiledscenelayer3drenderer.h | 2 - src/3d/qgstilingscheme.cpp | 4 +- src/3d/qgstilingscheme.h | 10 +- src/3d/qgsvectorlayer3drenderer.h | 2 +- src/3d/qgsvectorlayerchunkloader_p.cpp | 11 +- src/3d/qgsvirtualpointcloudentity_p.cpp | 9 +- src/3d/qgsvirtualpointcloudentity_p.h | 5 +- src/3d/qgswindow3dengine.h | 2 +- src/3d/symbols/qgsbillboardgeometry.cpp | 7 +- src/3d/symbols/qgsbillboardgeometry.h | 6 +- src/3d/symbols/qgsline3dsymbol.cpp | 13 +- src/3d/symbols/qgsline3dsymbol.h | 13 +- src/3d/symbols/qgsline3dsymbol_p.cpp | 58 +- src/3d/symbols/qgsline3dsymbol_p.h | 2 +- src/3d/symbols/qgslinematerial_p.cpp | 2 +- src/3d/symbols/qgslinematerial_p.h | 1 - src/3d/symbols/qgslinevertexdata_p.cpp | 26 +- src/3d/symbols/qgslinevertexdata_p.h | 44 +- src/3d/symbols/qgsmesh3dsymbol.cpp | 7 +- src/3d/symbols/qgsmesh3dsymbol.h | 11 +- .../symbols/qgspoint3dbillboardmaterial.cpp | 4 +- src/3d/symbols/qgspoint3dsymbol.cpp | 47 +- src/3d/symbols/qgspoint3dsymbol.h | 11 +- src/3d/symbols/qgspoint3dsymbol_p.cpp | 62 +- src/3d/symbols/qgspoint3dsymbol_p.h | 2 +- src/3d/symbols/qgspointcloud3dsymbol.cpp | 11 +- src/3d/symbols/qgspointcloud3dsymbol.h | 9 +- src/3d/symbols/qgspointcloud3dsymbol_p.cpp | 73 +- src/3d/symbols/qgspointcloud3dsymbol_p.h | 41 +- src/3d/symbols/qgspolygon3dsymbol.cpp | 16 +- src/3d/symbols/qgspolygon3dsymbol.h | 14 +- src/3d/symbols/qgspolygon3dsymbol_p.cpp | 67 +- src/3d/symbols/qgspolygon3dsymbol_p.h | 2 +- src/3d/terrain/qgsdemterraingenerator.h | 6 +- .../terrain/qgsdemterraintilegeometry_p.cpp | 23 +- src/3d/terrain/qgsdemterraintilegeometry_p.h | 17 +- src/3d/terrain/qgsdemterraintileloader_p.cpp | 24 +- src/3d/terrain/qgsdemterraintileloader_p.h | 14 +- src/3d/terrain/qgsflatterraingenerator.cpp | 9 +- src/3d/terrain/qgsflatterraingenerator.h | 4 - src/3d/terrain/qgsonlineterraingenerator.h | 7 +- .../qgsquantizedmeshterraingenerator.cpp | 41 +- src/3d/terrain/qgsterraindownloader.cpp | 6 +- src/3d/terrain/qgsterraindownloader.h | 13 +- src/3d/terrain/qgsterrainentity.cpp | 7 +- src/3d/terrain/qgsterrainentity.h | 2 - src/3d/terrain/qgsterraingenerator.cpp | 3 +- src/3d/terrain/qgsterraingenerator.h | 15 +- .../terrain/qgsterraintexturegenerator_p.cpp | 5 +- src/3d/terrain/qgsterraintexturegenerator_p.h | 10 +- src/3d/terrain/qgsterraintextureimage_p.cpp | 7 +- src/3d/terrain/qgsterraintileloader.cpp | 2 +- src/3d/terrain/qgsterraintileloader.h | 2 - src/server/qgis_map_serv.cpp | 5 +- src/server/qgis_mapserver.cpp | 158 +-- src/server/qgsaccesscontrol.cpp | 3 +- src/server/qgsaccesscontrol.h | 3 +- src/server/qgsaccesscontrolfilter.cpp | 4 +- src/server/qgsaccesscontrolfilter.h | 12 +- src/server/qgsbufferserverrequest.h | 1 - src/server/qgsbufferserverresponse.cpp | 8 +- src/server/qgsbufferserverresponse.h | 16 +- src/server/qgscapabilitiescache.cpp | 25 +- src/server/qgscapabilitiescache.h | 4 +- src/server/qgsconfigcache.cpp | 48 +- src/server/qgsconfigcache.h | 10 +- src/server/qgsdimensionfilter.cpp | 1 - src/server/qgsdimensionfilter.h | 2 +- src/server/qgsfcgiserverrequest.cpp | 26 +- src/server/qgsfcgiserverrequest.h | 4 +- src/server/qgsfcgiserverresponse.cpp | 63 +- src/server/qgsfcgiserverresponse.h | 12 +- src/server/qgsfeaturefilter.h | 1 - src/server/qgsfeaturefilterprovidergroup.h | 2 - src/server/qgsfilterresponsedecorator.cpp | 8 +- src/server/qgsfilterresponsedecorator.h | 11 +- src/server/qgsfilterrestorer.cpp | 3 +- src/server/qgsfilterrestorer.h | 6 +- src/server/qgsmapserviceexception.h | 1 - src/server/qgsrequesthandler.cpp | 14 +- src/server/qgsrequesthandler.h | 6 +- src/server/qgsserver.cpp | 91 +- src/server/qgsserver.h | 11 +- src/server/qgsserverapi.cpp | 1 - src/server/qgsserverapi.h | 6 - src/server/qgsserverapicontext.cpp | 15 +- src/server/qgsserverapicontext.h | 9 +- src/server/qgsserverapiutils.cpp | 156 +-- src/server/qgsserverapiutils.h | 13 +- src/server/qgsservercachefilter.h | 3 - src/server/qgsservercachemanager.cpp | 8 +- src/server/qgsservercachemanager.h | 2 +- src/server/qgsserverexception.cpp | 9 +- src/server/qgsserverexception.h | 27 +- src/server/qgsserverfeatureid.cpp | 2 +- src/server/qgsserverfeatureid.h | 11 +- src/server/qgsserverfilter.cpp | 4 +- src/server/qgsserverfilter.h | 4 - src/server/qgsserverinterface.cpp | 4 +- src/server/qgsserverinterface.h | 1 - src/server/qgsserverinterfaceimpl.h | 9 +- src/server/qgsserverlogger.cpp | 2 +- src/server/qgsserverlogger.h | 1 - src/server/qgsserverogcapi.cpp | 31 +- src/server/qgsserverogcapi.h | 38 +- src/server/qgsserverogcapihandler.cpp | 158 +-- src/server/qgsserverogcapihandler.h | 23 +- src/server/qgsserverparameters.cpp | 38 +- src/server/qgsserverparameters.h | 17 +- src/server/qgsserverplugins.cpp | 6 +- src/server/qgsserverplugins.h | 1 - src/server/qgsserverprojectutils.cpp | 35 +- src/server/qgsserverprojectutils.h | 11 +- src/server/qgsserverquerystringparameter.cpp | 38 +- src/server/qgsserverquerystringparameter.h | 18 +- src/server/qgsserverrequest.cpp | 5 +- src/server/qgsserverrequest.h | 36 +- src/server/qgsserverresponse.cpp | 2 - src/server/qgsserverresponse.h | 3 +- src/server/qgsserversettings.cpp | 395 ++---- src/server/qgsserversettings.h | 60 +- src/server/qgsserverstatichandler.cpp | 12 +- src/server/qgsserverstatichandler.h | 6 +- src/server/qgsservice.cpp | 1 - src/server/qgsservice.h | 6 +- src/server/qgsservicemodule.h | 5 +- src/server/qgsservicenativeloader.cpp | 13 +- src/server/qgsservicenativeloader.h | 7 +- src/server/qgsserviceregistry.cpp | 86 +- src/server/qgsserviceregistry.h | 11 +- src/server/qgsstorebadlayerinfo.h | 3 +- .../services/landingpage/qgslandingpage.cpp | 38 +- .../landingpage/qgslandingpagehandlers.cpp | 20 +- .../landingpage/qgslandingpagehandlers.h | 9 +- .../landingpage/qgslandingpageutils.cpp | 267 ++-- .../landingpage/qgslandingpageutils.h | 30 +- src/server/services/qgsmodule.h | 2 - src/server/services/wcs/qgswcs.cpp | 22 +- .../services/wcs/qgswcsdescribecoverage.cpp | 13 +- .../services/wcs/qgswcsdescribecoverage.h | 6 +- .../services/wcs/qgswcsgetcapabilities.cpp | 47 +- .../services/wcs/qgswcsgetcapabilities.h | 9 +- src/server/services/wcs/qgswcsgetcoverage.cpp | 8 +- src/server/services/wcs/qgswcsgetcoverage.h | 3 +- .../services/wcs/qgswcsserviceexception.h | 15 +- src/server/services/wcs/qgswcsutils.cpp | 14 +- src/server/services/wcs/qgswcsutils.h | 2 - src/server/services/wfs/qgswfs.cpp | 24 +- .../wfs/qgswfsdescribefeaturetype.cpp | 20 +- .../services/wfs/qgswfsdescribefeaturetype.h | 3 +- .../wfs/qgswfsdescribefeaturetypegml.cpp | 28 +- .../wfs/qgswfsdescribefeaturetypegml.h | 8 +- .../wfs/qgswfsdescribefeaturetypejson.cpp | 9 +- .../wfs/qgswfsdescribefeaturetypejson.h | 8 +- .../services/wfs/qgswfsgetcapabilities.cpp | 74 +- .../services/wfs/qgswfsgetcapabilities.h | 9 +- .../wfs/qgswfsgetcapabilities_1_0_0.cpp | 113 +- .../wfs/qgswfsgetcapabilities_1_0_0.h | 9 +- src/server/services/wfs/qgswfsgetfeature.cpp | 126 +- src/server/services/wfs/qgswfsgetfeature.h | 25 +- src/server/services/wfs/qgswfsparameters.cpp | 63 +- src/server/services/wfs/qgswfsparameters.h | 7 +- .../services/wfs/qgswfsserviceexception.h | 18 +- src/server/services/wfs/qgswfstransaction.cpp | 35 +- src/server/services/wfs/qgswfstransaction.h | 58 +- .../services/wfs/qgswfstransaction_1_0_0.cpp | 35 +- .../services/wfs/qgswfstransaction_1_0_0.h | 54 +- src/server/services/wfs/qgswfsutils.cpp | 11 +- src/server/services/wfs3/qgswfs3.cpp | 9 +- src/server/services/wfs3/qgswfs3handlers.cpp | 1105 +++++------------ src/server/services/wfs3/qgswfs3handlers.h | 38 +- src/server/services/wms/qgsdxfwriter.cpp | 4 +- src/server/services/wms/qgsdxfwriter.h | 4 +- .../services/wms/qgsmaprendererjobproxy.cpp | 9 +- .../services/wms/qgsmaprendererjobproxy.h | 7 +- src/server/services/wms/qgsmediancut.cpp | 20 +- src/server/services/wms/qgsmediancut.h | 2 - src/server/services/wms/qgspdfwriter.cpp | 4 +- src/server/services/wms/qgspdfwriter.h | 4 +- src/server/services/wms/qgswms.cpp | 31 +- .../services/wms/qgswmsdescribelayer.cpp | 23 +- src/server/services/wms/qgswmsdescribelayer.h | 7 +- .../services/wms/qgswmsgetcapabilities.cpp | 208 ++-- .../services/wms/qgswmsgetcapabilities.h | 29 +- src/server/services/wms/qgswmsgetcontext.cpp | 51 +- src/server/services/wms/qgswmsgetcontext.h | 13 +- .../services/wms/qgswmsgetfeatureinfo.cpp | 9 +- .../services/wms/qgswmsgetfeatureinfo.h | 8 +- .../services/wms/qgswmsgetlegendgraphics.cpp | 42 +- .../services/wms/qgswmsgetlegendgraphics.h | 4 +- src/server/services/wms/qgswmsgetmap.cpp | 7 +- src/server/services/wms/qgswmsgetmap.h | 4 +- src/server/services/wms/qgswmsgetprint.cpp | 7 +- src/server/services/wms/qgswmsgetprint.h | 8 +- .../services/wms/qgswmsgetschemaextension.cpp | 6 +- .../services/wms/qgswmsgetschemaextension.h | 4 - src/server/services/wms/qgswmsgetstyles.cpp | 16 +- src/server/services/wms/qgswmsgetstyles.h | 6 +- src/server/services/wms/qgswmslayerinfos.cpp | 29 +- src/server/services/wms/qgswmslayerinfos.h | 14 +- src/server/services/wms/qgswmsparameters.cpp | 277 ++--- src/server/services/wms/qgswmsparameters.h | 96 +- .../services/wms/qgswmsrendercontext.cpp | 82 +- src/server/services/wms/qgswmsrendercontext.h | 32 +- src/server/services/wms/qgswmsrenderer.cpp | 360 +++--- src/server/services/wms/qgswmsrenderer.h | 26 +- src/server/services/wms/qgswmsrequest.cpp | 2 +- src/server/services/wms/qgswmsrequest.h | 3 +- src/server/services/wms/qgswmsrestorer.cpp | 6 +- src/server/services/wms/qgswmsrestorer.h | 18 +- .../services/wms/qgswmsserviceexception.h | 14 +- src/server/services/wms/qgswmsutils.cpp | 41 +- src/server/services/wms/qgswmsutils.h | 15 +- src/server/services/wmts/qgswmts.cpp | 22 +- .../services/wmts/qgswmtsgetcapabilities.cpp | 74 +- .../services/wmts/qgswmtsgetcapabilities.h | 11 +- .../services/wmts/qgswmtsgetfeatureinfo.cpp | 8 +- .../services/wmts/qgswmtsgetfeatureinfo.h | 4 +- src/server/services/wmts/qgswmtsgettile.cpp | 8 +- src/server/services/wmts/qgswmtsgettile.h | 4 +- .../services/wmts/qgswmtsparameters.cpp | 60 +- src/server/services/wmts/qgswmtsparameters.h | 7 +- .../services/wmts/qgswmtsserviceexception.h | 15 +- src/server/services/wmts/qgswmtsutils.cpp | 56 +- src/server/services/wmts/qgswmtsutils.h | 73 +- 353 files changed, 3589 insertions(+), 5900 deletions(-) diff --git a/src/3d/chunks/qgschunkedentity.cpp b/src/3d/chunks/qgschunkedentity.cpp index 148e196bf5a..51008b28a6a 100644 --- a/src/3d/chunks/qgschunkedentity.cpp +++ b/src/3d/chunks/qgschunkedentity.cpp @@ -73,8 +73,7 @@ QgsChunkedEntity::QgsChunkedEntity( Qgs3DMapSettings *mapSettings, float tau, Qg mReplacementQueue = new QgsChunkList; // in case the chunk loader factory supports fetching of hierarchy in background (to avoid GUI freezes) - connect( loaderFactory, &QgsChunkLoaderFactory::childrenPrepared, this, [this] - { + connect( loaderFactory, &QgsChunkLoaderFactory::childrenPrepared, this, [this] { setNeedsUpdate( true ); emit pendingJobsCountChanged(); } ); @@ -99,7 +98,7 @@ QgsChunkedEntity::~QgsChunkedEntity() else if ( node->state() == QgsChunkNode::QueuedForUpdate ) node->cancelQueuedForUpdate(); else - Q_ASSERT( false ); // impossible! + Q_ASSERT( false ); // impossible! } delete mChunkLoaderQueue; @@ -211,19 +210,12 @@ void QgsChunkedEntity::handleSceneUpdate( const SceneContext &sceneContext ) // start a job from queue if there is anything waiting startJobs(); - mNeedsUpdate = false; // just updated + mNeedsUpdate = false; // just updated if ( pendingJobsCount() != oldJobsCount ) emit pendingJobsCountChanged(); - QgsDebugMsgLevel( QStringLiteral( "update: active %1 enabled %2 disabled %3 | culled %4 | loading %5 loaded %6 | unloaded %7 elapsed %8ms" ).arg( mActiveNodes.count() ) - .arg( enabled ) - .arg( disabled ) - .arg( mFrustumCulled ) - .arg( mChunkLoaderQueue->count() ) - .arg( mReplacementQueue->count() ) - .arg( unloaded ) - .arg( t.elapsed() ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "update: active %1 enabled %2 disabled %3 | culled %4 | loading %5 loaded %6 | unloaded %7 elapsed %8ms" ).arg( mActiveNodes.count() ).arg( enabled ).arg( disabled ).arg( mFrustumCulled ).arg( mChunkLoaderQueue->count() ).arg( mReplacementQueue->count() ).arg( unloaded ).arg( t.elapsed() ), 2 ); } @@ -255,7 +247,7 @@ int QgsChunkedEntity::unloadNodes() mReplacementQueue->takeEntry( entry ); usedGpuMemory -= Qgs3DUtils::calculateEntityGpuMemorySize( entry->chunk->entity() ); mActiveNodes.removeOne( entry->chunk ); - entry->chunk->unloadChunk(); // also deletes the entry + entry->chunk->unloadChunk(); // also deletes the entry ++unloaded; entry = entryPrev; } @@ -370,7 +362,7 @@ void QgsChunkedEntity::pruneLoaderQueue( const SceneContext &sceneContext ) { n->cancelQueuedForLoad(); } - else // queued for update + else // queued for update { n->cancelQueuedForUpdate(); mReplacementQueue->takeEntry( n->replacementQueueEntry() ); @@ -392,28 +384,29 @@ int QgsChunkedEntity::pendingJobsCount() const struct ResidencyRequest { - QgsChunkNode *node = nullptr; - float dist = 0.0; - int level = -1; - ResidencyRequest() = default; - ResidencyRequest( - QgsChunkNode *n, - float d, - int l ) - : node( n ) - , dist( d ) - , level( l ) - {} + QgsChunkNode *node = nullptr; + float dist = 0.0; + int level = -1; + ResidencyRequest() = default; + ResidencyRequest( + QgsChunkNode *n, + float d, + int l + ) + : node( n ) + , dist( d ) + , level( l ) + {} }; struct { - bool operator()( const ResidencyRequest &request, const ResidencyRequest &otherRequest ) const - { - if ( request.level == otherRequest.level ) - return request.dist > otherRequest.dist; - return request.level > otherRequest.level; - } + bool operator()( const ResidencyRequest &request, const ResidencyRequest &otherRequest ) const + { + if ( request.level == otherRequest.level ) + return request.dist > otherRequest.dist; + return request.level > otherRequest.level; + } } ResidencyRequestSorter; void QgsChunkedEntity::update( QgsChunkNode *root, const SceneContext &sceneContext ) @@ -422,8 +415,7 @@ void QgsChunkedEntity::update( QgsChunkNode *root, const SceneContext &sceneCont QVector residencyRequests; using slotItem = std::pair; - auto cmp_funct = []( const slotItem & p1, const slotItem & p2 ) - { + auto cmp_funct = []( const slotItem &p1, const slotItem &p2 ) { return p1.second <= p2.second; }; int renderedCount = 0; @@ -598,7 +590,7 @@ void QgsChunkedEntity::requestResidency( QgsChunkNode *node ) else if ( node->state() == QgsChunkNode::Skeleton ) { if ( !node->hasData() ) - return; // no need to load (we already tried but got nothing back) + return; // no need to load (we already tried but got nothing back) // add to the loading queue QgsChunkListEntry *entry = new QgsChunkListEntry( node ); @@ -712,7 +704,7 @@ QgsChunkQueueJob *QgsChunkedEntity::startJob( QgsChunkNode *node ) } else { - Q_ASSERT( false ); // not possible + Q_ASSERT( false ); // not possible return nullptr; } } diff --git a/src/3d/chunks/qgschunkedentity.h b/src/3d/chunks/qgschunkedentity.h index 4f277428c60..2271479a110 100644 --- a/src/3d/chunks/qgschunkedentity.h +++ b/src/3d/chunks/qgschunkedentity.h @@ -45,7 +45,7 @@ namespace QgsRayCastingUtils class Ray3D; struct RayCastContext; struct RayHit; -} +} // namespace QgsRayCastingUtils #include #include @@ -65,9 +65,7 @@ class QgsChunkedEntity : public Qgs3DMapSceneEntity Q_OBJECT public: //! Constructs a chunked entity - QgsChunkedEntity( Qgs3DMapSettings *mapSettings, float tau, QgsChunkLoaderFactory *loaderFactory, bool ownsFactory, - int primitivesBudget = std::numeric_limits::max(), - Qt3DCore::QNode *parent = nullptr ); + QgsChunkedEntity( Qgs3DMapSettings *mapSettings, float tau, QgsChunkLoaderFactory *loaderFactory, bool ownsFactory, int primitivesBudget = std::numeric_limits::max(), Qt3DCore::QNode *parent = nullptr ); ~QgsChunkedEntity() override; //! Called when e.g. camera changes and entity may need updated diff --git a/src/3d/chunks/qgschunklist_p.cpp b/src/3d/chunks/qgschunklist_p.cpp index 95ae834fc10..32ff2a3609e 100644 --- a/src/3d/chunks/qgschunklist_p.cpp +++ b/src/3d/chunks/qgschunklist_p.cpp @@ -53,7 +53,7 @@ void QgsChunkList::insertEntry( QgsChunkListEntry *entry, QgsChunkListEntry *nex next->prev = entry; } if ( next == mHead ) - mHead = entry; // update head if "entry" we was head before + mHead = entry; // update head if "entry" we was head before } ++mCount; } diff --git a/src/3d/chunks/qgschunklist_p.h b/src/3d/chunks/qgschunklist_p.h index 6c65ebcc3c8..44f1817a075 100644 --- a/src/3d/chunks/qgschunklist_p.h +++ b/src/3d/chunks/qgschunklist_p.h @@ -40,15 +40,15 @@ class QgsChunkNode; */ struct QgsChunkListEntry { - //! Constructs entry for a particular node - QgsChunkListEntry( QgsChunkNode *node ) - : chunk( node ) - { - } + //! Constructs entry for a particular node + QgsChunkListEntry( QgsChunkNode *node ) + : chunk( node ) + { + } - QgsChunkListEntry *prev = nullptr; - QgsChunkListEntry *next = nullptr; - QgsChunkNode *chunk; //!< TODO: shared pointer + QgsChunkListEntry *prev = nullptr; + QgsChunkListEntry *next = nullptr; + QgsChunkNode *chunk; //!< TODO: shared pointer }; diff --git a/src/3d/chunks/qgschunkloader.h b/src/3d/chunks/qgschunkloader.h index a716537ff77..1d19f5386ea 100644 --- a/src/3d/chunks/qgschunkloader.h +++ b/src/3d/chunks/qgschunkloader.h @@ -45,7 +45,8 @@ class QgsChunkLoader : public QgsChunkQueueJob Q_OBJECT public: //! Construct chunk loader for a node - QgsChunkLoader( QgsChunkNode *node ) : QgsChunkQueueJob( node ) { } + QgsChunkLoader( QgsChunkNode *node ) + : QgsChunkQueueJob( node ) {} /** * Run in main thread to use loaded data. @@ -59,7 +60,7 @@ class QgsChunkLoader : public QgsChunkQueueJob * \ingroup 3d * \brief Factory for chunk loaders for a particular type of entity */ -class QgsChunkLoaderFactory : public QObject +class QgsChunkLoaderFactory : public QObject { Q_OBJECT public: @@ -91,7 +92,11 @@ class QgsChunkLoaderFactory : public QObject * \see prepareChildren() * \see createChildren() */ - virtual bool canCreateChildren( QgsChunkNode *node ) { Q_UNUSED( node ); return true; } + virtual bool canCreateChildren( QgsChunkNode *node ) + { + Q_UNUSED( node ); + return true; + } /** * Requests that node has enough hierarchy information to create children in createChildren(). @@ -137,7 +142,6 @@ class _3D_EXPORT QgsQuadtreeChunkLoaderFactory : public QgsChunkLoaderFactory float mRootError = 0; //! maximum allowed depth of quad tree int mMaxLevel = 0; - }; /// @endcond diff --git a/src/3d/chunks/qgschunknode.cpp b/src/3d/chunks/qgschunknode.cpp index d6df1fd7251..a6e83398042 100644 --- a/src/3d/chunks/qgschunknode.cpp +++ b/src/3d/chunks/qgschunknode.cpp @@ -15,7 +15,7 @@ #include "qgschunknode.h" -#include "qgschunkedentity.h" // for ChunkLoader destructor +#include "qgschunkedentity.h" // for ChunkLoader destructor #include "qgschunklist_p.h" #include "qgschunkloader.h" #include @@ -56,7 +56,7 @@ bool QgsChunkNode::allChildChunksResident( QTime currentTime ) const for ( int i = 0; i < childCount(); ++i ) { if ( mChildren[i]->mHasData && !mChildren[i]->mEntity ) - return false; // no there yet + return false; // no there yet Q_UNUSED( currentTime ) // seems we do not need this extra time (it just brings extra problems) //if (children[i]->entityCreatedTime.msecsTo(currentTime) < 100) // return false; // allow some time for upload of stuff within Qt3D (TODO: better way to check it is ready?) @@ -136,7 +136,7 @@ void QgsChunkNode::cancelLoading() Q_ASSERT( !mEntity ); Q_ASSERT( !mReplacementQueueEntry ); - mLoader = nullptr; // not owned by chunk node + mLoader = nullptr; // not owned by chunk node mState = QgsChunkNode::Skeleton; } @@ -151,7 +151,7 @@ void QgsChunkNode::setLoaded( Qt3DCore::QEntity *newEntity ) mEntity = newEntity; mEntityCreatedTime = QTime::currentTime(); - mLoader = nullptr; // not owned by chunk node + mLoader = nullptr; // not owned by chunk node mState = QgsChunkNode::Loaded; mReplacementQueueEntry = new QgsChunkListEntry( this ); @@ -194,7 +194,7 @@ void QgsChunkNode::cancelQueuedForUpdate() Q_ASSERT( !mUpdater ); mState = Loaded; - mUpdaterFactory = nullptr; // not owned by the node + mUpdaterFactory = nullptr; // not owned by the node delete mLoaderQueueEntry; mLoaderQueueEntry = nullptr; @@ -211,7 +211,7 @@ void QgsChunkNode::setUpdating() mState = Updating; mUpdater = mUpdaterFactory->createJob( this ); - mUpdaterFactory = nullptr; // not owned by the node + mUpdaterFactory = nullptr; // not owned by the node mLoaderQueueEntry = nullptr; } @@ -221,7 +221,7 @@ void QgsChunkNode::cancelUpdating() Q_ASSERT( mUpdater ); Q_ASSERT( !mLoaderQueueEntry ); - mUpdater = nullptr; // not owned by chunk node + mUpdater = nullptr; // not owned by chunk node mState = Loaded; } @@ -233,7 +233,7 @@ void QgsChunkNode::setUpdated() Q_ASSERT( !mLoaderQueueEntry ); Q_ASSERT( mReplacementQueueEntry ); - mUpdater = nullptr; // not owned by chunk node + mUpdater = nullptr; // not owned by chunk node mState = QgsChunkNode::Loaded; } @@ -251,12 +251,12 @@ void QgsChunkNode::updateParentBoundingBoxesRecursively() const while ( currentNode ) { QgsChunkNode *const *currentNodeChildren = currentNode->children(); - double xMin = std::numeric_limits< double >::max(); - double xMax = -std::numeric_limits< double >::max(); - double yMin = std::numeric_limits< double >::max(); - double yMax = -std::numeric_limits< double >::max(); - double zMin = std::numeric_limits< double >::max(); - double zMax = -std::numeric_limits< double >::max(); + double xMin = std::numeric_limits::max(); + double xMax = -std::numeric_limits::max(); + double yMin = std::numeric_limits::max(); + double yMax = -std::numeric_limits::max(); + double zMin = std::numeric_limits::max(); + double zMax = -std::numeric_limits::max(); for ( int i = 0; i < currentNode->childCount(); ++i ) { diff --git a/src/3d/chunks/qgschunknode.h b/src/3d/chunks/qgschunknode.h index 70a4b210b29..38ed56daaa6 100644 --- a/src/3d/chunks/qgschunknode.h +++ b/src/3d/chunks/qgschunknode.h @@ -60,49 +60,48 @@ class QgsChunkQueueJobFactory; */ struct QgsChunkNodeId { - - /** + /** * Constructs node ID from depth, x, y and z. */ - QgsChunkNodeId( int _d = -1, int _x = -1, int _y = -1, int _z = -1 ) - : d( _d ), x( _x ), y( _y ), z( _z ) {} + QgsChunkNodeId( int _d = -1, int _x = -1, int _y = -1, int _z = -1 ) + : d( _d ), x( _x ), y( _y ), z( _z ) {} - /** + /** * Constructs node ID from a unique integer ID. * * Useful for nodes which are not structured in a quadtree or octree arrangement. */ - QgsChunkNodeId( long long id ) - : uniqueId( id ) - {} + QgsChunkNodeId( long long id ) + : uniqueId( id ) + {} - int d = 0; - int x = 0; - int y = 0; - int z = 0; - long long uniqueId = -1; + int d = 0; + int x = 0; + int y = 0; + int z = 0; + long long uniqueId = -1; - //! Returns textual representation of the node ID in form of "Z/X/Y" - QString text() const - { - if ( uniqueId != -1 ) - return QString::number( uniqueId ); - else if ( z == -1 ) - return QStringLiteral( "%1/%2/%3" ).arg( d ).arg( x ).arg( y ); // quadtree - else - return QStringLiteral( "%1/%2/%3/%4" ).arg( d ).arg( x ).arg( y ).arg( z ); // octree - } + //! Returns textual representation of the node ID in form of "Z/X/Y" + QString text() const + { + if ( uniqueId != -1 ) + return QString::number( uniqueId ); + else if ( z == -1 ) + return QStringLiteral( "%1/%2/%3" ).arg( d ).arg( x ).arg( y ); // quadtree + else + return QStringLiteral( "%1/%2/%3/%4" ).arg( d ).arg( x ).arg( y ).arg( z ); // octree + } - bool operator==( const QgsChunkNodeId &other ) const - { - return ( uniqueId == -1 && other.uniqueId == -1 && d == other.d && x == other.x && y == other.y && z == other.z ) - || ( uniqueId != -1 && uniqueId == other.uniqueId ); - } + bool operator==( const QgsChunkNodeId &other ) const + { + return ( uniqueId == -1 && other.uniqueId == -1 && d == other.d && x == other.x && y == other.y && z == other.z ) + || ( uniqueId != -1 && uniqueId == other.uniqueId ); + } - bool operator!=( const QgsChunkNodeId &other ) const - { - return !( *this == other ); - } + bool operator!=( const QgsChunkNodeId &other ) const + { + return !( *this == other ); + } }; /** @@ -124,7 +123,6 @@ struct QgsChunkNodeId class QgsChunkNode { public: - //! constructs a skeleton chunk QgsChunkNode( const QgsChunkNodeId &nodeId, const QgsBox3D &box3D, float error, QgsChunkNode *parent = nullptr ); @@ -150,12 +148,12 @@ class QgsChunkNode */ enum State { - Skeleton, //!< Does not contain data of the chunk and data are not being loaded - QueuedForLoad, //!< Data are not available yet, but node is in the request queue - Loading, //!< Data are being loaded right now - Loaded, //!< Data are fully available - QueuedForUpdate, //!< Loaded, but some data need to be updated - the node is in the queue - Updating, //!< Data are being updated right now + Skeleton, //!< Does not contain data of the chunk and data are not being loaded + QueuedForLoad, //!< Data are not available yet, but node is in the request queue + Loading, //!< Data are being loaded right now + Loaded, //!< Data are fully available + QueuedForUpdate, //!< Loaded, but some data need to be updated - the node is in the queue + Updating, //!< Data are being updated right now }; //! Returns 3D bounding box (in map coordinates) of the chunk @@ -259,30 +257,30 @@ class QgsChunkNode bool hasData() const { return mHasData; } private: - QgsBox3D mBox3D; //!< Bounding box in map coordinates + QgsBox3D mBox3D; //!< Bounding box in map coordinates float mError; //!< Error of the node in world coordinates (negative error means that chunk at this level has no data, but there may be children that do) - QgsChunkNodeId mNodeId; //!< Chunk coordinates (for use with a tiling scheme) + QgsChunkNodeId mNodeId; //!< Chunk coordinates (for use with a tiling scheme) - QgsChunkNode *mParent; //!< TODO: should be shared pointer - QVector mChildren; //!< Child nodes of this node. Initially children are not be populated - bool mChildrenPopulated = false; //!< Whether the child nodes (if any) have been already created + QgsChunkNode *mParent; //!< TODO: should be shared pointer + QVector mChildren; //!< Child nodes of this node. Initially children are not be populated + bool mChildrenPopulated = false; //!< Whether the child nodes (if any) have been already created - State mState; //!< State of the node + State mState; //!< State of the node - Qgis::TileRefinementProcess mRefinementProcess = Qgis::TileRefinementProcess::Replacement; //!< How to handle display of the node when children get activated + Qgis::TileRefinementProcess mRefinementProcess = Qgis::TileRefinementProcess::Replacement; //!< How to handle display of the node when children get activated - QgsChunkListEntry *mLoaderQueueEntry; //!< Not null <=> QueuedForLoad or QueuedForUpdate state - QgsChunkListEntry *mReplacementQueueEntry; //!< Not null <=> has non-null entity (Loaded or QueuedForUpdate or Updating state) + QgsChunkListEntry *mLoaderQueueEntry; //!< Not null <=> QueuedForLoad or QueuedForUpdate state + QgsChunkListEntry *mReplacementQueueEntry; //!< Not null <=> has non-null entity (Loaded or QueuedForUpdate or Updating state) - QgsChunkLoader *mLoader; //!< Contains extra data necessary for entity creation (not null <=> Loading state) - Qt3DCore::QEntity *mEntity; //!< Contains everything to display chunk as 3D object (not null <=> Loaded or QueuedForUpdate or Updating state) + QgsChunkLoader *mLoader; //!< Contains extra data necessary for entity creation (not null <=> Loading state) + Qt3DCore::QEntity *mEntity; //!< Contains everything to display chunk as 3D object (not null <=> Loaded or QueuedForUpdate or Updating state) - QgsChunkQueueJobFactory *mUpdaterFactory; //!< Object that creates updater (not null <=> QueuedForUpdate state) - QgsChunkQueueJob *mUpdater; //!< Object that does update of the chunk (not null <=> Updating state) + QgsChunkQueueJobFactory *mUpdaterFactory; //!< Object that creates updater (not null <=> QueuedForUpdate state) + QgsChunkQueueJob *mUpdater; //!< Object that does update of the chunk (not null <=> Updating state) QTime mEntityCreatedTime; - bool mHasData = true; //!< Whether there are (will be) any data in this node and so whether it makes sense to load this node + bool mHasData = true; //!< Whether there are (will be) any data in this node and so whether it makes sense to load this node }; /// @endcond diff --git a/src/3d/lights/qgsdirectionallightsettings.cpp b/src/3d/lights/qgsdirectionallightsettings.cpp index e70dd7a0c1e..df334fb2b95 100644 --- a/src/3d/lights/qgsdirectionallightsettings.cpp +++ b/src/3d/lights/qgsdirectionallightsettings.cpp @@ -59,9 +59,7 @@ QDomElement QgsDirectionalLightSettings::writeXml( QDomDocument &doc, const QgsR void QgsDirectionalLightSettings::readXml( const QDomElement &elem, const QgsReadWriteContext & ) { - mDirection.set( elem.attribute( QStringLiteral( "x" ) ).toFloat(), - elem.attribute( QStringLiteral( "y" ) ).toFloat(), - elem.attribute( QStringLiteral( "z" ) ).toFloat() ); + mDirection.set( elem.attribute( QStringLiteral( "x" ) ).toFloat(), elem.attribute( QStringLiteral( "y" ) ).toFloat(), elem.attribute( QStringLiteral( "z" ) ).toFloat() ); mColor = QgsColorUtils::colorFromString( elem.attribute( QStringLiteral( "color" ) ) ); mIntensity = elem.attribute( QStringLiteral( "intensity" ) ).toFloat(); } diff --git a/src/3d/lights/qgslightsource.cpp b/src/3d/lights/qgslightsource.cpp index 1083f0ae1ed..cdacf88b214 100644 --- a/src/3d/lights/qgslightsource.cpp +++ b/src/3d/lights/qgslightsource.cpp @@ -24,19 +24,18 @@ QgsLightSource::~QgsLightSource() = default; void QgsLightSource::resolveReferences( const QgsProject & ) { - } QgsLightSource *QgsLightSource::createFromXml( const QDomElement &element, const QgsReadWriteContext &context ) { - std::unique_ptr< QgsLightSource > res; + std::unique_ptr res; if ( element.nodeName() == QLatin1String( "point-light" ) ) { - res = std::make_unique< QgsPointLightSettings >(); + res = std::make_unique(); } else if ( element.nodeName() == QLatin1String( "directional-light" ) ) { - res = std::make_unique< QgsDirectionalLightSettings >(); + res = std::make_unique(); } if ( res ) diff --git a/src/3d/lights/qgslightsource.h b/src/3d/lights/qgslightsource.h index 3cd0338f8c4..84397eaa94f 100644 --- a/src/3d/lights/qgslightsource.h +++ b/src/3d/lights/qgslightsource.h @@ -45,9 +45,7 @@ namespace Qt3DCore */ class _3D_EXPORT QgsLightSource SIP_ABSTRACT { - public: - virtual ~QgsLightSource(); /** diff --git a/src/3d/lights/qgspointlightsettings.cpp b/src/3d/lights/qgspointlightsettings.cpp index 344294fc394..ec2d7d2b258 100644 --- a/src/3d/lights/qgspointlightsettings.cpp +++ b/src/3d/lights/qgspointlightsettings.cpp @@ -99,9 +99,7 @@ QDomElement QgsPointLightSettings::writeXml( QDomDocument &doc, const QgsReadWri void QgsPointLightSettings::readXml( const QDomElement &elem, const QgsReadWriteContext & ) { - mPosition.set( elem.attribute( QStringLiteral( "x" ) ).toDouble(), - elem.attribute( QStringLiteral( "y" ) ).toDouble(), - elem.attribute( QStringLiteral( "z" ) ).toDouble() ); + mPosition.set( elem.attribute( QStringLiteral( "x" ) ).toDouble(), elem.attribute( QStringLiteral( "y" ) ).toDouble(), elem.attribute( QStringLiteral( "z" ) ).toDouble() ); mColor = QgsColorUtils::colorFromString( elem.attribute( QStringLiteral( "color" ) ) ); mIntensity = elem.attribute( QStringLiteral( "intensity" ) ).toFloat(); mConstantAttenuation = elem.attribute( QStringLiteral( "attenuation-0" ) ).toDouble(); @@ -111,7 +109,5 @@ void QgsPointLightSettings::readXml( const QDomElement &elem, const QgsReadWrite bool QgsPointLightSettings::operator==( const QgsPointLightSettings &other ) { - return mPosition == other.mPosition && mColor == other.mColor && mIntensity == other.mIntensity && - mConstantAttenuation == other.mConstantAttenuation && mLinearAttenuation == other.mLinearAttenuation && - mQuadraticAttenuation == other.mQuadraticAttenuation; + return mPosition == other.mPosition && mColor == other.mColor && mIntensity == other.mIntensity && mConstantAttenuation == other.mConstantAttenuation && mLinearAttenuation == other.mLinearAttenuation && mQuadraticAttenuation == other.mQuadraticAttenuation; } diff --git a/src/3d/materials/qgsabstractmaterialsettings.cpp b/src/3d/materials/qgsabstractmaterialsettings.cpp index efe0b0d31df..f70ea3547d0 100644 --- a/src/3d/materials/qgsabstractmaterialsettings.cpp +++ b/src/3d/materials/qgsabstractmaterialsettings.cpp @@ -36,7 +36,7 @@ void QgsAbstractMaterialSettings::setDataDefinedProperties( const QgsPropertyCol mDataDefinedProperties = collection; } -QgsPropertyCollection QgsAbstractMaterialSettings::dataDefinedProperties() const {return mDataDefinedProperties;} +QgsPropertyCollection QgsAbstractMaterialSettings::dataDefinedProperties() const { return mDataDefinedProperties; } const QgsPropertiesDefinition &QgsAbstractMaterialSettings::propertyDefinitions() const { @@ -51,7 +51,7 @@ QByteArray QgsAbstractMaterialSettings::dataDefinedVertexColorsAsByte( const Qgs return QByteArray(); } -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) void QgsAbstractMaterialSettings::applyDataDefinedToGeometry( Qt3DRender::QGeometry *geometry, int vertexCount, const QByteArray &dataDefinedBytes ) const #else void QgsAbstractMaterialSettings::applyDataDefinedToGeometry( Qt3DCore::QGeometry *geometry, int vertexCount, const QByteArray &dataDefinedBytes ) const @@ -69,12 +69,11 @@ void QgsAbstractMaterialSettings::initPropertyDefinitions() const const QString origin = QStringLiteral( "material3d" ); - sPropertyDefinitions = QgsPropertiesDefinition - { - { static_cast< int >( Property::Diffuse ), QgsPropertyDefinition( "diffuse", QObject::tr( "Diffuse" ), QgsPropertyDefinition::ColorNoAlpha, origin ) }, - { static_cast< int >( Property::Ambient ), QgsPropertyDefinition( "ambient", QObject::tr( "Ambient" ), QgsPropertyDefinition::ColorNoAlpha, origin ) }, - { static_cast< int >( Property::Warm ), QgsPropertyDefinition( "warm", QObject::tr( "Warm" ), QgsPropertyDefinition::ColorNoAlpha, origin ) }, - { static_cast< int >( Property::Cool ), QgsPropertyDefinition( "cool", QObject::tr( "Cool" ), QgsPropertyDefinition::ColorNoAlpha, origin ) }, - { static_cast< int >( Property::Specular ), QgsPropertyDefinition( "specular", QObject::tr( "Specular" ), QgsPropertyDefinition::ColorNoAlpha, origin ) } + sPropertyDefinitions = QgsPropertiesDefinition { + { static_cast( Property::Diffuse ), QgsPropertyDefinition( "diffuse", QObject::tr( "Diffuse" ), QgsPropertyDefinition::ColorNoAlpha, origin ) }, + { static_cast( Property::Ambient ), QgsPropertyDefinition( "ambient", QObject::tr( "Ambient" ), QgsPropertyDefinition::ColorNoAlpha, origin ) }, + { static_cast( Property::Warm ), QgsPropertyDefinition( "warm", QObject::tr( "Warm" ), QgsPropertyDefinition::ColorNoAlpha, origin ) }, + { static_cast( Property::Cool ), QgsPropertyDefinition( "cool", QObject::tr( "Cool" ), QgsPropertyDefinition::ColorNoAlpha, origin ) }, + { static_cast( Property::Specular ), QgsPropertyDefinition( "specular", QObject::tr( "Specular" ), QgsPropertyDefinition::ColorNoAlpha, origin ) } }; } diff --git a/src/3d/materials/qgsabstractmaterialsettings.h b/src/3d/materials/qgsabstractmaterialsettings.h index ee26df32fe7..50de9ab1628 100644 --- a/src/3d/materials/qgsabstractmaterialsettings.h +++ b/src/3d/materials/qgsabstractmaterialsettings.h @@ -29,7 +29,7 @@ class QgsLineMaterial; class QgsExpressionContext; #ifndef SIP_RUN -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) namespace Qt3DRender { class QGeometry; @@ -47,15 +47,15 @@ namespace Qt3DCore * \ingroup 3d * \since QGIS 3.16 */ -enum class QgsMaterialSettingsRenderingTechnique SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsAbstractMaterialSettings, RenderingTechnique ): int - { - Triangles, //!< Triangle based rendering (default) - Lines, //!< Line based rendering, requires line data - InstancedPoints, //!< Instanced based rendering, requiring triangles and point data - Points, //!< Point based rendering, requires point data +enum class QgsMaterialSettingsRenderingTechnique SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsAbstractMaterialSettings, RenderingTechnique ) : int +{ + Triangles, //!< Triangle based rendering (default) + Lines, //!< Line based rendering, requires line data + InstancedPoints, //!< Instanced based rendering, requiring triangles and point data + Points, //!< Point based rendering, requires point data TrianglesWithFixedTexture, //!< Triangle based rendering, using a fixed, non-user-configurable texture (e.g. for terrain rendering) - TrianglesFromModel, //!< Triangle based rendering, using a model object source - TrianglesDataDefined, //!< Triangle based rendering with possibility of datadefined color \since QGIS 3.18 + TrianglesFromModel, //!< Triangle based rendering, using a model object source + TrianglesDataDefined, //!< Triangle based rendering with possibility of datadefined color \since QGIS 3.18 }; @@ -71,7 +71,6 @@ enum class QgsMaterialSettingsRenderingTechnique SIP_MONKEYPATCH_SCOPEENUM_UNNES class _3D_EXPORT QgsMaterialContext { public: - /** * Returns TRUE if the material should represent a selected state. * @@ -101,11 +100,9 @@ class _3D_EXPORT QgsMaterialContext void setSelectionColor( const QColor &color ) { mSelectedColor = color; } private: - bool mIsSelected = false; QColor mSelectedColor; - }; @@ -119,7 +116,6 @@ class _3D_EXPORT QgsMaterialContext */ class _3D_EXPORT QgsAbstractMaterialSettings SIP_ABSTRACT { - #ifdef SIP_RUN SIP_CONVERT_TO_SUBCLASS_CODE if ( sipCpp->type() == QLatin1String( "gooch" ) ) @@ -150,7 +146,6 @@ class _3D_EXPORT QgsAbstractMaterialSettings SIP_ABSTRACT #endif public: - virtual ~QgsAbstractMaterialSettings() = default; /** @@ -204,8 +199,8 @@ class _3D_EXPORT QgsAbstractMaterialSettings SIP_ABSTRACT { Diffuse, //!< Diffuse color Ambient, //!< Ambient color (phong material) - Warm, //!< Warm color (gooch material) - Cool,//!< Cool color (gooch material) + Warm, //!< Warm color (gooch material) + Cool, //!< Cool color (gooch material) Specular //!< Specular color }; // *INDENT-ON* @@ -226,13 +221,13 @@ class _3D_EXPORT QgsAbstractMaterialSettings SIP_ABSTRACT * Returns a reference to the material properties definition, used for data defined overrides. * \since QGIS 3.18 */ - const QgsPropertiesDefinition &propertyDefinitions() const; + const QgsPropertiesDefinition &propertyDefinitions() const; /** * Applies the data defined bytes, \a dataDefinedBytes, on the \a geometry by filling a specific vertex buffer that will be used by the shader. * \since QGIS 3.18 */ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) virtual void applyDataDefinedToGeometry( Qt3DRender::QGeometry *geometry, int vertexCount, const QByteArray &dataDefinedBytes ) const; #else virtual void applyDataDefinedToGeometry( Qt3DCore::QGeometry *geometry, int vertexCount, const QByteArray &dataDefinedBytes ) const; @@ -250,7 +245,7 @@ class _3D_EXPORT QgsAbstractMaterialSettings SIP_ABSTRACT * Returns byte stride of the data defined colors,used to fill the vertex colors data defined buffer for rendering * \since QGIS 3.18 */ - virtual int dataDefinedByteStride() const {return 0;} + virtual int dataDefinedByteStride() const { return 0; } #endif private: diff --git a/src/3d/materials/qgsgoochmaterialsettings.cpp b/src/3d/materials/qgsgoochmaterialsettings.cpp index d39366c6100..622b7f537ce 100644 --- a/src/3d/materials/qgsgoochmaterialsettings.cpp +++ b/src/3d/materials/qgsgoochmaterialsettings.cpp @@ -18,7 +18,7 @@ #include "qgs3dutils.h" #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -76,7 +76,7 @@ QgsGoochMaterialSettings *QgsGoochMaterialSettings::clone() const bool QgsGoochMaterialSettings::equals( const QgsAbstractMaterialSettings *other ) const { - const QgsGoochMaterialSettings *otherGooch = dynamic_cast< const QgsGoochMaterialSettings * >( other ); + const QgsGoochMaterialSettings *otherGooch = dynamic_cast( other ); if ( !otherGooch ) return false; @@ -140,7 +140,6 @@ void QgsGoochMaterialSettings::addParametersToEffect( Qt3DRender::QEffect *, con QByteArray QgsGoochMaterialSettings::dataDefinedVertexColorsAsByte( const QgsExpressionContext &expressionContext ) const { - const QColor diffuse = dataDefinedProperties().valueAsColor( QgsAbstractMaterialSettings::Property::Diffuse, expressionContext, mDiffuse ); const QColor warm = dataDefinedProperties().valueAsColor( QgsAbstractMaterialSettings::Property::Warm, expressionContext, mWarm ); const QColor cool = dataDefinedProperties().valueAsColor( QgsAbstractMaterialSettings::Property::Cool, expressionContext, mCool ); @@ -254,7 +253,7 @@ QgsMaterial *QgsGoochMaterialSettings::buildMaterial( const QgsMaterialContext & const QUrl urlVert( QStringLiteral( "qrc:/shaders/goochDataDefined.vert" ) ); shaderProgram->setShaderCode( Qt3DRender::QShaderProgram::Vertex, Qt3DRender::QShaderProgram::loadSource( urlVert ) ); - const QByteArray finalFragmentShaderCode = Qgs3DUtils::addDefinesToShaderCode( fragmentShaderCode, QStringList( {"DATA_DEFINED"} ) ); + const QByteArray finalFragmentShaderCode = Qgs3DUtils::addDefinesToShaderCode( fragmentShaderCode, QStringList( { "DATA_DEFINED" } ) ); shaderProgram->setFragmentShaderCode( finalFragmentShaderCode ); } else diff --git a/src/3d/materials/qgsgoochmaterialsettings.h b/src/3d/materials/qgsgoochmaterialsettings.h index 56c1e17b0cd..2b65dba7857 100644 --- a/src/3d/materials/qgsgoochmaterialsettings.h +++ b/src/3d/materials/qgsgoochmaterialsettings.h @@ -37,7 +37,6 @@ class QDomElement; class _3D_EXPORT QgsGoochMaterialSettings : public QgsAbstractMaterialSettings { public: - QgsGoochMaterialSettings() = default; QString type() const override; @@ -103,7 +102,7 @@ class _3D_EXPORT QgsGoochMaterialSettings : public QgsAbstractMaterialSettings QByteArray dataDefinedVertexColorsAsByte( const QgsExpressionContext &expressionContext ) const override; int dataDefinedByteStride() const override; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) void applyDataDefinedToGeometry( Qt3DRender::QGeometry *geometry, int vertexCount, const QByteArray &data ) const override; #else void applyDataDefinedToGeometry( Qt3DCore::QGeometry *geometry, int vertexCount, const QByteArray &data ) const override; @@ -114,21 +113,14 @@ class _3D_EXPORT QgsGoochMaterialSettings : public QgsAbstractMaterialSettings // TODO c++20 - replace with = default bool operator==( const QgsGoochMaterialSettings &other ) const { - return mDiffuse == other.mDiffuse && - mSpecular == other.mSpecular && - mWarm == other.mWarm && - mCool == other.mCool && - qgsDoubleNear( mShininess, other.mShininess ) && - qgsDoubleNear( mAlpha, other.mAlpha ) && - qgsDoubleNear( mBeta, other.mBeta ) && - dataDefinedProperties() == other.dataDefinedProperties(); + return mDiffuse == other.mDiffuse && mSpecular == other.mSpecular && mWarm == other.mWarm && mCool == other.mCool && qgsDoubleNear( mShininess, other.mShininess ) && qgsDoubleNear( mAlpha, other.mAlpha ) && qgsDoubleNear( mBeta, other.mBeta ) && dataDefinedProperties() == other.dataDefinedProperties(); } private: - QColor mDiffuse{ QColor::fromRgbF( 0.7f, 0.7f, 0.7f, 1.0f ) }; - QColor mSpecular{ QColor::fromRgbF( 1.0f, 1.0f, 1.0f, 1.0f ) }; - QColor mWarm {QColor( 107, 0, 107 ) }; - QColor mCool {QColor( 255, 130, 0 )}; + QColor mDiffuse { QColor::fromRgbF( 0.7f, 0.7f, 0.7f, 1.0f ) }; + QColor mSpecular { QColor::fromRgbF( 1.0f, 1.0f, 1.0f, 1.0f ) }; + QColor mWarm { QColor( 107, 0, 107 ) }; + QColor mCool { QColor( 255, 130, 0 ) }; double mShininess = 100.0; double mAlpha = 0.25; double mBeta = 0.5; diff --git a/src/3d/materials/qgsmaterial.cpp b/src/3d/materials/qgsmaterial.cpp index 9e72da6946b..443cdeab530 100644 --- a/src/3d/materials/qgsmaterial.cpp +++ b/src/3d/materials/qgsmaterial.cpp @@ -30,7 +30,6 @@ const QString QgsMaterial::CLIP_PLANE_DEFINE = QStringLiteral( "CLIPPING" ); QgsMaterial::QgsMaterial( QNode *parent ) : QMaterial( parent ) { - } QgsMaterial::~QgsMaterial() = default; @@ -77,7 +76,7 @@ void QgsMaterial::enableClipping( const QList &clipPlanesEquations ) { clipPlanesEquationsVariant << clipPlanesEquations[i]; } - Qt3DRender::QParameter *clipPlane = new Qt3DRender::QParameter( QgsMaterial::CLIP_PLANE_ARRAY_PARAMETER_NAME, clipPlanesEquationsVariant ); + Qt3DRender::QParameter *clipPlane = new Qt3DRender::QParameter( QgsMaterial::CLIP_PLANE_ARRAY_PARAMETER_NAME, clipPlanesEquationsVariant ); Qt3DRender::QParameter *clipPlaneNumber = new Qt3DRender::QParameter( QgsMaterial::CLIP_PLANE_MAX_PLANE_PARAMETER_NAME, nrClipPlanes ); materialEffect->addParameter( clipPlane ); @@ -118,7 +117,7 @@ void QgsMaterial::disableClipping() for ( Qt3DRender::QParameter *parameter : materialEffect->parameters() ) { const QString parameterName = parameter->name(); - if ( parameterName == QgsMaterial::CLIP_PLANE_ARRAY_PARAMETER_NAME || parameterName == QgsMaterial::CLIP_PLANE_MAX_PLANE_PARAMETER_NAME ) + if ( parameterName == QgsMaterial::CLIP_PLANE_ARRAY_PARAMETER_NAME || parameterName == QgsMaterial::CLIP_PLANE_MAX_PLANE_PARAMETER_NAME ) { materialEffect->removeParameter( parameter ); break; diff --git a/src/3d/materials/qgsmaterial.h b/src/3d/materials/qgsmaterial.h index 275c705c0ee..45424663604 100644 --- a/src/3d/materials/qgsmaterial.h +++ b/src/3d/materials/qgsmaterial.h @@ -39,7 +39,6 @@ class _3D_EXPORT QgsMaterial : public Qt3DRender::QMaterial { Q_OBJECT public: - /** * Constructor for QgsMaterial, with the specified \a parent node. */ @@ -64,7 +63,6 @@ class _3D_EXPORT QgsMaterial : public Qt3DRender::QMaterial void disableClipping(); private: - //! The name of the QParameter which contains the plane equations static const QString CLIP_PLANE_ARRAY_PARAMETER_NAME; //! The name of the QParameter which contains the number of planes @@ -73,7 +71,6 @@ class _3D_EXPORT QgsMaterial : public Qt3DRender::QMaterial static const QString CLIP_PLANE_DEFINE; bool mClippingEnabled = false; - }; #endif // QGSMATERIAL_H diff --git a/src/3d/materials/qgsmaterialregistry.h b/src/3d/materials/qgsmaterialregistry.h index c446f964b26..31b9eaf6916 100644 --- a/src/3d/materials/qgsmaterialregistry.h +++ b/src/3d/materials/qgsmaterialregistry.h @@ -40,7 +40,6 @@ enum class QgsMaterialSettingsRenderingTechnique; class _3D_EXPORT QgsMaterialSettingsAbstractMetadata { public: - /** * Constructor for QgsMaterialSettingsAbstractMetadata, with the specified \a type and \a visibleName. * @@ -121,7 +120,6 @@ typedef bool ( *QgsMaterialSettingsSupportsTechniqueFunc )( QgsMaterialSettingsR class _3D_EXPORT QgsMaterialSettingsMetadata : public QgsMaterialSettingsAbstractMetadata { public: - /** * Constructor for QgsMaterialSettingsMetadata, with the specified \a type and \a visibleName. * @@ -130,11 +128,7 @@ class _3D_EXPORT QgsMaterialSettingsMetadata : public QgsMaterialSettingsAbstrac * * An optional \a icon can be specified to represent the material type. */ - QgsMaterialSettingsMetadata( const QString &type, const QString &visibleName, - QgsMaterialSettingsCreateFunc pfCreate, - QgsMaterialSettingsSupportsTechniqueFunc pfSupportsTechnique, - QgsMaterialSettingsWidgetFunc pfWidget = nullptr, - const QIcon &icon = QIcon() ) + QgsMaterialSettingsMetadata( const QString &type, const QString &visibleName, QgsMaterialSettingsCreateFunc pfCreate, QgsMaterialSettingsSupportsTechniqueFunc pfSupportsTechnique, QgsMaterialSettingsWidgetFunc pfWidget = nullptr, const QIcon &icon = QIcon() ) : QgsMaterialSettingsAbstractMetadata( type, visibleName, icon ) , mCreateFunc( pfCreate ) , mSupportsTechniqueFunc( pfSupportsTechnique ) @@ -168,7 +162,6 @@ class _3D_EXPORT QgsMaterialSettingsMetadata : public QgsMaterialSettingsAbstrac QgsMaterialSettingsCreateFunc mCreateFunc; QgsMaterialSettingsSupportsTechniqueFunc mSupportsTechniqueFunc; QgsMaterialSettingsWidgetFunc mWidgetFunc; - }; #endif @@ -185,7 +178,6 @@ class _3D_EXPORT QgsMaterialSettingsMetadata : public QgsMaterialSettingsAbstrac class _3D_EXPORT QgsMaterialRegistry { public: - QgsMaterialRegistry(); ~QgsMaterialRegistry(); diff --git a/src/3d/materials/qgsmetalroughmaterial.cpp b/src/3d/materials/qgsmetalroughmaterial.cpp index 79559a29d9f..e0b8906aba3 100644 --- a/src/3d/materials/qgsmetalroughmaterial.cpp +++ b/src/3d/materials/qgsmetalroughmaterial.cpp @@ -201,18 +201,12 @@ void QgsMetalRoughMaterial::setTextureScale( float textureScale ) void QgsMetalRoughMaterial::init() { - QObject::connect( mBaseColorParameter, &Qt3DRender::QParameter::valueChanged, - this, &QgsMetalRoughMaterial::baseColorChanged ); - QObject::connect( mMetalnessParameter, &Qt3DRender::QParameter::valueChanged, - this, &QgsMetalRoughMaterial::metalnessChanged ); - QObject::connect( mRoughnessParameter, &Qt3DRender::QParameter::valueChanged, - this, &QgsMetalRoughMaterial::roughnessChanged ); - QObject::connect( mAmbientOcclusionMapParameter, &Qt3DRender::QParameter::valueChanged, - this, &QgsMetalRoughMaterial::ambientOcclusionChanged ); - QObject::connect( mNormalMapParameter, &Qt3DRender::QParameter::valueChanged, - this, &QgsMetalRoughMaterial::normalChanged ); - connect( mTextureScaleParameter, &Qt3DRender::QParameter::valueChanged, - this, &QgsMetalRoughMaterial::handleTextureScaleChanged ); + QObject::connect( mBaseColorParameter, &Qt3DRender::QParameter::valueChanged, this, &QgsMetalRoughMaterial::baseColorChanged ); + QObject::connect( mMetalnessParameter, &Qt3DRender::QParameter::valueChanged, this, &QgsMetalRoughMaterial::metalnessChanged ); + QObject::connect( mRoughnessParameter, &Qt3DRender::QParameter::valueChanged, this, &QgsMetalRoughMaterial::roughnessChanged ); + QObject::connect( mAmbientOcclusionMapParameter, &Qt3DRender::QParameter::valueChanged, this, &QgsMetalRoughMaterial::ambientOcclusionChanged ); + QObject::connect( mNormalMapParameter, &Qt3DRender::QParameter::valueChanged, this, &QgsMetalRoughMaterial::normalChanged ); + connect( mTextureScaleParameter, &Qt3DRender::QParameter::valueChanged, this, &QgsMetalRoughMaterial::handleTextureScaleChanged ); mMetalRoughGL3Shader->setVertexShaderCode( Qt3DRender::QShaderProgram::loadSource( QUrl( QStringLiteral( "qrc:/shaders/default.vert" ) ) ) ); diff --git a/src/3d/materials/qgsmetalroughmaterial.h b/src/3d/materials/qgsmetalroughmaterial.h index 1274d15b811..adadc4ba8bf 100644 --- a/src/3d/materials/qgsmetalroughmaterial.h +++ b/src/3d/materials/qgsmetalroughmaterial.h @@ -49,7 +49,6 @@ class _3D_EXPORT QgsMetalRoughMaterial : public QgsMaterial { Q_OBJECT public: - /** * Constructor for QgsMetalRoughMaterial, with the specified \a parent node. */ @@ -115,7 +114,6 @@ class _3D_EXPORT QgsMetalRoughMaterial : public QgsMaterial bool mUsingAmbientOcclusionMap = false; bool mUsingNormalMap = false; bool mFlatShading = false; - }; ///@endcond PRIVATE diff --git a/src/3d/materials/qgsmetalroughmaterialsettings.cpp b/src/3d/materials/qgsmetalroughmaterialsettings.cpp index fdcf98d1b32..64d556dea08 100644 --- a/src/3d/materials/qgsmetalroughmaterialsettings.cpp +++ b/src/3d/materials/qgsmetalroughmaterialsettings.cpp @@ -52,7 +52,7 @@ QgsMetalRoughMaterialSettings *QgsMetalRoughMaterialSettings::clone() const bool QgsMetalRoughMaterialSettings::equals( const QgsAbstractMaterialSettings *other ) const { - const QgsMetalRoughMaterialSettings *otherMetal = dynamic_cast< const QgsMetalRoughMaterialSettings * >( other ); + const QgsMetalRoughMaterialSettings *otherMetal = dynamic_cast( other ); if ( !otherMetal ) return false; @@ -86,7 +86,7 @@ QgsMaterial *QgsMetalRoughMaterialSettings::toMaterial( QgsMaterialSettingsRende case QgsMaterialSettingsRenderingTechnique::TrianglesWithFixedTexture: case QgsMaterialSettingsRenderingTechnique::TrianglesFromModel: { - QgsMetalRoughMaterial *material = new QgsMetalRoughMaterial; + QgsMetalRoughMaterial *material = new QgsMetalRoughMaterial; material->setBaseColor( context.isSelected() ? context.selectionColor() : mBaseColor ); material->setMetalness( mMetalness ); material->setRoughness( mRoughness ); @@ -109,5 +109,4 @@ QMap QgsMetalRoughMaterialSettings::toExportParameters() const void QgsMetalRoughMaterialSettings::addParametersToEffect( Qt3DRender::QEffect *, const QgsMaterialContext & ) const { - } diff --git a/src/3d/materials/qgsmetalroughmaterialsettings.h b/src/3d/materials/qgsmetalroughmaterialsettings.h index a073d00bc4f..d9602c1a484 100644 --- a/src/3d/materials/qgsmetalroughmaterialsettings.h +++ b/src/3d/materials/qgsmetalroughmaterialsettings.h @@ -35,7 +35,6 @@ class QDomElement; class _3D_EXPORT QgsMetalRoughMaterialSettings : public QgsAbstractMaterialSettings { public: - QgsMetalRoughMaterialSettings() = default; QString type() const override; @@ -108,14 +107,11 @@ class _3D_EXPORT QgsMetalRoughMaterialSettings : public QgsAbstractMaterialSetti // TODO c++20 - replace with = default bool operator==( const QgsMetalRoughMaterialSettings &other ) const { - return mBaseColor == other.mBaseColor && - qgsDoubleNear( mMetalness, other.mMetalness ) && - qgsDoubleNear( mRoughness, other.mRoughness ) && - dataDefinedProperties() == other.dataDefinedProperties(); + return mBaseColor == other.mBaseColor && qgsDoubleNear( mMetalness, other.mMetalness ) && qgsDoubleNear( mRoughness, other.mRoughness ) && dataDefinedProperties() == other.dataDefinedProperties(); } private: - QColor mBaseColor{ QColor::fromRgbF( 0.5f, 0.5f, 0.5f, 1.0f ) }; + QColor mBaseColor { QColor::fromRgbF( 0.5f, 0.5f, 0.5f, 1.0f ) }; double mMetalness = 0.0; double mRoughness = 0.0; }; diff --git a/src/3d/materials/qgsnullmaterialsettings.cpp b/src/3d/materials/qgsnullmaterialsettings.cpp index ce09153c714..bf951343e7a 100644 --- a/src/3d/materials/qgsnullmaterialsettings.cpp +++ b/src/3d/materials/qgsnullmaterialsettings.cpp @@ -53,7 +53,7 @@ QgsNullMaterialSettings *QgsNullMaterialSettings::clone() const bool QgsNullMaterialSettings::equals( const QgsAbstractMaterialSettings *other ) const { - const QgsNullMaterialSettings *otherNull = dynamic_cast< const QgsNullMaterialSettings * >( other ); + const QgsNullMaterialSettings *otherNull = dynamic_cast( other ); if ( !otherNull ) return false; diff --git a/src/3d/materials/qgsnullmaterialsettings.h b/src/3d/materials/qgsnullmaterialsettings.h index 6dcad7f5f4d..32bea1414ca 100644 --- a/src/3d/materials/qgsnullmaterialsettings.h +++ b/src/3d/materials/qgsnullmaterialsettings.h @@ -36,7 +36,6 @@ class QDomElement; class _3D_EXPORT QgsNullMaterialSettings : public QgsAbstractMaterialSettings { public: - QgsNullMaterialSettings() = default; QString type() const override; @@ -59,7 +58,6 @@ class _3D_EXPORT QgsNullMaterialSettings : public QgsAbstractMaterialSettings QgsMaterial *toMaterial( QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context ) const override SIP_FACTORY; void addParametersToEffect( Qt3DRender::QEffect *effect, const QgsMaterialContext &materialContext ) const override; #endif - }; diff --git a/src/3d/materials/qgsphongmaterialsettings.cpp b/src/3d/materials/qgsphongmaterialsettings.cpp index 1ef53eb12de..9b23ce26813 100644 --- a/src/3d/materials/qgsphongmaterialsettings.cpp +++ b/src/3d/materials/qgsphongmaterialsettings.cpp @@ -17,7 +17,7 @@ #include "qgscolorutils.h" #include "qgs3dutils.h" -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -76,7 +76,7 @@ QgsPhongMaterialSettings *QgsPhongMaterialSettings::clone() const bool QgsPhongMaterialSettings::equals( const QgsAbstractMaterialSettings *other ) const { - const QgsPhongMaterialSettings *otherPhong = dynamic_cast< const QgsPhongMaterialSettings * >( other ); + const QgsPhongMaterialSettings *otherPhong = dynamic_cast( other ); if ( !otherPhong ) return false; @@ -135,10 +135,10 @@ QgsMaterial *QgsPhongMaterialSettings::toMaterial( QgsMaterialSettingsRenderingT QMap QgsPhongMaterialSettings::toExportParameters() const { QMap parameters; - parameters[ QStringLiteral( "Kd" ) ] = QStringLiteral( "%1 %2 %3" ).arg( mDiffuse.redF() ).arg( mDiffuse.greenF() ).arg( mDiffuse.blueF() ); - parameters[ QStringLiteral( "Ka" ) ] = QStringLiteral( "%1 %2 %3" ).arg( mAmbient.redF() ).arg( mAmbient.greenF() ).arg( mAmbient.blueF() ); - parameters[ QStringLiteral( "Ks" ) ] = QStringLiteral( "%1 %2 %3" ).arg( mSpecular.redF() ).arg( mSpecular.greenF() ).arg( mSpecular.blueF() ); - parameters[ QStringLiteral( "Ns" ) ] = QString::number( mShininess ); + parameters[QStringLiteral( "Kd" )] = QStringLiteral( "%1 %2 %3" ).arg( mDiffuse.redF() ).arg( mDiffuse.greenF() ).arg( mDiffuse.blueF() ); + parameters[QStringLiteral( "Ka" )] = QStringLiteral( "%1 %2 %3" ).arg( mAmbient.redF() ).arg( mAmbient.greenF() ).arg( mAmbient.blueF() ); + parameters[QStringLiteral( "Ks" )] = QStringLiteral( "%1 %2 %3" ).arg( mSpecular.redF() ).arg( mSpecular.greenF() ).arg( mSpecular.blueF() ); + parameters[QStringLiteral( "Ns" )] = QString::number( mShininess ); return parameters; } @@ -147,20 +147,11 @@ void QgsPhongMaterialSettings::addParametersToEffect( Qt3DRender::QEffect *effec const QColor ambient = materialContext.isSelected() ? materialContext.selectionColor().darker() : mAmbient; const QColor diffuse = materialContext.isSelected() ? materialContext.selectionColor() : mDiffuse; - Qt3DRender::QParameter *ambientParameter = new Qt3DRender::QParameter( QStringLiteral( "ambientColor" ), - QColor::fromRgbF( ambient.redF() * mAmbientCoefficient, - ambient.greenF() * mAmbientCoefficient, - ambient.blueF() * mAmbientCoefficient ) ); - Qt3DRender::QParameter *diffuseParameter = new Qt3DRender::QParameter( QStringLiteral( "diffuseColor" ), - QColor::fromRgbF( diffuse.redF() * mDiffuseCoefficient, - diffuse.greenF() * mDiffuseCoefficient, - diffuse.blueF() * mDiffuseCoefficient ) ); - Qt3DRender::QParameter *specularParameter = new Qt3DRender::QParameter( QStringLiteral( "specularColor" ), - QColor::fromRgbF( mSpecular.redF() * mSpecularCoefficient, - mSpecular.greenF() * mSpecularCoefficient, - mSpecular.blueF() * mSpecularCoefficient ) ); - Qt3DRender::QParameter *shininessParameter = new Qt3DRender::QParameter( QStringLiteral( "shininess" ), static_cast< float >( mShininess ) ); - Qt3DRender::QParameter *opacityParameter = new Qt3DRender::QParameter( QStringLiteral( "opacity" ), static_cast< float >( mOpacity ) ); + Qt3DRender::QParameter *ambientParameter = new Qt3DRender::QParameter( QStringLiteral( "ambientColor" ), QColor::fromRgbF( ambient.redF() * mAmbientCoefficient, ambient.greenF() * mAmbientCoefficient, ambient.blueF() * mAmbientCoefficient ) ); + Qt3DRender::QParameter *diffuseParameter = new Qt3DRender::QParameter( QStringLiteral( "diffuseColor" ), QColor::fromRgbF( diffuse.redF() * mDiffuseCoefficient, diffuse.greenF() * mDiffuseCoefficient, diffuse.blueF() * mDiffuseCoefficient ) ); + Qt3DRender::QParameter *specularParameter = new Qt3DRender::QParameter( QStringLiteral( "specularColor" ), QColor::fromRgbF( mSpecular.redF() * mSpecularCoefficient, mSpecular.greenF() * mSpecularCoefficient, mSpecular.blueF() * mSpecularCoefficient ) ); + Qt3DRender::QParameter *shininessParameter = new Qt3DRender::QParameter( QStringLiteral( "shininess" ), static_cast( mShininess ) ); + Qt3DRender::QParameter *opacityParameter = new Qt3DRender::QParameter( QStringLiteral( "opacity" ), static_cast( mOpacity ) ); effect->addParameter( ambientParameter ); effect->addParameter( diffuseParameter ); @@ -187,13 +178,13 @@ QByteArray QgsPhongMaterialSettings::dataDefinedVertexColorsAsByte( const QgsExp *fptr++ = static_cast( diffuse.greenF() * mDiffuseCoefficient ); *fptr++ = static_cast( diffuse.blueF() * mDiffuseCoefficient ); - *fptr++ = static_cast( ambient.redF() * mAmbientCoefficient ); - *fptr++ = static_cast( ambient.greenF() * mAmbientCoefficient ); - *fptr++ = static_cast( ambient.blueF() * mAmbientCoefficient ); + *fptr++ = static_cast( ambient.redF() * mAmbientCoefficient ); + *fptr++ = static_cast( ambient.greenF() * mAmbientCoefficient ); + *fptr++ = static_cast( ambient.blueF() * mAmbientCoefficient ); - *fptr++ = static_cast( specular.redF() * mSpecularCoefficient ); - *fptr++ = static_cast( specular.greenF() * mSpecularCoefficient ); - *fptr++ = static_cast( specular.blueF() * mSpecularCoefficient ); + *fptr++ = static_cast( specular.redF() * mSpecularCoefficient ); + *fptr++ = static_cast( specular.greenF() * mSpecularCoefficient ); + *fptr++ = static_cast( specular.blueF() * mSpecularCoefficient ); } else { @@ -216,7 +207,7 @@ QByteArray QgsPhongMaterialSettings::dataDefinedVertexColorsAsByte( const QgsExp return array; } -int QgsPhongMaterialSettings::dataDefinedByteStride() const {return 9 * sizeof( unsigned char );} +int QgsPhongMaterialSettings::dataDefinedByteStride() const { return 9 * sizeof( unsigned char ); } void QgsPhongMaterialSettings::applyDataDefinedToGeometry( Qt3DQGeometry *geometry, int vertexCount, const QByteArray &data ) const { @@ -291,7 +282,7 @@ QgsMaterial *QgsPhongMaterialSettings::buildMaterial( const QgsMaterialContext & // Load shader programs const QUrl urlVert( QStringLiteral( "qrc:/shaders/phongDataDefined.vert" ) ); shaderProgram->setShaderCode( Qt3DRender::QShaderProgram::Vertex, Qt3DRender::QShaderProgram::loadSource( urlVert ) ); - const QByteArray finalFragmentShaderCode = Qgs3DUtils::addDefinesToShaderCode( fragmentShaderCode, QStringList( {"DATA_DEFINED"} ) ); + const QByteArray finalFragmentShaderCode = Qgs3DUtils::addDefinesToShaderCode( fragmentShaderCode, QStringList( { "DATA_DEFINED" } ) ); shaderProgram->setFragmentShaderCode( finalFragmentShaderCode ); } else @@ -304,22 +295,13 @@ QgsMaterial *QgsPhongMaterialSettings::buildMaterial( const QgsMaterialContext & const QColor ambient = context.isSelected() ? context.selectionColor().darker() : mAmbient; const QColor diffuse = context.isSelected() ? context.selectionColor() : mDiffuse; - effect->addParameter( new Qt3DRender::QParameter( QStringLiteral( "ambientColor" ), - QColor::fromRgbF( ambient.redF() * mAmbientCoefficient, - ambient.greenF() * mAmbientCoefficient, - ambient.blueF() * mAmbientCoefficient ) ) ); - effect->addParameter( new Qt3DRender::QParameter( QStringLiteral( "diffuseColor" ), - QColor::fromRgbF( diffuse.redF() * mDiffuseCoefficient, - diffuse.greenF() * mDiffuseCoefficient, - diffuse.blueF() * mDiffuseCoefficient ) ) ); - effect->addParameter( new Qt3DRender::QParameter( QStringLiteral( "specularColor" ), - QColor::fromRgbF( mSpecular.redF() * mSpecularCoefficient, - mSpecular.greenF() * mSpecularCoefficient, - mSpecular.blueF() * mSpecularCoefficient ) ) ); + effect->addParameter( new Qt3DRender::QParameter( QStringLiteral( "ambientColor" ), QColor::fromRgbF( ambient.redF() * mAmbientCoefficient, ambient.greenF() * mAmbientCoefficient, ambient.blueF() * mAmbientCoefficient ) ) ); + effect->addParameter( new Qt3DRender::QParameter( QStringLiteral( "diffuseColor" ), QColor::fromRgbF( diffuse.redF() * mDiffuseCoefficient, diffuse.greenF() * mDiffuseCoefficient, diffuse.blueF() * mDiffuseCoefficient ) ) ); + effect->addParameter( new Qt3DRender::QParameter( QStringLiteral( "specularColor" ), QColor::fromRgbF( mSpecular.redF() * mSpecularCoefficient, mSpecular.greenF() * mSpecularCoefficient, mSpecular.blueF() * mSpecularCoefficient ) ) ); } - effect->addParameter( new Qt3DRender::QParameter( QStringLiteral( "shininess" ), static_cast< float >( mShininess ) ) ); - effect->addParameter( new Qt3DRender::QParameter( QStringLiteral( "opacity" ), static_cast< float >( mOpacity ) ) ); + effect->addParameter( new Qt3DRender::QParameter( QStringLiteral( "shininess" ), static_cast( mShininess ) ) ); + effect->addParameter( new Qt3DRender::QParameter( QStringLiteral( "opacity" ), static_cast( mOpacity ) ) ); effect->addTechnique( technique ); material->setEffect( effect ); diff --git a/src/3d/materials/qgsphongmaterialsettings.h b/src/3d/materials/qgsphongmaterialsettings.h index 0e212520665..1a0a1a3e2a9 100644 --- a/src/3d/materials/qgsphongmaterialsettings.h +++ b/src/3d/materials/qgsphongmaterialsettings.h @@ -36,7 +36,6 @@ class QDomElement; class _3D_EXPORT QgsPhongMaterialSettings : public QgsAbstractMaterialSettings { public: - QgsPhongMaterialSettings() = default; QString type() const override; @@ -161,7 +160,7 @@ class _3D_EXPORT QgsPhongMaterialSettings : public QgsAbstractMaterialSettings QByteArray dataDefinedVertexColorsAsByte( const QgsExpressionContext &expressionContext ) const override; int dataDefinedByteStride() const override; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) void applyDataDefinedToGeometry( Qt3DRender::QGeometry *geometry, int vertexCount, const QByteArray &data ) const override; #else void applyDataDefinedToGeometry( Qt3DCore::QGeometry *geometry, int vertexCount, const QByteArray &data ) const override; @@ -171,21 +170,13 @@ class _3D_EXPORT QgsPhongMaterialSettings : public QgsAbstractMaterialSettings // TODO c++20 - replace with = default bool operator==( const QgsPhongMaterialSettings &other ) const { - return mAmbient == other.mAmbient && - mDiffuse == other.mDiffuse && - mOpacity == other.mOpacity && - mSpecular == other.mSpecular && - mShininess == other.mShininess && - mAmbientCoefficient == other.mAmbientCoefficient && - mDiffuseCoefficient == other.mDiffuseCoefficient && - mSpecularCoefficient == other.mSpecularCoefficient && - dataDefinedProperties() == other.dataDefinedProperties(); + return mAmbient == other.mAmbient && mDiffuse == other.mDiffuse && mOpacity == other.mOpacity && mSpecular == other.mSpecular && mShininess == other.mShininess && mAmbientCoefficient == other.mAmbientCoefficient && mDiffuseCoefficient == other.mDiffuseCoefficient && mSpecularCoefficient == other.mSpecularCoefficient && dataDefinedProperties() == other.dataDefinedProperties(); } private: - QColor mAmbient{ QColor::fromRgbF( 0.1f, 0.1f, 0.1f, 1.0f ) }; - QColor mDiffuse{ QColor::fromRgbF( 0.7f, 0.7f, 0.7f, 1.0f ) }; - QColor mSpecular{ QColor::fromRgbF( 1.0f, 1.0f, 1.0f, 1.0f ) }; + QColor mAmbient { QColor::fromRgbF( 0.1f, 0.1f, 0.1f, 1.0f ) }; + QColor mDiffuse { QColor::fromRgbF( 0.7f, 0.7f, 0.7f, 1.0f ) }; + QColor mSpecular { QColor::fromRgbF( 1.0f, 1.0f, 1.0f, 1.0f ) }; double mShininess = 0.0; double mAmbientCoefficient = 1.0; diff --git a/src/3d/materials/qgsphongtexturedmaterial.cpp b/src/3d/materials/qgsphongtexturedmaterial.cpp index b8312d1758d..fe9d398350c 100644 --- a/src/3d/materials/qgsphongtexturedmaterial.cpp +++ b/src/3d/materials/qgsphongtexturedmaterial.cpp @@ -41,18 +41,12 @@ QgsPhongTexturedMaterial::~QgsPhongTexturedMaterial() = default; void QgsPhongTexturedMaterial::init() { - connect( mAmbientParameter, &Qt3DRender::QParameter::valueChanged, - this, &QgsPhongTexturedMaterial::handleAmbientChanged ); - connect( mDiffuseTextureParameter, &Qt3DRender::QParameter::valueChanged, - this, &QgsPhongTexturedMaterial::handleDiffuseTextureChanged ); - connect( mDiffuseTextureScaleParameter, &Qt3DRender::QParameter::valueChanged, - this, &QgsPhongTexturedMaterial::handleDiffuseTextureScaleChanged ); - connect( mSpecularParameter, &Qt3DRender::QParameter::valueChanged, - this, &QgsPhongTexturedMaterial::handleSpecularChanged ); - connect( mShininessParameter, &Qt3DRender::QParameter::valueChanged, - this, &QgsPhongTexturedMaterial::handleShininessChanged ); - connect( mOpacityParameter, &Qt3DRender::QParameter::valueChanged, - this, &QgsPhongTexturedMaterial::handleOpacityChanged ); + connect( mAmbientParameter, &Qt3DRender::QParameter::valueChanged, this, &QgsPhongTexturedMaterial::handleAmbientChanged ); + connect( mDiffuseTextureParameter, &Qt3DRender::QParameter::valueChanged, this, &QgsPhongTexturedMaterial::handleDiffuseTextureChanged ); + connect( mDiffuseTextureScaleParameter, &Qt3DRender::QParameter::valueChanged, this, &QgsPhongTexturedMaterial::handleDiffuseTextureScaleChanged ); + connect( mSpecularParameter, &Qt3DRender::QParameter::valueChanged, this, &QgsPhongTexturedMaterial::handleSpecularChanged ); + connect( mShininessParameter, &Qt3DRender::QParameter::valueChanged, this, &QgsPhongTexturedMaterial::handleShininessChanged ); + connect( mOpacityParameter, &Qt3DRender::QParameter::valueChanged, this, &QgsPhongTexturedMaterial::handleOpacityChanged ); Qt3DRender::QEffect *effect = new Qt3DRender::QEffect(); effect->addParameter( mAmbientParameter ); diff --git a/src/3d/materials/qgsphongtexturedmaterial.h b/src/3d/materials/qgsphongtexturedmaterial.h index f3b5ef55ce6..b857eb53af9 100644 --- a/src/3d/materials/qgsphongtexturedmaterial.h +++ b/src/3d/materials/qgsphongtexturedmaterial.h @@ -49,7 +49,6 @@ class _3D_EXPORT QgsPhongTexturedMaterial : public QgsMaterial Q_PROPERTY( float opacity READ opacity WRITE setOpacity NOTIFY opacityChanged ) public: - /** * Constructor for QgsPhongTexturedMaterial, with the specified \a parent node. */ diff --git a/src/3d/materials/qgsphongtexturedmaterialsettings.cpp b/src/3d/materials/qgsphongtexturedmaterialsettings.cpp index 25dc64adc46..285797ed6b1 100644 --- a/src/3d/materials/qgsphongtexturedmaterialsettings.cpp +++ b/src/3d/materials/qgsphongtexturedmaterialsettings.cpp @@ -65,7 +65,7 @@ QgsPhongTexturedMaterialSettings *QgsPhongTexturedMaterialSettings::clone() cons bool QgsPhongTexturedMaterialSettings::equals( const QgsAbstractMaterialSettings *other ) const { - const QgsPhongTexturedMaterialSettings *otherPhong = dynamic_cast< const QgsPhongTexturedMaterialSettings * >( other ); + const QgsPhongTexturedMaterialSettings *otherPhong = dynamic_cast( other ); if ( !otherPhong ) return false; @@ -116,7 +116,7 @@ QgsMaterial *QgsPhongTexturedMaterialSettings::toMaterial( QgsMaterialSettingsRe { bool fitsInCache = false; const QImage textureSourceImage = QgsApplication::imageCache()->pathAsImage( mDiffuseTexturePath, QSize(), true, 1.0, fitsInCache ); - ( void )fitsInCache; + ( void ) fitsInCache; // No texture image was provided. // Fallback to QgsPhongMaterialSettings. @@ -158,14 +158,13 @@ QgsMaterial *QgsPhongTexturedMaterialSettings::toMaterial( QgsMaterialSettingsRe texture->setMinificationFilter( Qt3DRender::QTexture2D::Linear ); material->setDiffuseTexture( texture ); - material->setDiffuseTextureScale( static_cast< float >( mTextureScale ) ); + material->setDiffuseTextureScale( static_cast( mTextureScale ) ); return material; } case QgsMaterialSettingsRenderingTechnique::Lines: return nullptr; - } return nullptr; } @@ -173,9 +172,9 @@ QgsMaterial *QgsPhongTexturedMaterialSettings::toMaterial( QgsMaterialSettingsRe QMap QgsPhongTexturedMaterialSettings::toExportParameters() const { QMap parameters; - parameters[ QStringLiteral( "Ka" ) ] = QStringLiteral( "%1 %2 %3" ).arg( mAmbient.redF() ).arg( mAmbient.greenF() ).arg( mAmbient.blueF() ); - parameters[ QStringLiteral( "Ks" ) ] = QStringLiteral( "%1 %2 %3" ).arg( mSpecular.redF() ).arg( mSpecular.greenF() ).arg( mSpecular.blueF() ); - parameters[ QStringLiteral( "Ns" ) ] = QString::number( mShininess ); + parameters[QStringLiteral( "Ka" )] = QStringLiteral( "%1 %2 %3" ).arg( mAmbient.redF() ).arg( mAmbient.greenF() ).arg( mAmbient.blueF() ); + parameters[QStringLiteral( "Ks" )] = QStringLiteral( "%1 %2 %3" ).arg( mSpecular.redF() ).arg( mSpecular.greenF() ).arg( mSpecular.blueF() ); + parameters[QStringLiteral( "Ns" )] = QString::number( mShininess ); return parameters; } diff --git a/src/3d/materials/qgsphongtexturedmaterialsettings.h b/src/3d/materials/qgsphongtexturedmaterialsettings.h index 4fc1b8e2d45..735b9ab9e5d 100644 --- a/src/3d/materials/qgsphongtexturedmaterialsettings.h +++ b/src/3d/materials/qgsphongtexturedmaterialsettings.h @@ -36,7 +36,6 @@ class QDomElement; class _3D_EXPORT QgsPhongTexturedMaterialSettings : public QgsAbstractMaterialSettings { public: - QgsPhongTexturedMaterialSettings() = default; QString type() const override; @@ -134,24 +133,17 @@ class _3D_EXPORT QgsPhongTexturedMaterialSettings : public QgsAbstractMaterialSe // TODO c++20 - replace with = default bool operator==( const QgsPhongTexturedMaterialSettings &other ) const { - return mAmbient == other.mAmbient && - mSpecular == other.mSpecular && - mShininess == other.mShininess && - mOpacity == other.mOpacity && - mDiffuseTexturePath == other.mDiffuseTexturePath && - mTextureScale == other.mTextureScale && - mTextureRotation == other.mTextureRotation && - dataDefinedProperties() == other.dataDefinedProperties(); + return mAmbient == other.mAmbient && mSpecular == other.mSpecular && mShininess == other.mShininess && mOpacity == other.mOpacity && mDiffuseTexturePath == other.mDiffuseTexturePath && mTextureScale == other.mTextureScale && mTextureRotation == other.mTextureRotation && dataDefinedProperties() == other.dataDefinedProperties(); } private: - QColor mAmbient{ QColor::fromRgbF( 0.1f, 0.1f, 0.1f, 1.0f ) }; - QColor mSpecular{ QColor::fromRgbF( 1.0f, 1.0f, 1.0f, 1.0f ) }; + QColor mAmbient { QColor::fromRgbF( 0.1f, 0.1f, 0.1f, 1.0f ) }; + QColor mSpecular { QColor::fromRgbF( 1.0f, 1.0f, 1.0f, 1.0f ) }; double mShininess = 0.0; double mOpacity = 1.0; QString mDiffuseTexturePath; - double mTextureScale{ 1.0f }; - double mTextureRotation{ 0.0f }; + double mTextureScale { 1.0f }; + double mTextureRotation { 0.0f }; }; diff --git a/src/3d/materials/qgssimplelinematerialsettings.cpp b/src/3d/materials/qgssimplelinematerialsettings.cpp index bf4d82b000c..f86dee74a1f 100644 --- a/src/3d/materials/qgssimplelinematerialsettings.cpp +++ b/src/3d/materials/qgssimplelinematerialsettings.cpp @@ -22,7 +22,7 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -75,7 +75,7 @@ QgsSimpleLineMaterialSettings *QgsSimpleLineMaterialSettings::clone() const bool QgsSimpleLineMaterialSettings::equals( const QgsAbstractMaterialSettings *other ) const { - const QgsSimpleLineMaterialSettings *otherLine = dynamic_cast< const QgsSimpleLineMaterialSettings * >( other ); + const QgsSimpleLineMaterialSettings *otherLine = dynamic_cast( other ); if ( !otherLine ) return false; @@ -131,7 +131,7 @@ QgsMaterial *QgsSimpleLineMaterialSettings::toMaterial( QgsMaterialSettingsRende QMap QgsSimpleLineMaterialSettings::toExportParameters() const { QMap parameters; - parameters[ QStringLiteral( "Ka" ) ] = QStringLiteral( "%1 %2 %3" ).arg( mAmbient.redF() ).arg( mAmbient.greenF() ).arg( mAmbient.blueF() ); + parameters[QStringLiteral( "Ka" )] = QStringLiteral( "%1 %2 %3" ).arg( mAmbient.redF() ).arg( mAmbient.greenF() ).arg( mAmbient.blueF() ); return parameters; } diff --git a/src/3d/materials/qgssimplelinematerialsettings.h b/src/3d/materials/qgssimplelinematerialsettings.h index 3ec079f618b..755f16f97cc 100644 --- a/src/3d/materials/qgssimplelinematerialsettings.h +++ b/src/3d/materials/qgssimplelinematerialsettings.h @@ -37,7 +37,6 @@ class QDomElement; class _3D_EXPORT QgsSimpleLineMaterialSettings : public QgsAbstractMaterialSettings { public: - QgsSimpleLineMaterialSettings() = default; QString type() const override; @@ -76,7 +75,7 @@ class _3D_EXPORT QgsSimpleLineMaterialSettings : public QgsAbstractMaterialSetti QgsMaterial *toMaterial( QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context ) const override SIP_FACTORY; void addParametersToEffect( Qt3DRender::QEffect *effect, const QgsMaterialContext &materialContext ) const override; QByteArray dataDefinedVertexColorsAsByte( const QgsExpressionContext &expressionContext ) const override; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) void applyDataDefinedToGeometry( Qt3DRender::QGeometry *geometry, int vertexCount, const QByteArray &data ) const override; #else void applyDataDefinedToGeometry( Qt3DCore::QGeometry *geometry, int vertexCount, const QByteArray &data ) const override; @@ -86,13 +85,11 @@ class _3D_EXPORT QgsSimpleLineMaterialSettings : public QgsAbstractMaterialSetti // TODO c++20 - replace with = default bool operator==( const QgsSimpleLineMaterialSettings &other ) const { - return mAmbient == other.mAmbient && - dataDefinedProperties() == other.dataDefinedProperties(); + return mAmbient == other.mAmbient && dataDefinedProperties() == other.dataDefinedProperties(); } private: - QColor mAmbient{ QColor::fromRgbF( 0.1f, 0.1f, 0.1f, 1.0f ) }; - + QColor mAmbient { QColor::fromRgbF( 0.1f, 0.1f, 0.1f, 1.0f ) }; }; diff --git a/src/3d/materials/qgstexturematerial.cpp b/src/3d/materials/qgstexturematerial.cpp index dd5e88cfa4e..cf50d2a33b3 100644 --- a/src/3d/materials/qgstexturematerial.cpp +++ b/src/3d/materials/qgstexturematerial.cpp @@ -43,8 +43,7 @@ QgsTextureMaterial::~QgsTextureMaterial() = default; void QgsTextureMaterial::init() { - connect( mTextureParameter, &Qt3DRender::QParameter::valueChanged, - this, &QgsTextureMaterial::handleTextureChanged ); + connect( mTextureParameter, &Qt3DRender::QParameter::valueChanged, this, &QgsTextureMaterial::handleTextureChanged ); Qt3DRender::QEffect *effect = new Qt3DRender::QEffect(); diff --git a/src/3d/materials/qgstexturematerial.h b/src/3d/materials/qgstexturematerial.h index 947384da071..5bd146ddd57 100644 --- a/src/3d/materials/qgstexturematerial.h +++ b/src/3d/materials/qgstexturematerial.h @@ -49,7 +49,6 @@ class _3D_EXPORT QgsTextureMaterial : public QgsMaterial Q_PROPERTY( Qt3DRender::QAbstractTexture *texture READ texture WRITE setTexture NOTIFY textureChanged ) public: - /** * Constructor for QgsTextureMaterial, with the specified \a parent node. */ @@ -79,7 +78,6 @@ class _3D_EXPORT QgsTextureMaterial : public QgsMaterial Qt3DRender::QRenderPass *mGL3RenderPass = nullptr; Qt3DRender::QShaderProgram *mGL3Shader = nullptr; Qt3DRender::QFilterKey *mFilterKey = nullptr; - }; ///@endcond PRIVATE diff --git a/src/3d/mesh/qgsmesh3dentity_p.cpp b/src/3d/mesh/qgsmesh3dentity_p.cpp index 82511feb5ef..d1c690e8a9f 100644 --- a/src/3d/mesh/qgsmesh3dentity_p.cpp +++ b/src/3d/mesh/qgsmesh3dentity_p.cpp @@ -26,10 +26,7 @@ #include "qgsgeotransform.h" - -QgsMesh3DEntity::QgsMesh3DEntity( const Qgs3DRenderContext &context, - const QgsTriangularMesh &triangularMesh, - const QgsMesh3DSymbol *symbol ) +QgsMesh3DEntity::QgsMesh3DEntity( const Qgs3DRenderContext &context, const QgsTriangularMesh &triangularMesh, const QgsMesh3DSymbol *symbol ) : mRenderContext( context ) , mTriangularMesh( triangularMesh ) , mSymbol( symbol->clone() ) @@ -39,9 +36,9 @@ QgsMeshDataset3DEntity::QgsMeshDataset3DEntity( const Qgs3DRenderContext &context, const QgsTriangularMesh &triangularMesh, QgsMeshLayer *meshLayer, - const QgsMesh3DSymbol *symbol ) - : QgsMesh3DEntity( context, triangularMesh, symbol ), - mLayerRef( meshLayer ) + const QgsMesh3DSymbol *symbol +) + : QgsMesh3DEntity( context, triangularMesh, symbol ), mLayerRef( meshLayer ) {} void QgsMesh3DEntity::build() @@ -85,11 +82,7 @@ QgsMeshLayer *QgsMeshDataset3DEntity::layer() const return qobject_cast( mLayerRef.layer.data() ); } -QgsMesh3DTerrainTileEntity::QgsMesh3DTerrainTileEntity( const Qgs3DRenderContext &context, - const QgsTriangularMesh &triangularMesh, - const QgsMesh3DSymbol *symbol, - QgsChunkNodeId nodeId, - Qt3DCore::QNode *parent ) +QgsMesh3DTerrainTileEntity::QgsMesh3DTerrainTileEntity( const Qgs3DRenderContext &context, const QgsTriangularMesh &triangularMesh, const QgsMesh3DSymbol *symbol, QgsChunkNodeId nodeId, Qt3DCore::QNode *parent ) : QgsTerrainTileEntity( nodeId, parent ) , QgsMesh3DEntity( context, triangularMesh, symbol ) {} @@ -114,6 +107,7 @@ void QgsMesh3DTerrainTileEntity::applyMaterial() nullptr, QgsDateTimeRange(), mRenderContext.origin(), mSymbol.get(), - QgsMesh3DMaterial::ZValue ); + QgsMesh3DMaterial::ZValue + ); addComponent( material ); } diff --git a/src/3d/mesh/qgsmesh3dentity_p.h b/src/3d/mesh/qgsmesh3dentity_p.h index 88fe32c87fd..9f0230233b4 100644 --- a/src/3d/mesh/qgsmesh3dentity_p.h +++ b/src/3d/mesh/qgsmesh3dentity_p.h @@ -50,17 +50,16 @@ class QgsMesh3DEntity public: //! Builds the geometry and the material void build(); + protected: //! Constructor - QgsMesh3DEntity( const Qgs3DRenderContext &context, - const QgsTriangularMesh &triangularMesh, - const QgsMesh3DSymbol *symbol ); + QgsMesh3DEntity( const Qgs3DRenderContext &context, const QgsTriangularMesh &triangularMesh, const QgsMesh3DSymbol *symbol ); virtual ~QgsMesh3DEntity() = default; Qgs3DRenderContext mRenderContext; QgsTriangularMesh mTriangularMesh; - std::unique_ptr< QgsMesh3DSymbol > mSymbol; + std::unique_ptr mSymbol; private: virtual void buildGeometry() = 0; @@ -68,16 +67,13 @@ class QgsMesh3DEntity }; //! Entity that handles rendering of dataset -class QgsMeshDataset3DEntity: public Qt3DCore::QEntity, public QgsMesh3DEntity +class QgsMeshDataset3DEntity : public Qt3DCore::QEntity, public QgsMesh3DEntity { Q_OBJECT public: //! Constructor - QgsMeshDataset3DEntity( const Qgs3DRenderContext &context, - const QgsTriangularMesh &triangularMesh, - QgsMeshLayer *meshLayer, - const QgsMesh3DSymbol *symbol ); + QgsMeshDataset3DEntity( const Qgs3DRenderContext &context, const QgsTriangularMesh &triangularMesh, QgsMeshLayer *meshLayer, const QgsMesh3DSymbol *symbol ); private: void buildGeometry() override; @@ -85,20 +81,15 @@ class QgsMeshDataset3DEntity: public Qt3DCore::QEntity, public QgsMesh3DEntity QgsMeshLayer *layer() const; QgsMapLayerRef mLayerRef; - }; //! Entity that handles rendering of terrain mesh -class QgsMesh3DTerrainTileEntity: public QgsTerrainTileEntity, public QgsMesh3DEntity +class QgsMesh3DTerrainTileEntity : public QgsTerrainTileEntity, public QgsMesh3DEntity { Q_OBJECT public: - QgsMesh3DTerrainTileEntity( const Qgs3DRenderContext &context, - const QgsTriangularMesh &triangularMesh, - const QgsMesh3DSymbol *symbol, - QgsChunkNodeId nodeId, - Qt3DCore::QNode *parent = nullptr ); + QgsMesh3DTerrainTileEntity( const Qgs3DRenderContext &context, const QgsTriangularMesh &triangularMesh, const QgsMesh3DSymbol *symbol, QgsChunkNodeId nodeId, Qt3DCore::QNode *parent = nullptr ); private: void buildGeometry() override; diff --git a/src/3d/mesh/qgsmesh3dgeometry_p.cpp b/src/3d/mesh/qgsmesh3dgeometry_p.cpp index 27431a462cf..93ac53e6c11 100644 --- a/src/3d/mesh/qgsmesh3dgeometry_p.cpp +++ b/src/3d/mesh/qgsmesh3dgeometry_p.cpp @@ -21,7 +21,7 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include @@ -46,7 +46,8 @@ typedef Qt3DCore::QBuffer Qt3DQBuffer; static QByteArray createTerrainVertexData( const QgsTriangularMesh &mesh, const QgsVector3D &origin, - float vertScale ) + float vertScale +) { const int nVerts = mesh.vertices().count(); @@ -66,10 +67,10 @@ static QByteArray createTerrainVertexData( const QgsMeshVertex &vert = mesh.vertices().at( i ); *fptr++ = float( vert.x() - origin.x() ); *fptr++ = float( vert.y() - origin.y() ); - *fptr++ = float( vert.z() - origin.z() ) * vertScale ; + *fptr++ = float( vert.z() - origin.z() ) * vertScale; QVector3D normal = normals.at( i ); - normal = QVector3D( normal.x(), normal.y(), normal.z() / vertScale ); // TODO: correct? + normal = QVector3D( normal.x(), normal.y(), normal.z() / vertScale ); // TODO: correct? normal.normalize(); *fptr++ = normal.x(); @@ -85,22 +86,21 @@ static QByteArray createDatasetVertexData( const QgsMesh &nativeMesh, const QgsVector3D &origin, float vertScale, - const QgsMeshDataset3DGeometry::VertexData &data ) + const QgsMeshDataset3DGeometry::VertexData &data +) { const int nVerts = mesh.vertices().count(); - const QVector verticalMagnitude = - QgsMeshLayerUtils::calculateMagnitudeOnVertices( nativeMesh, data.verticalGroupMetadata, data.verticalData, data.activeFaceFlagValues ); + const QVector verticalMagnitude = QgsMeshLayerUtils::calculateMagnitudeOnVertices( nativeMesh, data.verticalGroupMetadata, data.verticalData, data.activeFaceFlagValues ); - const QVector scalarMagnitude = - QgsMeshLayerUtils::calculateMagnitudeOnVertices( nativeMesh, data.scalarGroupMetadata, data.scalarData, data.activeFaceFlagValues ); + const QVector scalarMagnitude = QgsMeshLayerUtils::calculateMagnitudeOnVertices( nativeMesh, data.scalarGroupMetadata, data.scalarData, data.activeFaceFlagValues ); //Calculate normals with Z value equal to verticaleMagnitude const QVector normals = QgsMeshLayerUtils::calculateNormals( mesh, verticalMagnitude, data.isVerticalMagnitudeRelative ); // Populate a buffer with the interleaved per-vertex data with // vec3 pos, vec3 normal, float magnitude - const quint32 elementSize = 3 + 3 + 1 ; + const quint32 elementSize = 3 + 3 + 1; const quint32 stride = elementSize * sizeof( float ); QByteArray bufferBytes; bufferBytes.resize( stride * nVerts ); @@ -117,7 +117,7 @@ static QByteArray createDatasetVertexData( *fptr++ = float( vert.x() - origin.x() ); *fptr++ = float( vert.y() - origin.y() ); - *fptr++ = float( vertMag - origin.z() ) * vertScale ; + *fptr++ = float( vertMag - origin.z() ) * vertScale; QVector3D normal = normals.at( i ); normal = QVector3D( normal.x(), normal.y(), normal.z() / vertScale ); // TODO: correct? @@ -196,12 +196,8 @@ static QByteArray createDatasetIndexData( const QgsTriangularMesh &mesh, const Q return indexBytes; } -QgsMesh3DGeometry::QgsMesh3DGeometry( const QgsTriangularMesh &triangularMesh, - const QgsVector3D &origin, - const QgsRectangle &extent, - double verticalScale, - Qt3DCore::QNode *parent ) -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +QgsMesh3DGeometry::QgsMesh3DGeometry( const QgsTriangularMesh &triangularMesh, const QgsVector3D &origin, const QgsRectangle &extent, double verticalScale, Qt3DCore::QNode *parent ) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) : Qt3DRender::QGeometry( parent ) #else : Qt3DCore::QGeometry( parent ) @@ -222,21 +218,19 @@ QgsMeshDataset3DGeometry::QgsMeshDataset3DGeometry( const QgsVector3D &origin, const QgsRectangle &extent, const QgsMesh3DSymbol *symbol, - Qt3DCore::QNode *parent ) + Qt3DCore::QNode *parent +) : QgsMesh3DGeometry( triangularMesh, origin, extent, symbol->verticalScale(), parent ) , mIsVerticalMagnitudeRelative( symbol->isVerticalMagnitudeRelative() ) , mVerticalGroupDatasetIndex( symbol->verticalDatasetGroupIndex() ) , mTimeRange( timeRange ) , mLayerRef( layer ) { + const int stride = ( 3 /*position*/ + 3 /*normal*/ + 1 /*magnitude*/ ) * sizeof( float ); - const int stride = ( 3 /*position*/ + - 3 /*normal*/ + - 1 /*magnitude*/ ) * sizeof( float ); - - prepareVerticesPositionAttribute( mVertexBuffer, stride, 0 ); - prepareVerticesNormalAttribute( mVertexBuffer, stride, 3 ); - prepareVerticesDatasetAttribute( mVertexBuffer, stride, 6 ); + prepareVerticesPositionAttribute( mVertexBuffer, stride, 0 ); + prepareVerticesNormalAttribute( mVertexBuffer, stride, 3 ); + prepareVerticesDatasetAttribute( mVertexBuffer, stride, 6 ); prepareIndexesAttribute( mIndexBuffer ); prepareData(); @@ -292,21 +286,19 @@ void QgsMeshDataset3DGeometry::prepareData() VertexData data; data.verticalGroupMetadata = layer->datasetGroupMetadata( mVerticalGroupDatasetIndex ); - const bool verticalDataOnVertices = data.verticalGroupMetadata.dataType() == QgsMeshDatasetGroupMetadata::DataOnVertices; + const bool verticalDataOnVertices = data.verticalGroupMetadata.dataType() == QgsMeshDatasetGroupMetadata::DataOnVertices; int datacount = verticalDataOnVertices ? nativeMesh.vertices.count() : nativeMesh.faces.count(); data.verticalData = QgsMeshLayerUtils::datasetValues( layer, verticalMagDatasetIndex, 0, datacount ); data.scalarGroupMetadata = layer->datasetGroupMetadata( layer->activeScalarDatasetAtTime( mTimeRange ) ); - const bool scalarDataOnVertices = data.scalarGroupMetadata.dataType() == QgsMeshDatasetGroupMetadata::DataOnVertices; + const bool scalarDataOnVertices = data.scalarGroupMetadata.dataType() == QgsMeshDatasetGroupMetadata::DataOnVertices; datacount = scalarDataOnVertices ? nativeMesh.vertices.count() : nativeMesh.faces.count(); data.scalarData = QgsMeshLayerUtils::datasetValues( layer, scalarDatasetIndex, 0, datacount ); - if ( ( verticalDataOnVertices && ( data.verticalData.count() != mTriangulaMesh.vertices().count() ) ) || - ( scalarDataOnVertices && ( data.scalarData.count() != mTriangulaMesh.vertices().count() ) ) ) + if ( ( verticalDataOnVertices && ( data.verticalData.count() != mTriangulaMesh.vertices().count() ) ) || ( scalarDataOnVertices && ( data.scalarData.count() != mTriangulaMesh.vertices().count() ) ) ) return; - if ( ( !verticalDataOnVertices && ( data.verticalData.count() != nativeMesh.faces.count() ) ) || - ( !scalarDataOnVertices && ( data.scalarData.count() != nativeMesh.faces.count() ) ) ) + if ( ( !verticalDataOnVertices && ( data.verticalData.count() != nativeMesh.faces.count() ) ) || ( !scalarDataOnVertices && ( data.scalarData.count() != nativeMesh.faces.count() ) ) ) return; data.activeFaceFlagValues = layer->areFacesActive( scalarDatasetIndex, 0, nativeMesh.faces.count() ); @@ -319,19 +311,13 @@ void QgsMeshDataset3DGeometry::prepareData() } -QgsMeshTerrain3DGeometry::QgsMeshTerrain3DGeometry( const QgsTriangularMesh &triangularMesh, - const QgsVector3D &origin, - const QgsRectangle &extent, - double verticalScale, - Qt3DCore::QNode *parent ) +QgsMeshTerrain3DGeometry::QgsMeshTerrain3DGeometry( const QgsTriangularMesh &triangularMesh, const QgsVector3D &origin, const QgsRectangle &extent, double verticalScale, Qt3DCore::QNode *parent ) : QgsMesh3DGeometry( triangularMesh, origin, extent, verticalScale, parent ) { - - const int stride = ( 3 /*position*/ + - 3 /*normal*/ ) * sizeof( float ); + const int stride = ( 3 /*position*/ + 3 /*normal*/ ) * sizeof( float ); prepareVerticesPositionAttribute( mVertexBuffer, stride, 0 ); - prepareVerticesNormalAttribute( mVertexBuffer, stride, 3 ); + prepareVerticesNormalAttribute( mVertexBuffer, stride, 3 ); prepareIndexesAttribute( mIndexBuffer ); mBuilder = new QgsMesh3DGeometryBuilder( triangularMesh, origin, extent, mVertScale, this ); @@ -419,8 +405,8 @@ void QgsMesh3DGeometry::prepareIndexesAttribute( Qt3DQBuffer *buffer ) } -QgsMesh3DGeometryBuilder::QgsMesh3DGeometryBuilder( const QgsTriangularMesh &mesh, const QgsVector3D &origin, const QgsRectangle &extent, float vertScale, QObject *parent ): - QObject( parent ) +QgsMesh3DGeometryBuilder::QgsMesh3DGeometryBuilder( const QgsTriangularMesh &mesh, const QgsVector3D &origin, const QgsRectangle &extent, float vertScale, QObject *parent ) + : QObject( parent ) , mMesh( mesh ) , mOrigin( origin ) , mExtent( extent ) @@ -462,15 +448,8 @@ void QgsMesh3DGeometryBuilder::indexFinished() } } -QgsMeshDataset3DGeometryBuilder::QgsMeshDataset3DGeometryBuilder -( const QgsTriangularMesh &mesh, - const QgsMesh &nativeMesh, - const QgsVector3D &origin, - const QgsRectangle &extent, - float vertScale, - const QgsMeshDataset3DGeometry::VertexData &vertexData, - QObject *parent ): - QgsMesh3DGeometryBuilder( mesh, origin, extent, vertScale, parent ) +QgsMeshDataset3DGeometryBuilder::QgsMeshDataset3DGeometryBuilder( const QgsTriangularMesh &mesh, const QgsMesh &nativeMesh, const QgsVector3D &origin, const QgsRectangle &extent, float vertScale, const QgsMeshDataset3DGeometry::VertexData &vertexData, QObject *parent ) + : QgsMesh3DGeometryBuilder( mesh, origin, extent, vertScale, parent ) , mNativeMesh( nativeMesh ) , mVertexData( vertexData ) {} diff --git a/src/3d/mesh/qgsmesh3dgeometry_p.h b/src/3d/mesh/qgsmesh3dgeometry_p.h index 2f153bd797b..bc25aaa88ee 100644 --- a/src/3d/mesh/qgsmesh3dgeometry_p.h +++ b/src/3d/mesh/qgsmesh3dgeometry_p.h @@ -21,7 +21,7 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #else #include @@ -48,18 +48,18 @@ #define SIP_NO_FILE -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) namespace Qt3DRender { class QAttribute; class QBuffer; -} +} // namespace Qt3DRender #else namespace Qt3DCore { class QAttribute; class QBuffer; -} +} // namespace Qt3DCore #endif class QgsMeshLayer; @@ -67,20 +67,16 @@ class QgsMeshLayer; /** * Class that constructs the geometry 3D mesh on another thread */ -class QgsMesh3DGeometryBuilder: public QObject +class QgsMesh3DGeometryBuilder : public QObject { Q_OBJECT public: - QgsMesh3DGeometryBuilder( const QgsTriangularMesh &mesh, - const QgsVector3D &origin, - const QgsRectangle &extent, - float vertScale, - QObject *parent ); + QgsMesh3DGeometryBuilder( const QgsTriangularMesh &mesh, const QgsVector3D &origin, const QgsRectangle &extent, float vertScale, QObject *parent ); virtual void start(); - QByteArray vertexData() const {return mFutureVertex.result();} - QByteArray indexData() const {return mFutureIndex.result();} + QByteArray vertexData() const { return mFutureVertex.result(); } + QByteArray indexData() const { return mFutureIndex.result(); } signals: void dataIsReady(); @@ -110,24 +106,20 @@ class QgsMesh3DGeometryBuilder: public QObject /** * Base class for creating attributes and vertex/index buffers for a mesh layer */ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -class QgsMesh3DGeometry: public Qt3DRender::QGeometry +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) +class QgsMesh3DGeometry : public Qt3DRender::QGeometry #else -class QgsMesh3DGeometry: public Qt3DCore::QGeometry +class QgsMesh3DGeometry : public Qt3DCore::QGeometry #endif { Q_OBJECT protected: //! Constructor - explicit QgsMesh3DGeometry( const QgsTriangularMesh &triangularMesh, - const QgsVector3D &origin, - const QgsRectangle &extent, - double verticalScale, - QNode *parent ); + explicit QgsMesh3DGeometry( const QgsTriangularMesh &triangularMesh, const QgsVector3D &origin, const QgsRectangle &extent, double verticalScale, QNode *parent ); ~QgsMesh3DGeometry() = default; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) void prepareVerticesPositionAttribute( Qt3DRender::QBuffer *buffer, int stride, int offset ); void prepareVerticesNormalAttribute( Qt3DRender::QBuffer *buffer, int stride, int offset ); void prepareIndexesAttribute( Qt3DRender::QBuffer *buffer ); @@ -142,7 +134,7 @@ class QgsMesh3DGeometry: public Qt3DCore::QGeometry float mVertScale; QgsTriangularMesh mTriangulaMesh; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) Qt3DRender::QBuffer *mVertexBuffer = nullptr; Qt3DRender::QBuffer *mIndexBuffer = nullptr; @@ -175,29 +167,23 @@ class QgsMeshDataset3DGeometryBuilder; * * When this job is finished, the mesh dataset 3D geometry node is updated and can be rendered in the 3D scene. */ -class QgsMeshDataset3DGeometry: public QgsMesh3DGeometry +class QgsMeshDataset3DGeometry : public QgsMesh3DGeometry { Q_OBJECT public: //! Constructs a mesh layer geometry from triangular mesh. - explicit QgsMeshDataset3DGeometry( const QgsTriangularMesh &triangularMesh, - QgsMeshLayer *layer, - const QgsDateTimeRange &timeRange, - const QgsVector3D &origin, - const QgsRectangle &extent, - const QgsMesh3DSymbol *symbol, - QNode *parent ); + explicit QgsMeshDataset3DGeometry( const QgsTriangularMesh &triangularMesh, QgsMeshLayer *layer, const QgsDateTimeRange &timeRange, const QgsVector3D &origin, const QgsRectangle &extent, const QgsMesh3DSymbol *symbol, QNode *parent ); //! Data sended to the other thread to consctruct the 3D geometry struct VertexData { - QgsMeshDatasetGroupMetadata verticalGroupMetadata; - QgsMeshDatasetGroupMetadata scalarGroupMetadata; - QgsMeshDataBlock verticalData; - QgsMeshDataBlock scalarData; + QgsMeshDatasetGroupMetadata verticalGroupMetadata; + QgsMeshDatasetGroupMetadata scalarGroupMetadata; + QgsMeshDataBlock verticalData; + QgsMeshDataBlock scalarData; - QgsMeshDataBlock activeFaceFlagValues; - bool isVerticalMagnitudeRelative; + QgsMeshDataBlock activeFaceFlagValues; + bool isVerticalMagnitudeRelative; }; private slots: @@ -208,7 +194,7 @@ class QgsMeshDataset3DGeometry: public QgsMesh3DGeometry //! Returns the number of active faces int extractDataset( QVector &verticaleMagnitude, QVector &scalarMagnitude, QgsMeshDataBlock &verticalActiveFaceFlagValues ); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) void prepareVerticesDatasetAttribute( Qt3DRender::QBuffer *buffer, int stride, int offset ); #else void prepareVerticesDatasetAttribute( Qt3DCore::QBuffer *buffer, int stride, int offset ); @@ -221,25 +207,19 @@ class QgsMeshDataset3DGeometry: public QgsMesh3DGeometry QgsMeshLayer *meshLayer() const; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) Qt3DRender::QAttribute *mMagnitudeAttribute = nullptr; #else Qt3DCore::QAttribute *mMagnitudeAttribute = nullptr; #endif }; -class QgsMeshDataset3DGeometryBuilder: public QgsMesh3DGeometryBuilder +class QgsMeshDataset3DGeometryBuilder : public QgsMesh3DGeometryBuilder { Q_OBJECT public: - QgsMeshDataset3DGeometryBuilder( const QgsTriangularMesh &mesh, - const QgsMesh &nativeMesh, - const QgsVector3D &origin, - const QgsRectangle &extent, - float vertScale, - const QgsMeshDataset3DGeometry::VertexData &vertexData, - QObject *parent ); + QgsMeshDataset3DGeometryBuilder( const QgsTriangularMesh &mesh, const QgsMesh &nativeMesh, const QgsVector3D &origin, const QgsRectangle &extent, float vertScale, const QgsMeshDataset3DGeometry::VertexData &vertexData, QObject *parent ); void start() override; private: @@ -253,20 +233,15 @@ class QgsMeshDataset3DGeometryBuilder: public QgsMesh3DGeometryBuilder * On creation, the instance launches immediately another thread that constructs 3D vertices, faces of the mesh based on the mesh vertices z value. * When this job is finished, the mesh terrain 3D geometry node is updated and can be rendered in the 3D scene. */ -class QgsMeshTerrain3DGeometry: public QgsMesh3DGeometry +class QgsMeshTerrain3DGeometry : public QgsMesh3DGeometry { Q_OBJECT public: //! Constructs a mesh layer geometry from triangular mesh. - explicit QgsMeshTerrain3DGeometry( const QgsTriangularMesh &triangularMesh, - const QgsVector3D &origin, - const QgsRectangle &extent, - double verticalScale, - QNode *parent ); + explicit QgsMeshTerrain3DGeometry( const QgsTriangularMesh &triangularMesh, const QgsVector3D &origin, const QgsRectangle &extent, double verticalScale, QNode *parent ); }; - ///@endcond #endif // QGSMESHGEOMETRY_P_H diff --git a/src/3d/mesh/qgsmesh3dmaterial_p.cpp b/src/3d/mesh/qgsmesh3dmaterial_p.cpp index 641021187d6..e7880304fc3 100644 --- a/src/3d/mesh/qgsmesh3dmaterial_p.cpp +++ b/src/3d/mesh/qgsmesh3dmaterial_p.cpp @@ -27,7 +27,7 @@ #include #include #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #else #include @@ -42,11 +42,11 @@ #include "qgscolorramptexture.h" -class ArrowsTextureGenerator: public Qt3DRender::QTextureImageDataGenerator +class ArrowsTextureGenerator : public Qt3DRender::QTextureImageDataGenerator { public: - ArrowsTextureGenerator( const QVector &vectors, const QSize &size, bool fixedSize, double maxVectorLength ): - mVectors( vectors ), mSize( size ), mFixedSize( fixedSize ), mMaxVectorLength( maxVectorLength ) + ArrowsTextureGenerator( const QVector &vectors, const QSize &size, bool fixedSize, double maxVectorLength ) + : mVectors( vectors ), mSize( size ), mFixedSize( fixedSize ), mMaxVectorLength( maxVectorLength ) {} Qt3DRender::QTextureImageDataPtr operator()() override @@ -68,9 +68,9 @@ class ArrowsTextureGenerator: public Qt3DRender::QTextureImageDataGenerator if ( mSize.isValid() ) { - data.resize( 2 * mSize.width()*mSize.height()*sizeof( float ) ); + data.resize( 2 * mSize.width() * mSize.height() * sizeof( float ) ); float *fptr = reinterpret_cast( data.data() ); - for ( int i = 0; i < mSize.width()*mSize.height(); ++i ) + for ( int i = 0; i < mSize.width() * mSize.height(); ++i ) { if ( mFixedSize ) *fptr++ = 1; @@ -85,15 +85,13 @@ class ArrowsTextureGenerator: public Qt3DRender::QTextureImageDataGenerator return dataPtr; } - bool operator ==( const Qt3DRender::QTextureImageDataGenerator &other ) const override + bool operator==( const Qt3DRender::QTextureImageDataGenerator &other ) const override { const ArrowsTextureGenerator *otherFunctor = functor_cast( &other ); if ( !otherFunctor ) return false; - return ( otherFunctor->mVectors == mVectors && - otherFunctor->mSize == mSize && - otherFunctor->mFixedSize == mFixedSize ); + return ( otherFunctor->mVectors == mVectors && otherFunctor->mSize == mSize && otherFunctor->mFixedSize == mFixedSize ); } private: @@ -109,12 +107,7 @@ class ArrowsTextureGenerator: public Qt3DRender::QTextureImageDataGenerator }; - -QgsMesh3DMaterial::QgsMesh3DMaterial( QgsMeshLayer *layer, - const QgsDateTimeRange &timeRange, - const QgsVector3D &origin, - const QgsMesh3DSymbol *symbol, - MagnitudeType magnitudeType ) +QgsMesh3DMaterial::QgsMesh3DMaterial( QgsMeshLayer *layer, const QgsDateTimeRange &timeRange, const QgsVector3D &origin, const QgsMesh3DSymbol *symbol, MagnitudeType magnitudeType ) : mSymbol( symbol->clone() ) , mMagnitudeType( magnitudeType ) , mOrigin( origin ) @@ -148,7 +141,6 @@ void QgsMesh3DMaterial::configure() colorRampTexture->addTextureImage( new QgsColorRampTexture( mSymbol->colorRampShader(), 1 ) ); break; } - } else { @@ -195,10 +187,10 @@ void QgsMesh3DMaterial::configure() mTechnique->addParameter( new Qt3DRender::QParameter( "lineColor", QVector4D( wireframecolor.redF(), wireframecolor.greenF(), wireframecolor.blueF(), 1.0f ) ) ); mTechnique->addParameter( new Qt3DRender::QParameter( "wireframeEnabled", mSymbol->wireframeEnabled() ) ); mTechnique->addParameter( new Qt3DRender::QParameter( "textureType", int( mSymbol->renderingStyle() ) ) ); - mTechnique->addParameter( new Qt3DRender::QParameter( "colorRampTexture", colorRampTexture ) ) ; + mTechnique->addParameter( new Qt3DRender::QParameter( "colorRampTexture", colorRampTexture ) ); mTechnique->addParameter( new Qt3DRender::QParameter( "colorRampCount", mSymbol->colorRampShader().colorRampItemList().count() ) ); const Qgis::ShaderInterpolationMethod colorRampType = mSymbol->colorRampShader().colorRampType(); - mTechnique->addParameter( new Qt3DRender::QParameter( "colorRampType", static_cast< int >( colorRampType ) ) ); + mTechnique->addParameter( new Qt3DRender::QParameter( "colorRampType", static_cast( colorRampType ) ) ); const QColor meshColor = mSymbol->singleMeshColor(); mTechnique->addParameter( new Qt3DRender::QParameter( "meshColor", QVector4D( meshColor.redF(), meshColor.greenF(), meshColor.blueF(), 1.0f ) ) ); mTechnique->addParameter( new Qt3DRender::QParameter( "isScalarMagnitude", ( mMagnitudeType == QgsMesh3DMaterial::ScalarDataSet ) ) ); @@ -216,7 +208,7 @@ void QgsMesh3DMaterial::configureArrows( QgsMeshLayer *layer, const QgsDateTimeR QVector vectors( 1 ); QSize gridSize( 1, 1 ); QgsPointXY minCorner; - std::unique_ptr< Qt3DRender::QParameter > arrowsEnabledParameter = std::make_unique< Qt3DRender::QParameter >( "arrowsEnabled", nullptr ); + std::unique_ptr arrowsEnabledParameter = std::make_unique( "arrowsEnabled", nullptr ); if ( !layer || mMagnitudeType != MagnitudeType::ScalarDataSet || !mSymbol->arrowsEnabled() || meta.isScalar() || !datasetIndex.isValid() ) arrowsEnabledParameter->setValue( false ); else @@ -248,18 +240,19 @@ void QgsMesh3DMaterial::configureArrows( QgsMeshLayer *layer, const QgsDateTimeR minCorner = QgsPointXY( xMin, yMin ); vectors = QgsMeshLayerUtils::griddedVectorValues( - layer, - datasetIndex, - xSpacing, - ySpacing, - gridSize, - minCorner ); + layer, + datasetIndex, + xSpacing, + ySpacing, + gridSize, + minCorner + ); if ( vectors.isEmpty() ) return; } - mTechnique->addParameter( arrowsEnabledParameter.release() ) ; + mTechnique->addParameter( arrowsEnabledParameter.release() ); Qt3DRender::QTexture2D *arrowsGridTexture = new Qt3DRender::QTexture2D( this ); arrowsGridTexture->addTextureImage( new ArrowsGridTexture( vectors, gridSize, mSymbol->arrowsFixedSize(), meta.maximum() ) ); @@ -272,11 +265,11 @@ void QgsMesh3DMaterial::configureArrows( QgsMeshLayer *layer, const QgsDateTimeR arrowTexture->addTextureImage( arrowTextureImage ); arrowTexture->setMinificationFilter( Qt3DRender::QTexture2D::Nearest ); arrowTexture->setMagnificationFilter( Qt3DRender::QTexture2D::Nearest ); - mTechnique->addParameter( new Qt3DRender::QParameter( "arrowsColor", QVector4D( arrowsColor.redF(), arrowsColor.greenF(), arrowsColor.blueF(), 1.0f ) ) ) ; - mTechnique->addParameter( new Qt3DRender::QParameter( "arrowsSpacing", float( mSymbol->arrowsSpacing() ) ) ) ; + mTechnique->addParameter( new Qt3DRender::QParameter( "arrowsColor", QVector4D( arrowsColor.redF(), arrowsColor.greenF(), arrowsColor.blueF(), 1.0f ) ) ); + mTechnique->addParameter( new Qt3DRender::QParameter( "arrowsSpacing", float( mSymbol->arrowsSpacing() ) ) ); mTechnique->addParameter( new Qt3DRender::QParameter( "arrowTexture", arrowTexture ) ); - mTechnique->addParameter( new Qt3DRender::QParameter( "arrowsGridTexture", arrowsGridTexture ) ) ; - mTechnique->addParameter( new Qt3DRender::QParameter( "arrowsMinCorner", QVector2D( minCorner.x() - mOrigin.x(), -minCorner.y() + mOrigin.y() ) ) ) ; + mTechnique->addParameter( new Qt3DRender::QParameter( "arrowsGridTexture", arrowsGridTexture ) ); + mTechnique->addParameter( new Qt3DRender::QParameter( "arrowsMinCorner", QVector2D( minCorner.x() - mOrigin.x(), -minCorner.y() + mOrigin.y() ) ) ); } ArrowsGridTexture::ArrowsGridTexture( const QVector &vectors, const QSize &size, bool fixedSize, double maxVectorLength ) diff --git a/src/3d/mesh/qgsmesh3dmaterial_p.h b/src/3d/mesh/qgsmesh3dmaterial_p.h index 12f8ab66146..bc6c6a5f1fa 100644 --- a/src/3d/mesh/qgsmesh3dmaterial_p.h +++ b/src/3d/mesh/qgsmesh3dmaterial_p.h @@ -71,14 +71,10 @@ class QgsMesh3DMaterial : public QgsMaterial }; //! Constructor - QgsMesh3DMaterial( QgsMeshLayer *layer, - const QgsDateTimeRange &timeRange, - const QgsVector3D &origin, - const QgsMesh3DSymbol *symbol, - MagnitudeType magnitudeType = ZValue ); + QgsMesh3DMaterial( QgsMeshLayer *layer, const QgsDateTimeRange &timeRange, const QgsVector3D &origin, const QgsMesh3DSymbol *symbol, MagnitudeType magnitudeType = ZValue ); private: - std::unique_ptr< QgsMesh3DSymbol > mSymbol; + std::unique_ptr mSymbol; Qt3DRender::QTechnique *mTechnique; MagnitudeType mMagnitudeType = ZValue; QgsVector3D mOrigin; @@ -88,7 +84,7 @@ class QgsMesh3DMaterial : public QgsMaterial }; -class ArrowsGridTexture: public Qt3DRender::QAbstractTextureImage +class ArrowsGridTexture : public Qt3DRender::QAbstractTextureImage { Q_OBJECT diff --git a/src/3d/mesh/qgsmeshterraingenerator.cpp b/src/3d/mesh/qgsmeshterraingenerator.cpp index e531d12460d..9fecc4256ae 100644 --- a/src/3d/mesh/qgsmeshterraingenerator.cpp +++ b/src/3d/mesh/qgsmeshterraingenerator.cpp @@ -49,9 +49,8 @@ Qt3DCore::QEntity *QgsMeshTerrainTileLoader::createEntity( Qt3DCore::QEntity *pa // QgsMeshTerrainGenerator::QgsMeshTerrainGenerator() - : mSymbol( std::make_unique< QgsMesh3DSymbol >() ) + : mSymbol( std::make_unique() ) { - } QgsChunkLoader *QgsMeshTerrainGenerator::createChunkLoader( QgsChunkNode *node ) const @@ -71,7 +70,7 @@ void QgsMeshTerrainGenerator::rootChunkHeightRange( float &hMin, float &hMax ) c for ( int i = 0; i < mTriangularMesh.vertices().count(); ++i ) { - const float zValue = static_cast< float >( mTriangularMesh.vertices().at( i ).z() ); + const float zValue = static_cast( mTriangularMesh.vertices().at( i ).z() ); if ( min > zValue ) min = zValue; if ( max < zValue ) @@ -120,7 +119,7 @@ QgsTerrainGenerator *QgsMeshTerrainGenerator::clone() const return cloned; } -QgsTerrainGenerator::Type QgsMeshTerrainGenerator::type() const {return QgsTerrainGenerator::Mesh;} +QgsTerrainGenerator::Type QgsMeshTerrainGenerator::type() const { return QgsTerrainGenerator::Mesh; } QgsRectangle QgsMeshTerrainGenerator::rootChunkExtent() const { diff --git a/src/3d/mesh/qgsmeshterraingenerator.h b/src/3d/mesh/qgsmeshterraingenerator.h index b26b5d4d787..adff7b380ab 100644 --- a/src/3d/mesh/qgsmeshterraingenerator.h +++ b/src/3d/mesh/qgsmeshterraingenerator.h @@ -31,7 +31,7 @@ * \brief Implementation of terrain generator that uses the Z values of a mesh layer to build a terrain * \since QGIS 3.12 */ -class _3D_EXPORT QgsMeshTerrainGenerator: public QgsTerrainGenerator +class _3D_EXPORT QgsMeshTerrainGenerator : public QgsTerrainGenerator { Q_OBJECT public: @@ -70,10 +70,8 @@ class _3D_EXPORT QgsMeshTerrainGenerator: public QgsTerrainGenerator QgsMapLayerRef mLayer; QgsCoordinateReferenceSystem mCrs; QgsCoordinateTransformContext mTransformContext; - std::unique_ptr< QgsMesh3DSymbol > mSymbol; + std::unique_ptr mSymbol; QgsTriangularMesh mTriangularMesh; - - }; #endif // QGSMESHTERRAINGENERATOR_H diff --git a/src/3d/mesh/qgsmeshterraintileloader_p.h b/src/3d/mesh/qgsmeshterraintileloader_p.h index 4bea9525ab4..dac8abf46f0 100644 --- a/src/3d/mesh/qgsmeshterraintileloader_p.h +++ b/src/3d/mesh/qgsmeshterraintileloader_p.h @@ -27,22 +27,19 @@ ///@cond PRIVATE //! Chunk loader for mesh terrain implementation -class QgsMeshTerrainTileLoader: public QgsTerrainTileLoader +class QgsMeshTerrainTileLoader : public QgsTerrainTileLoader { Q_OBJECT public: //! Construct the loader for a node - QgsMeshTerrainTileLoader( QgsTerrainEntity *terrain, - QgsChunkNode *node, - const QgsTriangularMesh &triangularMesh, - const QgsMesh3DSymbol *symbol ); + QgsMeshTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkNode *node, const QgsTriangularMesh &triangularMesh, const QgsMesh3DSymbol *symbol ); //! Create the 3D entity and returns it Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override; private: QgsTriangularMesh mTriangularMesh; - std::unique_ptr< QgsMesh3DSymbol > mSymbol; + std::unique_ptr mSymbol; }; ///@endcond diff --git a/src/3d/processing/qgs3dalgorithms.cpp b/src/3d/processing/qgs3dalgorithms.cpp index 923fc2ef870..a2febe2622a 100644 --- a/src/3d/processing/qgs3dalgorithms.cpp +++ b/src/3d/processing/qgs3dalgorithms.cpp @@ -63,6 +63,3 @@ void Qgs3DAlgorithms::loadAlgorithms() ///@endcond - - - diff --git a/src/3d/processing/qgs3dalgorithms.h b/src/3d/processing/qgs3dalgorithms.h index 08adb5290bd..5dd8a47780c 100644 --- a/src/3d/processing/qgs3dalgorithms.h +++ b/src/3d/processing/qgs3dalgorithms.h @@ -27,12 +27,11 @@ * \class Qgs3DAlgorithms * \brief QGIS 3D processing algorithm provider. */ -class _3D_EXPORT Qgs3DAlgorithms: public QgsProcessingProvider +class _3D_EXPORT Qgs3DAlgorithms : public QgsProcessingProvider { Q_OBJECT public: - /** * Constructor for Qgs3DAlgorithms. */ @@ -46,11 +45,7 @@ class _3D_EXPORT Qgs3DAlgorithms: public QgsProcessingProvider bool supportsNonFileBasedOutput() const override; protected: - void loadAlgorithms() override; - }; #endif // QGS3DALGORITHMS_H - - diff --git a/src/3d/processing/qgsalgorithmtessellate.cpp b/src/3d/processing/qgsalgorithmtessellate.cpp index e90528d0d19..9b862657061 100644 --- a/src/3d/processing/qgsalgorithmtessellate.cpp +++ b/src/3d/processing/qgsalgorithmtessellate.cpp @@ -72,7 +72,7 @@ QString QgsTessellateAlgorithm::shortHelpString() const QList QgsTessellateAlgorithm::inputLayerTypes() const { - return QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorPolygon ); + return QList() << static_cast( Qgis::ProcessingSourceType::VectorPolygon ); } QgsTessellateAlgorithm *QgsTessellateAlgorithm::createInstance() const @@ -91,7 +91,7 @@ QgsFeatureList QgsTessellateAlgorithm::processFeature( const QgsFeature &feature { const QgsGeometry inputGeometry = f.geometry(); bool tessellationComplete = false; -#if (GEOS_VERSION_MAJOR==3 && GEOS_VERSION_MINOR>=11) || GEOS_VERSION_MAJOR>3 +#if ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR >= 11 ) || GEOS_VERSION_MAJOR > 3 if ( !inputGeometry.constGet()->is3D() ) { // on supported GEOS versions we prefer to use GEOS GEOSConstrainedDelaunayTriangulation @@ -126,16 +126,16 @@ QgsFeatureList QgsTessellateAlgorithm::processFeature( const QgsFeature &feature if ( f.geometry().isMultipart() ) { - const QgsMultiSurface *ms = qgsgeometry_cast< const QgsMultiSurface * >( f.geometry().constGet() ); + const QgsMultiSurface *ms = qgsgeometry_cast( f.geometry().constGet() ); for ( int i = 0; i < ms->numGeometries(); ++i ) { - const std::unique_ptr< QgsPolygon > p( qgsgeometry_cast< QgsPolygon * >( ms->geometryN( i )->segmentize() ) ); + const std::unique_ptr p( qgsgeometry_cast( ms->geometryN( i )->segmentize() ) ); t.addPolygon( *p, 0 ); } } else { - const std::unique_ptr< QgsPolygon > p( qgsgeometry_cast< QgsPolygon * >( f.geometry().constGet()->segmentize() ) ); + const std::unique_ptr p( qgsgeometry_cast( f.geometry().constGet()->segmentize() ) ); t.addPolygon( *p, 0 ); } QgsGeometry g( t.asMultiPolygon() ); @@ -166,5 +166,3 @@ QgsFeatureList QgsTessellateAlgorithm::processFeature( const QgsFeature &feature } ///@endcond - - diff --git a/src/3d/processing/qgsalgorithmtessellate.h b/src/3d/processing/qgsalgorithmtessellate.h index 9e80244f534..9a5eb2c4dc5 100644 --- a/src/3d/processing/qgsalgorithmtessellate.h +++ b/src/3d/processing/qgsalgorithmtessellate.h @@ -30,9 +30,7 @@ */ class QgsTessellateAlgorithm : public QgsProcessingFeatureBasedAlgorithm { - public: - QgsTessellateAlgorithm() = default; QString name() const override; QString displayName() const override; @@ -49,12 +47,9 @@ class QgsTessellateAlgorithm : public QgsProcessingFeatureBasedAlgorithm Qgis::WkbType outputWkbType( Qgis::WkbType inputWkbType ) const override; QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; - }; ///@endcond PRIVATE #endif // QGSALGORITHMTESSELLATE_H - - diff --git a/src/3d/qgs3d.cpp b/src/3d/qgs3d.cpp index 08bfeedcafe..1684b273e12 100644 --- a/src/3d/qgs3d.cpp +++ b/src/3d/qgs3d.cpp @@ -67,25 +67,16 @@ void Qgs3D::initialize() QgsApplication::renderer3DRegistry()->addRenderer( new QgsPointCloudLayer3DRendererMetadata ); QgsApplication::renderer3DRegistry()->addRenderer( new QgsTiledSceneLayer3DRendererMetadata ); - QgsApplication::symbol3DRegistry()->addSymbolType( new Qgs3DSymbolMetadata( QStringLiteral( "point" ), QObject::tr( "Point" ), - &QgsPoint3DSymbol::create, nullptr, Qgs3DSymbolImpl::handlerForPoint3DSymbol ) ); - QgsApplication::symbol3DRegistry()->addSymbolType( new Qgs3DSymbolMetadata( QStringLiteral( "line" ), QObject::tr( "Line" ), - &QgsLine3DSymbol::create, nullptr, Qgs3DSymbolImpl::handlerForLine3DSymbol ) ); - QgsApplication::symbol3DRegistry()->addSymbolType( new Qgs3DSymbolMetadata( QStringLiteral( "polygon" ), QObject::tr( "Polygon" ), - &QgsPolygon3DSymbol::create, nullptr, Qgs3DSymbolImpl::handlerForPolygon3DSymbol ) ); + QgsApplication::symbol3DRegistry()->addSymbolType( new Qgs3DSymbolMetadata( QStringLiteral( "point" ), QObject::tr( "Point" ), &QgsPoint3DSymbol::create, nullptr, Qgs3DSymbolImpl::handlerForPoint3DSymbol ) ); + QgsApplication::symbol3DRegistry()->addSymbolType( new Qgs3DSymbolMetadata( QStringLiteral( "line" ), QObject::tr( "Line" ), &QgsLine3DSymbol::create, nullptr, Qgs3DSymbolImpl::handlerForLine3DSymbol ) ); + QgsApplication::symbol3DRegistry()->addSymbolType( new Qgs3DSymbolMetadata( QStringLiteral( "polygon" ), QObject::tr( "Polygon" ), &QgsPolygon3DSymbol::create, nullptr, Qgs3DSymbolImpl::handlerForPolygon3DSymbol ) ); - Qgs3D::materialRegistry()->addMaterialSettingsType( new QgsMaterialSettingsMetadata( QStringLiteral( "null" ), QObject::tr( "Embedded Textures" ), - QgsNullMaterialSettings::create, QgsNullMaterialSettings::supportsTechnique, nullptr, QgsApplication::getThemeIcon( QStringLiteral( "/mIconPhongTexturedMaterial.svg" ) ) ) ); - Qgs3D::materialRegistry()->addMaterialSettingsType( new QgsMaterialSettingsMetadata( QStringLiteral( "phong" ), QObject::tr( "Realistic (Phong)" ), - QgsPhongMaterialSettings::create, QgsPhongMaterialSettings::supportsTechnique, nullptr, QgsApplication::getThemeIcon( QStringLiteral( "/mIconPhongMaterial.svg" ) ) ) ); - Qgs3D::materialRegistry()->addMaterialSettingsType( new QgsMaterialSettingsMetadata( QStringLiteral( "phongtextured" ), QObject::tr( "Realistic Textured (Phong)" ), - QgsPhongTexturedMaterialSettings::create, QgsPhongTexturedMaterialSettings::supportsTechnique, nullptr, QgsApplication::getThemeIcon( QStringLiteral( "/mIconPhongTexturedMaterial.svg" ) ) ) ); - Qgs3D::materialRegistry()->addMaterialSettingsType( new QgsMaterialSettingsMetadata( QStringLiteral( "simpleline" ), QObject::tr( "Single Color (Unlit)" ), - QgsSimpleLineMaterialSettings::create, QgsSimpleLineMaterialSettings::supportsTechnique, nullptr, QgsApplication::getThemeIcon( QStringLiteral( "/mIconSimpleLineMaterial.svg" ) ) ) ); - Qgs3D::materialRegistry()->addMaterialSettingsType( new QgsMaterialSettingsMetadata( QStringLiteral( "gooch" ), QObject::tr( "CAD (Gooch)" ), - QgsGoochMaterialSettings::create, QgsGoochMaterialSettings::supportsTechnique, nullptr, QgsApplication::getThemeIcon( QStringLiteral( "/mIconGoochMaterial.svg" ) ) ) ); - Qgs3D::materialRegistry()->addMaterialSettingsType( new QgsMaterialSettingsMetadata( QStringLiteral( "metalrough" ), QObject::tr( "Metal Roughness" ), - QgsMetalRoughMaterialSettings::create, QgsMetalRoughMaterialSettings::supportsTechnique, nullptr, QgsApplication::getThemeIcon( QStringLiteral( "/mIconGoochMaterial.svg" ) ) ) ); + Qgs3D::materialRegistry()->addMaterialSettingsType( new QgsMaterialSettingsMetadata( QStringLiteral( "null" ), QObject::tr( "Embedded Textures" ), QgsNullMaterialSettings::create, QgsNullMaterialSettings::supportsTechnique, nullptr, QgsApplication::getThemeIcon( QStringLiteral( "/mIconPhongTexturedMaterial.svg" ) ) ) ); + Qgs3D::materialRegistry()->addMaterialSettingsType( new QgsMaterialSettingsMetadata( QStringLiteral( "phong" ), QObject::tr( "Realistic (Phong)" ), QgsPhongMaterialSettings::create, QgsPhongMaterialSettings::supportsTechnique, nullptr, QgsApplication::getThemeIcon( QStringLiteral( "/mIconPhongMaterial.svg" ) ) ) ); + Qgs3D::materialRegistry()->addMaterialSettingsType( new QgsMaterialSettingsMetadata( QStringLiteral( "phongtextured" ), QObject::tr( "Realistic Textured (Phong)" ), QgsPhongTexturedMaterialSettings::create, QgsPhongTexturedMaterialSettings::supportsTechnique, nullptr, QgsApplication::getThemeIcon( QStringLiteral( "/mIconPhongTexturedMaterial.svg" ) ) ) ); + Qgs3D::materialRegistry()->addMaterialSettingsType( new QgsMaterialSettingsMetadata( QStringLiteral( "simpleline" ), QObject::tr( "Single Color (Unlit)" ), QgsSimpleLineMaterialSettings::create, QgsSimpleLineMaterialSettings::supportsTechnique, nullptr, QgsApplication::getThemeIcon( QStringLiteral( "/mIconSimpleLineMaterial.svg" ) ) ) ); + Qgs3D::materialRegistry()->addMaterialSettingsType( new QgsMaterialSettingsMetadata( QStringLiteral( "gooch" ), QObject::tr( "CAD (Gooch)" ), QgsGoochMaterialSettings::create, QgsGoochMaterialSettings::supportsTechnique, nullptr, QgsApplication::getThemeIcon( QStringLiteral( "/mIconGoochMaterial.svg" ) ) ) ); + Qgs3D::materialRegistry()->addMaterialSettingsType( new QgsMaterialSettingsMetadata( QStringLiteral( "metalrough" ), QObject::tr( "Metal Roughness" ), QgsMetalRoughMaterialSettings::create, QgsMetalRoughMaterialSettings::supportsTechnique, nullptr, QgsApplication::getThemeIcon( QStringLiteral( "/mIconGoochMaterial.svg" ) ) ) ); // because we are usually populating the 3d registry AFTER QgsApplication initialization, we need to defer creation // of 3d symbols in the default style until now diff --git a/src/3d/qgs3d.h b/src/3d/qgs3d.h index 8a3ae9e9520..a58b3fa28aa 100644 --- a/src/3d/qgs3d.h +++ b/src/3d/qgs3d.h @@ -31,9 +31,7 @@ class QgsMaterialRegistry; */ class _3D_EXPORT Qgs3D { - public: - Qgs3D( const Qgs3D &other ) = delete; Qgs3D &operator=( const Qgs3D &other ) = delete; @@ -55,7 +53,6 @@ class _3D_EXPORT Qgs3D static QgsMaterialRegistry *materialRegistry(); private: - Qgs3D(); #ifdef SIP_RUN @@ -65,7 +62,6 @@ class _3D_EXPORT Qgs3D bool mInitialized = false; QgsMaterialRegistry *mMaterialRegistry = nullptr; - }; #endif // QGS3D_H diff --git a/src/3d/qgs3danimationsettings.cpp b/src/3d/qgs3danimationsettings.cpp index 918d49f3282..25b06e2ce07 100644 --- a/src/3d/qgs3danimationsettings.cpp +++ b/src/3d/qgs3danimationsettings.cpp @@ -56,9 +56,7 @@ Qgs3DAnimationSettings::Keyframe Qgs3DAnimationSettings::interpolate( float time Keyframe kf; kf.time = time; - kf.point.set( k0.point.x() * eIip + k1.point.x() * eIp, - k0.point.y() * eIip + k1.point.y() * eIp, - k0.point.z() * eIip + k1.point.z() * eIp ); + kf.point.set( k0.point.x() * eIip + k1.point.x() * eIp, k0.point.y() * eIip + k1.point.y() * eIp, k0.point.z() * eIip + k1.point.z() * eIp ); kf.dist = k0.dist * eIip + k1.dist * eIp; kf.pitch = k0.pitch * eIip + k1.pitch * eIp; @@ -93,9 +91,7 @@ void Qgs3DAnimationSettings::readXml( const QDomElement &elem ) { Keyframe kf; kf.time = elemKeyframe.attribute( QStringLiteral( "time" ) ).toFloat(); - kf.point.set( elemKeyframe.attribute( QStringLiteral( "x" ) ).toDouble(), - elemKeyframe.attribute( QStringLiteral( "y" ) ).toDouble(), - elemKeyframe.attribute( QStringLiteral( "z" ) ).toDouble() ); + kf.point.set( elemKeyframe.attribute( QStringLiteral( "x" ) ).toDouble(), elemKeyframe.attribute( QStringLiteral( "y" ) ).toDouble(), elemKeyframe.attribute( QStringLiteral( "z" ) ).toDouble() ); kf.dist = elemKeyframe.attribute( QStringLiteral( "dist" ) ).toFloat(); kf.pitch = elemKeyframe.attribute( QStringLiteral( "pitch" ) ).toFloat(); kf.yaw = elemKeyframe.attribute( QStringLiteral( "yaw" ) ).toFloat(); diff --git a/src/3d/qgs3danimationsettings.h b/src/3d/qgs3danimationsettings.h index db1ff963698..c93e4c2820e 100644 --- a/src/3d/qgs3danimationsettings.h +++ b/src/3d/qgs3danimationsettings.h @@ -38,17 +38,16 @@ class QgsReadWriteContext; class _3D_EXPORT Qgs3DAnimationSettings { public: - Qgs3DAnimationSettings(); //! keyframe definition struct Keyframe { - float time = 0; //!< Relative time of the keyframe in seconds - QgsVector3D point; //!< Point towards which the camera is looking in 3D world coords - float dist = 0; //!< Distance of the camera from the focal point - float pitch = 0; //!< Tilt of the camera in degrees (0 = looking from the top, 90 = looking from the side, 180 = looking from the bottom) - float yaw = 0; //!< Horizontal rotation around the focal point in degrees + float time = 0; //!< Relative time of the keyframe in seconds + QgsVector3D point; //!< Point towards which the camera is looking in 3D world coords + float dist = 0; //!< Distance of the camera from the focal point + float pitch = 0; //!< Tilt of the camera in degrees (0 = looking from the top, 90 = looking from the side, 180 = looking from the bottom) + float yaw = 0; //!< Horizontal rotation around the focal point in degrees }; typedef QVector Keyframes; diff --git a/src/3d/qgs3daxis.cpp b/src/3d/qgs3daxis.cpp index ea0c6860ea5..88ae64d182e 100644 --- a/src/3d/qgs3daxis.cpp +++ b/src/3d/qgs3daxis.cpp @@ -44,11 +44,7 @@ #include "qgsraycastingutils_p.h" #include "qgs3dwiredmesh_p.h" -Qgs3DAxis::Qgs3DAxis( Qgs3DMapCanvas *canvas, - Qt3DCore::QEntity *parent3DScene, - Qgs3DMapScene *mapScene, - QgsCameraController *cameraCtrl, - Qgs3DMapSettings *map ) +Qgs3DAxis::Qgs3DAxis( Qgs3DMapCanvas *canvas, Qt3DCore::QEntity *parent3DScene, Qgs3DMapScene *mapScene, QgsCameraController *cameraCtrl, Qgs3DMapSettings *map ) : QObject( canvas ) , mMapSettings( map ) , mCanvas( canvas ) @@ -100,7 +96,7 @@ Qgs3DAxis::~Qgs3DAxis() } } -void Qgs3DAxis::init3DObjectPicking( ) +void Qgs3DAxis::init3DObjectPicking() { mDefaultPickingMethod = mMapScene->engine()->renderSettings()->pickingSettings()->pickMethod(); @@ -140,8 +136,7 @@ bool Qgs3DAxis::eventFilter( QObject *watched, QEvent *event ) QMouseEvent *mouseEvent = static_cast( event ); // user has clicked and move ==> dragging start - if ( event->type() == QEvent::MouseMove && - ( ( mHasClicked && ( mouseEvent->pos() - mLastClickedPos ).manhattanLength() < QApplication::startDragDistance() ) || mIsDragging ) ) + if ( event->type() == QEvent::MouseMove && ( ( mHasClicked && ( mouseEvent->pos() - mLastClickedPos ).manhattanLength() < QApplication::startDragDistance() ) || mIsDragging ) ) { mIsDragging = true; } @@ -154,11 +149,10 @@ bool Qgs3DAxis::eventFilter( QObject *watched, QEvent *event ) } // user is moving or has released but not dragging - else if ( ! mIsDragging ) + else if ( !mIsDragging ) { // limit ray caster usage to the axis viewport - QPointF normalizedPos( static_cast( mouseEvent->pos().x() ) / static_cast( mCanvas->width() ), - static_cast( mouseEvent->pos().y() ) / static_cast( mCanvas->height() ) ); + QPointF normalizedPos( static_cast( mouseEvent->pos().x() ) / static_cast( mCanvas->width() ), static_cast( mouseEvent->pos().y() ) / static_cast( mCanvas->height() ) ); if ( 2 <= QgsLogger::debugLevel() && event->type() == QEvent::MouseButtonRelease ) { @@ -224,18 +218,14 @@ void Qgs3DAxis::onTouchedByRay( const Qt3DRender::QAbstractRayCaster::Hits &hits for ( int i = 0; i < hits.length() && mHitsFound == -1; ++i ) { - if ( hits.at( i ).distance() < 500.0f && hits.at( i ).entity() && - ( hits.at( i ).entity() == mCubeRoot || - hits.at( i ).entity() == mAxisRoot || - hits.at( i ).entity()->parent() == mCubeRoot || - hits.at( i ).entity()->parent() == mAxisRoot ) ) + if ( hits.at( i ).distance() < 500.0f && hits.at( i ).entity() && ( hits.at( i ).entity() == mCubeRoot || hits.at( i ).entity() == mAxisRoot || hits.at( i ).entity()->parent() == mCubeRoot || hits.at( i ).entity()->parent() == mAxisRoot ) ) { mHitsFound = i; } } } - if ( mLastClickedButton == Qt::NoButton ) // hover + if ( mLastClickedButton == Qt::NoButton ) // hover { if ( mHitsFound != -1 ) { @@ -246,8 +236,7 @@ void Qgs3DAxis::onTouchedByRay( const Qt3DRender::QAbstractRayCaster::Hits &hits QgsDebugMsgLevel( "Enabling arrow cursor", 2 ); // The cube needs triangle picking to handle click on faces. - if ( mMapScene->engine()->renderSettings()->pickingSettings()->pickMethod() != Qt3DRender::QPickingSettings::TrianglePicking && - mCubeRoot->isEnabled() ) + if ( mMapScene->engine()->renderSettings()->pickingSettings()->pickMethod() != Qt3DRender::QPickingSettings::TrianglePicking && mCubeRoot->isEnabled() ) { mMapScene->engine()->renderSettings()->pickingSettings()->setPickMethod( Qt3DRender::QPickingSettings::TrianglePicking ); QgsDebugMsgLevel( "Enabling triangle picking", 2 ); @@ -397,8 +386,7 @@ QVector3D Qgs3DAxis::from3DTo2DLabelPosition( const QVector3D &sourcePos, Qt3DRe { const int viewportWidth = static_cast( std::round( mTwoDLabelCamera->lens()->right() - mTwoDLabelCamera->lens()->left() ) ); const int viewportHeight = static_cast( std::round( mTwoDLabelCamera->lens()->top() - mTwoDLabelCamera->lens()->bottom() ) ); - QRect viewportRect( static_cast( std::round( mTwoDLabelCamera->lens()->left() ) ), static_cast( std::round( mTwoDLabelCamera->lens()->bottom() ) ), - viewportWidth, viewportHeight ); + QRect viewportRect( static_cast( std::round( mTwoDLabelCamera->lens()->left() ) ), static_cast( std::round( mTwoDLabelCamera->lens()->bottom() ) ), viewportWidth, viewportHeight ); QVector3D destPos = sourcePos.project( sourceCamera->viewMatrix(), destCamera->projectionMatrix(), viewportRect ); destPos.setZ( 0.0f ); @@ -453,7 +441,7 @@ void Qgs3DAxis::createAxisScene() mCubeRoot->setObjectName( "3DAxis_CubeRoot" ); mCubeRoot->addComponent( mAxisObjectLayer ); // raycaster will filter object containing this layer - createCube( ); + createCube(); } Qgs3DAxisSettings::Mode mode = mMapSettings->get3DAxisSettings().mode(); @@ -472,7 +460,7 @@ void Qgs3DAxis::createAxisScene() setEnableCube( false ); setEnableAxis( true ); - const QList< Qgis::CrsAxisDirection > axisDirections = mCrs.axisOrdering(); + const QList axisDirections = mCrs.axisOrdering(); if ( axisDirections.length() > 0 ) mTextX->setText( QgsCoordinateReferenceSystemUtils::axisDirectionToAbbreviatedString( axisDirections.at( 0 ) ) ); @@ -520,22 +508,22 @@ void Qgs3DAxis::createKeyboardShortCut() else { QShortcut *shortcutHome = new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_1 ), mapCanvas ); - connect( shortcutHome, &QShortcut::activated, this, [this]( ) {onCameraViewChangeHome();} ); + connect( shortcutHome, &QShortcut::activated, this, [this]() { onCameraViewChangeHome(); } ); QShortcut *shortcutTop = new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_5 ), mapCanvas ); - connect( shortcutTop, &QShortcut::activated, this, [this]( ) {onCameraViewChangeTop();} ); + connect( shortcutTop, &QShortcut::activated, this, [this]() { onCameraViewChangeTop(); } ); QShortcut *shortcutNorth = new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_8 ), mapCanvas ); - connect( shortcutNorth, &QShortcut::activated, this, [this]( ) {onCameraViewChangeNorth();} ); + connect( shortcutNorth, &QShortcut::activated, this, [this]() { onCameraViewChangeNorth(); } ); QShortcut *shortcutEast = new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_6 ), mapCanvas ); - connect( shortcutEast, &QShortcut::activated, this, [this]( ) {onCameraViewChangeEast();} ); + connect( shortcutEast, &QShortcut::activated, this, [this]() { onCameraViewChangeEast(); } ); QShortcut *shortcutSouth = new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_2 ), mapCanvas ); - connect( shortcutSouth, &QShortcut::activated, this, [this]( ) {onCameraViewChangeSouth();} ); + connect( shortcutSouth, &QShortcut::activated, this, [this]() { onCameraViewChangeSouth(); } ); QShortcut *shortcutWest = new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_4 ), mapCanvas ); - connect( shortcutWest, &QShortcut::activated, this, [this]( ) {onCameraViewChangeWest();} ); + connect( shortcutWest, &QShortcut::activated, this, [this]() { onCameraViewChangeWest(); } ); } } } @@ -548,8 +536,7 @@ void Qgs3DAxis::createMenu() QAction *typeOffAct = new QAction( tr( "&Off" ), mMenu ); typeOffAct->setCheckable( true ); typeOffAct->setStatusTip( tr( "Disable 3D axis" ) ); - connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [typeOffAct, this]() - { + connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [typeOffAct, this]() { if ( mMapSettings->get3DAxisSettings().mode() == Qgs3DAxisSettings::Mode::Off ) typeOffAct->setChecked( true ); } ); @@ -557,8 +544,7 @@ void Qgs3DAxis::createMenu() QAction *typeCrsAct = new QAction( tr( "Coordinate Reference &System" ), mMenu ); typeCrsAct->setCheckable( true ); typeCrsAct->setStatusTip( tr( "Coordinate Reference System 3D axis" ) ); - connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [typeCrsAct, this]() - { + connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [typeCrsAct, this]() { if ( mMapSettings->get3DAxisSettings().mode() == Qgs3DAxisSettings::Mode::Crs ) typeCrsAct->setChecked( true ); } ); @@ -566,8 +552,7 @@ void Qgs3DAxis::createMenu() QAction *typeCubeAct = new QAction( tr( "&Cube" ), mMenu ); typeCubeAct->setCheckable( true ); typeCubeAct->setStatusTip( tr( "Cube 3D axis" ) ); - connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [typeCubeAct, this]() - { + connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [typeCubeAct, this]() { if ( mMapSettings->get3DAxisSettings().mode() == Qgs3DAxisSettings::Mode::Cube ) typeCubeAct->setChecked( true ); } ); @@ -577,9 +562,9 @@ void Qgs3DAxis::createMenu() typeGroup->addAction( typeCrsAct ); typeGroup->addAction( typeCubeAct ); - connect( typeOffAct, &QAction::triggered, this, [this]( bool ) {onAxisModeChanged( Qgs3DAxisSettings::Mode::Off );} ); - connect( typeCrsAct, &QAction::triggered, this, [this]( bool ) {onAxisModeChanged( Qgs3DAxisSettings::Mode::Crs );} ); - connect( typeCubeAct, &QAction::triggered, this, [this]( bool ) {onAxisModeChanged( Qgs3DAxisSettings::Mode::Cube );} ); + connect( typeOffAct, &QAction::triggered, this, [this]( bool ) { onAxisModeChanged( Qgs3DAxisSettings::Mode::Off ); } ); + connect( typeCrsAct, &QAction::triggered, this, [this]( bool ) { onAxisModeChanged( Qgs3DAxisSettings::Mode::Crs ); } ); + connect( typeCubeAct, &QAction::triggered, this, [this]( bool ) { onAxisModeChanged( Qgs3DAxisSettings::Mode::Cube ); } ); QMenu *typeMenu = new QMenu( QStringLiteral( "Axis Type" ), mMenu ); Q_ASSERT( typeMenu ); @@ -591,24 +576,21 @@ void Qgs3DAxis::createMenu() // horizontal position menu QAction *hPosLeftAct = new QAction( tr( "&Left" ), mMenu ); hPosLeftAct->setCheckable( true ); - connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [hPosLeftAct, this]() - { + connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [hPosLeftAct, this]() { if ( mMapSettings->get3DAxisSettings().horizontalPosition() == Qt::AnchorPoint::AnchorLeft ) hPosLeftAct->setChecked( true ); } ); QAction *hPosMiddleAct = new QAction( tr( "&Center" ), mMenu ); hPosMiddleAct->setCheckable( true ); - connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [hPosMiddleAct, this]() - { + connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [hPosMiddleAct, this]() { if ( mMapSettings->get3DAxisSettings().horizontalPosition() == Qt::AnchorPoint::AnchorHorizontalCenter ) hPosMiddleAct->setChecked( true ); } ); QAction *hPosRightAct = new QAction( tr( "&Right" ), mMenu ); hPosRightAct->setCheckable( true ); - connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [hPosRightAct, this]() - { + connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [hPosRightAct, this]() { if ( mMapSettings->get3DAxisSettings().horizontalPosition() == Qt::AnchorPoint::AnchorRight ) hPosRightAct->setChecked( true ); } ); @@ -618,9 +600,9 @@ void Qgs3DAxis::createMenu() hPosGroup->addAction( hPosMiddleAct ); hPosGroup->addAction( hPosRightAct ); - connect( hPosLeftAct, &QAction::triggered, this, [this]( bool ) {onAxisHorizPositionChanged( Qt::AnchorPoint::AnchorLeft );} ); - connect( hPosMiddleAct, &QAction::triggered, this, [this]( bool ) {onAxisHorizPositionChanged( Qt::AnchorPoint::AnchorHorizontalCenter );} ); - connect( hPosRightAct, &QAction::triggered, this, [this]( bool ) {onAxisHorizPositionChanged( Qt::AnchorPoint::AnchorRight );} ); + connect( hPosLeftAct, &QAction::triggered, this, [this]( bool ) { onAxisHorizPositionChanged( Qt::AnchorPoint::AnchorLeft ); } ); + connect( hPosMiddleAct, &QAction::triggered, this, [this]( bool ) { onAxisHorizPositionChanged( Qt::AnchorPoint::AnchorHorizontalCenter ); } ); + connect( hPosRightAct, &QAction::triggered, this, [this]( bool ) { onAxisHorizPositionChanged( Qt::AnchorPoint::AnchorRight ); } ); QMenu *horizPosMenu = new QMenu( QStringLiteral( "Horizontal Position" ), mMenu ); horizPosMenu->addAction( hPosLeftAct ); @@ -631,24 +613,21 @@ void Qgs3DAxis::createMenu() // vertical position menu QAction *vPosTopAct = new QAction( tr( "&Top" ), mMenu ); vPosTopAct->setCheckable( true ); - connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [vPosTopAct, this]() - { + connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [vPosTopAct, this]() { if ( mMapSettings->get3DAxisSettings().verticalPosition() == Qt::AnchorPoint::AnchorTop ) vPosTopAct->setChecked( true ); } ); QAction *vPosMiddleAct = new QAction( tr( "&Middle" ), mMenu ); vPosMiddleAct->setCheckable( true ); - connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [vPosMiddleAct, this]() - { + connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [vPosMiddleAct, this]() { if ( mMapSettings->get3DAxisSettings().verticalPosition() == Qt::AnchorPoint::AnchorVerticalCenter ) vPosMiddleAct->setChecked( true ); } ); QAction *vPosBottomAct = new QAction( tr( "&Bottom" ), mMenu ); vPosBottomAct->setCheckable( true ); - connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [vPosBottomAct, this]() - { + connect( mMapSettings, &Qgs3DMapSettings::axisSettingsChanged, this, [vPosBottomAct, this]() { if ( mMapSettings->get3DAxisSettings().verticalPosition() == Qt::AnchorPoint::AnchorBottom ) vPosBottomAct->setChecked( true ); } ); @@ -658,9 +637,9 @@ void Qgs3DAxis::createMenu() vPosGroup->addAction( vPosMiddleAct ); vPosGroup->addAction( vPosBottomAct ); - connect( vPosTopAct, &QAction::triggered, this, [this]( bool ) {onAxisVertPositionChanged( Qt::AnchorPoint::AnchorTop );} ); - connect( vPosMiddleAct, &QAction::triggered, this, [this]( bool ) {onAxisVertPositionChanged( Qt::AnchorPoint::AnchorVerticalCenter );} ); - connect( vPosBottomAct, &QAction::triggered, this, [this]( bool ) {onAxisVertPositionChanged( Qt::AnchorPoint::AnchorBottom );} ); + connect( vPosTopAct, &QAction::triggered, this, [this]( bool ) { onAxisVertPositionChanged( Qt::AnchorPoint::AnchorTop ); } ); + connect( vPosMiddleAct, &QAction::triggered, this, [this]( bool ) { onAxisVertPositionChanged( Qt::AnchorPoint::AnchorVerticalCenter ); } ); + connect( vPosBottomAct, &QAction::triggered, this, [this]( bool ) { onAxisVertPositionChanged( Qt::AnchorPoint::AnchorBottom ); } ); QMenu *vertPosMenu = new QMenu( QStringLiteral( "Vertical Position" ), mMenu ); vertPosMenu->addAction( vPosTopAct ); @@ -758,12 +737,11 @@ void Qgs3DAxis::onCameraViewChange( float pitch, float yaw ) } pos.set( pos.x(), pos.y(), elevation + mMapSettings->terrainElevationOffset() ); - mCameraController->setLookingAtPoint( pos, ( mCameraController->camera()->position() - pos.toVector3D() ).length(), - pitch, yaw ); + mCameraController->setLookingAtPoint( pos, ( mCameraController->camera()->position() - pos.toVector3D() ).length(), pitch, yaw ); } -void Qgs3DAxis::createCube( ) +void Qgs3DAxis::createCube() { QVector3D minPos = QVector3D( -mCylinderLength * 0.5f, -mCylinderLength * 0.5f, -mCylinderLength * 0.5f ); @@ -771,8 +749,7 @@ void Qgs3DAxis::createCube( ) Qt3DCore::QEntity *cubeLineEntity = new Qt3DCore::QEntity( mCubeRoot ); cubeLineEntity->setObjectName( "3DAxis_cubeline" ); Qgs3DWiredMesh *cubeLine = new Qgs3DWiredMesh; - QgsAABB box = QgsAABB( -mCylinderLength * 0.5f, -mCylinderLength * 0.5f, -mCylinderLength * 0.5f, - mCylinderLength * 0.5f, mCylinderLength * 0.5f, mCylinderLength * 0.5f ); + QgsAABB box = QgsAABB( -mCylinderLength * 0.5f, -mCylinderLength * 0.5f, -mCylinderLength * 0.5f, mCylinderLength * 0.5f, mCylinderLength * 0.5f, mCylinderLength * 0.5f ); cubeLine->setVertices( box.verticesForLines() ); cubeLineEntity->addComponent( cubeLine ); @@ -810,10 +787,7 @@ void Qgs3DAxis::createCube( ) { text = QStringLiteral( "top" ); textWidth = static_cast( text.length() * fontSize ) * 0.75f; - QVector3D translation = minPos + QVector3D( - mCylinderLength * 0.5f - textWidth / 2.0f, - mCylinderLength * 0.5f - textHeight / 2.0f, - mCylinderLength * 1.01f ); + QVector3D translation = minPos + QVector3D( mCylinderLength * 0.5f - textWidth / 2.0f, mCylinderLength * 0.5f - textHeight / 2.0f, mCylinderLength * 1.01f ); QMatrix4x4 rotation; mCubeLabels << addCubeText( text, textHeight, textWidth, font, rotation, translation ); } @@ -821,10 +795,7 @@ void Qgs3DAxis::createCube( ) { text = QStringLiteral( "btm" ); textWidth = static_cast( text.length() * fontSize ) * 0.75f; - QVector3D translation = minPos + QVector3D( - mCylinderLength * 0.5f - textWidth / 2.0f, - mCylinderLength * 0.5f + textHeight / 2.0f, - -mCylinderLength * 0.01f ); + QVector3D translation = minPos + QVector3D( mCylinderLength * 0.5f - textWidth / 2.0f, mCylinderLength * 0.5f + textHeight / 2.0f, -mCylinderLength * 0.01f ); QMatrix4x4 rotation; rotation.rotate( 180.0f, QVector3D( 1.0f, 0.0f, 0.0f ).normalized() ); mCubeLabels << addCubeText( text, textHeight, textWidth, font, rotation, translation ); @@ -833,10 +804,7 @@ void Qgs3DAxis::createCube( ) { text = QStringLiteral( "west" ); textWidth = static_cast( text.length() * fontSize ) * 0.75f; - QVector3D translation = minPos + QVector3D( - - mCylinderLength * 0.01f, - mCylinderLength * 0.5f + textWidth / 2.0f, - mCylinderLength * 0.5f - textHeight / 2.0f ); + QVector3D translation = minPos + QVector3D( -mCylinderLength * 0.01f, mCylinderLength * 0.5f + textWidth / 2.0f, mCylinderLength * 0.5f - textHeight / 2.0f ); QMatrix4x4 rotation; rotation.rotate( 90.0f, QVector3D( 0.0f, -1.0f, 0.0f ).normalized() ); rotation.rotate( 90.0f, QVector3D( 0.0f, 0.0f, -1.0f ).normalized() ); @@ -846,10 +814,7 @@ void Qgs3DAxis::createCube( ) { text = QStringLiteral( "east" ); textWidth = static_cast( text.length() * fontSize ) * 0.75f; - QVector3D translation = minPos + QVector3D( - mCylinderLength * 1.01f, - mCylinderLength * 0.5f - textWidth / 2.0f, - mCylinderLength * 0.5f - textHeight / 2.0f ); + QVector3D translation = minPos + QVector3D( mCylinderLength * 1.01f, mCylinderLength * 0.5f - textWidth / 2.0f, mCylinderLength * 0.5f - textHeight / 2.0f ); QMatrix4x4 rotation; rotation.rotate( 90.0f, QVector3D( 0.0f, 1.0f, 0.0f ).normalized() ); rotation.rotate( 90.0f, QVector3D( 0.0f, 0.0f, 1.0f ).normalized() ); @@ -859,10 +824,7 @@ void Qgs3DAxis::createCube( ) { text = QStringLiteral( "south" ); textWidth = static_cast( text.length() * fontSize ) * 0.75f; - QVector3D translation = minPos + QVector3D( - mCylinderLength * 0.5f - textWidth / 2.0f, - - mCylinderLength * 0.01f, - mCylinderLength * 0.5f - textHeight / 2.0f ); + QVector3D translation = minPos + QVector3D( mCylinderLength * 0.5f - textWidth / 2.0f, -mCylinderLength * 0.01f, mCylinderLength * 0.5f - textHeight / 2.0f ); QMatrix4x4 rotation; rotation.rotate( 90.0f, QVector3D( 1.0f, 0.0f, 0.0f ).normalized() ); mCubeLabels << addCubeText( text, textHeight, textWidth, font, rotation, translation ); @@ -871,10 +833,7 @@ void Qgs3DAxis::createCube( ) { text = QStringLiteral( "north" ); textWidth = static_cast( text.length() * fontSize ) * 0.75f; - QVector3D translation = minPos + QVector3D( - mCylinderLength * 0.5f + textWidth / 2.0f, - mCylinderLength * 1.01f, - mCylinderLength * 0.5f - textHeight / 2.0f ); + QVector3D translation = minPos + QVector3D( mCylinderLength * 0.5f + textWidth / 2.0f, mCylinderLength * 1.01f, mCylinderLength * 0.5f - textHeight / 2.0f ); QMatrix4x4 rotation; rotation.rotate( 90.0f, QVector3D( -1.0f, 0.0f, 0.0f ).normalized() ); rotation.rotate( 180.0f, QVector3D( 0.0f, 0.0f, 1.0f ).normalized() ); @@ -921,10 +880,9 @@ void Qgs3DAxis::createAxis( Qt::Axis axisType ) switch ( axisType ) { case Qt::Axis::XAxis: - mTextX = new Qt3DExtras::QText2DEntity( ); // object initialization in two step: + mTextX = new Qt3DExtras::QText2DEntity(); // object initialization in two step: mTextX->setParent( mTwoDLabelSceneEntity ); // see https://bugreports.qt.io/browse/QTBUG-77139 - connect( mTextX, &Qt3DExtras::QText2DEntity::textChanged, this, [this]( const QString & text ) - { + connect( mTextX, &Qt3DExtras::QText2DEntity::textChanged, this, [this]( const QString &text ) { updateAxisLabelText( mTextX, text ); } ); mTextTransformX = new Qt3DCore::QTransform(); @@ -938,10 +896,9 @@ void Qgs3DAxis::createAxis( Qt::Axis axisType ) break; case Qt::Axis::YAxis: - mTextY = new Qt3DExtras::QText2DEntity( ); // object initialization in two step: + mTextY = new Qt3DExtras::QText2DEntity(); // object initialization in two step: mTextY->setParent( mTwoDLabelSceneEntity ); // see https://bugreports.qt.io/browse/QTBUG-77139 - connect( mTextY, &Qt3DExtras::QText2DEntity::textChanged, this, [this]( const QString & text ) - { + connect( mTextY, &Qt3DExtras::QText2DEntity::textChanged, this, [this]( const QString &text ) { updateAxisLabelText( mTextY, text ); } ); mTextTransformY = new Qt3DCore::QTransform(); @@ -956,10 +913,9 @@ void Qgs3DAxis::createAxis( Qt::Axis axisType ) break; case Qt::Axis::ZAxis: - mTextZ = new Qt3DExtras::QText2DEntity( ); // object initialization in two step: + mTextZ = new Qt3DExtras::QText2DEntity(); // object initialization in two step: mTextZ->setParent( mTwoDLabelSceneEntity ); // see https://bugreports.qt.io/browse/QTBUG-77139 - connect( mTextZ, &Qt3DExtras::QText2DEntity::textChanged, this, [this]( const QString & text ) - { + connect( mTextZ, &Qt3DExtras::QText2DEntity::textChanged, this, [this]( const QString &text ) { updateAxisLabelText( mTextZ, text ); } ); mTextTransformZ = new Qt3DCore::QTransform(); @@ -1037,41 +993,29 @@ void Qgs3DAxis::onAxisViewportSizeUpdate( int ) { Qgs3DAxisSettings settings = mMapSettings->get3DAxisSettings(); - double windowWidth = ( double )mCanvas->width(); - double windowHeight = ( double )mCanvas->height(); + double windowWidth = ( double ) mCanvas->width(); + double windowHeight = ( double ) mCanvas->height(); QgsMapSettings set; if ( 2 <= QgsLogger::debugLevel() ) { - QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate window w/h: %1px / %2px" ) - .arg( windowWidth ).arg( windowHeight ), 2 ); - QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate window physicalDpi %1 (%2, %3)" ) - .arg( mCanvas->screen()->physicalDotsPerInch() ) - .arg( mCanvas->screen()->physicalDotsPerInchX() ) - .arg( mCanvas->screen()->physicalDotsPerInchY() ), 2 ); - QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate window logicalDotsPerInch %1 (%2, %3)" ) - .arg( mCanvas->screen()->logicalDotsPerInch() ) - .arg( mCanvas->screen()->logicalDotsPerInchX() ) - .arg( mCanvas->screen()->logicalDotsPerInchY() ), 2 ); + QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate window w/h: %1px / %2px" ).arg( windowWidth ).arg( windowHeight ), 2 ); + QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate window physicalDpi %1 (%2, %3)" ).arg( mCanvas->screen()->physicalDotsPerInch() ).arg( mCanvas->screen()->physicalDotsPerInchX() ).arg( mCanvas->screen()->physicalDotsPerInchY() ), 2 ); + QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate window logicalDotsPerInch %1 (%2, %3)" ).arg( mCanvas->screen()->logicalDotsPerInch() ).arg( mCanvas->screen()->logicalDotsPerInchX() ).arg( mCanvas->screen()->logicalDotsPerInchY() ), 2 ); - QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate window pixel ratio %1" ) - .arg( mCanvas->screen()->devicePixelRatio() ), 2 ); + QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate window pixel ratio %1" ).arg( mCanvas->screen()->devicePixelRatio() ), 2 ); - QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate set pixel ratio %1" ) - .arg( set.devicePixelRatio() ), 2 ); - QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate set outputDpi %1" ) - .arg( set.outputDpi() ), 2 ); - QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate set dpiTarget %1" ) - .arg( set.dpiTarget() ), 2 ); + QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate set pixel ratio %1" ).arg( set.devicePixelRatio() ), 2 ); + QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate set outputDpi %1" ).arg( set.outputDpi() ), 2 ); + QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate set dpiTarget %1" ).arg( set.dpiTarget() ), 2 ); } // default viewport size in pixel according to 92 dpi - double defaultViewportPixelSize = ( ( double )settings.defaultViewportSize() / 25.4 ) * 92.0; + double defaultViewportPixelSize = ( ( double ) settings.defaultViewportSize() / 25.4 ) * 92.0; // computes the viewport size according to screen dpi but as the viewport size growths too fast // then we limit the growth by using a factor on the dpi difference. - double viewportPixelSize = defaultViewportPixelSize + ( ( double )settings.defaultViewportSize() / 25.4 ) - * ( mCanvas->screen()->physicalDotsPerInch() - 92.0 ) * 0.7; + double viewportPixelSize = defaultViewportPixelSize + ( ( double ) settings.defaultViewportSize() / 25.4 ) * ( mCanvas->screen()->physicalDotsPerInch() - 92.0 ) * 0.7; QgsDebugMsgLevel( QString( "onAxisViewportSizeUpdate viewportPixelSize %1" ).arg( viewportPixelSize ), 2 ); double widthRatio = viewportPixelSize / windowWidth; double heightRatio = widthRatio * windowWidth / windowHeight; @@ -1099,7 +1043,7 @@ void Qgs3DAxis::onAxisViewportSizeUpdate( int ) mAxisScaleFactor = viewportPixelSize / defaultViewportPixelSize; QgsDebugMsgLevel( QString( "3DAxis viewport mAxisScaleFactor %1" ).arg( mAxisScaleFactor ), 2 ); - if ( ! mViewport->isEnabled() ) + if ( !mViewport->isEnabled() ) { if ( settings.mode() == Qgs3DAxisSettings::Mode::Crs ) setEnableAxis( true ); @@ -1134,14 +1078,15 @@ void Qgs3DAxis::onAxisViewportSizeUpdate( int ) mTwoDLabelCamera->lens()->setOrthographicProjection( -halfWidthSize, halfWidthSize, -halfHeightSize, halfHeightSize, - mTwoDLabelCamera->lens()->nearPlane(), mTwoDLabelCamera->lens()->farPlane() ); + mTwoDLabelCamera->lens()->nearPlane(), mTwoDLabelCamera->lens()->farPlane() + ); updateAxisLabelPosition(); } } } -void Qgs3DAxis::onCameraUpdate( ) +void Qgs3DAxis::onCameraUpdate() { Qt3DRender::QCamera *parentCamera = mCameraController->camera(); diff --git a/src/3d/qgs3daxis.h b/src/3d/qgs3daxis.h index 255eb79700a..a4f26f845d5 100644 --- a/src/3d/qgs3daxis.h +++ b/src/3d/qgs3daxis.h @@ -55,7 +55,6 @@ class _3D_EXPORT Qgs3DAxis : public QObject { Q_OBJECT public: - /** * Default Qgs3DAxis constructor. * @@ -65,8 +64,7 @@ class _3D_EXPORT Qgs3DAxis : public QObject * \param camera camera controller used to track camera movements * \param map 3D map settings */ - Qgs3DAxis( Qgs3DMapCanvas *canvas, Qt3DCore::QEntity *parent3DScene, - Qgs3DMapScene *mapScene, QgsCameraController *camera, Qgs3DMapSettings *map ); + Qgs3DAxis( Qgs3DMapCanvas *canvas, Qt3DCore::QEntity *parent3DScene, Qgs3DMapScene *mapScene, QgsCameraController *camera, Qgs3DMapSettings *map ); ~Qgs3DAxis() override; /** @@ -83,11 +81,11 @@ class _3D_EXPORT Qgs3DAxis : public QObject public slots: //! Force update of the axis and the viewport when a setting has changed - void onAxisSettingsChanged( ); + void onAxisSettingsChanged(); private slots: - void onCameraUpdate( ); + void onCameraUpdate(); void onAxisViewportSizeUpdate( int val = 0 ); // axis picking and menu @@ -107,10 +105,9 @@ class _3D_EXPORT Qgs3DAxis : public QObject void onCameraViewChangeBottom() { onCameraViewChange( 180.0f, 0.0f ); } private: - void createAxisScene(); void createAxis( Qt::Axis axis ); - void createCube( ); + void createCube(); void setEnableCube( bool show ); void setEnableAxis( bool show ); void updateAxisLabelPosition(); @@ -123,7 +120,7 @@ class _3D_EXPORT Qgs3DAxis : public QObject Qt3DExtras::QText2DEntity *addCubeText( const QString &text, float textHeight, float textWidth, const QFont &font, const QMatrix4x4 &rotation, const QVector3D &translation ); // axis picking and menu - void init3DObjectPicking( ); + void init3DObjectPicking(); bool eventFilter( QObject *watched, QEvent *event ) override; void createKeyboardShortCut(); void createMenu(); @@ -161,7 +158,7 @@ class _3D_EXPORT Qgs3DAxis : public QObject QVector3D mPreviousVector; double mAxisScaleFactor = 1.0; - Qt3DRender::QCamera *mTwoDLabelCamera = nullptr; + Qt3DRender::QCamera *mTwoDLabelCamera = nullptr; Qt3DCore::QEntity *mTwoDLabelSceneEntity = nullptr; // axis picking and menu @@ -173,7 +170,6 @@ class _3D_EXPORT Qgs3DAxis : public QObject QCursor mPreviousCursor = Qt::ArrowCursor; Qt3DRender::QPickingSettings::PickMethod mDefaultPickingMethod; QMenu *mMenu = nullptr; - }; #endif // QGS3DAXIS_H diff --git a/src/3d/qgs3daxissettings.cpp b/src/3d/qgs3daxissettings.cpp index c338d94bff7..3b9044cbb27 100644 --- a/src/3d/qgs3daxissettings.cpp +++ b/src/3d/qgs3daxissettings.cpp @@ -32,7 +32,7 @@ bool Qgs3DAxisSettings::operator==( Qgs3DAxisSettings const &rhs ) const bool Qgs3DAxisSettings::operator!=( Qgs3DAxisSettings const &rhs ) const { - return ! this->operator==( rhs ); + return !this->operator==( rhs ); } void Qgs3DAxisSettings::readXml( const QDomElement &element, const QgsReadWriteContext & ) @@ -132,7 +132,6 @@ void Qgs3DAxisSettings::writeXml( QDomElement &element, const QgsReadWriteContex break; } element.setAttribute( QStringLiteral( "vertical" ), str ); - } void Qgs3DAxisSettings::setMinViewportRatio( double ratio ) diff --git a/src/3d/qgs3daxissettings.h b/src/3d/qgs3daxissettings.h index e8bcfa8e0ed..ce1b8e7fe23 100644 --- a/src/3d/qgs3daxissettings.h +++ b/src/3d/qgs3daxissettings.h @@ -35,14 +35,13 @@ class QDomElement; class _3D_EXPORT Qgs3DAxisSettings { public: - /** * \brief Axis representation enum */ enum class Mode { - Off = 1, //!< Hide 3d axis - Crs = 2, //!< Respect CRS directions + Off = 1, //!< Hide 3d axis + Crs = 2, //!< Respect CRS directions Cube = 3, //!< Abstract cube mode }; @@ -57,17 +56,17 @@ class _3D_EXPORT Qgs3DAxisSettings void writeXml( QDomElement &element, const QgsReadWriteContext &context ) const; //! Returns the default axis viewport size in millimeters - int defaultViewportSize() const { return mDefaultViewportSize;} + int defaultViewportSize() const { return mDefaultViewportSize; } //! Sets the defaultl axis viewport size in millimeters void setDefaultViewportSize( int size ) { mDefaultViewportSize = size; } //! Returns the minimal axis viewport ratio (see Qt3DRender::QViewport::normalizedRect()) - double minViewportRatio() const { return mMinViewportRatio;} + double minViewportRatio() const { return mMinViewportRatio; } //! Sets the minimal axis viewport ratio between 0-1 void setMinViewportRatio( double ratio ); //! Returns the maximal axis viewport ratio (see Qt3DRender::QViewport::normalizedRect()) - double maxViewportRatio() const { return mMaxViewportRatio;} + double maxViewportRatio() const { return mMaxViewportRatio; } //! Sets the maximal axis viewport ratio between 0-1 void setMaxViewportRatio( double ratio ); @@ -93,7 +92,6 @@ class _3D_EXPORT Qgs3DAxisSettings Qgs3DAxisSettings::Mode mMode = Qgs3DAxisSettings::Mode::Crs; Qt::AnchorPoint mHorizontalPosition = Qt::AnchorPoint::AnchorRight; Qt::AnchorPoint mVerticalPosition = Qt::AnchorPoint::AnchorTop; - }; #endif // QGS3DAXISSETTINGS_H diff --git a/src/3d/qgs3dexportobject.cpp b/src/3d/qgs3dexportobject.cpp index ea9c3aa5f2e..e31bb8661eb 100644 --- a/src/3d/qgs3dexportobject.cpp +++ b/src/3d/qgs3dexportobject.cpp @@ -20,7 +20,7 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include typedef Qt3DRender::QAttribute Qt3DQAttribute; @@ -41,7 +41,8 @@ void insertIndexData( QVector &vertexIndex, const QVector &faceIndex ) { for ( int i = 0; i < faceIndex.size(); i += 3 ) { - if ( i + 2 >= faceIndex.size() ) continue; + if ( i + 2 >= faceIndex.size() ) + continue; // skip invalid triangles if ( faceIndex[i] == faceIndex[i + 1] || faceIndex[i + 1] == faceIndex[i + 2] || faceIndex[i] == faceIndex[i + 2] ) continue; @@ -68,26 +69,27 @@ void Qgs3DExportObject::setupFaces( const QVector &facesIndexes ) void Qgs3DExportObject::setupLine( const QVector &lineIndexes ) { Q_UNUSED( lineIndexes ); - for ( int i = 0; i < mVertexPosition.size(); i += 3 ) mIndexes << i / 3 + 1; + for ( int i = 0; i < mVertexPosition.size(); i += 3 ) + mIndexes << i / 3 + 1; } void Qgs3DExportObject::setupNormalCoordinates( const QVector &normalsBuffer, const QMatrix4x4 &transform ) { // Qt does not provide QMatrix3x3 * QVector3D multiplication so we use QMatrix4x4 QMatrix3x3 normal3x3 = transform.normalMatrix(); - QMatrix4x4 normal4x4( normal3x3( 0, 0 ), normal3x3( 0, 1 ), normal3x3( 0, 2 ), 0, - normal3x3( 1, 0 ), normal3x3( 1, 1 ), normal3x3( 1, 2 ), 0, - normal3x3( 2, 0 ), normal3x3( 2, 1 ), normal3x3( 2, 2 ), 0, - 0, 0, 0, 1 ); + QMatrix4x4 normal4x4( normal3x3( 0, 0 ), normal3x3( 0, 1 ), normal3x3( 0, 2 ), 0, normal3x3( 1, 0 ), normal3x3( 1, 1 ), normal3x3( 1, 2 ), 0, normal3x3( 2, 0 ), normal3x3( 2, 1 ), normal3x3( 2, 2 ), 0, 0, 0, 0, 1 ); for ( int i = 0; i < normalsBuffer.size(); i += 3 ) { const QVector3D normalVector( normalsBuffer[i], normalsBuffer[i + 1], normalsBuffer[i + 2] ); QVector3D v = normal4x4.mapVector( normalVector ); // round numbers very close to zero to avoid tiny numbers like 6e-8 in export - if ( qgsFloatNear( v.x(), 0 ) ) v.setX( 0 ); - if ( qgsFloatNear( v.y(), 0 ) ) v.setY( 0 ); - if ( qgsFloatNear( v.z(), 0 ) ) v.setZ( 0 ); + if ( qgsFloatNear( v.x(), 0 ) ) + v.setX( 0 ); + if ( qgsFloatNear( v.y(), 0 ) ) + v.setY( 0 ); + if ( qgsFloatNear( v.z(), 0 ) ) + v.setZ( 0 ); mNormals << v.x() << v.y() << v.z(); } } @@ -108,7 +110,8 @@ void Qgs3DExportObject::setupMaterial( QgsAbstractMaterialSettings *material ) void Qgs3DExportObject::objectBounds( float &minX, float &minY, float &minZ, float &maxX, float &maxY, float &maxZ ) { - if ( mType != TriangularFaces ) return; + if ( mType != TriangularFaces ) + return; for ( const unsigned int vertice : qAsConst( mIndexes ) ) { const int heightIndex = static_cast( vertice ) * 3 + 1; @@ -168,8 +171,7 @@ void Qgs3DExportObject::saveTo( QTextStream &out, float scale, const QVector3D & // we use negative indexes as this is the way to use relative values to reference vertex positions // Positive values are absolute vertex position from the beginning of the file. - auto getVertexIndex = [&]( unsigned int i ) -> QString - { + auto getVertexIndex = [&]( unsigned int i ) -> QString { const int negativeIndex = static_cast( i - verticesCount ); if ( hasNormals && !hasTextures ) return QStringLiteral( "%1//%2" ).arg( negativeIndex ).arg( negativeIndex ); @@ -212,7 +214,8 @@ void Qgs3DExportObject::saveTo( QTextStream &out, float scale, const QVector3D & QString Qgs3DExportObject::saveMaterial( QTextStream &mtlOut, const QString &folderPath ) { QString materialName = mName + "_material"; - if ( mMaterialParameters.size() == 0 && ( mTexturesUV.size() == 0 || mTextureImage.isNull() ) ) return QString(); + if ( mMaterialParameters.size() == 0 && ( mTexturesUV.size() == 0 || mTextureImage.isNull() ) ) + return QString(); mtlOut << "newmtl " << materialName << "\n"; if ( mTexturesUV.size() != 0 && !mTextureImage.isNull() ) { diff --git a/src/3d/qgs3dexportobject.h b/src/3d/qgs3dexportobject.h index 925f381489e..64f1779c698 100644 --- a/src/3d/qgs3dexportobject.h +++ b/src/3d/qgs3dexportobject.h @@ -53,7 +53,8 @@ class _3D_EXPORT Qgs3DExportObject * Constructs an export object that will be filled with coordinates later * \param name The name of the parent (Will be useful to define scene hierarchy) */ - Qgs3DExportObject( const QString &name ) : mName( name ) { } + Qgs3DExportObject( const QString &name ) + : mName( name ) {} //! Returns the object name QString name() const { return mName; } @@ -108,10 +109,10 @@ class _3D_EXPORT Qgs3DExportObject QVector vertexPosition() const { return mVertexPosition; } //! Returns the vertex normal coordinates - QVector normals() const { return mNormals;} + QVector normals() const { return mNormals; } //! Returns the vertex texture coordinates - QVector texturesUV() const { return mTexturesUV;} + QVector texturesUV() const { return mTexturesUV; } //! Returns the vertex indexes QVector indexes() const { return mIndexes; } diff --git a/src/3d/qgs3dmapcanvas.cpp b/src/3d/qgs3dmapcanvas.cpp index f69a00cbe2a..8a68e7d7cd2 100644 --- a/src/3d/qgs3dmapcanvas.cpp +++ b/src/3d/qgs3dmapcanvas.cpp @@ -15,7 +15,7 @@ #include #include -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) #include #endif #include @@ -51,7 +51,7 @@ Qgs3DMapCanvas::Qgs3DMapCanvas() setSurfaceType( QSurface::OpenGLSurface ); // register aspects -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) m_aspectEngine->registerAspect( new Qt3DCore::QCoreAspect ); #endif m_aspectEngine->registerAspect( m_renderAspect ); @@ -64,8 +64,7 @@ Qgs3DMapCanvas::Qgs3DMapCanvas() const QgsSettings setting; mEngine = new QgsWindow3DEngine( this ); - connect( mEngine, &QgsAbstract3DEngine::imageCaptured, this, [ = ]( const QImage & image ) - { + connect( mEngine, &QgsAbstract3DEngine::imageCaptured, this, [=]( const QImage &image ) { image.save( mCaptureFileName, mCaptureFileFormat.toLocal8Bit().data() ); mEngine->setRenderCaptureEnabled( false ); emit savedAsImage( mCaptureFileName ); @@ -166,8 +165,7 @@ void Qgs3DMapCanvas::setMapSettings( Qgs3DMapSettings *mapSettings ) resetView(); - connect( cameraController(), &QgsCameraController::setCursorPosition, this, [ = ]( QPoint point ) - { + connect( cameraController(), &QgsCameraController::setCursorPosition, this, [=]( QPoint point ) { QCursor::setPos( mapToGlobal( point ) ); } ); connect( cameraController(), &QgsCameraController::cameraMovementSpeedChanged, mMapSettings, &Qgs3DMapSettings::setCameraMovementSpeed ); @@ -215,8 +213,7 @@ void Qgs3DMapCanvas::saveAsImage( const QString &fileName, const QString &fileFo Qt3DLogic::QFrameAction *screenCaptureFrameAction = new Qt3DLogic::QFrameAction; mScene->addComponent( screenCaptureFrameAction ); // Wait to have the render capture enabled in the next frame - connect( screenCaptureFrameAction, &Qt3DLogic::QFrameAction::triggered, this, [ = ]( float ) - { + connect( screenCaptureFrameAction, &Qt3DLogic::QFrameAction::triggered, this, [=]( float ) { mEngine->requestCaptureImage(); mScene->removeComponent( screenCaptureFrameAction ); screenCaptureFrameAction->deleteLater(); @@ -232,8 +229,7 @@ void Qgs3DMapCanvas::captureDepthBuffer() Qt3DLogic::QFrameAction *screenCaptureFrameAction = new Qt3DLogic::QFrameAction; mScene->addComponent( screenCaptureFrameAction ); // Wait to have the render capture enabled in the next frame - connect( screenCaptureFrameAction, &Qt3DLogic::QFrameAction::triggered, this, [ = ]( float ) - { + connect( screenCaptureFrameAction, &Qt3DLogic::QFrameAction::triggered, this, [=]( float ) { mEngine->requestDepthBufferCapture(); mScene->removeComponent( screenCaptureFrameAction ); screenCaptureFrameAction->deleteLater(); @@ -269,7 +265,6 @@ void Qgs3DMapCanvas::setMapTool( Qgs3DMapTool *tool ) mMapTool->activate(); setCursor( mMapTool->cursor() ); } - } bool Qgs3DMapCanvas::eventFilter( QObject *watched, QEvent *event ) @@ -282,7 +277,7 @@ bool Qgs3DMapCanvas::eventFilter( QObject *watched, QEvent *event ) // if the camera controller will handle a key event, don't allow it to propagate // outside of the 3d window or it may be grabbed by a parent window level shortcut // and accordingly never be received by the camera controller - if ( cameraController() && cameraController()->willHandleKeyEvent( static_cast< QKeyEvent * >( event ) ) ) + if ( cameraController() && cameraController()->willHandleKeyEvent( static_cast( event ) ) ) { event->accept(); return true; diff --git a/src/3d/qgs3dmapcanvas.h b/src/3d/qgs3dmapcanvas.h index a13eed59db7..be9920a3380 100644 --- a/src/3d/qgs3dmapcanvas.h +++ b/src/3d/qgs3dmapcanvas.h @@ -29,7 +29,7 @@ namespace Qt3DCore class QAspectEngine; class QAbstractAspect; class QEntity; -} +} // namespace Qt3DCore namespace Qt3DRender { @@ -37,7 +37,7 @@ namespace Qt3DRender class QFrameGraphNode; class QRenderAspect; class QRenderSettings; -} +} // namespace Qt3DRender namespace Qt3DExtras { @@ -48,7 +48,7 @@ namespace Qt3DInput { class QInputAspect; class QInputSettings; -} +} // namespace Qt3DInput namespace Qt3DLogic { @@ -80,7 +80,6 @@ class _3D_EXPORT Qgs3DMapCanvas : public QWindow { Q_OBJECT public: - Qgs3DMapCanvas(); ~Qgs3DMapCanvas(); @@ -191,7 +190,6 @@ class _3D_EXPORT Qgs3DMapCanvas : public QWindow void onNavigationModeChanged( Qgis::NavigationMode mode ); protected: - /** * Manages the display events specified in e. */ @@ -205,7 +203,6 @@ class _3D_EXPORT Qgs3DMapCanvas : public QWindow bool eventFilter( QObject *watched, QEvent *event ) override; private: - Qt3DCore::QAspectEngine *m_aspectEngine; // Aspects diff --git a/src/3d/qgs3dmapscene.cpp b/src/3d/qgs3dmapscene.cpp index e6405ebeee8..0b186e88289 100644 --- a/src/3d/qgs3dmapscene.cpp +++ b/src/3d/qgs3dmapscene.cpp @@ -83,13 +83,12 @@ #include "qgswindow3dengine.h" #include "qgspointcloudlayer.h" -std::function< QMap< QString, Qgs3DMapScene * >() > Qgs3DMapScene::sOpenScenesFunction = [] { return QMap< QString, Qgs3DMapScene * >(); }; +std::function()> Qgs3DMapScene::sOpenScenesFunction = [] { return QMap(); }; Qgs3DMapScene::Qgs3DMapScene( Qgs3DMapSettings &map, QgsAbstract3DEngine *engine ) : mMap( map ) , mEngine( engine ) { - connect( &map, &Qgs3DMapSettings::backgroundColorChanged, this, &Qgs3DMapScene::onBackgroundColorChanged ); onBackgroundColorChanged(); @@ -104,12 +103,11 @@ Qgs3DMapScene::Qgs3DMapScene( Qgs3DMapSettings &map, QgsAbstract3DEngine *engine mMaxClipPlanes = Qgs3DUtils::openGlMaxClipPlanes( mEngine->surface() ); // Camera - float aspectRatio = ( float )viewportRect.width() / viewportRect.height(); + float aspectRatio = ( float ) viewportRect.width() / viewportRect.height(); mEngine->camera()->lens()->setPerspectiveProjection( mMap.fieldOfView(), aspectRatio, 10.f, 10000.0f ); mFrameAction = new Qt3DLogic::QFrameAction(); - connect( mFrameAction, &Qt3DLogic::QFrameAction::triggered, - this, &Qgs3DMapScene::onFrameTriggered ); + connect( mFrameAction, &Qt3DLogic::QFrameAction::triggered, this, &Qgs3DMapScene::onFrameTriggered ); addComponent( mFrameAction ); // takes ownership // Camera controlling @@ -152,8 +150,7 @@ Qgs3DMapScene::Qgs3DMapScene( Qgs3DMapSettings &map, QgsAbstract3DEngine *engine connect( &map, &Qgs3DMapSettings::originChanged, this, &Qgs3DMapScene::onOriginChanged ); - connect( QgsApplication::sourceCache(), &QgsSourceCache::remoteSourceFetched, this, [ = ]( const QString & url ) - { + connect( QgsApplication::sourceCache(), &QgsSourceCache::remoteSourceFetched, this, [=]( const QString &url ) { const QList modelVectorLayers = mModelVectorLayers; for ( QgsMapLayer *layer : modelVectorLayers ) { @@ -162,7 +159,7 @@ Qgs3DMapScene::Qgs3DMapScene( Qgs3DMapSettings &map, QgsAbstract3DEngine *engine { if ( renderer->type() == QLatin1String( "vector" ) ) { - const QgsPoint3DSymbol *pointSymbol = static_cast< const QgsPoint3DSymbol * >( static_cast< QgsVectorLayer3DRenderer *>( renderer )->symbol() ); + const QgsPoint3DSymbol *pointSymbol = static_cast( static_cast( renderer )->symbol() ); if ( pointSymbol->shapeProperty( QStringLiteral( "model" ) ).toString() == url ) { removeLayerEntity( layer ); @@ -171,10 +168,10 @@ Qgs3DMapScene::Qgs3DMapScene( Qgs3DMapSettings &map, QgsAbstract3DEngine *engine } else if ( renderer->type() == QLatin1String( "rulebased" ) ) { - const QgsRuleBased3DRenderer::RuleList rules = static_cast< QgsRuleBased3DRenderer *>( renderer )->rootRule()->descendants(); + const QgsRuleBased3DRenderer::RuleList rules = static_cast( renderer )->rootRule()->descendants(); for ( auto rule : rules ) { - const QgsPoint3DSymbol *pointSymbol = dynamic_cast< const QgsPoint3DSymbol * >( rule->symbol() ); + const QgsPoint3DSymbol *pointSymbol = dynamic_cast( rule->symbol() ); if ( pointSymbol->shapeProperty( QStringLiteral( "model" ) ).toString() == url ) { removeLayerEntity( layer ); @@ -217,8 +214,8 @@ void Qgs3DMapScene::viewZoomFull() const QgsRectangle extent = sceneExtent(); const double side = std::max( extent.width(), extent.height() ); double d = side / 2 / std::tan( cameraController()->camera()->fieldOfView() / 2 * M_PI / 180 ); - d += yRange.isInfinite() ? 0. : yRange.upper(); - mCameraController->resetView( static_cast< float >( d ) ); + d += yRange.isInfinite() ? 0. : yRange.upper(); + mCameraController->resetView( static_cast( d ) ); return; } @@ -257,7 +254,7 @@ QVector Qgs3DMapScene::viewFrustum2DExtent() const QVector3D dir = ray.direction(); if ( dir.z() == 0.0 ) dir.setZ( 0.000001 ); - double t = - ray.origin().z() / dir.z(); + double t = -ray.origin().z() / dir.z(); if ( t < 0 ) { // If the projected point is on the back of the camera we choose the farthest point in the front @@ -308,7 +305,7 @@ void Qgs3DMapScene::onCameraChanged() { QRect viewportRect( QPoint( 0, 0 ), mEngine->size() ); const float viewWidthFromCenter = mCameraController->distance(); - const float viewHeightFromCenter = viewportRect.height() * viewWidthFromCenter / viewportRect.width(); + const float viewHeightFromCenter = viewportRect.height() * viewWidthFromCenter / viewportRect.width(); mEngine->camera()->lens()->setOrthographicProjection( -viewWidthFromCenter, viewWidthFromCenter, -viewHeightFromCenter, viewHeightFromCenter, mEngine->camera()->nearPlane(), mEngine->camera()->farPlane() ); } @@ -392,7 +389,7 @@ bool Qgs3DMapScene::updateCameraNearFarPlanes() } if ( fnear < 1 ) - fnear = 1; // does not really make sense to use negative far plane (behind camera) + fnear = 1; // does not really make sense to use negative far plane (behind camera) // the update didn't work out... this can happen if the scene does not contain // any Qgs3DMapSceneEntity. Use the scene extent to compute near and far planes @@ -443,7 +440,7 @@ void Qgs3DMapScene::onFrameTriggered( float dt ) accumulatedTime += dt; if ( accumulatedTime >= 0.2f ) { - float fps = ( float )frameCount / accumulatedTime; + float fps = ( float ) frameCount / accumulatedTime; frameCount = 0; accumulatedTime = 0.0f; emit fpsCountChanged( fps ); @@ -492,8 +489,7 @@ void Qgs3DMapScene::createTerrainDeferred() connect( mTerrain, &QgsChunkedEntity::pendingJobsCountChanged, this, &Qgs3DMapScene::totalPendingJobsCountChanged ); connect( mTerrain, &QgsTerrainEntity::pendingJobsCountChanged, this, &Qgs3DMapScene::terrainPendingJobsCountChanged ); - connect( mTerrain, &Qgs3DMapSceneEntity::newEntityCreated, this, [this]( Qt3DCore::QEntity * entity ) - { + connect( mTerrain, &Qgs3DMapSceneEntity::newEntityCreated, this, [this]( Qt3DCore::QEntity *entity ) { // let's make sure that any entity we're about to show has the right scene origin set const QList transforms = entity->findChildren(); for ( QgsGeoTransform *transform : transforms ) @@ -522,7 +518,7 @@ void Qgs3DMapScene::createTerrainDeferred() } emit terrainEntityChanged(); - onCameraChanged(); // force update of the new terrain + onCameraChanged(); // force update of the new terrain mTerrainUpdateScheduled = false; } @@ -537,7 +533,7 @@ void Qgs3DMapScene::updateLights() entity->deleteLater(); mLightEntities.clear(); - const QList< QgsLightSource * > newLights = mMap.lightSources(); + const QList newLights = mMap.lightSources(); for ( const QgsLightSource *source : newLights ) { mLightEntities.append( source->createEntity( mMap, this ) ); @@ -596,7 +592,7 @@ void Qgs3DMapScene::onLayersChanged() void Qgs3DMapScene::updateTemporal() { - const QList layers = mLayerEntities.keys(); + const QList layers = mLayerEntities.keys(); for ( QgsMapLayer *layer : layers ) { if ( QgsMapLayerTemporalProperties *temporalProperties = layer->temporalProperties() ) @@ -620,8 +616,7 @@ void Qgs3DMapScene::addLayerEntity( QgsMapLayer *layer ) // It has happened before that renderer pointed to a different layer (probably after copying a style). // This is a bit of a hack and it should be handled in QgsMapLayer::setRenderer3D() but in qgis_core // the vector layer 3D renderer classes are not available. - if ( layer->type() == Qgis::LayerType::Vector && - ( renderer->type() == QLatin1String( "vector" ) || renderer->type() == QLatin1String( "rulebased" ) ) ) + if ( layer->type() == Qgis::LayerType::Vector && ( renderer->type() == QLatin1String( "vector" ) || renderer->type() == QLatin1String( "rulebased" ) ) ) { static_cast( renderer )->setLayer( static_cast( layer ) ); if ( renderer->type() == QLatin1String( "vector" ) ) @@ -629,7 +624,7 @@ void Qgs3DMapScene::addLayerEntity( QgsMapLayer *layer ) QgsVectorLayer *vlayer = qobject_cast( layer ); if ( vlayer->geometryType() == Qgis::GeometryType::Point ) { - const QgsPoint3DSymbol *pointSymbol = static_cast< const QgsPoint3DSymbol * >( static_cast< QgsVectorLayer3DRenderer *>( renderer )->symbol() ); + const QgsPoint3DSymbol *pointSymbol = static_cast( static_cast( renderer )->symbol() ); if ( pointSymbol->shape() == Qgis::Point3DShape::Model ) { mModelVectorLayers.append( layer ); @@ -638,10 +633,10 @@ void Qgs3DMapScene::addLayerEntity( QgsMapLayer *layer ) } else if ( renderer->type() == QLatin1String( "rulebased" ) ) { - const QgsRuleBased3DRenderer::RuleList rules = static_cast< QgsRuleBased3DRenderer *>( renderer )->rootRule()->descendants(); + const QgsRuleBased3DRenderer::RuleList rules = static_cast( renderer )->rootRule()->descendants(); for ( auto rule : rules ) { - const QgsPoint3DSymbol *pointSymbol = dynamic_cast< const QgsPoint3DSymbol * >( rule->symbol() ); + const QgsPoint3DSymbol *pointSymbol = dynamic_cast( rule->symbol() ); if ( pointSymbol && pointSymbol->shape() == Qgis::Point3DShape::Model ) { mModelVectorLayers.append( layer ); @@ -685,8 +680,7 @@ void Qgs3DMapScene::addLayerEntity( QgsMapLayer *layer ) needsSceneUpdate = true; mSceneEntities.append( sceneNewEntity ); - connect( sceneNewEntity, &Qgs3DMapSceneEntity::newEntityCreated, this, [this]( Qt3DCore::QEntity * entity ) - { + connect( sceneNewEntity, &Qgs3DMapSceneEntity::newEntityCreated, this, [this]( Qt3DCore::QEntity *entity ) { finalizeNewEntity( entity ); // this ensures to update the near/far planes with the exact bounding box of the new entity. updateCameraNearFarPlanes(); @@ -698,7 +692,7 @@ void Qgs3DMapScene::addLayerEntity( QgsMapLayer *layer ) } if ( needsSceneUpdate ) - onCameraChanged(); // needed for chunked entities + onCameraChanged(); // needed for chunked entities connect( layer, &QgsMapLayer::request3DUpdate, this, &Qgs3DMapScene::onLayerRenderer3DChanged ); @@ -771,22 +765,20 @@ void Qgs3DMapScene::finalizeNewEntity( Qt3DCore::QEntity *newEntity ) // this is probably not the best place for material-specific configuration, // maybe this could be more generalized when other materials need some specific treatment - const QList< QgsLineMaterial *> childLineMaterials = newEntity->findChildren(); + const QList childLineMaterials = newEntity->findChildren(); for ( QgsLineMaterial *lm : childLineMaterials ) { - connect( mEngine, &QgsAbstract3DEngine::sizeChanged, lm, [lm, this] - { + connect( mEngine, &QgsAbstract3DEngine::sizeChanged, lm, [lm, this] { lm->setViewportSize( mEngine->size() ); } ); lm->setViewportSize( mEngine->size() ); } // configure billboard's viewport when the viewport is changed. - const QList< QgsPoint3DBillboardMaterial *> childBillboardMaterials = newEntity->findChildren(); + const QList childBillboardMaterials = newEntity->findChildren(); for ( QgsPoint3DBillboardMaterial *bm : childBillboardMaterials ) { - connect( mEngine, &QgsAbstract3DEngine::sizeChanged, bm, [bm, this] - { + connect( mEngine, &QgsAbstract3DEngine::sizeChanged, bm, [bm, this] { bm->setViewportSize( mEngine->size() ); } ); @@ -796,7 +788,7 @@ void Qgs3DMapScene::finalizeNewEntity( Qt3DCore::QEntity *newEntity ) // Finalize adding the 3D transparent objects by adding the layer components to the entities QgsFrameGraph *frameGraph = mEngine->frameGraph(); Qt3DRender::QLayer *transparentLayer = frameGraph->transparentObjectLayer(); - const QList< Qt3DRender::QMaterial *> childMaterials = newEntity->findChildren(); + const QList childMaterials = newEntity->findChildren(); for ( Qt3DRender::QMaterial *material : childMaterials ) { // This handles the phong material without data defined properties. @@ -817,7 +809,7 @@ void Qgs3DMapScene::finalizeNewEntity( Qt3DCore::QEntity *newEntity ) Qt3DRender::QEffect *effect = material->effect(); if ( effect ) { - const QVector< Qt3DRender::QParameter *> parameters = effect->parameters(); + const QVector parameters = effect->parameters(); for ( const Qt3DRender::QParameter *parameter : parameters ) { if ( parameter->name() == "opacity" && parameter->value() != 1.0f ) @@ -840,7 +832,7 @@ int Qgs3DMapScene::maximumTextureSize() const QSurface *surface = mEngine->surface(); QOpenGLContext context; context.create(); - bool success = context.makeCurrent( surface ); + bool success = context.makeCurrent( surface ); if ( success ) { @@ -855,7 +847,6 @@ int Qgs3DMapScene::maximumTextureSize() const { return 4096; //we can't have a context to defined the max texture size, we use this reasonable value } - } void Qgs3DMapScene::addCameraViewCenterEntity( Qt3DRender::QCamera *camera ) @@ -864,8 +855,7 @@ void Qgs3DMapScene::addCameraViewCenterEntity( Qt3DRender::QCamera *camera ) Qt3DCore::QTransform *trCameraViewCenter = new Qt3DCore::QTransform; mEntityCameraViewCenter->addComponent( trCameraViewCenter ); - connect( camera, &Qt3DRender::QCamera::viewCenterChanged, this, [trCameraViewCenter, camera] - { + connect( camera, &Qt3DRender::QCamera::viewCenterChanged, this, [trCameraViewCenter, camera] { trCameraViewCenter->setTranslation( camera->viewCenter() ); } ); @@ -880,8 +870,7 @@ void Qgs3DMapScene::addCameraViewCenterEntity( Qt3DRender::QCamera *camera ) mEntityCameraViewCenter->setEnabled( mMap.showCameraViewCenter() ); mEntityCameraViewCenter->setParent( this ); - connect( &mMap, &Qgs3DMapSettings::showCameraViewCenterChanged, this, [this] - { + connect( &mMap, &Qgs3DMapSettings::showCameraViewCenterChanged, this, [this] { mEntityCameraViewCenter->setEnabled( mMap.showCameraViewCenter() ); } ); } @@ -949,13 +938,13 @@ void Qgs3DMapScene::onShadowSettingsChanged() { QgsFrameGraph *frameGraph = mEngine->frameGraph(); - const QList< QgsLightSource * > lightSources = mMap.lightSources(); - QList< QgsDirectionalLightSettings * > directionalLightSources; + const QList lightSources = mMap.lightSources(); + QList directionalLightSources; for ( QgsLightSource *source : lightSources ) { if ( source->type() == Qgis::LightSourceType::Directional ) { - directionalLightSources << qgis::down_cast< QgsDirectionalLightSettings * >( source ); + directionalLightSources << qgis::down_cast( source ); } } @@ -1033,7 +1022,7 @@ void Qgs3DMapScene::exportScene( const Qgs3DMapExportSettings &exportSettings ) { QgsMapLayer *layer = it.key(); Qt3DCore::QEntity *rootEntity = it.value(); - Qgis::LayerType layerType = layer->type(); + Qgis::LayerType layerType = layer->type(); switch ( layerType ) { case Qgis::LayerType::Vector: @@ -1070,10 +1059,11 @@ void Qgs3DMapScene::exportScene( const Qgs3DMapExportSettings &exportSettings ) QVector Qgs3DMapScene::getLayerActiveChunkNodes( QgsMapLayer *layer ) { QVector chunks; - if ( !mLayerEntities.contains( layer ) ) return chunks; - if ( QgsChunkedEntity *c = qobject_cast( mLayerEntities[ layer ] ) ) + if ( !mLayerEntities.contains( layer ) ) + return chunks; + if ( QgsChunkedEntity *c = qobject_cast( mLayerEntities[layer] ) ) { - const QList< QgsChunkNode * > activeNodes = c->activeNodes(); + const QList activeNodes = c->activeNodes(); for ( QgsChunkNode *n : activeNodes ) chunks.push_back( n ); } @@ -1087,8 +1077,8 @@ QgsRectangle Qgs3DMapScene::sceneExtent() const QgsDoubleRange Qgs3DMapScene::elevationRange() const { - double yMin = std::numeric_limits< double >::max(); - double yMax = std::numeric_limits< double >::lowest(); + double yMin = std::numeric_limits::max(); + double yMax = std::numeric_limits::lowest(); if ( mMap.terrainRenderingEnabled() && mTerrain ) { const QgsBox3D box3D = mTerrain->rootNode()->box3D(); @@ -1103,7 +1093,7 @@ QgsDoubleRange Qgs3DMapScene::elevationRange() const { case Qgis::LayerType::PointCloud: { - QgsPointCloudLayer *pcl = qobject_cast< QgsPointCloudLayer *>( layer ); + QgsPointCloudLayer *pcl = qobject_cast( layer ); QgsDoubleRange zRange = pcl->elevationProperties()->calculateZRange( pcl ); yMin = std::min( yMin, zRange.lower() ); yMax = std::max( yMax, zRange.upper() ); @@ -1111,7 +1101,7 @@ QgsDoubleRange Qgs3DMapScene::elevationRange() const } case Qgis::LayerType::Mesh: { - QgsMeshLayer *meshLayer = qobject_cast< QgsMeshLayer *>( layer ); + QgsMeshLayer *meshLayer = qobject_cast( layer ); QgsAbstract3DRenderer *renderer3D = meshLayer->renderer3D(); if ( renderer3D ) { @@ -1126,7 +1116,7 @@ QgsDoubleRange Qgs3DMapScene::elevationRange() const } case Qgis::LayerType::TiledScene: { - QgsTiledSceneLayer *sceneLayer = qobject_cast< QgsTiledSceneLayer *>( layer ); + QgsTiledSceneLayer *sceneLayer = qobject_cast( layer ); const QgsDoubleRange zRange = sceneLayer->elevationProperties()->calculateZRange( sceneLayer ); if ( !zRange.isInfinite() && !zRange.isEmpty() ) { @@ -1144,12 +1134,11 @@ QgsDoubleRange Qgs3DMapScene::elevationRange() const break; } } - const QgsDoubleRange yRange( std::min( yMin, std::numeric_limits::max() ), - std::max( yMax, std::numeric_limits::lowest() ) ); + const QgsDoubleRange yRange( std::min( yMin, std::numeric_limits::max() ), std::max( yMax, std::numeric_limits::lowest() ) ); return yRange.isEmpty() ? QgsDoubleRange() : yRange; } -QMap< QString, Qgs3DMapScene * > Qgs3DMapScene::openScenes() +QMap Qgs3DMapScene::openScenes() { return sOpenScenesFunction(); } @@ -1169,13 +1158,11 @@ void Qgs3DMapScene::addCameraRotationCenterEntity( QgsCameraController *controll mEntityRotationCenter->setEnabled( false ); mEntityRotationCenter->setParent( this ); - connect( controller, &QgsCameraController::cameraRotationCenterChanged, this, [trRotationCenter]( QVector3D center ) - { + connect( controller, &QgsCameraController::cameraRotationCenterChanged, this, [trRotationCenter]( QVector3D center ) { trRotationCenter->setTranslation( center ); } ); - connect( &mMap, &Qgs3DMapSettings::showCameraRotationCenterChanged, this, [this] - { + connect( &mMap, &Qgs3DMapSettings::showCameraRotationCenterChanged, this, [this] { mEntityRotationCenter->setEnabled( mMap.showCameraRotationCenter() ); } ); } @@ -1190,11 +1177,7 @@ void Qgs3DMapScene::on3DAxisSettingsChanged() { if ( QgsWindow3DEngine *engine = dynamic_cast( mEngine ) ) { - m3DAxis = new Qgs3DAxis( static_cast( engine->window() ), - engine->root(), - this, - mCameraController, - &mMap ); + m3DAxis = new Qgs3DAxis( static_cast( engine->window() ), engine->root(), this, mCameraController, &mMap ); } } } diff --git a/src/3d/qgs3dmapscene.h b/src/3d/qgs3dmapscene.h index 56a2cf462c6..3bfc4a552c3 100644 --- a/src/3d/qgs3dmapscene.h +++ b/src/3d/qgs3dmapscene.h @@ -28,7 +28,7 @@ namespace Qt3DRender { class QRenderSettings; class QCamera; -} +} // namespace Qt3DRender namespace Qt3DLogic { @@ -39,7 +39,7 @@ namespace Qt3DExtras { class QForwardRenderer; class QSkyboxEntity; -} +} // namespace Qt3DExtras #endif @@ -114,8 +114,8 @@ class _3D_EXPORT Qgs3DMapScene : public QObject //! Enumeration of possible states of the 3D scene enum SceneState { - Ready, //!< The scene is fully loaded/updated - Updating, //!< The scene is still being loaded/updated + Ready, //!< The scene is fully loaded/updated + Updating, //!< The scene is still being loaded/updated }; //! Returns the current state of the scene @@ -212,7 +212,7 @@ class _3D_EXPORT Qgs3DMapScene : public QObject * \deprecated QGIS 3.36. Use QgisAppInterface::mapCanvases3D() instead. * \since QGIS 3.30 */ - Q_DECL_DEPRECATED static QMap< QString, Qgs3DMapScene * > openScenes() SIP_DEPRECATED; + Q_DECL_DEPRECATED static QMap openScenes() SIP_DEPRECATED; /** * Enables OpenGL clipping based on the planes equations defined in \a clipPlaneEquations. @@ -246,7 +246,7 @@ class _3D_EXPORT Qgs3DMapScene : public QObject #ifndef SIP_RUN //! Static function for returning open 3D map scenes - static std::function< QMap< QString, Qgs3DMapScene * >() > sOpenScenesFunction; + static std::function()> sOpenScenesFunction; #endif signals: @@ -332,7 +332,6 @@ class _3D_EXPORT Qgs3DMapScene : public QObject void handleClippingOnAllEntities() const; private: - Qgs3DMapSettings &mMap; QgsAbstract3DEngine *mEngine = nullptr; //! Provides a way to have a synchronous function executed each frame @@ -360,6 +359,5 @@ class _3D_EXPORT Qgs3DMapScene : public QObject QList mClipPlanesEquations; int mMaxClipPlanes = 6; - }; #endif // QGS3DMAPSCENE_H diff --git a/src/3d/qgs3dmapsceneentity.h b/src/3d/qgs3dmapsceneentity.h index 0a3151eb944..9e10f1f2317 100644 --- a/src/3d/qgs3dmapsceneentity.h +++ b/src/3d/qgs3dmapsceneentity.h @@ -60,10 +60,10 @@ class Qgs3DMapSceneEntity : public Qt3DCore::QEntity //! Records some bits about the scene (context for handleSceneUpdate() method) struct SceneContext { - QVector3D cameraPos; //!< Camera position - float cameraFov; //!< Field of view (in degrees) - int screenSizePx; //!< Size of the viewport in pixels - QMatrix4x4 viewProjectionMatrix; //!< For frustum culling + QVector3D cameraPos; //!< Camera position + float cameraFov; //!< Field of view (in degrees) + int screenSizePx; //!< Size of the viewport in pixels + QMatrix4x4 viewProjectionMatrix; //!< For frustum culling }; //! Called when e.g. camera changes and entity may need updated @@ -76,7 +76,11 @@ class Qgs3DMapSceneEntity : public Qt3DCore::QEntity virtual bool needsUpdate() const { return false; } //! Returns the near to far plane range for the entity using the specified \a viewMatrix - virtual QgsRange getNearFarPlaneRange( const QMatrix4x4 &viewMatrix ) const { Q_UNUSED( viewMatrix ) return QgsRange( 1e9, 0 ); } + virtual QgsRange getNearFarPlaneRange( const QMatrix4x4 &viewMatrix ) const + { + Q_UNUSED( viewMatrix ) + return QgsRange( 1e9, 0 ); + } /** * Returns the associated 3D mapSettings settings. diff --git a/src/3d/qgs3dmapsettings.cpp b/src/3d/qgs3dmapsettings.cpp index c082248daa3..65efe205e08 100644 --- a/src/3d/qgs3dmapsettings.cpp +++ b/src/3d/qgs3dmapsettings.cpp @@ -41,8 +41,7 @@ Qgs3DMapSettings::Qgs3DMapSettings() : QObject( nullptr ) { - connect( this, &Qgs3DMapSettings::settingsChanged, [&]() - { + connect( this, &Qgs3DMapSettings::settingsChanged, [&]() { QgsProject::instance()->setDirty(); } ); connectChangedSignalsToSettingsChanged(); @@ -110,8 +109,7 @@ Qgs3DMapSettings::Qgs3DMapSettings( const Qgs3DMapSettings &other ) mLightSources << source->clone(); } - connect( this, &Qgs3DMapSettings::settingsChanged, [&]() - { + connect( this, &Qgs3DMapSettings::settingsChanged, [&]() { QgsProject::instance()->setDirty(); } ); connectChangedSignalsToSettingsChanged(); @@ -129,18 +127,20 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte QgsProjectDirtyBlocker blocker( QgsProject::instance() ); QDomElement elemOrigin = elem.firstChildElement( QStringLiteral( "origin" ) ); mOrigin = QgsVector3D( - elemOrigin.attribute( QStringLiteral( "x" ) ).toDouble(), - elemOrigin.attribute( QStringLiteral( "y" ) ).toDouble(), - elemOrigin.attribute( QStringLiteral( "z" ) ).toDouble() ); + elemOrigin.attribute( QStringLiteral( "x" ) ).toDouble(), + elemOrigin.attribute( QStringLiteral( "y" ) ).toDouble(), + elemOrigin.attribute( QStringLiteral( "z" ) ).toDouble() + ); QDomElement elemExtent = elem.firstChildElement( QStringLiteral( "extent" ) ); if ( !elemExtent.isNull() ) { mExtent = QgsRectangle( - elemExtent.attribute( QStringLiteral( "xMin" ) ).toDouble(), - elemExtent.attribute( QStringLiteral( "yMin" ) ).toDouble(), - elemExtent.attribute( QStringLiteral( "xMax" ) ).toDouble(), - elemExtent.attribute( QStringLiteral( "yMax" ) ).toDouble() ); + elemExtent.attribute( QStringLiteral( "xMin" ) ).toDouble(), + elemExtent.attribute( QStringLiteral( "yMin" ) ).toDouble(), + elemExtent.attribute( QStringLiteral( "xMax" ) ).toDouble(), + elemExtent.attribute( QStringLiteral( "yMax" ) ).toDouble() + ); mShowExtentIn2DView = elemExtent.attribute( QStringLiteral( "showIn2dView" ), QStringLiteral( "0" ) ).toInt(); } @@ -153,7 +153,7 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte if ( !elemCamera.isNull() ) { mFieldOfView = elemCamera.attribute( QStringLiteral( "field-of-view" ), QStringLiteral( "45" ) ).toFloat(); - mProjectionType = static_cast< Qt3DRender::QCameraLens::ProjectionType >( elemCamera.attribute( QStringLiteral( "projection-type" ), QStringLiteral( "1" ) ).toInt() ); + mProjectionType = static_cast( elemCamera.attribute( QStringLiteral( "projection-type" ), QStringLiteral( "1" ) ).toInt() ); QString cameraNavigationMode = elemCamera.attribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "basic-navigation" ) ); if ( cameraNavigationMode == QLatin1String( "terrain-based-navigation" ) ) mCameraNavigationMode = Qgis::NavigationMode::TerrainBased; @@ -209,7 +209,7 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte QDomElement elemPointLight = elemPointLights.firstChildElement( QStringLiteral( "point-light" ) ); while ( !elemPointLight.isNull() ) { - std::unique_ptr< QgsPointLightSettings > pointLight = std::make_unique< QgsPointLightSettings >(); + std::unique_ptr pointLight = std::make_unique(); pointLight->readXml( elemPointLight, context ); mLightSources << pointLight.release(); elemPointLight = elemPointLight.nextSiblingElement( QStringLiteral( "point-light" ) ); @@ -218,7 +218,7 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte else { // QGIS <= 3.4 did not have light configuration - std::unique_ptr< QgsPointLightSettings > defaultLight = std::make_unique< QgsPointLightSettings >(); + std::unique_ptr defaultLight = std::make_unique(); defaultLight->setPosition( QgsVector3D( 0, 1000, 0 ) ); mLightSources << defaultLight.release(); } @@ -229,7 +229,7 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte QDomElement elemDirectionalLight = elemDirectionalLights.firstChildElement( QStringLiteral( "directional-light" ) ); while ( !elemDirectionalLight.isNull() ) { - std::unique_ptr< QgsDirectionalLightSettings > directionalLight = std::make_unique< QgsDirectionalLightSettings >(); + std::unique_ptr directionalLight = std::make_unique(); directionalLight->readXml( elemDirectionalLight, context ); mLightSources << directionalLight.release(); elemDirectionalLight = elemDirectionalLight.nextSiblingElement( QStringLiteral( "directional-light" ) ); @@ -245,7 +245,7 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte mapLayers << QgsMapLayerRef( elemMapLayer.attribute( QStringLiteral( "id" ) ) ); elemMapLayer = elemMapLayer.nextSiblingElement( QStringLiteral( "layer" ) ); } - mLayers = mapLayers; // needs to resolve refs afterwards + mLayers = mapLayers; // needs to resolve refs afterwards QDomElement elemTerrainGenerator = elemTerrain.firstChildElement( QStringLiteral( "generator" ) ); QString terrainGenType = elemTerrainGenerator.attribute( QStringLiteral( "type" ) ); @@ -325,7 +325,6 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte QDomElement elem3dAxis = elem.firstChildElement( QStringLiteral( "axis3d" ) ); m3dAxisSettings.readXml( elem3dAxis, context ); - } QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const @@ -350,7 +349,7 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon QDomElement elemCamera = doc.createElement( QStringLiteral( "camera" ) ); elemCamera.setAttribute( QStringLiteral( "field-of-view" ), mFieldOfView ); - elemCamera.setAttribute( QStringLiteral( "projection-type" ), static_cast< int >( mProjectionType ) ); + elemCamera.setAttribute( QStringLiteral( "projection-type" ), static_cast( mProjectionType ) ); switch ( mCameraNavigationMode ) { case Qgis::NavigationMode::TerrainBased: @@ -443,7 +442,7 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon elem.appendChild( elemEyeDomeLighting ); QDomElement elemNavigationSync = doc.createElement( QStringLiteral( "navigation-sync" ) ); - elemNavigationSync.setAttribute( QStringLiteral( "view-sync-mode" ), ( int )mViewSyncMode ); + elemNavigationSync.setAttribute( QStringLiteral( "view-sync-mode" ), ( int ) mViewSyncMode ); elemNavigationSync.setAttribute( QStringLiteral( "view-frustum-visualization-enabled" ), mVisualizeViewFrustum ? 1 : 0 ); elem.appendChild( elemNavigationSync ); @@ -693,7 +692,7 @@ void Qgs3DMapSettings::configureTerrainFromProject( QgsProjectElevationPropertie } else if ( properties->terrainProvider()->type() == QLatin1String( "raster" ) ) { - QgsRasterDemTerrainProvider *rasterProvider = qgis::down_cast< QgsRasterDemTerrainProvider * >( properties->terrainProvider() ); + QgsRasterDemTerrainProvider *rasterProvider = qgis::down_cast( properties->terrainProvider() ); QgsDemTerrainGenerator *demTerrainGen = new QgsDemTerrainGenerator; demTerrainGen->setCrs( crs(), QgsProject::instance()->transformContext() ); @@ -705,12 +704,12 @@ void Qgs3DMapSettings::configureTerrainFromProject( QgsProjectElevationPropertie } else if ( properties->terrainProvider()->type() == QLatin1String( "mesh" ) ) { - QgsMeshTerrainProvider *meshProvider = qgis::down_cast< QgsMeshTerrainProvider * >( properties->terrainProvider() ); + QgsMeshTerrainProvider *meshProvider = qgis::down_cast( properties->terrainProvider() ); QgsMeshTerrainGenerator *newTerrainGenerator = new QgsMeshTerrainGenerator; newTerrainGenerator->setCrs( crs(), QgsProject::instance()->transformContext() ); newTerrainGenerator->setLayer( meshProvider->layer() ); - std::unique_ptr< QgsMesh3DSymbol > symbol( newTerrainGenerator->symbol()->clone() ); + std::unique_ptr symbol( newTerrainGenerator->symbol()->clone() ); symbol->setVerticalScale( properties->terrainProvider()->scale() ); newTerrainGenerator->setSymbol( symbol.release() ); setTerrainGenerator( newTerrainGenerator ); @@ -1078,11 +1077,11 @@ void Qgs3DMapSettings::setLightSources( const QList &lights ) switch ( mLightSources[i]->type() ) { case Qgis::LightSourceType::Point: - if ( *static_cast< QgsPointLightSettings * >( mLightSources[i] ) == *static_cast< QgsPointLightSettings * >( lights[i] ) ) + if ( *static_cast( mLightSources[i] ) == *static_cast( lights[i] ) ) continue; break; case Qgis::LightSourceType::Directional: - if ( *static_cast< QgsDirectionalLightSettings * >( mLightSources[i] ) == *static_cast< QgsDirectionalLightSettings * >( lights[i] ) ) + if ( *static_cast( mLightSources[i] ) == *static_cast( lights[i] ) ) continue; break; } diff --git a/src/3d/qgs3dmapsettings.h b/src/3d/qgs3dmapsettings.h index 35da509c6ce..d07aff58256 100644 --- a/src/3d/qgs3dmapsettings.h +++ b/src/3d/qgs3dmapsettings.h @@ -55,7 +55,6 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec { Q_OBJECT public: - Qgs3DMapSettings(); Qgs3DMapSettings( const Qgs3DMapSettings &other ); ~Qgs3DMapSettings() override; @@ -977,42 +976,42 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec private: //! Offset in map CRS coordinates at which our 3D world has origin (0,0,0) QgsVector3D mOrigin; - QgsCoordinateReferenceSystem mCrs; //!< Destination coordinate system of the world - QColor mBackgroundColor = Qt::black; //!< Background color of the scene - QColor mSelectionColor; //!< Color to be used for selected map features - double mTerrainVerticalScale = 1; //!< Multiplier of terrain heights to make the terrain shape more pronounced - std::unique_ptr mTerrainGenerator; //!< Implementation of the terrain generation - int mMapTileResolution = 512; //!< Size of map textures of tiles in pixels (width/height) - float mMaxTerrainScreenError = 3.f; //!< Maximum allowed terrain error in pixels (determines when tiles are switched to more detailed ones) - float mMaxTerrainGroundError = 1.f; //!< Maximum allowed horizontal map error in map units (determines how many zoom levels will be used) - float mTerrainElevationOffset = 0.0f; //!< Terrain elevation offset (used to adjust the position of the terrain and move it up and down) - bool mTerrainShadingEnabled = false; //!< Whether terrain should be shaded taking lights into account - QgsPhongMaterialSettings mTerrainShadingMaterial; //!< Material to use for the terrain (if shading is enabled). Diffuse color is ignored. - QString mTerrainMapTheme; //!< Name of map theme used for terrain's texture (empty means use the current map theme) - bool mShowTerrainBoundingBoxes = false; //!< Whether to show bounding boxes of entities - useful for debugging - bool mShowTerrainTileInfo = false; //!< Whether to draw extra information about terrain tiles to the textures - useful for debugging - bool mShowCameraViewCenter = false; //!< Whether to show camera view center as a sphere - useful for debugging - bool mShowCameraRotationCenter = false; //!< Whether to show camera rotation center as a sphere - useful for debugging - bool mShowLightSources = false; //!< Whether to show the origin of light sources - bool mShowLabels = false; //!< Whether to display labels on terrain tiles - bool mStopUpdates = false; //!< Whether to stop updating scene on zoom - bool mShowDebugPanel = false; //!< Whether to show debug panel - QList< QgsLightSource * > mLightSources; //!< List of light sources in the scene (owned by the settings) - float mFieldOfView = 45.0f; // mTerrainGenerator; //!< Implementation of the terrain generation + int mMapTileResolution = 512; //!< Size of map textures of tiles in pixels (width/height) + float mMaxTerrainScreenError = 3.f; //!< Maximum allowed terrain error in pixels (determines when tiles are switched to more detailed ones) + float mMaxTerrainGroundError = 1.f; //!< Maximum allowed horizontal map error in map units (determines how many zoom levels will be used) + float mTerrainElevationOffset = 0.0f; //!< Terrain elevation offset (used to adjust the position of the terrain and move it up and down) + bool mTerrainShadingEnabled = false; //!< Whether terrain should be shaded taking lights into account + QgsPhongMaterialSettings mTerrainShadingMaterial; //!< Material to use for the terrain (if shading is enabled). Diffuse color is ignored. + QString mTerrainMapTheme; //!< Name of map theme used for terrain's texture (empty means use the current map theme) + bool mShowTerrainBoundingBoxes = false; //!< Whether to show bounding boxes of entities - useful for debugging + bool mShowTerrainTileInfo = false; //!< Whether to draw extra information about terrain tiles to the textures - useful for debugging + bool mShowCameraViewCenter = false; //!< Whether to show camera view center as a sphere - useful for debugging + bool mShowCameraRotationCenter = false; //!< Whether to show camera rotation center as a sphere - useful for debugging + bool mShowLightSources = false; //!< Whether to show the origin of light sources + bool mShowLabels = false; //!< Whether to display labels on terrain tiles + bool mStopUpdates = false; //!< Whether to stop updating scene on zoom + bool mShowDebugPanel = false; //!< Whether to show debug panel + QList mLightSources; //!< List of light sources in the scene (owned by the settings) + float mFieldOfView = 45.0f; // mLayers; //!< Layers to be rendered + QList mLayers; //!< Layers to be rendered //! Coordinate transform context QgsCoordinateTransformContext mTransformContext; QgsPathResolver mPathResolver; - QgsMapThemeCollection *mMapThemes = nullptr; //!< Pointer to map themes (e.g. from the current project) to resolve map theme content from the name - double mDpi = 96; //!< Dot per inch value for the screen / painter + QgsMapThemeCollection *mMapThemes = nullptr; //!< Pointer to map themes (e.g. from the current project) to resolve map theme content from the name + double mDpi = 96; //!< Dot per inch value for the screen / painter bool mIsFpsCounterEnabled = false; - bool mIsSkyboxEnabled = false; //!< Whether the skybox is enabled - QgsSkyboxSettings mSkyboxSettings; //!< Skybox related configuration - QgsShadowSettings mShadowSettings; //!< Shadow rendering related settings + bool mIsSkyboxEnabled = false; //!< Whether the skybox is enabled + QgsSkyboxSettings mSkyboxSettings; //!< Skybox related configuration + QgsShadowSettings mShadowSettings; //!< Shadow rendering related settings QgsAmbientOcclusionSettings mAmbientOcclusionSettings; //!< Screen Space Ambient Occlusion related settings bool mEyeDomeLightingEnabled = false; @@ -1041,7 +1040,6 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec QgsRectangle mExtent; //!< 2d extent used to limit the 3d view bool mShowExtentIn2DView = false; - }; diff --git a/src/3d/qgs3dmaptool.cpp b/src/3d/qgs3dmaptool.cpp index 0d9d2d5c4a5..f5cb4ebff05 100644 --- a/src/3d/qgs3dmaptool.cpp +++ b/src/3d/qgs3dmaptool.cpp @@ -59,7 +59,6 @@ QCursor Qgs3DMapTool::cursor() const void Qgs3DMapTool::onMapSettingsChanged() { - } Qgs3DMapCanvas *Qgs3DMapTool::canvas() diff --git a/src/3d/qgs3drendercontext.h b/src/3d/qgs3drendercontext.h index a67439f07c5..dd12578ccb9 100644 --- a/src/3d/qgs3drendercontext.h +++ b/src/3d/qgs3drendercontext.h @@ -45,9 +45,7 @@ class Qgs3DMapSettings; */ class _3D_EXPORT Qgs3DRenderContext { - public: - Qgs3DRenderContext() = default; /** @@ -152,25 +150,25 @@ class _3D_EXPORT Qgs3DRenderContext const QgsExpressionContext &expressionContext() const SIP_SKIP { return mExpressionContext; } private: - QgsCoordinateReferenceSystem mCrs; //!< Destination coordinate system of the world + QgsCoordinateReferenceSystem mCrs; //!< Destination coordinate system of the world //! Coordinate transform context QgsCoordinateTransformContext mTransformContext; //! Offset in map CRS coordinates at which our 3D world has origin (0,0,0) QgsVector3D mOrigin; QgsRectangle mExtent; //!< 2d extent used to limit the 3d view QgsDateTimeRange mTemporalRange; - QColor mSelectionColor; //!< Color to be used for selected map features - double mDpi = 96; //!< Dot per inch value for the screen / painter + QColor mSelectionColor; //!< Color to be used for selected map features + double mDpi = 96; //!< Dot per inch value for the screen / painter float mFieldOfView = 45.0f; //!< Camera lens field of view value bool mTerrainRenderingEnabled = true; - double mTerrainVerticalScale = 1; //!< Multiplier of terrain heights to make the terrain shape more pronounced + double mTerrainVerticalScale = 1; //!< Multiplier of terrain heights to make the terrain shape more pronounced //! Expression context QgsExpressionContext mExpressionContext; // not owned, currently a pointer to the Qgs3DMapSettings terrain generator. // TODO -- fix during implementation of https://github.com/qgis/QGIS-Enhancement-Proposals/issues/301 - QgsTerrainGenerator *mTerrainGenerator = nullptr; //!< Implementation of the terrain generation + QgsTerrainGenerator *mTerrainGenerator = nullptr; //!< Implementation of the terrain generation }; diff --git a/src/3d/qgs3dsceneexporter.cpp b/src/3d/qgs3dsceneexporter.cpp index 0c1939c7357..c8b73f0ff72 100644 --- a/src/3d/qgs3dsceneexporter.cpp +++ b/src/3d/qgs3dsceneexporter.cpp @@ -21,7 +21,7 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -166,8 +166,10 @@ Qt3DQAttribute *findAttribute( Qt3DQGeometry *geometry, const QString &name, Qt3 QVector attributes = geometry->attributes(); for ( Qt3DQAttribute *attribute : attributes ) { - if ( attribute->attributeType() != type ) continue; - if ( name.isEmpty() || attribute->name() == name ) return attribute; + if ( attribute->attributeType() != type ) + continue; + if ( name.isEmpty() || attribute->name() == name ) + return attribute; } return nullptr; } @@ -189,7 +191,7 @@ Component *findTypedComponent( Qt3DCore::QEntity *entity ) bool Qgs3DSceneExporter::parseVectorLayerEntity( Qt3DCore::QEntity *entity, QgsVectorLayer *layer ) { - QgsAbstract3DRenderer *abstractRenderer = layer->renderer3D(); + QgsAbstract3DRenderer *abstractRenderer = layer->renderer3D(); const QString rendererType = abstractRenderer->type(); if ( rendererType == "rulebased" ) @@ -214,7 +216,7 @@ bool Qgs3DSceneExporter::parseVectorLayerEntity( Qt3DCore::QEntity *entity, QgsV else if ( rendererType == "vector" ) { - QgsVectorLayer3DRenderer *vectorLayerRenderer = dynamic_cast< QgsVectorLayer3DRenderer *>( abstractRenderer ); + QgsVectorLayer3DRenderer *vectorLayerRenderer = dynamic_cast( abstractRenderer ); if ( vectorLayerRenderer ) { const QgsAbstract3DSymbol *symbol = vectorLayerRenderer->symbol(); @@ -246,7 +248,7 @@ void Qgs3DSceneExporter::processEntityMaterial( Qt3DCore::QEntity *entity, Qgs3D Qt3DExtras::QDiffuseSpecularMaterial *diffuseMapMaterial = findTypedComponent( entity ); if ( diffuseMapMaterial ) { - const Qt3DRender::QTexture2D *diffuseTexture = diffuseMapMaterial->diffuse().value< Qt3DRender::QTexture2D * >(); + const Qt3DRender::QTexture2D *diffuseTexture = diffuseMapMaterial->diffuse().value(); if ( diffuseTexture ) { const QVector textureImages = diffuseTexture->textureImages(); @@ -264,7 +266,7 @@ void Qgs3DSceneExporter::processEntityMaterial( Qt3DCore::QEntity *entity, Qgs3D } } -void Qgs3DSceneExporter::parseTerrain( QgsTerrainEntity *terrain, const QString &layerName ) +void Qgs3DSceneExporter::parseTerrain( QgsTerrainEntity *terrain, const QString &layerName ) { Qgs3DMapSettings *settings = terrain->mapSettings(); if ( !settings->terrainRenderingEnabled() ) @@ -379,10 +381,11 @@ void Qgs3DSceneExporter::parseFlatTile( QgsTerrainTileEntity *tileEntity, const QgsDebugError( QString( "Geometry for '%1' has index attribute with empty data!" ).arg( layerName ) ); return; } - const QVector indexesBuffer = getIndexData( indexAttribute, indexBytes ); + const QVector indexesBuffer = getIndexData( indexAttribute, indexBytes ); QString objectNamePrefix = layerName; - if ( objectNamePrefix != QString() ) objectNamePrefix += QString(); + if ( objectNamePrefix != QString() ) + objectNamePrefix += QString(); Qgs3DExportObject *object = new Qgs3DExportObject( getObjectName( objectNamePrefix + QStringLiteral( "Flat_tile" ) ) ); mObjects.push_back( object ); @@ -395,7 +398,8 @@ void Qgs3DSceneExporter::parseFlatTile( QgsTerrainTileEntity *tileEntity, const { // Everts QVector normalsBuffer; - for ( int i = 0; i < positionBuffer.size(); i += 3 ) normalsBuffer << 0.0f << 1.0f << 0.0f; + for ( int i = 0; i < positionBuffer.size(); i += 3 ) + normalsBuffer << 0.0f << 1.0f << 0.0f; object->setupNormalCoordinates( normalsBuffer, transform->matrix() ); } @@ -464,7 +468,8 @@ void Qgs3DSceneExporter::parseDemTile( QgsTerrainTileEntity *tileEntity, const Q void Qgs3DSceneExporter::parseMeshTile( QgsTerrainTileEntity *tileEntity, const QString &layerName ) { QString objectNamePrefix = layerName; - if ( objectNamePrefix != QString() ) objectNamePrefix += QStringLiteral( "_" ); + if ( objectNamePrefix != QString() ) + objectNamePrefix += QStringLiteral( "_" ); const QList renderers = tileEntity->findChildren(); for ( Qt3DRender::QGeometryRenderer *renderer : renderers ) @@ -479,7 +484,7 @@ void Qgs3DSceneExporter::parseMeshTile( QgsTerrainTileEntity *tileEntity, const QVector Qgs3DSceneExporter::processInstancedPointGeometry( Qt3DCore::QEntity *entity, const QString &objectNamePrefix ) { QVector objects; - const QList geometriesList = entity->findChildren(); + const QList geometriesList = entity->findChildren(); for ( Qt3DQGeometry *geometry : geometriesList ) { Qt3DQAttribute *positionAttribute = findAttribute( geometry, Qt3DQAttribute::defaultPositionAttributeName(), Qt3DQAttribute::VertexAttribute ); @@ -501,7 +506,7 @@ QVector Qgs3DSceneExporter::processInstancedPointGeometry( const QVector positionData = getAttributeData( positionAttribute, vertexBytes ); const QVector indexData = getIndexData( indexAttribute, indexBytes ); - Qt3DQAttribute *instanceDataAttribute = findAttribute( geometry, QStringLiteral( "pos" ), Qt3DQAttribute::VertexAttribute ); + Qt3DQAttribute *instanceDataAttribute = findAttribute( geometry, QStringLiteral( "pos" ), Qt3DQAttribute::VertexAttribute ); if ( !instanceDataAttribute ) { QgsDebugError( QString( "Cannot export '%1' - geometry has no instanceData attribute!" ).arg( objectNamePrefix ) ); @@ -568,7 +573,7 @@ Qgs3DExportObject *Qgs3DSceneExporter::processGeometryRenderer( Qt3DRender::QGeo return nullptr; Qt3DQGeometry *geometry = geomRenderer->geometry(); - if ( ! geometry ) + if ( !geometry ) return nullptr; // === Compute triangleIndexStartingIndiceToKeep according to duplicated features @@ -591,7 +596,7 @@ Qgs3DExportObject *Qgs3DSceneExporter::processGeometryRenderer( Qt3DRender::QGeo for ( int idx = 0; idx < featureIds.size(); idx++ ) { const QgsFeatureId feat = featureIds[idx]; - if ( ! mExportedFeatureIds.contains( feat ) ) + if ( !mExportedFeatureIds.contains( feat ) ) { // add the feature (as it was unknown) to temp set and not to the mExportedFeatureIds (as featureIds can have the same id multiple times) tempFeatToAdd += feat; @@ -742,7 +747,8 @@ QVector Qgs3DSceneExporter::processLines( Qt3DCore::QEntity const QList renderers = entity->findChildren(); for ( Qt3DRender::QGeometryRenderer *renderer : renderers ) { - if ( renderer->primitiveType() != Qt3DRender::QGeometryRenderer::LineStripAdjacency ) continue; + if ( renderer->primitiveType() != Qt3DRender::QGeometryRenderer::LineStripAdjacency ) + continue; Qt3DQGeometry *geom = renderer->geometry(); Qt3DQAttribute *positionAttribute = findAttribute( geom, Qt3DQAttribute::defaultPositionAttributeName(), Qt3DQAttribute::VertexAttribute ); Qt3DQAttribute *indexAttribute = findAttribute( geom, QString(), Qt3DQAttribute::IndexAttribute ); diff --git a/src/3d/qgs3dsceneexporter.h b/src/3d/qgs3dsceneexporter.h index 67453d56d0b..cefa70c98aa 100644 --- a/src/3d/qgs3dsceneexporter.h +++ b/src/3d/qgs3dsceneexporter.h @@ -59,7 +59,7 @@ class _3D_EXPORT Qgs3DSceneExporter : public Qt3DCore::QEntity Q_OBJECT public: - Qgs3DSceneExporter() { } + Qgs3DSceneExporter() {} ~Qgs3DSceneExporter() { @@ -74,7 +74,7 @@ class _3D_EXPORT Qgs3DSceneExporter : public Qt3DCore::QEntity bool parseVectorLayerEntity( Qt3DCore::QEntity *entity, QgsVectorLayer *layer ); //! Creates terrain export objects from the terrain entity - void parseTerrain( QgsTerrainEntity *terrain, const QString &layer ); + void parseTerrain( QgsTerrainEntity *terrain, const QString &layer ); //! Saves the scene to a .obj file void save( const QString &sceneName, const QString &sceneFolderPath, int precision = 6 ); @@ -137,6 +137,7 @@ class _3D_EXPORT Qgs3DSceneExporter : public Qt3DCore::QEntity void parseMeshTile( QgsTerrainTileEntity *meshEntity, const QString &layerName ); QString getObjectName( const QString &name ); + private: QMap usedObjectNamesCounter; QVector mObjects; diff --git a/src/3d/qgs3dtypes.h b/src/3d/qgs3dtypes.h index 631b91b0c3a..abadfeccb8d 100644 --- a/src/3d/qgs3dtypes.h +++ b/src/3d/qgs3dtypes.h @@ -30,14 +30,13 @@ class _3D_EXPORT Qgs3DTypes { public: - //! Triangle culling mode enum CullingMode { - NoCulling, //!< Will render both front and back faces of triangles - Front, //!< Will render only back faces of triangles - Back, //!< Will render only front faces of triangles (recommended when input data are consistent) - FrontAndBack //!< Will not render anything + NoCulling, //!< Will render both front and back faces of triangles + Front, //!< Will render only back faces of triangles + Back, //!< Will render only front faces of triangles (recommended when input data are consistent) + FrontAndBack //!< Will not render anything }; //! Qt property name to hold the 3D geometry renderer flag @@ -46,11 +45,9 @@ class _3D_EXPORT Qgs3DTypes //! 3D geometry renderer flag enum Flag3DRenderer { - Main3DRenderer = 0, //!< Renderer for normal entities - Selected3DRenderer, //!< Renderer for selected entities + Main3DRenderer = 0, //!< Renderer for normal entities + Selected3DRenderer, //!< Renderer for selected entities }; - - }; #endif // QGS3DTYPES_H diff --git a/src/3d/qgs3dutils.cpp b/src/3d/qgs3dutils.cpp index 1d5eb151f53..2d313d60551 100644 --- a/src/3d/qgs3dutils.cpp +++ b/src/3d/qgs3dutils.cpp @@ -46,7 +46,7 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include typedef Qt3DRender::QBuffer Qt3DQBuffer; #else @@ -65,8 +65,7 @@ QImage Qgs3DUtils::captureSceneImage( QgsAbstract3DEngine &engine, Qgs3DMapScene // We need to change render policy to RenderPolicy::Always, since otherwise render capture node won't work engine.renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::Always ); - auto requestImageFcn = [&engine, scene] - { + auto requestImageFcn = [&engine, scene] { if ( scene->sceneState() == Qgs3DMapScene::Ready ) { engine.renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::OnDemand ); @@ -74,8 +73,7 @@ QImage Qgs3DUtils::captureSceneImage( QgsAbstract3DEngine &engine, Qgs3DMapScene } }; - auto saveImageFcn = [&evLoop, &resImage]( const QImage & img ) - { + auto saveImageFcn = [&evLoop, &resImage]( const QImage &img ) { resImage = img; evLoop.quit(); }; @@ -111,8 +109,7 @@ QImage Qgs3DUtils::captureSceneDepthBuffer( QgsAbstract3DEngine &engine, Qgs3DMa // We need to change render policy to RenderPolicy::Always, since otherwise render capture node won't work engine.renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::Always ); - auto requestImageFcn = [&engine, scene] - { + auto requestImageFcn = [&engine, scene] { if ( scene->sceneState() == Qgs3DMapScene::Ready ) { engine.renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::OnDemand ); @@ -120,8 +117,7 @@ QImage Qgs3DUtils::captureSceneDepthBuffer( QgsAbstract3DEngine &engine, Qgs3DMa } }; - auto saveImageFcn = [&evLoop, &resImage]( const QImage & img ) - { + auto saveImageFcn = [&evLoop, &resImage]( const QImage &img ) { resImage = img; evLoop.quit(); }; @@ -166,15 +162,7 @@ double Qgs3DUtils::calculateEntityGpuMemorySize( Qt3DCore::QEntity *entity ) } -bool Qgs3DUtils::exportAnimation( const Qgs3DAnimationSettings &animationSettings, - Qgs3DMapSettings &mapSettings, - int framesPerSecond, - const QString &outputDirectory, - const QString &fileNameTemplate, - const QSize &outputSize, - QString &error, - QgsFeedback *feedback - ) +bool Qgs3DUtils::exportAnimation( const Qgs3DAnimationSettings &animationSettings, Qgs3DMapSettings &mapSettings, int framesPerSecond, const QString &outputDirectory, const QString &fileNameTemplate, const QSize &outputSize, QString &error, QgsFeedback *feedback ) { if ( animationSettings.keyFrames().size() < 2 ) { @@ -230,7 +218,6 @@ bool Qgs3DUtils::exportAnimation( const Qgs3DAnimationSettings &animationSetting while ( time <= duration ) { - if ( feedback ) { if ( feedback->isCanceled() ) @@ -264,14 +251,14 @@ bool Qgs3DUtils::exportAnimation( const Qgs3DAnimationSettings &animationSetting int Qgs3DUtils::maxZoomLevel( double tile0width, double tileResolution, double maxError ) { if ( maxError <= 0 || tileResolution <= 0 || tile0width <= 0 ) - return 0; // invalid input + return 0; // invalid input // derived from: // tile width [map units] = tile0width / 2^zoomlevel // tile error [map units] = tile width / tile resolution // + re-arranging to get zoom level if we know tile error we want to get const double zoomLevel = -log( tileResolution * maxError / tile0width ) / log( 2 ); - return round( zoomLevel ); // we could use ceil() here if we wanted to always get to the desired error + return round( zoomLevel ); // we could use ceil() here if we wanted to always get to the desired error } QString Qgs3DUtils::altClampingToString( Qgis::AltitudeClamping altClamp ) @@ -295,7 +282,7 @@ Qgis::AltitudeClamping Qgs3DUtils::altClampingFromString( const QString &str ) return Qgis::AltitudeClamping::Absolute; else if ( str == QLatin1String( "terrain" ) ) return Qgis::AltitudeClamping::Terrain; - else // "relative" (default) + else // "relative" (default) return Qgis::AltitudeClamping::Relative; } @@ -317,7 +304,7 @@ Qgis::AltitudeBinding Qgs3DUtils::altBindingFromString( const QString &str ) { if ( str == QLatin1String( "vertex" ) ) return Qgis::AltitudeBinding::Vertex; - else // "centroid" (default) + else // "centroid" (default) return Qgis::AltitudeBinding::Centroid; } @@ -517,9 +504,10 @@ void Qgs3DUtils::extractPointPositions( const QgsFeature &f, const Qgs3DRenderCo break; } positions.append( QVector3D( - static_cast( pt.x() - chunkOrigin.x() ), - static_cast( pt.y() - chunkOrigin.y() ), - h ) ); + static_cast( pt.x() - chunkOrigin.x() ), + static_cast( pt.y() - chunkOrigin.y() ), + h + ) ); QgsDebugMsgLevel( QStringLiteral( "%1 %2 %3" ).arg( positions.last().x() ).arg( positions.last().y() ).arg( positions.last().z() ), 2 ); } } @@ -539,12 +527,18 @@ static inline uint outcode( QVector4D v ) // TODO: optimise this with assembler - according to D&P this can // be done in one line of assembler on some platforms uint code = 0; - if ( v.x() < -v.w() ) code |= 0x01; - if ( v.x() > v.w() ) code |= 0x02; - if ( v.y() < -v.w() ) code |= 0x04; - if ( v.y() > v.w() ) code |= 0x08; - if ( v.z() < -v.w() ) code |= 0x10; - if ( v.z() > v.w() ) code |= 0x20; + if ( v.x() < -v.w() ) + code |= 0x01; + if ( v.x() > v.w() ) + code |= 0x02; + if ( v.y() < -v.w() ) + code |= 0x04; + if ( v.y() > v.w() ) + code |= 0x08; + if ( v.z() < -v.w() ) + code |= 0x10; + if ( v.z() > v.w() ) + code |= 0x20; return code; } @@ -565,9 +559,7 @@ bool Qgs3DUtils::isCullable( const QgsAABB &bbox, const QMatrix4x4 &viewProjecti for ( int i = 0; i < 8; ++i ) { - const QVector4D p( ( ( i >> 0 ) & 1 ) ? bbox.xMin : bbox.xMax, - ( ( i >> 1 ) & 1 ) ? bbox.yMin : bbox.yMax, - ( ( i >> 2 ) & 1 ) ? bbox.zMin : bbox.zMax, 1 ); + const QVector4D p( ( ( i >> 0 ) & 1 ) ? bbox.xMin : bbox.xMax, ( ( i >> 1 ) & 1 ) ? bbox.yMin : bbox.yMax, ( ( i >> 2 ) & 1 ) ? bbox.zMin : bbox.zMax, 1 ); const QVector4D pc = viewProjectionMatrix * p; // if the logical AND of all the outcodes is non-zero then the BB is @@ -579,17 +571,12 @@ bool Qgs3DUtils::isCullable( const QgsAABB &bbox, const QMatrix4x4 &viewProjecti QgsVector3D Qgs3DUtils::mapToWorldCoordinates( const QgsVector3D &mapCoords, const QgsVector3D &origin ) { - return QgsVector3D( mapCoords.x() - origin.x(), - mapCoords.y() - origin.y(), - mapCoords.z() - origin.z() ); - + return QgsVector3D( mapCoords.x() - origin.x(), mapCoords.y() - origin.y(), mapCoords.z() - origin.z() ); } QgsVector3D Qgs3DUtils::worldToMapCoordinates( const QgsVector3D &worldCoords, const QgsVector3D &origin ) { - return QgsVector3D( worldCoords.x() + origin.x(), - worldCoords.y() + origin.y(), - worldCoords.z() + origin.z() ); + return QgsVector3D( worldCoords.x() + origin.x(), worldCoords.y() + origin.y(), worldCoords.z() + origin.z() ); } QgsRectangle Qgs3DUtils::tryReprojectExtent2D( const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs1, const QgsCoordinateReferenceSystem &crs2, const QgsCoordinateTransformContext &context ) @@ -631,8 +618,7 @@ QgsAABB Qgs3DUtils::mapToWorldExtent( const QgsRectangle &extent, double zMin, d const QgsVector3D extentMax3D( extent.xMaximum(), extent.yMaximum(), zMax ); const QgsVector3D worldExtentMin3D = mapToWorldCoordinates( extentMin3D, mapOrigin ); const QgsVector3D worldExtentMax3D = mapToWorldCoordinates( extentMax3D, mapOrigin ); - QgsAABB rootBbox( worldExtentMin3D.x(), worldExtentMin3D.y(), worldExtentMin3D.z(), - worldExtentMax3D.x(), worldExtentMax3D.y(), worldExtentMax3D.z() ); + QgsAABB rootBbox( worldExtentMin3D.x(), worldExtentMin3D.y(), worldExtentMin3D.z(), worldExtentMax3D.x(), worldExtentMax3D.y(), worldExtentMax3D.z() ); return rootBbox; } @@ -643,12 +629,7 @@ QgsAABB Qgs3DUtils::mapToWorldExtent( const QgsBox3D &box3D, const QgsVector3D & const QgsVector3D worldExtentMin3D = mapToWorldCoordinates( extentMin3D, mapOrigin ); const QgsVector3D worldExtentMax3D = mapToWorldCoordinates( extentMax3D, mapOrigin ); // casting to float should be ok, assuming that the map origin is not too far from the box - return QgsAABB( static_cast( worldExtentMin3D.x() ), - static_cast( worldExtentMin3D.y() ), - static_cast( worldExtentMin3D.z() ), - static_cast( worldExtentMax3D.x() ), - static_cast( worldExtentMax3D.y() ), - static_cast( worldExtentMax3D.z() ) ); + return QgsAABB( static_cast( worldExtentMin3D.x() ), static_cast( worldExtentMin3D.y() ), static_cast( worldExtentMin3D.z() ), static_cast( worldExtentMax3D.x() ), static_cast( worldExtentMax3D.y() ), static_cast( worldExtentMax3D.z() ) ); } QgsRectangle Qgs3DUtils::worldToMapExtent( const QgsAABB &bbox, const QgsVector3D &mapOrigin ) @@ -702,8 +683,10 @@ void Qgs3DUtils::estimateVectorLayerZRange( QgsVectorLayer *layer, double &zMin, for ( auto vit = g.vertices_begin(); vit != g.vertices_end(); ++vit ) { const double z = ( *vit ).z(); - if ( z < zMin ) zMin = z; - if ( z > zMax ) zMax = z; + if ( z < zMin ) + zMin = z; + if ( z > zMax ) + zMax = z; } } @@ -795,21 +778,21 @@ std::unique_ptr Qgs3DUtils::convert2DPointCloudRen if ( !renderer ) return nullptr; - std::unique_ptr< QgsPointCloud3DSymbol > symbol3D; + std::unique_ptr symbol3D; if ( renderer->type() == QLatin1String( "ramp" ) ) { - const QgsPointCloudAttributeByRampRenderer *renderer2D = dynamic_cast< const QgsPointCloudAttributeByRampRenderer * >( renderer ); - symbol3D = std::make_unique< QgsColorRampPointCloud3DSymbol >(); - QgsColorRampPointCloud3DSymbol *symbol = static_cast< QgsColorRampPointCloud3DSymbol * >( symbol3D.get() ); + const QgsPointCloudAttributeByRampRenderer *renderer2D = dynamic_cast( renderer ); + symbol3D = std::make_unique(); + QgsColorRampPointCloud3DSymbol *symbol = static_cast( symbol3D.get() ); symbol->setAttribute( renderer2D->attribute() ); symbol->setColorRampShaderMinMax( renderer2D->minimum(), renderer2D->maximum() ); symbol->setColorRampShader( renderer2D->colorRampShader() ); } else if ( renderer->type() == QLatin1String( "rgb" ) ) { - const QgsPointCloudRgbRenderer *renderer2D = dynamic_cast< const QgsPointCloudRgbRenderer * >( renderer ); - symbol3D = std::make_unique< QgsRgbPointCloud3DSymbol >(); - QgsRgbPointCloud3DSymbol *symbol = static_cast< QgsRgbPointCloud3DSymbol * >( symbol3D.get() ); + const QgsPointCloudRgbRenderer *renderer2D = dynamic_cast( renderer ); + symbol3D = std::make_unique(); + QgsRgbPointCloud3DSymbol *symbol = static_cast( symbol3D.get() ); symbol->setRedAttribute( renderer2D->redAttribute() ); symbol->setGreenAttribute( renderer2D->greenAttribute() ); symbol->setBlueAttribute( renderer2D->blueAttribute() ); @@ -820,17 +803,16 @@ std::unique_ptr Qgs3DUtils::convert2DPointCloudRen } else if ( renderer->type() == QLatin1String( "classified" ) ) { - - const QgsPointCloudClassifiedRenderer *renderer2D = dynamic_cast< const QgsPointCloudClassifiedRenderer * >( renderer ); - symbol3D = std::make_unique< QgsClassificationPointCloud3DSymbol >(); - QgsClassificationPointCloud3DSymbol *symbol = static_cast< QgsClassificationPointCloud3DSymbol * >( symbol3D.get() ); + const QgsPointCloudClassifiedRenderer *renderer2D = dynamic_cast( renderer ); + symbol3D = std::make_unique(); + QgsClassificationPointCloud3DSymbol *symbol = static_cast( symbol3D.get() ); symbol->setAttribute( renderer2D->attribute() ); symbol->setCategoriesList( renderer2D->categories() ); } if ( symbol3D ) { - std::unique_ptr< QgsPointCloudLayer3DRenderer > renderer3D = std::make_unique< QgsPointCloudLayer3DRenderer >(); + std::unique_ptr renderer3D = std::make_unique(); renderer3D->setSymbol( symbol3D.release() ); return renderer3D; } @@ -840,7 +822,7 @@ std::unique_ptr Qgs3DUtils::convert2DPointCloudRen QHash> Qgs3DUtils::castRay( Qgs3DMapScene *scene, const QgsRay3D &ray, const QgsRayCastingUtils::RayCastContext &context ) { QgsRayCastingUtils::Ray3D r( ray.origin(), ray.direction(), context.maxDistance ); - QHash> results; + QHash> results; const QList keys = scene->layers(); for ( QgsMapLayer *layer : keys ) { @@ -850,14 +832,14 @@ QHash> Qgs3DUtils::castRay( Q { const QVector result = chunkedEntity->rayIntersection( r, context ); if ( !result.isEmpty() ) - results[ layer ] = result; + results[layer] = result; } } if ( QgsTerrainEntity *terrain = scene->terrainEntity() ) { const QVector result = terrain->rayIntersection( r, context ); if ( !result.isEmpty() ) - results[ nullptr ] = result; // Terrain hits are not tied to a layer so we use nullptr as their key here + results[nullptr] = result; // Terrain hits are not tied to a layer so we use nullptr as their key here } return results; } @@ -884,7 +866,7 @@ float Qgs3DUtils::screenSpaceError( float epsilon, float distance, int screenSiz * \|/ angle = field of view * camera */ - float phi = epsilon * static_cast( screenSize ) / static_cast( 2 * distance * tan( fov * M_PI / ( 2 * 180 ) ) ); + float phi = epsilon * static_cast( screenSize ) / static_cast( 2 * distance * tan( fov * M_PI / ( 2 * 180 ) ) ); return phi; } @@ -895,13 +877,11 @@ void Qgs3DUtils::computeBoundingBoxNearFarPlanes( const QgsAABB &bbox, const QMa for ( int i = 0; i < 8; ++i ) { - const QVector4D p( ( ( i >> 0 ) & 1 ) ? bbox.xMin : bbox.xMax, - ( ( i >> 1 ) & 1 ) ? bbox.yMin : bbox.yMax, - ( ( i >> 2 ) & 1 ) ? bbox.zMin : bbox.zMax, 1 ); + const QVector4D p( ( ( i >> 0 ) & 1 ) ? bbox.xMin : bbox.xMax, ( ( i >> 1 ) & 1 ) ? bbox.yMin : bbox.yMax, ( ( i >> 2 ) & 1 ) ? bbox.zMin : bbox.zMax, 1 ); const QVector4D pc = viewMatrix * p; - const float dst = -pc.z(); // in camera coordinates, x grows right, y grows down, z grows to the back + const float dst = -pc.z(); // in camera coordinates, x grows right, y grows down, z grows to the back fnear = std::min( fnear, dst ); ffar = std::max( ffar, dst ); } @@ -911,10 +891,14 @@ Qt3DRender::QCullFace::CullingMode Qgs3DUtils::qt3DcullingMode( Qgs3DTypes::Cull { switch ( mode ) { - case Qgs3DTypes::NoCulling: return Qt3DRender::QCullFace::NoCulling; - case Qgs3DTypes::Front: return Qt3DRender::QCullFace::Front; - case Qgs3DTypes::Back: return Qt3DRender::QCullFace::Back; - case Qgs3DTypes::FrontAndBack: return Qt3DRender::QCullFace::FrontAndBack; + case Qgs3DTypes::NoCulling: + return Qt3DRender::QCullFace::NoCulling; + case Qgs3DTypes::Front: + return Qt3DRender::QCullFace::Front; + case Qgs3DTypes::Back: + return Qt3DRender::QCullFace::Back; + case Qgs3DTypes::FrontAndBack: + return Qt3DRender::QCullFace::FrontAndBack; } return Qt3DRender::QCullFace::NoCulling; } @@ -961,15 +945,20 @@ void Qgs3DUtils::decomposeTransformMatrix( const QMatrix4x4 &matrix, QVector3D & // decompose the transform matrix // assuming the last row has values [0 0 0 1] // see https://math.stackexchange.com/questions/237369/given-this-transformation-matrix-how-do-i-decompose-it-into-translation-rotati - const float *md = matrix.data(); // returns data in column-major order + const float *md = matrix.data(); // returns data in column-major order const float sx = QVector3D( md[0], md[1], md[2] ).length(); const float sy = QVector3D( md[4], md[5], md[6] ).length(); const float sz = QVector3D( md[8], md[9], md[10] ).length(); - float rd[9] = - { - md[0] / sx, md[4] / sy, md[8] / sz, - md[1] / sx, md[5] / sy, md[9] / sz, - md[2] / sx, md[6] / sy, md[10] / sz, + float rd[9] = { + md[0] / sx, + md[4] / sy, + md[8] / sz, + md[1] / sx, + md[5] / sy, + md[9] / sz, + md[2] / sx, + md[6] / sy, + md[10] / sz, }; const QMatrix3x3 rot3x3( rd ); // takes data in row-major order diff --git a/src/3d/qgs3dutils.h b/src/3d/qgs3dutils.h index a5bcb89130f..f95058c0a8c 100644 --- a/src/3d/qgs3dutils.h +++ b/src/3d/qgs3dutils.h @@ -58,7 +58,6 @@ class Qgs3DRenderContext; class _3D_EXPORT Qgs3DUtils { public: - /** * Captures image of the current 3D scene of a 3D engine. The function waits * until the scene is not fully loaded/updated before capturing the image. @@ -101,15 +100,7 @@ class _3D_EXPORT Qgs3DUtils * * \since QGIS 3.8 */ - static bool exportAnimation( const Qgs3DAnimationSettings &animationSettings, - Qgs3DMapSettings &mapSettings, - int framesPerSecond, - const QString &outputDirectory, - const QString &fileNameTemplate, - const QSize &outputSize, - QString &error, - QgsFeedback *feedback = nullptr - ); + static bool exportAnimation( const Qgs3DAnimationSettings &animationSettings, Qgs3DMapSettings &mapSettings, int framesPerSecond, const QString &outputDirectory, const QString &fileNameTemplate, const QSize &outputSize, QString &error, QgsFeedback *feedback = nullptr ); /** * Calculates the highest needed zoom level for tiles in quad-tree given width of the base tile (zoom level 0) @@ -189,8 +180,7 @@ class _3D_EXPORT Qgs3DUtils static QgsRectangle worldToMapExtent( const QgsAABB &bbox, const QgsVector3D &mapOrigin ); //! Transforms a world point from (origin1, crs1) to (origin2, crs2) - static QgsVector3D transformWorldCoordinates( const QgsVector3D &worldPoint1, const QgsVector3D &origin1, const QgsCoordinateReferenceSystem &crs1, const QgsVector3D &origin2, const QgsCoordinateReferenceSystem &crs2, - const QgsCoordinateTransformContext &context ); + static QgsVector3D transformWorldCoordinates( const QgsVector3D &worldPoint1, const QgsVector3D &origin1, const QgsCoordinateReferenceSystem &crs1, const QgsVector3D &origin2, const QgsCoordinateReferenceSystem &crs2, const QgsCoordinateTransformContext &context ); /** * Try to estimate range of Z values used in the given vector layer and store that in zMin and zMax. @@ -254,7 +244,7 @@ class _3D_EXPORT Qgs3DUtils * \note This function was formerly in Qgs3DAppUtils * \since QGIS 3.26 */ - static std::unique_ptr< QgsPointCloudLayer3DRenderer > convert2DPointCloudRendererTo3D( QgsPointCloudRenderer *renderer ); + static std::unique_ptr convert2DPointCloudRendererTo3D( QgsPointCloudRenderer *renderer ); /** * Casts a \a ray through the \a scene and returns information about the intersecting entities (ray uses World coordinates). diff --git a/src/3d/qgs3dwiredmesh_p.cpp b/src/3d/qgs3dwiredmesh_p.cpp index 38c33a8fce0..472cfa07e0c 100644 --- a/src/3d/qgs3dwiredmesh_p.cpp +++ b/src/3d/qgs3dwiredmesh_p.cpp @@ -16,7 +16,7 @@ #include "qgs3dwiredmesh_p.h" #include "moc_qgs3dwiredmesh_p.cpp" -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include typedef Qt3DRender::QAttribute Qt3DQAttribute; diff --git a/src/3d/qgs3dwiredmesh_p.h b/src/3d/qgs3dwiredmesh_p.h index 5f8dd707396..442a15a9b13 100644 --- a/src/3d/qgs3dwiredmesh_p.h +++ b/src/3d/qgs3dwiredmesh_p.h @@ -29,7 +29,7 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #else #include @@ -51,7 +51,6 @@ class Qgs3DWiredMesh : public Qt3DRender::QGeometryRenderer Q_OBJECT public: - /** * \brief Default Qgs3DWiredMesh constructor */ @@ -69,7 +68,7 @@ class Qgs3DWiredMesh : public Qt3DRender::QGeometryRenderer void setVertices( const QList &bboxes ); private: -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) Qt3DRender::QGeometry *mGeom = nullptr; Qt3DRender::QAttribute *mPositionAttribute = nullptr; Qt3DRender::QBuffer *mVertexBuffer = nullptr; diff --git a/src/3d/qgsaabb.cpp b/src/3d/qgsaabb.cpp index 8d73dd53964..85743ecf63a 100644 --- a/src/3d/qgsaabb.cpp +++ b/src/3d/qgsaabb.cpp @@ -34,16 +34,12 @@ QgsAABB::QgsAABB( float xMin, float yMin, float zMin, float xMax, float yMax, fl bool QgsAABB::intersects( const QgsAABB &other ) const { - return xMin < other.xMax && other.xMin < xMax && - yMin < other.yMax && other.yMin < yMax && - zMin < other.zMax && other.zMin < zMax; + return xMin < other.xMax && other.xMin < xMax && yMin < other.yMax && other.yMin < yMax && zMin < other.zMax && other.zMin < zMax; } bool QgsAABB::intersects( float x, float y, float z ) const { - return xMin <= x && xMax >= x && - yMin <= y && yMax >= y && - zMin <= z && zMax >= z; + return xMin <= x && xMax >= x && yMin <= y && yMax >= y && zMin <= z && zMax >= z; } diff --git a/src/3d/qgsabstract3dengine.cpp b/src/3d/qgsabstract3dengine.cpp index a266d4eb2fb..0e3ca333160 100644 --- a/src/3d/qgsabstract3dengine.cpp +++ b/src/3d/qgsabstract3dengine.cpp @@ -24,7 +24,6 @@ QgsAbstract3DEngine::QgsAbstract3DEngine( QObject *parent ) : QObject( parent ) { - } void QgsAbstract3DEngine::requestCaptureImage() @@ -32,8 +31,7 @@ void QgsAbstract3DEngine::requestCaptureImage() Qt3DRender::QRenderCaptureReply *captureReply; captureReply = mFrameGraph->renderCapture()->requestCapture(); - connect( captureReply, &Qt3DRender::QRenderCaptureReply::completed, this, [ = ] - { + connect( captureReply, &Qt3DRender::QRenderCaptureReply::completed, this, [=] { emit imageCaptured( captureReply->image() ); captureReply->deleteLater(); } ); @@ -44,8 +42,7 @@ void QgsAbstract3DEngine::requestDepthBufferCapture() Qt3DRender::QRenderCaptureReply *captureReply; captureReply = mFrameGraph->depthRenderCapture()->requestCapture(); - connect( captureReply, &Qt3DRender::QRenderCaptureReply::completed, this, [ = ] - { + connect( captureReply, &Qt3DRender::QRenderCaptureReply::completed, this, [=] { emit depthBufferCaptured( captureReply->image() ); captureReply->deleteLater(); } ); @@ -65,8 +62,10 @@ void QgsAbstract3DEngine::dumpFrameGraphToConsole() const { if ( mFrameGraph ) { - qDebug() << "FrameGraph:\n" << mFrameGraph->dumpFrameGraph(); - qDebug() << "SceneGraph:\n" << mFrameGraph->dumpSceneGraph(); + qDebug() << "FrameGraph:\n" + << mFrameGraph->dumpFrameGraph(); + qDebug() << "SceneGraph:\n" + << mFrameGraph->dumpSceneGraph(); } } diff --git a/src/3d/qgsabstract3dengine.h b/src/3d/qgsabstract3dengine.h index 6ad313eeced..55eec97055e 100644 --- a/src/3d/qgsabstract3dengine.h +++ b/src/3d/qgsabstract3dengine.h @@ -37,7 +37,7 @@ namespace Qt3DRender class QRenderSettings; class QCamera; class QFrameGraphNode; -} +} // namespace Qt3DRender class QgsFrameGraph; @@ -61,7 +61,6 @@ class _3D_EXPORT QgsAbstract3DEngine : public QObject { Q_OBJECT public: - /** * Constructor for QgsAbstract3DEngine with the specified \a parent object. */ @@ -153,6 +152,7 @@ class _3D_EXPORT QgsAbstract3DEngine : public QObject * \since QGIS 3.30 */ void sizeChanged(); + protected: QgsFrameGraph *mFrameGraph = nullptr; }; diff --git a/src/3d/qgsabstractvectorlayer3drenderer.cpp b/src/3d/qgsabstractvectorlayer3drenderer.cpp index b54af6b1a00..4c564131943 100644 --- a/src/3d/qgsabstractvectorlayer3drenderer.cpp +++ b/src/3d/qgsabstractvectorlayer3drenderer.cpp @@ -18,7 +18,6 @@ #include "qgsvectorlayer.h" - void QgsVectorLayer3DTilingSettings::writeXml( QDomElement &elem ) const { QDomDocument doc = elem.ownerDocument(); diff --git a/src/3d/qgsabstractvectorlayer3drenderer.h b/src/3d/qgsabstractvectorlayer3drenderer.h index 6ed409b407e..ae97007cd8e 100644 --- a/src/3d/qgsabstractvectorlayer3drenderer.h +++ b/src/3d/qgsabstractvectorlayer3drenderer.h @@ -37,7 +37,6 @@ class QgsVectorLayer; class _3D_EXPORT QgsVectorLayer3DTilingSettings { public: - /** * Returns number of zoom levels. One zoom level means there will be one tile. * Every extra zoom level multiplies number of tiles by four. For example, three @@ -100,8 +99,8 @@ class _3D_EXPORT QgsAbstractVectorLayer3DRenderer : public QgsAbstract3DRenderer void readXmlBaseProperties( const QDomElement &elem, const QgsReadWriteContext &context ); private: - QgsMapLayerRef mLayerRef; //!< Layer used to extract polygons from - QgsVectorLayer3DTilingSettings mTilingSettings; //!< How is layer tiled into chunks + QgsMapLayerRef mLayerRef; //!< Layer used to extract polygons from + QgsVectorLayer3DTilingSettings mTilingSettings; //!< How is layer tiled into chunks }; #endif // QGSABSTRACTVECTORLAYER3DRENDERER_H diff --git a/src/3d/qgsambientocclusionblurentity.h b/src/3d/qgsambientocclusionblurentity.h index 3afb9e622a7..a7d3c908afc 100644 --- a/src/3d/qgsambientocclusionblurentity.h +++ b/src/3d/qgsambientocclusionblurentity.h @@ -34,6 +34,7 @@ class QgsAmbientOcclusionBlurEntity : public QgsRenderPassQuad public: //! Constructor QgsAmbientOcclusionBlurEntity( Qt3DRender::QTexture2D *texture, Qt3DRender::QLayer *layer, QNode *parent = nullptr ); + private: Qt3DRender::QParameter *mAmbientOcclusionFactorTextureParameter = nullptr; }; diff --git a/src/3d/qgsambientocclusionrenderentity.cpp b/src/3d/qgsambientocclusionrenderentity.cpp index 334b564beab..cab15d8a42a 100644 --- a/src/3d/qgsambientocclusionrenderentity.cpp +++ b/src/3d/qgsambientocclusionrenderentity.cpp @@ -28,32 +28,27 @@ QgsAmbientOcclusionRenderEntity::QgsAmbientOcclusionRenderEntity( Qt3DRender::QT mFarPlaneParameter = new Qt3DRender::QParameter( QStringLiteral( "farPlane" ), camera->farPlane() ); mMaterial->addParameter( mFarPlaneParameter ); - connect( camera, &Qt3DRender::QCamera::farPlaneChanged, mFarPlaneParameter, [&]( float farPlane ) - { + connect( camera, &Qt3DRender::QCamera::farPlaneChanged, mFarPlaneParameter, [&]( float farPlane ) { mFarPlaneParameter->setValue( farPlane ); } ); mNearPlaneParameter = new Qt3DRender::QParameter( QStringLiteral( "nearPlane" ), camera->nearPlane() ); mMaterial->addParameter( mNearPlaneParameter ); - connect( camera, &Qt3DRender::QCamera::nearPlaneChanged, mNearPlaneParameter, [&]( float nearPlane ) - { + connect( camera, &Qt3DRender::QCamera::nearPlaneChanged, mNearPlaneParameter, [&]( float nearPlane ) { mNearPlaneParameter->setValue( nearPlane ); } ); mProjMatrixParameter = new Qt3DRender::QParameter( QStringLiteral( "origProjMatrix" ), camera->projectionMatrix() ); mMaterial->addParameter( mProjMatrixParameter ); - connect( camera, &Qt3DRender::QCamera::projectionMatrixChanged, mProjMatrixParameter, [&]( const QMatrix4x4 & projectionMatrix ) - { + connect( camera, &Qt3DRender::QCamera::projectionMatrixChanged, mProjMatrixParameter, [&]( const QMatrix4x4 &projectionMatrix ) { mProjMatrixParameter->setValue( projectionMatrix ); } ); mAspectRatioParameter = new Qt3DRender::QParameter( QStringLiteral( "uAspectRatio" ), camera->aspectRatio() ); mMaterial->addParameter( mAspectRatioParameter ); - connect( camera, &Qt3DRender::QCamera::aspectRatioChanged, mAspectRatioParameter, [&]( float ratio ) - { + connect( camera, &Qt3DRender::QCamera::aspectRatioChanged, mAspectRatioParameter, [&]( float ratio ) { mAspectRatioParameter->setValue( ratio ); } ); mTanHalfFovParameter = new Qt3DRender::QParameter( QStringLiteral( "uTanHalfFov" ), tan( camera->fieldOfView() / 2 * M_PI / 180 ) ); mMaterial->addParameter( mTanHalfFovParameter ); - connect( camera, &Qt3DRender::QCamera::fieldOfViewChanged, mTanHalfFovParameter, [&]( float fov ) - { + connect( camera, &Qt3DRender::QCamera::fieldOfViewChanged, mTanHalfFovParameter, [&]( float fov ) { mTanHalfFovParameter->setValue( tan( fov / 2 * M_PI / 180 ) ); } ); @@ -70,7 +65,7 @@ QgsAmbientOcclusionRenderEntity::QgsAmbientOcclusionRenderEntity( Qt3DRender::QT randomFloats( generator ) * 2.0 - 1.0 ); sample.normalize(); - float scale = static_cast< float >( i ) / static_cast< float >( kernelSize ); + float scale = static_cast( i ) / static_cast( kernelSize ); scale = 0.1 + 0.9 * scale * scale; sample *= scale; ssaoKernelValues.push_back( sample ); diff --git a/src/3d/qgsambientocclusionrenderentity.h b/src/3d/qgsambientocclusionrenderentity.h index 6478fbdaabf..c4dcf87ba4f 100644 --- a/src/3d/qgsambientocclusionrenderentity.h +++ b/src/3d/qgsambientocclusionrenderentity.h @@ -45,7 +45,6 @@ class QgsAmbientOcclusionRenderEntity : public QgsRenderPassQuad void setThreshold( float threshold ); private: - Qt3DRender::QParameter *mDepthTextureParameter = nullptr; Qt3DRender::QParameter *mAmbientOcclusionKernelParameter = nullptr; diff --git a/src/3d/qgsambientocclusionsettings.cpp b/src/3d/qgsambientocclusionsettings.cpp index 8a140fdfddf..b12d42a2cec 100644 --- a/src/3d/qgsambientocclusionsettings.cpp +++ b/src/3d/qgsambientocclusionsettings.cpp @@ -26,7 +26,6 @@ QgsAmbientOcclusionSettings::QgsAmbientOcclusionSettings( const QgsAmbientOcclus , mRadius( other.mRadius ) , mThreshold( other.mThreshold ) { - } QgsAmbientOcclusionSettings &QgsAmbientOcclusionSettings::operator=( QgsAmbientOcclusionSettings const &rhs ) diff --git a/src/3d/qgsambientocclusionsettings.h b/src/3d/qgsambientocclusionsettings.h index 8ca9e6afc6e..8a6f7faf024 100644 --- a/src/3d/qgsambientocclusionsettings.h +++ b/src/3d/qgsambientocclusionsettings.h @@ -35,7 +35,6 @@ class QDomElement; class _3D_EXPORT QgsAmbientOcclusionSettings { public: - QgsAmbientOcclusionSettings() = default; QgsAmbientOcclusionSettings( const QgsAmbientOcclusionSettings &other ); QgsAmbientOcclusionSettings &operator=( QgsAmbientOcclusionSettings const &rhs ); diff --git a/src/3d/qgscameracontroller.cpp b/src/3d/qgscameracontroller.cpp index 62f35355f4b..b06d61fc672 100644 --- a/src/3d/qgscameracontroller.cpp +++ b/src/3d/qgscameracontroller.cpp @@ -38,28 +38,20 @@ QgsCameraController::QgsCameraController( Qgs3DMapScene *scene ) , mOrigin( scene->mapSettings()->origin() ) { mMouseHandler->setSourceDevice( new Qt3DInput::QMouseDevice() ); - connect( mMouseHandler, &Qt3DInput::QMouseHandler::positionChanged, - this, &QgsCameraController::onPositionChanged ); - connect( mMouseHandler, &Qt3DInput::QMouseHandler::wheel, - this, &QgsCameraController::onWheel ); - connect( mMouseHandler, &Qt3DInput::QMouseHandler::pressed, - this, &QgsCameraController::onMousePressed ); - connect( mMouseHandler, &Qt3DInput::QMouseHandler::released, - this, &QgsCameraController::onMouseReleased ); + connect( mMouseHandler, &Qt3DInput::QMouseHandler::positionChanged, this, &QgsCameraController::onPositionChanged ); + connect( mMouseHandler, &Qt3DInput::QMouseHandler::wheel, this, &QgsCameraController::onWheel ); + connect( mMouseHandler, &Qt3DInput::QMouseHandler::pressed, this, &QgsCameraController::onMousePressed ); + connect( mMouseHandler, &Qt3DInput::QMouseHandler::released, this, &QgsCameraController::onMouseReleased ); addComponent( mMouseHandler ); mKeyboardHandler->setSourceDevice( new Qt3DInput::QKeyboardDevice() ); - connect( mKeyboardHandler, &Qt3DInput::QKeyboardHandler::pressed, - this, &QgsCameraController::onKeyPressed ); - connect( mKeyboardHandler, &Qt3DInput::QKeyboardHandler::released, - this, &QgsCameraController::onKeyReleased ); + connect( mKeyboardHandler, &Qt3DInput::QKeyboardHandler::pressed, this, &QgsCameraController::onKeyPressed ); + connect( mKeyboardHandler, &Qt3DInput::QKeyboardHandler::released, this, &QgsCameraController::onKeyReleased ); addComponent( mKeyboardHandler ); // Disable the handlers when the entity is disabled - connect( this, &Qt3DCore::QEntity::enabledChanged, - mMouseHandler, &Qt3DInput::QMouseHandler::setEnabled ); - connect( this, &Qt3DCore::QEntity::enabledChanged, - mKeyboardHandler, &Qt3DInput::QKeyboardHandler::setEnabled ); + connect( this, &Qt3DCore::QEntity::enabledChanged, mMouseHandler, &Qt3DInput::QMouseHandler::setEnabled ); + connect( this, &Qt3DCore::QEntity::enabledChanged, mKeyboardHandler, &Qt3DInput::QKeyboardHandler::setEnabled ); mFpsNavTimer = new QTimer( this ); mFpsNavTimer->setInterval( 10 ); @@ -107,9 +99,9 @@ void QgsCameraController::rotateCamera( float diffPitch, float diffYaw ) const float yaw = mCameraPose.headingAngle(); if ( pitch + diffPitch > 180 ) - diffPitch = 180 - pitch; // prevent going over the head + diffPitch = 180 - pitch; // prevent going over the head if ( pitch + diffPitch < 0 ) - diffPitch = 0 - pitch; // prevent going over the head + diffPitch = 0 - pitch; // prevent going over the head // Is it always going to be love/hate relationship with quaternions??? // This quaternion combines two rotations: @@ -117,10 +109,8 @@ void QgsCameraController::rotateCamera( float diffPitch, float diffYaw ) // - then it applies new rotation // (We can't just apply our euler angles difference because the camera may be already rotated) // BONUS: we use two separate fromEulerAngles() calls because one would not do rotations in order we need - const QQuaternion q1 = QQuaternion::fromEulerAngles( 0, 0, yaw + diffYaw ) * - QQuaternion::fromEulerAngles( pitch + diffPitch, 0, 0 ); - const QQuaternion q2 = QQuaternion::fromEulerAngles( 0, 0, yaw ) * - QQuaternion::fromEulerAngles( pitch, 0, 0 ); + const QQuaternion q1 = QQuaternion::fromEulerAngles( 0, 0, yaw + diffYaw ) * QQuaternion::fromEulerAngles( pitch + diffPitch, 0, 0 ); + const QQuaternion q2 = QQuaternion::fromEulerAngles( 0, 0, yaw ) * QQuaternion::fromEulerAngles( pitch, 0, 0 ); const QQuaternion q = q1 * q2.conjugated(); // get camera's view vector, rotate it to get new view center @@ -386,7 +376,7 @@ void QgsCameraController::onPositionChangedTerrainNavigation( Qt3DInput::QMouseE setMouseParameters( MouseOperation::RotationCamera ); // rotate/tilt using mouse (camera stays at one position as it rotates) const float diffPitch = 0.2f * dy; - const float diffYaw = - 0.2f * dx; + const float diffYaw = -0.2f * dx; rotateCamera( diffPitch, diffYaw ); } else if ( hasLeftButton && !hasShift && !hasCtrl ) @@ -407,7 +397,6 @@ void QgsCameraController::onPositionChangedTerrainNavigation( Qt3DInput::QMouseE mDragPoint = worldPosition; mDragPointCalculated = true; } - } QVector3D cameraBeforeDragPos = mCameraBefore->position(); @@ -480,14 +469,14 @@ void QgsCameraController::onPositionChangedTerrainNavigation( Qt3DInput::QMouseE // Applies smoothing if ( mMousePos.y() > mClickPoint.y() ) // zoom in { - double f = ( double )( mMousePos.y() - mClickPoint.y() ) / ( double )( screenHeight - mClickPoint.y() - yOffset ); + double f = ( double ) ( mMousePos.y() - mClickPoint.y() ) / ( double ) ( screenHeight - mClickPoint.y() - yOffset ); f = std::max( 0.0, std::min( 1.0, f ) ); f = 1 - ( std::expm1( -2 * f ) ) / ( std::expm1( -2 ) ); dist = dist * f; } else // zoom out { - double f = 1 - ( double )( mMousePos.y() + yOffset ) / ( double )( mClickPoint.y() + yOffset ); + double f = 1 - ( double ) ( mMousePos.y() + yOffset ) / ( double ) ( mClickPoint.y() + yOffset ); f = std::max( 0.0, std::min( 1.0, f ) ); f = ( std::expm1( 2 * f ) ) / ( std::expm1( 2 ) ); dist = dist + 2 * dist * f; @@ -595,7 +584,6 @@ void QgsCameraController::onWheel( Qt3DInput::QWheelEvent *wheel ) case Qgis::NavigationMode::TerrainBased: { - const float scaling = ( ( wheel->modifiers() & Qt::ControlModifier ) != 0 ? 0.5f : 5.f ); // Apparently angleDelta needs to be accumulated @@ -619,20 +607,15 @@ void QgsCameraController::onMousePressed( Qt3DInput::QMouseEvent *mouse ) { mKeyboardHandler->setFocus( true ); - if ( mouse->button() == Qt3DInput::QMouseEvent::MiddleButton || - ( ( mouse->modifiers() & Qt::ShiftModifier ) != 0 && mouse->button() == Qt3DInput::QMouseEvent::LeftButton ) || - ( ( mouse->modifiers() & Qt::ControlModifier ) != 0 && mouse->button() == Qt3DInput::QMouseEvent::LeftButton ) ) + if ( mouse->button() == Qt3DInput::QMouseEvent::MiddleButton || ( ( mouse->modifiers() & Qt::ShiftModifier ) != 0 && mouse->button() == Qt3DInput::QMouseEvent::LeftButton ) || ( ( mouse->modifiers() & Qt::ControlModifier ) != 0 && mouse->button() == Qt3DInput::QMouseEvent::LeftButton ) ) { mMousePos = QPoint( mouse->x(), mouse->y() ); if ( mCaptureFpsMouseMovements ) mIgnoreNextMouseMove = true; - const MouseOperation operation - { - ( mouse->modifiers() & Qt::ControlModifier ) != 0 && mouse->button() == Qt3DInput::QMouseEvent::LeftButton ? - MouseOperation::RotationCamera : - MouseOperation::RotationCenter + const MouseOperation operation { + ( mouse->modifiers() & Qt::ControlModifier ) != 0 && mouse->button() == Qt3DInput::QMouseEvent::LeftButton ? MouseOperation::RotationCamera : MouseOperation::RotationCenter }; setMouseParameters( operation, mMousePos ); } @@ -734,8 +717,8 @@ void QgsCameraController::onKeyPressedTerrainNavigation( Qt3DInput::QKeyEvent *e else if ( hasCtrl && !hasShift ) { // rotate/tilt using keyboard (camera stays at one position as it rotates) - const float diffPitch = ty; // down key = rotating camera down - const float diffYaw = -tx; // right key = rotating camera to the right + const float diffPitch = ty; // down key = rotating camera down + const float diffYaw = -tx; // right key = rotating camera to the right rotateCamera( diffPitch, diffYaw ); } } @@ -918,7 +901,7 @@ void QgsCameraController::onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent break; } - const float diffYaw = - 0.2f * dx; + const float diffYaw = -0.2f * dx; rotateCamera( diffPitch, diffYaw ); } else if ( mouse->buttons() & Qt::LeftButton ) @@ -934,7 +917,7 @@ void QgsCameraController::onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent case Qgis::VerticalAxisInversion::Never: break; } - const float diffYaw = - 0.2f * dx; + const float diffYaw = -0.2f * dx; rotateCamera( diffPitch, diffYaw ); } } @@ -960,7 +943,7 @@ void QgsCameraController::tiltUpAroundViewCenter( float deltaPitch ) { // Tilt up the view by deltaPitch around the view center (camera moves) float pitch = mCameraPose.pitchAngle(); - pitch -= deltaPitch; // down key = moving camera toward terrain + pitch -= deltaPitch; // down key = moving camera toward terrain mCameraPose.setPitchAngle( pitch ); updateCameraFromPose(); } @@ -969,7 +952,7 @@ void QgsCameraController::rotateAroundViewCenter( float deltaYaw ) { // Rotate clockwise the view by deltaYaw around the view center (camera moves) float yaw = mCameraPose.headingAngle(); - yaw -= deltaYaw; // right key = moving camera clockwise + yaw -= deltaYaw; // right key = moving camera clockwise mCameraPose.setHeadingAngle( yaw ); updateCameraFromPose(); } @@ -1067,8 +1050,7 @@ void QgsCameraController::depthBufferCaptured( const QImage &depthImage ) bool QgsCameraController::isATranslationRotationSequence( MouseOperation newOperation ) const { - return std::find( mTranslateOrRotate.begin(), mTranslateOrRotate.end(), newOperation ) != std::end( mTranslateOrRotate ) && - std::find( mTranslateOrRotate.begin(), mTranslateOrRotate.end(), mCurrentOperation ) != std::end( mTranslateOrRotate ); + return std::find( mTranslateOrRotate.begin(), mTranslateOrRotate.end(), newOperation ) != std::end( mTranslateOrRotate ) && std::find( mTranslateOrRotate.begin(), mTranslateOrRotate.end(), mCurrentOperation ) != std::end( mTranslateOrRotate ); } void QgsCameraController::setMouseParameters( const MouseOperation &newOperation, const QPoint &clickPoint ) diff --git a/src/3d/qgscameracontroller.h b/src/3d/qgscameracontroller.h index 636538cbe9f..e756ca6458a 100644 --- a/src/3d/qgscameracontroller.h +++ b/src/3d/qgscameracontroller.h @@ -30,7 +30,7 @@ namespace Qt3DInput class QMouseEvent; class QMouseHandler; class QWheelEvent; -} +} // namespace Qt3DInput namespace Qt3DRender { @@ -63,7 +63,6 @@ class _3D_EXPORT QgsCameraController : public QObject Q_OBJECT public: - //! Constructs the camera controller with optional parent node that will take ownership QgsCameraController( Qgs3DMapScene *scene ) SIP_SKIP; ~QgsCameraController() override; @@ -244,8 +243,7 @@ class _3D_EXPORT QgsCameraController : public QObject // This list gathers all the rotation and translation operations. // It is used to update the appropriate parameters when successive // translation and rotation happen. - const QList mTranslateOrRotate = - { + const QList mTranslateOrRotate = { MouseOperation::Translation, MouseOperation::RotationCamera, MouseOperation::RotationCenter @@ -332,7 +330,7 @@ class _3D_EXPORT QgsCameraController : public QObject bool mDepthBufferIsReady = false; QImage mDepthBufferImage; - std::unique_ptr< Qt3DRender::QCamera > mCameraBefore; + std::unique_ptr mCameraBefore; bool mRotationCenterCalculated = false; QVector3D mRotationCenter; @@ -353,7 +351,7 @@ class _3D_EXPORT QgsCameraController : public QObject Qgis::VerticalAxisInversion mVerticalAxisInversion = Qgis::VerticalAxisInversion::WhenDragging; double mCameraMovementSpeed = 5.0; - QSet< int > mDepressedKeys; + QSet mDepressedKeys; bool mCaptureFpsMouseMovements = false; bool mIgnoreNextMouseMove = false; QTimer *mFpsNavTimer = nullptr; diff --git a/src/3d/qgscamerapose.cpp b/src/3d/qgscamerapose.cpp index 76c79ecb0d5..f868db7b213 100644 --- a/src/3d/qgscamerapose.cpp +++ b/src/3d/qgscamerapose.cpp @@ -64,7 +64,7 @@ void QgsCameraPose::setPitchAngle( float pitch ) // With a mPitchAngle < 0.2 or > 179.8, QQuaternion::fromEulerAngles( mPitchAngle, mHeadingAngle, 0 ) // will return bad rotation angle in Qt5. // See https://bugreports.qt.io/browse/QTBUG-72103 -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) mPitchAngle = std::clamp( pitch, 0.2f, 179.8f ); #else mPitchAngle = std::clamp( pitch, 0.0f, 180.0f ); @@ -75,8 +75,7 @@ void QgsCameraPose::updateCamera( Qt3DRender::QCamera *camera ) { // first rotate by pitch angle around X axis, then by heading angle around Z axis // (we use two separate fromEulerAngles() calls because one would not do rotations in order we need) - QQuaternion q = QQuaternion::fromEulerAngles( 0, 0, mHeadingAngle ) * - QQuaternion::fromEulerAngles( mPitchAngle, 0, 0 ); + QQuaternion q = QQuaternion::fromEulerAngles( 0, 0, mHeadingAngle ) * QQuaternion::fromEulerAngles( mPitchAngle, 0, 0 ); QVector3D cameraToCenter = q * QVector3D( 0, 0, -mDistanceFromCenterPoint ); camera->setUpVector( q * QVector3D( 0, 1, 0 ) ); camera->setPosition( mCenterPoint.toVector3D() - cameraToCenter ); diff --git a/src/3d/qgscamerapose.h b/src/3d/qgscamerapose.h index 3e5664bba83..6dcf99bc2b7 100644 --- a/src/3d/qgscamerapose.h +++ b/src/3d/qgscamerapose.h @@ -46,7 +46,6 @@ class QDomElement; class _3D_EXPORT QgsCameraPose { public: - //! Returns center point (towards which point the camera is looking) QgsVector3D centerPoint() const { return mCenterPoint; } //! Sets center point (towards which point the camera is looking) @@ -78,10 +77,7 @@ class _3D_EXPORT QgsCameraPose // TODO c++20 - replace with = default bool operator==( const QgsCameraPose &other ) const { - return mCenterPoint == other.mCenterPoint && - mDistanceFromCenterPoint == other.mDistanceFromCenterPoint && - mPitchAngle == other.mPitchAngle && - mHeadingAngle == other.mHeadingAngle; + return mCenterPoint == other.mCenterPoint && mDistanceFromCenterPoint == other.mDistanceFromCenterPoint && mPitchAngle == other.mPitchAngle && mHeadingAngle == other.mHeadingAngle; } bool operator!=( const QgsCameraPose &other ) const { @@ -98,7 +94,7 @@ class _3D_EXPORT QgsCameraPose // With a mPitchAngle < 0.2 or > 179.8, QQuaternion::fromEulerAngles( mPitchAngle, mHeadingAngle, 0 ) // will return bad rotation angle. // See https://bugreports.qt.io/browse/QTBUG-72103 -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) float mPitchAngle = 0.2f; #else float mPitchAngle = 0.0f; diff --git a/src/3d/qgscolorramptexture.cpp b/src/3d/qgscolorramptexture.cpp index ae2f1e18c02..f3a609a2a69 100644 --- a/src/3d/qgscolorramptexture.cpp +++ b/src/3d/qgscolorramptexture.cpp @@ -38,7 +38,7 @@ Qt3DRender::QTextureImageDataPtr QgsColorRampTextureGenerator::operator()() QByteArray data; const QList colorItemList = mColorRampShader.colorRampItemList(); - const int size = colorItemList.count() ; + const int size = colorItemList.count(); dataPtr->setWidth( size ); dataPtr->setHeight( 1 ); @@ -81,11 +81,8 @@ bool QgsColorRampTextureGenerator::operator==( const Qt3DRender::QTextureImageDa // ColorRampTexture QgsColorRampTexture::QgsColorRampTexture( const QgsColorRampShader &colorRampShader, double verticalScale, Qt3DCore::QNode *parent ) - : Qt3DRender::QAbstractTextureImage( parent ), - mColorRampShader( colorRampShader ), - mVerticalScale( verticalScale ) + : Qt3DRender::QAbstractTextureImage( parent ), mColorRampShader( colorRampShader ), mVerticalScale( verticalScale ) { - } Qt3DRender::QTextureImageDataGeneratorPtr QgsColorRampTexture::dataGenerator() const diff --git a/src/3d/qgscolorramptexture.h b/src/3d/qgscolorramptexture.h index 84ee28807d4..bfada997755 100644 --- a/src/3d/qgscolorramptexture.h +++ b/src/3d/qgscolorramptexture.h @@ -35,16 +35,15 @@ #define SIP_NO_FILE -class QgsColorRampTextureGenerator: public Qt3DRender::QTextureImageDataGenerator +class QgsColorRampTextureGenerator : public Qt3DRender::QTextureImageDataGenerator { - public: QgsColorRampTextureGenerator( const QgsColorRampShader &colorRampShader, double verticalScale = 1 ); public: Qt3DRender::QTextureImageDataPtr operator()() override; - bool operator ==( const Qt3DRender::QTextureImageDataGenerator &other ) const override; + bool operator==( const Qt3DRender::QTextureImageDataGenerator &other ) const override; // marked as deprecated in 5.15, but undeprecated for Qt 6.0. TODO -- remove when we require 6.0 Q_NOWARN_DEPRECATED_PUSH @@ -57,7 +56,7 @@ class QgsColorRampTextureGenerator: public Qt3DRender::QTextureImageDataGenerato }; -class QgsColorRampTexture: public Qt3DRender::QAbstractTextureImage +class QgsColorRampTexture : public Qt3DRender::QAbstractTextureImage { Q_OBJECT diff --git a/src/3d/qgsfgutils.cpp b/src/3d/qgsfgutils.cpp index a279b21cdd7..6552edc5635 100644 --- a/src/3d/qgsfgutils.cpp +++ b/src/3d/qgsfgutils.cpp @@ -51,16 +51,14 @@ QString QgsFgUtils::formatIdName( FgDumpContext context, const Qt3DRender::QAbst { QString fixedName = texture->objectName().isEmpty() ? QLatin1String( "" ) : texture->objectName(); return QLatin1String( "{%1[%2]/%3" ) - .arg( QString::number( texture->id().id() - context.lowestId ) - , QString( QMetaEnum::fromType().valueToKey( texture->format() ) ) - , fixedName ); + .arg( QString::number( texture->id().id() - context.lowestId ), QString( QMetaEnum::fromType().valueToKey( texture->format() ) ), fixedName ); } QString QgsFgUtils::formatNode( FgDumpContext context, const Qt3DCore::QNode *node ) { QString res = QLatin1String( "(%1%2)" ) - .arg( QLatin1String( node->metaObject()->className() ) ) - .arg( formatIdName( context, node->id().id(), node->objectName() ) ); + .arg( QLatin1String( node->metaObject()->className() ) ) + .arg( formatIdName( context, node->id().id(), node->objectName() ) ); if ( !node->isEnabled() ) res += QLatin1String( " [D]" ); return res; @@ -96,8 +94,7 @@ QString QgsFgUtils::formatField( const QString &name, const QString &value ) QString QgsFgUtils::dumpSGEntity( FgDumpContext context, const Qt3DCore::QEntity *node, int level ) { - auto extractTextureParam = []( FgDumpContext context, const QVector ¶ms, QStringList & fl ) - { + auto extractTextureParam = []( FgDumpContext context, const QVector ¶ms, QStringList &fl ) { for ( const auto *param : params ) { if ( strstr( param->value().typeName(), "QAbstractTexture*" ) ) @@ -111,7 +108,7 @@ QString QgsFgUtils::dumpSGEntity( FgDumpContext context, const Qt3DCore::QEntity QString res = formatNode( context, node ); const auto &components = node->components(); - if ( ! components.isEmpty() ) + if ( !components.isEmpty() ) { QStringList componentNames; for ( const auto &comp : components ) @@ -126,8 +123,9 @@ QString QgsFgUtils::dumpSGEntity( FgDumpContext context, const Qt3DCore::QEntity for ( const auto *texImg : texImages ) { fl += formatField( - texImg->metaObject()->className(), - formatIdName( context, texImg->id().id(), texImg->objectName() ) ); + texImg->metaObject()->className(), + formatIdName( context, texImg->id().id(), texImg->objectName() ) + ); } } } @@ -192,16 +190,14 @@ QString QgsFgUtils::dumpFGNode( FgDumpContext context, const Qt3DRender::QFrameG } QStringList fl; - fl += formatField( QMetaEnum::fromType().valueToKey( lf->filterMode() ) - , formatList( sl ) ); + fl += formatField( QMetaEnum::fromType().valueToKey( lf->filterMode() ), formatList( sl ) ); res += QString( " %1" ).arg( formatList( fl ) ); } else if ( const auto *cs = qobject_cast( node ) ) { QStringList fl; - fl += formatField( cs->camera()->metaObject()->className(), - formatIdName( context, cs->camera()->id().id(), cs->camera()->objectName() ) ); + fl += formatField( cs->camera()->metaObject()->className(), formatIdName( context, cs->camera()->id().id(), cs->camera()->objectName() ) ); res += QString( " %1" ).arg( formatList( fl ) ); } @@ -277,12 +273,10 @@ QString QgsFgUtils::dumpFGNode( FgDumpContext context, const Qt3DRender::QFrameG const auto outputs = rs->target()->outputs(); for ( auto output : outputs ) { - sl += formatField( QMetaEnum::fromType().valueToKey( output->attachmentPoint() ), - formatIdName( context, output->texture() ) ); + sl += formatField( QMetaEnum::fromType().valueToKey( output->attachmentPoint() ), formatIdName( context, output->texture() ) ); } QStringList fl; - fl += formatField( QLatin1String( "outputs" ), - formatList( sl ) ); + fl += formatField( QLatin1String( "outputs" ), formatList( sl ) ); res += QString( " %1" ).arg( formatList( fl ) ); } } diff --git a/src/3d/qgsfgutils.h b/src/3d/qgsfgutils.h index 613ccbc8692..20c19f8f75a 100644 --- a/src/3d/qgsfgutils.h +++ b/src/3d/qgsfgutils.h @@ -47,10 +47,9 @@ class QgsFgUtils { public: - struct FgDumpContext { - quint64 lowestId = 0; + quint64 lowestId = 0; }; //! Returns a tree view of the scene graph starting from \a node. The object ids will be given relatively to the \a context lowestId. diff --git a/src/3d/qgsframegraph.cpp b/src/3d/qgsframegraph.cpp index 988a7cf6f1e..76c6ae09041 100644 --- a/src/3d/qgsframegraph.cpp +++ b/src/3d/qgsframegraph.cpp @@ -22,7 +22,7 @@ #include "qgsambientocclusionrenderentity.h" #include "qgsambientocclusionblurentity.h" -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -379,7 +379,8 @@ Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructAmbientOcclusionRenderPass( mAmbientOcclusionRenderStateSet = new Qt3DRender::QRenderStateSet( mAmbientOcclusionRenderCameraSelector ); Qt3DRender::QDepthTest *depthRenderDepthTest = new Qt3DRender::QDepthTest; - depthRenderDepthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );; + depthRenderDepthTest->setDepthFunction( Qt3DRender::QDepthTest::Always ); + ; Qt3DRender::QCullFace *depthRenderCullFace = new Qt3DRender::QCullFace; depthRenderCullFace->setMode( Qt3DRender::QCullFace::NoCulling ); @@ -427,7 +428,8 @@ Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructAmbientOcclusionBlurPass() mAmbientOcclusionBlurStateSet = new Qt3DRender::QRenderStateSet( mAmbientOcclusionBlurCameraSelector ); Qt3DRender::QDepthTest *depthRenderDepthTest = new Qt3DRender::QDepthTest; - depthRenderDepthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );; + depthRenderDepthTest->setDepthFunction( Qt3DRender::QDepthTest::Always ); + ; Qt3DRender::QCullFace *depthRenderCullFace = new Qt3DRender::QCullFace; depthRenderCullFace->setMode( Qt3DRender::QCullFace::NoCulling ); @@ -491,7 +493,6 @@ Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructRubberBandsPass() } - Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructDepthRenderPass() { // depth buffer render to copy pass @@ -503,7 +504,8 @@ Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructDepthRenderPass() mDepthRenderStateSet = new Qt3DRender::QRenderStateSet( mDepthRenderCameraSelector ); Qt3DRender::QDepthTest *depthRenderDepthTest = new Qt3DRender::QDepthTest; - depthRenderDepthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );; + depthRenderDepthTest->setDepthFunction( Qt3DRender::QDepthTest::Always ); + ; Qt3DRender::QCullFace *depthRenderCullFace = new Qt3DRender::QCullFace; depthRenderCullFace->setMode( Qt3DRender::QCullFace::NoCulling ); @@ -563,7 +565,7 @@ Qt3DCore::QEntity *QgsFrameGraph::constructDepthRenderQuad() Qt3DQGeometry *geom = new Qt3DQGeometry; Qt3DQAttribute *positionAttribute = new Qt3DQAttribute; - const QVector vert = { -1.0f, -1.0f, 1.0f, /**/ 1.0f, -1.0f, 1.0f, /**/ -1.0f, 1.0f, 1.0f, /**/ -1.0f, 1.0f, 1.0f, /**/ 1.0f, -1.0f, 1.0f, /**/ 1.0f, 1.0f, 1.0f }; + const QVector vert = { -1.0f, -1.0f, 1.0f, /**/ 1.0f, -1.0f, 1.0f, /**/ -1.0f, 1.0f, 1.0f, /**/ -1.0f, 1.0f, 1.0f, /**/ 1.0f, -1.0f, 1.0f, /**/ 1.0f, 1.0f, 1.0f }; const QByteArray vertexArr( ( const char * ) vert.constData(), vert.size() * sizeof( float ) ); Qt3DQBuffer *vertexBuffer = nullptr; @@ -629,7 +631,6 @@ QgsFrameGraph::QgsFrameGraph( QSurface *surface, QSize s, Qt3DRender::QCamera *m : Qt3DCore::QEntity( root ) , mSize( s ) { - // general overview of how the frame graph looks: // // +------------------------+ using window or @@ -680,7 +681,7 @@ QgsFrameGraph::QgsFrameGraph( QSurface *surface, QSize s, Qt3DRender::QCamera *m mRenderSurfaceSelector = new Qt3DRender::QRenderSurfaceSelector; - QObject *surfaceObj = dynamic_cast< QObject * >( surface ); + QObject *surfaceObj = dynamic_cast( surface ); Q_ASSERT( surfaceObj ); mRenderSurfaceSelector->setSurface( surfaceObj ); @@ -751,21 +752,20 @@ void calculateViewExtent( Qt3DRender::QCamera *camera, float shadowRenderingDist const QMatrix4x4 projectionMatrix = camera->projectionMatrix(); const QMatrix4x4 viewMatrix = camera->viewMatrix(); float depth = 1.0f; - QVector4D viewCenter = viewMatrix * QVector4D( camera->viewCenter(), 1.0f ); + QVector4D viewCenter = viewMatrix * QVector4D( camera->viewCenter(), 1.0f ); viewCenter /= viewCenter.w(); viewCenter = projectionMatrix * viewCenter; viewCenter /= viewCenter.w(); depth = viewCenter.z(); - QVector viewFrustumPoints = - { - QVector3D( 0.0f, 0.0f, depth ), - QVector3D( 0.0f, 1.0f, depth ), - QVector3D( 1.0f, 0.0f, depth ), - QVector3D( 1.0f, 1.0f, depth ), - QVector3D( 0.0f, 0.0f, 0 ), - QVector3D( 0.0f, 1.0f, 0 ), - QVector3D( 1.0f, 0.0f, 0 ), - QVector3D( 1.0f, 1.0f, 0 ) + QVector viewFrustumPoints = { + QVector3D( 0.0f, 0.0f, depth ), + QVector3D( 0.0f, 1.0f, depth ), + QVector3D( 1.0f, 0.0f, depth ), + QVector3D( 1.0f, 1.0f, depth ), + QVector3D( 0.0f, 0.0f, 0 ), + QVector3D( 0.0f, 1.0f, 0 ), + QVector3D( 1.0f, 0.0f, 0 ), + QVector3D( 1.0f, 1.0f, 0 ) }; maxX = std::numeric_limits::lowest(); maxY = std::numeric_limits::lowest(); @@ -822,9 +822,10 @@ void QgsFrameGraph::setupDirectionalLight( const QgsDirectionalLightSettings &li mLightCamera->setProjectionType( Qt3DRender::QCameraLens::ProjectionType::OrthographicProjection ); mLightCamera->lens()->setOrthographicProjection( - - 0.7f * ( maxX - minX ), 0.7f * ( maxX - minX ), - - 0.7f * ( maxY - minY ), 0.7f * ( maxY - minY ), - 1.0f, 2 * ( lookingAt - lightPosition ).length() ); + -0.7f * ( maxX - minX ), 0.7f * ( maxX - minX ), + -0.7f * ( maxY - minY ), 0.7f * ( maxY - minY ), + 1.0f, 2 * ( lookingAt - lightPosition ).length() + ); mPostprocessingEntity->setupShadowRenderingExtent( minX, maxX, minY, maxY ); mPostprocessingEntity->setupDirectionalLight( lightPosition, lightDirection ); @@ -910,7 +911,7 @@ void QgsFrameGraph::setFrustumCullingEnabled( bool enabled ) if ( mFrustumCullingEnabled ) mFrustumCulling->setParent( mForwardClearBuffers ); else - mFrustumCulling->setParent( ( Qt3DCore::QNode * )nullptr ); + mFrustumCulling->setParent( ( Qt3DCore::QNode * ) nullptr ); } void QgsFrameGraph::setupEyeDomeLighting( bool enabled, double strength, int distance ) @@ -1021,5 +1022,4 @@ void QgsFrameGraph::addClipPlanes( int nrClipPlanes ) clipPlane->setPlaneIndex( i ); mClipRenderStateSet->addRenderState( clipPlane ); } - } diff --git a/src/3d/qgsgltf3dutils.cpp b/src/3d/qgsgltf3dutils.cpp index 09c75092c81..165dc152ead 100644 --- a/src/3d/qgsgltf3dutils.cpp +++ b/src/3d/qgsgltf3dutils.cpp @@ -25,7 +25,7 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -137,7 +137,7 @@ static Qt3DQAttribute *parseAttribute( tinygltf::Model &model, int accessorIndex attribute->setBuffer( buffer ); attribute->setByteOffset( bv.byteOffset + accessor.byteOffset ); - attribute->setByteStride( bv.byteStride ); // could be zero, it seems that's fine (assuming packed) + attribute->setByteStride( bv.byteStride ); // could be zero, it seems that's fine (assuming packed) attribute->setCount( accessor.count ); attribute->setVertexBaseType( parseVertexBaseType( accessor.componentType ) ); attribute->setVertexSize( tinygltf::GetNumComponentsInType( accessor.type ) ); @@ -166,9 +166,9 @@ static Qt3DQAttribute *reprojectPositions( tinygltf::Model &model, int accessorI double y = vy[i] - sceneOrigin.y(); double z = ( vz[i] * transform.zValueScale ) + transform.zValueOffset - sceneOrigin.z(); - out[i * 3 + 0] = static_cast< float >( x ); - out[i * 3 + 1] = static_cast< float >( y ); - out[i * 3 + 2] = static_cast< float >( z ); + out[i * 3 + 0] = static_cast( x ); + out[i * 3 + 1] = static_cast( y ); + out[i * 3 + 2] = static_cast( z ); } Qt3DQBuffer *buffer = new Qt3DQBuffer(); @@ -203,7 +203,7 @@ class TinyGltfTextureImageDataGenerator : public Qt3DRender::QTextureImageDataGe return mImagePtr; } - bool operator ==( const QTextureImageDataGenerator &other ) const override + bool operator==( const QTextureImageDataGenerator &other ) const override { const TinyGltfTextureImageDataGenerator *otherFunctor = functor_cast( &other ); return mImagePtr.get() == otherFunctor->mImagePtr.get(); diff --git a/src/3d/qgsgltf3dutils.h b/src/3d/qgsgltf3dutils.h index 7aa73657044..fe326139829 100644 --- a/src/3d/qgsgltf3dutils.h +++ b/src/3d/qgsgltf3dutils.h @@ -33,8 +33,8 @@ #include "qgsmatrix4x4.h" -#define TINYGLTF_NO_STB_IMAGE // we use QImage-based reading of images -#define TINYGLTF_NO_STB_IMAGE_WRITE // we don't need writing of images +#define TINYGLTF_NO_STB_IMAGE // we use QImage-based reading of images +#define TINYGLTF_NO_STB_IMAGE_WRITE // we don't need writing of images #include "tiny_gltf.h" class QgsCoordinateTransform; @@ -54,22 +54,21 @@ namespace Qt3DCore class _3D_EXPORT QgsGltf3DUtils { public: - //! Helper struct to keep track of transforms to be applied to positions struct EntityTransform { - //! chunk's origin in coordinates of the target CRS - QgsVector3D chunkOriginTargetCrs; - //! Tile's matrix to transform GLTF model coordinates to ECEF (normally EPSG:4978) - QgsMatrix4x4 tileTransform; - //! Transform from ECEF (normally EPSG:4978) to the target CRS - const QgsCoordinateTransform *ecefToTargetCrs = nullptr; + //! chunk's origin in coordinates of the target CRS + QgsVector3D chunkOriginTargetCrs; + //! Tile's matrix to transform GLTF model coordinates to ECEF (normally EPSG:4978) + QgsMatrix4x4 tileTransform; + //! Transform from ECEF (normally EPSG:4978) to the target CRS + const QgsCoordinateTransform *ecefToTargetCrs = nullptr; - //! Axis to treat as up axis in the GLTF model - Qgis::Axis gltfUpAxis = Qgis::Axis::Y; + //! Axis to treat as up axis in the GLTF model + Qgis::Axis gltfUpAxis = Qgis::Axis::Y; - double zValueScale = 1; - double zValueOffset = 0; + double zValueScale = 1; + double zValueOffset = 0; }; /** @@ -92,7 +91,6 @@ class _3D_EXPORT QgsGltf3DUtils * \see gltfToEntity() */ static Qt3DCore::QEntity *parsedGltfToEntity( tinygltf::Model &model, const QgsGltf3DUtils::EntityTransform &transform, QString baseUri, QStringList *errors ); - }; ///@endcond diff --git a/src/3d/qgsimagetexture.h b/src/3d/qgsimagetexture.h index 7d389ff83a3..42d99740c8c 100644 --- a/src/3d/qgsimagetexture.h +++ b/src/3d/qgsimagetexture.h @@ -51,9 +51,7 @@ class _3D_EXPORT QgsImageTexture : public Qt3DRender::QPaintedTextureImage QImage getImage() const { return mImage; } private: - QImage mImage; - }; #endif // QGSIMAGETEXTURE_H diff --git a/src/3d/qgslayoutitem3dmap.cpp b/src/3d/qgslayoutitem3dmap.cpp index 8d91e580017..724972e2b90 100644 --- a/src/3d/qgslayoutitem3dmap.cpp +++ b/src/3d/qgslayoutitem3dmap.cpp @@ -147,8 +147,7 @@ void QgsLayoutItem3DMap::draw( QgsLayoutItemRenderContext &context ) } QSizeF sizePixels = mLayout->renderContext().measurementConverter().convert( sizeWithUnits(), Qgis::LayoutUnit::Pixels ).toQSizeF(); - QSize sizePixelsInt = QSize( static_cast( std::ceil( sizePixels.width() ) ), - static_cast( std::ceil( sizePixels.height() ) ) ); + QSize sizePixelsInt = QSize( static_cast( std::ceil( sizePixels.width() ) ), static_cast( std::ceil( sizePixels.height() ) ) ); if ( isTemporal() ) mSettings->setTemporalRange( temporalRange() ); @@ -163,7 +162,6 @@ void QgsLayoutItem3DMap::draw( QgsLayoutItemRenderContext &context ) connect( mScene, &Qgs3DMapScene::sceneStateChanged, this, &QgsLayoutItem3DMap::onSceneStateChanged ); mEngine->setRootEntity( mScene ); - } if ( mEngine->size() != sizePixelsInt ) diff --git a/src/3d/qgslayoutitem3dmap.h b/src/3d/qgslayoutitem3dmap.h index d974ad5ff17..913422b80e6 100644 --- a/src/3d/qgslayoutitem3dmap.h +++ b/src/3d/qgslayoutitem3dmap.h @@ -26,11 +26,11 @@ // this is needed for the "convert to subclass" code below to compile % ModuleHeaderCode #include "qgslayoutitem3dmap.h" -% End + % End #endif -class Qgs3DMapScene; + class Qgs3DMapScene; class Qgs3DMapSettings; class QgsOffscreen3DEngine; @@ -63,7 +63,6 @@ class _3D_EXPORT QgsLayoutItem3DMap : public QgsLayoutItem, public QgsTemporalRa #endif public: - /** * Constructor for QgsLayoutItem3DMap, with the specified parent \a layout. * @@ -127,7 +126,7 @@ class _3D_EXPORT QgsLayoutItem3DMap : public QgsLayoutItem, public QgsTemporalRa private: std::unique_ptr mSettings; std::unique_ptr mEngine; - Qgs3DMapScene *mScene = nullptr; //!< 3D scene (owned by the 3D engine) + Qgs3DMapScene *mScene = nullptr; //!< 3D scene (owned by the 3D engine) QImage mCapturedImage; QgsCameraPose mCameraPose; bool mDrawing = false; diff --git a/src/3d/qgsmeshlayer3drenderer.cpp b/src/3d/qgsmeshlayer3drenderer.cpp index a705f73a350..2e3470a62fd 100644 --- a/src/3d/qgsmeshlayer3drenderer.cpp +++ b/src/3d/qgsmeshlayer3drenderer.cpp @@ -46,7 +46,7 @@ QgsMeshLayer3DRenderer::QgsMeshLayer3DRenderer( QgsMesh3DSymbol *s ) QgsMeshLayer3DRenderer *QgsMeshLayer3DRenderer::clone() const { - QgsMeshLayer3DRenderer *r = new QgsMeshLayer3DRenderer( mSymbol ? ( QgsMesh3DSymbol * )mSymbol->clone() : nullptr ); + QgsMeshLayer3DRenderer *r = new QgsMeshLayer3DRenderer( mSymbol ? ( QgsMesh3DSymbol * ) mSymbol->clone() : nullptr ); r->mLayerRef = mLayerRef; return r; } @@ -78,8 +78,7 @@ Qt3DCore::QEntity *QgsMeshLayer3DRenderer::createEntity( Qgs3DMapSettings *map ) if ( !meshLayer || !meshLayer->dataProvider() ) return nullptr; - if ( meshLayer->dataProvider()->contains( QgsMesh::ElementType::Edge ) || - !mSymbol->isEnabled() ) + if ( meshLayer->dataProvider()->contains( QgsMesh::ElementType::Edge ) || !mSymbol->isEnabled() ) { // 3D not implemented for 1D meshes return nullptr; diff --git a/src/3d/qgsmeshlayer3drenderer.h b/src/3d/qgsmeshlayer3drenderer.h index f13ce50ec02..4b75014af24 100644 --- a/src/3d/qgsmeshlayer3drenderer.h +++ b/src/3d/qgsmeshlayer3drenderer.h @@ -82,8 +82,8 @@ class _3D_EXPORT QgsMeshLayer3DRenderer : public QgsAbstract3DRenderer private: - QgsMapLayerRef mLayerRef; //!< Layer used to extract mesh data from - std::unique_ptr mSymbol; //!< 3D symbol that defines appearance + QgsMapLayerRef mLayerRef; //!< Layer used to extract mesh data from + std::unique_ptr mSymbol; //!< 3D symbol that defines appearance private: #ifdef SIP_RUN diff --git a/src/3d/qgsoffscreen3dengine.cpp b/src/3d/qgsoffscreen3dengine.cpp index a6daf7686d8..65a14f62c42 100644 --- a/src/3d/qgsoffscreen3dengine.cpp +++ b/src/3d/qgsoffscreen3dengine.cpp @@ -49,7 +49,7 @@ QgsOffscreen3DEngine::QgsOffscreen3DEngine() // Set up the engine and the aspects that we want to use. mAspectEngine = new Qt3DCore::QAspectEngine(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) mRenderAspect = new Qt3DRender::QRenderAspect( Qt3DRender::QRenderAspect::Threaded ); // Only threaded mode seems to work right now. #else mRenderAspect = new Qt3DRender::QRenderAspect(); @@ -110,7 +110,6 @@ QgsOffscreen3DEngine::QgsOffscreen3DEngine() // Set the root entity of the engine. This causes the engine to begin running. mAspectEngine->setRootEntity( Qt3DCore::QEntityPtr( mRoot ) ); - } QgsOffscreen3DEngine::~QgsOffscreen3DEngine() diff --git a/src/3d/qgsoffscreen3dengine.h b/src/3d/qgsoffscreen3dengine.h index 2c41ed7a4cb..1ce4a2418bc 100644 --- a/src/3d/qgsoffscreen3dengine.h +++ b/src/3d/qgsoffscreen3dengine.h @@ -26,7 +26,7 @@ namespace Qt3DCore { class QAspectEngine; class QNode; -} +} // namespace Qt3DCore namespace Qt3DRender { @@ -39,7 +39,7 @@ namespace Qt3DRender class QRenderSurfaceSelector; class QTexture2D; class QViewport; -} +} // namespace Qt3DRender namespace Qt3DLogic { @@ -79,17 +79,16 @@ class _3D_EXPORT QgsOffscreen3DEngine : public QgsAbstract3DEngine QSurface *surface() const override; private: - QSize mSize = QSize( 640, 480 ); Qt3DRender::QCamera *mCamera = nullptr; QOffscreenSurface *mOffscreenSurface = nullptr; // basic Qt3D stuff - Qt3DCore::QAspectEngine *mAspectEngine = nullptr; // The aspect engine, which holds the scene and related aspects. - Qt3DRender::QRenderAspect *mRenderAspect = nullptr; // The render aspect, which deals with rendering the scene. - Qt3DLogic::QLogicAspect *mLogicAspect = nullptr; // The logic aspect, which runs jobs to do with synchronising frames. - Qt3DRender::QRenderSettings *mRenderSettings = nullptr; // The render settings, which control the general rendering behavior. - Qt3DCore::QNode *mSceneRoot = nullptr; // The scene root, which becomes a child of the engine's root entity. + Qt3DCore::QAspectEngine *mAspectEngine = nullptr; // The aspect engine, which holds the scene and related aspects. + Qt3DRender::QRenderAspect *mRenderAspect = nullptr; // The render aspect, which deals with rendering the scene. + Qt3DLogic::QLogicAspect *mLogicAspect = nullptr; // The logic aspect, which runs jobs to do with synchronising frames. + Qt3DRender::QRenderSettings *mRenderSettings = nullptr; // The render settings, which control the general rendering behavior. + Qt3DCore::QNode *mSceneRoot = nullptr; // The scene root, which becomes a child of the engine's root entity. Qt3DCore::QEntity *mRoot = nullptr; }; diff --git a/src/3d/qgspointcloudlayer3drenderer.cpp b/src/3d/qgspointcloudlayer3drenderer.cpp index b04adc63733..c3525d1ff07 100644 --- a/src/3d/qgspointcloudlayer3drenderer.cpp +++ b/src/3d/qgspointcloudlayer3drenderer.cpp @@ -116,7 +116,7 @@ QgsAbstract3DRenderer *QgsPointCloudLayer3DRendererMetadata::createRenderer( QDo // --------- -QgsPointCloudLayer3DRenderer::QgsPointCloudLayer3DRenderer( ) +QgsPointCloudLayer3DRenderer::QgsPointCloudLayer3DRenderer() { } @@ -161,15 +161,11 @@ Qt3DCore::QEntity *QgsPointCloudLayer3DRenderer::createEntity( Qgs3DMapSettings Qt3DCore::QEntity *entity = nullptr; if ( pcl->dataProvider()->index() ) { - entity = new QgsPointCloudLayerChunkedEntity( map, pcl->dataProvider()->index(), coordinateTransform, dynamic_cast( mSymbol->clone() ), static_cast< float >( maximumScreenError() ), showBoundingBoxes(), - static_cast< const QgsPointCloudLayerElevationProperties * >( pcl->elevationProperties() )->zScale(), - static_cast< const QgsPointCloudLayerElevationProperties * >( pcl->elevationProperties() )->zOffset(), mPointBudget ); + entity = new QgsPointCloudLayerChunkedEntity( map, pcl->dataProvider()->index(), coordinateTransform, dynamic_cast( mSymbol->clone() ), static_cast( maximumScreenError() ), showBoundingBoxes(), static_cast( pcl->elevationProperties() )->zScale(), static_cast( pcl->elevationProperties() )->zOffset(), mPointBudget ); } else if ( !pcl->dataProvider()->subIndexes().isEmpty() ) { - entity = new QgsVirtualPointCloudEntity( map, pcl, coordinateTransform, dynamic_cast( mSymbol->clone() ), static_cast< float >( maximumScreenError() ), showBoundingBoxes(), - static_cast< const QgsPointCloudLayerElevationProperties * >( pcl->elevationProperties() )->zScale(), - static_cast< const QgsPointCloudLayerElevationProperties * >( pcl->elevationProperties() )->zOffset(), mPointBudget ); + entity = new QgsVirtualPointCloudEntity( map, pcl, coordinateTransform, dynamic_cast( mSymbol->clone() ), static_cast( maximumScreenError() ), showBoundingBoxes(), static_cast( pcl->elevationProperties() )->zScale(), static_cast( pcl->elevationProperties() )->zOffset(), mPointBudget ); } return entity; } @@ -257,7 +253,7 @@ void QgsPointCloudLayer3DRenderer::setPointRenderingBudget( int budget ) bool QgsPointCloudLayer3DRenderer::convertFrom2DRenderer( QgsPointCloudRenderer *renderer ) { - std::unique_ptr< QgsPointCloudLayer3DRenderer > renderer3D = Qgs3DUtils::convert2DPointCloudRendererTo3D( renderer ); + std::unique_ptr renderer3D = Qgs3DUtils::convert2DPointCloudRendererTo3D( renderer ); if ( !renderer3D ) { setSymbol( nullptr ); @@ -265,8 +261,8 @@ bool QgsPointCloudLayer3DRenderer::convertFrom2DRenderer( QgsPointCloudRenderer } QgsPointCloud3DSymbol *newSymbol = const_cast( - static_cast( renderer3D->symbol()->clone() ) - ); + static_cast( renderer3D->symbol()->clone() ) + ); // we need to retain some settings from the previous symbol, like point size const QgsPointCloud3DSymbol *oldSymbol = symbol(); if ( oldSymbol ) diff --git a/src/3d/qgspointcloudlayer3drenderer.h b/src/3d/qgspointcloudlayer3drenderer.h index 3fe2431a82d..ec6482e8de0 100644 --- a/src/3d/qgspointcloudlayer3drenderer.h +++ b/src/3d/qgspointcloudlayer3drenderer.h @@ -41,7 +41,6 @@ class QgsPointCloudLayer; class _3D_NO_EXPORT QgsPointCloud3DRenderContext : public Qgs3DRenderContext { public: - /** * Constructor for QgsPointCloud3DRenderContext. * @@ -51,8 +50,7 @@ class _3D_NO_EXPORT QgsPointCloud3DRenderContext : public Qgs3DRenderContext * The \a zValueFixedOffset argument specifies any constant offset value which must be added to z values * taken from the point cloud index. */ - QgsPointCloud3DRenderContext( const Qgs3DRenderContext &context, const QgsCoordinateTransform &coordinateTransform, std::unique_ptr< QgsPointCloud3DSymbol > symbol, - double zValueScale, double zValueFixedOffset ); + QgsPointCloud3DRenderContext( const Qgs3DRenderContext &context, const QgsCoordinateTransform &coordinateTransform, std::unique_ptr symbol, double zValueScale, double zValueFixedOffset ); QgsPointCloud3DRenderContext( const QgsPointCloud3DRenderContext &rh ) = delete; QgsPointCloud3DRenderContext &operator=( const QgsPointCloud3DRenderContext & ) = delete; @@ -101,46 +99,46 @@ class _3D_NO_EXPORT QgsPointCloud3DRenderContext : public Qgs3DRenderContext * Retrieves the attribute \a value from \a data at the specified \a offset, where * \a type indicates the original data type for the attribute. */ - template + template void getAttribute( const char *data, std::size_t offset, QgsPointCloudAttribute::DataType type, T &value ) const { switch ( type ) { case QgsPointCloudAttribute::UChar: - value = *reinterpret_cast< const unsigned char * >( data + offset ); + value = *reinterpret_cast( data + offset ); return; case QgsPointCloudAttribute::Char: value = *( data + offset ); return; case QgsPointCloudAttribute::Int32: - value = *reinterpret_cast< const qint32 * >( data + offset ); + value = *reinterpret_cast( data + offset ); return; case QgsPointCloudAttribute::UInt32: - value = *reinterpret_cast< const quint32 * >( data + offset ); + value = *reinterpret_cast( data + offset ); return; case QgsPointCloudAttribute::Int64: - value = *reinterpret_cast< const qint64 * >( data + offset ); + value = *reinterpret_cast( data + offset ); return; case QgsPointCloudAttribute::UInt64: - value = *reinterpret_cast< const quint64 * >( data + offset ); + value = *reinterpret_cast( data + offset ); return; case QgsPointCloudAttribute::Short: - value = *reinterpret_cast< const short * >( data + offset ); + value = *reinterpret_cast( data + offset ); return; case QgsPointCloudAttribute::UShort: - value = *reinterpret_cast< const unsigned short * >( data + offset ); + value = *reinterpret_cast( data + offset ); return; case QgsPointCloudAttribute::Float: - value = *reinterpret_cast< const float * >( data + offset ); + value = *reinterpret_cast( data + offset ); return; case QgsPointCloudAttribute::Double: - value = *reinterpret_cast< const double * >( data + offset ); + value = *reinterpret_cast( data + offset ); return; } } @@ -307,7 +305,7 @@ class _3D_EXPORT QgsPointCloudLayer3DRenderer : public QgsAbstractPointCloud3DRe private: QgsMapLayerRef mLayerRef; //!< Layer used to extract mesh data from - std::unique_ptr< QgsPointCloud3DSymbol > mSymbol; + std::unique_ptr mSymbol; double mMaximumScreenError = 3.0; bool mShowBoundingBoxes = false; int mPointBudget = 5000000; diff --git a/src/3d/qgspointcloudlayerchunkloader_p.cpp b/src/3d/qgspointcloudlayerchunkloader_p.cpp index f7e8a4519c2..d1da768719e 100644 --- a/src/3d/qgspointcloudlayerchunkloader_p.cpp +++ b/src/3d/qgspointcloudlayerchunkloader_p.cpp @@ -32,7 +32,7 @@ #include "qgsraycastingutils_p.h" #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #else #include @@ -47,13 +47,11 @@ /////////////// -QgsPointCloudLayerChunkLoader::QgsPointCloudLayerChunkLoader( const QgsPointCloudLayerChunkLoaderFactory *factory, QgsChunkNode *node, std::unique_ptr< QgsPointCloud3DSymbol > symbol, - const QgsCoordinateTransform &coordinateTransform, double zValueScale, double zValueOffset ) +QgsPointCloudLayerChunkLoader::QgsPointCloudLayerChunkLoader( const QgsPointCloudLayerChunkLoaderFactory *factory, QgsChunkNode *node, std::unique_ptr symbol, const QgsCoordinateTransform &coordinateTransform, double zValueScale, double zValueOffset ) : QgsChunkLoader( node ) , mFactory( factory ) , mContext( factory->mRenderContext, coordinateTransform, std::move( symbol ), zValueScale, zValueOffset ) { - QgsPointCloudIndex *pc = mFactory->mPointCloudIndex; mContext.setAttributes( pc->attributes() ); @@ -84,8 +82,7 @@ QgsPointCloudLayerChunkLoader::QgsPointCloudLayerChunkLoader( const QgsPointClou connect( mFutureWatcher, &QFutureWatcher::finished, this, &QgsChunkQueueJob::finished ); const QgsBox3D box3D = node->box3D(); - const QFuture future = QtConcurrent::run( [pc, pcNode, box3D, this] - { + const QFuture future = QtConcurrent::run( [pc, pcNode, box3D, this] { const QgsEventTracing::ScopedEvent e( QStringLiteral( "3D" ), QStringLiteral( "PC chunk load" ) ); if ( mContext.isCanceled() ) @@ -140,8 +137,7 @@ Qt3DCore::QEntity *QgsPointCloudLayerChunkLoader::createEntity( Qt3DCore::QEntit /////////////// -QgsPointCloudLayerChunkLoaderFactory::QgsPointCloudLayerChunkLoaderFactory( const Qgs3DRenderContext &context, const QgsCoordinateTransform &coordinateTransform, QgsPointCloudIndex *pc, QgsPointCloud3DSymbol *symbol, - double zValueScale, double zValueOffset, int pointBudget ) +QgsPointCloudLayerChunkLoaderFactory::QgsPointCloudLayerChunkLoaderFactory( const Qgs3DRenderContext &context, const QgsCoordinateTransform &coordinateTransform, QgsPointCloudIndex *pc, QgsPointCloud3DSymbol *symbol, double zValueScale, double zValueOffset, int pointBudget ) : mRenderContext( context ) , mCoordinateTransform( coordinateTransform ) , mPointCloudIndex( pc ) @@ -167,8 +163,8 @@ QgsChunkLoader *QgsPointCloudLayerChunkLoaderFactory::createChunkLoader( QgsChun const QgsChunkNodeId id = node->tileId(); Q_ASSERT( mPointCloudIndex->hasNode( QgsPointCloudNodeId( id.d, id.x, id.y, id.z ) ) ); - QgsPointCloud3DSymbol *symbol = static_cast< QgsPointCloud3DSymbol * >( mSymbol->clone() ); - return new QgsPointCloudLayerChunkLoader( this, node, std::unique_ptr< QgsPointCloud3DSymbol >( symbol ), mCoordinateTransform, mZValueScale, mZValueOffset ); + QgsPointCloud3DSymbol *symbol = static_cast( mSymbol->clone() ); + return new QgsPointCloudLayerChunkLoader( this, node, std::unique_ptr( symbol ), mCoordinateTransform, mZValueScale, mZValueOffset ); } int QgsPointCloudLayerChunkLoaderFactory::primitivesCount( QgsChunkNode *node ) const @@ -182,12 +178,8 @@ int QgsPointCloudLayerChunkLoaderFactory::primitivesCount( QgsChunkNode *node ) static QgsBox3D nodeBoundsToBox3D( QgsBox3D nodeBounds, const QgsCoordinateTransform &coordinateTransform, double zValueOffset, double zValueScale ) { - QgsVector3D extentMin3D( nodeBounds.xMinimum(), - nodeBounds.yMinimum(), - nodeBounds.zMinimum() * zValueScale + zValueOffset ); - QgsVector3D extentMax3D( nodeBounds.xMaximum(), - nodeBounds.yMaximum(), - nodeBounds.zMaximum() * zValueScale + zValueOffset ); + QgsVector3D extentMin3D( nodeBounds.xMinimum(), nodeBounds.yMinimum(), nodeBounds.zMinimum() * zValueScale + zValueOffset ); + QgsVector3D extentMax3D( nodeBounds.xMaximum(), nodeBounds.yMaximum(), nodeBounds.zMaximum() * zValueScale + zValueOffset ); QgsCoordinateTransform extentTransform = coordinateTransform; extentTransform.setBallparkTransformsAreAppropriate( true ); try @@ -199,8 +191,7 @@ static QgsBox3D nodeBoundsToBox3D( QgsBox3D nodeBounds, const QgsCoordinateTrans { QgsDebugError( QStringLiteral( "Error transforming node bounds coordinate" ) ); } - return QgsBox3D( extentMin3D.x(), extentMin3D.y(), extentMin3D.z(), - extentMax3D.x(), extentMax3D.y(), extentMax3D.z() ); + return QgsBox3D( extentMin3D.x(), extentMin3D.y(), extentMin3D.z(), extentMax3D.x(), extentMax3D.y(), extentMax3D.z() ); } @@ -231,8 +222,7 @@ QVector QgsPointCloudLayerChunkLoaderFactory::createChildren( Qg continue; const QgsPointCloudNode childNode = mPointCloudIndex->getNode( childPcId ); const QgsBox3D childBounds = childNode.bounds(); - if ( !mExtent.isEmpty() && - !childBounds.intersects( mExtent ) ) + if ( !mExtent.isEmpty() && !childBounds.intersects( mExtent ) ) continue; QgsBox3D childBox3D = nodeBoundsToBox3D( childBounds, mCoordinateTransform, mZValueOffset, mZValueScale ); @@ -247,14 +237,8 @@ QVector QgsPointCloudLayerChunkLoaderFactory::createChildren( Qg /////////////// -QgsPointCloudLayerChunkedEntity::QgsPointCloudLayerChunkedEntity( Qgs3DMapSettings *map, QgsPointCloudIndex *pc, - const QgsCoordinateTransform &coordinateTransform, QgsPointCloud3DSymbol *symbol, - float maximumScreenSpaceError, bool showBoundingBoxes, - double zValueScale, double zValueOffset, - int pointBudget ) - : QgsChunkedEntity( map, - maximumScreenSpaceError, - new QgsPointCloudLayerChunkLoaderFactory( Qgs3DRenderContext::fromMapSettings( map ), coordinateTransform, pc, symbol, zValueScale, zValueOffset, pointBudget ), true, pointBudget ) +QgsPointCloudLayerChunkedEntity::QgsPointCloudLayerChunkedEntity( Qgs3DMapSettings *map, QgsPointCloudIndex *pc, const QgsCoordinateTransform &coordinateTransform, QgsPointCloud3DSymbol *symbol, float maximumScreenSpaceError, bool showBoundingBoxes, double zValueScale, double zValueOffset, int pointBudget ) + : QgsChunkedEntity( map, maximumScreenSpaceError, new QgsPointCloudLayerChunkLoaderFactory( Qgs3DRenderContext::fromMapSettings( map ), coordinateTransform, pc, symbol, zValueScale, zValueOffset, pointBudget ), true, pointBudget ) { setShowBoundingBoxes( showBoundingBoxes ); } @@ -290,7 +274,7 @@ QVector QgsPointCloudLayerChunkedEntity::rayIntersec const double limitAngle = 2. * pointSize / screenSizePx * factory->mRenderContext.fieldOfView(); // adjust ray to elevation properties - const QgsVector3D adjustedRayOrigin = QgsVector3D( rayOriginMapCoords.x(), rayOriginMapCoords.y(), ( rayOriginMapCoords.z() - factory->mZValueOffset ) / factory->mZValueScale ); + const QgsVector3D adjustedRayOrigin = QgsVector3D( rayOriginMapCoords.x(), rayOriginMapCoords.y(), ( rayOriginMapCoords.z() - factory->mZValueOffset ) / factory->mZValueScale ); QgsVector3D adjustedRayDirection = QgsVector3D( rayDirectionMapCoords.x(), rayDirectionMapCoords.y(), rayDirectionMapCoords.z() / factory->mZValueScale ); adjustedRayDirection.normalize(); @@ -344,7 +328,7 @@ QVector QgsPointCloudLayerChunkedEntity::rayIntersec // calculate the angle between the point and the projected point // similar to QgsRay3D::angleToPoint(), but using doubles const QgsVector3D projPoint = adjustedRayOrigin + adjustedRayDirection * QgsVector3D::dotProduct( point - adjustedRayOrigin, adjustedRayDirection ); - const QgsVector3D v1 = projPoint - adjustedRayOrigin ; + const QgsVector3D v1 = projPoint - adjustedRayOrigin; const QgsVector3D v2 = point - projPoint; double angle = std::atan2( v2.length(), v1.length() ) * 180 / M_PI; if ( angle > limitAngle ) @@ -363,9 +347,9 @@ QVector QgsPointCloudLayerChunkedEntity::rayIntersec // Note : applying elevation properties is done in fromPointCloudIdentificationToIdentifyResults QVariantMap pointAttr = QgsPointCloudAttribute::getAttributeMap( ptr, i * recordSize, blockAttributes ); - pointAttr[ QStringLiteral( "X" ) ] = x; - pointAttr[ QStringLiteral( "Y" ) ] = y; - pointAttr[ QStringLiteral( "Z" ) ] = z; + pointAttr[QStringLiteral( "X" )] = x; + pointAttr[QStringLiteral( "Y" )] = y; + pointAttr[QStringLiteral( "Z" )] = z; const QgsVector3D worldPoint = factory->mRenderContext.mapToWorldCoordinates( point ); QgsRayCastingUtils::RayHit hit( dist, worldPoint.toVector3D(), FID_NULL, pointAttr ); diff --git a/src/3d/qgspointcloudlayerchunkloader_p.h b/src/3d/qgspointcloudlayerchunkloader_p.h index d3baf456343..59c37cfc3fd 100644 --- a/src/3d/qgspointcloudlayerchunkloader_p.h +++ b/src/3d/qgspointcloudlayerchunkloader_p.h @@ -36,7 +36,7 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #else @@ -59,13 +59,11 @@ class QgsPointCloudLayerChunkLoaderFactory : public QgsChunkLoaderFactory Q_OBJECT public: - /** * Constructs the factory * The factory takes ownership over the passed \a symbol */ - QgsPointCloudLayerChunkLoaderFactory( const Qgs3DRenderContext &context, const QgsCoordinateTransform &coordinateTransform, QgsPointCloudIndex *pc, QgsPointCloud3DSymbol *symbol, - double zValueScale, double zValueOffset, int pointBudget ); + QgsPointCloudLayerChunkLoaderFactory( const Qgs3DRenderContext &context, const QgsCoordinateTransform &coordinateTransform, QgsPointCloudIndex *pc, QgsPointCloud3DSymbol *symbol, double zValueScale, double zValueOffset, int pointBudget ); //! Creates loader for the given chunk node. Ownership of the returned is passed to the caller. virtual QgsChunkLoader *createChunkLoader( QgsChunkNode *node ) const override; @@ -75,7 +73,7 @@ class QgsPointCloudLayerChunkLoaderFactory : public QgsChunkLoaderFactory Qgs3DRenderContext mRenderContext; QgsCoordinateTransform mCoordinateTransform; QgsPointCloudIndex *mPointCloudIndex; - std::unique_ptr< QgsPointCloud3DSymbol > mSymbol; + std::unique_ptr mSymbol; double mZValueScale = 1.0; double mZValueOffset = 0; int mPointBudget = 1000000; @@ -97,13 +95,11 @@ class QgsPointCloudLayerChunkLoader : public QgsChunkLoader Q_OBJECT public: - /** * Constructs the loader * QgsPointCloudLayerChunkLoader takes ownership over symbol */ - QgsPointCloudLayerChunkLoader( const QgsPointCloudLayerChunkLoaderFactory *factory, QgsChunkNode *node, std::unique_ptr< QgsPointCloud3DSymbol > symbol, - const QgsCoordinateTransform &coordinateTransform, double zValueScale, double zValueOffset ); + QgsPointCloudLayerChunkLoader( const QgsPointCloudLayerChunkLoaderFactory *factory, QgsChunkNode *node, std::unique_ptr symbol, const QgsCoordinateTransform &coordinateTransform, double zValueScale, double zValueOffset ); ~QgsPointCloudLayerChunkLoader() override; virtual void cancel() override; @@ -131,8 +127,7 @@ class QgsPointCloudLayerChunkedEntity : public QgsChunkedEntity { Q_OBJECT public: - explicit QgsPointCloudLayerChunkedEntity( Qgs3DMapSettings *map, QgsPointCloudIndex *pc, const QgsCoordinateTransform &coordinateTransform, QgsPointCloud3DSymbol *symbol, float maxScreenError, bool showBoundingBoxes, - double zValueScale, double zValueOffset, int pointBudget ); + explicit QgsPointCloudLayerChunkedEntity( Qgs3DMapSettings *map, QgsPointCloudIndex *pc, const QgsCoordinateTransform &coordinateTransform, QgsPointCloud3DSymbol *symbol, float maxScreenError, bool showBoundingBoxes, double zValueScale, double zValueOffset, int pointBudget ); QVector rayIntersection( const QgsRayCastingUtils::Ray3D &ray, const QgsRayCastingUtils::RayCastContext &context ) const override; diff --git a/src/3d/qgspostprocessingentity.cpp b/src/3d/qgspostprocessingentity.cpp index d13ae0eab6f..619f793aa09 100644 --- a/src/3d/qgspostprocessingentity.cpp +++ b/src/3d/qgspostprocessingentity.cpp @@ -16,7 +16,7 @@ #include "qgspostprocessingentity.h" #include "moc_qgspostprocessingentity.cpp" -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -61,27 +61,23 @@ QgsPostprocessingEntity::QgsPostprocessingEntity( QgsFrameGraph *frameGraph, Qt3 mFarPlaneParameter = new Qt3DRender::QParameter( QStringLiteral( "farPlane" ), mMainCamera->farPlane() ); mMaterial->addParameter( mFarPlaneParameter ); - connect( mMainCamera, &Qt3DRender::QCamera::farPlaneChanged, mFarPlaneParameter, [&]( float farPlane ) - { + connect( mMainCamera, &Qt3DRender::QCamera::farPlaneChanged, mFarPlaneParameter, [&]( float farPlane ) { mFarPlaneParameter->setValue( farPlane ); } ); mNearPlaneParameter = new Qt3DRender::QParameter( QStringLiteral( "nearPlane" ), mMainCamera->nearPlane() ); mMaterial->addParameter( mNearPlaneParameter ); - connect( mMainCamera, &Qt3DRender::QCamera::nearPlaneChanged, mNearPlaneParameter, [&]( float nearPlane ) - { + connect( mMainCamera, &Qt3DRender::QCamera::nearPlaneChanged, mNearPlaneParameter, [&]( float nearPlane ) { mNearPlaneParameter->setValue( nearPlane ); } ); mLightFarPlaneParameter = new Qt3DRender::QParameter( QStringLiteral( "lightFarPlane" ), mLightCamera->farPlane() ); mMaterial->addParameter( mLightFarPlaneParameter ); - connect( mLightCamera, &Qt3DRender::QCamera::farPlaneChanged, mLightFarPlaneParameter, [&]( float farPlane ) - { + connect( mLightCamera, &Qt3DRender::QCamera::farPlaneChanged, mLightFarPlaneParameter, [&]( float farPlane ) { mLightFarPlaneParameter->setValue( farPlane ); } ); mLightNearPlaneParameter = new Qt3DRender::QParameter( QStringLiteral( "lightNearPlane" ), mLightCamera->nearPlane() ); mMaterial->addParameter( mLightNearPlaneParameter ); - connect( mLightCamera, &Qt3DRender::QCamera::nearPlaneChanged, mLightNearPlaneParameter, [&]( float nearPlane ) - { + connect( mLightCamera, &Qt3DRender::QCamera::nearPlaneChanged, mLightNearPlaneParameter, [&]( float nearPlane ) { mLightNearPlaneParameter->setValue( nearPlane ); } ); @@ -89,12 +85,10 @@ QgsPostprocessingEntity::QgsPostprocessingEntity( QgsFrameGraph *frameGraph, Qt3 mMaterial->addParameter( mMainCameraInvViewMatrixParameter ); mMainCameraInvProjMatrixParameter = new Qt3DRender::QParameter( QStringLiteral( "invertedCameraProj" ), mMainCamera->projectionMatrix().inverted() ); mMaterial->addParameter( mMainCameraInvProjMatrixParameter ); - connect( mMainCamera, &Qt3DRender::QCamera::projectionMatrixChanged, mMainCameraInvProjMatrixParameter, [&]( const QMatrix4x4 & projectionMatrix ) - { + connect( mMainCamera, &Qt3DRender::QCamera::projectionMatrixChanged, mMainCameraInvProjMatrixParameter, [&]( const QMatrix4x4 &projectionMatrix ) { mMainCameraInvProjMatrixParameter->setValue( projectionMatrix.inverted() ); } ); - connect( mMainCamera, &Qt3DRender::QCamera::viewMatrixChanged, mMainCameraInvViewMatrixParameter, [&]() - { + connect( mMainCamera, &Qt3DRender::QCamera::viewMatrixChanged, mMainCameraInvViewMatrixParameter, [&]() { mMainCameraInvViewMatrixParameter->setValue( mMainCamera->viewMatrix().inverted() ); } ); diff --git a/src/3d/qgspreviewquad.cpp b/src/3d/qgspreviewquad.cpp index b2aae058c58..b8816f79996 100644 --- a/src/3d/qgspreviewquad.cpp +++ b/src/3d/qgspreviewquad.cpp @@ -16,7 +16,7 @@ #include "qgspreviewquad.h" #include "moc_qgspreviewquad.cpp" -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -39,16 +39,13 @@ typedef Qt3DCore::QGeometry Qt3DQGeometry; #include #include -QgsPreviewQuad::QgsPreviewQuad( Qt3DRender::QAbstractTexture *texture, - const QPointF ¢erTexCoords, const QSizeF &sizeTexCoords, - QVector additionalShaderParameters, - Qt3DCore::QEntity *parent ) +QgsPreviewQuad::QgsPreviewQuad( Qt3DRender::QAbstractTexture *texture, const QPointF ¢erTexCoords, const QSizeF &sizeTexCoords, QVector additionalShaderParameters, Qt3DCore::QEntity *parent ) : Qt3DCore::QEntity( parent ) { setObjectName( "Preview Quad" ); Qt3DQGeometry *geom = new Qt3DQGeometry; Qt3DQAttribute *positionAttribute = new Qt3DQAttribute; - const QVector vert = { -1.0f, -1.0f, 1.0f, /**/ 1.0f, -1.0f, 1.0f, /**/ -1.0f, 1.0f, 1.0f, /**/ -1.0f, 1.0f, 1.0f, /**/ 1.0f, -1.0f, 1.0f, /**/ 1.0f, 1.0f, 1.0f }; + const QVector vert = { -1.0f, -1.0f, 1.0f, /**/ 1.0f, -1.0f, 1.0f, /**/ -1.0f, 1.0f, 1.0f, /**/ -1.0f, 1.0f, 1.0f, /**/ 1.0f, -1.0f, 1.0f, /**/ 1.0f, 1.0f, 1.0f }; const QByteArray vertexArr( ( const char * ) vert.constData(), vert.size() * sizeof( float ) ); Qt3DQBuffer *vertexBuffer = nullptr; @@ -93,7 +90,8 @@ QgsPreviewQuadMaterial::QgsPreviewQuadMaterial( Qt3DRender::QAbstractTexture *te addParameter( mTextureParameter ); addParameter( mCenterTextureCoords ); addParameter( mSizeTextureCoords ); - for ( Qt3DRender::QParameter *parameter : additionalShaderParameters ) addParameter( parameter ); + for ( Qt3DRender::QParameter *parameter : additionalShaderParameters ) + addParameter( parameter ); mEffect = new Qt3DRender::QEffect; diff --git a/src/3d/qgspreviewquad.h b/src/3d/qgspreviewquad.h index 48b1beb38c7..233d37cf459 100644 --- a/src/3d/qgspreviewquad.h +++ b/src/3d/qgspreviewquad.h @@ -40,12 +40,12 @@ class QgsPreviewQuadMaterial : public Qt3DRender::QMaterial //! Sets the view port of the quad void setViewPort( QVector2D centerTexCoords, QVector2D sizeTexCoords ); + private: Qt3DRender::QEffect *mEffect = nullptr; Qt3DRender::QParameter *mTextureParameter = nullptr; Qt3DRender::QParameter *mCenterTextureCoords = nullptr; Qt3DRender::QParameter *mSizeTextureCoords = nullptr; - }; /** @@ -60,7 +60,6 @@ class QgsPreviewQuad : public Qt3DCore::QEntity Q_OBJECT public: - /** * \brief Construct an object that displays a texture for debugging purposes (example: depth buffer) * \param texture The texture to be rendered @@ -74,6 +73,7 @@ class QgsPreviewQuad : public Qt3DCore::QEntity //! Sets where the quad will be located on the scene void setViewPort( const QPointF ¢erNDC, const QSizeF &size ); + private: QgsPreviewQuadMaterial *mMaterial = nullptr; }; diff --git a/src/3d/qgsraycastingutils.cpp b/src/3d/qgsraycastingutils.cpp index d78ca007eca..d56d2e0b3f0 100644 --- a/src/3d/qgsraycastingutils.cpp +++ b/src/3d/qgsraycastingutils.cpp @@ -22,7 +22,7 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -44,8 +44,8 @@ typedef Qt3DCore::QGeometry Qt3DQGeometry; namespace QgsRayCastingUtils { -// copied from qt3d/src/render/raycasting/qray3d_p.h + qray3d.cpp -// by KDAB, licensed under the terms of LGPL + // copied from qt3d/src/render/raycasting/qray3d_p.h + qray3d.cpp + // by KDAB, licensed under the terms of LGPL Ray3D::Ray3D() @@ -143,8 +143,7 @@ namespace QgsRayCastingUtils { Q_ASSERT( !m_direction.isNull() ); - return QVector3D::dotProduct( point - m_origin, m_direction ) / - m_direction.lengthSquared(); + return QVector3D::dotProduct( point - m_origin, m_direction ) / m_direction.lengthSquared(); } QVector3D Ray3D::project( QVector3D vector ) const @@ -171,7 +170,7 @@ namespace QgsRayCastingUtils return dbg; } -} +} // namespace QgsRayCastingUtils //////////////////////////////////////////////////////////////////////////// @@ -179,33 +178,49 @@ namespace QgsRayCastingUtils struct box { - box( const QgsAABB &b ) - { - min[0] = b.xMin; min[1] = b.yMin; min[2] = b.zMin; - max[0] = b.xMax; max[1] = b.yMax; max[2] = b.zMax; - } - double min[3]; - double max[3]; + box( const QgsAABB &b ) + { + min[0] = b.xMin; + min[1] = b.yMin; + min[2] = b.zMin; + max[0] = b.xMax; + max[1] = b.yMax; + max[2] = b.zMax; + } + double min[3]; + double max[3]; }; struct ray { - ray( double xO, double yO, double zO, double xD, double yD, double zD ) - { - origin[0] = xO; origin[1] = yO; origin[2] = zO; - dir[0] = xD; dir[1] = yD; dir[2] = zD; - dir_inv[0] = 1 / dir[0]; dir_inv[1] = 1 / dir[1]; dir_inv[2] = 1 / dir[2]; - } - ray( const QgsRayCastingUtils::Ray3D &r ) - { - // ignoring length... - origin[0] = r.origin().x(); origin[1] = r.origin().y(); origin[2] = r.origin().z(); - dir[0] = r.direction().x(); dir[1] = r.direction().y(); dir[2] = r.direction().z(); - dir_inv[0] = 1 / dir[0]; dir_inv[1] = 1 / dir[1]; dir_inv[2] = 1 / dir[2]; - } - double origin[3]; - double dir[3]; - double dir_inv[3]; + ray( double xO, double yO, double zO, double xD, double yD, double zD ) + { + origin[0] = xO; + origin[1] = yO; + origin[2] = zO; + dir[0] = xD; + dir[1] = yD; + dir[2] = zD; + dir_inv[0] = 1 / dir[0]; + dir_inv[1] = 1 / dir[1]; + dir_inv[2] = 1 / dir[2]; + } + ray( const QgsRayCastingUtils::Ray3D &r ) + { + // ignoring length... + origin[0] = r.origin().x(); + origin[1] = r.origin().y(); + origin[2] = r.origin().z(); + dir[0] = r.direction().x(); + dir[1] = r.direction().y(); + dir[2] = r.direction().z(); + dir_inv[0] = 1 / dir[0]; + dir_inv[1] = 1 / dir[1]; + dir_inv[2] = 1 / dir[2]; + } + double origin[3]; + double dir[3]; + double dir_inv[3]; }; // https://tavianator.com/fast-branchless-raybounding-box-intersections/ @@ -240,21 +255,19 @@ namespace QgsRayCastingUtils box b( aabb ); // intersection() does not like yMin==yMax (excludes borders) - if ( b.min[0] == b.max[0] ) b.max[0] += 0.1; - if ( b.min[1] == b.max[1] ) b.max[1] += 0.1; - if ( b.min[2] == b.max[2] ) b.max[2] += 0.1; + if ( b.min[0] == b.max[0] ) + b.max[0] += 0.1; + if ( b.min[1] == b.max[1] ) + b.max[1] += 0.1; + if ( b.min[2] == b.max[2] ) + b.max[2] += 0.1; return intersection( b, ray( r ) ); } -// copied from intersectsSegmentTriangle() from qt3d/src/render/backend/triangleboundingvolume.cpp -// by KDAB, licensed under the terms of LGPL - bool rayTriangleIntersection( const Ray3D &ray, - QVector3D a, - QVector3D b, - QVector3D c, - QVector3D &uvw, - float &t ) + // copied from intersectsSegmentTriangle() from qt3d/src/render/backend/triangleboundingvolume.cpp + // by KDAB, licensed under the terms of LGPL + bool rayTriangleIntersection( const Ray3D &ray, QVector3D a, QVector3D b, QVector3D c, QVector3D &uvw, float &t ) { // Note: a, b, c in clockwise order // RealTime Collision Detection page 192 @@ -295,11 +308,7 @@ namespace QgsRayCastingUtils return true; } - bool rayMeshIntersection( Qt3DRender::QGeometryRenderer *geometryRenderer, - const QgsRayCastingUtils::Ray3D &r, - const QMatrix4x4 &worldTransform, - QVector3D &intPt, - int &triangleIndex ) + bool rayMeshIntersection( Qt3DRender::QGeometryRenderer *geometryRenderer, const QgsRayCastingUtils::Ray3D &r, const QMatrix4x4 &worldTransform, QVector3D &intPt, int &triangleIndex ) { if ( geometryRenderer->primitiveType() != Qt3DRender::QGeometryRenderer::Triangles ) { @@ -336,7 +345,7 @@ namespace QgsRayCastingUtils if ( positionAttr->vertexBaseType() != Qt3DQAttribute::Float || positionAttr->vertexSize() != 3 ) { - QgsDebugError( QString( "Unsupported position attribute: base type %1, vertex size %2" ). arg( positionAttr->vertexBaseType() ).arg( positionAttr->vertexSize() ) ); + QgsDebugError( QString( "Unsupported position attribute: base type %1, vertex size %2" ).arg( positionAttr->vertexBaseType() ).arg( positionAttr->vertexSize() ) ); return false; } @@ -440,8 +449,7 @@ namespace QgsRayCastingUtils // We're testing both triangle orientations here and ignoring the culling mode. // We should probably respect the culling mode used for the entity and perform a // single test using the properly oriented triangle. - if ( QgsRayCastingUtils::rayTriangleIntersection( r, tA, tB, tC, uvw, t ) || - QgsRayCastingUtils::rayTriangleIntersection( r, tA, tC, tB, uvw, t ) ) + if ( QgsRayCastingUtils::rayTriangleIntersection( r, tA, tB, tC, uvw, t ) || QgsRayCastingUtils::rayTriangleIntersection( r, tA, tC, tB, uvw, t ) ) { intersectionPt = r.point( t * r.distance() ); const float distance = r.projectedDistance( intersectionPt ); @@ -464,7 +472,7 @@ namespace QgsRayCastingUtils else return false; } -} +} // namespace QgsRayCastingUtils /// @endcond diff --git a/src/3d/qgsraycastingutils.h b/src/3d/qgsraycastingutils.h index 666add6808b..23e8b015904 100644 --- a/src/3d/qgsraycastingutils.h +++ b/src/3d/qgsraycastingutils.h @@ -31,18 +31,18 @@ namespace QgsRayCastingUtils */ struct RayHit { - //! Creates a new hit - RayHit( const float distance, const QVector3D pos, const QgsFeatureId fid = FID_NULL, const QVariantMap attributes = QVariantMap() ) - : distance( distance ) - , pos( pos ) - , fid( fid ) - , attributes( attributes ) - { - } - float distance; //!< Distance from ray's origin - QVector3D pos; //!< Hit position in world coordinates - QgsFeatureId fid; //!< Fid of feature hit closest to ray origin, FID_NULL if no features hit - QVariantMap attributes; //!< Point cloud point attributes, empty map if no point cloud points hit + //! Creates a new hit + RayHit( const float distance, const QVector3D pos, const QgsFeatureId fid = FID_NULL, const QVariantMap attributes = QVariantMap() ) + : distance( distance ) + , pos( pos ) + , fid( fid ) + , attributes( attributes ) + { + } + float distance; //!< Distance from ray's origin + QVector3D pos; //!< Hit position in world coordinates + QgsFeatureId fid; //!< Fid of feature hit closest to ray origin, FID_NULL if no features hit + QVariantMap attributes; //!< Point cloud point attributes, empty map if no point cloud points hit }; /** @@ -50,20 +50,20 @@ namespace QgsRayCastingUtils */ struct RayCastContext { - RayCastContext( bool singleResult = true, QSize screenSize = QSize(), float maxDistance = 0.f ) - : singleResult( singleResult ) - , screenSize( screenSize ) - , maxDistance( maxDistance ) - {} - bool singleResult; //!< If set to TRUE, only the closest point cloud hit will be returned (other entities always return only closest hit) - QSize screenSize; //!< QSize of the 3d engine window + RayCastContext( bool singleResult = true, QSize screenSize = QSize(), float maxDistance = 0.f ) + : singleResult( singleResult ) + , screenSize( screenSize ) + , maxDistance( maxDistance ) + {} + bool singleResult; //!< If set to TRUE, only the closest point cloud hit will be returned (other entities always return only closest hit) + QSize screenSize; //!< QSize of the 3d engine window - /** + /** * The maximum distance from ray origin to look for hits when casting a ray. * Should be normally set to far plane, to ignore data that will not get displayed in the 3D view */ - float maxDistance; + float maxDistance; }; -} +} // namespace QgsRayCastingUtils #endif // QGSRAYCASTINGUTILS_H diff --git a/src/3d/qgsraycastingutils_p.h b/src/3d/qgsraycastingutils_p.h index 6f8cbe30713..e2c6ff78cf1 100644 --- a/src/3d/qgsraycastingutils_p.h +++ b/src/3d/qgsraycastingutils_p.h @@ -37,7 +37,7 @@ namespace Qt3DRender { class QCamera; class QGeometryRenderer; -} +} // namespace Qt3DRender namespace QgsRayCastingUtils @@ -99,12 +99,7 @@ namespace QgsRayCastingUtils * \note With switch to Qt 5.11 we may remove it and use QRayCaster/QScreenRayCaster instead. * \since QGIS 3.4 */ - bool rayTriangleIntersection( const Ray3D &ray, - QVector3D a, - QVector3D b, - QVector3D c, - QVector3D &uvw, - float &t ); + bool rayTriangleIntersection( const Ray3D &ray, QVector3D a, QVector3D b, QVector3D c, QVector3D &uvw, float &t ); /** * Tests whether a triangular mesh is intersected by a ray. Returns whether an intersection @@ -112,13 +107,9 @@ namespace QgsRayCastingUtils * of the intersecting triangle. * \since QGIS 3.34 */ - bool rayMeshIntersection( Qt3DRender::QGeometryRenderer *geometryRenderer, - const QgsRayCastingUtils::Ray3D &r, - const QMatrix4x4 &worldTransform, - QVector3D &intPt, - int &triangleIndex ); + bool rayMeshIntersection( Qt3DRender::QGeometryRenderer *geometryRenderer, const QgsRayCastingUtils::Ray3D &r, const QMatrix4x4 &worldTransform, QVector3D &intPt, int &triangleIndex ); -} +} // namespace QgsRayCastingUtils /// @endcond diff --git a/src/3d/qgsrenderpassquad.cpp b/src/3d/qgsrenderpassquad.cpp index 54923e16136..3df0e7ba136 100644 --- a/src/3d/qgsrenderpassquad.cpp +++ b/src/3d/qgsrenderpassquad.cpp @@ -18,7 +18,7 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -49,7 +49,7 @@ QgsRenderPassQuad::QgsRenderPassQuad( Qt3DRender::QLayer *layer, QNode *parent ) { Qt3DQGeometry *geom = new Qt3DQGeometry( this ); Qt3DQAttribute *positionAttribute = new Qt3DQAttribute( this ); - const QVector vert = { -1.0f, -1.0f, 0.0f, /**/ 1.0f, -1.0f, 0.0f, /**/ -1.0f, 1.0f, 0.0f, /**/ -1.0f, 1.0f, 0.0f, /**/ 1.0f, -1.0f, 0.0f, /**/ 1.0f, 1.0f, 0.0f }; + const QVector vert = { -1.0f, -1.0f, 0.0f, /**/ 1.0f, -1.0f, 0.0f, /**/ -1.0f, 1.0f, 0.0f, /**/ -1.0f, 1.0f, 0.0f, /**/ 1.0f, -1.0f, 0.0f, /**/ 1.0f, 1.0f, 0.0f }; const QByteArray vertexArr( ( const char * ) vert.constData(), vert.size() * sizeof( float ) ); Qt3DQBuffer *vertexBuffer = nullptr; diff --git a/src/3d/qgsrubberband3d.cpp b/src/3d/qgsrubberband3d.cpp index ff0e77e9f7a..72fb873db51 100644 --- a/src/3d/qgsrubberband3d.cpp +++ b/src/3d/qgsrubberband3d.cpp @@ -28,7 +28,7 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -72,8 +72,7 @@ QgsRubberBand3D::QgsRubberBand3D( Qgs3DMapSettings &map, QgsWindow3DEngine *engi mLineMaterial->setLineWidth( 3 ); mLineMaterial->setLineColor( Qt::red ); - QObject::connect( engine, &QgsAbstract3DEngine::sizeChanged, mLineMaterial, [this, engine] - { + QObject::connect( engine, &QgsAbstract3DEngine::sizeChanged, mLineMaterial, [this, engine] { mLineMaterial->setViewportSize( engine->size() ); } ); mLineMaterial->setViewportSize( engine->size() ); @@ -88,12 +87,11 @@ QgsRubberBand3D::QgsRubberBand3D( Qgs3DMapSettings &map, QgsWindow3DEngine *engi mMarkerGeometryRenderer->setGeometry( mMarkerGeometry ); mMarkerGeometryRenderer->setVertexCount( mMarkerGeometry->count() ); - const QVariantMap props - { - {QStringLiteral( "color" ), QStringLiteral( "red" ) }, - {QStringLiteral( "size" ), 6 }, - {QStringLiteral( "outline_color" ), QStringLiteral( "green" ) }, - {QStringLiteral( "outline_width" ), 0.5 } + const QVariantMap props { + { QStringLiteral( "color" ), QStringLiteral( "red" ) }, + { QStringLiteral( "size" ), 6 }, + { QStringLiteral( "outline_color" ), QStringLiteral( "green" ) }, + { QStringLiteral( "outline_width" ), 0.5 } }; mMarkerSymbol = QgsMarkerSymbol::createSimple( props ); @@ -193,8 +191,7 @@ void QgsRubberBand3D::updateMarkerMaterial() mMarkerEntity->addComponent( mMarkerMaterial ); //TODO: QgsAbstract3DEngine::sizeChanged should have const QSize &size param - QObject::connect( mEngine, &QgsAbstract3DEngine::sizeChanged, mMarkerMaterial, [this] - { + QObject::connect( mEngine, &QgsAbstract3DEngine::sizeChanged, mMarkerMaterial, [this] { mMarkerMaterial->setViewportSize( mEngine->size() ); } ); mMarkerMaterial->setViewportSize( mEngine->size() ); diff --git a/src/3d/qgsrubberband3d.h b/src/3d/qgsrubberband3d.h index dae77483ef8..85c7a8b11dc 100644 --- a/src/3d/qgsrubberband3d.h +++ b/src/3d/qgsrubberband3d.h @@ -43,22 +43,22 @@ class QgsPoint3DBillboardMaterial; namespace Qt3DCore { class QEntity; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) class QBuffer; class QGeometry; class QAttribute; #endif -} +} // namespace Qt3DCore namespace Qt3DRender { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) class QBuffer; class QGeometry; class QAttribute; #endif class QGeometryRenderer; -} +} // namespace Qt3DRender /** * \ingroup 3d @@ -102,15 +102,15 @@ class _3D_EXPORT QgsRubberBand3D QgsLineString mLineString; bool mShowLastMarker = false; - Qgs3DMapSettings *mMapSettings = nullptr; // not owned + Qgs3DMapSettings *mMapSettings = nullptr; // not owned QgsWindow3DEngine *mEngine = nullptr; - Qt3DCore::QEntity *mLineEntity = nullptr; // owned by parentEntity (from constructor) + Qt3DCore::QEntity *mLineEntity = nullptr; // owned by parentEntity (from constructor) Qt3DCore::QEntity *mMarkerEntity = nullptr; // owned by parentEntity (from constructor) // all these are owned by mLineEntity Qt3DRender::QGeometryRenderer *mGeomRenderer = nullptr; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) Qt3DRender::QGeometry *mGeometry = nullptr; Qt3DRender::QAttribute *mPositionAttribute = nullptr; Qt3DRender::QAttribute *mIndexAttribute = nullptr; @@ -129,7 +129,7 @@ class _3D_EXPORT QgsRubberBand3D // Disable copying as we have pointer members. QgsRubberBand3D( const QgsRubberBand3D & ) = delete; - QgsRubberBand3D &operator= ( const QgsRubberBand3D & ) = delete; + QgsRubberBand3D &operator=( const QgsRubberBand3D & ) = delete; }; /// @endcond diff --git a/src/3d/qgsrulebased3drenderer.cpp b/src/3d/qgsrulebased3drenderer.cpp index cc0e1e51ed6..419821821e0 100644 --- a/src/3d/qgsrulebased3drenderer.cpp +++ b/src/3d/qgsrulebased3drenderer.cpp @@ -262,7 +262,7 @@ void QgsRuleBased3DRenderer::Rule::createHandlers( QgsVectorLayer *layer, QgsRul } -void QgsRuleBased3DRenderer::Rule::prepare( const Qgs3DRenderContext &context, QSet &attributeNames, const QgsVector3D &chunkOrigin, QgsRuleBased3DRenderer::RuleToHandlerMap &handlers ) const +void QgsRuleBased3DRenderer::Rule::prepare( const Qgs3DRenderContext &context, QSet &attributeNames, const QgsVector3D &chunkOrigin, QgsRuleBased3DRenderer::RuleToHandlerMap &handlers ) const { if ( mSymbol ) { @@ -338,7 +338,7 @@ QgsRuleBased3DRenderer::Rule::RegisterResult QgsRuleBased3DRenderer::Rule::regis bool QgsRuleBased3DRenderer::Rule::isFilterOK( QgsFeature &f, Qgs3DRenderContext &context ) const { - if ( ! mFilter || mElseRule ) + if ( !mFilter || mElseRule ) return true; context.expressionContext().setFeature( f ); diff --git a/src/3d/qgsrulebased3drenderer.h b/src/3d/qgsrulebased3drenderer.h index a6855f307b6..77038991363 100644 --- a/src/3d/qgsrulebased3drenderer.h +++ b/src/3d/qgsrulebased3drenderer.h @@ -61,7 +61,6 @@ class _3D_EXPORT QgsRuleBased3DRendererMetadata : public Qgs3DRendererAbstractMe class _3D_EXPORT QgsRuleBased3DRenderer : public QgsAbstractVectorLayer3DRenderer { public: - class Rule; typedef QList RuleList; typedef QHash RuleToHandlerMap; @@ -132,7 +131,11 @@ class _3D_EXPORT QgsRuleBased3DRenderer : public QgsAbstractVectorLayer3DRendere * * \param filterExp An expression */ - void setFilterExpression( const QString &filterExp ) { mFilterExp = filterExp; initFilter(); } + void setFilterExpression( const QString &filterExp ) + { + mFilterExp = filterExp; + initFilter(); + } /** * Set a human readable description for this rule @@ -308,7 +311,6 @@ class _3D_EXPORT QgsRuleBased3DRenderer : public QgsAbstractVectorLayer3DRendere private: Rule *mRootRule = nullptr; - }; #endif // QGSRULEBASED3DRENDERER_H diff --git a/src/3d/qgsrulebasedchunkloader_p.cpp b/src/3d/qgsrulebasedchunkloader_p.cpp index fcc8451ed75..c306df10c93 100644 --- a/src/3d/qgsrulebasedchunkloader_p.cpp +++ b/src/3d/qgsrulebasedchunkloader_p.cpp @@ -84,8 +84,7 @@ QgsRuleBasedChunkLoader::QgsRuleBasedChunkLoader( const QgsRuleBasedChunkLoaderF mFutureWatcher = new QFutureWatcher( this ); connect( mFutureWatcher, &QFutureWatcher::finished, this, &QgsChunkQueueJob::finished ); - const QFuture future = QtConcurrent::run( [req, this] - { + const QFuture future = QtConcurrent::run( [req, this] { const QgsEventTracing::ScopedEvent e( QStringLiteral( "3D" ), QStringLiteral( "RB chunk load" ) ); QgsFeature f; @@ -124,7 +123,7 @@ Qt3DCore::QEntity *QgsRuleBasedChunkLoader::createEntity( Qt3DCore::QEntity *par { if ( mNode->level() < mFactory->mLeafLevel ) { - return new Qt3DCore::QEntity( parent ); // dummy entity + return new Qt3DCore::QEntity( parent ); // dummy entity } long long featureCount = 0; @@ -175,7 +174,7 @@ QgsRuleBasedChunkLoaderFactory::QgsRuleBasedChunkLoaderFactory( const Qgs3DRende , mLeafLevel( leafLevel ) { const QgsBox3D rootBox3D( context.extent(), zMin, zMax ); - setupQuadtree( rootBox3D, -1, leafLevel ); // negative root error means that the node does not contain anything + setupQuadtree( rootBox3D, -1, leafLevel ); // negative root error means that the node does not contain anything } QgsRuleBasedChunkLoaderFactory::~QgsRuleBasedChunkLoaderFactory() = default; diff --git a/src/3d/qgsrulebasedchunkloader_p.h b/src/3d/qgsrulebasedchunkloader_p.h index f2a45d06664..7392b9a905a 100644 --- a/src/3d/qgsrulebasedchunkloader_p.h +++ b/src/3d/qgsrulebasedchunkloader_p.h @@ -126,6 +126,7 @@ class QgsRuleBasedChunkedEntity : public QgsChunkedEntity ~QgsRuleBasedChunkedEntity(); private slots: void onTerrainElevationOffsetChanged( float newOffset ); + private: Qt3DCore::QTransform *mTransform = nullptr; diff --git a/src/3d/qgsshadowsettings.cpp b/src/3d/qgsshadowsettings.cpp index 40f3800319f..4f2b7a6a5e3 100644 --- a/src/3d/qgsshadowsettings.cpp +++ b/src/3d/qgsshadowsettings.cpp @@ -27,7 +27,6 @@ QgsShadowSettings::QgsShadowSettings( const QgsShadowSettings &other ) , mShadowBias( other.mShadowBias ) , mShadowMapResolution( other.mShadowMapResolution ) { - } QgsShadowSettings &QgsShadowSettings::operator=( QgsShadowSettings const &rhs ) diff --git a/src/3d/qgsshadowsettings.h b/src/3d/qgsshadowsettings.h index 5f973d20aa7..9ad1d607dee 100644 --- a/src/3d/qgsshadowsettings.h +++ b/src/3d/qgsshadowsettings.h @@ -34,7 +34,6 @@ class QDomElement; class _3D_EXPORT QgsShadowSettings { public: - QgsShadowSettings() = default; QgsShadowSettings( const QgsShadowSettings &other ); QgsShadowSettings &operator=( QgsShadowSettings const &rhs ); diff --git a/src/3d/qgsskyboxentity.h b/src/3d/qgsskyboxentity.h index 5e379bbb540..a5b7c6ffa31 100644 --- a/src/3d/qgsskyboxentity.h +++ b/src/3d/qgsskyboxentity.h @@ -51,6 +51,7 @@ class _3D_EXPORT QgsSkyboxEntity : public Qt3DCore::QEntity PanoramicSkybox, DistinctTexturesSkybox }; + public: //! Constructor QgsSkyboxEntity( QNode *parent = nullptr ); @@ -90,6 +91,7 @@ class _3D_EXPORT QgsPanoramicSkyboxEntity : public QgsSkyboxEntity private: void reloadTexture(); + private: QString mTexturePath; Qt3DRender::QTextureLoader *mLoadedTexture = nullptr; @@ -116,6 +118,7 @@ class _3D_EXPORT QgsCubeFacesSkyboxEntity : public QgsSkyboxEntity private: void init(); void reloadTexture(); + private: QMap mCubeFacesPaths; Qt3DRender::QShaderProgram *mGlShader = nullptr; diff --git a/src/3d/qgsskyboxsettings.cpp b/src/3d/qgsskyboxsettings.cpp index 55b3565eb98..fc5dbe5347b 100644 --- a/src/3d/qgsskyboxsettings.cpp +++ b/src/3d/qgsskyboxsettings.cpp @@ -25,7 +25,6 @@ QgsSkyboxSettings::QgsSkyboxSettings( const QgsSkyboxSettings &other ) , mPanoramicTexturePath( other.mPanoramicTexturePath ) , mCubeMapFacesPaths( other.mCubeMapFacesPaths ) { - } QgsSkyboxSettings &QgsSkyboxSettings::operator=( QgsSkyboxSettings const &rhs ) @@ -46,12 +45,12 @@ void QgsSkyboxSettings::readXml( const QDomElement &element, const QgsReadWriteC mSkyboxType = QgsSkyboxEntity::PanoramicSkybox; mPanoramicTexturePath = pathResolver.readPath( element.attribute( QStringLiteral( "panoramic-texture-path" ) ) ); mCubeMapFacesPaths.clear(); - mCubeMapFacesPaths[ QStringLiteral( "posX" ) ] = pathResolver.readPath( element.attribute( QStringLiteral( "posX-texture-path" ) ) ); - mCubeMapFacesPaths[ QStringLiteral( "posY" ) ] = pathResolver.readPath( element.attribute( QStringLiteral( "posY-texture-path" ) ) ); - mCubeMapFacesPaths[ QStringLiteral( "posZ" ) ] = pathResolver.readPath( element.attribute( QStringLiteral( "posZ-texture-path" ) ) ); - mCubeMapFacesPaths[ QStringLiteral( "negX" ) ] = pathResolver.readPath( element.attribute( QStringLiteral( "negX-texture-path" ) ) ); - mCubeMapFacesPaths[ QStringLiteral( "negY" ) ] = pathResolver.readPath( element.attribute( QStringLiteral( "negY-texture-path" ) ) ); - mCubeMapFacesPaths[ QStringLiteral( "negZ" ) ] = pathResolver.readPath( element.attribute( QStringLiteral( "negZ-texture-path" ) ) ); + mCubeMapFacesPaths[QStringLiteral( "posX" )] = pathResolver.readPath( element.attribute( QStringLiteral( "posX-texture-path" ) ) ); + mCubeMapFacesPaths[QStringLiteral( "posY" )] = pathResolver.readPath( element.attribute( QStringLiteral( "posY-texture-path" ) ) ); + mCubeMapFacesPaths[QStringLiteral( "posZ" )] = pathResolver.readPath( element.attribute( QStringLiteral( "posZ-texture-path" ) ) ); + mCubeMapFacesPaths[QStringLiteral( "negX" )] = pathResolver.readPath( element.attribute( QStringLiteral( "negX-texture-path" ) ) ); + mCubeMapFacesPaths[QStringLiteral( "negY" )] = pathResolver.readPath( element.attribute( QStringLiteral( "negY-texture-path" ) ) ); + mCubeMapFacesPaths[QStringLiteral( "negZ" )] = pathResolver.readPath( element.attribute( QStringLiteral( "negZ-texture-path" ) ) ); } void QgsSkyboxSettings::writeXml( QDomElement &element, const QgsReadWriteContext &context ) const @@ -68,10 +67,10 @@ void QgsSkyboxSettings::writeXml( QDomElement &element, const QgsReadWriteContex const QgsPathResolver &pathResolver = context.pathResolver(); element.setAttribute( QStringLiteral( "panoramic-texture-path" ), pathResolver.writePath( mPanoramicTexturePath ) ); - element.setAttribute( QStringLiteral( "posX-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "posX" ) ] ) ); - element.setAttribute( QStringLiteral( "posY-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "posY" ) ] ) ); - element.setAttribute( QStringLiteral( "posZ-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "posZ" ) ] ) ); - element.setAttribute( QStringLiteral( "negX-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "negX" ) ] ) ); - element.setAttribute( QStringLiteral( "negY-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "negY" ) ] ) ); - element.setAttribute( QStringLiteral( "negZ-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "negZ" ) ] ) ); + element.setAttribute( QStringLiteral( "posX-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[QStringLiteral( "posX" )] ) ); + element.setAttribute( QStringLiteral( "posY-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[QStringLiteral( "posY" )] ) ); + element.setAttribute( QStringLiteral( "posZ-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[QStringLiteral( "posZ" )] ) ); + element.setAttribute( QStringLiteral( "negX-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[QStringLiteral( "negX" )] ) ); + element.setAttribute( QStringLiteral( "negY-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[QStringLiteral( "negY" )] ) ); + element.setAttribute( QStringLiteral( "negZ-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[QStringLiteral( "negZ" )] ) ); } diff --git a/src/3d/qgsskyboxsettings.h b/src/3d/qgsskyboxsettings.h index ea0b83f2d40..e15d15285bd 100644 --- a/src/3d/qgsskyboxsettings.h +++ b/src/3d/qgsskyboxsettings.h @@ -36,7 +36,6 @@ class QDomElement; class _3D_EXPORT QgsSkyboxSettings { public: - QgsSkyboxSettings() = default; QgsSkyboxSettings( const QgsSkyboxSettings &other ); QgsSkyboxSettings &operator=( QgsSkyboxSettings const &rhs ); diff --git a/src/3d/qgstessellatedpolygongeometry.cpp b/src/3d/qgstessellatedpolygongeometry.cpp index 07b238e60df..1e3f96bb990 100644 --- a/src/3d/qgstessellatedpolygongeometry.cpp +++ b/src/3d/qgstessellatedpolygongeometry.cpp @@ -20,7 +20,7 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include typedef Qt3DRender::QAttribute Qt3DQAttribute; @@ -103,10 +103,10 @@ static int binary_search( uint v, const uint *data, int count ) int idx1 = count - 1; if ( v < data[0] ) - return -1; // not in the array + return -1; // not in the array if ( v >= data[count - 1] ) - return count - 1; // for larger values the last bin is returned + return count - 1; // for larger values the last bin is returned while ( idx0 != idx1 ) { @@ -115,11 +115,11 @@ static int binary_search( uint v, const uint *data, int count ) if ( pivot <= v ) { if ( data[idxPivot + 1] > v ) - return idxPivot; // we're done! - else // continue searching values greater than the pivot + return idxPivot; // we're done! + else // continue searching values greater than the pivot idx0 = idxPivot; } - else // continue searching values lower than the pivot + else // continue searching values lower than the pivot idx1 = idxPivot; } return idx0; diff --git a/src/3d/qgstessellatedpolygongeometry.h b/src/3d/qgstessellatedpolygongeometry.h index 20cb2cc9a7a..130b9130661 100644 --- a/src/3d/qgstessellatedpolygongeometry.h +++ b/src/3d/qgstessellatedpolygongeometry.h @@ -18,7 +18,7 @@ #include "qgsfeatureid.h" -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #else #include @@ -33,7 +33,7 @@ namespace QgsRayCastingUtils class Ray3D; } -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) namespace Qt3DRender { class QBuffer; @@ -57,7 +57,7 @@ namespace Qt3DCore * \note Not available in Python bindings * */ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) class QgsTessellatedPolygonGeometry : public Qt3DRender::QGeometry #else class QgsTessellatedPolygonGeometry : public Qt3DCore::QGeometry @@ -111,9 +111,9 @@ class QgsTessellatedPolygonGeometry : public Qt3DCore::QGeometry QVector triangleIndexStartingIndices() const { return mTriangleIndexStartingIndices; } friend class Qgs3DSceneExporter; - private: -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + private: +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) Qt3DRender::QAttribute *mPositionAttribute = nullptr; Qt3DRender::QAttribute *mNormalAttribute = nullptr; Qt3DRender::QAttribute *mTextureCoordsAttribute = nullptr; diff --git a/src/3d/qgstiledscenechunkloader_p.cpp b/src/3d/qgstiledscenechunkloader_p.cpp index 14665127f81..587ff8cccd5 100644 --- a/src/3d/qgstiledscenechunkloader_p.cpp +++ b/src/3d/qgstiledscenechunkloader_p.cpp @@ -65,8 +65,7 @@ QgsTiledSceneChunkLoader::QgsTiledSceneChunkLoader( QgsChunkNode *node, const Qg const QgsChunkNodeId tileId = node->tileId(); const QgsVector3D chunkOrigin = node->box3D().center(); - const QFuture future = QtConcurrent::run( [this, tileId, zValueScale, zValueOffset, boundsTransform, chunkOrigin] - { + const QFuture future = QtConcurrent::run( [this, tileId, zValueScale, zValueOffset, boundsTransform, chunkOrigin] { const QgsTiledSceneTile tile = mIndex.getTile( tileId.uniqueId ); // we do not load tiles that are too big - at least for the time being @@ -98,7 +97,7 @@ QgsTiledSceneChunkLoader::QgsTiledSceneChunkLoader( QgsChunkNode *node, const Qg entityTransform.ecefToTargetCrs = &mFactory.mBoundsTransform; entityTransform.zValueScale = zValueScale; entityTransform.zValueOffset = zValueOffset; - entityTransform.gltfUpAxis = static_cast< Qgis::Axis >( tile.metadata().value( QStringLiteral( "gltfUpAxis" ), static_cast< int >( Qgis::Axis::Y ) ).toInt() ); + entityTransform.gltfUpAxis = static_cast( tile.metadata().value( QStringLiteral( "gltfUpAxis" ), static_cast( Qgis::Axis::Y ) ).toInt() ); const QString &format = tile.metadata().value( QStringLiteral( "contentFormat" ) ).value(); QStringList errors; @@ -124,7 +123,8 @@ QgsTiledSceneChunkLoader::QgsTiledSceneChunkLoader( QgsChunkNode *node, const Qg entityTransform.tileTransform.translate( tileContent.rtcCenter ); mEntity = QgsGltf3DUtils::gltfToEntity( tileContent.gltf, entityTransform, uri, &errors ); } - else return; // unsupported tile content type + else + return; // unsupported tile content type // TODO: report errors somewhere? if ( !errors.isEmpty() ) @@ -218,7 +218,7 @@ QVector QgsTiledSceneChunkLoaderFactory::createChildren( QgsChun // fetching of hierarchy is handled by canCreateChildren() + prepareChildren() Q_ASSERT( mIndex.childAvailability( indexTileId ) != Qgis::TileChildrenAvailability::NeedFetching ); - const QVector< long long > childIds = mIndex.childTileIds( indexTileId ); + const QVector childIds = mIndex.childTileIds( indexTileId ); for ( long long childId : childIds ) { const QgsChunkNodeId chId( childId ); @@ -244,10 +244,10 @@ QVector QgsTiledSceneChunkLoaderFactory::createChildren( QgsChun half[0], half[3], half[6], 0, half[1], half[4], half[7], 0, half[2], half[5], half[8], 0, - 0, 0, 0, 1 ); + 0, 0, 0, 1 + ); QVector3D aaa = rot.inverted().map( ecef2.toVector3D() ); - if ( aaa.x() > 1 || aaa.y() > 1 || aaa.z() > 1 || - aaa.x() < -1 || aaa.y() < -1 || aaa.z() < -1 ) + if ( aaa.x() > 1 || aaa.y() > 1 || aaa.z() > 1 || aaa.x() < -1 || aaa.y() < -1 || aaa.z() < -1 ) { continue; } @@ -278,7 +278,7 @@ bool QgsTiledSceneChunkLoaderFactory::canCreateChildren( QgsChunkNode *node ) // we fetch its hierarchy before a chunk node is created for such child tile - otherwise we // end up trying to load tileset JSON file instead of the actual content - const QVector< long long > childIds = mIndex.childTileIds( nodeId ); + const QVector childIds = mIndex.childTileIds( nodeId ); for ( long long childId : childIds ) { if ( mFutureHierarchyFetches.contains( childId ) || mPendingHierarchyFetches.contains( childId ) ) @@ -300,14 +300,12 @@ void QgsTiledSceneChunkLoaderFactory::fetchHierarchyForNode( long long nodeId, Q mPendingHierarchyFetches.insert( nodeId ); QFutureWatcher *futureWatcher = new QFutureWatcher( this ); - connect( futureWatcher, &QFutureWatcher::finished, this, [this, origNode, nodeId, futureWatcher] - { + connect( futureWatcher, &QFutureWatcher::finished, this, [this, origNode, nodeId, futureWatcher] { mPendingHierarchyFetches.remove( nodeId ); emit childrenPrepared( origNode ); futureWatcher->deleteLater(); } ); - futureWatcher->setFuture( QtConcurrent::run( [this, nodeId] - { + futureWatcher->setFuture( QtConcurrent::run( [this, nodeId] { mIndex.fetchHierarchy( nodeId ); } ) ); } @@ -325,7 +323,7 @@ void QgsTiledSceneChunkLoaderFactory::prepareChildren( QgsChunkNode *node ) // we fetch its hierarchy before a chunk node is created for such child tile - otherwise we // end up trying to load tileset JSON file instead of the actual content - const QVector< long long > childIds = mIndex.childTileIds( nodeId ); + const QVector childIds = mIndex.childTileIds( nodeId ); for ( long long childId : childIds ) { if ( mFutureHierarchyFetches.contains( childId ) ) @@ -381,9 +379,7 @@ QVector QgsTiledSceneLayerChunkedEntity::rayIntersec QgsAABB nodeBbox = Qgs3DUtils::mapToWorldExtent( node->box3D(), mMapSettings->origin() ); - if ( node->entity() && - ( minDist < 0 || nodeBbox.distanceFromPoint( ray.origin() ) < minDist ) && - QgsRayCastingUtils::rayBoxIntersection( ray, nodeBbox ) ) + if ( node->entity() && ( minDist < 0 || nodeBbox.distanceFromPoint( ray.origin() ) < minDist ) && QgsRayCastingUtils::rayBoxIntersection( ray, nodeBbox ) ) { #ifdef QGISDEBUG nodeUsed++; @@ -417,10 +413,10 @@ QVector QgsTiledSceneLayerChunkedEntity::rayIntersec QVariantMap vm; QgsTiledSceneTile tile = mIndex.getTile( minNode->tileId().uniqueId ); // at this point this is mostly for debugging - we may want to change/rename what's returned here - vm[ QStringLiteral( "node_id" ) ] = tile.id(); - vm[ QStringLiteral( "node_error" ) ] = tile.geometricError(); - vm[ QStringLiteral( "node_content" ) ] = tile.resources().value( QStringLiteral( "content" ) ); - vm[ QStringLiteral( "triangle_index" ) ] = minTriangleIndex; + vm[QStringLiteral( "node_id" )] = tile.id(); + vm[QStringLiteral( "node_error" )] = tile.geometricError(); + vm[QStringLiteral( "node_content" )] = tile.resources().value( QStringLiteral( "content" ) ); + vm[QStringLiteral( "triangle_index" )] = minTriangleIndex; QgsRayCastingUtils::RayHit hit( minDist, intersectionPoint, FID_NULL, vm ); result.append( hit ); } diff --git a/src/3d/qgstiledscenechunkloader_p.h b/src/3d/qgstiledscenechunkloader_p.h index bb6798a23a6..95e8c86fc0f 100644 --- a/src/3d/qgstiledscenechunkloader_p.h +++ b/src/3d/qgstiledscenechunkloader_p.h @@ -82,7 +82,8 @@ class QgsTiledSceneChunkLoaderFactory : public QgsChunkLoaderFactory public: QgsTiledSceneChunkLoaderFactory( const Qgs3DRenderContext &context, const QgsTiledSceneIndex &index, QgsCoordinateReferenceSystem tileCrs, - double zValueScale, double zValueOffset ); + double zValueScale, double zValueOffset + ); virtual QgsChunkLoader *createChunkLoader( QgsChunkNode *node ) const override; virtual QgsChunkNode *createRootNode() const override; @@ -119,8 +120,7 @@ class QgsTiledSceneLayerChunkedEntity : public QgsChunkedEntity { Q_OBJECT public: - explicit QgsTiledSceneLayerChunkedEntity( Qgs3DMapSettings *map, const QgsTiledSceneIndex &index, QgsCoordinateReferenceSystem tileCrs, double maximumScreenError, bool showBoundingBoxes, - double zValueScale, double zValueOffset ); + explicit QgsTiledSceneLayerChunkedEntity( Qgs3DMapSettings *map, const QgsTiledSceneIndex &index, QgsCoordinateReferenceSystem tileCrs, double maximumScreenError, bool showBoundingBoxes, double zValueScale, double zValueOffset ); ~QgsTiledSceneLayerChunkedEntity(); diff --git a/src/3d/qgstiledscenelayer3drenderer.cpp b/src/3d/qgstiledscenelayer3drenderer.cpp index 1e2cb612106..4e6890717c3 100644 --- a/src/3d/qgstiledscenelayer3drenderer.cpp +++ b/src/3d/qgstiledscenelayer3drenderer.cpp @@ -66,12 +66,7 @@ Qt3DCore::QEntity *QgsTiledSceneLayer3DRenderer::createEntity( Qgs3DMapSettings QgsTiledSceneIndex index = tsl->dataProvider()->index(); - return new QgsTiledSceneLayerChunkedEntity( map, index, - tsl->dataProvider()->sceneCrs(), - maximumScreenError(), - showBoundingBoxes(), - qgis::down_cast< const QgsTiledSceneLayerElevationProperties * >( tsl->elevationProperties() )->zScale(), - qgis::down_cast< const QgsTiledSceneLayerElevationProperties * >( tsl->elevationProperties() )->zOffset() ); + return new QgsTiledSceneLayerChunkedEntity( map, index, tsl->dataProvider()->sceneCrs(), maximumScreenError(), showBoundingBoxes(), qgis::down_cast( tsl->elevationProperties() )->zScale(), qgis::down_cast( tsl->elevationProperties() )->zOffset() ); } void QgsTiledSceneLayer3DRenderer::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const diff --git a/src/3d/qgstiledscenelayer3drenderer.h b/src/3d/qgstiledscenelayer3drenderer.h index 45ba407c4cb..866fcc7646f 100644 --- a/src/3d/qgstiledscenelayer3drenderer.h +++ b/src/3d/qgstiledscenelayer3drenderer.h @@ -26,7 +26,6 @@ class QgsTiledSceneLayer; - /** * \ingroup 3d * \brief Metadata for tiled scene layer 3D renderer to allow creation of its instances from XML @@ -51,7 +50,6 @@ class _3D_EXPORT QgsTiledSceneLayer3DRendererMetadata : public Qgs3DRendererAbst */ class _3D_EXPORT QgsTiledSceneLayer3DRenderer : public QgsAbstract3DRenderer { - #ifdef SIP_RUN SIP_CONVERT_TO_SUBCLASS_CODE if ( sipCpp->type() == QLatin1String( "tiledscene" ) ) diff --git a/src/3d/qgstilingscheme.cpp b/src/3d/qgstilingscheme.cpp index f697dec5408..488aac67168 100644 --- a/src/3d/qgstilingscheme.cpp +++ b/src/3d/qgstilingscheme.cpp @@ -55,7 +55,7 @@ QgsRectangle QgsTilingScheme::tileToExtent( const QgsChunkNodeId &nodeId ) const void QgsTilingScheme::extentToTile( const QgsRectangle &extent, int &x, int &y, int &z ) const { - x = y = z = 0; // start with root tile + x = y = z = 0; // start with root tile while ( true ) { // try to see if any child tile fully contains our extent - if so, go deeper @@ -81,7 +81,7 @@ void QgsTilingScheme::extentToTile( const QgsRectangle &extent, int &x, int &y, } else { - return; // cannot go deeper + return; // cannot go deeper } z++; } diff --git a/src/3d/qgstilingscheme.h b/src/3d/qgstilingscheme.h index efd92dda565..61f61075eb1 100644 --- a/src/3d/qgstilingscheme.h +++ b/src/3d/qgstilingscheme.h @@ -67,12 +67,10 @@ class _3D_EXPORT QgsTilingScheme QgsRectangle fullExtent() const { return mFullExtent; } private: - QgsPointXY mMapOrigin; //!< Origin point in map coordinates: (0,0) in the tiling scheme - double mBaseTileSide = 0; //!< Length of tile side at zoom level 0 in map coordinates - QgsCoordinateReferenceSystem mCrs; //!< CRS of the coordinates - QgsRectangle mFullExtent; //!< The fullExtent used in constructor - - + QgsPointXY mMapOrigin; //!< Origin point in map coordinates: (0,0) in the tiling scheme + double mBaseTileSide = 0; //!< Length of tile side at zoom level 0 in map coordinates + QgsCoordinateReferenceSystem mCrs; //!< CRS of the coordinates + QgsRectangle mFullExtent; //!< The fullExtent used in constructor }; #endif // QGSTILINGSCHEME_H diff --git a/src/3d/qgsvectorlayer3drenderer.h b/src/3d/qgsvectorlayer3drenderer.h index 88db21a9c18..6026e52f62f 100644 --- a/src/3d/qgsvectorlayer3drenderer.h +++ b/src/3d/qgsvectorlayer3drenderer.h @@ -70,7 +70,7 @@ class _3D_EXPORT QgsVectorLayer3DRenderer : public QgsAbstractVectorLayer3DRende void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override; private: - std::unique_ptr mSymbol; //!< 3D symbol that defines appearance + std::unique_ptr mSymbol; //!< 3D symbol that defines appearance private: #ifdef SIP_RUN diff --git a/src/3d/qgsvectorlayerchunkloader_p.cpp b/src/3d/qgsvectorlayerchunkloader_p.cpp index 2101b0d8a58..8bbfbf23ba3 100644 --- a/src/3d/qgsvectorlayerchunkloader_p.cpp +++ b/src/3d/qgsvectorlayerchunkloader_p.cpp @@ -91,8 +91,7 @@ QgsVectorLayerChunkLoader::QgsVectorLayerChunkLoader( const QgsVectorLayerChunkL mFutureWatcher = new QFutureWatcher( this ); connect( mFutureWatcher, &QFutureWatcher::finished, this, &QgsChunkQueueJob::finished ); - const QFuture future = QtConcurrent::run( [req, this] - { + const QFuture future = QtConcurrent::run( [req, this] { const QgsEventTracing::ScopedEvent e( QStringLiteral( "3D" ), QStringLiteral( "VL chunk load" ) ); QgsFeature f; @@ -128,7 +127,7 @@ Qt3DCore::QEntity *QgsVectorLayerChunkLoader::createEntity( Qt3DCore::QEntity *p { if ( mNode->level() < mFactory->mLeafLevel ) { - Qt3DCore::QEntity *entity = new Qt3DCore::QEntity( parent ); // dummy entity + Qt3DCore::QEntity *entity = new Qt3DCore::QEntity( parent ); // dummy entity entity->setObjectName( mLayerName + "_CONTAINER_" + mNode->tileId().text() ); return entity; } @@ -172,7 +171,7 @@ QgsVectorLayerChunkLoaderFactory::QgsVectorLayerChunkLoaderFactory( const Qgs3DR QgsBox3D rootBox3D( context.extent(), zMin, zMax ); // add small padding to avoid clipping of point features located at the edge of the bounding box rootBox3D.grow( 1.0 ); - setupQuadtree( rootBox3D, -1, leafLevel ); // negative root error means that the node does not contain anything + setupQuadtree( rootBox3D, -1, leafLevel ); // negative root error means that the node does not contain anything } QgsChunkLoader *QgsVectorLayerChunkLoaderFactory::createChunkLoader( QgsChunkNode *node ) const @@ -286,9 +285,7 @@ QVector QgsVectorLayerChunkedEntity::rayIntersection QgsAABB nodeBbox = Qgs3DUtils::mapToWorldExtent( node->box3D(), origin ); - if ( node->entity() && - ( minDist < 0 || nodeBbox.distanceFromPoint( ray.origin() ) < minDist ) && - QgsRayCastingUtils::rayBoxIntersection( ray, nodeBbox ) ) + if ( node->entity() && ( minDist < 0 || nodeBbox.distanceFromPoint( ray.origin() ) < minDist ) && QgsRayCastingUtils::rayBoxIntersection( ray, nodeBbox ) ) { #ifdef QGISDEBUG nodeUsed++; diff --git a/src/3d/qgsvirtualpointcloudentity_p.cpp b/src/3d/qgsvirtualpointcloudentity_p.cpp index 5a0d8081c1b..22f01ff1e9b 100644 --- a/src/3d/qgsvirtualpointcloudentity_p.cpp +++ b/src/3d/qgsvirtualpointcloudentity_p.cpp @@ -32,7 +32,8 @@ QgsVirtualPointCloudEntity::QgsVirtualPointCloudEntity( bool showBoundingBoxes, double zValueScale, double zValueOffset, - int pointBudget ) + int pointBudget +) : Qgs3DMapSceneEntity( map, nullptr ) , mLayer( layer ) , mCoordinateTransform( coordinateTransform ) @@ -59,7 +60,6 @@ QgsVirtualPointCloudEntity::QgsVirtualPointCloudEntity( updateBboxEntity(); connect( this, &QgsVirtualPointCloudEntity::subIndexNeedsLoading, provider(), &QgsVirtualPointCloudProvider::loadSubIndex, Qt::QueuedConnection ); connect( provider(), &QgsVirtualPointCloudProvider::subIndexLoaded, this, &QgsVirtualPointCloudEntity::createChunkedEntityForSubIndex ); - } QList QgsVirtualPointCloudEntity::chunkedEntities() const @@ -90,12 +90,13 @@ void QgsVirtualPointCloudEntity::createChunkedEntityForSubIndex( int i ) mapSettings(), si.index(), mCoordinateTransform, - static_cast< QgsPointCloud3DSymbol * >( mSymbol->clone() ), + static_cast( mSymbol->clone() ), mMaximumScreenSpaceError, mShowBoundingBoxes, mZValueScale, mZValueOffset, - mPointBudget ); + mPointBudget + ); mChunkedEntitiesMap.insert( i, newChunkedEntity ); newChunkedEntity->setParent( this ); diff --git a/src/3d/qgsvirtualpointcloudentity_p.h b/src/3d/qgsvirtualpointcloudentity_p.h index 8e256855ce7..a28a0fd26b0 100644 --- a/src/3d/qgsvirtualpointcloudentity_p.h +++ b/src/3d/qgsvirtualpointcloudentity_p.h @@ -57,8 +57,7 @@ class QgsVirtualPointCloudEntity : public Qgs3DMapSceneEntity Q_OBJECT public: //! Constructs - QgsVirtualPointCloudEntity( Qgs3DMapSettings *map, QgsPointCloudLayer *layer, const QgsCoordinateTransform &coordinateTransform, QgsPointCloud3DSymbol *symbol, float maxScreenError, bool showBoundingBoxes, - double zValueScale, double zValueOffset, int pointBudget ); + QgsVirtualPointCloudEntity( Qgs3DMapSettings *map, QgsPointCloudLayer *layer, const QgsCoordinateTransform &coordinateTransform, QgsPointCloud3DSymbol *symbol, float maxScreenError, bool showBoundingBoxes, double zValueScale, double zValueOffset, int pointBudget ); //! This is called when the camera moves. It's responsible for loading new indexes and decides if subindex will be rendered as bbox or chunked entity. void handleSceneUpdate( const SceneContext &sceneContext ) override; @@ -97,7 +96,7 @@ class QgsVirtualPointCloudEntity : public Qgs3DMapSceneEntity QgsChunkBoundsEntity *mBboxesEntity = nullptr; QList mBboxes; QgsCoordinateTransform mCoordinateTransform; - std::unique_ptr< QgsPointCloud3DSymbol > mSymbol; + std::unique_ptr mSymbol; double mZValueScale = 1.0; double mZValueOffset = 0; int mPointBudget = 1000000; diff --git a/src/3d/qgswindow3dengine.h b/src/3d/qgswindow3dengine.h index 370f167c7d5..dfbd5fa3ff3 100644 --- a/src/3d/qgswindow3dengine.h +++ b/src/3d/qgswindow3dengine.h @@ -46,7 +46,6 @@ class _3D_EXPORT QgsWindow3DEngine : public QgsAbstract3DEngine { Q_OBJECT public: - /** * Constructor for QgsWindow3DEngine with the specified \a parent Qgs3DMapCanvas. */ @@ -73,6 +72,7 @@ class _3D_EXPORT QgsWindow3DEngine : public QgsAbstract3DEngine QSurface *surface() const override; void setSize( QSize s ) override; + private: //! 3D window with all the 3D magic inside Qgs3DMapCanvas *mMapCanvas3D = nullptr; diff --git a/src/3d/symbols/qgsbillboardgeometry.cpp b/src/3d/symbols/qgsbillboardgeometry.cpp index 532733c2455..c7e1e2ca6ef 100644 --- a/src/3d/symbols/qgsbillboardgeometry.cpp +++ b/src/3d/symbols/qgsbillboardgeometry.cpp @@ -15,7 +15,7 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include @@ -37,7 +37,6 @@ QgsBillboardGeometry::QgsBillboardGeometry( Qt3DCore::QNode *parent ) , mPositionAttribute( new Qt3DQAttribute( this ) ) , mVertexBuffer( new Qt3DQBuffer( this ) ) { - mPositionAttribute->setAttributeType( Qt3DQAttribute::VertexAttribute ); mPositionAttribute->setBuffer( mVertexBuffer ); mPositionAttribute->setVertexBaseType( Qt3DQAttribute::Float ); @@ -47,7 +46,6 @@ QgsBillboardGeometry::QgsBillboardGeometry( Qt3DCore::QNode *parent ) mPositionAttribute->setName( Qt3DQAttribute::defaultPositionAttributeName() ); addAttribute( mPositionAttribute ); - } void QgsBillboardGeometry::setPoints( const QVector &vertices ) @@ -67,12 +65,9 @@ void QgsBillboardGeometry::setPoints( const QVector &vertices ) mVertexBuffer->setData( vertexBufferData ); emit countChanged( mVertexCount ); - } int QgsBillboardGeometry::count() const { return mVertexCount; } - - diff --git a/src/3d/symbols/qgsbillboardgeometry.h b/src/3d/symbols/qgsbillboardgeometry.h index 01ac1cfe1c9..6d91f998d37 100644 --- a/src/3d/symbols/qgsbillboardgeometry.h +++ b/src/3d/symbols/qgsbillboardgeometry.h @@ -17,7 +17,7 @@ #define QGSBILLBOARDGEOMETRY_H #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -37,7 +37,7 @@ * * \since QGIS 3.10 */ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) class QgsBillboardGeometry : public Qt3DRender::QGeometry #else class QgsBillboardGeometry : public Qt3DCore::QGeometry @@ -60,7 +60,7 @@ class QgsBillboardGeometry : public Qt3DCore::QGeometry void countChanged( int count ); private: -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) Qt3DRender::QAttribute *mPositionAttribute = nullptr; Qt3DRender::QBuffer *mVertexBuffer = nullptr; #else diff --git a/src/3d/symbols/qgsline3dsymbol.cpp b/src/3d/symbols/qgsline3dsymbol.cpp index 1afd3bf5783..93107c4475e 100644 --- a/src/3d/symbols/qgsline3dsymbol.cpp +++ b/src/3d/symbols/qgsline3dsymbol.cpp @@ -23,16 +23,15 @@ #include "qgsvectorlayerelevationproperties.h" QgsLine3DSymbol::QgsLine3DSymbol() - : mMaterialSettings( std::make_unique< QgsPhongMaterialSettings >() ) + : mMaterialSettings( std::make_unique() ) { - } QgsLine3DSymbol::~QgsLine3DSymbol() = default; QgsAbstract3DSymbol *QgsLine3DSymbol::clone() const { - std::unique_ptr< QgsLine3DSymbol > result = std::make_unique< QgsLine3DSymbol >(); + std::unique_ptr result = std::make_unique(); result->mAltClamping = mAltClamping; result->mAltBinding = mAltBinding; result->mWidth = mWidth; @@ -100,17 +99,17 @@ void QgsLine3DSymbol::setMaterialSettings( QgsAbstractMaterialSettings *material QList QgsLine3DSymbol::compatibleGeometryTypes() const { - return QList< Qgis::GeometryType >() << Qgis::GeometryType::Line; + return QList() << Qgis::GeometryType::Line; } void QgsLine3DSymbol::setDefaultPropertiesFromLayer( const QgsVectorLayer *layer ) { - const QgsVectorLayerElevationProperties *props = qgis::down_cast< const QgsVectorLayerElevationProperties * >( const_cast< QgsVectorLayer *>( layer )->elevationProperties() ); + const QgsVectorLayerElevationProperties *props = qgis::down_cast( const_cast( layer )->elevationProperties() ); mAltClamping = props->clamping(); mAltBinding = props->binding(); - mExtrusionHeight = props->extrusionEnabled() ? static_cast< float>( props->extrusionHeight() ) : 0.0f; - mOffset = static_cast< float >( props->zOffset() ); + mExtrusionHeight = props->extrusionEnabled() ? static_cast( props->extrusionHeight() ) : 0.0f; + mOffset = static_cast( props->zOffset() ); } QgsAbstract3DSymbol *QgsLine3DSymbol::create() diff --git a/src/3d/symbols/qgsline3dsymbol.h b/src/3d/symbols/qgsline3dsymbol.h index 7e54af06e76..12dc7920c8d 100644 --- a/src/3d/symbols/qgsline3dsymbol.h +++ b/src/3d/symbols/qgsline3dsymbol.h @@ -34,7 +34,6 @@ class QgsAbstractMaterialSettings; class _3D_EXPORT QgsLine3DSymbol : public QgsAbstract3DSymbol SIP_NODEFAULTCTORS { public: - QgsLine3DSymbol(); ~QgsLine3DSymbol() override; @@ -50,7 +49,7 @@ class _3D_EXPORT QgsLine3DSymbol : public QgsAbstract3DSymbol SIP_NODEFAULTCTORS void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override; void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override; - QList< Qgis::GeometryType > compatibleGeometryTypes() const override; + QList compatibleGeometryTypes() const override; void setDefaultPropertiesFromLayer( const QgsVectorLayer *layer ) override; //! Returns method that determines altitude (whether to clamp to feature to terrain) @@ -128,11 +127,11 @@ class _3D_EXPORT QgsLine3DSymbol : public QgsAbstract3DSymbol SIP_NODEFAULTCTORS //! how to handle clamping of vertices of individual features Qgis::AltitudeBinding mAltBinding = Qgis::AltitudeBinding::Centroid; - float mWidth = 2.0f; //!< Line width (horizontally) - float mOffset = 0.0f; //!< Base height of polygons - float mExtrusionHeight = 0.0f; //!< How much to extrude (0 means no walls) - bool mRenderAsSimpleLines = false; //!< Whether to render data with simple lines (otherwise it uses buffer) - std::unique_ptr< QgsAbstractMaterialSettings > mMaterialSettings; //!< Defines appearance of objects + float mWidth = 2.0f; //!< Line width (horizontally) + float mOffset = 0.0f; //!< Base height of polygons + float mExtrusionHeight = 0.0f; //!< How much to extrude (0 means no walls) + bool mRenderAsSimpleLines = false; //!< Whether to render data with simple lines (otherwise it uses buffer) + std::unique_ptr mMaterialSettings; //!< Defines appearance of objects }; diff --git a/src/3d/symbols/qgsline3dsymbol_p.cpp b/src/3d/symbols/qgsline3dsymbol_p.cpp index fa6a8359014..c99d7161e21 100644 --- a/src/3d/symbols/qgsline3dsymbol_p.cpp +++ b/src/3d/symbols/qgsline3dsymbol_p.cpp @@ -36,7 +36,7 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include @@ -62,7 +62,7 @@ class QgsBufferedLine3DSymbolHandler : public QgsFeature3DHandler { public: QgsBufferedLine3DSymbolHandler( const QgsLine3DSymbol *symbol, const QgsFeatureIds &selectedIds ) - : mSymbol( static_cast< QgsLine3DSymbol *>( symbol->clone() ) ) + : mSymbol( static_cast( symbol->clone() ) ) , mSelectedIds( selectedIds ) {} bool prepare( const Qgs3DRenderContext &context, QSet &attributeNames, const QgsVector3D &chunkOrigin ) override; @@ -70,13 +70,12 @@ class QgsBufferedLine3DSymbolHandler : public QgsFeature3DHandler void finalize( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context ) override; private: - //! temporary data we will pass to the tessellator struct LineData { - std::unique_ptr tessellator; - QVector triangleIndexFids; - QVector triangleIndexStartingIndices; + std::unique_ptr tessellator; + QVector triangleIndexFids; + QVector triangleIndexStartingIndices; }; void processPolygon( QgsPolygon *polyBuffered, QgsFeatureId fid, float height, float extrusionHeight, const Qgs3DRenderContext &context, LineData &out ); @@ -84,7 +83,7 @@ class QgsBufferedLine3DSymbolHandler : public QgsFeature3DHandler void makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, LineData &out, bool selected ); // input specific for this class - std::unique_ptr< QgsLine3DSymbol > mSymbol; + std::unique_ptr mSymbol; // inputs - generic QgsFeatureIds mSelectedIds; @@ -92,28 +91,21 @@ class QgsBufferedLine3DSymbolHandler : public QgsFeature3DHandler QgsVector3D mChunkOrigin; // outputs - LineData outNormal; //!< Features that are not selected - LineData outSelected; //!< Features that are selected + LineData outNormal; //!< Features that are not selected + LineData outSelected; //!< Features that are selected }; - bool QgsBufferedLine3DSymbolHandler::prepare( const Qgs3DRenderContext &, QSet &attributeNames, const QgsVector3D &chunkOrigin ) { Q_UNUSED( attributeNames ) mChunkOrigin = chunkOrigin; - const QgsPhongTexturedMaterialSettings *texturedMaterialSettings = dynamic_cast< const QgsPhongTexturedMaterialSettings * >( mSymbol->materialSettings() ); + const QgsPhongTexturedMaterialSettings *texturedMaterialSettings = dynamic_cast( mSymbol->materialSettings() ); - outNormal.tessellator.reset( new QgsTessellator( chunkOrigin.x(), chunkOrigin.y(), true, - false, false, false, texturedMaterialSettings ? texturedMaterialSettings->requiresTextureCoordinates() : false, - 3, - texturedMaterialSettings ? texturedMaterialSettings->textureRotation() : 0 ) ); - outSelected.tessellator.reset( new QgsTessellator( chunkOrigin.x(), chunkOrigin.y(), true, - false, false, false, texturedMaterialSettings ? texturedMaterialSettings->requiresTextureCoordinates() : false, - 3, - texturedMaterialSettings ? texturedMaterialSettings->textureRotation() : 0 ) ); + outNormal.tessellator.reset( new QgsTessellator( chunkOrigin.x(), chunkOrigin.y(), true, false, false, false, texturedMaterialSettings ? texturedMaterialSettings->requiresTextureCoordinates() : false, 3, texturedMaterialSettings ? texturedMaterialSettings->textureRotation() : 0 ) ); + outSelected.tessellator.reset( new QgsTessellator( chunkOrigin.x(), chunkOrigin.y(), true, false, false, false, texturedMaterialSettings ? texturedMaterialSettings->requiresTextureCoordinates() : false, 3, texturedMaterialSettings ? texturedMaterialSettings->textureRotation() : 0 ) ); outNormal.tessellator->setOutputZUp( true ); outSelected.tessellator->setOutputZUp( true ); @@ -207,7 +199,7 @@ void QgsBufferedLine3DSymbolHandler::finalize( Qt3DCore::QEntity *parent, const void QgsBufferedLine3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, LineData &out, bool selected ) { if ( out.tessellator->dataVerticesCount() == 0 ) - return; // nothing to show - no need to create the entity + return; // nothing to show - no need to create the entity QgsMaterialContext materialContext; materialContext.setIsSelected( selected ); @@ -215,13 +207,12 @@ void QgsBufferedLine3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, cons QgsMaterial *mat = mSymbol->materialSettings()->toMaterial( QgsMaterialSettingsRenderingTechnique::Triangles, materialContext ); // extract vertex buffer data from tessellator - const QByteArray data( ( const char * )out.tessellator->data().constData(), out.tessellator->data().count() * sizeof( float ) ); + const QByteArray data( ( const char * ) out.tessellator->data().constData(), out.tessellator->data().count() * sizeof( float ) ); const int nVerts = data.count() / out.tessellator->stride(); - const QgsPhongTexturedMaterialSettings *texturedMaterialSettings = dynamic_cast< const QgsPhongTexturedMaterialSettings * >( mSymbol->materialSettings() ); + const QgsPhongTexturedMaterialSettings *texturedMaterialSettings = dynamic_cast( mSymbol->materialSettings() ); - QgsTessellatedPolygonGeometry *geometry = new QgsTessellatedPolygonGeometry( true, false, false, - texturedMaterialSettings ? texturedMaterialSettings->requiresTextureCoordinates() : false ); + QgsTessellatedPolygonGeometry *geometry = new QgsTessellatedPolygonGeometry( true, false, false, texturedMaterialSettings ? texturedMaterialSettings->requiresTextureCoordinates() : false ); geometry->setData( data, nVerts, out.triangleIndexFids, out.triangleIndexStartingIndices ); Qt3DRender::QGeometryRenderer *renderer = new Qt3DRender::QGeometryRenderer; @@ -239,7 +230,7 @@ void QgsBufferedLine3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, cons entity->setParent( parent ); if ( !selected ) - renderer->setProperty( Qgs3DTypes::PROP_NAME_3D_RENDERER_FLAG, Qgs3DTypes::Main3DRenderer ); // temporary measure to distinguish between "selected" and "main" + renderer->setProperty( Qgs3DTypes::PROP_NAME_3D_RENDERER_FLAG, Qgs3DTypes::Main3DRenderer ); // temporary measure to distinguish between "selected" and "main" // cppcheck wrongly believes entity will leak // cppcheck-suppress memleak @@ -253,7 +244,7 @@ class QgsThickLine3DSymbolHandler : public QgsFeature3DHandler { public: QgsThickLine3DSymbolHandler( const QgsLine3DSymbol *symbol, const QgsFeatureIds &selectedIds ) - : mSymbol( static_cast< QgsLine3DSymbol * >( symbol->clone() ) ) + : mSymbol( static_cast( symbol->clone() ) ) , mSelectedIds( selectedIds ) { } @@ -263,14 +254,12 @@ class QgsThickLine3DSymbolHandler : public QgsFeature3DHandler void finalize( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context ) override; private: - - void makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, QgsLineVertexData &out, bool selected ); Qt3DExtras::QPhongMaterial *material( const QgsLine3DSymbol &symbol ) const; void processMaterialDatadefined( uint verticesCount, const QgsExpressionContext &context, QgsLineVertexData &out ); // input specific for this class - std::unique_ptr< QgsLine3DSymbol > mSymbol; + std::unique_ptr mSymbol; // inputs - generic QgsFeatureIds mSelectedIds; @@ -278,12 +267,11 @@ class QgsThickLine3DSymbolHandler : public QgsFeature3DHandler QgsVector3D mChunkOrigin; // outputs - QgsLineVertexData outNormal; //!< Features that are not selected - QgsLineVertexData outSelected; //!< Features that are selected + QgsLineVertexData outNormal; //!< Features that are not selected + QgsLineVertexData outSelected; //!< Features that are selected }; - bool QgsThickLine3DSymbolHandler::prepare( const Qgs3DRenderContext &context, QSet &attributeNames, const QgsVector3D &chunkOrigin ) { Q_UNUSED( attributeNames ) @@ -375,7 +363,7 @@ void QgsThickLine3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const Q mat = defaultMaterial.toMaterial( QgsMaterialSettingsRenderingTechnique::Lines, materialContext ); } - if ( QgsLineMaterial *lineMaterial = dynamic_cast< QgsLineMaterial * >( mat ) ) + if ( QgsLineMaterial *lineMaterial = dynamic_cast( mat ) ) lineMaterial->setLineWidth( mSymbol->width() ); Qt3DCore::QEntity *entity = new Qt3DCore::QEntity; @@ -420,7 +408,7 @@ namespace Qgs3DSymbolImpl QgsFeature3DHandler *handlerForLine3DSymbol( QgsVectorLayer *layer, const QgsAbstract3DSymbol *symbol ) { - const QgsLine3DSymbol *lineSymbol = dynamic_cast< const QgsLine3DSymbol * >( symbol ); + const QgsLine3DSymbol *lineSymbol = dynamic_cast( symbol ); if ( !lineSymbol ) return nullptr; @@ -429,6 +417,6 @@ namespace Qgs3DSymbolImpl else return new QgsBufferedLine3DSymbolHandler( lineSymbol, layer->selectedFeatureIds() ); } -} +} // namespace Qgs3DSymbolImpl /// @endcond diff --git a/src/3d/symbols/qgsline3dsymbol_p.h b/src/3d/symbols/qgsline3dsymbol_p.h index d77a84c3551..d791b141302 100644 --- a/src/3d/symbols/qgsline3dsymbol_p.h +++ b/src/3d/symbols/qgsline3dsymbol_p.h @@ -38,7 +38,7 @@ namespace Qgs3DSymbolImpl { //! factory method for QgsLine3DSymbol QgsFeature3DHandler *handlerForLine3DSymbol( QgsVectorLayer *layer, const QgsAbstract3DSymbol *symbol ); -} +} // namespace Qgs3DSymbolImpl /// @endcond diff --git a/src/3d/symbols/qgslinematerial_p.cpp b/src/3d/symbols/qgslinematerial_p.cpp index 7a56114bafd..8b236fafd03 100644 --- a/src/3d/symbols/qgslinematerial_p.cpp +++ b/src/3d/symbols/qgslinematerial_p.cpp @@ -35,7 +35,7 @@ QgsLineMaterial::QgsLineMaterial() : mParameterThickness( new Qt3DRender::QParameter( "THICKNESS", 10, this ) ) - , mParameterMiterLimit( new Qt3DRender::QParameter( "MITER_LIMIT", -1, this ) ) // 0.75 + , mParameterMiterLimit( new Qt3DRender::QParameter( "MITER_LIMIT", -1, this ) ) // 0.75 , mParameterLineColor( new Qt3DRender::QParameter( "lineColor", QColor( 0, 255, 0 ), this ) ) , mParameterUseVertexColors( new Qt3DRender::QParameter( "useVertexColors", false, this ) ) , mParameterWindowScale( new Qt3DRender::QParameter( "WIN_SCALE", QSizeF(), this ) ) diff --git a/src/3d/symbols/qgslinematerial_p.h b/src/3d/symbols/qgslinematerial_p.h index c4ba049fcf2..a16e3823d8f 100644 --- a/src/3d/symbols/qgslinematerial_p.h +++ b/src/3d/symbols/qgslinematerial_p.h @@ -76,7 +76,6 @@ class QgsLineMaterial : public QgsMaterial Qt3DRender::QParameter *mParameterUseVertexColors = nullptr; Qt3DRender::QParameter *mParameterWindowScale = nullptr; - }; /// @endcond diff --git a/src/3d/symbols/qgslinevertexdata_p.cpp b/src/3d/symbols/qgslinevertexdata_p.cpp index ddf3daa18a5..8c169f206bb 100644 --- a/src/3d/symbols/qgslinevertexdata_p.cpp +++ b/src/3d/symbols/qgslinevertexdata_p.cpp @@ -15,7 +15,7 @@ #include "qgslinevertexdata_p.h" -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -119,7 +119,7 @@ Qt3DQGeometry *QgsLineVertexData::createGeometry( Qt3DCore::QNode *parent ) void QgsLineVertexData::addLineString( const QgsLineString &lineString, float extraHeightOffset ) { if ( withAdjacency ) - indexes << vertices.count(); // add the following vertex (for adjacency) + indexes << vertices.count(); // add the following vertex (for adjacency) QgsPoint centroid; switch ( altBinding ) @@ -136,16 +136,14 @@ void QgsLineVertexData::addLineString( const QgsLineString &lineString, float ex QgsPoint p = lineString.pointN( i ); float z = Qgs3DUtils::clampAltitude( p, altClamping, altBinding, baseHeight + extraHeightOffset, centroid, renderContext ); - vertices << QVector3D( static_cast< float >( p.x() - origin.x() ), - static_cast< float >( p.y() - origin.y() ), - z ); + vertices << QVector3D( static_cast( p.x() - origin.x() ), static_cast( p.y() - origin.y() ), z ); indexes << vertices.count() - 1; } if ( withAdjacency ) - indexes << vertices.count() - 1; // add the last vertex (for adjacency) + indexes << vertices.count() - 1; // add the last vertex (for adjacency) - indexes << 0; // add primitive restart + indexes << 0; // add primitive restart } void QgsLineVertexData::addVerticalLines( const QgsLineString &lineString, float verticalLength, float extraHeightOffset ) @@ -167,21 +165,17 @@ void QgsLineVertexData::addVerticalLines( const QgsLineString &lineString, float float z2 = z + verticalLength; if ( withAdjacency ) - indexes << vertices.count(); // add the following vertex (for adjacency) + indexes << vertices.count(); // add the following vertex (for adjacency) - vertices << QVector3D( static_cast< float >( p.x() - origin.x() ), - static_cast< float >( p.y() - origin.y() ), - z ); + vertices << QVector3D( static_cast( p.x() - origin.x() ), static_cast( p.y() - origin.y() ), z ); indexes << vertices.count() - 1; - vertices << QVector3D( static_cast< float >( p.x() - origin.x() ), - static_cast< float >( p.y() - origin.y() ), - z2 ); + vertices << QVector3D( static_cast( p.x() - origin.x() ), static_cast( p.y() - origin.y() ), z2 ); indexes << vertices.count() - 1; if ( withAdjacency ) - indexes << vertices.count() - 1; // add the last vertex (for adjacency) + indexes << vertices.count() - 1; // add the last vertex (for adjacency) - indexes << 0; // add primitive restart + indexes << 0; // add primitive restart } } diff --git a/src/3d/symbols/qgslinevertexdata_p.h b/src/3d/symbols/qgslinevertexdata_p.h index 8710ceb2cc3..186f51c0db1 100644 --- a/src/3d/symbols/qgslinevertexdata_p.h +++ b/src/3d/symbols/qgslinevertexdata_p.h @@ -39,12 +39,12 @@ namespace Qt3DCore { class QNode; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) class QGeometry; #endif -} +} // namespace Qt3DCore -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) namespace Qt3DRender { class QGeometry; @@ -70,33 +70,33 @@ class QgsLineString; */ struct QgsLineVertexData { - QVector vertices; - QVector indexes; - QByteArray materialDataDefined; + QVector vertices; + QVector indexes; + QByteArray materialDataDefined; - bool withAdjacency = false; //!< Whether line strip with adjacency primitive will be used + bool withAdjacency = false; //!< Whether line strip with adjacency primitive will be used - // extra info to calculate elevation - Qgis::AltitudeClamping altClamping = Qgis::AltitudeClamping::Relative; - Qgis::AltitudeBinding altBinding = Qgis::AltitudeBinding::Vertex; - float baseHeight = 0; - Qgs3DRenderContext renderContext; // used for altitude clamping - QgsVector3D origin; // all coordinates are relative to this origin (e.g. center of the chunk) + // extra info to calculate elevation + Qgis::AltitudeClamping altClamping = Qgis::AltitudeClamping::Relative; + Qgis::AltitudeBinding altBinding = Qgis::AltitudeBinding::Vertex; + float baseHeight = 0; + Qgs3DRenderContext renderContext; // used for altitude clamping + QgsVector3D origin; // all coordinates are relative to this origin (e.g. center of the chunk) - QgsLineVertexData(); + QgsLineVertexData(); - void init( Qgis::AltitudeClamping clamping, Qgis::AltitudeBinding binding, float height, const Qgs3DRenderContext &renderContext, const QgsVector3D &chunkOrigin ); + void init( Qgis::AltitudeClamping clamping, Qgis::AltitudeBinding binding, float height, const Qgs3DRenderContext &renderContext, const QgsVector3D &chunkOrigin ); - QByteArray createVertexBuffer(); - QByteArray createIndexBuffer(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - Qt3DRender::QGeometry *createGeometry( Qt3DCore::QNode *parent ); + QByteArray createVertexBuffer(); + QByteArray createIndexBuffer(); +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) + Qt3DRender::QGeometry *createGeometry( Qt3DCore::QNode *parent ); #else - Qt3DCore::QGeometry *createGeometry( Qt3DCore::QNode *parent ); + Qt3DCore::QGeometry *createGeometry( Qt3DCore::QNode *parent ); #endif - void addLineString( const QgsLineString &lineString, float extraHeightOffset = 0 ); - void addVerticalLines( const QgsLineString &lineString, float verticalLength, float extraHeightOffset = 0 ); + void addLineString( const QgsLineString &lineString, float extraHeightOffset = 0 ); + void addVerticalLines( const QgsLineString &lineString, float verticalLength, float extraHeightOffset = 0 ); }; /// @endcond diff --git a/src/3d/symbols/qgsmesh3dsymbol.cpp b/src/3d/symbols/qgsmesh3dsymbol.cpp index 38eae32fa2f..eaaee4cc852 100644 --- a/src/3d/symbols/qgsmesh3dsymbol.cpp +++ b/src/3d/symbols/qgsmesh3dsymbol.cpp @@ -20,16 +20,15 @@ #include "qgsphongmaterialsettings.h" QgsMesh3DSymbol::QgsMesh3DSymbol() - : mMaterialSettings( std::make_unique< QgsPhongMaterialSettings >() ) + : mMaterialSettings( std::make_unique() ) { - } QgsMesh3DSymbol::~QgsMesh3DSymbol() = default; QgsMesh3DSymbol *QgsMesh3DSymbol::clone() const { - std::unique_ptr< QgsMesh3DSymbol > result = std::make_unique< QgsMesh3DSymbol >(); + std::unique_ptr result = std::make_unique(); result->mAltClamping = mAltClamping; result->mHeight = mHeight; @@ -84,7 +83,7 @@ void QgsMesh3DSymbol::writeXml( QDomElement &elem, const QgsReadWriteContext &co elemAdvancedSettings.setAttribute( QStringLiteral( "vertical-scale" ), mVerticalScale ); elemAdvancedSettings.setAttribute( QStringLiteral( "vertical-group-index" ), mVerticalDatasetGroupIndex ); elemAdvancedSettings.setAttribute( QStringLiteral( "vertical-relative" ), mIsVerticalMagnitudeRelative ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ); - elemAdvancedSettings.setAttribute( QStringLiteral( "texture-type" ), static_cast< int >( mRenderingStyle ) ); + elemAdvancedSettings.setAttribute( QStringLiteral( "texture-type" ), static_cast( mRenderingStyle ) ); elemAdvancedSettings.appendChild( mColorRampShader.writeXml( doc, context ) ); elemAdvancedSettings.setAttribute( QStringLiteral( "min-color-ramp-shader" ), mColorRampShader.minimumValue() ); elemAdvancedSettings.setAttribute( QStringLiteral( "max-color-ramp-shader" ), mColorRampShader.maximumValue() ); diff --git a/src/3d/symbols/qgsmesh3dsymbol.h b/src/3d/symbols/qgsmesh3dsymbol.h index 6d4c9da57fa..486b038f6ab 100644 --- a/src/3d/symbols/qgsmesh3dsymbol.h +++ b/src/3d/symbols/qgsmesh3dsymbol.h @@ -38,7 +38,6 @@ class QgsAbstractMaterialSettings; class _3D_EXPORT QgsMesh3DSymbol : public QgsAbstract3DSymbol { public: - /** * How to render the color of the mesh * @@ -46,8 +45,8 @@ class _3D_EXPORT QgsMesh3DSymbol : public QgsAbstract3DSymbol */ enum class RenderingStyle : int { - SingleColor = 0, //!< Render the mesh with a single color - ColorRamp, //!< Render the mesh with a color ramp + SingleColor = 0, //!< Render the mesh with a single color + ColorRamp, //!< Render the mesh with a color ramp ColorRamp2DRendering, //!< Render the mesh with the color ramp shader of the 2D rendering }; @@ -58,7 +57,7 @@ class _3D_EXPORT QgsMesh3DSymbol : public QgsAbstract3DSymbol */ enum class ZValueType : int { - VerticesZValue = 0, //!< Use the Z value of the vertices + VerticesZValue = 0, //!< Use the Z value of the vertices ScalarDatasetZvalue, //!< Use the value from a dataset (for example, water surface value) }; @@ -356,8 +355,8 @@ class _3D_EXPORT QgsMesh3DSymbol : public QgsAbstract3DSymbol //! how to handle altitude of vector features Qgis::AltitudeClamping mAltClamping = Qgis::AltitudeClamping::Relative; - float mHeight = 0.0f; //!< Base height of triangles - std::unique_ptr< QgsAbstractMaterialSettings > mMaterialSettings; //!< Defines appearance of objects + float mHeight = 0.0f; //!< Base height of triangles + std::unique_ptr mMaterialSettings; //!< Defines appearance of objects bool mAddBackFaces = false; bool mEnabled = true; diff --git a/src/3d/symbols/qgspoint3dbillboardmaterial.cpp b/src/3d/symbols/qgspoint3dbillboardmaterial.cpp index 8b85b6d53c3..ad3beb5b684 100644 --- a/src/3d/symbols/qgspoint3dbillboardmaterial.cpp +++ b/src/3d/symbols/qgspoint3dbillboardmaterial.cpp @@ -117,7 +117,7 @@ void QgsPoint3DBillboardMaterial::setTexture2DFromImage( QImage image, double si void QgsPoint3DBillboardMaterial::useDefaultSymbol( const Qgs3DRenderContext &context, bool selected ) { // Default texture - const std::unique_ptr< QgsMarkerSymbol> defaultSymbol( static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ) ); + const std::unique_ptr defaultSymbol( static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ) ); setTexture2DFromSymbol( defaultSymbol.get(), context, selected ); } @@ -128,7 +128,7 @@ void QgsPoint3DBillboardMaterial::setTexture2DFromSymbol( QgsMarkerSymbol *marke context2D.setScaleFactor( context.outputDpi() / 25.4 ); context2D.setFlag( Qgis::RenderContextFlag::Antialiasing ); context2D.setFlag( Qgis::RenderContextFlag::HighQualityImageTransforms ); - const double pixelSize = context2D.convertToPainterUnits( markerSymbol->size( context2D ), markerSymbol->sizeUnit() ); + const double pixelSize = context2D.convertToPainterUnits( markerSymbol->size( context2D ), markerSymbol->sizeUnit() ); // This number is an max estimation ratio between stroke width and symbol size. const double strokeRatio = 0.5; diff --git a/src/3d/symbols/qgspoint3dsymbol.cpp b/src/3d/symbols/qgspoint3dsymbol.cpp index 57c4cb4dcf5..35844aa470f 100644 --- a/src/3d/symbols/qgspoint3dsymbol.cpp +++ b/src/3d/symbols/qgspoint3dsymbol.cpp @@ -38,7 +38,7 @@ QgsAbstract3DSymbol *QgsPoint3DSymbol::create() } QgsPoint3DSymbol::QgsPoint3DSymbol() - : mMaterialSettings( std::make_unique< QgsPhongMaterialSettings >() ) + : mMaterialSettings( std::make_unique() ) { setBillboardSymbol( static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ) ); @@ -117,26 +117,26 @@ void QgsPoint3DSymbol::readXml( const QDomElement &elem, const QgsReadWriteConte const QDomElement symbolElem = elem.firstChildElement( QStringLiteral( "symbol" ) ); - setBillboardSymbol( QgsSymbolLayerUtils::loadSymbol< QgsMarkerSymbol >( symbolElem, context ) ); + setBillboardSymbol( QgsSymbolLayerUtils::loadSymbol( symbolElem, context ) ); } QList QgsPoint3DSymbol::compatibleGeometryTypes() const { - return QList< Qgis::GeometryType >() << Qgis::GeometryType::Point; + return QList() << Qgis::GeometryType::Point; } void QgsPoint3DSymbol::setDefaultPropertiesFromLayer( const QgsVectorLayer *layer ) { - const QgsVectorLayerElevationProperties *props = qgis::down_cast< const QgsVectorLayerElevationProperties * >( const_cast< QgsVectorLayer *>( layer )->elevationProperties() ); + const QgsVectorLayerElevationProperties *props = qgis::down_cast( const_cast( layer )->elevationProperties() ); mAltClamping = props->clamping(); - mTransform.data()[13] = static_cast< float >( props->zOffset() ); - mShapeProperties[QStringLiteral( "length" )] = props->extrusionEnabled() ? static_cast< float>( props->extrusionHeight() ) : 0.0f; + mTransform.data()[13] = static_cast( props->zOffset() ); + mShapeProperties[QStringLiteral( "length" )] = props->extrusionEnabled() ? static_cast( props->extrusionHeight() ) : 0.0f; } Qgis::Point3DShape QgsPoint3DSymbol::shapeFromString( const QString &shape ) { - if ( shape == QStringLiteral( "sphere" ) ) + if ( shape == QStringLiteral( "sphere" ) ) return Qgis::Point3DShape::Sphere; else if ( shape == QLatin1String( "cone" ) ) return Qgis::Point3DShape::Cone; @@ -152,7 +152,7 @@ Qgis::Point3DShape QgsPoint3DSymbol::shapeFromString( const QString &shape ) return Qgis::Point3DShape::Model; else if ( shape == QLatin1String( "billboard" ) ) return Qgis::Point3DShape::Billboard; - else // "cylinder" (default) + else // "cylinder" (default) return Qgis::Point3DShape::Cylinder; } @@ -160,16 +160,27 @@ QString QgsPoint3DSymbol::shapeToString( Qgis::Point3DShape shape ) { switch ( shape ) { - case Qgis::Point3DShape::Cylinder: return QStringLiteral( "cylinder" ); - case Qgis::Point3DShape::Sphere: return QStringLiteral( "sphere" ); - case Qgis::Point3DShape::Cone: return QStringLiteral( "cone" ); - case Qgis::Point3DShape::Cube: return QStringLiteral( "cube" ); - case Qgis::Point3DShape::Torus: return QStringLiteral( "torus" ); - case Qgis::Point3DShape::Plane: return QStringLiteral( "plane" ); - case Qgis::Point3DShape::ExtrudedText: return QStringLiteral( "extruded-text" ); - case Qgis::Point3DShape::Model: return QStringLiteral( "model" ); - case Qgis::Point3DShape::Billboard: return QStringLiteral( "billboard" ); - default: Q_ASSERT( false ); return QString(); + case Qgis::Point3DShape::Cylinder: + return QStringLiteral( "cylinder" ); + case Qgis::Point3DShape::Sphere: + return QStringLiteral( "sphere" ); + case Qgis::Point3DShape::Cone: + return QStringLiteral( "cone" ); + case Qgis::Point3DShape::Cube: + return QStringLiteral( "cube" ); + case Qgis::Point3DShape::Torus: + return QStringLiteral( "torus" ); + case Qgis::Point3DShape::Plane: + return QStringLiteral( "plane" ); + case Qgis::Point3DShape::ExtrudedText: + return QStringLiteral( "extruded-text" ); + case Qgis::Point3DShape::Model: + return QStringLiteral( "model" ); + case Qgis::Point3DShape::Billboard: + return QStringLiteral( "billboard" ); + default: + Q_ASSERT( false ); + return QString(); } } diff --git a/src/3d/symbols/qgspoint3dsymbol.h b/src/3d/symbols/qgspoint3dsymbol.h index f002764f7e7..45bef877e3f 100644 --- a/src/3d/symbols/qgspoint3dsymbol.h +++ b/src/3d/symbols/qgspoint3dsymbol.h @@ -57,7 +57,7 @@ class _3D_EXPORT QgsPoint3DSymbol : public QgsAbstract3DSymbol SIP_NODEFAULTCTOR void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override; void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override; - QList< Qgis::GeometryType > compatibleGeometryTypes() const override; + QList compatibleGeometryTypes() const override; void setDefaultPropertiesFromLayer( const QgsVectorLayer *layer ) override; //! Returns method that determines altitude (whether to clamp to feature to terrain) @@ -172,14 +172,15 @@ class _3D_EXPORT QgsPoint3DSymbol : public QgsAbstract3DSymbol SIP_NODEFAULTCTOR * Returns whether any objects were exported */ bool exportGeometries( Qgs3DSceneExporter *exporter, Qt3DCore::QEntity *entity, const QString &objectNamePrefix ) const override SIP_SKIP; + private: //! how to handle altitude of vector features Qgis::AltitudeClamping mAltClamping = Qgis::AltitudeClamping::Relative; - std::unique_ptr< QgsAbstractMaterialSettings> mMaterialSettings; //!< Defines appearance of objects - Qgis::Point3DShape mShape = Qgis::Point3DShape::Cylinder; //!< What kind of shape to use - QVariantMap mShapeProperties; //!< Key-value dictionary of shape's properties (different keys for each shape) - QMatrix4x4 mTransform; //!< Transform of individual instanced models + std::unique_ptr mMaterialSettings; //!< Defines appearance of objects + Qgis::Point3DShape mShape = Qgis::Point3DShape::Cylinder; //!< What kind of shape to use + QVariantMap mShapeProperties; //!< Key-value dictionary of shape's properties (different keys for each shape) + QMatrix4x4 mTransform; //!< Transform of individual instanced models std::unique_ptr mBillboardSymbol; #ifdef SIP_RUN QgsPoint3DSymbol &operator=( const QgsPoint3DSymbol & ); diff --git a/src/3d/symbols/qgspoint3dsymbol_p.cpp b/src/3d/symbols/qgspoint3dsymbol_p.cpp index 8700078424a..55c0b28e63a 100644 --- a/src/3d/symbols/qgspoint3dsymbol_p.cpp +++ b/src/3d/symbols/qgspoint3dsymbol_p.cpp @@ -15,7 +15,7 @@ #include "qgspoint3dsymbol_p.h" -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -74,7 +74,7 @@ class QgsInstancedPoint3DSymbolHandler : public QgsFeature3DHandler { public: QgsInstancedPoint3DSymbolHandler( const QgsPoint3DSymbol *symbol, const QgsFeatureIds &selectedIds ) - : mSymbol( static_cast< QgsPoint3DSymbol *>( symbol->clone() ) ) + : mSymbol( static_cast( symbol->clone() ) ) , mSelectedIds( selectedIds ) {} bool prepare( const Qgs3DRenderContext &context, QSet &attributeNames, const QgsVector3D &chunkOrigin ) override; @@ -82,7 +82,6 @@ class QgsInstancedPoint3DSymbolHandler : public QgsFeature3DHandler void finalize( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context ) override; private: - static QgsMaterial *material( const QgsPoint3DSymbol *symbol, const QgsMaterialContext &materialContext ); static Qt3DRender::QGeometryRenderer *renderer( const QgsPoint3DSymbol *symbol, const QVector &positions ); static Qt3DQGeometry *symbolGeometry( const QgsPoint3DSymbol *symbol ); @@ -90,13 +89,13 @@ class QgsInstancedPoint3DSymbolHandler : public QgsFeature3DHandler //! temporary data we will pass to the tessellator struct PointData { - QVector positions; // contains triplets of float x,y,z for each point + QVector positions; // contains triplets of float x,y,z for each point }; void makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, PointData &out, bool selected ); // input specific for this class - std::unique_ptr< QgsPoint3DSymbol > mSymbol; + std::unique_ptr mSymbol; // inputs - generic QgsFeatureIds mSelectedIds; @@ -104,8 +103,8 @@ class QgsInstancedPoint3DSymbolHandler : public QgsFeature3DHandler QgsVector3D mChunkOrigin; // outputs - PointData outNormal; //!< Features that are not selected - PointData outSelected; //!< Features that are selected + PointData outNormal; //!< Features that are not selected + PointData outSelected; //!< Features that are selected }; @@ -224,12 +223,11 @@ void QgsInstancedPoint3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, co entity->addComponent( tr ); entity->setParent( parent ); -// cppcheck wrongly believes entity will leak -// cppcheck-suppress memleak + // cppcheck wrongly believes entity will leak + // cppcheck-suppress memleak } - QgsMaterial *QgsInstancedPoint3DSymbolHandler::material( const QgsPoint3DSymbol *symbol, const QgsMaterialContext &materialContext ) { Qt3DRender::QFilterKey *filterKey = new Qt3DRender::QFilterKey; @@ -252,7 +250,7 @@ QgsMaterial *QgsInstancedPoint3DSymbolHandler::material( const QgsPoint3DSymbol technique->graphicsApiFilter()->setMinorVersion( 2 ); const QMatrix4x4 transformMatrix = symbol->transform(); - QMatrix3x3 normalMatrix = transformMatrix.normalMatrix(); // transponed inverse of 3x3 sub-matrix + QMatrix3x3 normalMatrix = transformMatrix.normalMatrix(); // transponed inverse of 3x3 sub-matrix // QMatrix3x3 is not supported for passing to shaders, so we pass QMatrix4x4 float *n = normalMatrix.data(); @@ -260,7 +258,8 @@ QgsMaterial *QgsInstancedPoint3DSymbolHandler::material( const QgsPoint3DSymbol n[0], n[3], n[6], 0, n[1], n[4], n[7], 0, n[2], n[5], n[8], 0, - 0, 0, 0, 0 ); + 0, 0, 0, 0 + ); Qt3DRender::QParameter *paramInst = new Qt3DRender::QParameter; paramInst->setName( QStringLiteral( "inst" ) ); @@ -409,7 +408,7 @@ class QgsModelPoint3DSymbolHandler : public QgsFeature3DHandler { public: QgsModelPoint3DSymbolHandler( const QgsPoint3DSymbol *symbol, const QgsFeatureIds &selectedIds ) - : mSymbol( static_cast< QgsPoint3DSymbol * >( symbol->clone() ) ) + : mSymbol( static_cast( symbol->clone() ) ) , mSelectedIds( selectedIds ) {} bool prepare( const Qgs3DRenderContext &context, QSet &attributeNames, const QgsVector3D &chunkOrigin ) override; @@ -417,7 +416,6 @@ class QgsModelPoint3DSymbolHandler : public QgsFeature3DHandler void finalize( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context ) override; private: - static void addSceneEntities( const Qgs3DRenderContext &context, const QVector &positions, const QgsVector3D &chunkOrigin, const QgsPoint3DSymbol *symbol, Qt3DCore::QEntity *parent ); static void addMeshEntities( const Qgs3DRenderContext &context, const QVector &positions, const QgsVector3D &chunkOrigin, const QgsPoint3DSymbol *symbol, Qt3DCore::QEntity *parent, bool are_selected ); static QgsGeoTransform *transform( QVector3D position, const QgsPoint3DSymbol *symbol, const QgsVector3D &chunkOrigin ); @@ -425,13 +423,13 @@ class QgsModelPoint3DSymbolHandler : public QgsFeature3DHandler //! temporary data we will pass to the tessellator struct PointData { - QVector positions; // contains triplets of float x,y,z for each point + QVector positions; // contains triplets of float x,y,z for each point }; void makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, PointData &out, bool selected ); // input specific for this class - std::unique_ptr< QgsPoint3DSymbol > mSymbol; + std::unique_ptr mSymbol; // inputs - generic QgsFeatureIds mSelectedIds; @@ -439,8 +437,8 @@ class QgsModelPoint3DSymbolHandler : public QgsFeature3DHandler QgsVector3D mChunkOrigin; // outputs - PointData outNormal; //!< Features that are not selected - PointData outSelected; //!< Features that are selected + PointData outNormal; //!< Features that are not selected + PointData outSelected; //!< Features that are selected }; bool QgsModelPoint3DSymbolHandler::prepare( const Qgs3DRenderContext &context, QSet &attributeNames, const QgsVector3D &chunkOrigin ) @@ -500,7 +498,6 @@ void QgsModelPoint3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const } - void QgsModelPoint3DSymbolHandler::addSceneEntities( const Qgs3DRenderContext &context, const QVector &positions, const QgsVector3D &chunkOrigin, const QgsPoint3DSymbol *symbol, Qt3DCore::QEntity *parent ) { Q_UNUSED( context ); @@ -521,8 +518,8 @@ void QgsModelPoint3DSymbolHandler::addSceneEntities( const Qgs3DRenderContext &c entity->addComponent( transform( position, symbol, chunkOrigin ) ); entity->setParent( parent ); -// cppcheck wrongly believes entity will leak -// cppcheck-suppress memleak + // cppcheck wrongly believes entity will leak + // cppcheck-suppress memleak } } } @@ -556,8 +553,8 @@ void QgsModelPoint3DSymbolHandler::addMeshEntities( const Qgs3DRenderContext &co entity->addComponent( transform( position, symbol, chunkOrigin ) ); entity->setParent( parent ); -// cppcheck wrongly believes entity will leak -// cppcheck-suppress memleak + // cppcheck wrongly believes entity will leak + // cppcheck-suppress memleak } } } @@ -579,7 +576,7 @@ class QgsPoint3DBillboardSymbolHandler : public QgsFeature3DHandler { public: QgsPoint3DBillboardSymbolHandler( const QgsPoint3DSymbol *symbol, const QgsFeatureIds &selectedIds ) - : mSymbol( static_cast< QgsPoint3DSymbol * >( symbol->clone() ) ) + : mSymbol( static_cast( symbol->clone() ) ) , mSelectedIds( selectedIds ) {} bool prepare( const Qgs3DRenderContext &context, QSet &attributeNames, const QgsVector3D &chunkOrigin ) override; @@ -587,17 +584,16 @@ class QgsPoint3DBillboardSymbolHandler : public QgsFeature3DHandler void finalize( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context ) override; private: - //! temporary data we will pass to the tessellator struct PointData { - QVector positions; // contains triplets of float x,y,z for each point + QVector positions; // contains triplets of float x,y,z for each point }; void makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, PointData &out, bool selected ); // input specific for this class - std::unique_ptr< QgsPoint3DSymbol > mSymbol; + std::unique_ptr mSymbol; // inputs - generic QgsFeatureIds mSelectedIds; @@ -605,8 +601,8 @@ class QgsPoint3DBillboardSymbolHandler : public QgsFeature3DHandler QgsVector3D mChunkOrigin; // outputs - PointData outNormal; //!< Features that are not selected - PointData outSelected; //!< Features that are selected + PointData outNormal; //!< Features that are not selected + PointData outSelected; //!< Features that are selected }; bool QgsPoint3DBillboardSymbolHandler::prepare( const Qgs3DRenderContext &context, QSet &attributeNames, const QgsVector3D &chunkOrigin ) @@ -681,8 +677,8 @@ void QgsPoint3DBillboardSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, co entity->addComponent( billboardGeometryRenderer ); entity->setParent( parent ); -// cppcheck wrongly believes entity will leak -// cppcheck-suppress memleak + // cppcheck wrongly believes entity will leak + // cppcheck-suppress memleak } @@ -691,7 +687,7 @@ namespace Qgs3DSymbolImpl QgsFeature3DHandler *handlerForPoint3DSymbol( QgsVectorLayer *layer, const QgsAbstract3DSymbol *symbol ) { - const QgsPoint3DSymbol *pointSymbol = dynamic_cast< const QgsPoint3DSymbol * >( symbol ); + const QgsPoint3DSymbol *pointSymbol = dynamic_cast( symbol ); if ( !pointSymbol ) return nullptr; @@ -703,6 +699,6 @@ namespace Qgs3DSymbolImpl else return new QgsInstancedPoint3DSymbolHandler( pointSymbol, layer->selectedFeatureIds() ); } -} +} // namespace Qgs3DSymbolImpl /// @endcond diff --git a/src/3d/symbols/qgspoint3dsymbol_p.h b/src/3d/symbols/qgspoint3dsymbol_p.h index dbfe54a8a1c..f08ed184fd3 100644 --- a/src/3d/symbols/qgspoint3dsymbol_p.h +++ b/src/3d/symbols/qgspoint3dsymbol_p.h @@ -42,7 +42,7 @@ namespace Qgs3DSymbolImpl //! convenience function to create a complete entity from QgsPolygon3DSymbol (will run getFeatures() on the layer) Qt3DCore::QEntity *entityForPoint3DSymbol( const Qgs3DRenderContext &context, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol ); -} +} // namespace Qgs3DSymbolImpl /// @endcond diff --git a/src/3d/symbols/qgspointcloud3dsymbol.cpp b/src/3d/symbols/qgspointcloud3dsymbol.cpp index 6c93ee067e8..9f76f90f600 100644 --- a/src/3d/symbols/qgspointcloud3dsymbol.cpp +++ b/src/3d/symbols/qgspointcloud3dsymbol.cpp @@ -30,7 +30,7 @@ QgsPointCloud3DSymbol::QgsPointCloud3DSymbol() { } -QgsPointCloud3DSymbol::~QgsPointCloud3DSymbol() { } +QgsPointCloud3DSymbol::~QgsPointCloud3DSymbol() {} void QgsPointCloud3DSymbol::setPointSize( float size ) { @@ -128,7 +128,6 @@ void QgsPointCloud3DSymbol::copyBaseSettings( QgsAbstract3DSymbol *destination ) QgsSingleColorPointCloud3DSymbol::QgsSingleColorPointCloud3DSymbol() : QgsPointCloud3DSymbol() { - } QString QgsSingleColorPointCloud3DSymbol::symbolType() const @@ -150,7 +149,6 @@ void QgsSingleColorPointCloud3DSymbol::writeXml( QDomElement &elem, const QgsRea writeBaseXml( elem, context ); elem.setAttribute( QStringLiteral( "single-color" ), QgsColorUtils::colorToString( mSingleColor ) ); - } void QgsSingleColorPointCloud3DSymbol::readXml( const QDomElement &elem, const QgsReadWriteContext &context ) @@ -181,7 +179,6 @@ void QgsSingleColorPointCloud3DSymbol::fillMaterial( QgsMaterial *mat ) QgsColorRampPointCloud3DSymbol::QgsColorRampPointCloud3DSymbol() : QgsPointCloud3DSymbol() { - } QgsAbstract3DSymbol *QgsColorRampPointCloud3DSymbol::clone() const @@ -272,7 +269,7 @@ void QgsColorRampPointCloud3DSymbol::fillMaterial( QgsMaterial *mat ) Qt3DRender::QParameter *colorRampCountParameter = new Qt3DRender::QParameter( "u_colorRampCount", mColorRampShader.colorRampItemList().count() ); mat->addParameter( colorRampCountParameter ); const Qgis::ShaderInterpolationMethod colorRampType = mColorRampShader.colorRampType(); - Qt3DRender::QParameter *colorRampTypeParameter = new Qt3DRender::QParameter( "u_colorRampType", static_cast< int >( colorRampType ) ); + Qt3DRender::QParameter *colorRampTypeParameter = new Qt3DRender::QParameter( "u_colorRampType", static_cast( colorRampType ) ); mat->addParameter( colorRampTypeParameter ); } @@ -281,7 +278,6 @@ void QgsColorRampPointCloud3DSymbol::fillMaterial( QgsMaterial *mat ) QgsRgbPointCloud3DSymbol::QgsRgbPointCloud3DSymbol() : QgsPointCloud3DSymbol() { - } QString QgsRgbPointCloud3DSymbol::symbolType() const @@ -459,7 +455,6 @@ void QgsRgbPointCloud3DSymbol::setBlueContrastEnhancement( QgsContrastEnhancemen QgsClassificationPointCloud3DSymbol::QgsClassificationPointCloud3DSymbol() : QgsPointCloud3DSymbol() { - } QgsAbstract3DSymbol *QgsClassificationPointCloud3DSymbol::clone() const @@ -594,6 +589,6 @@ void QgsClassificationPointCloud3DSymbol::fillMaterial( QgsMaterial *mat ) Qt3DRender::QParameter *colorRampCountParameter = new Qt3DRender::QParameter( "u_colorRampCount", mColorRampShader.colorRampItemList().count() ); mat->addParameter( colorRampCountParameter ); const Qgis::ShaderInterpolationMethod colorRampType = mColorRampShader.colorRampType(); - Qt3DRender::QParameter *colorRampTypeParameter = new Qt3DRender::QParameter( "u_colorRampType", static_cast< int >( colorRampType ) ); + Qt3DRender::QParameter *colorRampTypeParameter = new Qt3DRender::QParameter( "u_colorRampType", static_cast( colorRampType ) ); mat->addParameter( colorRampTypeParameter ); } diff --git a/src/3d/symbols/qgspointcloud3dsymbol.h b/src/3d/symbols/qgspointcloud3dsymbol.h index 52ab85af608..a8a38c7e1f7 100644 --- a/src/3d/symbols/qgspointcloud3dsymbol.h +++ b/src/3d/symbols/qgspointcloud3dsymbol.h @@ -38,7 +38,6 @@ class _3D_EXPORT QgsPointCloud3DSymbol : public QgsAbstract3DSymbol SIP_ABSTRACT { public: - /** * How to render the point cloud */ @@ -443,7 +442,6 @@ class _3D_EXPORT QgsRgbPointCloud3DSymbol : public QgsPointCloud3DSymbol void setBlueContrastEnhancement( QgsContrastEnhancement *enhancement SIP_TRANSFER ); private: - #ifdef SIP_RUN QgsRgbPointCloud3DSymbol( const QgsRgbPointCloud3DSymbol &other ); #endif @@ -452,10 +450,9 @@ class _3D_EXPORT QgsRgbPointCloud3DSymbol : public QgsPointCloud3DSymbol QString mGreenAttribute = QStringLiteral( "Green" ); QString mBlueAttribute = QStringLiteral( "Blue" ); - std::unique_ptr< QgsContrastEnhancement > mRedContrastEnhancement; - std::unique_ptr< QgsContrastEnhancement > mGreenContrastEnhancement; - std::unique_ptr< QgsContrastEnhancement > mBlueContrastEnhancement; - + std::unique_ptr mRedContrastEnhancement; + std::unique_ptr mGreenContrastEnhancement; + std::unique_ptr mBlueContrastEnhancement; }; /** diff --git a/src/3d/symbols/qgspointcloud3dsymbol_p.cpp b/src/3d/symbols/qgspointcloud3dsymbol_p.cpp index 22d704825dc..a8d7e096208 100644 --- a/src/3d/symbols/qgspointcloud3dsymbol_p.cpp +++ b/src/3d/symbols/qgspointcloud3dsymbol_p.cpp @@ -30,7 +30,7 @@ #include #include #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -88,7 +88,7 @@ QgsPointCloud3DGeometry::QgsPointCloud3DGeometry( Qt3DCore::QNode *parent, const { if ( !data.triangles.isEmpty() ) { - mTriangleBuffer = new Qt3DQBuffer( this ); + mTriangleBuffer = new Qt3DQBuffer( this ); mTriangleIndexAttribute->setAttributeType( Qt3DQAttribute::IndexAttribute ); mTriangleIndexAttribute->setBuffer( mTriangleBuffer ); mTriangleIndexAttribute->setVertexBaseType( Qt3DQAttribute::UnsignedInt ); @@ -291,10 +291,10 @@ void QgsPointCloud3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const // Geometry Qt3DQGeometry *geom = makeGeometry( parent, out, context.symbol()->byteStride() ); Qt3DRender::QGeometryRenderer *gr = new Qt3DRender::QGeometryRenderer; - if ( context.symbol()->renderAsTriangles() && ! out.triangles.isEmpty() ) + if ( context.symbol()->renderAsTriangles() && !out.triangles.isEmpty() ) { gr->setPrimitiveType( Qt3DRender::QGeometryRenderer::Triangles ); - gr->setVertexCount( out.triangles.size() / sizeof( quint32 ) ); + gr->setVertexCount( out.triangles.size() / sizeof( quint32 ) ); } else { @@ -323,7 +323,7 @@ void QgsPointCloud3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const if ( out.triangles.isEmpty() ) { Qt3DRender::QPointSize *pointSize = new Qt3DRender::QPointSize( renderPass ); - pointSize->setSizeMode( Qt3DRender::QPointSize::Programmable ); // supported since OpenGL 3.2 + pointSize->setSizeMode( Qt3DRender::QPointSize::Programmable ); // supported since OpenGL 3.2 renderPass->addRenderState( pointSize ); } @@ -358,7 +358,6 @@ void QgsPointCloud3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const std::vector QgsPointCloud3DSymbolHandler::getVertices( QgsPointCloudIndex *pc, const QgsPointCloudNodeId &n, const QgsPointCloud3DRenderContext &context, const QgsBox3D &box3D ) { - bool hasColorData = !outNormal.colors.empty(); bool hasParameterData = !outNormal.parameter.empty(); bool hasPointSizeData = !outNormal.pointSizes.empty(); @@ -369,7 +368,7 @@ std::vector QgsPointCloud3DSymbolHandler::getVertices( QgsPointCloudInde for ( int i = 0; i < outNormal.positions.size(); ++i ) { vertices[idx++] = outNormal.positions.at( i ).x(); - vertices[idx++] = -outNormal.positions.at( i ).y(); // flipping y to have correctly oriented triangles from delaunator + vertices[idx++] = -outNormal.positions.at( i ).y(); // flipping y to have correctly oriented triangles from delaunator } // next, we also need all points of all parents nodes to make the triangulation (also external points) @@ -400,7 +399,7 @@ std::vector QgsPointCloud3DSymbolHandler::getVertices( QgsPointCloudInde { filteredExtraPointData.positions.append( pos ); vertices.push_back( pos.x() ); - vertices.push_back( -pos.y() ); // flipping y to have correctly oriented triangles from delaunator + vertices.push_back( -pos.y() ); // flipping y to have correctly oriented triangles from delaunator if ( hasColorData ) filteredExtraPointData.colors.append( outputParent.colors.at( i ) ); @@ -436,8 +435,9 @@ void QgsPointCloud3DSymbolHandler::calculateNormals( const std::vector & //calculate normals for ( size_t j = 0; j < 3; ++j ) normals[triangles.at( i + j )] += QVector3D::crossProduct( - triangleVertices.at( 1 ) - triangleVertices.at( 0 ), - triangleVertices.at( 2 ) - triangleVertices.at( 0 ) ); + triangleVertices.at( 1 ) - triangleVertices.at( 0 ), + triangleVertices.at( 2 ) - triangleVertices.at( 0 ) + ); } // Build now normals array @@ -462,8 +462,8 @@ void QgsPointCloud3DSymbolHandler::filterTriangles( const std::vector &t bool horizontalFilter = context.symbol()->horizontalTriangleFilter(); bool verticalFilter = context.symbol()->verticalTriangleFilter(); - float horizontalThreshold = context.symbol()->horizontalFilterThreshold(); - float verticalThreshold = context.symbol()->verticalFilterThreshold(); + float horizontalThreshold = context.symbol()->horizontalFilterThreshold(); + float verticalThreshold = context.symbol()->verticalFilterThreshold(); QgsBox3D boxRelativeToChunkOrigin = box3D - outNormal.positionsOrigin; @@ -474,7 +474,7 @@ void QgsPointCloud3DSymbolHandler::filterTriangles( const std::vector &t bool verticalSkip = false; for ( size_t j = 0; j < 3; j++ ) { - QVector3D pos = outNormal.positions.at( triangleIndexes.at( i + j ) ); + QVector3D pos = outNormal.positions.at( triangleIndexes.at( i + j ) ); atLeastOneInBox |= boxRelativeToChunkOrigin.contains( pos.x(), pos.y(), pos.z() ); if ( verticalFilter || horizontalFilter ) @@ -484,11 +484,10 @@ void QgsPointCloud3DSymbolHandler::filterTriangles( const std::vector &t if ( verticalFilter ) verticalSkip |= std::fabs( pos.z() - pos2.z() ) > verticalThreshold; - if ( horizontalFilter && ! verticalSkip ) + if ( horizontalFilter && !verticalSkip ) { // filter only in the horizontal plan, it is a 2.5D triangulation. - horizontalSkip |= sqrt( std::pow( pos.x() - pos2.x(), 2 ) + - std::pow( pos.y() - pos2.y(), 2 ) ) > horizontalThreshold; + horizontalSkip |= sqrt( std::pow( pos.x() - pos2.x(), 2 ) + std::pow( pos.y() - pos2.y(), 2 ) ) > horizontalThreshold; } if ( horizontalSkip || verticalSkip ) @@ -561,8 +560,7 @@ std::unique_ptr QgsPointCloud3DSymbolHandler::pointCloudBloc QEventLoop loop; QgsPointCloudBlockRequest *req = pc->asyncNodeData( n, request ); QObject::connect( req, &QgsPointCloudBlockRequest::finished, &loop, &QEventLoop::quit ); - QObject::connect( context.feedback(), &QgsFeedback::canceled, &loop, [ & ]() - { + QObject::connect( context.feedback(), &QgsFeedback::canceled, &loop, [&]() { loopAborted = true; loop.quit(); } ); @@ -579,7 +577,6 @@ std::unique_ptr QgsPointCloud3DSymbolHandler::pointCloudBloc QgsSingleColorPointCloud3DSymbolHandler::QgsSingleColorPointCloud3DSymbolHandler() : QgsPointCloud3DSymbolHandler() { - } bool QgsSingleColorPointCloud3DSymbolHandler::prepare( const QgsPointCloud3DRenderContext &context ) @@ -622,9 +619,9 @@ void QgsSingleColorPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex *p if ( context.isCanceled() ) break; - const qint32 ix = *( qint32 * )( ptr + i * recordSize + 0 ); - const qint32 iy = *( qint32 * )( ptr + i * recordSize + 4 ); - const qint32 iz = *( qint32 * )( ptr + i * recordSize + 8 ); + const qint32 ix = *( qint32 * ) ( ptr + i * recordSize + 0 ); + const qint32 iy = *( qint32 * ) ( ptr + i * recordSize + 4 ); + const qint32 iz = *( qint32 * ) ( ptr + i * recordSize + 8 ); double x = blockOffset.x() + blockScale.x() * ix; double y = blockOffset.y() + blockScale.y() * iy; @@ -659,7 +656,6 @@ Qt3DQGeometry *QgsSingleColorPointCloud3DSymbolHandler::makeGeometry( Qt3DCore:: QgsColorRampPointCloud3DSymbolHandler::QgsColorRampPointCloud3DSymbolHandler() : QgsPointCloud3DSymbolHandler() { - } bool QgsColorRampPointCloud3DSymbolHandler::prepare( const QgsPointCloud3DRenderContext &context ) @@ -747,9 +743,9 @@ void QgsColorRampPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex *pc, if ( context.isCanceled() ) break; - const qint32 ix = *( qint32 * )( ptr + i * recordSize + xOffset ); - const qint32 iy = *( qint32 * )( ptr + i * recordSize + yOffset ); - const qint32 iz = *( qint32 * )( ptr + i * recordSize + zOffset ); + const qint32 ix = *( qint32 * ) ( ptr + i * recordSize + xOffset ); + const qint32 iy = *( qint32 * ) ( ptr + i * recordSize + yOffset ); + const qint32 iz = *( qint32 * ) ( ptr + i * recordSize + zOffset ); double x = blockOffset.x() + blockScale.x() * ix; double y = blockOffset.y() + blockScale.y() * iy; @@ -797,7 +793,6 @@ Qt3DQGeometry *QgsColorRampPointCloud3DSymbolHandler::makeGeometry( Qt3DCore::QN QgsRGBPointCloud3DSymbolHandler::QgsRGBPointCloud3DSymbolHandler() : QgsPointCloud3DSymbolHandler() { - } bool QgsRGBPointCloud3DSymbolHandler::prepare( const QgsPointCloud3DRenderContext &context ) @@ -816,7 +811,7 @@ void QgsRGBPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex *pc, const QgsRgbPointCloud3DSymbol *symbol = dynamic_cast( context.symbol() ); // we have to get the RGB attributes using their real data types -- they aren't always short! (sometimes unsigned short) - int attrOffset = 0 ; + int attrOffset = 0; const int redOffset = attributes.pointRecordSize(); const QgsPointCloudAttribute *colorAttribute = context.attributes().find( symbol->redAttribute(), attrOffset ); @@ -872,9 +867,9 @@ void QgsRGBPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex *pc, const if ( context.isCanceled() ) break; - const qint32 ix = *( qint32 * )( ptr + i * recordSize + 0 ); - const qint32 iy = *( qint32 * )( ptr + i * recordSize + 4 ); - const qint32 iz = *( qint32 * )( ptr + i * recordSize + 8 ); + const qint32 ix = *( qint32 * ) ( ptr + i * recordSize + 0 ); + const qint32 iy = *( qint32 * ) ( ptr + i * recordSize + 4 ); + const qint32 iz = *( qint32 * ) ( ptr + i * recordSize + 8 ); double x = blockOffset.x() + blockScale.x() * ix; double y = blockOffset.y() + blockScale.y() * iy; double z = ( blockOffset.z() + blockScale.z() * iz ) * zValueScale + zValueOffset; @@ -942,7 +937,6 @@ Qt3DQGeometry *QgsRGBPointCloud3DSymbolHandler::makeGeometry( Qt3DCore::QNode *p QgsClassificationPointCloud3DSymbolHandler::QgsClassificationPointCloud3DSymbolHandler() : QgsPointCloud3DSymbolHandler() { - } bool QgsClassificationPointCloud3DSymbolHandler::prepare( const QgsPointCloud3DRenderContext &context ) @@ -1025,8 +1019,8 @@ void QgsClassificationPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex for ( QgsPointCloudCategory &c : categoriesList ) { categoriesValues.push_back( c.value() ); - categoriesPointSizes.insert( c.value(), c.pointSize() > 0 ? c.pointSize() : - context.symbol() ? context.symbol()->pointSize() : 1.0 ); + categoriesPointSizes.insert( c.value(), c.pointSize() > 0 ? c.pointSize() : context.symbol() ? context.symbol()->pointSize() + : 1.0 ); } if ( !output ) @@ -1040,9 +1034,9 @@ void QgsClassificationPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex if ( context.isCanceled() ) break; - const qint32 ix = *( qint32 * )( ptr + i * recordSize + xOffset ); - const qint32 iy = *( qint32 * )( ptr + i * recordSize + yOffset ); - const qint32 iz = *( qint32 * )( ptr + i * recordSize + zOffset ); + const qint32 ix = *( qint32 * ) ( ptr + i * recordSize + xOffset ); + const qint32 iy = *( qint32 * ) ( ptr + i * recordSize + yOffset ); + const qint32 iz = *( qint32 * ) ( ptr + i * recordSize + zOffset ); double x = blockOffset.x() + blockScale.x() * ix; double y = blockOffset.y() + blockScale.y() * iy; @@ -1070,13 +1064,12 @@ void QgsClassificationPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex else context.getAttribute( ptr, i * recordSize + attributeOffset, attributeType, iParam ); - if ( filteredOutValues.contains( ( int ) iParam ) || - ! categoriesValues.contains( ( int ) iParam ) ) + if ( filteredOutValues.contains( ( int ) iParam ) || !categoriesValues.contains( ( int ) iParam ) ) continue; output->positions.push_back( point.toVector3D() ); // find iParam actual index in the categories list - float iParam2 = categoriesValues.indexOf( ( int )iParam ) + 1; + float iParam2 = categoriesValues.indexOf( ( int ) iParam ) + 1; output->parameter.push_back( iParam2 ); output->pointSizes.push_back( categoriesPointSizes.value( ( int ) iParam ) ); } diff --git a/src/3d/symbols/qgspointcloud3dsymbol_p.h b/src/3d/symbols/qgspointcloud3dsymbol_p.h index 579d2a3ca5b..47b17d8ebbf 100644 --- a/src/3d/symbols/qgspointcloud3dsymbol_p.h +++ b/src/3d/symbols/qgspointcloud3dsymbol_p.h @@ -21,7 +21,7 @@ #include "qgspointcloudlayer3drenderer.h" #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #else @@ -44,9 +44,9 @@ class QgsPointCloud3DSymbolHandler struct PointData; - virtual bool prepare( const QgsPointCloud3DRenderContext &context ) = 0;// override; + virtual bool prepare( const QgsPointCloud3DRenderContext &context ) = 0; // override; virtual void processNode( QgsPointCloudIndex *pc, const QgsPointCloudNodeId &n, const QgsPointCloud3DRenderContext &context, PointData *output = nullptr ) = 0; // override; - virtual void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) = 0;// override; + virtual void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) = 0; // override; void triangulate( QgsPointCloudIndex *pc, const QgsPointCloudNodeId &n, const QgsPointCloud3DRenderContext &context, const QgsBox3D &box3D ); @@ -56,13 +56,13 @@ class QgsPointCloud3DSymbolHandler //! temporary data we will pass to the tessellator struct PointData { - QgsVector3D positionsOrigin; // All "positions" are relative to this point, defined in map coordinates (with double precision) - QVector positions; // Contains triplets of float x,y,z for each point. These are in map coordinates, relative to "positionsOrigin" - QVector parameter; - QVector pointSizes; // Contains point sizes, in case they are overridden for classification renderer - QVector colors; - QByteArray triangles; // In case of points triangulation, contains index of point in the array positions - QByteArray normals; // In case of points triangulation, contains the normals of the solid surface on each vertex + QgsVector3D positionsOrigin; // All "positions" are relative to this point, defined in map coordinates (with double precision) + QVector positions; // Contains triplets of float x,y,z for each point. These are in map coordinates, relative to "positionsOrigin" + QVector parameter; + QVector pointSizes; // Contains point sizes, in case they are overridden for classification renderer + QVector colors; + QByteArray triangles; // In case of points triangulation, contains index of point in the array positions + QByteArray normals; // In case of points triangulation, contains the normals of the solid surface on each vertex }; protected: @@ -71,7 +71,7 @@ class QgsPointCloud3DSymbolHandler void makeEntity( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context, const PointData &out, bool selected ); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) virtual Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) = 0; #else virtual Qt3DCore::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) = 0; @@ -79,7 +79,7 @@ class QgsPointCloud3DSymbolHandler std::unique_ptr pointCloudBlock( QgsPointCloudIndex *pc, const QgsPointCloudNodeId &node, const QgsPointCloudRequest &request, const QgsPointCloud3DRenderContext &context ); // outputs - PointData outNormal; //!< Features that are not selected + PointData outNormal; //!< Features that are not selected private: //! Returns all vertices of the node \a n, and of its parents contained in \a bbox and in an extension of this box depending of the density of the points @@ -109,7 +109,7 @@ class QgsSingleColorPointCloud3DSymbolHandler : public QgsPointCloud3DSymbolHand void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) override; private: -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override; #else Qt3DCore::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override; @@ -126,7 +126,7 @@ class QgsColorRampPointCloud3DSymbolHandler : public QgsPointCloud3DSymbolHandle void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) override; private: -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override; #else Qt3DCore::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override; @@ -143,7 +143,7 @@ class QgsRGBPointCloud3DSymbolHandler : public QgsPointCloud3DSymbolHandler void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) override; private: -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override; #else Qt3DCore::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override; @@ -160,17 +160,17 @@ class QgsClassificationPointCloud3DSymbolHandler : public QgsPointCloud3DSymbolH void finalize( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context ) override; private: -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override; #else Qt3DCore::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) override; #endif }; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -class QgsPointCloud3DGeometry: public Qt3DRender::QGeometry +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) +class QgsPointCloud3DGeometry : public Qt3DRender::QGeometry #else -class QgsPointCloud3DGeometry: public Qt3DCore::QGeometry +class QgsPointCloud3DGeometry : public Qt3DCore::QGeometry #endif { Q_OBJECT @@ -181,7 +181,7 @@ class QgsPointCloud3DGeometry: public Qt3DCore::QGeometry protected: virtual void makeVertexBuffer( const QgsPointCloud3DSymbolHandler::PointData &data ) = 0; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) Qt3DRender::QAttribute *mPositionAttribute = nullptr; Qt3DRender::QAttribute *mParameterAttribute = nullptr; Qt3DRender::QAttribute *mPointSizeAttribute = nullptr; @@ -235,6 +235,7 @@ class QgsRGBPointCloud3DGeometry : public QgsPointCloud3DGeometry public: QgsRGBPointCloud3DGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ); + private: void makeVertexBuffer( const QgsPointCloud3DSymbolHandler::PointData &data ) override; }; diff --git a/src/3d/symbols/qgspolygon3dsymbol.cpp b/src/3d/symbols/qgspolygon3dsymbol.cpp index 5d83e9fd059..3629b7f2796 100644 --- a/src/3d/symbols/qgspolygon3dsymbol.cpp +++ b/src/3d/symbols/qgspolygon3dsymbol.cpp @@ -27,16 +27,15 @@ #include "qgstessellatedpolygongeometry.h" QgsPolygon3DSymbol::QgsPolygon3DSymbol() - : mMaterialSettings( std::make_unique< QgsPhongMaterialSettings >() ) + : mMaterialSettings( std::make_unique() ) { - } QgsPolygon3DSymbol::~QgsPolygon3DSymbol() = default; QgsAbstract3DSymbol *QgsPolygon3DSymbol::clone() const { - std::unique_ptr< QgsPolygon3DSymbol > result = std::make_unique< QgsPolygon3DSymbol >(); + std::unique_ptr result = std::make_unique(); result->mAltClamping = mAltClamping; result->mAltBinding = mAltBinding; result->mOffset = mOffset; @@ -122,16 +121,16 @@ void QgsPolygon3DSymbol::readXml( const QDomElement &elem, const QgsReadWriteCon QList QgsPolygon3DSymbol::compatibleGeometryTypes() const { - return QList< Qgis::GeometryType >() << Qgis::GeometryType::Polygon; + return QList() << Qgis::GeometryType::Polygon; } void QgsPolygon3DSymbol::setDefaultPropertiesFromLayer( const QgsVectorLayer *layer ) { - const QgsVectorLayerElevationProperties *props = qgis::down_cast< const QgsVectorLayerElevationProperties * >( const_cast< QgsVectorLayer *>( layer )->elevationProperties() ); + const QgsVectorLayerElevationProperties *props = qgis::down_cast( const_cast( layer )->elevationProperties() ); mAltClamping = props->clamping(); mAltBinding = props->binding(); - mExtrusionHeight = props->extrusionEnabled() ? static_cast< float>( props->extrusionHeight() ) : 0.0f; + mExtrusionHeight = props->extrusionEnabled() ? static_cast( props->extrusionHeight() ) : 0.0f; if ( props->dataDefinedProperties().isActive( QgsMapLayerElevationProperties::Property::ExtrusionHeight ) ) { mDataDefinedProperties.setProperty( QgsAbstract3DSymbol::Property::ExtrusionHeight, props->dataDefinedProperties().property( QgsMapLayerElevationProperties::Property::ExtrusionHeight ) ); @@ -148,7 +147,7 @@ void QgsPolygon3DSymbol::setDefaultPropertiesFromLayer( const QgsVectorLayer *la { mDataDefinedProperties.setProperty( QgsAbstract3DSymbol::Property::Height, QgsProperty() ); } - mOffset = static_cast< float >( props->zOffset() ); + mOffset = static_cast( props->zOffset() ); } QgsAbstract3DSymbol *QgsPolygon3DSymbol::create() @@ -173,8 +172,7 @@ bool QgsPolygon3DSymbol::exportGeometries( Qgs3DSceneExporter *exporter, Qt3DCor { QList subEntities = entity->findChildren( QString(), Qt::FindDirectChildrenOnly ); // sort geometries by their name in order to always export them in the same way: - std::sort( subEntities.begin(), subEntities.end(), []( const Qt3DCore::QEntity * a, const Qt3DCore::QEntity * b ) - { + std::sort( subEntities.begin(), subEntities.end(), []( const Qt3DCore::QEntity *a, const Qt3DCore::QEntity *b ) { return a->objectName() < b->objectName(); } ); diff --git a/src/3d/symbols/qgspolygon3dsymbol.h b/src/3d/symbols/qgspolygon3dsymbol.h index 4c2345131c2..712a12d554f 100644 --- a/src/3d/symbols/qgspolygon3dsymbol.h +++ b/src/3d/symbols/qgspolygon3dsymbol.h @@ -44,7 +44,7 @@ class _3D_EXPORT QgsPolygon3DSymbol : public QgsAbstract3DSymbol SIP_NODEFAULTCT void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override; void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override; - QList< Qgis::GeometryType > compatibleGeometryTypes() const override; + QList compatibleGeometryTypes() const override; void setDefaultPropertiesFromLayer( const QgsVectorLayer *layer ) override; /** @@ -190,16 +190,16 @@ class _3D_EXPORT QgsPolygon3DSymbol : public QgsAbstract3DSymbol SIP_NODEFAULTCT //! how to handle clamping of vertices of individual features Qgis::AltitudeBinding mAltBinding = Qgis::AltitudeBinding::Centroid; - float mOffset = 0.0f; //!< Vertical offset of polygons - float mExtrusionHeight = 0.0f; //!< How much to extrude (0 means no walls) - std::unique_ptr< QgsAbstractMaterialSettings > mMaterialSettings; //!< Defines appearance of objects - Qgs3DTypes::CullingMode mCullingMode = Qgs3DTypes::NoCulling; //!< Front/back culling mode + float mOffset = 0.0f; //!< Vertical offset of polygons + float mExtrusionHeight = 0.0f; //!< How much to extrude (0 means no walls) + std::unique_ptr mMaterialSettings; //!< Defines appearance of objects + Qgs3DTypes::CullingMode mCullingMode = Qgs3DTypes::NoCulling; //!< Front/back culling mode bool mInvertNormals = false; bool mAddBackFaces = false; int mRenderedFacade = 3; - bool mEdgesEnabled = false; //!< Whether to highlight edges - float mEdgeWidth = 1.f; //!< Width of edges in pixels + bool mEdgesEnabled = false; //!< Whether to highlight edges + float mEdgeWidth = 1.f; //!< Width of edges in pixels QColor mEdgeColor = Qt::black; //!< Color of edge lines }; diff --git a/src/3d/symbols/qgspolygon3dsymbol_p.cpp b/src/3d/symbols/qgspolygon3dsymbol_p.cpp index 77e4633e00c..7860290b3a4 100644 --- a/src/3d/symbols/qgspolygon3dsymbol_p.cpp +++ b/src/3d/symbols/qgspolygon3dsymbol_p.cpp @@ -51,7 +51,7 @@ class QgsPolygon3DSymbolHandler : public QgsFeature3DHandler { public: QgsPolygon3DSymbolHandler( const QgsPolygon3DSymbol *symbol, const QgsFeatureIds &selectedIds ) - : mSymbol( static_cast< QgsPolygon3DSymbol *>( symbol->clone() ) ) + : mSymbol( static_cast( symbol->clone() ) ) , mSelectedIds( selectedIds ) {} bool prepare( const Qgs3DRenderContext &context, QSet &attributeNames, const QgsVector3D &chunkOrigin ) override; @@ -59,14 +59,13 @@ class QgsPolygon3DSymbolHandler : public QgsFeature3DHandler void finalize( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context ) override; private: - //! temporary data we will pass to the tessellator struct PolygonData { - std::unique_ptr tessellator; - QVector triangleIndexFids; - QVector triangleIndexStartingIndices; - QByteArray materialDataDefined; + std::unique_ptr tessellator; + QVector triangleIndexFids; + QVector triangleIndexStartingIndices; + QByteArray materialDataDefined; }; void processPolygon( const QgsPolygon *poly, QgsFeatureId fid, float offset, float extrusionHeight, const Qgs3DRenderContext &context, PolygonData &out ); @@ -75,7 +74,7 @@ class QgsPolygon3DSymbolHandler : public QgsFeature3DHandler QgsMaterial *material( const QgsPolygon3DSymbol *symbol, bool isSelected, const Qgs3DRenderContext &context ) const; // input specific for this class - std::unique_ptr< QgsPolygon3DSymbol > mSymbol; + std::unique_ptr mSymbol; // inputs - generic QgsFeatureIds mSelectedIds; @@ -83,10 +82,10 @@ class QgsPolygon3DSymbolHandler : public QgsFeature3DHandler QgsVector3D mChunkOrigin; // outputs - PolygonData outNormal; //!< Features that are not selected - PolygonData outSelected; //!< Features that are selected + PolygonData outNormal; //!< Features that are not selected + PolygonData outSelected; //!< Features that are selected - QgsLineVertexData outEdges; //!< When highlighting edges, this holds data for vertex/index buffer + QgsLineVertexData outEdges; //!< When highlighting edges, this holds data for vertex/index buffer }; @@ -97,17 +96,10 @@ bool QgsPolygon3DSymbolHandler::prepare( const Qgs3DRenderContext &context, QSet mChunkOrigin = chunkOrigin; - const QgsPhongTexturedMaterialSettings *texturedMaterialSettings = dynamic_cast< const QgsPhongTexturedMaterialSettings * >( mSymbol->materialSettings() ); + const QgsPhongTexturedMaterialSettings *texturedMaterialSettings = dynamic_cast( mSymbol->materialSettings() ); - outNormal.tessellator.reset( new QgsTessellator( chunkOrigin.x(), chunkOrigin.y(), true, mSymbol->invertNormals(), mSymbol->addBackFaces(), false, - texturedMaterialSettings && texturedMaterialSettings->requiresTextureCoordinates(), - mSymbol->renderedFacade(), - texturedMaterialSettings ? texturedMaterialSettings->textureRotation() : 0 ) ); - outSelected.tessellator.reset( new QgsTessellator( chunkOrigin.x(), chunkOrigin.y(), true, mSymbol->invertNormals(), - mSymbol->addBackFaces(), false, - texturedMaterialSettings && texturedMaterialSettings->requiresTextureCoordinates(), - mSymbol->renderedFacade(), - texturedMaterialSettings ? texturedMaterialSettings->textureRotation() : 0 ) ); + outNormal.tessellator.reset( new QgsTessellator( chunkOrigin.x(), chunkOrigin.y(), true, mSymbol->invertNormals(), mSymbol->addBackFaces(), false, texturedMaterialSettings && texturedMaterialSettings->requiresTextureCoordinates(), mSymbol->renderedFacade(), texturedMaterialSettings ? texturedMaterialSettings->textureRotation() : 0 ) ); + outSelected.tessellator.reset( new QgsTessellator( chunkOrigin.x(), chunkOrigin.y(), true, mSymbol->invertNormals(), mSymbol->addBackFaces(), false, texturedMaterialSettings && texturedMaterialSettings->requiresTextureCoordinates(), mSymbol->renderedFacade(), texturedMaterialSettings ? texturedMaterialSettings->textureRotation() : 0 ) ); outNormal.tessellator->setOutputZUp( true ); outSelected.tessellator->setOutputZUp( true ); @@ -121,7 +113,7 @@ bool QgsPolygon3DSymbolHandler::prepare( const Qgs3DRenderContext &context, QSet void QgsPolygon3DSymbolHandler::processPolygon( const QgsPolygon *poly, QgsFeatureId fid, float offset, float extrusionHeight, const Qgs3DRenderContext &context, PolygonData &out ) { - std::unique_ptr< QgsPolygon > polyClone( poly->clone() ); + std::unique_ptr polyClone( poly->clone() ); const uint oldVerticesCount = out.tessellator->dataVerticesCount(); if ( mSymbol->edgesEnabled() ) @@ -196,11 +188,11 @@ void QgsPolygon3DSymbolHandler::processFeature( const QgsFeature &f, const Qgs3D if ( hasDDExtrusion ) extrusionHeight = ddp.valueAsDouble( QgsAbstract3DSymbol::Property::ExtrusionHeight, context.expressionContext(), extrusionHeight ); - if ( const QgsPolygon *poly = qgsgeometry_cast< const QgsPolygon *>( g ) ) + if ( const QgsPolygon *poly = qgsgeometry_cast( g ) ) { processPolygon( poly, f.id(), offset, extrusionHeight, context, out ); } - else if ( const QgsMultiPolygon *mpoly = qgsgeometry_cast< const QgsMultiPolygon *>( g ) ) + else if ( const QgsMultiPolygon *mpoly = qgsgeometry_cast( g ) ) { for ( int i = 0; i < mpoly->numGeometries(); ++i ) { @@ -208,19 +200,19 @@ void QgsPolygon3DSymbolHandler::processFeature( const QgsFeature &f, const Qgs3D processPolygon( poly, f.id(), offset, extrusionHeight, context, out ); } } - else if ( const QgsGeometryCollection *gc = qgsgeometry_cast< const QgsGeometryCollection *>( g ) ) + else if ( const QgsGeometryCollection *gc = qgsgeometry_cast( g ) ) { for ( int i = 0; i < gc->numGeometries(); ++i ) { const QgsAbstractGeometry *g2 = gc->geometryN( i ); if ( QgsWkbTypes::flatType( g2->wkbType() ) == Qgis::WkbType::Polygon ) { - const QgsPolygon *poly = static_cast< const QgsPolygon *>( g2 ); + const QgsPolygon *poly = static_cast( g2 ); processPolygon( poly, f.id(), offset, extrusionHeight, context, out ); } } } - else if ( const QgsPolyhedralSurface *polySurface = qgsgeometry_cast< const QgsPolyhedralSurface *>( g ) ) + else if ( const QgsPolyhedralSurface *polySurface = qgsgeometry_cast( g ) ) { for ( int i = 0; i < polySurface->numPatches(); ++i ) { @@ -251,7 +243,7 @@ void QgsPolygon3DSymbolHandler::finalize( Qt3DCore::QEntity *parent, const Qgs3D mat->setLineWidth( mSymbol->edgeWidth() ); Qt3DCore::QEntity *entity = new Qt3DCore::QEntity; - entity->setObjectName( parent->objectName() + "_EDGES" ); + entity->setObjectName( parent->objectName() + "_EDGES" ); // geometry renderer Qt3DRender::QGeometryRenderer *renderer = new Qt3DRender::QGeometryRenderer; @@ -277,7 +269,7 @@ void QgsPolygon3DSymbolHandler::finalize( Qt3DCore::QEntity *parent, const Qgs3D void QgsPolygon3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, PolygonData &polyData, bool selected ) { if ( polyData.tessellator->dataVerticesCount() == 0 ) - return; // nothing to show - no need to create the entity + return; // nothing to show - no need to create the entity QgsMaterial *mat = material( mSymbol.get(), selected, context ); @@ -285,10 +277,9 @@ void QgsPolygon3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const Qgs const QByteArray data( reinterpret_cast( polyData.tessellator->data().constData() ), static_cast( polyData.tessellator->data().count() * sizeof( float ) ) ); const int nVerts = data.count() / polyData.tessellator->stride(); - const QgsPhongTexturedMaterialSettings *texturedMaterialSettings = dynamic_cast< const QgsPhongTexturedMaterialSettings * >( mSymbol->materialSettings() ); + const QgsPhongTexturedMaterialSettings *texturedMaterialSettings = dynamic_cast( mSymbol->materialSettings() ); - QgsTessellatedPolygonGeometry *geometry = new QgsTessellatedPolygonGeometry( true, mSymbol->invertNormals(), mSymbol->addBackFaces(), - texturedMaterialSettings && texturedMaterialSettings->requiresTextureCoordinates() ); + QgsTessellatedPolygonGeometry *geometry = new QgsTessellatedPolygonGeometry( true, mSymbol->invertNormals(), mSymbol->addBackFaces(), texturedMaterialSettings && texturedMaterialSettings->requiresTextureCoordinates() ); geometry->setData( data, nVerts, polyData.triangleIndexFids, polyData.triangleIndexStartingIndices ); @@ -311,10 +302,10 @@ void QgsPolygon3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const Qgs entity->setParent( parent ); if ( !selected ) - renderer->setProperty( Qgs3DTypes::PROP_NAME_3D_RENDERER_FLAG, Qgs3DTypes::Main3DRenderer ); // temporary measure to distinguish between "selected" and "main" + renderer->setProperty( Qgs3DTypes::PROP_NAME_3D_RENDERER_FLAG, Qgs3DTypes::Main3DRenderer ); // temporary measure to distinguish between "selected" and "main" -// cppcheck wrongly believes entity will leak -// cppcheck-suppress memleak + // cppcheck wrongly believes entity will leak + // cppcheck-suppress memleak } // front/back side culling @@ -340,9 +331,7 @@ QgsMaterial *QgsPolygon3DSymbolHandler::material( const QgsPolygon3DSymbol *symb materialContext.setSelectionColor( context.selectionColor() ); const bool dataDefined = mSymbol->materialSettings()->dataDefinedProperties().hasActiveProperties(); - QgsMaterial *material = symbol->materialSettings()->toMaterial( dataDefined ? - QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined : QgsMaterialSettingsRenderingTechnique::Triangles, - materialContext ); + QgsMaterial *material = symbol->materialSettings()->toMaterial( dataDefined ? QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined : QgsMaterialSettingsRenderingTechnique::Triangles, materialContext ); applyCullingMode( symbol->cullingMode(), material ); return material; } @@ -357,12 +346,12 @@ namespace Qgs3DSymbolImpl QgsFeature3DHandler *handlerForPolygon3DSymbol( QgsVectorLayer *layer, const QgsAbstract3DSymbol *symbol ) { - const QgsPolygon3DSymbol *polygonSymbol = dynamic_cast< const QgsPolygon3DSymbol * >( symbol ); + const QgsPolygon3DSymbol *polygonSymbol = dynamic_cast( symbol ); if ( !polygonSymbol ) return nullptr; return new QgsPolygon3DSymbolHandler( polygonSymbol, layer->selectedFeatureIds() ); } -} +} // namespace Qgs3DSymbolImpl /// @endcond diff --git a/src/3d/symbols/qgspolygon3dsymbol_p.h b/src/3d/symbols/qgspolygon3dsymbol_p.h index 8faaca3364a..d77bd2acf44 100644 --- a/src/3d/symbols/qgspolygon3dsymbol_p.h +++ b/src/3d/symbols/qgspolygon3dsymbol_p.h @@ -38,7 +38,7 @@ namespace Qgs3DSymbolImpl { //! factory method for QgsPolygon3DSymbol QgsFeature3DHandler *handlerForPolygon3DSymbol( QgsVectorLayer *layer, const QgsAbstract3DSymbol *symbol ); -} +} // namespace Qgs3DSymbolImpl /// @endcond diff --git a/src/3d/terrain/qgsdemterraingenerator.h b/src/3d/terrain/qgsdemterraingenerator.h index f0839bdad9f..4ba881e22fd 100644 --- a/src/3d/terrain/qgsdemterraingenerator.h +++ b/src/3d/terrain/qgsdemterraingenerator.h @@ -52,7 +52,11 @@ class _3D_EXPORT QgsDemTerrainGenerator : public QgsTerrainGenerator QgsCoordinateReferenceSystem crs() const override { return mCrs; } //! Sets resolution of the generator (how many elevation samples on one side of a terrain tile) - void setResolution( int resolution ) { mResolution = resolution; updateGenerator(); } + void setResolution( int resolution ) + { + mResolution = resolution; + updateGenerator(); + } //! Returns resolution of the generator (how many elevation samples on one side of a terrain tile) int resolution() const { return mResolution; } diff --git a/src/3d/terrain/qgsdemterraintilegeometry_p.cpp b/src/3d/terrain/qgsdemterraintilegeometry_p.cpp index 5b61dfc457d..6b2de5005f5 100644 --- a/src/3d/terrain/qgsdemterraintilegeometry_p.cpp +++ b/src/3d/terrain/qgsdemterraintilegeometry_p.cpp @@ -18,7 +18,7 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -93,7 +93,7 @@ static QByteArray createPlaneVertexData( int res, float side, float vertScale, f if ( i == iBound && j == jBound ) height = *zBits++; else - height = zData[ jBound * resolution.width() + iBound ] - skirtHeight; + height = zData[jBound * resolution.width() + iBound] - skirtHeight; if ( std::isnan( height ) ) height = noDataHeight; @@ -108,7 +108,7 @@ static QByteArray createPlaneVertexData( int res, float side, float vertScale, f *fptr++ = v; // calculate normal coordinates -#define zAt( ii, jj ) zData[ jj * resolution.width() + ii ] * vertScale +#define zAt( ii, jj ) zData[jj * resolution.width() + ii] * vertScale float zi0 = zAt( std::clamp( i - 1, 0, iMax ), jBound ); float zi1 = zAt( std::clamp( i + 1, 0, iMax ), jBound ); float zj0 = zAt( iBound, std::clamp( j - 1, 0, jMax ) ); @@ -158,10 +158,7 @@ inline int ijToHeightMapIndex( int i, int j, int resX, int resZ ) static bool hasNoData( int i, int j, const float *heightMap, int resX, int resZ ) { - return std::isnan( heightMap[ ijToHeightMapIndex( i, j, resX, resZ ) ] ) || - std::isnan( heightMap[ ijToHeightMapIndex( i + 1, j, resX, resZ ) ] ) || - std::isnan( heightMap[ ijToHeightMapIndex( i, j + 1, resX, resZ ) ] ) || - std::isnan( heightMap[ ijToHeightMapIndex( i + 1, j + 1, resX, resZ ) ] ); + return std::isnan( heightMap[ijToHeightMapIndex( i, j, resX, resZ )] ) || std::isnan( heightMap[ijToHeightMapIndex( i + 1, j, resX, resZ )] ) || std::isnan( heightMap[ijToHeightMapIndex( i, j + 1, resX, resZ )] ) || std::isnan( heightMap[ijToHeightMapIndex( i + 1, j + 1, resX, resZ )] ); } static QByteArray createPlaneIndexData( int res, const QByteArray &heightMap ) @@ -237,15 +234,11 @@ class PlaneVertexBufferFunctor : public Qt3DQAbstractFunctor return createPlaneVertexData( mResolution, mSide, mVertScale, mSkirtHeight, mHeightMap ); } - bool operator ==( const Qt3DQAbstractFunctor &other ) const + bool operator==( const Qt3DQAbstractFunctor &other ) const { const PlaneVertexBufferFunctor *otherFunctor = functor_cast( &other ); if ( otherFunctor ) - return ( otherFunctor->mResolution == mResolution && - otherFunctor->mSide == mSide && - otherFunctor->mVertScale == mVertScale && - otherFunctor->mSkirtHeight == mSkirtHeight && - otherFunctor->mHeightMap == mHeightMap ); + return ( otherFunctor->mResolution == mResolution && otherFunctor->mSide == mSide && otherFunctor->mVertScale == mVertScale && otherFunctor->mSkirtHeight == mSkirtHeight && otherFunctor->mHeightMap == mHeightMap ); return false; } @@ -261,7 +254,7 @@ class PlaneVertexBufferFunctor : public Qt3DQAbstractFunctor //! Generates index buffer for DEM terrain tiles -class PlaneIndexBufferFunctor: public Qt3DQAbstractFunctor +class PlaneIndexBufferFunctor : public Qt3DQAbstractFunctor { public: explicit PlaneIndexBufferFunctor( int resolution, const QByteArray &heightMap ) @@ -274,7 +267,7 @@ class PlaneIndexBufferFunctor: public Qt3DQAbstractFunctor return createPlaneIndexData( mResolution, mHeightMap ); } - bool operator ==( const Qt3DQAbstractFunctor &other ) const + bool operator==( const Qt3DQAbstractFunctor &other ) const { const PlaneIndexBufferFunctor *otherFunctor = functor_cast( &other ); if ( otherFunctor ) diff --git a/src/3d/terrain/qgsdemterraintilegeometry_p.h b/src/3d/terrain/qgsdemterraintilegeometry_p.h index 93407efcdc5..a793f9653f1 100644 --- a/src/3d/terrain/qgsdemterraintilegeometry_p.h +++ b/src/3d/terrain/qgsdemterraintilegeometry_p.h @@ -30,7 +30,7 @@ #define SIP_NO_FILE #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #else #include @@ -39,18 +39,18 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) namespace Qt3DRender { class QAttribute; class QBuffer; -} +} // namespace Qt3DRender #else namespace Qt3DCore { class QAttribute; class QBuffer; -} +} // namespace Qt3DCore #endif namespace QgsRayCastingUtils @@ -62,7 +62,7 @@ namespace QgsRayCastingUtils * \ingroup 3d * \brief Stores attributes and vertex/index buffers for one terrain tile based on DEM. */ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) class DemTerrainTileGeometry : public Qt3DRender::QGeometry #else class DemTerrainTileGeometry : public Qt3DCore::QGeometry @@ -71,7 +71,6 @@ class DemTerrainTileGeometry : public Qt3DCore::QGeometry Q_OBJECT public: - /** * Constructs a terrain tile geometry. Resolution is the number of vertices on one side of the tile, * heightMap is array of float values with one height value for each vertex @@ -80,7 +79,7 @@ class DemTerrainTileGeometry : public Qt3DCore::QGeometry bool rayIntersection( const QgsRayCastingUtils::Ray3D &ray, const QMatrix4x4 &worldTransform, QVector3D &intersectionPoint ); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) Qt3DRender::QAttribute *positionAttribute() { return mPositionAttribute; } Qt3DRender::QAttribute *normalAttribute() { return mNormalAttribute; } Qt3DRender::QAttribute *texCoordsAttribute() { return mTexCoordAttribute; } @@ -100,7 +99,7 @@ class DemTerrainTileGeometry : public Qt3DCore::QGeometry float mVertScale; float mSkirtHeight; QByteArray mHeightMap; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) Qt3DRender::QAttribute *mPositionAttribute = nullptr; Qt3DRender::QAttribute *mNormalAttribute = nullptr; Qt3DRender::QAttribute *mTexCoordAttribute = nullptr; @@ -119,4 +118,4 @@ class DemTerrainTileGeometry : public Qt3DCore::QGeometry /// @endcond -#endif // QGSDEMTERRAINTILEGEOMETRY_P_H +#endif // QGSDEMTERRAINTILEGEOMETRY_P_H diff --git a/src/3d/terrain/qgsdemterraintileloader_p.cpp b/src/3d/terrain/qgsdemterraintileloader_p.cpp index 44385847cbd..d9777af73a8 100644 --- a/src/3d/terrain/qgsdemterraintileloader_p.cpp +++ b/src/3d/terrain/qgsdemterraintileloader_p.cpp @@ -61,7 +61,6 @@ QgsDemTerrainTileLoader::QgsDemTerrainTileLoader( QgsTerrainEntity *terrain, Qgs : QgsTerrainTileLoader( terrain, node ) , mResolution( 0 ) { - QgsDemHeightMapGenerator *heightMapGenerator = nullptr; if ( terrainGenerator->type() == QgsTerrainGenerator::Dem ) { @@ -117,8 +116,7 @@ Qt3DCore::QEntity *QgsDemTerrainTileLoader::createEntity( Qt3DCore::QEntity *par transform->setGeoTranslation( QgsVector3D( extent.xMinimum(), extent.yMinimum(), 0 ) ); entity->addComponent( transform ); - mNode->setExactBox3D( QgsBox3D( extent.xMinimum(), extent.yMinimum(), zMin * map->terrainVerticalScale(), - extent.xMinimum() + side, extent.yMinimum() + side, zMax * map->terrainVerticalScale() ) ); + mNode->setExactBox3D( QgsBox3D( extent.xMinimum(), extent.yMinimum(), zMin * map->terrainVerticalScale(), extent.xMinimum() + side, extent.yMinimum() + side, zMax * map->terrainVerticalScale() ) ); mNode->updateParentBoundingBoxesRecursively(); entity->setParent( parent ); @@ -179,7 +177,7 @@ static QByteArray _readDtmData( QgsRasterDataProvider *provider, const QgsRectan projector->setInput( provider ); input = projector.get(); } - std::unique_ptr< QgsRasterBlock > block( input->block( 1, extent, res, res ) ); + std::unique_ptr block( input->block( 1, extent, res, res ) ); QByteArray data; if ( block ) @@ -197,7 +195,7 @@ static QByteArray _readDtmData( QgsRasterDataProvider *provider, const QgsRectan block->setIsNoDataExcept( subRect ); data = block->data(); - data.detach(); // this should make a deep copy + data.detach(); // this should make a deep copy if ( block->hasNoData() ) { @@ -245,7 +243,7 @@ int QgsDemHeightMapGenerator::render( const QgsChunkNodeId &nodeId ) if ( mClonedProvider ) { // make a clone of the data provider so it is safe to use in worker thread - std::unique_ptr< QgsRasterDataProvider > clonedProviderClone( mClonedProvider->clone() ); + std::unique_ptr clonedProviderClone( mClonedProvider->clone() ); clonedProviderClone->moveToThread( nullptr ); jd.future = QtConcurrent::run( _readDtmData, clonedProviderClone.release(), extent, mResolution, mTilingScheme.crs(), mTilingScheme.fullExtent() ); } @@ -269,7 +267,7 @@ void QgsDemHeightMapGenerator::waitForFinished() disconnect( fw, &QFutureWatcher::finished, this, &QgsDemHeightMapGenerator::onFutureFinished ); disconnect( fw, &QFutureWatcher::finished, fw, &QObject::deleteLater ); } - QVector*> toBeDeleted; + QVector *> toBeDeleted; for ( auto it = mJobs.keyBegin(); it != mJobs.keyEnd(); it++ ) { QFutureWatcher *fw = *it; @@ -293,24 +291,24 @@ void QgsDemHeightMapGenerator::lazyLoadDtmCoarseData( int res, const QgsRectangl QMutexLocker locker( &mLazyLoadDtmCoarseDataMutex ); if ( mDtmCoarseData.isEmpty() ) { - std::unique_ptr< QgsRasterBlock > block( mClonedProvider->block( 1, rect, res, res ) ); + std::unique_ptr block( mClonedProvider->block( 1, rect, res, res ) ); block->convert( Qgis::DataType::Float32 ); mDtmCoarseData = block->data(); - mDtmCoarseData.detach(); // make a deep copy + mDtmCoarseData.detach(); // make a deep copy } } float QgsDemHeightMapGenerator::heightAt( double x, double y ) { if ( !mClonedProvider ) - return 0; // TODO: calculate heights for online DTM + return 0; // TODO: calculate heights for online DTM // TODO: this is quite a primitive implementation: better to use heightmaps currently in use int res = 1024; lazyLoadDtmCoarseData( res, mDtmExtent ); - int cellX = ( int )( ( x - mDtmExtent.xMinimum() ) / mDtmExtent.width() * res + .5f ); - int cellY = ( int )( ( mDtmExtent.yMaximum() - y ) / mDtmExtent.height() * res + .5f ); + int cellX = ( int ) ( ( x - mDtmExtent.xMinimum() ) / mDtmExtent.width() * res + .5f ); + int cellY = ( int ) ( ( mDtmExtent.yMaximum() - y ) / mDtmExtent.height() * res + .5f ); cellX = std::clamp( cellX, 0, res - 1 ); cellY = std::clamp( cellY, 0, res - 1 ); @@ -320,7 +318,7 @@ float QgsDemHeightMapGenerator::heightAt( double x, double y ) void QgsDemHeightMapGenerator::onFutureFinished() { - QFutureWatcher *fw = static_cast*>( sender() ); + QFutureWatcher *fw = static_cast *>( sender() ); Q_ASSERT( fw ); Q_ASSERT( mJobs.contains( fw ) ); JobData jobData = mJobs.value( fw ); diff --git a/src/3d/terrain/qgsdemterraintileloader_p.h b/src/3d/terrain/qgsdemterraintileloader_p.h index 198700960f3..02884d87632 100644 --- a/src/3d/terrain/qgsdemterraintileloader_p.h +++ b/src/3d/terrain/qgsdemterraintileloader_p.h @@ -62,7 +62,6 @@ class QgsDemTerrainTileLoader : public QgsTerrainTileLoader void onHeightMapReady( int jobId, const QByteArray &heightMap ); private: - int mHeightMapJobId; QByteArray mHeightMap; int mResolution; @@ -80,7 +79,6 @@ class QgsDemHeightMapGenerator : public QObject { Q_OBJECT public: - /** * Constructs height map generator based on a raster layer with elevation model, * terrain's tiling scheme and height map resolution (number of height values on each side of tile) @@ -124,14 +122,14 @@ class QgsDemHeightMapGenerator : public QObject struct JobData { - int jobId; - QgsChunkNodeId tileId; - QgsRectangle extent; - QFuture future; - QElapsedTimer timer; + int jobId; + QgsChunkNodeId tileId; + QgsRectangle extent; + QFuture future; + QElapsedTimer timer; }; - QHash*, JobData> mJobs; + QHash *, JobData> mJobs; void lazyLoadDtmCoarseData( int res, const QgsRectangle &rect ); mutable QMutex mLazyLoadDtmCoarseDataMutex; diff --git a/src/3d/terrain/qgsflatterraingenerator.cpp b/src/3d/terrain/qgsflatterraingenerator.cpp index 6ae1cff5ec3..5cfb2b77184 100644 --- a/src/3d/terrain/qgsflatterraingenerator.cpp +++ b/src/3d/terrain/qgsflatterraingenerator.cpp @@ -50,7 +50,7 @@ Qt3DCore::QEntity *FlatTerrainChunkLoader::createEntity( Qt3DCore::QEntity *pare Qt3DRender::QGeometryRenderer *mesh = new Qt3DRender::QGeometryRenderer; mesh->setGeometry( mTileGeometry ); // takes ownership if the component has no parent - entity->addComponent( mesh ); // takes ownership if the component has no parent + entity->addComponent( mesh ); // takes ownership if the component has no parent // create material @@ -66,12 +66,7 @@ Qt3DCore::QEntity *FlatTerrainChunkLoader::createEntity( Qt3DCore::QEntity *pare const QgsBox3D box3D = mNode->box3D(); const QgsBox3D mapFullBox3D( map->extent(), box3D.zMinimum(), box3D.zMaximum() ); - const QgsBox3D commonExtent( std::max( box3D.xMinimum(), mapFullBox3D.xMinimum() ), - std::max( box3D.yMinimum(), mapFullBox3D.yMinimum() ), - box3D.zMinimum(), - std::min( box3D.xMaximum(), mapFullBox3D.xMaximum() ), - std::min( box3D.yMaximum(), mapFullBox3D.yMaximum() ), - box3D.zMaximum() ); + const QgsBox3D commonExtent( std::max( box3D.xMinimum(), mapFullBox3D.xMinimum() ), std::max( box3D.yMinimum(), mapFullBox3D.yMinimum() ), box3D.zMinimum(), std::min( box3D.xMaximum(), mapFullBox3D.xMaximum() ), std::min( box3D.yMaximum(), mapFullBox3D.yMaximum() ), box3D.zMaximum() ); const double xSide = commonExtent.width(); const double ySide = commonExtent.height(); const double xMin = commonExtent.xMinimum(); diff --git a/src/3d/terrain/qgsflatterraingenerator.h b/src/3d/terrain/qgsflatterraingenerator.h index cb1fe08cdb1..e707ee93b71 100644 --- a/src/3d/terrain/qgsflatterraingenerator.h +++ b/src/3d/terrain/qgsflatterraingenerator.h @@ -52,7 +52,6 @@ class _3D_EXPORT QgsFlatTerrainGenerator : public QgsTerrainGenerator { Q_OBJECT public: - QgsFlatTerrainGenerator() = default; QgsChunkLoader *createChunkLoader( QgsChunkNode *node ) const override SIP_FACTORY; @@ -71,13 +70,10 @@ class _3D_EXPORT QgsFlatTerrainGenerator : public QgsTerrainGenerator QgsCoordinateReferenceSystem crs() const override { return mCrs; } private: - void updateTilingScheme(); QgsCoordinateReferenceSystem mCrs; }; - - #endif // QGSFLATTERRAINGENERATOR_H diff --git a/src/3d/terrain/qgsonlineterraingenerator.h b/src/3d/terrain/qgsonlineterraingenerator.h index afdb4ecf5be..675a3fba3f3 100644 --- a/src/3d/terrain/qgsonlineterraingenerator.h +++ b/src/3d/terrain/qgsonlineterraingenerator.h @@ -47,7 +47,11 @@ class _3D_EXPORT QgsOnlineTerrainGenerator : public QgsTerrainGenerator QgsCoordinateReferenceSystem crs() const override { return mCrs; } //! Sets resolution of the generator (how many elevation samples on one side of a terrain tile) - void setResolution( int resolution ) { mResolution = resolution; updateGenerator(); } + void setResolution( int resolution ) + { + mResolution = resolution; + updateGenerator(); + } //! Returns resolution of the generator (how many elevation samples on one side of a terrain tile) int resolution() const { return mResolution; } @@ -71,7 +75,6 @@ class _3D_EXPORT QgsOnlineTerrainGenerator : public QgsTerrainGenerator QgsChunkLoader *createChunkLoader( QgsChunkNode *node ) const override SIP_FACTORY; private: - void updateGenerator(); QgsCoordinateReferenceSystem mCrs; diff --git a/src/3d/terrain/qgsquantizedmeshterraingenerator.cpp b/src/3d/terrain/qgsquantizedmeshterraingenerator.cpp index 8fd97dcbe75..3a1ec8c0c5a 100644 --- a/src/3d/terrain/qgsquantizedmeshterraingenerator.cpp +++ b/src/3d/terrain/qgsquantizedmeshterraingenerator.cpp @@ -55,7 +55,8 @@ class QgsQuantizedMeshTerrainChunkLoader : public QgsTerrainTileLoader Q_OBJECT public: QgsQuantizedMeshTerrainChunkLoader( - QgsTerrainEntity *terrain, QgsChunkNode *node, long long tileId, QgsTiledSceneIndex index, const QgsCoordinateTransform &tileCrsToMapCrs ); + QgsTerrainEntity *terrain, QgsChunkNode *node, long long tileId, QgsTiledSceneIndex index, const QgsCoordinateTransform &tileCrsToMapCrs + ); virtual Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override; protected: @@ -79,8 +80,7 @@ QgsQuantizedMeshTerrainChunkLoader::QgsQuantizedMeshTerrainChunkLoader( QgsTerra bool shadingEnabled = map->isTerrainShadingEnabled(); QgsVector3D chunkOrigin = node->box3D().center(); - QThreadPool::globalInstance()->start( [ this, node, tileId, index, tileCrsToMapCrs, vertScale, chunkOrigin, shadingEnabled ]() - { + QThreadPool::globalInstance()->start( [this, node, tileId, index, tileCrsToMapCrs, vertScale, chunkOrigin, shadingEnabled]() { if ( tileId == QgsQuantizedMeshIndex::ROOT_TILE_ID ) { // Nothing to load for imaginary root tile @@ -102,7 +102,7 @@ QgsQuantizedMeshTerrainChunkLoader::QgsQuantizedMeshTerrainChunkLoader( QgsTerra entityTransform.tileTransform = ( tile.transform() ? *tile.transform() : QgsMatrix4x4() ); entityTransform.chunkOriginTargetCrs = chunkOrigin; entityTransform.ecefToTargetCrs = &tileCrsToMapCrs; - entityTransform.gltfUpAxis = static_cast< Qgis::Axis >( tile.metadata().value( QStringLiteral( "gltfUpAxis" ), static_cast< int >( Qgis::Axis::Y ) ).toInt() ); + entityTransform.gltfUpAxis = static_cast( tile.metadata().value( QStringLiteral( "gltfUpAxis" ), static_cast( Qgis::Axis::Y ) ).toInt() ); try { @@ -209,11 +209,11 @@ void QgsQuantizedMeshTerrainChunkLoader::onTextureLoaded() void QgsQuantizedMeshTerrainGenerator::setTerrain( QgsTerrainEntity *t ) { mTerrain = t; - mTileCrsToMapCrs = - QgsCoordinateTransform( - mMetadata->mCrs, - mTerrain->mapSettings()->crs(), - mTerrain->mapSettings()->transformContext() ); + mTileCrsToMapCrs = QgsCoordinateTransform( + mMetadata->mCrs, + mTerrain->mapSettings()->crs(), + mTerrain->mapSettings()->transformContext() + ); } QgsTerrainGenerator *QgsQuantizedMeshTerrainGenerator::clone() const @@ -312,16 +312,17 @@ QgsChunkLoader *QgsQuantizedMeshTerrainGenerator::createChunkLoader( QgsChunkNod QgsChunkNode *QgsQuantizedMeshTerrainGenerator::createRootNode() const { return new QgsChunkNode( - {0, 0, 0}, - mRootBox3D, // Given to us by setupQuadtree() - mMetadata->geometricErrorAtZoom( -1 ) ); + { 0, 0, 0 }, + mRootBox3D, // Given to us by setupQuadtree() + mMetadata->geometricErrorAtZoom( -1 ) + ); } QVector QgsQuantizedMeshTerrainGenerator::createChildren( QgsChunkNode *node ) const { QVector children; - for ( auto offset : std::vector> {{0, 0}, {0, 1}, {1, 0}, {1, 1}} ) + for ( auto offset : std::vector> { { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 } } ) { QgsChunkNodeId childId( node->tileId().d + 1, @@ -345,7 +346,9 @@ QVector QgsQuantizedMeshTerrainGenerator::createChildren( QgsChu childId, QgsBox3D( corner1, corner2 ), mMetadata->geometricErrorAtZoom( tile.zoomLevel() ), - node ) ); + node + ) + ); } return children; @@ -391,13 +394,13 @@ QgsTileXYZ QgsQuantizedMeshTerrainGenerator::nodeIdToTile( QgsChunkNodeId nodeId // nodeId zoom=0 is tile zoom=-1 to get unique root tile if ( nodeId.d == 0 ) return { 0, 0, -1 }; - return - { + return { nodeId.x, mMetadata->mTileScheme == QStringLiteral( "tms" ) - ? ( 1 << ( nodeId.d - 1 ) ) - nodeId.y - 1 - : nodeId.y, - nodeId.d - 1 }; + ? ( 1 << ( nodeId.d - 1 ) ) - nodeId.y - 1 + : nodeId.y, + nodeId.d - 1 + }; } #include "qgsquantizedmeshterraingenerator.moc" diff --git a/src/3d/terrain/qgsterraindownloader.cpp b/src/3d/terrain/qgsterraindownloader.cpp index b267cba90f1..d118e1cc270 100644 --- a/src/3d/terrain/qgsterraindownloader.cpp +++ b/src/3d/terrain/qgsterraindownloader.cpp @@ -86,7 +86,8 @@ double QgsTerrainDownloader::findBestTileResolution( double requestedMupp ) cons break; } - if ( zoom > 15 ) zoom = 15; + if ( zoom > 15 ) + zoom = 15; const double finalMupp = mXSpan / ( 256 * ( 1 << zoom ) ); return finalMupp; } @@ -172,8 +173,7 @@ QByteArray QgsTerrainDownloader::getHeightMap( const QgsRectangle &extentOrig, i } // resample to the desired extent + resolution - QgsGdalUtils::resampleSingleBandRaster( hSrcDS.get(), hDstDS.get(), GRA_Bilinear, - context.calculateCoordinateOperation( mOnlineDtm->crs(), destCrs ).toUtf8().constData() ); + QgsGdalUtils::resampleSingleBandRaster( hSrcDS.get(), hDstDS.get(), GRA_Bilinear, context.calculateCoordinateOperation( mOnlineDtm->crs(), destCrs ).toUtf8().constData() ); QByteArray heightMapOut; heightMapOut.resize( resOrig * resOrig * sizeof( float ) ); diff --git a/src/3d/terrain/qgsterraindownloader.h b/src/3d/terrain/qgsterraindownloader.h index 427b01534a1..de600123e73 100644 --- a/src/3d/terrain/qgsterraindownloader.h +++ b/src/3d/terrain/qgsterraindownloader.h @@ -47,23 +47,21 @@ class QgsCoordinateTransformContext; */ class _3D_EXPORT QgsTerrainDownloader { - public: - /** * Constructs a QgsTerrainDownloader object * \param transformContext coordinate transform context */ - QgsTerrainDownloader( const QgsCoordinateTransformContext &transformContext ); + QgsTerrainDownloader( const QgsCoordinateTransformContext &transformContext ); ~QgsTerrainDownloader(); //! Definition of data source for terrain tiles (assuming "terrarium" data encoding with usual XYZ tiling scheme) struct DataSource { - QString uri; //!< HTTP(S) template for XYZ tiles requests (e.g. http://example.com/{z}/{x}/{y}.png) - int zMin = 0; //!< Minimum zoom level (Z) with valid data - int zMax = 0; //!< Maximum zoom level (Z) with valid data + QString uri; //!< HTTP(S) template for XYZ tiles requests (e.g. http://example.com/{z}/{x}/{y}.png) + int zMin = 0; //!< Minimum zoom level (Z) with valid data + int zMax = 0; //!< Maximum zoom level (Z) with valid data }; //! Returns the data source used by default @@ -82,7 +80,6 @@ class _3D_EXPORT QgsTerrainDownloader QByteArray getHeightMap( const QgsRectangle &extentOrig, int res, const QgsCoordinateReferenceSystem &destCrs, const QgsCoordinateTransformContext &context = QgsCoordinateTransformContext(), QString tmpFilenameImg = QString(), QString tmpFilenameTif = QString() ); private: - /** * For the requested resolution given as map units per pixel, find out the best native tile resolution * (higher resolution = fewer map units per pixel) @@ -103,7 +100,7 @@ class _3D_EXPORT QgsTerrainDownloader private: DataSource mDataSource; std::unique_ptr mOnlineDtm; - double mXSpan = 0; //!< Width of the tile at zoom level 0 in map units + double mXSpan = 0; //!< Width of the tile at zoom level 0 in map units }; #endif // QGSTERRAINDOWNLOADER_H diff --git a/src/3d/terrain/qgsterrainentity.cpp b/src/3d/terrain/qgsterrainentity.cpp index 7f5e0672abe..880777eca7c 100644 --- a/src/3d/terrain/qgsterrainentity.cpp +++ b/src/3d/terrain/qgsterrainentity.cpp @@ -104,7 +104,7 @@ QVector QgsTerrainEntity::rayIntersection( const Qgs case QgsTerrainGenerator::Flat: { if ( ray.direction().z() == 0 ) - break; // the ray is parallel to the flat terrain + break; // the ray is parallel to the flat terrain const float dist = static_cast( mMapSettings->terrainElevationOffset() - ray.origin().z() ) / ray.direction().z(); const QVector3D terrainPlanePoint = ray.origin() + ray.direction() * dist; @@ -121,12 +121,9 @@ QVector QgsTerrainEntity::rayIntersection( const Qgs const QList activeNodes = this->activeNodes(); for ( QgsChunkNode *node : activeNodes ) { - QgsAABB nodeBbox = Qgs3DUtils::mapToWorldExtent( node->box3D(), mMapSettings->origin() ); - if ( node->entity() && - ( minDist < 0 || nodeBbox.distanceFromPoint( ray.origin() ) < minDist ) && - QgsRayCastingUtils::rayBoxIntersection( ray, nodeBbox ) ) + if ( node->entity() && ( minDist < 0 || nodeBbox.distanceFromPoint( ray.origin() ) < minDist ) && QgsRayCastingUtils::rayBoxIntersection( ray, nodeBbox ) ) { Qt3DRender::QGeometryRenderer *rend = node->entity()->findChild(); auto *geom = rend->geometry(); diff --git a/src/3d/terrain/qgsterrainentity.h b/src/3d/terrain/qgsterrainentity.h index 08cd1e8501c..6ab9174c619 100644 --- a/src/3d/terrain/qgsterrainentity.h +++ b/src/3d/terrain/qgsterrainentity.h @@ -78,7 +78,6 @@ class QgsTerrainEntity : public QgsChunkedEntity void onTerrainElevationOffsetChanged( float newOffset ); private: - void connectToLayersRepaintRequest(); QgsTerrainTextureGenerator *mTextureGenerator = nullptr; @@ -91,7 +90,6 @@ class QgsTerrainEntity : public QgsChunkedEntity }; - //! Handles asynchronous updates of terrain's map images when layers change class TerrainMapUpdateJob : public QgsChunkQueueJob { diff --git a/src/3d/terrain/qgsterraingenerator.cpp b/src/3d/terrain/qgsterraingenerator.cpp index f9321b5fcb2..772fd936c04 100644 --- a/src/3d/terrain/qgsterraingenerator.cpp +++ b/src/3d/terrain/qgsterraingenerator.cpp @@ -26,8 +26,7 @@ QgsBox3D QgsTerrainGenerator::rootChunkBox3D( const Qgs3DMapSettings &map ) cons float hMin, hMax; rootChunkHeightRange( hMin, hMax ); - return QgsBox3D( te.xMinimum(), te.yMinimum(), hMin * map.terrainVerticalScale(), - te.xMaximum(), te.yMaximum(), hMax * map.terrainVerticalScale() ); + return QgsBox3D( te.xMinimum(), te.yMinimum(), hMin * map.terrainVerticalScale(), te.xMaximum(), te.yMaximum(), hMax * map.terrainVerticalScale() ); } float QgsTerrainGenerator::rootChunkError( const Qgs3DMapSettings &map ) const diff --git a/src/3d/terrain/qgsterraingenerator.h b/src/3d/terrain/qgsterraingenerator.h index 37c5151a703..68ccbd8a781 100644 --- a/src/3d/terrain/qgsterraingenerator.h +++ b/src/3d/terrain/qgsterraingenerator.h @@ -50,15 +50,14 @@ class _3D_EXPORT QgsTerrainGenerator : public QgsQuadtreeChunkLoaderFactory { Q_OBJECT public: - //! Enumeration of the available terrain generators enum Type { - Flat, //!< The whole terrain is flat area - Dem, //!< Terrain is built from raster layer with digital elevation model - Online, //!< Terrain is built from downloaded tiles with digital elevation model - Mesh, //!< Terrain is built from mesh layer with z value on vertices - QuantizedMesh, //!< Terrain is built from quantized mesh tiles + Flat, //!< The whole terrain is flat area + Dem, //!< Terrain is built from raster layer with digital elevation model + Online, //!< Terrain is built from downloaded tiles with digital elevation model + Mesh, //!< Terrain is built from mesh layer with z value on vertices + QuantizedMesh, //!< Terrain is built from quantized mesh tiles }; //! Sets terrain entity for the generator (does not transfer ownership) @@ -118,13 +117,11 @@ class _3D_EXPORT QgsTerrainGenerator : public QgsQuadtreeChunkLoaderFactory void terrainChanged(); protected: - - QgsTilingScheme mTerrainTilingScheme; //!< Tiling scheme of the terrain + QgsTilingScheme mTerrainTilingScheme; //!< Tiling scheme of the terrain QgsTerrainEntity *mTerrain = nullptr; QgsRectangle mExtent; bool mIsValid = true; - }; diff --git a/src/3d/terrain/qgsterraintexturegenerator_p.cpp b/src/3d/terrain/qgsterraintexturegenerator_p.cpp index 656aa5efd71..eb6a5cd1271 100644 --- a/src/3d/terrain/qgsterraintexturegenerator_p.cpp +++ b/src/3d/terrain/qgsterraintexturegenerator_p.cpp @@ -192,10 +192,7 @@ QgsMapSettings QgsTerrainTextureGenerator::baseMapSettings() layers = mapThemes->mapThemeVisibleLayers( mapThemeName ); mapSettings.setLayerStyleOverrides( mapThemes->mapThemeStyleOverrides( mapThemeName ) ); } - layers.erase( std::remove_if( layers.begin(), - layers.end(), - []( const QgsMapLayer * layer ) { return layer->renderer3D(); } ), - layers.end() ); + layers.erase( std::remove_if( layers.begin(), layers.end(), []( const QgsMapLayer *layer ) { return layer->renderer3D(); } ), layers.end() ); mapSettings.setLayers( layers ); return mapSettings; diff --git a/src/3d/terrain/qgsterraintexturegenerator_p.h b/src/3d/terrain/qgsterraintexturegenerator_p.h index e7548e82628..3f97c8be118 100644 --- a/src/3d/terrain/qgsterraintexturegenerator_p.h +++ b/src/3d/terrain/qgsterraintexturegenerator_p.h @@ -90,11 +90,11 @@ class QgsTerrainTextureGenerator : public QObject struct JobData { - int jobId; - QgsChunkNodeId tileId; - QgsMapRendererSequentialJob *job = nullptr; - QgsRectangle extent; - QString debugText; + int jobId; + QgsChunkNodeId tileId; + QgsMapRendererSequentialJob *job = nullptr; + QgsRectangle extent; + QString debugText; }; QHash mJobs; diff --git a/src/3d/terrain/qgsterraintextureimage_p.cpp b/src/3d/terrain/qgsterraintextureimage_p.cpp index 58344e901d6..c7c98ed14c8 100644 --- a/src/3d/terrain/qgsterraintextureimage_p.cpp +++ b/src/3d/terrain/qgsterraintextureimage_p.cpp @@ -25,7 +25,6 @@ class TerrainTextureImageDataGenerator : public Qt3DRender::QTextureImageDataGenerator { public: - static QImage placeholderImage() { // simple placeholder image @@ -47,11 +46,10 @@ class TerrainTextureImageDataGenerator : public Qt3DRender::QTextureImageDataGen return dataPtr; } - bool operator ==( const QTextureImageDataGenerator &other ) const override + bool operator==( const QTextureImageDataGenerator &other ) const override { const TerrainTextureImageDataGenerator *otherFunctor = functor_cast( &other ); - return otherFunctor && otherFunctor->mVersion == mVersion && - mExtent == otherFunctor->mExtent; + return otherFunctor && otherFunctor->mVersion == mVersion && mExtent == otherFunctor->mExtent; } // marked as deprecated in 5.15, but undeprecated for Qt 6.0. TODO -- remove when we require 6.0 @@ -67,7 +65,6 @@ class TerrainTextureImageDataGenerator : public Qt3DRender::QTextureImageDataGen }; - //////// diff --git a/src/3d/terrain/qgsterraintileloader.cpp b/src/3d/terrain/qgsterraintileloader.cpp index 8e71ef5f1e5..2a48b7c759b 100644 --- a/src/3d/terrain/qgsterraintileloader.cpp +++ b/src/3d/terrain/qgsterraintileloader.cpp @@ -103,7 +103,7 @@ Qt3DRender::QTexture2D *QgsTerrainTileLoader::createTexture( QgsTerrainTileEntit { Qt3DRender::QTexture2D *texture = new Qt3DRender::QTexture2D; QgsTerrainTextureImage *textureImage = new QgsTerrainTextureImage( mTextureImage, mExtentMapCrs, mTileDebugText ); - texture->addTextureImage( textureImage );//texture take the ownership of textureImage if has no parant + texture->addTextureImage( textureImage ); //texture take the ownership of textureImage if has no parant texture->setMinificationFilter( Qt3DRender::QTexture2D::Linear ); texture->setMagnificationFilter( Qt3DRender::QTexture2D::Linear ); diff --git a/src/3d/terrain/qgsterraintileloader.h b/src/3d/terrain/qgsterraintileloader.h index 39840de1153..120d1f50da9 100644 --- a/src/3d/terrain/qgsterraintileloader.h +++ b/src/3d/terrain/qgsterraintileloader.h @@ -44,7 +44,6 @@ namespace Qt3DRender } - /** * \ingroup 3d * \brief Base class for chunk loaders for terrain tiles. @@ -82,7 +81,6 @@ class QgsTerrainTileLoader : public QgsChunkLoader QString mTileDebugText; int mTextureJobId = -1; QImage mTextureImage; - }; /// @endcond diff --git a/src/server/qgis_map_serv.cpp b/src/server/qgis_map_serv.cpp index 931ec2642ad..98e90524abe 100644 --- a/src/server/qgis_map_serv.cpp +++ b/src/server/qgis_map_serv.cpp @@ -86,9 +86,9 @@ int main( int argc, char *argv[] ) // Starts FCGI loop while ( fcgi_accept() >= 0 ) { - QgsFcgiServerRequest request; + QgsFcgiServerRequest request; QgsFcgiServerResponse response( request.method() ); - if ( ! request.hasError() ) + if ( !request.hasError() ) { server.handleRequest( request, response ); } @@ -100,4 +100,3 @@ int main( int argc, char *argv[] ) QgsApplication::exitQgis(); return 0; } - diff --git a/src/server/qgis_mapserver.cpp b/src/server/qgis_mapserver.cpp index 6080df2b824..1476f7d27c4 100644 --- a/src/server/qgis_mapserver.cpp +++ b/src/server/qgis_mapserver.cpp @@ -67,18 +67,17 @@ std::mutex SERVER_MUTEX; struct RequestContext { - QPointer clientConnection; - QString httpHeader; - std::chrono::steady_clock::time_point startTime; - QgsBufferServerRequest request; - QgsBufferServerResponse response; + QPointer clientConnection; + QString httpHeader; + std::chrono::steady_clock::time_point startTime; + QgsBufferServerRequest request; + QgsBufferServerResponse response; }; QQueue REQUEST_QUEUE; -const QMap knownStatuses -{ +const QMap knownStatuses { { 200, QStringLiteral( "OK" ) }, { 201, QStringLiteral( "Created" ) }, { 202, QStringLiteral( "Accepted" ) }, @@ -99,11 +98,9 @@ const QMap knownStatuses /** * The HttpException class represents an HTTP parsing exception. */ -class HttpException: public std::exception +class HttpException : public std::exception { - public: - /** * Constructs an HttpException with the given \a message */ @@ -115,33 +112,32 @@ class HttpException: public std::exception /** * Returns the exception message. */ - QString message( ) + QString message() { return mMessage; } private: - QString mMessage; - }; -class TcpServerWorker: public QObject +class TcpServerWorker : public QObject { Q_OBJECT public: - TcpServerWorker( const QString &ipAddress, int port ) { QHostAddress address { QHostAddress::AnyIPv4 }; address.setAddress( ipAddress ); - if ( ! mTcpServer.listen( address, port ) ) + if ( !mTcpServer.listen( address, port ) ) { std::cerr << tr( "Unable to start the server: %1." ) - .arg( mTcpServer.errorString() ).toStdString() << std::endl; + .arg( mTcpServer.errorString() ) + .toStdString() + << std::endl; } else { @@ -155,8 +151,7 @@ class TcpServerWorker: public QObject mIsListening = true; // Incoming connection handler - QTcpServer::connect( &mTcpServer, &QTcpServer::newConnection, this, [ = ] - { + QTcpServer::connect( &mTcpServer, &QTcpServer::newConnection, this, [=] { QTcpSocket *clientConnection = mTcpServer.nextPendingConnection(); mConnectionCounter++; @@ -169,8 +164,7 @@ class TcpServerWorker: public QObject QObject *context { new QObject }; // Deletes the connection later - auto connectionDeleter = [ = ]() - { + auto connectionDeleter = [=]() { clientConnection->deleteLater(); mConnectionCounter--; delete incomingData; @@ -179,7 +173,7 @@ class TcpServerWorker: public QObject // This will delete the connection QObject::connect( clientConnection, &QAbstractSocket::disconnected, clientConnection, connectionDeleter, Qt::QueuedConnection ); -#if 0 // Debugging output +#if 0 // Debugging output clientConnection->connect( clientConnection, &QAbstractSocket::errorOccurred, clientConnection, [ = ]( QAbstractSocket::SocketError socketError ) { qDebug() << "Socket error #" << socketError; @@ -187,8 +181,7 @@ class TcpServerWorker: public QObject #endif // Incoming connection parser - QObject::connect( clientConnection, &QIODevice::readyRead, context, [ = ] { - + QObject::connect( clientConnection, &QIODevice::readyRead, context, [=] { // Read all incoming data while ( clientConnection->bytesAvailable() > 0 ) { @@ -244,7 +237,7 @@ class TcpServerWorker: public QObject } // cppcheck-suppress containerOutOfBounds - const QString protocol { firstLinePieces.at( 2 )}; + const QString protocol { firstLinePieces.at( 2 ) }; if ( protocol != QLatin1String( "HTTP/1.0" ) && protocol != QLatin1String( "HTTP/1.1" ) ) { throw HttpException( QStringLiteral( "HTTP error unsupported protocol: %1" ).arg( protocol ) ); @@ -293,7 +286,7 @@ class TcpServerWorker: public QObject if ( url.isEmpty() ) { // cppcheck-suppress containerOutOfBounds - const QString path { firstLinePieces.at( 1 )}; + const QString path { firstLinePieces.at( 1 ) }; // Take Host header if defined if ( headers.contains( QStringLiteral( "Host" ) ) ) { @@ -310,14 +303,13 @@ class TcpServerWorker: public QObject if ( !incomingData->isEmpty() && clientConnection->state() == QAbstractSocket::SocketState::ConnectedState ) { - auto requestContext = new RequestContext - { + auto requestContext = new RequestContext { clientConnection, firstLinePieces.join( ' ' ), std::chrono::steady_clock::now(), { url, method, headers, &data }, {}, - } ; + }; REQUEST_QUEUE_MUTEX.lock(); REQUEST_QUEUE.enqueue( requestContext ); REQUEST_QUEUE_MUTEX.unlock(); @@ -335,9 +327,11 @@ class TcpServerWorker: public QObject clientConnection->write( ex.message().toUtf8() ); std::cout << QStringLiteral( "\033[1;31m%1 [%2] \"%3\" - - 500\033[0m" ) - .arg( clientConnection->peerAddress().toString() ) - .arg( QDateTime::currentDateTime().toString() ) - .arg( ex.message() ).toStdString() << std::endl; + .arg( clientConnection->peerAddress().toString() ) + .arg( QDateTime::currentDateTime().toString() ) + .arg( ex.message() ) + .toStdString() + << std::endl; clientConnection->disconnectFromHost(); } @@ -360,7 +354,7 @@ class TcpServerWorker: public QObject public slots: // Outgoing connection handler - void responseReady( RequestContext *requestContext ) //#spellok + void responseReady( RequestContext *requestContext ) //#spellok { std::unique_ptr request { requestContext }; const auto elapsedTime { std::chrono::steady_clock::now() - request->startTime }; @@ -368,8 +362,7 @@ class TcpServerWorker: public QObject const auto &response { request->response }; const auto &clientConnection { request->clientConnection }; - if ( ! clientConnection || - clientConnection->state() != QAbstractSocket::SocketState::ConnectedState ) + if ( !clientConnection || clientConnection->state() != QAbstractSocket::SocketState::ConnectedState ) { std::cout << "Connection reset by peer" << std::endl; return; @@ -395,13 +388,8 @@ class TcpServerWorker: public QObject // 10.185.248.71 [09/Jan/2015:19:12:06 +0000] 808840