QGIS API Documentation
4.0.0-Norrköping (1ddcee3d0e4)
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
QgsSkyboxSettings
&
QgsSkyboxSettings::operator=
(
QgsSkyboxSettings
const
&rhs )
33
{
34
if
( &rhs ==
this
)
35
return
*
this
;
36
37
this->mSkyboxType = rhs.mSkyboxType;
38
this->mPanoramicTexturePath = rhs.mPanoramicTexturePath;
39
this->mCubeMapFacesPaths = rhs.mCubeMapFacesPaths;
40
return
*
this
;
41
}
42
43
void
QgsSkyboxSettings::readXml
(
const
QDomElement &element,
const
QgsReadWriteContext
&context )
44
{
45
const
QgsPathResolver
&pathResolver = context.
pathResolver
();
46
const
QString skyboxTypeStr = element.attribute( u
"skybox-type"
_s );
47
if
( skyboxTypeStr ==
"Distinct Faces"
_L1 )
48
mSkyboxType =
QgsSkyboxEntity::DistinctTexturesSkybox
;
49
else
if
( skyboxTypeStr ==
"Panoramic Texture"
_L1 )
50
mSkyboxType =
QgsSkyboxEntity::PanoramicSkybox
;
51
mPanoramicTexturePath = pathResolver.
readPath
( element.attribute( u
"panoramic-texture-path"
_s ) );
52
mCubeMapFacesPaths.clear();
53
mCubeMapFacesPaths[u
"posX"
_s] = pathResolver.
readPath
( element.attribute( u
"posX-texture-path"
_s ) );
54
mCubeMapFacesPaths[u
"posY"
_s] = pathResolver.
readPath
( element.attribute( u
"posY-texture-path"
_s ) );
55
mCubeMapFacesPaths[u
"posZ"
_s] = pathResolver.
readPath
( element.attribute( u
"posZ-texture-path"
_s ) );
56
mCubeMapFacesPaths[u
"negX"
_s] = pathResolver.
readPath
( element.attribute( u
"negX-texture-path"
_s ) );
57
mCubeMapFacesPaths[u
"negY"
_s] = pathResolver.
readPath
( element.attribute( u
"negY-texture-path"
_s ) );
58
mCubeMapFacesPaths[u
"negZ"
_s] = pathResolver.
readPath
( element.attribute( u
"negZ-texture-path"
_s ) );
59
}
60
61
void
QgsSkyboxSettings::writeXml
( QDomElement &element,
const
QgsReadWriteContext
&context )
const
62
{
63
switch
( mSkyboxType )
64
{
65
case
QgsSkyboxEntity::DistinctTexturesSkybox
:
66
element.setAttribute( u
"skybox-type"
_s, u
"Distinct Faces"
_s );
67
break
;
68
case
QgsSkyboxEntity::PanoramicSkybox
:
69
element.setAttribute( u
"skybox-type"
_s, u
"Panoramic Texture"
_s );
70
break
;
71
}
72
73
const
QgsPathResolver
&pathResolver = context.
pathResolver
();
74
element.setAttribute( u
"panoramic-texture-path"
_s, pathResolver.
writePath
( mPanoramicTexturePath ) );
75
element.setAttribute( u
"posX-texture-path"
_s, pathResolver.
writePath
( mCubeMapFacesPaths[u
"posX"
_s] ) );
76
element.setAttribute( u
"posY-texture-path"
_s, pathResolver.
writePath
( mCubeMapFacesPaths[u
"posY"
_s] ) );
77
element.setAttribute( u
"posZ-texture-path"
_s, pathResolver.
writePath
( mCubeMapFacesPaths[u
"posZ"
_s] ) );
78
element.setAttribute( u
"negX-texture-path"
_s, pathResolver.
writePath
( mCubeMapFacesPaths[u
"negX"
_s] ) );
79
element.setAttribute( u
"negY-texture-path"
_s, pathResolver.
writePath
( mCubeMapFacesPaths[u
"negY"
_s] ) );
80
element.setAttribute( u
"negZ-texture-path"
_s, pathResolver.
writePath
( mCubeMapFacesPaths[u
"negZ"
_s] ) );
81
}
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:235
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:49
QgsSkyboxEntity::PanoramicSkybox
@ PanoramicSkybox
Definition
qgsskyboxentity.h:63
QgsSkyboxEntity::DistinctTexturesSkybox
@ DistinctTexturesSkybox
Definition
qgsskyboxentity.h:64
QgsSkyboxSettings::QgsSkyboxSettings
QgsSkyboxSettings()=default
QgsSkyboxSettings::readXml
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
Definition
qgsskyboxsettings.cpp:43
QgsSkyboxSettings::operator=
QgsSkyboxSettings & operator=(QgsSkyboxSettings const &rhs)
Definition
qgsskyboxsettings.cpp:32
QgsSkyboxSettings::writeXml
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.
Definition
qgsskyboxsettings.cpp:61
qgsreadwritecontext.h
qgsskyboxsettings.h
qgssymbollayerutils.h
Generated on
for QGIS API Documentation by
1.15.0