@@ -17,8 +17,10 @@ email : ersts@amnh.org
17
17
***************************************************************************/
18
18
19
19
#include " qgslogger.h"
20
-
20
+ # include " qgscolorrampshader.h "
21
21
#include " qgsrastershader.h"
22
+ #include < QDomDocument>
23
+ #include < QDomElement>
22
24
23
25
QgsRasterShader::QgsRasterShader ( double theMinimumValue, double theMaximumValue )
24
26
{
@@ -124,3 +126,32 @@ void QgsRasterShader::setMinimumValue( double theValue )
124
126
mRasterShaderFunction ->setMinimumValue ( theValue );
125
127
}
126
128
}
129
+
130
+ void QgsRasterShader::writeXML ( QDomDocument& doc, QDomElement& parent ) const
131
+ {
132
+ if ( parent.isNull () || !mRasterShaderFunction )
133
+ {
134
+ return ;
135
+ }
136
+
137
+ QDomElement rasterShaderElem = doc.createElement ( " rastershader" );
138
+ QgsColorRampShader* colorRampShader = dynamic_cast <QgsColorRampShader*>( mRasterShaderFunction );
139
+ if ( colorRampShader )
140
+ {
141
+ QDomElement colorRampShaderElem = doc.createElement ( " colorrampshader" );
142
+ colorRampShaderElem.setAttribute ( " colorRampType" , colorRampShader->colorRampTypeAsQString () );
143
+ // items
144
+ QList<QgsColorRampShader::ColorRampItem> itemList = colorRampShader->colorRampItemList ();
145
+ QList<QgsColorRampShader::ColorRampItem>::const_iterator itemIt = itemList.constBegin ();
146
+ for (; itemIt != itemList.constEnd (); ++itemIt )
147
+ {
148
+ QDomElement itemElem = doc.createElement ( " item" );
149
+ itemElem.setAttribute ( " label" , itemIt->label );
150
+ itemElem.setAttribute ( " value" , itemIt->value );
151
+ itemElem.setAttribute ( " color" , itemIt->color .name () );
152
+ colorRampShaderElem.appendChild ( itemElem );
153
+ }
154
+ rasterShaderElem.appendChild ( colorRampShaderElem );
155
+ }
156
+ parent.appendChild ( rasterShaderElem );
157
+ }
0 commit comments