Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move writeXml and readXml to qgsskyboxsettings.cpp
  • Loading branch information
NEDJIMAbelgacem committed Aug 2, 2020
1 parent 717b58e commit 76424fb
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 34 deletions.
1 change: 1 addition & 0 deletions src/3d/CMakeLists.txt
Expand Up @@ -29,6 +29,7 @@ SET(QGIS_3D_SRCS
qgsmeshlayer3drenderer.cpp
qgswindow3dengine.cpp
qgsskyboxentity.cpp
qgsskyboxsettings.cpp

chunks/qgschunkboundsentity_p.cpp
chunks/qgschunkedentity_p.cpp
Expand Down
54 changes: 54 additions & 0 deletions src/3d/qgsskyboxsettings.cpp
@@ -0,0 +1,54 @@
/***************************************************************************
qgsskyboxsettings.cpp
--------------------------------------
Date : August 2020
Copyright : (C) 2020 by Belgacem Nedjima
Email : gb uderscore nedjima at esi dot dz
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsskyboxsettings.h"

#include <QDomDocument>

#include "qgsreadwritecontext.h"
#include "qgssymbollayerutils.h"

void QgsSkyboxSettings::readXml( const QDomElement &element, const QgsReadWriteContext &context )
{
Q_UNUSED( context );
mIsSkyboxEnabled = element.attribute( QStringLiteral( "skybox-enabled" ) ).toInt();
mSkyboxType = element.attribute( QStringLiteral( "skybox-type" ) );
mSkyboxBaseName = element.attribute( QStringLiteral( "base-name" ) );
mSkyboxExt = element.attribute( QStringLiteral( "extension" ) );
mHDRTexturePath = element.attribute( 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" ) );
}

void QgsSkyboxSettings::writeXml( QDomElement &element, const QgsReadWriteContext &context ) const
{
Q_UNUSED( context );
element.setAttribute( QStringLiteral( "skybox-enabled" ), mIsSkyboxEnabled );
element.setAttribute( QStringLiteral( "skybox-type" ), mSkyboxType );
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" ) ] );
}
39 changes: 5 additions & 34 deletions src/3d/qgsskyboxsettings.h
Expand Up @@ -18,12 +18,12 @@

#include <QString>
#include <QMap>
#include <QDomDocument>

#include "qgsreadwritecontext.h"
#include "qgssymbollayerutils.h"
#include "qgis_3d.h"

class QgsReadWriteContext;
class QDomElement;

/**
* \brief class containing the configuration of a skybox entity
* \ingroup 3d
Expand All @@ -34,39 +34,10 @@ class _3D_EXPORT QgsSkyboxSettings
public:

//! Reads settings from a DOM \a element
void readXml( const QDomElement &element, const QgsReadWriteContext &context )
{
Q_UNUSED( context );
mIsSkyboxEnabled = element.attribute( QStringLiteral( "skybox-enabled" ) ).toInt();
mSkyboxType = element.attribute( QStringLiteral( "skybox-type" ) );
mSkyboxBaseName = element.attribute( QStringLiteral( "base-name" ) );
mSkyboxExt = element.attribute( QStringLiteral( "extension" ) );
mHDRTexturePath = element.attribute( 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" ) );
}
void readXml( const QDomElement &element, const QgsReadWriteContext &context );

//! Writes settings to a DOM \a element
void writeXml( QDomElement &element, const QgsReadWriteContext &context ) const
{
Q_UNUSED( context );
element.setAttribute( QStringLiteral( "skybox-enabled" ), mIsSkyboxEnabled );
element.setAttribute( QStringLiteral( "skybox-type" ), mSkyboxType );
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" ) ] );
}
void writeXml( QDomElement &element, const QgsReadWriteContext &context ) const;

//! Returns whether the skybox is enabled
bool isSkyboxEnabled() const { return mIsSkyboxEnabled; }
Expand Down

0 comments on commit 76424fb

Please sign in to comment.