QGIS API Documentation 4.1.0-Master (3b8ef1f72a3)
Loading...
Searching...
No Matches
qgsgoochmaterialsettings.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsgoochmaterialsettings.cpp
3 --------------------------------------
4 Date : July 2020
5 Copyright : (C) 2020 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
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 "qgscolorutils.h"
19
20#include <QString>
21#include <QUrl>
22
23using namespace Qt::StringLiterals;
24
26{
27 return u"gooch"_s;
28}
29
34
53
58
60{
61 const QgsGoochMaterialSettings *otherGooch = dynamic_cast<const QgsGoochMaterialSettings *>( other );
62 if ( !otherGooch )
63 return false;
64
65 return *this == *otherGooch;
66}
67
68void QgsGoochMaterialSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
69{
70 mWarm = QgsColorUtils::colorFromString( elem.attribute( u"warm"_s, u"107,0,107"_s ) );
71 mCool = QgsColorUtils::colorFromString( elem.attribute( u"cool"_s, u"255,130,0"_s ) );
72 mDiffuse = QgsColorUtils::colorFromString( elem.attribute( u"diffuse"_s, u"178,178,178"_s ) );
73 mSpecular = QgsColorUtils::colorFromString( elem.attribute( u"specular"_s ) );
74 mShininess = elem.attribute( u"shininess2"_s, u"100"_s ).toDouble();
75 mAlpha = elem.attribute( u"alpha"_s, u"0.25"_s ).toDouble();
76 mBeta = elem.attribute( u"beta"_s, u"0.5"_s ).toDouble();
77
79}
80
81void QgsGoochMaterialSettings::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const
82{
83 elem.setAttribute( u"warm"_s, QgsColorUtils::colorToString( mWarm ) );
84 elem.setAttribute( u"cool"_s, QgsColorUtils::colorToString( mCool ) );
85 elem.setAttribute( u"diffuse"_s, QgsColorUtils::colorToString( mDiffuse ) );
86 elem.setAttribute( u"specular"_s, QgsColorUtils::colorToString( mSpecular ) );
87 elem.setAttribute( u"shininess2"_s, mShininess );
88 elem.setAttribute( u"alpha"_s, mAlpha );
89 elem.setAttribute( u"beta"_s, mBeta );
90
92}
MaterialRenderingTechnique
Material rendering techniques.
Definition qgis.h:4327
@ Points
Point based rendering, requires point data.
Definition qgis.h:4331
@ Triangles
Triangle based rendering (default).
Definition qgis.h:4328
@ TrianglesFromModel
Triangle based rendering, using a model object source.
Definition qgis.h:4333
@ Lines
Line based rendering, requires line data.
Definition qgis.h:4329
@ Billboards
Flat billboard rendering.
Definition qgis.h:4335
@ TrianglesDataDefined
Triangle based rendering with possibility of datadefined color.
Definition qgis.h:4334
@ InstancedPoints
Instanced based rendering, requiring triangles and point data.
Definition qgis.h:4330
@ TrianglesWithFixedTexture
Triangle based rendering, using a fixed, non-user-configurable texture (e.g. for terrain rendering).
Definition qgis.h:4332
Abstract base class for material settings.
virtual void writeXml(QDomElement &element, const QgsReadWriteContext &) const
Writes settings to a DOM element.
virtual void readXml(const QDomElement &element, const QgsReadWriteContext &)
Reads settings from a DOM element.
static QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
QgsGoochMaterialSettings * clone() const override
Clones the material settings.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes settings to a DOM element.
bool equals(const QgsAbstractMaterialSettings *other) const override
Returns true if this settings exactly matches an other settings.
QString type() const override
Returns the unique type name for the material.
QgsGoochMaterialSettings()=default
static bool supportsTechnique(Qgis::MaterialRenderingTechnique technique)
Returns true if the specified technique is supported by the Gooch material.
static QgsAbstractMaterialSettings * create()
Returns a new instance of QgsGoochMaterialSettings.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads settings from a DOM element.
A container for the context for various read/write operations on objects.