38 , visibleName( visibleName )
39 , rendererCreateFunction( rendererFunction )
40 , widgetCreateFunction( widgetFunction )
69 mEntries.insert( entry.
name, entry );
70 mSortedEntries.append( entry.
name );
75 if ( !mEntries.contains( rendererName ) )
79 mEntries[rendererName].widgetCreateFunction = func;
84 const QHash< QString, QgsRasterRendererRegistryEntry >::const_iterator it = mEntries.find( rendererName );
85 if ( it == mEntries.constEnd() )
95 return mSortedEntries;
100 QList< QgsRasterRendererRegistryEntry > result;
102 QHash< QString, QgsRasterRendererRegistryEntry >::const_iterator it = mEntries.constBegin();
103 for ( ; it != mEntries.constEnd(); ++it )
105 result.push_back( it.value() );
112 if ( !provider || provider->
bandCount() < 1 )
119 switch ( drawingStyle )
123 const int grayBand = 1;
133 const int grayBand = 1;
145 const int bandNo = 1;
149 minMaxValuesForBand( bandNo, provider, minValue, maxValue );
158 int redBand = s.
value( QStringLiteral(
"/Raster/defaultRedBand" ), 1 ).toInt();
159 if ( redBand < 0 || redBand > provider->
bandCount() )
163 int greenBand = s.
value( QStringLiteral(
"/Raster/defaultGreenBand" ), 2 ).toInt();
164 if ( greenBand < 0 || greenBand > provider->
bandCount() )
168 int blueBand = s.
value( QStringLiteral(
"/Raster/defaultBlueBand" ), 3 ).toInt();
169 if ( blueBand < 0 || blueBand > provider->
bandCount() )
187 const int bandCount = renderer->
usesBands().size();
188 if ( bandCount == 1 )
190 const QList<QgsRasterTransparency::TransparentSingleValuePixel> transparentSingleList;
193 else if ( bandCount == 3 )
195 const QList<QgsRasterTransparency::TransparentThreeValuePixel> transparentThreeValueList;
202bool QgsRasterRendererRegistry::minMaxValuesForBand(
int band,
QgsRasterDataProvider *provider,
double &minValue,
double &maxValue )
const
213 if ( s.
value( QStringLiteral(
"/Raster/useStandardDeviation" ),
false ).toBool() )
217 const double stdDevFactor = s.
value( QStringLiteral(
"/Raster/defaultStandardDeviation" ), 2.0 ).toDouble();
218 const double diff = stdDevFactor * stats.
stdDev;
219 minValue = stats.
mean - diff;
220 maxValue = stats.
mean + diff;
DataType
Raster data types.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Manipulates raster or point cloud pixel values so that they enhanceContrast or clip into a specified ...
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
Factory method to create a new renderer.
Renderer for multiband images with the color components.
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
Renderer for paletted raster images.
QList< QgsPalettedRasterRenderer::Class > ClassData
Map of value to class properties.
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
static QgsPalettedRasterRenderer::ClassData colorTableToClassData(const QList< QgsColorRampShader::ColorRampItem > &table)
Converts a raster color table to paletted renderer class data.
The RasterBandStats struct is a container for statistics about a single raster band.
double mean
The mean cell value for the band. NO_DATA values are excluded.
double stdDev
The standard deviation of the cell values.
double minimumValue
The minimum cell value in the raster band.
double maximumValue
The maximum cell value in the raster band.
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
Creates an instance of the renderer based on definition from XML (used by renderer registry)
Base class for raster data providers.
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
virtual QList< QgsColorRampShader::ColorRampItem > colorTable(int bandNo) const
virtual int bandCount() const =0
Gets number of bands.
virtual QgsRasterBandStats bandStatistics(int bandNo, int stats=QgsRasterBandStats::All, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, QgsRasterBlockFeedback *feedback=nullptr)
Returns the band statistics.
void insertWidgetFunction(const QString &rendererName, QgsRasterRendererWidgetCreateFunc func)
QgsRasterRendererRegistry()
QgsRasterRenderer * defaultRendererForDrawingStyle(QgsRaster::DrawingStyle drawingStyle, QgsRasterDataProvider *provider) const
Creates a default renderer for a raster drawing style (considering user options such as default contr...
QList< QgsRasterRendererRegistryEntry > entries() const
void insert(const QgsRasterRendererRegistryEntry &entry)
bool rendererData(const QString &rendererName, QgsRasterRendererRegistryEntry &data) const
QStringList renderersList() const
Raster renderer pipe that applies colors to a raster.
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
void setRasterTransparency(QgsRasterTransparency *t)
Interface for all raster shaders.
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
void setTransparentSingleValuePixelList(const QList< QgsRasterTransparency::TransparentSingleValuePixel > &newList)
Sets the transparent single value pixel list, replacing the whole existing list.
void setTransparentThreeValuePixelList(const QList< QgsRasterTransparency::TransparentThreeValuePixel > &newList)
Sets the transparent three value pixel list, replacing the whole existing list.
DrawingStyle
This enumerator describes the different kinds of drawing we can do.
@ SingleBandColorDataStyle
@ MultiBandSingleBandGray
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Raster renderer pipe for single band color.
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
Raster renderer pipe for single band gray.
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
Raster renderer pipe for single band pseudocolor.
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
QgsRasterRendererWidget *(* QgsRasterRendererWidgetCreateFunc)(QgsRasterLayer *, const QgsRectangle &extent)
QgsRasterRenderer *(* QgsRasterRendererCreateFunc)(const QDomElement &, QgsRasterInterface *input)
Registry for raster renderer entries.
QgsRasterRendererRegistryEntry()=default
Constructor for QgsRasterRendererRegistryEntry.