31 std::unique_ptr< QgsMesh3DSymbol > result = std::make_unique< QgsMesh3DSymbol >();
33 result->mAltClamping = mAltClamping;
34 result->mHeight = mHeight;
35 result->mMaterial.reset( mMaterial->clone() );
36 result->mAddBackFaces = mAddBackFaces;
37 result->mEnabled = mEnabled;
38 result->mSmoothedTriangles = mSmoothedTriangles;
39 result->mWireframeEnabled = mWireframeEnabled;
40 result->mWireframeLineWidth = mWireframeLineWidth;
41 result->mWireframeLineColor = mWireframeLineColor;
42 result->mLevelOfDetailIndex = mLevelOfDetailIndex;
43 result->mVerticalScale = mVerticalScale;
44 result->mVerticalDatasetGroupIndex = mVerticalDatasetGroupIndex;
45 result->mIsVerticalMagnitudeRelative = mIsVerticalMagnitudeRelative;
46 result->mRenderingStyle = mRenderingStyle;
47 result->mColorRampShader = mColorRampShader;
48 result->mSingleColor = mSingleColor;
49 result->mArrowsEnabled = mArrowsEnabled;
50 result->mArrowsSpacing = mArrowsSpacing;
51 result->mArrowsFixedSize = mArrowsFixedSize;
52 result->mArrowsColor = mArrowsColor;
53 result->mMaximumTextureSize = mMaximumTextureSize;
55 return result.release();
60 QDomDocument doc = elem.ownerDocument();
63 QDomElement elemDataProperties = doc.createElement( QStringLiteral(
"data" ) );
65 elemDataProperties.setAttribute( QStringLiteral(
"height" ), mHeight );
66 elemDataProperties.setAttribute( QStringLiteral(
"add-back-faces" ), mAddBackFaces ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
67 elem.appendChild( elemDataProperties );
69 QDomElement elemMaterial = doc.createElement( QStringLiteral(
"material" ) );
70 mMaterial->writeXml( elemMaterial, context );
71 elem.appendChild( elemMaterial );
74 QDomElement elemAdvancedSettings = doc.createElement( QStringLiteral(
"advanced-settings" ) );
75 elemAdvancedSettings.setAttribute( QStringLiteral(
"renderer-3d-enabled" ), mEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
76 elemAdvancedSettings.setAttribute( QStringLiteral(
"smoothed-triangle" ), mSmoothedTriangles ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
77 elemAdvancedSettings.setAttribute( QStringLiteral(
"wireframe-enabled" ), mWireframeEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
78 elemAdvancedSettings.setAttribute( QStringLiteral(
"wireframe-line-width" ), mWireframeLineWidth );
80 elemAdvancedSettings.setAttribute( QStringLiteral(
"level-of-detail" ), mLevelOfDetailIndex );
81 elemAdvancedSettings.setAttribute( QStringLiteral(
"vertical-scale" ), mVerticalScale );
82 elemAdvancedSettings.setAttribute( QStringLiteral(
"vertical-group-index" ), mVerticalDatasetGroupIndex );
83 elemAdvancedSettings.setAttribute( QStringLiteral(
"vertical-relative" ), mIsVerticalMagnitudeRelative ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
84 elemAdvancedSettings.setAttribute( QStringLiteral(
"texture-type" ), mRenderingStyle );
85 elemAdvancedSettings.appendChild( mColorRampShader.
writeXml( doc, context ) );
86 elemAdvancedSettings.setAttribute( QStringLiteral(
"min-color-ramp-shader" ), mColorRampShader.
minimumValue() );
87 elemAdvancedSettings.setAttribute( QStringLiteral(
"max-color-ramp-shader" ), mColorRampShader.
maximumValue() );
89 elemAdvancedSettings.setAttribute( QStringLiteral(
"arrows-enabled" ), mArrowsEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
90 elemAdvancedSettings.setAttribute( QStringLiteral(
"arrows-spacing" ), mArrowsSpacing );
91 elemAdvancedSettings.setAttribute( QStringLiteral(
"arrows-fixed-size" ), mArrowsFixedSize ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
92 elem.appendChild( elemAdvancedSettings );
94 QDomElement elemDDP = doc.createElement( QStringLiteral(
"data-defined-properties" ) );
96 elem.appendChild( elemDDP );
102 const QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral(
"data" ) );
104 mHeight = elemDataProperties.attribute( QStringLiteral(
"height" ) ).toFloat();
105 mAddBackFaces = elemDataProperties.attribute( QStringLiteral(
"add-back-faces" ) ).toInt();
107 const QDomElement elemMaterial = elem.firstChildElement( QStringLiteral(
"material" ) );
108 mMaterial->readXml( elemMaterial, context );
111 const QDomElement elemAdvancedSettings = elem.firstChildElement( QStringLiteral(
"advanced-settings" ) );
112 mEnabled = elemAdvancedSettings.attribute( QStringLiteral(
"renderer-3d-enabled" ) ).toInt();
113 mSmoothedTriangles = elemAdvancedSettings.attribute( QStringLiteral(
"smoothed-triangle" ) ).toInt();
114 mWireframeEnabled = elemAdvancedSettings.attribute( QStringLiteral(
"wireframe-enabled" ) ).toInt();
115 mWireframeLineWidth = elemAdvancedSettings.attribute( QStringLiteral(
"wireframe-line-width" ) ).toDouble();
117 mLevelOfDetailIndex = elemAdvancedSettings.attribute( QStringLiteral(
"level-of-detail" ) ).toInt();
118 mVerticalScale = elemAdvancedSettings.attribute(
"vertical-scale" ).toDouble();
119 mVerticalDatasetGroupIndex = elemAdvancedSettings.attribute(
"vertical-group-index" ).toInt();
120 mIsVerticalMagnitudeRelative = elemAdvancedSettings.attribute(
"vertical-relative" ).toInt();
122 mColorRampShader.
readXml( elemAdvancedSettings.firstChildElement(
"colorrampshader" ), context );
123 mColorRampShader.
setMinimumValue( elemAdvancedSettings.attribute( QStringLiteral(
"min-color-ramp-shader" ) ).toDouble() );
124 mColorRampShader.
setMaximumValue( elemAdvancedSettings.attribute( QStringLiteral(
"max-color-ramp-shader" ) ).toDouble() );
126 mArrowsEnabled = elemAdvancedSettings.attribute( QStringLiteral(
"arrows-enabled" ) ).toInt();
127 if ( elemAdvancedSettings.hasAttribute( QStringLiteral(
"arrows-spacing" ) ) )
128 mArrowsSpacing = elemAdvancedSettings.attribute( QStringLiteral(
"arrows-spacing" ) ).toDouble();
129 mArrowsFixedSize = elemAdvancedSettings.attribute( QStringLiteral(
"arrows-fixed-size" ) ).toInt();
130 const QDomElement elemDDP = elem.firstChildElement( QStringLiteral(
"data-defined-properties" ) );
131 if ( !elemDDP.isNull() )
137 return mSmoothedTriangles;
142 mSmoothedTriangles = smoothTriangles;
147 return mWireframeEnabled;
157 return mWireframeLineWidth;
167 return mWireframeLineColor;
177 return mVerticalScale;
187 return mColorRampShader;
202 mSingleColor = color;
207 return mRenderingStyle;
212 mRenderingStyle = coloringType;
217 return mVerticalDatasetGroupIndex;
227 return mIsVerticalMagnitudeRelative;
232 mIsVerticalMagnitudeRelative = isVerticalScaleIsRelative;
237 return mArrowsEnabled;
242 mArrowsEnabled = vectorEnabled;
247 return mArrowsSpacing;
257 return mMaximumTextureSize;
267 return mArrowsFixedSize;
272 mArrowsFixedSize = arrowsFixeSize;
277 return mLevelOfDetailIndex;
282 mLevelOfDetailIndex = lod;
298 return mMaterial.get();