QGIS API Documentation 4.3.0-Master (18b5e825726)
Loading...
Searching...
No Matches
qgsunlitmaterialsettings.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsunlitmaterialsettings.cpp
3 --------------------------------------
4 Date : June 2026
5 Copyright : (C) 2026 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 "qgscolorutils.h"
19
20#include <QMap>
21#include <QString>
22
23using namespace Qt::StringLiterals;
24
26{
27 return u"unlit"_s;
28}
29
48
53
58
60{
61 const QgsUnlitMaterialSettings *otherLine = dynamic_cast<const QgsUnlitMaterialSettings *>( other );
62 if ( !otherLine )
63 return false;
64
65 return *this == *otherLine;
66}
67
68QSet<QgsAbstractMaterialSettings::Property> QgsUnlitMaterialSettings::supportedProperties() const
69{
71}
72
73void QgsUnlitMaterialSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
74{
75 mColor = QgsColorUtils::colorFromString( elem.attribute( u"color"_s, QgsColorUtils::colorToString( mColor ) ) );
76
78}
79
80void QgsUnlitMaterialSettings::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const
81{
82 elem.setAttribute( u"color"_s, QgsColorUtils::colorToString( mColor ) );
83
85}
86
88{
89 return mColor;
90}
91
92void QgsUnlitMaterialSettings::setColorsFromBase( const QColor &baseColor )
93{
94 mColor = baseColor;
95}
MaterialRenderingTechnique
Material rendering techniques.
Definition qgis.h:4388
@ Points
Point based rendering, requires point data.
Definition qgis.h:4392
@ Triangles
Triangle based rendering (default).
Definition qgis.h:4389
@ TrianglesFromModel
Triangle based rendering, using a model object source.
Definition qgis.h:4394
@ Lines
Line based rendering, requires line data.
Definition qgis.h:4390
@ Billboards
Flat billboard rendering.
Definition qgis.h:4396
@ TrianglesDataDefined
Triangle based rendering with possibility of datadefined color.
Definition qgis.h:4395
@ InstancedPoints
Instanced based rendering, requiring triangles and point data.
Definition qgis.h:4391
@ TrianglesWithFixedTexture
Triangle based rendering, using a fixed, non-user-configurable texture (e.g. for terrain rendering).
Definition qgis.h:4393
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.
@ BaseColor
Base color (metal-rough material).
static QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
A container for the context for various read/write operations on objects.
QgsUnlitMaterialSettings()=default
bool equals(const QgsAbstractMaterialSettings *other) const override
Returns true if this settings exactly matches an other settings.
QColor averageColor() const override
Returns an approximate color representing the blended material color.
QSet< QgsAbstractMaterialSettings::Property > supportedProperties() const override
Returns the set of data-defined properties supported by this material.
QString type() const override
Returns the unique type name for the material.
QgsUnlitMaterialSettings * clone() const override
Clones the material settings.
static QgsAbstractMaterialSettings * create()
Returns a new instance of QgsUnlitMaterialSettings.
void setColorsFromBase(const QColor &baseColor) override
Decomposes a base color into the material's color components, and sets the material's colors accordin...
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes settings to a DOM element.
static bool supportsTechnique(Qgis::MaterialRenderingTechnique technique)
Returns true if the specified technique is supported by the material.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads settings from a DOM element.