QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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 }
bool operator==(const QgsDirectionalLightSettings &other)
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element and returns it.
void readXml(const QDomElement &elem)
Reads configuration from a DOM element previously written using writeXml()
static QColor decodeColor(const QString &str)
static QString encodeColor(const QColor &color)
double y() const
Returns Y coordinate.
Definition: qgsvector3d.h:51
double z() const
Returns Z coordinate.
Definition: qgsvector3d.h:53
double x() const
Returns X coordinate.
Definition: qgsvector3d.h:49
void set(double x, double y, double z)
Sets vector coordinates.
Definition: qgsvector3d.h:56