QGIS API Documentation 3.41.0-Master (181b2f43d8e)
Loading...
Searching...
No Matches
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>
24#include "qgsmaterial.h"
25
26class QDomElement;
28class QgsLineMaterial;
30
31#ifndef SIP_RUN
32#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
33namespace Qt3DRender
34{
35 class QGeometry;
36}
37#else
38namespace Qt3DCore
39{
40 class QGeometry;
41}
42#endif
43#endif //SIP_RUN
44
60
61
71class _3D_EXPORT QgsMaterialContext
72{
73 public:
74
80 bool isSelected() const { return mIsSelected; }
81
87 void setIsSelected( bool isSelected ) { mIsSelected = isSelected; }
88
94 QColor selectionColor() const { return mSelectedColor; }
95
101 void setSelectionColor( const QColor &color ) { mSelectedColor = color; }
102
103 private:
104
105 bool mIsSelected = false;
106
107 QColor mSelectedColor;
108
109};
110
111
121{
122
123#ifdef SIP_RUN
125 if ( sipCpp->type() == QLatin1String( "gooch" ) )
126 {
127 sipType = sipType_QgsGoochMaterialSettings;
128 }
129 else if ( sipCpp->type() == QLatin1String( "phong" ) )
130 {
131 sipType = sipType_QgsPhongMaterialSettings;
132 }
133 else if ( sipCpp->type() == "phongtextured" )
134 {
135 sipType = sipType_QgsPhongTexturedMaterialSettings;
136 }
137 else if ( sipCpp->type() == "simpleline" )
138 {
139 sipType = sipType_QgsSimpleLineMaterialSettings;
140 }
141 else if ( sipCpp->type() == "null" )
142 {
143 sipType = sipType_QgsNullMaterialSettings;
144 }
145 else
146 {
147 sipType = 0;
148 }
149 SIP_END
150#endif
151
152 public:
153
154 virtual ~QgsAbstractMaterialSettings() = default;
155
159 virtual QString type() const = 0;
160
167
169 virtual void readXml( const QDomElement &element, const QgsReadWriteContext & );
170
172 virtual void writeXml( QDomElement &element, const QgsReadWriteContext & ) const;
173
179 virtual bool equals( const QgsAbstractMaterialSettings *other ) const = 0;
180
181#ifndef SIP_RUN
182
190
194 virtual QMap<QString, QString> toExportParameters() const = 0;
195
199 virtual void addParametersToEffect( Qt3DRender::QEffect *effect, const QgsMaterialContext &materialContext ) const = 0;
200
201 // *INDENT-OFF*
204 {
205 Diffuse,
206 Ambient,
207 Warm,
208 Cool,
209 Specular
210 };
211 // *INDENT-ON*
212
217 void setDataDefinedProperties( const QgsPropertyCollection &collection );
218
223 QgsPropertyCollection dataDefinedProperties() const;
224
229 const QgsPropertiesDefinition &propertyDefinitions() const;
230
235#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
236 virtual void applyDataDefinedToGeometry( Qt3DRender::QGeometry *geometry, int vertexCount, const QByteArray &dataDefinedBytes ) const;
237#else
238 virtual void applyDataDefinedToGeometry( Qt3DCore::QGeometry *geometry, int vertexCount, const QByteArray &dataDefinedBytes ) const;
239#endif
240
247 virtual QByteArray dataDefinedVertexColorsAsByte( const QgsExpressionContext &expressionContext ) const;
248
253 virtual int dataDefinedByteStride() const {return 0;}
254#endif
255
256 private:
257 QgsPropertyCollection mDataDefinedProperties;
258 static QgsPropertiesDefinition sPropertyDefinitions;
259 void initPropertyDefinitions() const;
260};
261
262
263#endif // QGSABSTRACTMATERIALSETTINGS_H
virtual bool equals(const QgsAbstractMaterialSettings *other) const =0
Returns true if this settings exactly matches an other settings.
virtual QMap< QString, QString > toExportParameters() const =0
Returns the parameters to be exported to .mtl file.
virtual QgsAbstractMaterialSettings * clone() const =0
Clones the material settings.
virtual int dataDefinedByteStride() const
Returns byte stride of the data defined colors,used to fill the vertex colors data defined buffer for...
virtual void addParametersToEffect(Qt3DRender::QEffect *effect, const QgsMaterialContext &materialContext) const =0
Adds parameters from the material to a destination effect.
virtual ~QgsAbstractMaterialSettings()=default
virtual QString type() const =0
Returns the unique type name for the material.
virtual QgsMaterial * toMaterial(QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context) const =0
Creates a new QgsMaterial object representing the material settings.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QColor selectionColor() const
Returns the color for representing materials in a selected state.
void setIsSelected(bool isSelected)
Sets whether the material should represent a selected state.
void setSelectionColor(const QColor &color)
Sets the color for representing materials in a selected state.
bool isSelected() const
Returns true if the material should represent a selected state.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
The class is used as a container of context for various read/write operations on other objects.
QgsMaterialSettingsRenderingTechnique
Material rendering techniques 3.
@ Points
Point based rendering, requires point data.
@ Triangles
Triangle based rendering (default)
@ TrianglesFromModel
Triangle based rendering, using a model object source.
@ Lines
Line based rendering, requires line data.
@ TrianglesDataDefined
Triangle based rendering with possibility of datadefined color.
@ InstancedPoints
Instanced based rendering, requiring triangles and point data.
@ TrianglesWithFixedTexture
Triangle based rendering, using a fixed, non-user-configurable texture (e.g. for terrain rendering)
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:191
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:271
#define SIP_ABSTRACT
Definition qgis_sip.h:213
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_END
Definition qgis_sip.h:208
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.