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, context ) );
 
  104   parent.appendChild( rasterShaderElem );
 
  110   QDomElement colorRampShaderElem = elem.firstChildElement( QStringLiteral( 
"colorrampshader" ) );
 
  111   if ( !colorRampShaderElem.isNull() )
 
  114     colorRampShader->
readXml( colorRampShaderElem, context );
 
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext()) const
Writes configuration to a new DOM element.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context=QgsReadWriteContext())
Reads configuration from the given DOM element.
The raster shade function applies a shader to a pixel at render time - typically used to render grays...
void setMinimumValue(double value)
Sets the minimum value for the raster shader.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context=QgsReadWriteContext())
Reads shader state from an XML element.
QgsRasterShader(double minimumValue=0.0, double maximumValue=255.0)
bool shade(double value, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlpha)
Generates a new RGBA value based on one input value.
void writeXml(QDomDocument &doc, QDomElement &parent, const QgsReadWriteContext &context=QgsReadWriteContext()) const
Writes shader state to an XML element.
void setRasterShaderFunction(QgsRasterShaderFunction *function)
A public method that allows the user to set their own shader function.
void setMaximumValue(double value)
Sets the maximum value for the raster shader.
The class is used as a container of context for various read/write operations on other objects.
#define QgsDebugMsgLevel(str, level)