25 #include <QDomDocument> 26 #include <QDomElement> 29 : mMinimumValue( minimumValue )
30 , mMaximumValue( maximumValue )
36 bool QgsRasterShader::shade(
double value,
int *returnRedValue,
int *returnGreenValue,
int *returnBlueValue,
int *returnAlpha )
38 if ( mRasterShaderFunction )
40 return mRasterShaderFunction->shade( value, returnRedValue, returnGreenValue, returnBlueValue, returnAlpha );
46 bool QgsRasterShader::shade(
double redValue,
double greenValue,
double blueValue,
double alphaValue,
int *returnRedValue,
int *returnGreenValue,
int *returnBlueValue,
int *returnAlphaValue )
48 if ( mRasterShaderFunction )
50 return mRasterShaderFunction->shade( redValue, greenValue, blueValue, alphaValue, returnRedValue, returnGreenValue, returnBlueValue, returnAlphaValue );
60 if ( mRasterShaderFunction.get() == function )
65 mRasterShaderFunction.reset(
function );
73 mMaximumValue = value;
74 if ( mRasterShaderFunction )
76 mRasterShaderFunction->setMaximumValue( value );
84 mMinimumValue = value;
85 if ( mRasterShaderFunction )
87 mRasterShaderFunction->setMinimumValue( value );
93 if ( parent.isNull() || !mRasterShaderFunction )
98 QDomElement rasterShaderElem = doc.createElement( QStringLiteral(
"rastershader" ) );
100 if ( colorRampShader )
102 rasterShaderElem.appendChild( colorRampShader->
writeXml( doc ) );
104 parent.appendChild( rasterShaderElem );
110 QDomElement colorRampShaderElem = elem.firstChildElement( QStringLiteral(
"colorrampshader" ) );
111 if ( !colorRampShaderElem.isNull() )
114 colorRampShader->
readXml( colorRampShaderElem );
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
void writeXml(QDomDocument &doc, QDomElement &parent) const
Writes shader state to an XML element.
#define QgsDebugMsgLevel(str, level)
The raster shade function applies a shader to a pixel at render time - typically used to render grays...
void setRasterShaderFunction(QgsRasterShaderFunction *function)
A public method that allows the user to set their own shader function.
void readXml(const QDomElement &elem)
Reads configuration from the given DOM element.
bool shade(double value, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlpha)
Generates a new RGBA value based on one input value.
QgsRasterShader(double minimumValue=0.0, double maximumValue=255.0)
void setMinimumValue(double value)
Sets the minimum value for the raster shader.
void setMaximumValue(double value)
Sets the maximum value for the raster shader.
void readXml(const QDomElement &elem)
Reads shader state from an XML element.