23 #include <QDomDocument> 24 #include <QDomElement> 30 mMinimumValue = theMinimumValue;
31 mMaximumValue = theMaximumValue;
37 delete mRasterShaderFunction;
50 bool QgsRasterShader::shade(
double theValue,
int* theReturnRedValue,
int* theReturnGreenValue,
int* theReturnBlueValue,
int *theReturnAlpha )
52 if ( mRasterShaderFunction )
54 return mRasterShaderFunction->
shade( theValue, theReturnRedValue, theReturnGreenValue, theReturnBlueValue, theReturnAlpha );
73 bool QgsRasterShader::shade(
double theRedValue,
double theGreenValue,
double theBlueValue,
double theAlphaValue,
int* theReturnRedValue,
int* theReturnGreenValue,
int* theReturnBlueValue,
int* theReturnAlphaValue )
75 if ( mRasterShaderFunction )
77 return mRasterShaderFunction->
shade( theRedValue, theGreenValue, theBlueValue, theAlphaValue, theReturnRedValue, theReturnGreenValue, theReturnBlueValue, theReturnAlphaValue );
92 if ( mRasterShaderFunction == theFunction )
97 delete mRasterShaderFunction;
98 mRasterShaderFunction = theFunction;
111 mMaximumValue = theValue;
112 if ( mRasterShaderFunction )
127 mMinimumValue = theValue;
128 if ( mRasterShaderFunction )
136 if ( parent.
isNull() || !mRasterShaderFunction )
143 if ( colorRampShader )
151 for ( ; itemIt != itemList.
constEnd(); ++itemIt )
157 itemElem.
setAttribute(
"alpha", itemIt->color.alpha() );
160 rasterShaderElem.
appendChild( colorRampShaderElem );
169 if ( !colorRampShaderElem.
isNull() )
173 colorRampShader->
setClip( colorRampShaderElem.
attribute(
"clip",
"0" ) ==
"1" );
183 for (
int i = 0; i < itemNodeList.
size(); ++i )
187 itemLabel = itemElem.
attribute(
"label" );
QDomNodeList elementsByTagName(const QString &tagname) const
void setMaximumValue(double)
Set the maximum value.
static QString printValue(double value)
Print double value with all necessary significant digits.
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
QList< QgsColorRampShader::ColorRampItem > colorRampItemList() const
Get the custom colormap.
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &theList)
Set custom colormap.
void setClip(bool clip)
Sets whether the shader should not render values out of range.
void setNamedColor(const QString &name)
double toDouble(bool *ok) const
void writeXML(QDomDocument &doc, QDomElement &parent) const
QDomElement toElement() const
QString number(int n, int base)
#define QgsDebugMsgLevel(str, level)
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.
bool clip() const
Returns whether the shader will clip values which are out of range.
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