mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
Use path resolver's read/writePath()
Remove QSkyboxEntity include Use deleteLater() instead of delete Remove unneeded todo Add \since to skyboxSettings in qgs3dmapsettings.h
This commit is contained in:
parent
5be696d33f
commit
d7787f2477
@ -605,6 +605,8 @@ Emitted when the camera lens field of view changes
|
||||
void skyboxSettingsChanged();
|
||||
%Docstring
|
||||
Emitted when skybox settings are changed
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
private:
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <Qt3DRender/QSceneLoader>
|
||||
#include <Qt3DExtras/QForwardRenderer>
|
||||
#include <Qt3DExtras/QPhongMaterial>
|
||||
#include <Qt3DExtras/QSkyboxEntity>
|
||||
#include <Qt3DExtras/QSphereMesh>
|
||||
#include <Qt3DLogic/QFrameAction>
|
||||
#include <Qt3DRender/QEffect>
|
||||
@ -860,7 +859,7 @@ void Qgs3DMapScene::onSkyboxSettingsChanged()
|
||||
QgsSkyboxSettings skyboxSettings = mMap.skyboxSettings();
|
||||
if ( mSkybox != nullptr )
|
||||
{
|
||||
delete mSkybox;
|
||||
mSkybox->deleteLater();
|
||||
mSkybox = nullptr;
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,6 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon
|
||||
elem.appendChild( elemRenderers );
|
||||
|
||||
QDomElement elemSkybox = doc.createElement( QStringLiteral( "skybox" ) );
|
||||
// TODO: use context for relative paths, maybe explicitly list all files(?)
|
||||
mSkyboxSettings.writeXml( elemSkybox, context );
|
||||
elem.appendChild( elemSkybox );
|
||||
|
||||
|
@ -414,11 +414,13 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec
|
||||
|
||||
/**
|
||||
* Returns the current configuration of the skybox
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
QgsSkyboxSettings skyboxSettings() const SIP_SKIP { return mSkyboxSettings; }
|
||||
|
||||
/**
|
||||
* Sets the current configuration of the skybox
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
void setSkyboxSettings( const QgsSkyboxSettings &skyboxSettings ) SIP_SKIP;
|
||||
|
||||
@ -517,6 +519,7 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec
|
||||
|
||||
/**
|
||||
* Emitted when skybox settings are changed
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
void skyboxSettingsChanged();
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
void QgsSkyboxSettings::readXml( const QDomElement &element, const QgsReadWriteContext &context )
|
||||
{
|
||||
Q_UNUSED( context );
|
||||
const QgsPathResolver &pathResolver = context.pathResolver();
|
||||
mIsSkyboxEnabled = element.attribute( QStringLiteral( "skybox-enabled" ) ).toInt();
|
||||
QString skyboxTypeStr = element.attribute( QStringLiteral( "skybox-type" ) );
|
||||
if ( skyboxTypeStr == QStringLiteral( "Textures collection" ) )
|
||||
@ -33,19 +33,18 @@ void QgsSkyboxSettings::readXml( const QDomElement &element, const QgsReadWriteC
|
||||
mSkyboxType = QgsSkyboxEntity::HDRSkybox;
|
||||
mSkyboxBaseName = element.attribute( QStringLiteral( "base-name" ) );
|
||||
mSkyboxExt = element.attribute( QStringLiteral( "extension" ) );
|
||||
mHDRTexturePath = element.attribute( QStringLiteral( "HDR-texture-path" ) );
|
||||
mHDRTexturePath = element.attribute( pathResolver.readPath( QStringLiteral( "HDR-texture-path" ) ) );
|
||||
mCubeMapFacesPaths.clear();
|
||||
mCubeMapFacesPaths[ QStringLiteral( "posX" ) ] = element.attribute( QStringLiteral( "posX-texture-path" ) );
|
||||
mCubeMapFacesPaths[ QStringLiteral( "posY" ) ] = element.attribute( QStringLiteral( "posY-texture-path" ) );
|
||||
mCubeMapFacesPaths[ QStringLiteral( "posZ" ) ] = element.attribute( QStringLiteral( "posZ-texture-path" ) );
|
||||
mCubeMapFacesPaths[ QStringLiteral( "negX" ) ] = element.attribute( QStringLiteral( "negX-texture-path" ) );
|
||||
mCubeMapFacesPaths[ QStringLiteral( "negY" ) ] = element.attribute( QStringLiteral( "negY-texture-path" ) );
|
||||
mCubeMapFacesPaths[ QStringLiteral( "negZ" ) ] = element.attribute( QStringLiteral( "negZ-texture-path" ) );
|
||||
mCubeMapFacesPaths[ QStringLiteral( "posX" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "posX-texture-path" ) ) );
|
||||
mCubeMapFacesPaths[ QStringLiteral( "posY" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "posY-texture-path" ) ) );
|
||||
mCubeMapFacesPaths[ QStringLiteral( "posZ" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "posZ-texture-path" ) ) );
|
||||
mCubeMapFacesPaths[ QStringLiteral( "negX" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "negX-texture-path" ) ) );
|
||||
mCubeMapFacesPaths[ QStringLiteral( "negY" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "negY-texture-path" ) ) );
|
||||
mCubeMapFacesPaths[ QStringLiteral( "negZ" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "negZ-texture-path" ) ) );
|
||||
}
|
||||
|
||||
void QgsSkyboxSettings::writeXml( QDomElement &element, const QgsReadWriteContext &context ) const
|
||||
{
|
||||
Q_UNUSED( context );
|
||||
element.setAttribute( QStringLiteral( "skybox-enabled" ), mIsSkyboxEnabled );
|
||||
switch ( mSkyboxType )
|
||||
{
|
||||
@ -59,13 +58,15 @@ void QgsSkyboxSettings::writeXml( QDomElement &element, const QgsReadWriteContex
|
||||
element.setAttribute( QStringLiteral( "skybox-type" ), QStringLiteral( "HDR texture" ) );
|
||||
break;
|
||||
}
|
||||
|
||||
const QgsPathResolver &pathResolver = context.pathResolver();
|
||||
element.setAttribute( QStringLiteral( "base-name" ), mSkyboxBaseName );
|
||||
element.setAttribute( QStringLiteral( "extension" ), mSkyboxExt );
|
||||
element.setAttribute( QStringLiteral( "HDR-texture-path" ), mHDRTexturePath );
|
||||
element.setAttribute( QStringLiteral( "posX-texture-path" ), mCubeMapFacesPaths[ QStringLiteral( "posX" ) ] );
|
||||
element.setAttribute( QStringLiteral( "posY-texture-path" ), mCubeMapFacesPaths[ QStringLiteral( "posY" ) ] );
|
||||
element.setAttribute( QStringLiteral( "posZ-texture-path" ), mCubeMapFacesPaths[ QStringLiteral( "posZ" ) ] );
|
||||
element.setAttribute( QStringLiteral( "negX-texture-path" ), mCubeMapFacesPaths[ QStringLiteral( "negX" ) ] );
|
||||
element.setAttribute( QStringLiteral( "negY-texture-path" ), mCubeMapFacesPaths[ QStringLiteral( "negY" ) ] );
|
||||
element.setAttribute( QStringLiteral( "negZ-texture-path" ), mCubeMapFacesPaths[ QStringLiteral( "negZ" ) ] );
|
||||
element.setAttribute( QStringLiteral( "HDR-texture-path" ), pathResolver.writePath( mHDRTexturePath ) );
|
||||
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" ) ] ) );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user