QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsphongmaterialsettings.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsphongmaterialsettings.h
3  --------------------------------------
4  Date : July 2017
5  Copyright : (C) 2017 by Martin Dobias
6  Email : wonder dot sk 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 QGSPHONGMATERIALSETTINGS_H
17 #define QGSPHONGMATERIALSETTINGS_H
18 
19 #include "qgis_3d.h"
21 
22 #include <QColor>
23 
24 class QDomElement;
25 
37 {
38  public:
39 
44 
45  QString type() const override;
46 
50  static bool supportsTechnique( QgsMaterialSettingsRenderingTechnique technique );
51 
56 
57  QgsPhongMaterialSettings *clone() const override SIP_FACTORY;
58 
60  QColor ambient() const { return mAmbient; }
62  QColor diffuse() const { return mDiffuse; }
64  QColor specular() const { return mSpecular; }
66  float shininess() const { return mShininess; }
67 
68  QMap<QString, QString> toExportParameters() const override;
69 
71  void setAmbient( const QColor &ambient ) { mAmbient = ambient; }
73  void setDiffuse( const QColor &diffuse ) { mDiffuse = diffuse; }
75  void setSpecular( const QColor &specular ) { mSpecular = specular; }
77  void setShininess( float shininess ) { mShininess = shininess; }
78 
79  void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
80  void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
81 #ifndef SIP_RUN
82  Qt3DRender::QMaterial *toMaterial( QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context ) const override SIP_FACTORY;
83  void addParametersToEffect( Qt3DRender::QEffect *effect ) const override;
84 #endif
85 
86  bool operator==( const QgsPhongMaterialSettings &other ) const
87  {
88  return mAmbient == other.mAmbient &&
89  mDiffuse == other.mDiffuse &&
90  mSpecular == other.mSpecular &&
91  mShininess == other.mShininess;
92  }
93 
94  private:
95  QColor mAmbient{ QColor::fromRgbF( 0.1f, 0.1f, 0.1f, 1.0f ) };
96  QColor mDiffuse{ QColor::fromRgbF( 0.7f, 0.7f, 0.7f, 1.0f ) };
97  QColor mSpecular{ QColor::fromRgbF( 1.0f, 1.0f, 1.0f, 1.0f ) };
98  float mShininess = 0.0f;
99 };
100 
101 
102 #endif // QGSPHONGMATERIALSETTINGS_H
QgsAbstractMaterialSettings::type
virtual QString type() const =0
Returns the unique type name for the material.
QgsPhongMaterialSettings::diffuse
QColor diffuse() const
Returns diffuse color component.
Definition: qgsphongmaterialsettings.h:62
QgsPhongMaterialSettings::specular
QColor specular() const
Returns specular color component.
Definition: qgsphongmaterialsettings.h:64
QgsPhongMaterialSettings::QgsPhongMaterialSettings
QgsPhongMaterialSettings()=default
Constructor for QgsPhongMaterialSettings.
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsAbstractMaterialSettings::toExportParameters
virtual QMap< QString, QString > toExportParameters() const =0
Returns the parameters to be exported to .mtl file.
QgsAbstractMaterialSettings::readXml
virtual void readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads settings from a DOM element.
QgsPhongMaterialSettings::setSpecular
void setSpecular(const QColor &specular)
Sets specular color component.
Definition: qgsphongmaterialsettings.h:75
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsMaterialContext
3 Context settings for a material.
Definition: qgsabstractmaterialsettings.h:55
QgsPhongMaterialSettings
3 Basic shading material used for rendering based on the Phong shading model with three color compone...
Definition: qgsphongmaterialsettings.h:37
qgsabstractmaterialsettings.h
QgsAbstractMaterialSettings
3 Abstract base class for material settings.
Definition: qgsabstractmaterialsettings.h:105
QgsPhongMaterialSettings::operator==
bool operator==(const QgsPhongMaterialSettings &other) const
Definition: qgsphongmaterialsettings.h:86
QgsPhongMaterialSettings::setShininess
void setShininess(float shininess)
Sets shininess of the surface.
Definition: qgsphongmaterialsettings.h:77
QgsAbstractMaterialSettings::addParametersToEffect
virtual void addParametersToEffect(Qt3DRender::QEffect *effect) const =0
Adds parameters from the material to a destination effect.
QgsPhongMaterialSettings::setDiffuse
void setDiffuse(const QColor &diffuse)
Sets diffuse color component.
Definition: qgsphongmaterialsettings.h:73
QgsAbstractMaterialSettings::writeXml
virtual void writeXml(QDomElement &element, const QgsReadWriteContext &context) const =0
Writes settings to a DOM element.
QgsMaterialSettingsRenderingTechnique
QgsMaterialSettingsRenderingTechnique
Material rendering techniques 3.
Definition: qgsabstractmaterialsettings.h:36
QgsAbstractMaterialSettings::toMaterial
virtual Qt3DRender::QMaterial * toMaterial(QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context) const =0
Creates a new QMaterial object representing the material settings.
QgsPhongMaterialSettings::setAmbient
void setAmbient(const QColor &ambient)
Sets ambient color component.
Definition: qgsphongmaterialsettings.h:71
QgsPhongMaterialSettings::shininess
float shininess() const
Returns shininess of the surface.
Definition: qgsphongmaterialsettings.h:66