QGIS API Documentation 3.39.0-Master (3aed037ce22)
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_3d.h"
21
22#include <QColor>
23
24class QDomElement;
25
37{
38 public:
39
41
42 QString type() const override;
43
48
52 static bool supportsTechnique( QgsMaterialSettingsRenderingTechnique technique );
53
54 QgsGoochMaterialSettings *clone() const override SIP_FACTORY;
55
57 QColor warm() const { return mWarm; }
58
60 QColor cool() const { return mCool; }
61
63 QColor diffuse() const { return mDiffuse; }
65 QColor specular() const { return mSpecular; }
67 float shininess() const { return mShininess; }
68
70 float alpha() const { return mAlpha; }
71
73 float beta() const { return mBeta; }
74
76 void setWarm( const QColor &warm ) { mWarm = warm; }
77
79 void setCool( const QColor &cool ) { mCool = cool; }
80
82 void setDiffuse( const QColor &diffuse ) { mDiffuse = diffuse; }
84 void setSpecular( const QColor &specular ) { mSpecular = specular; }
86 void setShininess( float shininess ) { mShininess = shininess; }
87
89 void setAlpha( float alpha ) { mAlpha = alpha; }
90
92 void setBeta( float beta ) { mBeta = beta; }
93
94 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
95 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
96 QMap<QString, QString> toExportParameters() const override;
97
98#ifndef SIP_RUN
99 Qt3DRender::QMaterial *toMaterial( QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context ) const override;
100 void addParametersToEffect( Qt3DRender::QEffect *effect, const QgsMaterialContext &materialContext ) const override;
101
102 QByteArray dataDefinedVertexColorsAsByte( const QgsExpressionContext &expressionContext ) const override;
103 int dataDefinedByteStride() const override;
104#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
105 void applyDataDefinedToGeometry( Qt3DRender::QGeometry *geometry, int vertexCount, const QByteArray &data ) const override;
106#else
107 void applyDataDefinedToGeometry( Qt3DCore::QGeometry *geometry, int vertexCount, const QByteArray &data ) const override;
108#endif
109
110#endif
111
112 // TODO c++20 - replace with = default
113 bool operator==( const QgsGoochMaterialSettings &other ) const
114 {
115 return mDiffuse == other.mDiffuse &&
116 mSpecular == other.mSpecular &&
117 mWarm == other.mWarm &&
118 mCool == other.mCool &&
119 mShininess == other.mShininess &&
120 mAlpha == other.mAlpha &&
121 mBeta == other.mBeta;
122 }
123
124 private:
125 QColor mDiffuse{ QColor::fromRgbF( 0.7f, 0.7f, 0.7f, 1.0f ) };
126 QColor mSpecular{ QColor::fromRgbF( 1.0f, 1.0f, 1.0f, 1.0f ) };
127 QColor mWarm {QColor( 107, 0, 107 ) };
128 QColor mCool {QColor( 255, 130, 0 )};
129 float mShininess = 100.0f;
130 float mAlpha = 0.25f;
131 float mBeta = 0.5f;
132
134 Qt3DRender::QMaterial *buildMaterial( const QgsMaterialContext &context ) const;
135};
136
137
138#endif // QGSGOOCHMATERIALSETTINGS_H
virtual void writeXml(QDomElement &element, const QgsReadWriteContext &) const
Writes settings to a DOM element.
virtual QByteArray dataDefinedVertexColorsAsByte(const QgsExpressionContext &expressionContext) const
Returns byte array corresponding to the data defined colors depending of the expressionContext,...
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 int dataDefinedByteStride() const
Returns byte stride of the data defined colors,used to fill the vertex colors data defined buffer for...
virtual Qt3DRender::QMaterial * toMaterial(QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context) const =0
Creates a new QMaterial object representing the material settings.
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 void applyDataDefinedToGeometry(Qt3DCore::QGeometry *geometry, int vertexCount, const QByteArray &dataDefinedBytes) const
Applies the data defined bytes, dataDefinedBytes, on the geometry by filling a specific vertex buffer...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QColor specular() const
Returns specular color component.
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 setShininess(float shininess)
Sets shininess of the surface.
float alpha() const
Returns the alpha value.
void setAlpha(float alpha)
Sets alpha value.
void setSpecular(const QColor &specular)
Sets specular color component.
QColor diffuse() const
Returns diffuse color component.
bool operator==(const QgsGoochMaterialSettings &other) const
QgsGoochMaterialSettings()=default
float shininess() const
Returns shininess of the surface.
float beta() const
Returns the beta value.
void setDiffuse(const QColor &diffuse)
Sets diffuse color component.
void setBeta(float beta)
Sets beta value.
The class is used as a container of context for various read/write operations on other objects.
QgsMaterialSettingsRenderingTechnique
Material rendering techniques 3.
#define SIP_FACTORY
Definition qgis_sip.h:76