| 
    QGIS API Documentation
    3.26.3-Buenos Aires (65e4edfdad)
    
   | 
 
 
 
 
Go to the documentation of this file.
   24 #include <QCoreApplication> 
   25 #include <QDomDocument> 
   26 #include <QDomElement> 
   67   if ( !
input ) 
return false;
 
  107   return QList< QPair< QString, QColor > >();
 
  112   QList<QgsLayerTreeModelLegendNode *> nodes;
 
  115   if ( rasterItemList.isEmpty() )
 
  121   const int max_count = 1000;
 
  123   for ( 
auto itemIt = rasterItemList.constBegin(); itemIt != rasterItemList.constEnd(); ++itemIt, ++count )
 
  127     if ( count == max_count )
 
  129       const QString label = tr( 
"following %1 items\nnot displayed" ).arg( rasterItemList.size() - max_count );
 
  140   if ( rasterRendererElem.isNull() )
 
  145   rasterRendererElem.setAttribute( QStringLiteral( 
"type" ), 
mType );
 
  146   rasterRendererElem.setAttribute( QStringLiteral( 
"opacity" ), QString::number( 
mOpacity ) );
 
  147   rasterRendererElem.setAttribute( QStringLiteral( 
"alphaBand" ), 
mAlphaBand );
 
  155   QDomElement minMaxOriginElem = doc.createElement( QStringLiteral( 
"minMaxOrigin" ) );
 
  157   rasterRendererElem.appendChild( minMaxOriginElem );
 
  162   if ( !mNodataColor.isValid() )
 
  165     return mNodataColor.rgba();
 
  170   if ( rendererElem.isNull() )
 
  175   mType = rendererElem.attribute( QStringLiteral( 
"type" ) );
 
  176   mOpacity = rendererElem.attribute( QStringLiteral( 
"opacity" ), QStringLiteral( 
"1.0" ) ).toDouble();
 
  177   mAlphaBand = rendererElem.attribute( QStringLiteral( 
"alphaBand" ), QStringLiteral( 
"-1" ) ).toInt();
 
  178   const QString colorEncoded = rendererElem.attribute( QStringLiteral( 
"nodataColor" ) );
 
  181   const QDomElement rasterTransparencyElem = rendererElem.firstChildElement( QStringLiteral( 
"rasterTransparency" ) );
 
  182   if ( !rasterTransparencyElem.isNull() )
 
  189   const QDomElement minMaxOriginElem = rendererElem.firstChildElement( QStringLiteral( 
"minMaxOrigin" ) );
 
  190   if ( !minMaxOriginElem.isNull() )
 
  205   if ( copyMinMaxOrigin )
 
  211   QDomElement rasterSymbolizerElem = doc.createElement( QStringLiteral( 
"sld:RasterSymbolizer" ) );
 
  212   element.appendChild( rasterSymbolizerElem );
 
  217     QDomElement opacityElem = doc.createElement( QStringLiteral( 
"sld:Opacity" ) );
 
  218     opacityElem.appendChild( doc.createTextNode( QString::number( 
opacity() ) ) );
 
  219     rasterSymbolizerElem.appendChild( opacityElem );
 
  
virtual QList< QPair< QString, QColor > > legendSymbologyItems() const
Returns symbology items if provided by renderer.
 
static QString encodeColor(const QColor &color)
 
void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Writes the transparency information to an XML document.
 
void setRasterTransparency(QgsRasterTransparency *t)
 
void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Serialize object.
 
bool isEmpty() const
True if there are no entries in the pixel lists except the nodata value.
 
const QgsRasterMinMaxOrigin & minMaxOrigin() const
Returns const reference to origin of min/max values.
 
QgsRasterInterface * mInput
 
#define QgsDebugMsgLevel(str, level)
 
static bool typeIsNumeric(Qgis::DataType type)
Returns true if data type is numeric.
 
QgsRasterRenderer(QgsRasterInterface *input=nullptr, const QString &type=QString())
Constructor for QgsRasterRenderer.
 
Implementation of legend node interface for displaying arbitrary label with icon.
 
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
 
QColor nodataColor() const
Returns the color to use for shading nodata pixels.
 
void readXml(const QDomElement &elem)
Deserialize object.
 
DataType
Raster data types.
 
An interface for classes which can visit style entity (e.g. symbol) nodes (using the visitor pattern)...
 
static QColor decodeColor(const QString &str)
 
static const QRgb NODATA_COLOR
 
bool setInput(QgsRasterInterface *input) override
Set input.
 
QgsRasterMinMaxOrigin mMinMaxOrigin
Origin of min/max values.
 
Raster renderer pipe that applies colors to a raster.
 
const QgsRasterTransparency * rasterTransparency() const
 
virtual Qgis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
 
Layer tree node points to a map layer.
 
QgsRasterTransparency * mRasterTransparency
Raster transparency per color or value. Overwrites global alpha value.
 
@ UnknownDataType
Unknown or unspecified type.
 
void setAlphaBand(int band)
 
void readXml(const QDomElement &rendererElem) override
Sets base class members from xml. Usually called from create() methods of subclasses.
 
virtual void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const
Used from subclasses to create SLD Rule elements following SLD v1.0 specs.
 
void _writeXml(QDomDocument &doc, QDomElement &rasterRendererElem) const
Write upper class info into rasterrenderer element (called by writeXml method of subclasses)
 
void copyCommonProperties(const QgsRasterRenderer *other, bool copyMinMaxOrigin=true)
Copies common properties like opacity / transparency data from other renderer.
 
bool usesTransparency() const
 
~QgsRasterRenderer() override
 
@ ARGB32_Premultiplied
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
 
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
 
void readXml(const QDomElement &elem)
Reads the transparency information from an XML document.
 
int mAlphaBand
Read alpha value from band.
 
int bandCount() const override
Gets number of bands.
 
Qgis::DataType dataType(int bandNo) const override
Returns data type for the band specified by number.
 
void setMinMaxOrigin(const QgsRasterMinMaxOrigin &origin)
Sets origin of min/max values.
 
Base class for processing filters like renderers, reprojector, resampler etc.
 
QRgb renderColorForNodataPixel() const
Returns the color for the renderer to use to represent nodata pixels.
 
virtual QgsRasterInterface * input() const
Current input.
 
double mOpacity
Global alpha value (0-1)
 
void setNodataColor(const QColor &color)
Sets the color to use for shading nodata pixels.
 
Implementation of legend node interface for displaying raster legend entries.
 
virtual int bandCount() const =0
Gets number of bands.
 
void setOpacity(double opacity)
Sets the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
 
virtual QList< QgsLayerTreeModelLegendNode * > createLegendNodes(QgsLayerTreeLayer *nodeLayer)
Creates a set of legend nodes representing the renderer.
 
double opacity() const
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....