QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsrasterrenderer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrasterrenderer.h
3 -------------------
4 begin : December 2011
5 copyright : (C) 2011 by Marco Hugentobler
6 email : marco at sourcepole dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSRASTERRENDERER_H
19#define QGSRASTERRENDERER_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgsrasterinterface.h"
25#include "qgsrectangle.h"
26
27#include <QPair>
28
29class QDomElement;
30
31class QPainter;
36
41class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface
42{
43
44 Q_DECLARE_TR_FUNCTIONS( QgsRasterRenderer ) // cppcheck-suppress duplInheritedMember
45
46 public:
47
48 static const QRgb NODATA_COLOR;
49
53 QgsRasterRenderer( QgsRasterInterface *input = nullptr, const QString &type = QString() );
54 ~QgsRasterRenderer() override;
55
59 const QgsRasterRenderer &operator=( const QgsRasterRenderer & ) = delete;
60
61 QgsRasterRenderer *clone() const override = 0 SIP_FACTORY;
62
63 int bandCount() const override;
64
65 Qgis::DataType dataType( int bandNo ) const override;
66
70 virtual QString type() const { return mType; }
71
77 virtual Qgis::RasterRendererFlags flags() const;
78
85 virtual bool canCreateRasterAttributeTable( ) const;
86
87 bool setInput( QgsRasterInterface *input ) override;
88
101 virtual int inputBand() const;
102
115 virtual bool setInputBand( int band );
116
117 QgsRasterBlock *block( int bandNo,
118 const QgsRectangle &extent,
119 int width,
120 int height,
121 QgsRasterBlockFeedback *feedback = nullptr ) override = 0 SIP_FACTORY;
122
123 bool usesTransparency() const;
124
130 void setOpacity( double opacity ) { mOpacity = opacity; }
131
137 double opacity() const { return mOpacity; }
138
149 QColor nodataColor() const { return mNodataColor; }
150
160 void setNodataColor( const QColor &color ) { mNodataColor = color; }
161
162 void setRasterTransparency( QgsRasterTransparency *t SIP_TRANSFER );
164
165 void setAlphaBand( int band ) { mAlphaBand = band; }
166 int alphaBand() const { return mAlphaBand; }
167
173 virtual QList< QPair< QString, QColor > > legendSymbologyItems() const;
174
185 virtual QList<QgsLayerTreeModelLegendNode *> createLegendNodes( QgsLayerTreeLayer *nodeLayer ) SIP_FACTORY;
186
188 void readXml( const QDomElement &rendererElem ) override;
189
194 void copyCommonProperties( const QgsRasterRenderer *other, bool copyMinMaxOrigin = true );
195
201 virtual QList<int> usesBands() const { return QList<int>(); }
202
205
207 void setMinMaxOrigin( const QgsRasterMinMaxOrigin &origin ) { mMinMaxOrigin = origin; }
208
213 Q_DECL_DEPRECATED virtual void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props = QVariantMap() ) const SIP_DEPRECATED;
214
219 virtual bool toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const;
220
230 virtual bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
231
238 bool needsRefresh( const QgsRectangle &extent ) const SIP_SKIP;
239
248 virtual bool refresh( const QgsRectangle &extent, const QList<double> &min, const QList<double> &max, bool forceRefresh = false ) SIP_SKIP;
249
250 protected:
251
253 void _writeXml( QDomDocument &doc, QDomElement &rasterRendererElem ) const;
254
255 QString mType;
256
258 double mOpacity = 1.0;
261
266 int mAlphaBand = -1;
267
270
279 QRgb renderColorForNodataPixel() const;
280
283
284 private:
285
286 QColor mNodataColor;
287
288#ifdef SIP_RUN
291#endif
292
293};
294
295#endif // QGSRASTERRENDERER_H
QFlags< RasterRendererFlag > RasterRendererFlags
Flags which control behavior of raster renderers.
Definition qgis.h:1512
DataType
Raster data types.
Definition qgis.h:372
Layer tree node points to a map layer.
An abstract interface for legend items returned from QgsMapLayerLegend implementation.
Feedback object tailored for raster block reading.
Raster data container.
Base class for processing filters like renderers, reprojector, resampler etc.
virtual Qgis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
QgsRasterInterface(QgsRasterInterface *input=nullptr)
virtual int bandCount() const =0
Gets number of bands.
virtual void readXml(const QDomElement &filterElem)
Sets base class members from xml. Usually called from create() methods of subclasses.
virtual QgsRectangle extent() const
Gets the extent of the interface.
virtual QgsRasterInterface * input() const
Current input.
virtual bool setInput(QgsRasterInterface *input)
Set input.
Describes the origin of minimum and maximum values in a raster.
Raster renderer pipe that applies colors to a raster.
QColor nodataColor() const
Returns the color to use for shading nodata pixels.
QgsRasterRenderer(QgsRasterInterface *input=nullptr, const QString &type=QString())
Constructor for QgsRasterRenderer.
virtual QString type() const
Returns a unique string representation of the renderer type.
double mOpacity
Global alpha value (0-1).
void setMinMaxOrigin(const QgsRasterMinMaxOrigin &origin)
Sets origin of min/max values.
int mAlphaBand
Read alpha value from band.
QgsRectangle mLastRectangleUsedByRefreshContrastEnhancementIfNeeded
To save computations and possible infinite cycle of notifications.
QRgb renderColorForNodataPixel() const
Returns the color for the renderer to use to represent nodata pixels.
const QgsRasterTransparency * rasterTransparency() const
std::unique_ptr< QgsRasterTransparency > mRasterTransparency
Raster transparency per color or value. Overwrites global alpha value.
const QgsRasterMinMaxOrigin & minMaxOrigin() const
Returns const reference to origin of min/max values.
double opacity() const
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr) override=0
Read block of data using given extent and size.
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
void setAlphaBand(int band)
void setOpacity(double opacity)
Sets the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
QgsRasterMinMaxOrigin mMinMaxOrigin
Origin of min/max values.
QgsRasterRenderer(const QgsRasterRenderer &)=delete
QgsRasterRenderer cannot be copied. Use clone() instead.
bool usesTransparency() const
static const QRgb NODATA_COLOR
void setNodataColor(const QColor &color)
Sets the color to use for shading nodata pixels.
const QgsRasterRenderer & operator=(const QgsRasterRenderer &)=delete
QgsRasterRenderer cannot be copied. Use clone() instead.
QgsRasterRenderer * clone() const override=0
Clone itself, create deep copy.
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
A rectangle specified with double values.
Holds SLD export options and other information related to SLD export of a QGIS layer style.
An interface for classes which can visit style entity (e.g.
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84