1 /***************************************************************************
2   qgsshadowsettings.cpp
3   --------------------------------------
4   Date                 : September 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 "qgsshadowsettings.h"
17 
18 #include <QDomDocument>
19 
20 #include "qgsreadwritecontext.h"
21 #include "qgssymbollayerutils.h"
22 
QgsShadowSettings(const QgsShadowSettings & other)23 QgsShadowSettings::QgsShadowSettings( const QgsShadowSettings &other )
24   : mRenderShadows( other.mRenderShadows )
25   , mSelectedDirectionalLight( other.mSelectedDirectionalLight )
26   , mMaximumShadowRenderingDistance( other.mMaximumShadowRenderingDistance )
27   , mShadowBias( other.mShadowBias )
28   , mShadowMapResolution( other.mShadowMapResolution )
29 {
30 
31 }
32 
operator =(QgsShadowSettings const & rhs)33 QgsShadowSettings &QgsShadowSettings::operator=( QgsShadowSettings const &rhs )
34 {
35   this->mRenderShadows = rhs.mRenderShadows;
36   this->mSelectedDirectionalLight = rhs.mSelectedDirectionalLight;
37   this->mMaximumShadowRenderingDistance = rhs.mMaximumShadowRenderingDistance;
38   this->mShadowBias = rhs.mShadowBias;
39   this->mShadowMapResolution = rhs.mShadowMapResolution;
40   return *this;
41 }
42 
readXml(const QDomElement & element,const QgsReadWriteContext & context)43 void QgsShadowSettings::readXml( const QDomElement &element, const QgsReadWriteContext &context )
44 {
45   Q_UNUSED( context );
46   mRenderShadows = element.attribute( QStringLiteral( "shadow-rendering-enabled" ), QStringLiteral( "0" ) ).toInt();
47   mSelectedDirectionalLight = element.attribute( QStringLiteral( "selected-directional-light" ), QStringLiteral( "-1" ) ).toInt();
48   mMaximumShadowRenderingDistance = element.attribute( QStringLiteral( "max-shadow-rendering-distance" ), QStringLiteral( "1500" ) ).toInt();
49   mShadowBias = element.attribute( QStringLiteral( "shadow-bias" ), QStringLiteral( "0.00001" ) ).toFloat();
50   mShadowMapResolution = element.attribute( QStringLiteral( "shadow-map-resolution" ), QStringLiteral( "2048" ) ).toInt();
51 }
52 
writeXml(QDomElement & element,const QgsReadWriteContext & context) const53 void QgsShadowSettings::writeXml( QDomElement &element, const QgsReadWriteContext &context ) const
54 {
55   Q_UNUSED( context );
56   element.setAttribute( QStringLiteral( "shadow-rendering-enabled" ), mRenderShadows );
57   element.setAttribute( QStringLiteral( "selected-directional-light" ), mSelectedDirectionalLight );
58   element.setAttribute( QStringLiteral( "max-shadow-rendering-distance" ), mMaximumShadowRenderingDistance );
59   element.setAttribute( QStringLiteral( "shadow-bias" ), mShadowBias );
60   element.setAttribute( QStringLiteral( "shadow-map-resolution" ), mShadowMapResolution );
61 }
62