QGIS API Documentation 3.41.0-Master (cea29feecf2)
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_3d.h"
21
22#include <QColor>
23
24class QDomElement;
25
36{
37 public:
39
40 QString type() const override;
41
45 static bool supportsTechnique( QgsMaterialSettingsRenderingTechnique technique );
46
51
52 QgsMetalRoughMaterialSettings *clone() const override SIP_FACTORY;
53 bool equals( const QgsAbstractMaterialSettings *other ) const override;
54
60 QColor baseColor() const { return mBaseColor; }
61
67 double metalness() const { return mMetalness; }
68
74 double roughness() const { return mRoughness; }
75
76 QMap<QString, QString> toExportParameters() const override;
77
83 void setBaseColor( const QColor &color ) { mBaseColor = color; }
84
90 void setMetalness( double metalness ) { mMetalness = metalness; }
91
97 void setRoughness( double roughness ) { mRoughness = roughness; }
98
99 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
100 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
101
102#ifndef SIP_RUN
104 void addParametersToEffect( Qt3DRender::QEffect *effect, const QgsMaterialContext &materialContext ) const override;
105#endif
106
107 // TODO c++20 - replace with = default
108 bool operator==( const QgsMetalRoughMaterialSettings &other ) const
109 {
110 return mBaseColor == other.mBaseColor && qgsDoubleNear( mMetalness, other.mMetalness ) && qgsDoubleNear( mRoughness, other.mRoughness ) && dataDefinedProperties() == other.dataDefinedProperties();
111 }
112
113 private:
114 QColor mBaseColor { QColor::fromRgbF( 0.5f, 0.5f, 0.5f, 1.0f ) };
115 double mMetalness = 0.0;
116 double mRoughness = 0.0;
117};
118
119
120#endif // QGSMETALROUGHMATERIALSETTINGS_H
virtual void writeXml(QDomElement &element, const QgsReadWriteContext &) const
Writes settings to a DOM element.
virtual QMap< QString, QString > toExportParameters() const =0
Returns the parameters to be exported to .mtl file.
virtual void readXml(const QDomElement &element, const QgsReadWriteContext &)
Reads settings from a DOM element.
virtual void addParametersToEffect(Qt3DRender::QEffect *effect, const QgsMaterialContext &materialContext) const =0
Adds parameters from the material to a destination effect.
virtual QString type() const =0
Returns the unique type name for the material.
virtual QgsMaterial * toMaterial(QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context) const =0
Creates a new QgsMaterial object representing the material settings.
QgsPropertyCollection dataDefinedProperties() const
Returns the symbol material property collection, used for data defined overrides.
bool operator==(const QgsMetalRoughMaterialSettings &other) const
double roughness() const
Returns the material's roughness.
double metalness() const
Returns the material's metalness.
void setRoughness(double roughness)
Returns the material's roughness.
void setMetalness(double metalness)
Returns the material's metalness.
void setBaseColor(const QColor &color)
Sets the base material color.
The class is used as a container of context for various read/write operations on other objects.
QgsMaterialSettingsRenderingTechnique
Material rendering techniques 3.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition qgis.h:6024
#define SIP_FACTORY
Definition qgis_sip.h:76