QGIS API Documentation 4.3.0-Master (03a7e469fa9)
Loading...
Searching...
No Matches
qgsphongmaterialsettings.h
Go to the documentation of this file.
1
2/***************************************************************************
3 qgsphongmaterialsettings.h
4 --------------------------------------
5 Date : July 2017
6 Copyright : (C) 2017 by Martin Dobias
7 Email : wonder dot sk at gmail dot com
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSPHONGMATERIALSETTINGS_H
18#define QGSPHONGMATERIALSETTINGS_H
19
20#include "qgis_core.h"
22
23#include <QColor>
24
25class QgsMaterial;
26class QDomElement;
27
38{
39 public:
41
42 QString type() const override;
43
48
53
55 bool equals( const QgsAbstractMaterialSettings *other ) const override;
57
59 QColor ambient() const { return mAmbient; }
61 QColor diffuse() const { return mDiffuse; }
63 QColor specular() const { return mSpecular; }
65 double shininess() const { return mShininess; }
66
71 double opacity() const { return mOpacity; }
72
82 double ambientCoefficient() const { return mAmbientCoefficient; }
83
93 double diffuseCoefficient() const { return mDiffuseCoefficient; }
94
104 double specularCoefficient() const { return mSpecularCoefficient; }
105
107 void setAmbient( const QColor &ambient ) { mAmbient = ambient; }
109 void setDiffuse( const QColor &diffuse ) { mDiffuse = diffuse; }
111 void setSpecular( const QColor &specular ) { mSpecular = specular; }
113 void setShininess( double shininess ) { mShininess = shininess; }
114
119 void setOpacity( double opacity ) { mOpacity = opacity; }
120
130 void setAmbientCoefficient( double coefficient ) { mAmbientCoefficient = coefficient; }
131
141 void setDiffuseCoefficient( double coefficient ) { mDiffuseCoefficient = coefficient; }
142
152 void setSpecularCoefficient( double coefficient ) { mSpecularCoefficient = coefficient; }
153
166 QColor averageColor() const override;
167
184 void setColorsFromBase( const QColor &baseColor, float metallic );
185
201 void setColorsFromBase( const QColor &baseColor ) override;
202
203 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
204 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
205
206 // TODO c++20 - replace with = default
207 bool operator==( const QgsPhongMaterialSettings &other ) const
208 {
209 return mAmbient == other.mAmbient
210 && mDiffuse == other.mDiffuse
211 && mOpacity == other.mOpacity
212 && mSpecular == other.mSpecular
213 && mShininess == other.mShininess
214 && mAmbientCoefficient == other.mAmbientCoefficient
215 && mDiffuseCoefficient == other.mDiffuseCoefficient
216 && mSpecularCoefficient == other.mSpecularCoefficient
218 }
219
220 private:
221 QColor mAmbient { QColor::fromRgbF( 0.1f, 0.1f, 0.1f, 1.0f ) };
222 QColor mDiffuse { QColor::fromRgbF( 0.7f, 0.7f, 0.7f, 1.0f ) };
223 QColor mSpecular { QColor::fromRgbF( 1.0f, 1.0f, 1.0f, 1.0f ) };
224 double mShininess = 0.0;
225
226 double mAmbientCoefficient = 1.0;
227 double mDiffuseCoefficient = 1.0;
228 double mSpecularCoefficient = 1.0;
229
230 double mOpacity = 1.0;
231};
232
233
234#endif // QGSPHONGMATERIALSETTINGS_H
MaterialRenderingTechnique
Material rendering techniques.
Definition qgis.h:4404
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 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.
Base class for all materials used within QGIS 3D views.
Definition qgsmaterial.h:40
QSet< QgsAbstractMaterialSettings::Property > supportedProperties() const override
Returns the set of data-defined properties supported by this material.
double ambientCoefficient() const
Returns the coefficient for the ambient color contribution (ie strength factor of the ambient color).
void setOpacity(double opacity)
Sets opacity of the surface.
bool operator==(const QgsPhongMaterialSettings &other) const
void setDiffuse(const QColor &diffuse)
Sets diffuse color component.
bool equals(const QgsAbstractMaterialSettings *other) const override
Returns true if this settings exactly matches an other settings.
void setDiffuseCoefficient(double coefficient)
Sets the coefficient for the diffuse color contribution (ie strength factor of the diffuse color).
void setShininess(double shininess)
Sets shininess of the surface.
QColor diffuse() const
Returns diffuse color component.
double opacity() const
Returns the opacity of the surface.
static bool supportsTechnique(Qgis::MaterialRenderingTechnique technique)
Returns true if the specified technique is supported by the Phong material.
QColor specular() const
Returns specular color component.
QColor ambient() const
Returns ambient color component.
void setAmbient(const QColor &ambient)
Sets ambient color component.
void setSpecularCoefficient(double coefficient)
Sets the coefficient for the specular color contribution (ie strength factor of the specular color).
double specularCoefficient() const
Returns the coefficient for the specular color contribution (ie strength factor of the specular color...
static QgsAbstractMaterialSettings * create()
Returns a new instance of QgsPhongMaterialSettings.
QgsPhongMaterialSettings * clone() const override
Clones the material settings.
double shininess() const
Returns shininess of the surface.
QgsPhongMaterialSettings()=default
double diffuseCoefficient() const
Returns the coefficient for the diffuse color contribution (ie strength factor of the diffuse color).
void setSpecular(const QColor &specular)
Sets specular color component.
void setAmbientCoefficient(double coefficient)
Sets the coefficient for the ambient color contribution (ie strength factor of the ambient color).
A container for the context for various read/write operations on objects.
#define SIP_FACTORY
Definition qgis_sip.h:83