QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsskyboxsettings.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsskyboxsettings.cpp
3 --------------------------------------
4 Date : August 2020
5 Copyright : (C) 2020 by Belgacem Nedjima
6 Email : gb uderscore nedjima at esi dot dz
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgsskyboxsettings.h"
17
18#include "qgsreadwritecontext.h"
19#include "qgssymbollayerutils.h"
20
21#include <QDomDocument>
22
24 : mSkyboxType( other.mSkyboxType )
25 , mPanoramicTexturePath( other.mPanoramicTexturePath )
26 , mCubeMapFacesPaths( other.mCubeMapFacesPaths )
27{
28}
29
31{
32 if ( &rhs == this )
33 return *this;
34
35 this->mSkyboxType = rhs.mSkyboxType;
36 this->mPanoramicTexturePath = rhs.mPanoramicTexturePath;
37 this->mCubeMapFacesPaths = rhs.mCubeMapFacesPaths;
38 return *this;
39}
40
41void QgsSkyboxSettings::readXml( const QDomElement &element, const QgsReadWriteContext &context )
42{
43 const QgsPathResolver &pathResolver = context.pathResolver();
44 const QString skyboxTypeStr = element.attribute( QStringLiteral( "skybox-type" ) );
45 if ( skyboxTypeStr == QLatin1String( "Distinct Faces" ) )
47 else if ( skyboxTypeStr == QLatin1String( "Panoramic Texture" ) )
49 mPanoramicTexturePath = pathResolver.readPath( element.attribute( QStringLiteral( "panoramic-texture-path" ) ) );
50 mCubeMapFacesPaths.clear();
51 mCubeMapFacesPaths[QStringLiteral( "posX" )] = pathResolver.readPath( element.attribute( QStringLiteral( "posX-texture-path" ) ) );
52 mCubeMapFacesPaths[QStringLiteral( "posY" )] = pathResolver.readPath( element.attribute( QStringLiteral( "posY-texture-path" ) ) );
53 mCubeMapFacesPaths[QStringLiteral( "posZ" )] = pathResolver.readPath( element.attribute( QStringLiteral( "posZ-texture-path" ) ) );
54 mCubeMapFacesPaths[QStringLiteral( "negX" )] = pathResolver.readPath( element.attribute( QStringLiteral( "negX-texture-path" ) ) );
55 mCubeMapFacesPaths[QStringLiteral( "negY" )] = pathResolver.readPath( element.attribute( QStringLiteral( "negY-texture-path" ) ) );
56 mCubeMapFacesPaths[QStringLiteral( "negZ" )] = pathResolver.readPath( element.attribute( QStringLiteral( "negZ-texture-path" ) ) );
57}
58
59void QgsSkyboxSettings::writeXml( QDomElement &element, const QgsReadWriteContext &context ) const
60{
61 switch ( mSkyboxType )
62 {
64 element.setAttribute( QStringLiteral( "skybox-type" ), QStringLiteral( "Distinct Faces" ) );
65 break;
67 element.setAttribute( QStringLiteral( "skybox-type" ), QStringLiteral( "Panoramic Texture" ) );
68 break;
69 }
70
71 const QgsPathResolver &pathResolver = context.pathResolver();
72 element.setAttribute( QStringLiteral( "panoramic-texture-path" ), pathResolver.writePath( mPanoramicTexturePath ) );
73 element.setAttribute( QStringLiteral( "posX-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[QStringLiteral( "posX" )] ) );
74 element.setAttribute( QStringLiteral( "posY-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[QStringLiteral( "posY" )] ) );
75 element.setAttribute( QStringLiteral( "posZ-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[QStringLiteral( "posZ" )] ) );
76 element.setAttribute( QStringLiteral( "negX-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[QStringLiteral( "negX" )] ) );
77 element.setAttribute( QStringLiteral( "negY-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[QStringLiteral( "negY" )] ) );
78 element.setAttribute( QStringLiteral( "negZ-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[QStringLiteral( "negZ" )] ) );
79}
Resolves relative paths into absolute paths and vice versa.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
A container for the context for various read/write operations on objects.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
QgsSkyboxSettings()=default
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
QgsSkyboxSettings & operator=(QgsSkyboxSettings const &rhs)
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.