QGIS API Documentation 3.39.0-Master (be2050b798e)
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#include "qgssymbollayerutils.h"
19
21{
22 return QStringLiteral( "metalrough" );
23}
24
42
47
52
53void QgsMetalRoughMaterialSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
54{
55 mBaseColor = QgsSymbolLayerUtils::decodeColor( elem.attribute( QStringLiteral( "base" ), QStringLiteral( "125,125,125" ) ) );
56 mMetalness = elem.attribute( QStringLiteral( "metalness" ) ).toFloat();
57 mRoughness = elem.attribute( QStringLiteral( "roughness" ) ).toFloat();
58
60}
61
62void QgsMetalRoughMaterialSettings::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const
63{
64 elem.setAttribute( QStringLiteral( "base" ), QgsSymbolLayerUtils::encodeColor( mBaseColor ) );
65 elem.setAttribute( QStringLiteral( "metalness" ), mMetalness );
66 elem.setAttribute( QStringLiteral( "roughness" ), mRoughness );
67
69}
70
72{
73 switch ( technique )
74 {
79 {
80 QgsMetalRoughMaterial *material = new QgsMetalRoughMaterial;
81 material->setBaseColor( context.isSelected() ? context.selectionColor() : mBaseColor );
82 material->setMetalness( mMetalness );
83 material->setRoughness( mRoughness );
84 return material;
85 }
86
90 return nullptr;
91 }
92 return nullptr;
93}
94
96{
97 QMap<QString, QString> parameters;
98 return parameters;
99}
100
102{
103
104}
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.
QColor selectionColor() const
Returns the color for representing materials in a selected state.
bool isSelected() const
Returns true if the material should represent a selected state.
static QgsAbstractMaterialSettings * create()
Returns a new instance of QgsMetalRoughMaterialSettings.
Qt3DRender::QMaterial * toMaterial(QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context) const override
Creates a new QMaterial object representing the material settings.
QgsMetalRoughMaterialSettings * clone() const override
Clones the material settings.
QString type() const override
Returns the unique type name for the material.
QgsMetalRoughMaterialSettings()=default
Constructor for QgsMetalRoughMaterialSettings.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads settings from a DOM element.
void addParametersToEffect(Qt3DRender::QEffect *effect, const QgsMaterialContext &materialContext) const override
Adds parameters from the material to a destination effect.
static bool supportsTechnique(QgsMaterialSettingsRenderingTechnique technique)
Returns true if the specified technique is supported by the metal rough material.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes settings to a DOM element.
QMap< QString, QString > toExportParameters() const override
Returns the parameters to be exported to .mtl file.
The class is used as a container of context for various read/write operations on other objects.
static QColor decodeColor(const QString &str)
static QString encodeColor(const QColor &color)
QgsMaterialSettingsRenderingTechnique
Material rendering techniques 3.
@ Points
Point based rendering, requires point data.
@ Triangles
Triangle based rendering (default)
@ TrianglesFromModel
Triangle based rendering, using a model object source.
@ Lines
Line based rendering, requires line data.
@ TrianglesDataDefined
Triangle based rendering with possibility of datadefined color.
@ InstancedPoints
Instanced based rendering, requiring triangles and point data.
@ TrianglesWithFixedTexture
Triangle based rendering, using a fixed, non-user-configurable texture (e.g. for terrain rendering)