22 #include <QDomDocument>
23 #include <QDomElement>
30 , mClassificationMin( std::numeric_limits<double>::quiet_NaN() )
31 , mClassificationMax( std::numeric_limits<double>::quiet_NaN() )
52 if ( origColorRampShader )
84 int band = elem.attribute(
"band",
"-1" ).toInt();
86 QDomElement rasterShaderElem = elem.firstChildElement(
"rastershader" );
87 if ( !rasterShaderElem.isNull() )
90 shader->
readXML( rasterShaderElem );
116 if ( !inputBlock || inputBlock->
isEmpty() )
130 if ( !alphaBlock || alphaBlock->
isEmpty() )
139 alphaBlock = inputBlock;
155 outputBlock->
setColor( i, myDefaultColor );
158 double val = inputBlock->
value( i );
159 int red, green, blue, alpha;
160 if ( !
mShader->
shade( val, &red, &green, &blue, &alpha ) )
162 outputBlock->
setColor( i, myDefaultColor );
169 red *= ( alpha / 255.0 );
170 blue *= ( alpha / 255.0 );
171 green *= ( alpha / 255.0 );
174 if ( !hasTransparency )
176 outputBlock->
setColor( i, qRgba( red, green, blue, alpha ) );
188 currentOpacity *= alphaBlock->
value( i ) / 255.0;
191 outputBlock->
setColor( i, qRgba( currentOpacity * red, currentOpacity * green, currentOpacity * blue, currentOpacity * alpha ) );
206 if ( parentElem.isNull() )
211 QDomElement rasterRendererElem = doc.createElement(
"rasterrenderer" );
213 rasterRendererElem.setAttribute(
"band",
mBand );
218 rasterRendererElem.setAttribute(
"classificationMin", QString::number(
mClassificationMin ) );
219 rasterRendererElem.setAttribute(
"classificationMax", QString::number(
mClassificationMax ) );
222 parentElem.appendChild( rasterRendererElem );
230 if ( shaderFunction )
void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const
Get symbology items if provided by renderer.
A rectangle specified with double values.
Interface for all raster shaders.
static int minMaxOriginFromName(QString theName)
double mClassificationMin
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
void setClassificationMinMaxOrigin(int origin)
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &theList)
Set custom colormap.
QgsRasterShader * shader()
void setClassificationMax(double max)
bool isNoData(int row, int column)
Check if value at position is no data.
void setShader(QgsRasterShader *shader)
Takes ownership of the shader.
bool usesTransparency() const
QgsRasterTransparency * mRasterTransparency
Raster transparency per color or value.
void writeXML(QDomDocument &doc, QDomElement &parent) const
bool setColor(int row, int column, QRgb color)
Set color on position.
static const QRgb NODATA_COLOR
int alphaValue(double, int theGlobalTransparency=255) const
Returns the transparency value for a single value Pixel.
QgsSingleBandPseudoColorRenderer(QgsRasterInterface *input, int band, QgsRasterShader *shader)
Note: takes ownership of QgsRasterShader.
QgsRasterInterface * clone() const
Clone itself, create deep copy.
double value(int row, int column) const
Read a single value if type of block is numeric.
QgsRasterShaderFunction * rasterShaderFunction()
The raster shade function applies a shader to a pixel at render time - typically used to render grays...
double maximumValue()
Return the maximum value for the raster shader.
Raster renderer pipe for single band pseudocolor.
bool shade(double, int *, int *, int *, int *)
generates and new RGBA value based on one input value
void writeXML(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
int mAlphaBand
Read alpha value from band.
void setAlphaBand(int band)
void setRasterShaderFunction(QgsRasterShaderFunction *)
A public method that allows the user to set their own shader function.
Base class for processing filters like renderers, reprojector, resampler etc.
double mClassificationMax
void setColorRampType(QgsColorRampShader::ColorRamp_TYPE theColorRampType)
Set the color ramp type.
unsigned long long qgssize
qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be har...
void readXML(const QDomElement &rendererElem)
Sets base class members from xml.
bool reset(QGis::DataType theDataType, int theWidth, int theHeight)
Reset block.
~QgsSingleBandPseudoColorRenderer()
virtual void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const
QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height)
Read block of data using given extent and size.
void setClassificationMin(double min)
QgsRasterShader * mShader
int mClassificationMinMaxOrigin
static QString minMaxOriginName(int theOrigin)
virtual QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height)=0
Read block of data using given extent and size.
double minimumValue()
Return the minimum value for the raster shader.
double mOpacity
Global alpha value (0-1)
void readXML(const QDomElement &elem)
void setOpacity(double opacity)
void _writeXML(QDomDocument &doc, QDomElement &rasterRendererElem) const
Write upper class info into rasterrenderer element (called by writeXML method of subclasses) ...
QgsRasterInterface * mInput
void setRasterTransparency(QgsRasterTransparency *t)
Raster renderer pipe that applies colors to a raster.
bool isEmpty() const
Returns true if block is empty, i.e.