20#include <Qt3DRender/QTexture>
21#include <Qt3DRender/QParameter>
22#include <Qt3DRender/QEffect>
25#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
26#include <Qt3DRender/QAttribute>
27#include <Qt3DRender/QBuffer>
28#include <Qt3DRender/QGeometry>
34#include <Qt3DCore/QAttribute>
35#include <Qt3DCore/QBuffer>
36#include <Qt3DCore/QGeometry>
45 return QStringLiteral(
"simpleline" );
104 QgsLineMaterial *mat =
new QgsLineMaterial;
107 mat->setLineColor( mAmbient );
114 mat->setUseVertexColors(
false );
124 QMap<QString, QString> parameters;
125 parameters[ QStringLiteral(
"Ka" ) ] = QStringLiteral(
"%1 %2 %3" ).arg( mAmbient.redF() ).arg( mAmbient.greenF() ).arg( mAmbient.blueF() );
132 Qt3DRender::QParameter *ambientParameter =
new Qt3DRender::QParameter( QStringLiteral(
"ambientColor" ),
ambient );
133 effect->addParameter( ambientParameter );
141 array.resize(
sizeof(
unsigned char ) * 3 );
142 unsigned char *fptr =
reinterpret_cast<unsigned char *
>( array.data() );
144 *fptr++ =
static_cast<unsigned char>(
ambient.red() );
145 *fptr++ =
static_cast<unsigned char>(
ambient.green() );
146 *fptr++ =
static_cast<unsigned char>(
ambient.blue() );
155 colorAttribute->setName( QStringLiteral(
"dataDefinedColor" ) );
156 colorAttribute->setVertexBaseType( Qt3DQAttribute::UnsignedByte );
157 colorAttribute->setVertexSize( 3 );
158 colorAttribute->setAttributeType( Qt3DQAttribute::VertexAttribute );
159 colorAttribute->setBuffer( dataBuffer );
160 colorAttribute->setByteStride( 3 *
sizeof(
unsigned char ) );
161 colorAttribute->setByteOffset( 0 );
162 colorAttribute->setCount( vertexCount );
163 geometry->addAttribute( colorAttribute );
165 dataBuffer->setData( data );
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.
@ Ambient
Ambient color (phong material)
QgsPropertyCollection dataDefinedProperties() const
Returns the symbol material property collection, used for data defined overrides.
QColor valueAsColor(int key, const QgsExpressionContext &context, const QColor &defaultColor=QColor(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a color.
static QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
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.
bool isSelected() const
Returns true if the material should represent a selected state.
The class is used as a container of context for various read/write operations on other objects.
QgsSimpleLineMaterialSettings * clone() const override
Clones the material settings.
void applyDataDefinedToGeometry(Qt3DCore::QGeometry *geometry, int vertexCount, const QByteArray &data) const override
Applies the data defined bytes, dataDefinedBytes, on the geometry by filling a specific vertex buffer...
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes settings to a DOM element.
static bool supportsTechnique(QgsMaterialSettingsRenderingTechnique technique)
Returns true if the specified technique is supported by the material.
static QgsAbstractMaterialSettings * create()
Returns a new instance of QgsSimpleLineMaterialSettings.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads settings from a DOM element.
QByteArray dataDefinedVertexColorsAsByte(const QgsExpressionContext &expressionContext) const override
Returns byte array corresponding to the data defined colors depending of the expressionContext,...
QgsSimpleLineMaterialSettings()=default
QColor ambient() const
Returns the ambient color component.
QString type() const override
Returns the unique type name for the material.
QMap< QString, QString > toExportParameters() const override
Returns the parameters to be exported to .mtl file.
QgsMaterial * toMaterial(QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context) const override
Creates a new QgsMaterial object representing the material settings.
void addParametersToEffect(Qt3DRender::QEffect *effect, const QgsMaterialContext &materialContext) const override
Adds parameters from the material to a destination effect.
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)
Qt3DCore::QAttribute Qt3DQAttribute
Qt3DCore::QBuffer Qt3DQBuffer
Qt3DCore::QGeometry Qt3DQGeometry
Qt3DCore::QAttribute Qt3DQAttribute
Qt3DCore::QBuffer Qt3DQBuffer
Qt3DCore::QGeometry Qt3DQGeometry