QGIS API Documentation 4.1.0-Master (3b8ef1f72a3)
Loading...
Searching...
No Matches
qgsphongtexturedmaterialsettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsphongtexturedmaterialsettings.h
3 --------------------------------------
4 Date : August 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 QGSPHONGTEXTUREDMATERIALSETTINGS_H
17#define QGSPHONGTEXTUREDMATERIALSETTINGS_H
18
19#include "qgis_core.h"
21
22#include <QColor>
23
24class QgsMaterial;
25class QDomElement;
26
37{
38 public:
40
41 QString type() const override;
42
47
52
54 bool equals( const QgsAbstractMaterialSettings *other ) const override;
55
57 QColor ambient() const { return mAmbient; }
59 QColor specular() const { return mSpecular; }
61 double shininess() const { return mShininess; }
62
68 QString diffuseTexturePath() const { return mDiffuseTexturePath; }
69
75 double textureScale() const { return mTextureScale; }
76
77 bool requiresTextureCoordinates() const override;
78
82 double textureRotation() const;
83
88 double opacity() const { return mOpacity; }
89
91 void setAmbient( const QColor &ambient ) { mAmbient = ambient; }
92
94 void setSpecular( const QColor &specular ) { mSpecular = specular; }
96 void setShininess( double shininess ) { mShininess = shininess; }
97
102 void setDiffuseTexturePath( const QString &path ) { mDiffuseTexturePath = path; }
103
109 void setTextureScale( double scale ) { mTextureScale = scale; }
110
112 void setTextureRotation( double rotation ) { mTextureRotation = rotation; }
113
118 void setOpacity( double opacity ) { mOpacity = opacity; }
119
120 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
121 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
122
123 // TODO c++20 - replace with = default
125 {
126 return mAmbient == other.mAmbient
127 && mSpecular == other.mSpecular
128 && mShininess == other.mShininess
129 && mOpacity == other.mOpacity
130 && mDiffuseTexturePath == other.mDiffuseTexturePath
131 && mTextureScale == other.mTextureScale
132 && mTextureRotation == other.mTextureRotation
134 }
135
136 private:
137 QColor mAmbient { QColor::fromRgbF( 0.1f, 0.1f, 0.1f, 1.0f ) };
138 QColor mSpecular { QColor::fromRgbF( 1.0f, 1.0f, 1.0f, 1.0f ) };
139 double mShininess = 0.0;
140 double mOpacity = 1.0;
141 QString mDiffuseTexturePath;
142 double mTextureScale { 1.0f };
143 double mTextureRotation { 0.0f };
144};
145
146
147#endif // QGSPHONGTEXTUREDMATERIALSETTINGS_H
MaterialRenderingTechnique
Material rendering techniques.
Definition qgis.h:4327
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 QString type() const =0
Returns the unique type name for the material.
QgsPropertyCollection dataDefinedProperties() const
Returns the symbol material property collection, used for data defined overrides.
virtual bool requiresTextureCoordinates() const
Returns true if the material requires texture coordinates to be generated during triangulation.
Base class for all materials used within QGIS 3D views.
Definition qgsmaterial.h:40
void setShininess(double shininess)
Sets shininess of the surface.
static bool supportsTechnique(Qgis::MaterialRenderingTechnique technique)
Returns true if the specified technique is supported by the Phong material.
bool equals(const QgsAbstractMaterialSettings *other) const override
Returns true if this settings exactly matches an other settings.
void setTextureRotation(double rotation)
Sets the texture rotation in degrees.
void setSpecular(const QColor &specular)
Sets specular color component.
void setDiffuseTexturePath(const QString &path)
Sets the path of the diffuse texture.
QString diffuseTexturePath() const
Returns the diffuse texture path.
QColor specular() const
Returns specular color component.
void setTextureScale(double scale)
Sets the texture scale The texture scale changes the size of the displayed texture in the 3D scene If...
void setAmbient(const QColor &ambient)
Sets ambient color component.
double shininess() const
Returns shininess of the surface.
double opacity() const
Returns the opacity of the surface.
QgsPhongTexturedMaterialSettings * clone() const override
Clones the material settings.
void setOpacity(double opacity)
Sets opacity of the surface.
static QgsAbstractMaterialSettings * create()
Returns a new instance of QgsPhongTexturedMaterialSettings.
bool operator==(const QgsPhongTexturedMaterialSettings &other) const
double textureScale() const
Returns the texture scale The texture scale changes the size of the displayed texture in the 3D scene...
QColor ambient() const
Returns ambient color component.
A container for the context for various read/write operations on objects.
#define SIP_FACTORY
Definition qgis_sip.h:83