Skip to content

Commit d7787f2

Browse files
committedAug 6, 2020
Use path resolver's read/writePath()
Remove QSkyboxEntity include Use deleteLater() instead of delete Remove unneeded todo Add \since to skyboxSettings in qgs3dmapsettings.h
1 parent 5be696d commit d7787f2

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed
 

‎python/3d/auto_generated/qgs3dmapsettings.sip.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,8 @@ Emitted when the camera lens field of view changes
605605
void skyboxSettingsChanged();
606606
%Docstring
607607
Emitted when skybox settings are changed
608+
609+
.. versionadded:: 3.16
608610
%End
609611

610612
private:

‎src/3d/qgs3dmapscene.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <Qt3DRender/QSceneLoader>
2828
#include <Qt3DExtras/QForwardRenderer>
2929
#include <Qt3DExtras/QPhongMaterial>
30-
#include <Qt3DExtras/QSkyboxEntity>
3130
#include <Qt3DExtras/QSphereMesh>
3231
#include <Qt3DLogic/QFrameAction>
3332
#include <Qt3DRender/QEffect>
@@ -860,7 +859,7 @@ void Qgs3DMapScene::onSkyboxSettingsChanged()
860859
QgsSkyboxSettings skyboxSettings = mMap.skyboxSettings();
861860
if ( mSkybox != nullptr )
862861
{
863-
delete mSkybox;
862+
mSkybox->deleteLater();
864863
mSkybox = nullptr;
865864
}
866865

‎src/3d/qgs3dmapsettings.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon
325325
elem.appendChild( elemRenderers );
326326

327327
QDomElement elemSkybox = doc.createElement( QStringLiteral( "skybox" ) );
328-
// TODO: use context for relative paths, maybe explicitly list all files(?)
329328
mSkyboxSettings.writeXml( elemSkybox, context );
330329
elem.appendChild( elemSkybox );
331330

‎src/3d/qgs3dmapsettings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,13 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec
414414

415415
/**
416416
* Returns the current configuration of the skybox
417+
* \since QGIS 3.16
417418
*/
418419
QgsSkyboxSettings skyboxSettings() const SIP_SKIP { return mSkyboxSettings; }
419420

420421
/**
421422
* Sets the current configuration of the skybox
423+
* \since QGIS 3.16
422424
*/
423425
void setSkyboxSettings( const QgsSkyboxSettings &skyboxSettings ) SIP_SKIP;
424426

@@ -517,6 +519,7 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec
517519

518520
/**
519521
* Emitted when skybox settings are changed
522+
* \since QGIS 3.16
520523
*/
521524
void skyboxSettingsChanged();
522525

‎src/3d/qgsskyboxsettings.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
void QgsSkyboxSettings::readXml( const QDomElement &element, const QgsReadWriteContext &context )
2424
{
25-
Q_UNUSED( context );
25+
const QgsPathResolver &pathResolver = context.pathResolver();
2626
mIsSkyboxEnabled = element.attribute( QStringLiteral( "skybox-enabled" ) ).toInt();
2727
QString skyboxTypeStr = element.attribute( QStringLiteral( "skybox-type" ) );
2828
if ( skyboxTypeStr == QStringLiteral( "Textures collection" ) )
@@ -33,19 +33,18 @@ void QgsSkyboxSettings::readXml( const QDomElement &element, const QgsReadWriteC
3333
mSkyboxType = QgsSkyboxEntity::HDRSkybox;
3434
mSkyboxBaseName = element.attribute( QStringLiteral( "base-name" ) );
3535
mSkyboxExt = element.attribute( QStringLiteral( "extension" ) );
36-
mHDRTexturePath = element.attribute( QStringLiteral( "HDR-texture-path" ) );
36+
mHDRTexturePath = element.attribute( pathResolver.readPath( QStringLiteral( "HDR-texture-path" ) ) );
3737
mCubeMapFacesPaths.clear();
38-
mCubeMapFacesPaths[ QStringLiteral( "posX" ) ] = element.attribute( QStringLiteral( "posX-texture-path" ) );
39-
mCubeMapFacesPaths[ QStringLiteral( "posY" ) ] = element.attribute( QStringLiteral( "posY-texture-path" ) );
40-
mCubeMapFacesPaths[ QStringLiteral( "posZ" ) ] = element.attribute( QStringLiteral( "posZ-texture-path" ) );
41-
mCubeMapFacesPaths[ QStringLiteral( "negX" ) ] = element.attribute( QStringLiteral( "negX-texture-path" ) );
42-
mCubeMapFacesPaths[ QStringLiteral( "negY" ) ] = element.attribute( QStringLiteral( "negY-texture-path" ) );
43-
mCubeMapFacesPaths[ QStringLiteral( "negZ" ) ] = element.attribute( QStringLiteral( "negZ-texture-path" ) );
38+
mCubeMapFacesPaths[ QStringLiteral( "posX" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "posX-texture-path" ) ) );
39+
mCubeMapFacesPaths[ QStringLiteral( "posY" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "posY-texture-path" ) ) );
40+
mCubeMapFacesPaths[ QStringLiteral( "posZ" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "posZ-texture-path" ) ) );
41+
mCubeMapFacesPaths[ QStringLiteral( "negX" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "negX-texture-path" ) ) );
42+
mCubeMapFacesPaths[ QStringLiteral( "negY" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "negY-texture-path" ) ) );
43+
mCubeMapFacesPaths[ QStringLiteral( "negZ" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "negZ-texture-path" ) ) );
4444
}
4545

4646
void QgsSkyboxSettings::writeXml( QDomElement &element, const QgsReadWriteContext &context ) const
4747
{
48-
Q_UNUSED( context );
4948
element.setAttribute( QStringLiteral( "skybox-enabled" ), mIsSkyboxEnabled );
5049
switch ( mSkyboxType )
5150
{
@@ -59,13 +58,15 @@ void QgsSkyboxSettings::writeXml( QDomElement &element, const QgsReadWriteContex
5958
element.setAttribute( QStringLiteral( "skybox-type" ), QStringLiteral( "HDR texture" ) );
6059
break;
6160
}
61+
62+
const QgsPathResolver &pathResolver = context.pathResolver();
6263
element.setAttribute( QStringLiteral( "base-name" ), mSkyboxBaseName );
6364
element.setAttribute( QStringLiteral( "extension" ), mSkyboxExt );
64-
element.setAttribute( QStringLiteral( "HDR-texture-path" ), mHDRTexturePath );
65-
element.setAttribute( QStringLiteral( "posX-texture-path" ), mCubeMapFacesPaths[ QStringLiteral( "posX" ) ] );
66-
element.setAttribute( QStringLiteral( "posY-texture-path" ), mCubeMapFacesPaths[ QStringLiteral( "posY" ) ] );
67-
element.setAttribute( QStringLiteral( "posZ-texture-path" ), mCubeMapFacesPaths[ QStringLiteral( "posZ" ) ] );
68-
element.setAttribute( QStringLiteral( "negX-texture-path" ), mCubeMapFacesPaths[ QStringLiteral( "negX" ) ] );
69-
element.setAttribute( QStringLiteral( "negY-texture-path" ), mCubeMapFacesPaths[ QStringLiteral( "negY" ) ] );
70-
element.setAttribute( QStringLiteral( "negZ-texture-path" ), mCubeMapFacesPaths[ QStringLiteral( "negZ" ) ] );
65+
element.setAttribute( QStringLiteral( "HDR-texture-path" ), pathResolver.writePath( mHDRTexturePath ) );
66+
element.setAttribute( QStringLiteral( "posX-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "posX" ) ] ) );
67+
element.setAttribute( QStringLiteral( "posY-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "posY" ) ] ) );
68+
element.setAttribute( QStringLiteral( "posZ-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "posZ" ) ] ) );
69+
element.setAttribute( QStringLiteral( "negX-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "negX" ) ] ) );
70+
element.setAttribute( QStringLiteral( "negY-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "negY" ) ] ) );
71+
element.setAttribute( QStringLiteral( "negZ-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "negZ" ) ] ) );
7172
}

0 commit comments

Comments
 (0)
Please sign in to comment.