22 #include <QDomDocument>
23 #include <QDomElement>
49 bool QgsRasterShader::shade(
double theValue,
int* theReturnRedValue,
int* theReturnGreenValue,
int* theReturnBlueValue ,
int *theReturnAlpha )
72 bool QgsRasterShader::shade(
double theRedValue,
double theGreenValue,
double theBlueValue,
double theAlphaValue,
int* theReturnRedValue,
int* theReturnGreenValue,
int* theReturnBlueValue,
int* theReturnAlphaValue )
76 return mRasterShaderFunction->
shade( theRedValue, theGreenValue, theBlueValue, theAlphaValue, theReturnRedValue, theReturnGreenValue, theReturnBlueValue, theReturnAlphaValue );
94 if ( 0 != theFunction )
108 QgsDebugMsg(
"Value = " + QString::number( theValue ) );
124 QgsDebugMsg(
"Value = " + QString::number( theValue ) );
140 QDomElement rasterShaderElem = doc.createElement(
"rastershader" );
142 if ( colorRampShader )
144 QDomElement colorRampShaderElem = doc.createElement(
"colorrampshader" );
146 colorRampShaderElem.setAttribute(
"clip", colorRampShader->
clip() );
148 QList<QgsColorRampShader::ColorRampItem> itemList = colorRampShader->
colorRampItemList();
149 QList<QgsColorRampShader::ColorRampItem>::const_iterator itemIt = itemList.constBegin();
150 for ( ; itemIt != itemList.constEnd(); ++itemIt )
152 QDomElement itemElem = doc.createElement(
"item" );
153 itemElem.setAttribute(
"label", itemIt->label );
154 itemElem.setAttribute(
"value", QString::number( itemIt->value ) );
155 itemElem.setAttribute(
"color", itemIt->color.name() );
156 itemElem.setAttribute(
"alpha", itemIt->color.alpha() );
157 colorRampShaderElem.appendChild( itemElem );
159 rasterShaderElem.appendChild( colorRampShaderElem );
161 parent.appendChild( rasterShaderElem );
167 QDomElement colorRampShaderElem = elem.firstChildElement(
"colorrampshader" );
168 if ( !colorRampShaderElem.isNull() )
171 colorRampShader->
setColorRampType( colorRampShaderElem.attribute(
"colorRampType",
"INTERPOLATED" ) );
172 colorRampShader->
setClip( colorRampShaderElem.attribute(
"clip",
"0" ) ==
"1" );
174 QList<QgsColorRampShader::ColorRampItem> itemList;
175 QDomElement itemElem;
180 QDomNodeList itemNodeList = colorRampShaderElem.elementsByTagName(
"item" );
181 for (
int i = 0; i < itemNodeList.size(); ++i )
183 itemElem = itemNodeList.at( i ).toElement();
184 itemValue = itemElem.attribute(
"value" ).toDouble();
185 itemLabel = itemElem.attribute(
"label" );
186 itemColor.setNamedColor( itemElem.attribute(
"color" ) );
187 itemColor.setAlpha( itemElem.attribute(
"alpha",
"255" ).toInt() );