QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsdirectionallightsettings.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdirectionallightsettings.cpp
3  --------------------------------------
4  Date : June 2020
5  Copyright : (C) 2020 by Belgacem Nedjima
6  Email : gb underscore 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 
17 
18 #include <QDomDocument>
19 
20 #include "qgssymbollayerutils.h"
21 
22 
23 QDomElement QgsDirectionalLightSettings::writeXml( QDomDocument &doc ) const
24 {
25  QDomElement elemLight = doc.createElement( QStringLiteral( "directional-light" ) );
26  elemLight.setAttribute( QStringLiteral( "x" ), mDirection.x() );
27  elemLight.setAttribute( QStringLiteral( "y" ), mDirection.y() );
28  elemLight.setAttribute( QStringLiteral( "z" ), mDirection.z() );
29  elemLight.setAttribute( QStringLiteral( "color" ), QgsSymbolLayerUtils::encodeColor( mColor ) );
30  elemLight.setAttribute( QStringLiteral( "intensity" ), mIntensity );
31  return elemLight;
32 }
33 
34 void QgsDirectionalLightSettings::readXml( const QDomElement &elem )
35 {
36  mDirection.set( elem.attribute( QStringLiteral( "x" ) ).toFloat(),
37  elem.attribute( QStringLiteral( "y" ) ).toFloat(),
38  elem.attribute( QStringLiteral( "z" ) ).toFloat() );
39  mColor = QgsSymbolLayerUtils::decodeColor( elem.attribute( QStringLiteral( "color" ) ) );
40  mIntensity = elem.attribute( QStringLiteral( "intensity" ) ).toFloat();
41 }
42 
44 {
45  return mDirection == other.mDirection && mColor == other.mColor && mIntensity == other.mIntensity;
46 }
QgsSymbolLayerUtils::encodeColor
static QString encodeColor(const QColor &color)
Definition: qgssymbollayerutils.cpp:52
QgsVector3D::y
double y() const
Returns Y coordinate.
Definition: qgsvector3d.h:51
qgssymbollayerutils.h
QgsVector3D::set
void set(double x, double y, double z)
Sets vector coordinates.
Definition: qgsvector3d.h:56
QgsSymbolLayerUtils::decodeColor
static QColor decodeColor(const QString &str)
Definition: qgssymbollayerutils.cpp:57
QgsVector3D::z
double z() const
Returns Z coordinate.
Definition: qgsvector3d.h:53
QgsDirectionalLightSettings::readXml
void readXml(const QDomElement &elem)
Reads configuration from a DOM element previously written using writeXml()
Definition: qgsdirectionallightsettings.cpp:34
QgsDirectionalLightSettings::writeXml
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element and returns it.
Definition: qgsdirectionallightsettings.cpp:23
QgsDirectionalLightSettings::operator==
bool operator==(const QgsDirectionalLightSettings &other)
Definition: qgsdirectionallightsettings.cpp:43
QgsVector3D::x
double x() const
Returns X coordinate.
Definition: qgsvector3d.h:49
qgsdirectionallightsettings.h
QgsDirectionalLightSettings
3 Definition of a directional light in a 3D map scene
Definition: qgsdirectionallightsettings.h:33