22 #include <QDomDocument> 23 #include <QDomElement> 30 , mClassificationMin( std::numeric_limits<double>::quiet_NaN() )
31 , mClassificationMax( std::numeric_limits<double>::quiet_NaN() )
61 if ( origColorRampShader )
96 if ( !rasterShaderElem.
isNull() )
99 shader->
readXML( rasterShaderElem );
118 if ( !
mInput || !mShader )
125 if ( !inputBlock || inputBlock->
isEmpty() )
139 if ( !alphaBlock || alphaBlock->
isEmpty() )
148 alphaBlock = inputBlock;
164 outputBlock->
setColor( i, myDefaultColor );
167 double val = inputBlock->
value( i );
168 int red, green, blue, alpha;
169 if ( !mShader->
shade( val, &red, &green, &blue, &alpha ) )
171 outputBlock->
setColor( i, myDefaultColor );
178 red *= ( alpha / 255.0 );
179 blue *= ( alpha / 255.0 );
180 green *= ( alpha / 255.0 );
183 if ( !hasTransparency )
185 outputBlock->
setColor( i, qRgba( red, green, blue, alpha ) );
197 currentOpacity *= alphaBlock->
value( i ) / 255.0;
200 outputBlock->
setColor( i, qRgba( currentOpacity * red, currentOpacity * green, currentOpacity * blue, currentOpacity * alpha ) );
215 if ( parentElem.
isNull() )
225 mShader->
writeXML( doc, rasterRendererElem );
239 if ( shaderFunction )
virtual int bandCount() const =0
Get number of bands.
A rectangle specified with double values.
Interface for all raster shaders.
void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const override
Get symbology items if provided by renderer.
QDomNode appendChild(const QDomNode &newChild)
QgsSingleBandPseudoColorRenderer * clone() const override
Clone itself, create deep copy.
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.
QString attribute(const QString &name, const QString &defValue) const
void setClassificationMinMaxOrigin(int origin)
static int minMaxOriginFromName(const QString &theName)
virtual QgsRasterInterface * input() const
Current input.
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &theList)
Set custom colormap.
double toDouble(bool *ok) const
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.
void readXML(const QDomElement &rendererElem) override
Sets base class members from xml.
void writeXML(QDomDocument &doc, QDomElement &parentElem) const override
Write base class members to xml.
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.
QString number(int n, int base)
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
QgsSingleBandPseudoColorRenderer(QgsRasterInterface *input, int band, QgsRasterShader *shader)
Note: takes ownership of QgsRasterShader.
double value(int row, int column) const
Read a single value if type of block is numeric.
void setAttribute(const QString &name, const QString &value)
int band() const
Returns the band used by the renderer.
int toInt(bool *ok, int base) const
QgsRasterShaderFunction * rasterShaderFunction()
QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height) override
Read block of data using given extent and size.
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
int mAlphaBand
Read alpha value from band.
void setAlphaBand(int band)
QList< int > usesBands() const override
Returns a list of band numbers used by the renderer.
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.
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...
bool reset(QGis::DataType theDataType, int theWidth, int theHeight)
Reset block.
~QgsSingleBandPseudoColorRenderer()
virtual void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const
virtual QgsRectangle extent()
Get the extent of the interface.
void setClassificationMin(double min)
QDomElement firstChildElement(const QString &tagName) const
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.
void setBand(int bandNo)
Sets the band used by the renderer.
double mOpacity
Global alpha value (0-1)
void readXML(const QDomElement &elem)
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
void setOpacity(double opacity)
QDomElement createElement(const QString &tagName)
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.