QGIS API Documentation 4.1.0-Master (70f46ec8b69)
Loading...
Searching...
No Matches
qgsmetalroughmaterialsettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmetalroughmaterialsettings.h
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
16#ifndef QGSMETALROUGHMATERIALSETTINGS_H
17#define QGSMETALROUGHMATERIALSETTINGS_H
18
19#include "qgis_core.h"
21
22#include <QColor>
23
24class QDomElement;
25
36{
37 public:
39
40 QString type() const override;
41 QSet< QgsAbstractMaterialSettings::Property > supportedProperties() const override;
42
47
52
54 bool equals( const QgsAbstractMaterialSettings *other ) const override;
55 bool requiresTangents() const override;
56
62 QColor baseColor() const { return mBaseColor; }
63
69 double metalness() const { return mMetalness; }
70
76 double roughness() const { return mRoughness; }
77
86 double reflectance() const { return mReflectance; }
87
97 double anisotropy() const { return mAnisotropy; }
98
108 double anisotropyRotation() const { return mAnisotropyRotation; }
109
116 QColor emissionColor() const { return mEmissiveColor; }
117
129 double emissionFactor() const { return mEmissionFactor; }
130
137 double opacity() const { return mOpacity; }
138
149 QColor averageColor() const override;
150
156 void setBaseColor( const QColor &color ) { mBaseColor = color; }
157
163 void setMetalness( double metalness ) { mMetalness = metalness; }
164
170 void setRoughness( double roughness ) { mRoughness = roughness; }
171
180 void setReflectance( double reflectance ) { mReflectance = reflectance; }
181
191 void setAnisotropy( double anisotropy ) { mAnisotropy = anisotropy; }
192
202 void setAnisotropyRotation( double rotation ) { mAnisotropyRotation = rotation; }
203
210 void setOpacity( double opacity ) { mOpacity = opacity; }
211
218 void setEmissionColor( const QColor &color ) { mEmissiveColor = color; }
219
231 void setEmissionFactor( double factor ) { mEmissionFactor = factor; }
232
240 double clearCoatFactor() const { return mClearCoatFactor; }
241
249 void setClearCoatFactor( double factor ) { mClearCoatFactor = factor; }
250
258 double clearCoatRoughness() const { return mClearCoatRoughness; }
259
267 void setClearCoatRoughness( double roughness ) { mClearCoatRoughness = roughness; }
268
281 void setColorsFromBase( const QColor &baseColor ) override;
282
283 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
284 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
285
286 bool operator==( const QgsMetalRoughMaterialSettings &other ) const
287 {
288 return mBaseColor == other.mBaseColor
289 && mEmissiveColor == other.mEmissiveColor
290 && qgsDoubleNear( mMetalness, other.mMetalness )
291 && qgsDoubleNear( mRoughness, other.mRoughness )
292 && qgsDoubleNear( mReflectance, other.mReflectance )
293 && qgsDoubleNear( mAnisotropy, other.mAnisotropy )
294 && qgsDoubleNear( mAnisotropyRotation, other.mAnisotropyRotation )
295 && qgsDoubleNear( mOpacity, other.mOpacity )
296 && qgsDoubleNear( mEmissionFactor, other.mEmissionFactor )
297 && qgsDoubleNear( mClearCoatFactor, other.mClearCoatFactor )
298 && qgsDoubleNear( mClearCoatRoughness, other.mClearCoatRoughness )
300 }
301
302 private:
303 QColor mBaseColor { QColor::fromRgbF( 0.5f, 0.5f, 0.5f, 1.0f ) };
304 QColor mEmissiveColor;
305 double mMetalness = 0.0;
306 double mRoughness = 0.5;
307 double mReflectance = 0.5;
308 double mAnisotropy = 0.0;
309 double mAnisotropyRotation = 0.0;
310 double mEmissionFactor = 1.0;
311 double mClearCoatFactor = 0.0;
312 double mClearCoatRoughness = 0.0;
313 double mOpacity = 1.0;
314};
315
316
317#endif // QGSMETALROUGHMATERIALSETTINGS_H
MaterialRenderingTechnique
Material rendering techniques.
Definition qgis.h:4362
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.
virtual QSet< QgsAbstractMaterialSettings::Property > supportedProperties() const
Returns the set of data-defined properties supported by this material.
virtual QColor averageColor() const =0
Returns an approximate color representing the blended material color.
virtual QString type() const =0
Returns the unique type name for the material.
virtual void setColorsFromBase(const QColor &baseColor)=0
Decomposes a base color into the material's color components, and sets the material's colors accordin...
QgsPropertyCollection dataDefinedProperties() const
Returns the symbol material property collection, used for data defined overrides.
double opacity() const
Returns the opacity of the surface.
static QgsAbstractMaterialSettings * create()
Returns a new instance of QgsMetalRoughMaterialSettings.
bool operator==(const QgsMetalRoughMaterialSettings &other) const
double roughness() const
Returns the material's roughness, as a value between 0 and 1.
bool requiresTangents() const override
Returns true if the material requires tangents generated during triangulation.
double metalness() const
Returns the material's metalness, as a value between 0 and 1.
double reflectance() const
Returns the material's reflectance, as a value between 0 and 1.
static bool supportsTechnique(Qgis::MaterialRenderingTechnique technique)
Returns true if the specified technique is supported by the metal rough material.
void setEmissionFactor(double factor)
Sets the emission factor, which dictates the strength of the emission effect.
QgsMetalRoughMaterialSettings * clone() const override
Clones the material settings.
void setRoughness(double roughness)
Sets the material's roughness, as a value between 0 and 1.
void setEmissionColor(const QColor &color)
Sets the material's emissive color.
void setClearCoatFactor(double factor)
Sets the material's clear coat factor, as a value between 0 and 1.
bool equals(const QgsAbstractMaterialSettings *other) const override
Returns true if this settings exactly matches an other settings.
double anisotropyRotation() const
Returns the rotation of the material's anisotropy, as a angle in degrees.
void setReflectance(double reflectance)
Sets the material's reflectance, as a value between 0 and 1.
void setClearCoatRoughness(double roughness)
Sets the material's clear coat roughness, as a value between 0 and 1.
void setAnisotropyRotation(double rotation)
Sets the rotation of the material's anisotropy, as a angle in degrees.
double clearCoatRoughness() const
Returns the material's clear coat roughness, as a value between 0 and 1.
double clearCoatFactor() const
Returns the material's clear coat factor, as a value between 0 and 1.
QColor emissionColor() const
Returns the material's emissive color.
void setMetalness(double metalness)
Sets the material's metalness, as a value between 0 and 1.
void setBaseColor(const QColor &color)
Sets the base material color.
double anisotropy() const
Returns the material's anisotropy, as a value between 0 and 1.
void setOpacity(double opacity)
Sets the opacity of the surface.
double emissionFactor() const
Returns the emission factor, which dictates the strength of the emission effect.
void setAnisotropy(double anisotropy)
Sets the material's anisotropy, as a value between 0 and 1.
QColor baseColor() const
Returns the base material color.
A container for the context for various read/write operations on objects.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Definition qgis.h:7327
#define SIP_FACTORY
Definition qgis_sip.h:83