QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgspalettedrasterrenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspalettedrasterrenderer.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 QGSPALETTEDRASTERRENDERER_H
19 #define QGSPALETTEDRASTERRENDERER_H
20 
21 #include <QVector>
22 
23 #include "qgsrasterrenderer.h"
24 
25 class QColor;
26 class QDomElement;
27 
32 {
33  public:
35  QgsPalettedRasterRenderer( QgsRasterInterface* input, int bandNumber, QColor* colorArray, int nColors, const QVector<QString>& labels = QVector<QString>() );
36  QgsPalettedRasterRenderer( QgsRasterInterface* input, int bandNumber, QRgb* colorArray, int nColors, const QVector<QString>& labels = QVector<QString>() );
38  QgsPalettedRasterRenderer * clone() const override;
39  static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input );
40 
41  QgsRasterBlock *block( int bandNo, const QgsRectangle & extent, int width, int height ) override;
42  QgsRasterBlock *block2( int bandNo, const QgsRectangle & extent, int width, int height, QgsRasterBlockFeedback* feedback = nullptr ) override;
43 
45  int nColors() const { return mNColors; }
47  QColor* colors() const;
48 
52  QRgb* rgbArray() const;
53 
56  QString label( int idx ) const { return mLabels.value( idx ); }
57 
60  void setLabel( int idx, const QString& label );
61 
62  void writeXML( QDomDocument& doc, QDomElement& parentElem ) const override;
63 
64  void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const override;
65 
66  QList<int> usesBands() const override;
67 
68  private:
69  int mBand;
71  QRgb* mColors;
73  int mNColors;
75  QVector<QString> mLabels;
76 
78  const QgsPalettedRasterRenderer& operator=( const QgsPalettedRasterRenderer& );
79 };
80 
81 #endif // QGSPALETTEDRASTERRENDERER_H
A rectangle specified with double values.
Definition: qgsrectangle.h:35
Renderer for paletted raster images.
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
int nColors() const
Returns number of colors.
virtual QgsRasterBlock * block2(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr)
Read block of data using given extent and size.
Raster data container.
virtual void writeXML(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
QString label(int idx) const
Return optional category label.
Base class for processing filters like renderers, reprojector, resampler etc.
virtual QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height)=0
Read block of data using given extent and size.
QgsRasterRenderer * clone() const override=0
Clone itself, create deep copy.
virtual void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const
Get symbology items if provided by renderer.
Feedback object tailored for raster block reading.
Raster renderer pipe that applies colors to a raster.