29 name( theName ), visibleName( theVisibleName ), rendererCreateFunction( rendererFunction ),
30 widgetCreateFunction( widgetFunction )
70 if ( !
mEntries.contains( rendererName ) )
74 mEntries[rendererName].widgetCreateFunction = func;
79 QHash< QString, QgsRasterRendererRegistryEntry >::const_iterator it =
mEntries.find( rendererName );
95 QList< QgsRasterRendererRegistryEntry > result;
97 QHash< QString, QgsRasterRendererRegistryEntry >::const_iterator it =
mEntries.constBegin();
98 for ( ; it !=
mEntries.constEnd(); ++it )
100 result.push_back( it.value() );
107 if ( !provider || provider->
bandCount() < 1 )
114 switch ( theDrawingStyle )
119 QList<QgsColorRampShader::ColorRampItem> colorEntries = provider->
colorTable( grayBand );
122 int colorArraySize = 0;
123 QList<QgsColorRampShader::ColorRampItem>::const_iterator colorIt = colorEntries.constBegin();
124 for ( ; colorIt != colorEntries.constEnd(); ++colorIt )
126 if ( colorIt->value > colorArraySize )
128 colorArraySize = ( int )( colorIt->value );
133 QColor* colorArray =
new QColor[ colorArraySize ];
134 colorIt = colorEntries.constBegin();
135 QVector<QString> labels;
136 for ( ; colorIt != colorEntries.constEnd(); ++colorIt )
138 int idx = ( int )( colorIt->value );
139 colorArray[idx] = colorIt->color;
140 if ( !colorIt->label.isEmpty() )
142 if ( labels.size() <= idx ) labels.resize( idx + 1 );
143 labels[idx] = colorIt->label;
182 int redBand = s.value(
"/Raster/defaultRedBand", 1 ).toInt();
183 if ( redBand < 0 || redBand > provider->
bandCount() )
187 int greenBand = s.value(
"/Raster/defaultGreenBand", 2 ).toInt();
188 if ( greenBand < 0 || greenBand > provider->
bandCount() )
192 int blueBand = s.value(
"/Raster/defaultBlueBand", 3 ).toInt();
193 if ( blueBand < 0 || blueBand > provider->
bandCount() )
211 int bandCount = renderer->
usesBands().size();
212 if ( bandCount == 1 )
214 QList<QgsRasterTransparency::TransparentSingleValuePixel> transparentSingleList;
217 else if ( bandCount == 3 )
219 QList<QgsRasterTransparency::TransparentThreeValuePixel> transparentThreeValueList;
237 if ( s.value(
"/Raster/useStandardDeviation",
false ).toBool() )
241 double stdDevFactor = s.value(
"/Raster/defaultStandardDeviation", 2.0 ).toDouble();
242 double diff = stdDevFactor * stats.
stdDev;
243 minValue = stats.
mean - diff;
244 maxValue = stats.
mean + diff;
virtual int bandCount() const =0
Get number of bands.
static QgsRasterRendererRegistry * mInstance
Interface for all raster shaders.
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
Renderer for paletted raster images.
bool rendererData(const QString &rendererName, QgsRasterRendererRegistryEntry &data) const
DrawingStyle
This enumerator describes the different kinds of drawing we can do.
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
QgsRasterRendererRegistry()
void setTransparentSingleValuePixelList(QList< QgsRasterTransparency::TransparentSingleValuePixel >)
Mutator for transparentSingleValuePixelList.
double maximumValue
The maximum cell value in the raster band.
Registry for raster renderers.
QgsRasterRendererWidget *(* QgsRasterRendererWidgetCreateFunc)(QgsRasterLayer *, const QgsRectangle &extent)
QHash< QString, QgsRasterRendererRegistryEntry > mEntries
Raster renderer pipe for single band color.
virtual QgsRasterBandStats bandStatistics(int theBandNo, int theStats=QgsRasterBandStats::All, const QgsRectangle &theExtent=QgsRectangle(), int theSampleSize=0)
Get band statistics.
double stdDev
The standard deviation of the cell values.
The RasterBandStats struct is a container for statistics about a single raster band.
static QgsRasterRendererRegistry * instance()
double mean
The mean cell value for the band.
QgsRasterRendererRegistryEntry()
void insert(QgsRasterRendererRegistryEntry entry)
Raster renderer pipe for single band pseudocolor.
virtual QGis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
~QgsRasterRendererRegistry()
Raster renderer pipe for single band gray.
QgsRasterRenderer * defaultRendererForDrawingStyle(const QgsRaster::DrawingStyle &theDrawingStyle, QgsRasterDataProvider *provider) const
Creates a default renderer for a raster drawing style (considering user options such as default contr...
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
QStringList mSortedEntries
Registry for raster renderer entries.
QgsRasterRenderer *(* QgsRasterRendererCreateFunc)(const QDomElement &, QgsRasterInterface *input)
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
DataType
Raster data types.
void setTransparentThreeValuePixelList(QList< QgsRasterTransparency::TransparentThreeValuePixel >)
Mutator for transparentThreeValuePixelList.
double minimumValue
The minimum cell value in the raster band.
Renderer for multiband images with the color components.
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range...
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
bool minMaxValuesForBand(int band, QgsRasterDataProvider *provider, double &minValue, double &maxValue) const
QList< QgsRasterRendererRegistryEntry > entries() const
virtual QList< QgsColorRampShader::ColorRampItem > colorTable(int bandNo) const
void setRasterTransparency(QgsRasterTransparency *t)
void insertWidgetFunction(const QString &rendererName, QgsRasterRendererWidgetCreateFunc func)
Raster renderer pipe that applies colors to a raster.
Base class for raster data providers.
QStringList renderersList() const