QGIS API Documentation 4.1.0-Master (3b8ef1f72a3)
Loading...
Searching...
No Matches
qgsmetalroughmaterialsettings.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmetalroughmaterialsettings.cpp
3 --------------------------------------
4 Date : December 2023
5 Copyright : (C) 2023 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 "qgssymbollayerutils.h"
19
20#include <QString>
21
22using namespace Qt::StringLiterals;
23
25{
26 return u"metalrough"_s;
27}
28
47
52
57
59{
60 const QgsMetalRoughMaterialSettings *otherMetal = dynamic_cast<const QgsMetalRoughMaterialSettings *>( other );
61 if ( !otherMetal )
62 return false;
63
64 return *this == *otherMetal;
65}
66
67void QgsMetalRoughMaterialSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
68{
69 mBaseColor = QgsSymbolLayerUtils::decodeColor( elem.attribute( u"base"_s, u"125,125,125"_s ) );
70 mMetalness = elem.attribute( u"metalness"_s, u"0.0"_s ).toDouble();
71 mRoughness = elem.attribute( u"roughness"_s, u"0.5"_s ).toDouble();
72
74}
75
76void QgsMetalRoughMaterialSettings::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const
77{
78 elem.setAttribute( u"base"_s, QgsSymbolLayerUtils::encodeColor( mBaseColor ) );
79 elem.setAttribute( u"metalness"_s, mMetalness );
80 elem.setAttribute( u"roughness"_s, mRoughness );
81
83}
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 QgsAbstractMaterialSettings * create()
Returns a new instance of QgsMetalRoughMaterialSettings.
static bool supportsTechnique(Qgis::MaterialRenderingTechnique technique)
Returns true if the specified technique is supported by the metal rough material.
QgsMetalRoughMaterialSettings * clone() const override
Clones the material settings.
QString type() const override
Returns the unique type name for the material.
bool equals(const QgsAbstractMaterialSettings *other) const override
Returns true if this settings exactly matches an other settings.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads settings from a DOM element.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes settings to a DOM element.
A container for the context for various read/write operations on objects.
static QColor decodeColor(const QString &str)
static QString encodeColor(const QColor &color)