QGIS API Documentation 4.3.0-Master (0cfde48c85b)
Loading...
Searching...
No Matches
qgsgoochmaterialsettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsgoochmaterialsettings.h
3 --------------------------------------
4 Date : July 2020
5 Copyright : (C) 2020 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 QGSGOOCHMATERIALSETTINGS_H
17#define QGSGOOCHMATERIALSETTINGS_H
18
19#include "qgis_core.h"
21
22#include <QColor>
23
24class QgsMaterial;
25class QDomElement;
26
38{
39 public:
41
42 QString type() const override;
43
47 static std::unique_ptr<QgsAbstractMaterialSettings> create();
48
53
55 bool equals( const QgsAbstractMaterialSettings *other ) const override;
57
59 QColor warm() const { return mWarm; }
60
62 QColor cool() const { return mCool; }
63
65 QColor diffuse() const { return mDiffuse; }
67 QColor specular() const { return mSpecular; }
69 double shininess() const { return mShininess; }
70
72 double alpha() const { return mAlpha; }
73
75 double beta() const { return mBeta; }
76
78 void setWarm( const QColor &warm ) { mWarm = warm; }
79
81 void setCool( const QColor &cool ) { mCool = cool; }
82
84 void setDiffuse( const QColor &diffuse ) { mDiffuse = diffuse; }
86 void setSpecular( const QColor &specular ) { mSpecular = specular; }
88 void setShininess( double shininess ) { mShininess = shininess; }
89
91 void setAlpha( double alpha ) { mAlpha = alpha; }
92
94 void setBeta( double beta ) { mBeta = beta; }
95
109 QColor averageColor() const override;
110
130 void setColorsFromBase( const QColor &baseColor, double alpha, double beta );
131
148 void setColorsFromBase( const QColor &baseColor ) override;
149
150 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
151 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
152
153 bool operator==( const QgsGoochMaterialSettings &other ) const
154 {
155 return mDiffuse == other.mDiffuse
156 && mSpecular == other.mSpecular
157 && mWarm == other.mWarm
158 && mCool == other.mCool
159 && qgsDoubleNear( mShininess, other.mShininess )
160 && qgsDoubleNear( mAlpha, other.mAlpha )
161 && qgsDoubleNear( mBeta, other.mBeta )
163 }
164
165 private:
166 QColor mDiffuse { QColor::fromRgbF( 0.7f, 0.7f, 0.7f, 1.0f ) };
167 QColor mSpecular { QColor::fromRgbF( 1.0f, 1.0f, 1.0f, 1.0f ) };
168 QColor mWarm { QColor( 107, 0, 107 ) };
169 QColor mCool { QColor( 255, 130, 0 ) };
170 double mShininess = 100.0;
171 double mAlpha = 0.25;
172 double mBeta = 0.5;
173};
174
175
176#endif // QGSGOOCHMATERIALSETTINGS_H
MaterialRenderingTechnique
Material rendering techniques.
Definition qgis.h:4453
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 QgsAbstractMaterialSettings * clone() const =0
Clones the material settings.
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.
QColor specular() const
Returns specular color component.
double alpha() const
Returns the alpha value.
void setCool(const QColor &cool)
Sets cool color component.
void setWarm(const QColor &warm)
Sets warm color component.
QColor cool() const
Returns cool color component.
void setSpecular(const QColor &specular)
Sets specular color component.
QColor warm() const
Returns warm color component.
bool equals(const QgsAbstractMaterialSettings *other) const override
Returns true if this settings exactly matches an other settings.
QColor diffuse() const
Returns diffuse color component.
double beta() const
Returns the beta value.
bool operator==(const QgsGoochMaterialSettings &other) const
QgsGoochMaterialSettings()=default
static bool supportsTechnique(Qgis::MaterialRenderingTechnique technique)
Returns true if the specified technique is supported by the Gooch material.
void setBeta(double beta)
Sets beta value.
static std::unique_ptr< QgsAbstractMaterialSettings > create()
Returns a new instance of QgsGoochMaterialSettings.
void setShininess(double shininess)
Sets shininess of the surface.
void setAlpha(double alpha)
Sets alpha value.
void setDiffuse(const QColor &diffuse)
Sets diffuse color component.
double shininess() const
Returns shininess of the surface.
QSet< QgsAbstractMaterialSettings::Property > supportedProperties() const override
Returns the set of data-defined properties supported by this material.
Base class for all materials used within QGIS 3D views.
Definition qgsmaterial.h:40
A container for the context for various read/write operations on objects.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Definition qgis.h:7725
#define SIP_FACTORY
Definition qgis_sip.h:83