QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsabstractmaterialsettings.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsabstractmaterialsettings.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 QGSABSTRACTMATERIALSETTINGS_H
17 #define QGSABSTRACTMATERIALSETTINGS_H
18 
19 #include "qgis_3d.h"
20 #include "qgis_sip.h"
21 
22 #include <QColor>
23 #include <Qt3DRender/qmaterial.h>
24 
25 class QDomElement;
27 class QgsLineMaterial;
28 
29 
36  {
37  Triangles,
38  Lines,
39  InstancedPoints,
40  Points,
42 };
43 
44 
54 class _3D_EXPORT QgsMaterialContext
55 {
56  public:
57 
63  bool isSelected() const { return mIsSelected; }
64 
70  void setIsSelected( bool isSelected ) { mIsSelected = isSelected; }
71 
77  QColor selectionColor() const { return mSelectedColor; }
78 
84  void setSelectionColor( const QColor &color ) { mSelectedColor = color; }
85 
86  private:
87 
88  bool mIsSelected = false;
89 
90  QColor mSelectedColor;
91 
92 };
93 
94 
105 {
106 
107 #ifdef SIP_RUN
109  if ( sipCpp->type() == QLatin1String( "gooch" ) )
110  {
111  sipType = sipType_QgsGoochMaterialSettings;
112  }
113  else if ( sipCpp->type() == QLatin1String( "phong" ) )
114  {
115  sipType = sipType_QgsPhongMaterialSettings;
116  }
117  else if ( sipCpp->type() == "phongtextured" )
118  {
119  sipType = sipType_QgsPhongTexturedMaterialSettings;
120  }
121  else if ( sipCpp->type() == "simpleline" )
122  {
123  sipType = sipType_QgsSimpleLineMaterialSettings;
124  }
125  else
126  {
127  sipType = 0;
128  }
129  SIP_END
130 #endif
131 
132  public:
133 
134  virtual ~QgsAbstractMaterialSettings() = default;
135 
139  virtual QString type() const = 0;
140 
147 
149  virtual void readXml( const QDomElement &element, const QgsReadWriteContext &context ) = 0;
150 
152  virtual void writeXml( QDomElement &element, const QgsReadWriteContext &context ) const = 0;
153 
154 #ifndef SIP_RUN
155 
162  virtual Qt3DRender::QMaterial *toMaterial( QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context ) const = 0 SIP_FACTORY;
163 
167  virtual QMap<QString, QString> toExportParameters() const = 0;
168 
172  virtual void addParametersToEffect( Qt3DRender::QEffect *effect ) const = 0;
173 #endif
174 
175 };
176 
177 
178 #endif // QGSABSTRACTMATERIALSETTINGS_H
QgsAbstractMaterialSettings::type
virtual QString type() const =0
Returns the unique type name for the material.
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.
QgsMaterialContext::setSelectionColor
void setSelectionColor(const QColor &color)
Sets the color for representing materials in a selected state.
Definition: qgsabstractmaterialsettings.h:84
QgsAbstractMaterialSettings::readXml
virtual void readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads settings from a DOM element.
QgsAbstractMaterialSettings::~QgsAbstractMaterialSettings
virtual ~QgsAbstractMaterialSettings()=default
QgsMaterialContext::selectionColor
QColor selectionColor() const
Returns the color for representing materials in a selected state.
Definition: qgsabstractmaterialsettings.h:77
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsMaterialContext
3 Context settings for a material.
Definition: qgsabstractmaterialsettings.h:55
SIP_MONKEYPATCH_SCOPEENUM_UNNEST
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition: qgis_sip.h:257
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
QgsAbstractMaterialSettings
3 Abstract base class for material settings.
Definition: qgsabstractmaterialsettings.h:105
qgis_sip.h
QgsMaterialSettingsRenderingTechnique::Triangles
@ Triangles
Triangle based rendering (default)
QgsAbstractMaterialSettings::addParametersToEffect
virtual void addParametersToEffect(Qt3DRender::QEffect *effect) const =0
Adds parameters from the material to a destination effect.
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.
QgsMaterialContext::setIsSelected
void setIsSelected(bool isSelected)
Sets whether the material should represent a selected state.
Definition: qgsabstractmaterialsettings.h:70
QgsMaterialSettingsRenderingTechnique::Points
@ Points
Point based rendering, requires point data.
QgsAbstractMaterialSettings::clone
virtual QgsAbstractMaterialSettings * clone() const =0
Clones the material settings.
SIP_END
#define SIP_END
Definition: qgis_sip.h:194
QgsMaterialContext::isSelected
bool isSelected() const
Returns true if the material should represent a selected state.
Definition: qgsabstractmaterialsettings.h:63
SIP_ABSTRACT
#define SIP_ABSTRACT
Definition: qgis_sip.h:199