QGIS API Documentation 4.1.0-Master (9af12b5a203)
Loading...
Searching...
No Matches
qgsshadowsettings.cpp
Go to the documentation of this file.
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 "qgsreadwritecontext.h"
19#include "qgssymbollayerutils.h"
20
21#include <QDomDocument>
22#include <QString>
23
24using namespace Qt::StringLiterals;
25
27 : mRenderShadows( other.mRenderShadows )
28 , mSelectedDirectionalLight( other.mSelectedDirectionalLight )
29 , mMaximumShadowRenderingDistance( other.mMaximumShadowRenderingDistance )
30 , mShadowBias( other.mShadowBias )
31 , mShadowQuality( other.mShadowQuality )
32 , mShowCascadeSplits( other.mShowCascadeSplits )
33{}
34
36{
37 if ( &rhs == this )
38 return *this;
39
40 this->mRenderShadows = rhs.mRenderShadows;
41 this->mSelectedDirectionalLight = rhs.mSelectedDirectionalLight;
42 this->mMaximumShadowRenderingDistance = rhs.mMaximumShadowRenderingDistance;
43 this->mShadowBias = rhs.mShadowBias;
44 this->mShadowQuality = rhs.mShadowQuality;
45 this->mShowCascadeSplits = rhs.mShowCascadeSplits;
46 return *this;
47}
48
49void QgsShadowSettings::readXml( const QDomElement &element, const QgsReadWriteContext &context )
50{
51 Q_UNUSED( context );
52 mRenderShadows = element.attribute( u"shadow-rendering-enabled"_s, u"0"_s ).toInt();
53 mSelectedDirectionalLight = element.attribute( u"selected-directional-light"_s, u"-1"_s ).toInt();
54 mMaximumShadowRenderingDistance = element.attribute( u"max-shadow-rendering-distance"_s, u"1500"_s ).toInt();
55 mShadowBias = element.attribute( u"shadow-bias"_s, u"0.00001"_s ).toFloat();
56}
57
58void QgsShadowSettings::writeXml( QDomElement &element, const QgsReadWriteContext &context ) const
59{
60 Q_UNUSED( context );
61 element.setAttribute( u"shadow-rendering-enabled"_s, mRenderShadows );
62 element.setAttribute( u"selected-directional-light"_s, mSelectedDirectionalLight );
63 element.setAttribute( u"max-shadow-rendering-distance"_s, mMaximumShadowRenderingDistance );
64 element.setAttribute( u"shadow-bias"_s, mShadowBias );
65}
66
68{
69 switch ( quality )
70 {
72 return 512;
74 return 1024;
76 return 2048;
78 return 4096;
80 return 8192;
81 }
83}
84
86{
87 return mShowCascadeSplits;
88}
89
90void QgsShadowSettings::setShowCascadeSplits( bool newShowCascadeSplits )
91{
92 mShowCascadeSplits = newShowCascadeSplits;
93}
ShadowQuality
Shadow texture quality.
Definition qgis.h:4389
@ Low
Low quality.
Definition qgis.h:4390
@ High
High quality.
Definition qgis.h:4392
@ Medium
Medium quality.
Definition qgis.h:4391
@ Extreme
Extremely high quality.
Definition qgis.h:4394
@ VeryHigh
Very high quality.
Definition qgis.h:4393
A container for the context for various read/write operations on objects.
QgsShadowSettings & operator=(QgsShadowSettings const &rhs)
QgsShadowSettings()=default
static int qualityToMapResolution(Qgis::ShadowQuality quality)
Returns the shadow map resolution corresponding to the specified shadow quality.
void setShowCascadeSplits(bool show)
Sets whether the cascading shadow splits should be tinted in the view.
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
bool showCascadeSplits() const
Returns true if the cascading shadow splits should be tinted in the view.
#define BUILTIN_UNREACHABLE
Definition qgis.h:7802