QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsrasterrendererwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasterrendererwidget.cpp
3  ---------------------------
4  begin : June 2012
5  copyright : (C) 2012 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 
19 #include "qgsrasterdataprovider.h"
20 #include "qgsrasterlayer.h"
21 #include "qgsmapcanvas.h"
22 
24 {
25  mCanvas = canvas;
26 }
27 
29 {
30  return mCanvas;
31 }
32 
34 {
35  QString name;
36  if ( !mRasterLayer )
37  {
38  return name;
39  }
40 
41  const QgsRasterDataProvider* provider = mRasterLayer->dataProvider();
42  if ( !provider )
43  {
44  return name;
45  }
46 
47  name = provider->generateBandName( band );
48 
49  QString colorInterp = provider->colorInterpretationName( band );
50  if ( colorInterp != "Undefined" )
51  {
52  name.append( QString( " (%1)" ).arg( colorInterp ) );
53  }
54  return name;
55 }
56 
QString & append(QChar ch)
virtual QString generateBandName(int theBandNumber) const
helper function to create zero padded band names
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:109
virtual void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
const char * name() const
QgsMapCanvas * mapCanvas()
Returns the map canvas associated with the widget.
QString displayBandName(int band) const
Returns a band name for display.
virtual QString colorInterpretationName(int theBandNo) const
QgsRasterDataProvider * dataProvider()
Returns the data provider.
QgsMapCanvas * mCanvas
Associated map canvas.
Base class for raster data providers.