25using namespace Qt::StringLiterals;
36 auto result = std::make_unique<QgsMesh3DSymbol>();
38 result->mAltClamping = mAltClamping;
39 result->mHeight = mHeight;
40 result->mMaterialSettings.reset( mMaterialSettings->clone() );
41 result->mAddBackFaces = mAddBackFaces;
42 result->mCullingMode = mCullingMode;
43 result->mEnabled = mEnabled;
44 result->mSmoothedTriangles = mSmoothedTriangles;
45 result->mWireframeEnabled = mWireframeEnabled;
46 result->mWireframeLineWidth = mWireframeLineWidth;
47 result->mWireframeLineColor = mWireframeLineColor;
48 result->mLevelOfDetailIndex = mLevelOfDetailIndex;
49 result->mVerticalScale = mVerticalScale;
50 result->mVerticalDatasetGroupIndex = mVerticalDatasetGroupIndex;
51 result->mIsVerticalMagnitudeRelative = mIsVerticalMagnitudeRelative;
52 result->mRenderingStyle = mRenderingStyle;
53 result->mColorRampShader = mColorRampShader;
54 result->mSingleColor = mSingleColor;
55 result->mArrowsEnabled = mArrowsEnabled;
56 result->mArrowsSpacing = mArrowsSpacing;
57 result->mArrowsFixedSize = mArrowsFixedSize;
58 result->mArrowsColor = mArrowsColor;
59 result->mMaximumTextureSize = mMaximumTextureSize;
61 return result.release();
66 QDomDocument doc = elem.ownerDocument();
69 QDomElement elemDataProperties = doc.createElement( u
"data"_s );
71 elemDataProperties.setAttribute( u
"height"_s, mHeight );
72 elemDataProperties.setAttribute( u
"add-back-faces"_s, mAddBackFaces ? u
"1"_s : u
"0"_s );
73 elem.appendChild( elemDataProperties );
75 QDomElement elemMaterial = doc.createElement( u
"material"_s );
76 mMaterialSettings->writeXml( elemMaterial, context );
77 elem.appendChild( elemMaterial );
80 QDomElement elemAdvancedSettings = doc.createElement( u
"advanced-settings"_s );
81 elemAdvancedSettings.setAttribute( u
"renderer-3d-enabled"_s, mEnabled ? u
"1"_s : u
"0"_s );
83 elemAdvancedSettings.setAttribute( u
"smoothed-triangle"_s, mSmoothedTriangles ? u
"1"_s : u
"0"_s );
84 elemAdvancedSettings.setAttribute( u
"wireframe-enabled"_s, mWireframeEnabled ? u
"1"_s : u
"0"_s );
85 elemAdvancedSettings.setAttribute( u
"wireframe-line-width"_s, mWireframeLineWidth );
87 elemAdvancedSettings.setAttribute( u
"level-of-detail"_s, mLevelOfDetailIndex );
88 elemAdvancedSettings.setAttribute( u
"vertical-scale"_s, mVerticalScale );
89 elemAdvancedSettings.setAttribute( u
"vertical-group-index"_s, mVerticalDatasetGroupIndex );
90 elemAdvancedSettings.setAttribute( u
"vertical-relative"_s, mIsVerticalMagnitudeRelative ? u
"1"_s : u
"0"_s );
91 elemAdvancedSettings.setAttribute( u
"texture-type"_s,
static_cast<int>( mRenderingStyle ) );
92 elemAdvancedSettings.appendChild( mColorRampShader.writeXml( doc, context ) );
93 elemAdvancedSettings.setAttribute( u
"min-color-ramp-shader"_s, mColorRampShader.minimumValue() );
94 elemAdvancedSettings.setAttribute( u
"max-color-ramp-shader"_s, mColorRampShader.maximumValue() );
96 elemAdvancedSettings.setAttribute( u
"arrows-enabled"_s, mArrowsEnabled ? u
"1"_s : u
"0"_s );
97 elemAdvancedSettings.setAttribute( u
"arrows-spacing"_s, mArrowsSpacing );
98 elemAdvancedSettings.setAttribute( u
"arrows-fixed-size"_s, mArrowsFixedSize ? u
"1"_s : u
"0"_s );
99 elem.appendChild( elemAdvancedSettings );
101 QDomElement elemDDP = doc.createElement( u
"data-defined-properties"_s );
103 elem.appendChild( elemDDP );
109 const QDomElement elemDataProperties = elem.firstChildElement( u
"data"_s );
111 mHeight = elemDataProperties.attribute( u
"height"_s ).toFloat();
112 mAddBackFaces = elemDataProperties.attribute( u
"add-back-faces"_s ).toInt();
114 const QDomElement elemMaterial = elem.firstChildElement( u
"material"_s );
115 mMaterialSettings->readXml( elemMaterial, context );
118 const QDomElement elemAdvancedSettings = elem.firstChildElement( u
"advanced-settings"_s );
119 mEnabled = elemAdvancedSettings.attribute( u
"renderer-3d-enabled"_s ).toInt();
121 mSmoothedTriangles = elemAdvancedSettings.attribute( u
"smoothed-triangle"_s ).toInt();
122 mWireframeEnabled = elemAdvancedSettings.attribute( u
"wireframe-enabled"_s ).toInt();
123 mWireframeLineWidth = elemAdvancedSettings.attribute( u
"wireframe-line-width"_s ).toDouble();
125 mLevelOfDetailIndex = elemAdvancedSettings.attribute( u
"level-of-detail"_s ).toInt();
126 mVerticalScale = elemAdvancedSettings.attribute(
"vertical-scale" ).toDouble();
127 mVerticalDatasetGroupIndex = elemAdvancedSettings.attribute(
"vertical-group-index" ).toInt();
128 mIsVerticalMagnitudeRelative = elemAdvancedSettings.attribute(
"vertical-relative" ).toInt();
130 mColorRampShader.readXml( elemAdvancedSettings.firstChildElement(
"colorrampshader" ), context );
131 mColorRampShader.setMinimumValue( elemAdvancedSettings.attribute( u
"min-color-ramp-shader"_s ).toDouble() );
132 mColorRampShader.setMaximumValue( elemAdvancedSettings.attribute( u
"max-color-ramp-shader"_s ).toDouble() );
134 mArrowsEnabled = elemAdvancedSettings.attribute( u
"arrows-enabled"_s ).toInt();
135 if ( elemAdvancedSettings.hasAttribute( u
"arrows-spacing"_s ) )
136 mArrowsSpacing = elemAdvancedSettings.attribute( u
"arrows-spacing"_s ).toDouble();
137 mArrowsFixedSize = elemAdvancedSettings.attribute( u
"arrows-fixed-size"_s ).toInt();
138 const QDomElement elemDDP = elem.firstChildElement( u
"data-defined-properties"_s );
139 if ( !elemDDP.isNull() )
145 return mSmoothedTriangles;
150 mSmoothedTriangles = smoothTriangles;
155 return mWireframeEnabled;
165 return mWireframeLineWidth;
175 return mWireframeLineColor;
185 return mVerticalScale;
195 return mColorRampShader;
210 mSingleColor = color;
215 return mRenderingStyle;
220 mRenderingStyle = coloringType;
225 return mVerticalDatasetGroupIndex;
235 return mIsVerticalMagnitudeRelative;
240 mIsVerticalMagnitudeRelative = isVerticalScaleIsRelative;
245 return mArrowsEnabled;
250 mArrowsEnabled = vectorEnabled;
255 return mArrowsSpacing;
265 return mMaximumTextureSize;
275 return mArrowsFixedSize;
280 mArrowsFixedSize = arrowsFixeSize;
285 return mLevelOfDetailIndex;
290 mLevelOfDetailIndex = lod;
295 if ( mAltClamping != other.mAltClamping
296 || mHeight != other.mHeight
297 || mAddBackFaces != other.mAddBackFaces
298 || mEnabled != other.mEnabled
299 || mCullingMode != other.mCullingMode
300 || mSmoothedTriangles != other.mSmoothedTriangles
301 || mWireframeEnabled != other.mWireframeEnabled
302 || !
qgsDoubleNear( mWireframeLineWidth, other.mWireframeLineWidth )
303 || mWireframeLineColor != other.mWireframeLineColor
304 || mLevelOfDetailIndex != other.mLevelOfDetailIndex
306 || mVerticalDatasetGroupIndex != other.mVerticalDatasetGroupIndex
307 || mIsVerticalMagnitudeRelative != other.mIsVerticalMagnitudeRelative
308 || mRenderingStyle != other.mRenderingStyle
309 || mColorRampShader != other.mColorRampShader
310 || mSingleColor != other.mSingleColor
311 || mArrowsEnabled != other.mArrowsEnabled
313 || mArrowsFixedSize != other.mArrowsFixedSize
314 || mArrowsColor != other.mArrowsColor
315 || mMaximumTextureSize != other.mMaximumTextureSize )
330 return !( *
this == other );
355 return mMaterialSettings.get();
CullingMode
Triangle culling mode.
static Qgs3DTypes::CullingMode cullingModeFromString(const QString &str)
Converts a string to a value from CullingMode enum.
static Qgis::AltitudeClamping altClampingFromString(const QString &str)
Converts a string to a value from AltitudeClamping enum.
static QString cullingModeToString(Qgs3DTypes::CullingMode mode)
Converts a value from CullingMode enum to a string.
static QString altClampingToString(Qgis::AltitudeClamping altClamp)
Converts a value from AltitudeClamping enum to a string.
virtual void copyBaseSettings(QgsAbstract3DSymbol *destination) const
Copies base class settings from this object to a destination object.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
QgsPropertyCollection mDataDefinedProperties
Abstract base class for material settings.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
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.
double arrowsSpacing() const
Returns the arrow spacing.
bool wireframeEnabled() const
Returns if the mesh wireframe.
void setWireframeLineColor(const QColor &wireframeLineColor)
Sets wireframe line color.
bool isVerticalMagnitudeRelative() const
Returns if the vertical component of the mesh is relative to the mesh vertices Z value.
void setWireframeEnabled(bool wireframeEnabled)
Sets if the mesh wireframe.
bool smoothedTriangles() const
Returns if mesh triangle are smoothed.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes symbol configuration to the given DOM element.
QgsAbstractMaterialSettings * materialSettings() const
Returns material settings used for shading of the symbol.
void setWireframeLineWidth(double wireframeLineWidth)
Sets wireframe line width.
QColor wireframeLineColor() const
Returns wireframe line color.
bool arrowsEnabled() const
Returns if arrows are enabled for 3D rendering.
void setIsVerticalMagnitudeRelative(bool isVerticalMagnitudeRelative)
Sets if the vertical component of the mesh is relative to the mesh vertices Z value.
void setMaterialSettings(QgsAbstractMaterialSettings *materialSettings SIP_TRANSFER)
Sets the material settings used for shading of the symbol.
void setLevelOfDetailIndex(int lod)
Returns the index of the level of detail of the mesh that is the position of the simplified mesh that...
void setArrowsSpacing(double arrowsSpacing)
Sets the arrow spacing.
void setCullingMode(const Qgs3DTypes::CullingMode &mode)
Sets culling mode.
double verticalScale() const
Returns mesh vertical scale.
void setVerticalDatasetGroupIndex(int verticalDatasetGroupIndex)
Sets the index of the dataset group that will be used to render the vertical component of the 3D mesh...
bool operator==(const QgsMesh3DSymbol &other) const
QgsMesh3DSymbol()
Constructor for QgsMesh3DSymbol.
void setArrowsFixedSize(bool arrowsFixedSize)
Sets if the arrow size is fixed.
Qgs3DTypes::CullingMode cullingMode() const
Returns culling mode.
int levelOfDetailIndex() const
Returns the index of the level of detail of the mesh that is the position of the simplified mesh that...
void setArrowsEnabled(bool arrowsEnabled)
Sets if arrows are enabled for 3D rendering.
void setVerticalScale(double verticalScale)
Sets mesh vertical scale.
QgsColorRampShader colorRampShader() const
Returns the color ramp shader used to render the color.
QgsMesh3DSymbol::RenderingStyle renderingStyle() const
Returns the rendering style.
void setSmoothedTriangles(bool smoothTriangles)
Sets if the mesh triangles have to been smoothed.
void setColorRampShader(const QgsColorRampShader &colorRampShader)
Sets the color ramp shader used to render the color.
bool arrowsFixedSize() const
Returns if the arrow size is fixed.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads symbol configuration from the given DOM element.
void setSingleMeshColor(const QColor &singleMeshColor)
Sets the single color.
bool operator!=(const QgsMesh3DSymbol &other) const
QColor singleMeshColor() const
Returns the single color.
RenderingStyle
How to render the color of the mesh.
int verticalDatasetGroupIndex() const
Returns the index of the dataset group that will be used to render the vertical component of the 3D m...
void setRenderingStyle(const QgsMesh3DSymbol::RenderingStyle &textureType)
Sets the rendering style.
~QgsMesh3DSymbol() override
void setMaximumTextureSize(int maximumTextureSize)
Sets the maximum texture size supported by the hardware Used to store the GL_MAX_TEXTURE_SIZE value t...
bool isEnabled() const
Returns if the 3d rendering is enabled.
double wireframeLineWidth() const
Returns wireframe line width.
void setEnabled(bool enabled)
Sets if the 3d rendering is enabled.
QgsMesh3DSymbol * clone() const override SIP_FACTORY
Returns a new instance of the symbol with the same settings.
int maximumTextureSize() const
Returns the maximum texture size supported by the hardware Used to store the GL_MAX_TEXTURE_SIZE valu...
Basic shading material used for rendering based on the Phong shading model with three color component...
A container for the context for various read/write operations on objects.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).