QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
46
51
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
Abstract base class for material settings.
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.
Context settings for a material.
Base class for all materials used within QGIS 3D views.
Definition qgsmaterial.h:39
static QgsAbstractMaterialSettings * create()
Returns a new instance of QgsMetalRoughMaterialSettings.
bool operator==(const QgsMetalRoughMaterialSettings &other) const
double roughness() const
Returns the material's roughness.
double metalness() const
Returns the material's metalness.
QgsMetalRoughMaterialSettings * clone() const override
Clones the material settings.
void setRoughness(double roughness)
Returns the material's roughness.
bool equals(const QgsAbstractMaterialSettings *other) const override
Returns true if this settings exactly matches an other settings.
void setMetalness(double metalness)
Returns the material's metalness.
void setBaseColor(const QColor &color)
Sets the base material color.
static bool supportsTechnique(QgsMaterialSettingsRenderingTechnique technique)
Returns true if the specified technique is supported by the metal rough material.
QColor baseColor() const
Returns the base material color.
A container for the context for various read/write operations on objects.
QgsMaterialSettingsRenderingTechnique
Material rendering techniques.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Definition qgis.h:6607
#define SIP_FACTORY
Definition qgis_sip.h:84