25using namespace Qt::StringLiterals;
35 auto result = std::make_unique<QgsMesh3DSymbol>();
37 result->mAltClamping = mAltClamping;
38 result->mHeight = mHeight;
39 result->mMaterialSettings.reset( mMaterialSettings->clone() );
40 result->mAddBackFaces = mAddBackFaces;
41 result->mCullingMode = mCullingMode;
42 result->mEnabled = mEnabled;
43 result->mSmoothedTriangles = mSmoothedTriangles;
44 result->mWireframeEnabled = mWireframeEnabled;
45 result->mWireframeLineWidth = mWireframeLineWidth;
46 result->mWireframeLineColor = mWireframeLineColor;
47 result->mLevelOfDetailIndex = mLevelOfDetailIndex;
48 result->mVerticalScale = mVerticalScale;
49 result->mVerticalDatasetGroupIndex = mVerticalDatasetGroupIndex;
50 result->mIsVerticalMagnitudeRelative = mIsVerticalMagnitudeRelative;
51 result->mRenderingStyle = mRenderingStyle;
52 result->mColorRampShader = mColorRampShader;
53 result->mSingleColor = mSingleColor;
54 result->mArrowsEnabled = mArrowsEnabled;
55 result->mArrowsSpacing = mArrowsSpacing;
56 result->mArrowsFixedSize = mArrowsFixedSize;
57 result->mArrowsColor = mArrowsColor;
58 result->mMaximumTextureSize = mMaximumTextureSize;
60 return result.release();
65 QDomDocument doc = elem.ownerDocument();
68 QDomElement elemDataProperties = doc.createElement( u
"data"_s );
70 elemDataProperties.setAttribute( u
"height"_s, mHeight );
71 elemDataProperties.setAttribute( u
"add-back-faces"_s, mAddBackFaces ? u
"1"_s : u
"0"_s );
72 elem.appendChild( elemDataProperties );
74 QDomElement elemMaterial = doc.createElement( u
"material"_s );
75 mMaterialSettings->writeXml( elemMaterial, context );
76 elem.appendChild( elemMaterial );
79 QDomElement elemAdvancedSettings = doc.createElement( u
"advanced-settings"_s );
80 elemAdvancedSettings.setAttribute( u
"renderer-3d-enabled"_s, mEnabled ? u
"1"_s : u
"0"_s );
82 elemAdvancedSettings.setAttribute( u
"smoothed-triangle"_s, mSmoothedTriangles ? u
"1"_s : u
"0"_s );
83 elemAdvancedSettings.setAttribute( u
"wireframe-enabled"_s, mWireframeEnabled ? u
"1"_s : u
"0"_s );
84 elemAdvancedSettings.setAttribute( u
"wireframe-line-width"_s, mWireframeLineWidth );
86 elemAdvancedSettings.setAttribute( u
"level-of-detail"_s, mLevelOfDetailIndex );
87 elemAdvancedSettings.setAttribute( u
"vertical-scale"_s, mVerticalScale );
88 elemAdvancedSettings.setAttribute( u
"vertical-group-index"_s, mVerticalDatasetGroupIndex );
89 elemAdvancedSettings.setAttribute( u
"vertical-relative"_s, mIsVerticalMagnitudeRelative ? u
"1"_s : u
"0"_s );
90 elemAdvancedSettings.setAttribute( u
"texture-type"_s,
static_cast<int>( mRenderingStyle ) );
91 elemAdvancedSettings.appendChild( mColorRampShader.writeXml( doc, context ) );
92 elemAdvancedSettings.setAttribute( u
"min-color-ramp-shader"_s, mColorRampShader.minimumValue() );
93 elemAdvancedSettings.setAttribute( u
"max-color-ramp-shader"_s, mColorRampShader.maximumValue() );
95 elemAdvancedSettings.setAttribute( u
"arrows-enabled"_s, mArrowsEnabled ? u
"1"_s : u
"0"_s );
96 elemAdvancedSettings.setAttribute( u
"arrows-spacing"_s, mArrowsSpacing );
97 elemAdvancedSettings.setAttribute( u
"arrows-fixed-size"_s, mArrowsFixedSize ? u
"1"_s : u
"0"_s );
98 elem.appendChild( elemAdvancedSettings );
100 QDomElement elemDDP = doc.createElement( u
"data-defined-properties"_s );
102 elem.appendChild( elemDDP );
108 const QDomElement elemDataProperties = elem.firstChildElement( u
"data"_s );
110 mHeight = elemDataProperties.attribute( u
"height"_s ).toFloat();
111 mAddBackFaces = elemDataProperties.attribute( u
"add-back-faces"_s ).toInt();
113 const QDomElement elemMaterial = elem.firstChildElement( u
"material"_s );
114 mMaterialSettings->readXml( elemMaterial, context );
117 const QDomElement elemAdvancedSettings = elem.firstChildElement( u
"advanced-settings"_s );
118 mEnabled = elemAdvancedSettings.attribute( u
"renderer-3d-enabled"_s ).toInt();
120 mSmoothedTriangles = elemAdvancedSettings.attribute( u
"smoothed-triangle"_s ).toInt();
121 mWireframeEnabled = elemAdvancedSettings.attribute( u
"wireframe-enabled"_s ).toInt();
122 mWireframeLineWidth = elemAdvancedSettings.attribute( u
"wireframe-line-width"_s ).toDouble();
124 mLevelOfDetailIndex = elemAdvancedSettings.attribute( u
"level-of-detail"_s ).toInt();
125 mVerticalScale = elemAdvancedSettings.attribute(
"vertical-scale" ).toDouble();
126 mVerticalDatasetGroupIndex = elemAdvancedSettings.attribute(
"vertical-group-index" ).toInt();
127 mIsVerticalMagnitudeRelative = elemAdvancedSettings.attribute(
"vertical-relative" ).toInt();
129 mColorRampShader.readXml( elemAdvancedSettings.firstChildElement(
"colorrampshader" ), context );
130 mColorRampShader.setMinimumValue( elemAdvancedSettings.attribute( u
"min-color-ramp-shader"_s ).toDouble() );
131 mColorRampShader.setMaximumValue( elemAdvancedSettings.attribute( u
"max-color-ramp-shader"_s ).toDouble() );
133 mArrowsEnabled = elemAdvancedSettings.attribute( u
"arrows-enabled"_s ).toInt();
134 if ( elemAdvancedSettings.hasAttribute( u
"arrows-spacing"_s ) )
135 mArrowsSpacing = elemAdvancedSettings.attribute( u
"arrows-spacing"_s ).toDouble();
136 mArrowsFixedSize = elemAdvancedSettings.attribute( u
"arrows-fixed-size"_s ).toInt();
137 const QDomElement elemDDP = elem.firstChildElement( u
"data-defined-properties"_s );
138 if ( !elemDDP.isNull() )
144 return mSmoothedTriangles;
149 mSmoothedTriangles = smoothTriangles;
154 return mWireframeEnabled;
164 return mWireframeLineWidth;
174 return mWireframeLineColor;
184 return mVerticalScale;
194 return mColorRampShader;
209 mSingleColor = color;
214 return mRenderingStyle;
219 mRenderingStyle = coloringType;
224 return mVerticalDatasetGroupIndex;
234 return mIsVerticalMagnitudeRelative;
239 mIsVerticalMagnitudeRelative = isVerticalScaleIsRelative;
244 return mArrowsEnabled;
249 mArrowsEnabled = vectorEnabled;
254 return mArrowsSpacing;
264 return mMaximumTextureSize;
274 return mArrowsFixedSize;
279 mArrowsFixedSize = arrowsFixeSize;
284 return mLevelOfDetailIndex;
289 mLevelOfDetailIndex = lod;
294 if ( mAltClamping != other.mAltClamping
295 || mHeight != other.mHeight
296 || mAddBackFaces != other.mAddBackFaces
297 || mEnabled != other.mEnabled
298 || mCullingMode != other.mCullingMode
299 || mSmoothedTriangles != other.mSmoothedTriangles
300 || mWireframeEnabled != other.mWireframeEnabled
301 || !
qgsDoubleNear( mWireframeLineWidth, other.mWireframeLineWidth )
302 || mWireframeLineColor != other.mWireframeLineColor
303 || mLevelOfDetailIndex != other.mLevelOfDetailIndex
305 || mVerticalDatasetGroupIndex != other.mVerticalDatasetGroupIndex
306 || mIsVerticalMagnitudeRelative != other.mIsVerticalMagnitudeRelative
307 || mRenderingStyle != other.mRenderingStyle
308 || mColorRampShader != other.mColorRampShader
309 || mSingleColor != other.mSingleColor
310 || mArrowsEnabled != other.mArrowsEnabled
312 || mArrowsFixedSize != other.mArrowsFixedSize
313 || mArrowsColor != other.mArrowsColor
314 || mMaximumTextureSize != other.mMaximumTextureSize )
329 return !( *
this == other );
354 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).