QGIS API Documentation 3.99.0-Master (09f76ad7019)
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#include <QString>
23
24using namespace Qt::StringLiterals;
25
27 : mSkyboxType( other.mSkyboxType )
28 , mPanoramicTexturePath( other.mPanoramicTexturePath )
29 , mCubeMapFacesPaths( other.mCubeMapFacesPaths )
30{
31}
32
34{
35 if ( &rhs == this )
36 return *this;
37
38 this->mSkyboxType = rhs.mSkyboxType;
39 this->mPanoramicTexturePath = rhs.mPanoramicTexturePath;
40 this->mCubeMapFacesPaths = rhs.mCubeMapFacesPaths;
41 return *this;
42}
43
44void QgsSkyboxSettings::readXml( const QDomElement &element, const QgsReadWriteContext &context )
45{
46 const QgsPathResolver &pathResolver = context.pathResolver();
47 const QString skyboxTypeStr = element.attribute( u"skybox-type"_s );
48 if ( skyboxTypeStr == "Distinct Faces"_L1 )
50 else if ( skyboxTypeStr == "Panoramic Texture"_L1 )
52 mPanoramicTexturePath = pathResolver.readPath( element.attribute( u"panoramic-texture-path"_s ) );
53 mCubeMapFacesPaths.clear();
54 mCubeMapFacesPaths[u"posX"_s] = pathResolver.readPath( element.attribute( u"posX-texture-path"_s ) );
55 mCubeMapFacesPaths[u"posY"_s] = pathResolver.readPath( element.attribute( u"posY-texture-path"_s ) );
56 mCubeMapFacesPaths[u"posZ"_s] = pathResolver.readPath( element.attribute( u"posZ-texture-path"_s ) );
57 mCubeMapFacesPaths[u"negX"_s] = pathResolver.readPath( element.attribute( u"negX-texture-path"_s ) );
58 mCubeMapFacesPaths[u"negY"_s] = pathResolver.readPath( element.attribute( u"negY-texture-path"_s ) );
59 mCubeMapFacesPaths[u"negZ"_s] = pathResolver.readPath( element.attribute( u"negZ-texture-path"_s ) );
60}
61
62void QgsSkyboxSettings::writeXml( QDomElement &element, const QgsReadWriteContext &context ) const
63{
64 switch ( mSkyboxType )
65 {
67 element.setAttribute( u"skybox-type"_s, u"Distinct Faces"_s );
68 break;
70 element.setAttribute( u"skybox-type"_s, u"Panoramic Texture"_s );
71 break;
72 }
73
74 const QgsPathResolver &pathResolver = context.pathResolver();
75 element.setAttribute( u"panoramic-texture-path"_s, pathResolver.writePath( mPanoramicTexturePath ) );
76 element.setAttribute( u"posX-texture-path"_s, pathResolver.writePath( mCubeMapFacesPaths[u"posX"_s] ) );
77 element.setAttribute( u"posY-texture-path"_s, pathResolver.writePath( mCubeMapFacesPaths[u"posY"_s] ) );
78 element.setAttribute( u"posZ-texture-path"_s, pathResolver.writePath( mCubeMapFacesPaths[u"posZ"_s] ) );
79 element.setAttribute( u"negX-texture-path"_s, pathResolver.writePath( mCubeMapFacesPaths[u"negX"_s] ) );
80 element.setAttribute( u"negY-texture-path"_s, pathResolver.writePath( mCubeMapFacesPaths[u"negY"_s] ) );
81 element.setAttribute( u"negZ-texture-path"_s, pathResolver.writePath( mCubeMapFacesPaths[u"negZ"_s] ) );
82}
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.