QGIS API Documentation
3.99.0-Master (09f76ad7019)
Loading...
Searching...
No Matches
src
3d
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
24
using namespace
Qt::StringLiterals;
25
26
QgsSkyboxSettings::QgsSkyboxSettings
(
const
QgsSkyboxSettings
&other )
27
: mSkyboxType( other.mSkyboxType )
28
, mPanoramicTexturePath( other.mPanoramicTexturePath )
29
, mCubeMapFacesPaths( other.mCubeMapFacesPaths )
30
{
31
}
32
33
QgsSkyboxSettings
&
QgsSkyboxSettings::operator=
(
QgsSkyboxSettings
const
&rhs )
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
44
void
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 )
49
mSkyboxType =
QgsSkyboxEntity::DistinctTexturesSkybox
;
50
else
if
( skyboxTypeStr ==
"Panoramic Texture"
_L1 )
51
mSkyboxType =
QgsSkyboxEntity::PanoramicSkybox
;
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
62
void
QgsSkyboxSettings::writeXml
( QDomElement &element,
const
QgsReadWriteContext
&context )
const
63
{
64
switch
( mSkyboxType )
65
{
66
case
QgsSkyboxEntity::DistinctTexturesSkybox
:
67
element.setAttribute( u
"skybox-type"
_s, u
"Distinct Faces"
_s );
68
break
;
69
case
QgsSkyboxEntity::PanoramicSkybox
:
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
}
QgsPathResolver
Resolves relative paths into absolute paths and vice versa.
Definition
qgspathresolver.h:35
QgsPathResolver::writePath
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
Definition
qgspathresolver.cpp:238
QgsPathResolver::readPath
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
Definition
qgspathresolver.cpp:45
QgsReadWriteContext
A container for the context for various read/write operations on objects.
Definition
qgsreadwritecontext.h:38
QgsReadWriteContext::pathResolver
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
Definition
qgsreadwritecontext.cpp:51
QgsSkyboxEntity::PanoramicSkybox
@ PanoramicSkybox
Definition
qgsskyboxentity.h:51
QgsSkyboxEntity::DistinctTexturesSkybox
@ DistinctTexturesSkybox
Definition
qgsskyboxentity.h:52
QgsSkyboxSettings::QgsSkyboxSettings
QgsSkyboxSettings()=default
QgsSkyboxSettings::readXml
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
Definition
qgsskyboxsettings.cpp:44
QgsSkyboxSettings::operator=
QgsSkyboxSettings & operator=(QgsSkyboxSettings const &rhs)
Definition
qgsskyboxsettings.cpp:33
QgsSkyboxSettings::writeXml
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.
Definition
qgsskyboxsettings.cpp:62
qgsreadwritecontext.h
qgsskyboxsettings.h
qgssymbollayerutils.h
Generated on
for QGIS API Documentation by
1.15.0