22 #include <QDomDocument>
23 #include <QDomElement>
29 mMinimumValue = theMinimumValue;
30 mMaximumValue = theMaximumValue;
36 delete mRasterShaderFunction;
49 bool QgsRasterShader::shade(
double theValue,
int* theReturnRedValue,
int* theReturnGreenValue,
int* theReturnBlueValue,
int *theReturnAlpha )
51 if ( 0 != mRasterShaderFunction )
53 return mRasterShaderFunction->
shade( theValue, theReturnRedValue, theReturnGreenValue, theReturnBlueValue, theReturnAlpha );
72 bool QgsRasterShader::shade(
double theRedValue,
double theGreenValue,
double theBlueValue,
double theAlphaValue,
int* theReturnRedValue,
int* theReturnGreenValue,
int* theReturnBlueValue,
int* theReturnAlphaValue )
74 if ( 0 != mRasterShaderFunction )
76 return mRasterShaderFunction->
shade( theRedValue, theGreenValue, theBlueValue, theAlphaValue, theReturnRedValue, theReturnGreenValue, theReturnBlueValue, theReturnAlphaValue );
91 if ( mRasterShaderFunction == theFunction )
94 if ( 0 != theFunction )
96 delete mRasterShaderFunction;
97 mRasterShaderFunction = theFunction;
110 mMaximumValue = theValue;
111 if ( 0 != mRasterShaderFunction )
126 mMinimumValue = theValue;
127 if ( 0 != mRasterShaderFunction )
135 if ( parent.
isNull() || !mRasterShaderFunction )
142 if ( colorRampShader )
150 for ( ; itemIt != itemList.
constEnd(); ++itemIt )
156 itemElem.
setAttribute(
"alpha", itemIt->color.alpha() );
159 rasterShaderElem.
appendChild( colorRampShaderElem );
168 if ( !colorRampShaderElem.
isNull() )
172 colorRampShader->
setClip( colorRampShaderElem.
attribute(
"clip",
"0" ) ==
"1" );
181 for (
int i = 0; i < itemNodeList.
size(); ++i )
185 itemLabel = itemElem.
attribute(
"label" );
QDomNodeList elementsByTagName(const QString &tagname) const
void setMaximumValue(double)
Set the maximum value.
QDomNode appendChild(const QDomNode &newChild)
void push_back(const T &value)
void setMinimumValue(double)
Return the minimum value.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
QString attribute(const QString &name, const QString &defValue) const
virtual bool shade(double, int *, int *, int *, int *)
generates and new RGBA value based on one input value
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &theList)
Set custom colormap.
void setNamedColor(const QString &name)
double toDouble(bool *ok) const
void writeXML(QDomDocument &doc, QDomElement &parent) const
QDomElement toElement() const
QList< QgsColorRampShader::ColorRampItem > colorRampItemList() const
Get the custom colormap.
QString number(int n, int base)
void setAttribute(const QString &name, const QString &value)
int toInt(bool *ok, int base) const
The raster shade function applies a shader to a pixel at render time - typically used to render grays...
bool shade(double, int *, int *, int *, int *)
generates and new RGBA value based on one input value
void setRasterShaderFunction(QgsRasterShaderFunction *)
A public method that allows the user to set their own shader function.
void setColorRampType(QgsColorRampShader::ColorRamp_TYPE theColorRampType)
Set the color ramp type.
QString colorRampTypeAsQString()
Get the color ramp type as a string.
QDomElement firstChildElement(const QString &tagName) const
virtual void setMinimumValue(double)
Return the minimum value.
QgsRasterShader(double theMinimumValue=0.0, double theMaximumValue=255.0)
void readXML(const QDomElement &elem)
const_iterator constEnd() const
QDomElement createElement(const QString &tagName)
const_iterator constBegin() const
virtual void setMaximumValue(double)
Set the maximum value.
QDomNode at(int index) const