21 #include <QCoreApplication>
22 #include <QDomDocument>
23 #include <QDomElement>
27 #define tr( sourceText ) QCoreApplication::translate ( "QgsRasterRenderer", sourceText )
34 , mType( type ), mOpacity( 1.0 ), mRasterTransparency( 0 )
66 if ( !input )
return false;
75 for (
int i = 1; i <= input->
bandCount(); i++ )
103 if ( rasterRendererElem.isNull() )
108 rasterRendererElem.setAttribute(
"type",
mType );
109 rasterRendererElem.setAttribute(
"opacity", QString::number(
mOpacity ) );
110 rasterRendererElem.setAttribute(
"alphaBand",
mAlphaBand );
120 if ( rendererElem.isNull() )
125 mType = rendererElem.attribute(
"type" );
126 mOpacity = rendererElem.attribute(
"opacity",
"1.0" ).toDouble();
127 mAlphaBand = rendererElem.attribute(
"alphaBand",
"-1" ).toInt();
129 QDomElement rasterTransparencyElem = rendererElem.firstChildElement(
"rasterTransparency" );
130 if ( !rasterTransparencyElem.isNull() )
156 name +=
"CumulativeCut";
165 name +=
"FullExtent";
187 return tr(
"Unknown" );
191 return tr(
"User defined" );
201 est_exact =
tr(
"Estimated" );
205 est_exact =
tr(
"Exact" );
210 values =
tr(
"min / max" );
214 values =
tr(
"cumulative cut" );
218 values =
tr(
"standard deviation" );
223 extent =
tr(
"full extent" );
227 extent =
tr(
"sub extent" );
230 label = QCoreApplication::translate(
"QgsRasterRenderer",
"%1 %2 of %3.",
231 "min/max origin label in raster properties, where %1 - estimated/exact, %2 - values (min/max, stddev, etc.), %3 - extent" )
240 if ( theName.contains(
"Unknown" ) )
244 else if ( theName.contains(
"User" ) )
251 if ( theName.contains(
"MinMax" ) )
255 else if ( theName.contains(
"CumulativeCut" ) )
259 else if ( theName.contains(
"StdDev" ) )
264 if ( theName.contains(
"FullExtent" ) )
268 else if ( theName.contains(
"SubExtent" ) )
273 if ( theName.contains(
"Estimated" ) )
277 else if ( theName.contains(
"Exact" ) )
virtual int bandCount() const =0
Get number of bands.
static int minMaxOriginFromName(QString theName)
static bool typeIsNumeric(QGis::DataType type)
Returns true if data type is numeric.
QgsRasterRenderer(QgsRasterInterface *input=0, const QString &type="")
virtual QgsRasterInterface * input() const
Current input.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
bool usesTransparency() const
QgsRasterTransparency * mRasterTransparency
Raster transparency per color or value.
static const QRgb NODATA_COLOR
static QString minMaxOriginLabel(int theOrigin)
bool isEmpty() const
True if there are no entries in the pixel lists except the nodata value.
virtual ~QgsRasterRenderer()
int mAlphaBand
Read alpha value from band.
virtual QGis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
Base class for processing filters like renderers, reprojector, resampler etc.
void readXML(const QDomElement &rendererElem)
Sets base class members from xml.
virtual QGis::DataType dataType(int bandNo) const
Returns data type for the band specified by number.
virtual QgsRectangle extent()
Get the extent of the interface.
virtual bool setInput(QgsRasterInterface *input)
Set input.
void writeXML(QDomDocument &doc, QDomElement &parentElem) const
static QString minMaxOriginName(int theOrigin)
DataType
Raster data types.
void readXML(const QDomElement &elem)
double mOpacity
Global alpha value (0-1)
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
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)
virtual int bandCount() const
Get number of bands.