QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgssinglebandpseudocolorrenderer.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgssinglebandpseudocolorrenderer.cpp
3 ------------------------------------
4 begin : January 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
20#include "qgscolorramp.h"
22#include "qgscolorrampshader.h"
23#include "qgsrastershader.h"
25#include "qgssldexportcontext.h"
27
28#include <QDomDocument>
29#include <QDomElement>
30#include <QImage>
31
33 : QgsRasterRenderer( input, QStringLiteral( "singlebandpseudocolor" ) )
34 , mShader( shader )
35 , mBand( band )
36 , mClassificationMin( std::numeric_limits<double>::quiet_NaN() )
37 , mClassificationMax( std::numeric_limits<double>::quiet_NaN() )
38{
39}
40
42{
43 setInputBand( bandNo );
44}
45
47{
48 return mBand;
49}
50
52{
53 if ( !mInput )
54 {
55 mBand = band;
56 return true;
57 }
58 else if ( band > 0 && band <= mInput->bandCount() )
59 {
60 mBand = band;
61 return true;
62 }
63 return false;
64}
65
67{
68 mClassificationMin = min;
69 if ( auto *lShader = shader() )
70 {
71 QgsColorRampShader *colorRampShader = dynamic_cast<QgsColorRampShader *>( lShader->rasterShaderFunction() );
72 if ( colorRampShader )
73 {
74 colorRampShader->setMinimumValue( min );
75 }
76 }
77}
78
80{
81 mClassificationMax = max;
82 if ( auto *lShader = shader() )
83 {
84 QgsColorRampShader *colorRampShader = dynamic_cast<QgsColorRampShader *>( lShader->rasterShaderFunction() );
85 if ( colorRampShader )
86 {
87 colorRampShader->setMaximumValue( max );
88 }
89 }
90}
91
93{
94 QgsRasterShader *shader = nullptr;
95
96 if ( mShader )
97 {
98 shader = new QgsRasterShader( mShader->minimumValue(), mShader->maximumValue() );
99
100 // Shader function
101 const QgsColorRampShader *origColorRampShader = dynamic_cast<const QgsColorRampShader *>( mShader->rasterShaderFunction() );
102
103 if ( origColorRampShader )
104 {
105 QgsColorRampShader *colorRampShader = new QgsColorRampShader( *origColorRampShader );
106 shader->setRasterShaderFunction( colorRampShader );
107 }
108 }
110 renderer->copyCommonProperties( this );
111
112 return renderer;
113}
114
119
124
126{
127 if ( mBand == -1 || classificationMin() >= classificationMax() )
128 {
129 return;
130 }
131
132 QgsColorRampShader *colorRampShader = new QgsColorRampShader( classificationMin(), classificationMax(), colorRamp, colorRampType, classificationMode );
133 colorRampShader->classifyColorRamp( classes, mBand, extent, input() );
134 colorRampShader->setClip( clip );
135
136 QgsRasterShader *rasterShader = new QgsRasterShader();
137 rasterShader->setRasterShaderFunction( colorRampShader );
138 setShader( rasterShader );
139}
140
142{
143 if ( elem.isNull() )
144 {
145 return nullptr;
146 }
147
148 const int band = elem.attribute( QStringLiteral( "band" ), QStringLiteral( "-1" ) ).toInt();
149 QgsRasterShader *shader = nullptr;
150 const QDomElement rasterShaderElem = elem.firstChildElement( QStringLiteral( "rastershader" ) );
151 if ( !rasterShaderElem.isNull() )
152 {
153 shader = new QgsRasterShader();
154 shader->readXml( rasterShaderElem );
155 }
156
158 r->readXml( elem );
159
160 // TODO: add _readXML in superclass?
161 r->setClassificationMin( elem.attribute( QStringLiteral( "classificationMin" ), QStringLiteral( "NaN" ) ).toDouble() );
162 r->setClassificationMax( elem.attribute( QStringLiteral( "classificationMax" ), QStringLiteral( "NaN" ) ).toDouble() );
163
164 // Backward compatibility with serialization of QGIS 2.X era
165 const QString minMaxOrigin = elem.attribute( QStringLiteral( "classificationMinMaxOrigin" ) );
166 if ( !minMaxOrigin.isEmpty() )
167 {
168 if ( minMaxOrigin.contains( QLatin1String( "MinMax" ) ) )
169 {
171 }
172 else if ( minMaxOrigin.contains( QLatin1String( "CumulativeCut" ) ) )
173 {
175 }
176 else if ( minMaxOrigin.contains( QLatin1String( "StdDev" ) ) )
177 {
179 }
180 else
181 {
183 }
184
185 if ( minMaxOrigin.contains( QLatin1String( "FullExtent" ) ) )
186 {
188 }
189 else if ( minMaxOrigin.contains( QLatin1String( "SubExtent" ) ) )
190 {
192 }
193 else
194 {
196 }
197
198 if ( minMaxOrigin.contains( QLatin1String( "Estimated" ) ) )
199 {
201 }
202 else // if ( minMaxOrigin.contains( QLatin1String( "Exact" ) ) )
203 {
205 }
206 }
207
208 return r;
209}
210
212{
213 Q_UNUSED( bandNo )
214
215 auto outputBlock = std::make_unique<QgsRasterBlock>();
216 if ( !mInput || !mShader || !mShader->rasterShaderFunction() )
217 {
218 return outputBlock.release();
219 }
220
221
222 const std::shared_ptr< QgsRasterBlock > inputBlock( mInput->block( mBand, extent, width, height, feedback ) );
223 if ( !inputBlock || inputBlock->isEmpty() )
224 {
225 QgsDebugError( QStringLiteral( "No raster data!" ) );
226 return outputBlock.release();
227 }
228
229 //rendering is faster without considering user-defined transparency
230 const bool hasTransparency = usesTransparency();
231
232 std::shared_ptr< QgsRasterBlock > alphaBlock;
233 if ( mAlphaBand > 0 && mAlphaBand != mBand )
234 {
235 alphaBlock.reset( mInput->block( mAlphaBand, extent, width, height, feedback ) );
236 if ( !alphaBlock || alphaBlock->isEmpty() )
237 {
238 return outputBlock.release();
239 }
240 }
241 else if ( mAlphaBand == mBand )
242 {
243 alphaBlock = inputBlock;
244 }
245
246 if ( !outputBlock->reset( Qgis::DataType::ARGB32_Premultiplied, width, height ) )
247 {
248 return outputBlock.release();
249 }
250
251 const QRgb myDefaultColor = renderColorForNodataPixel();
252 QRgb *outputBlockData = outputBlock->colorData();
253 const QgsRasterShaderFunction *fcn = mShader->rasterShaderFunction();
254
255 const qgssize count = ( qgssize )width * height;
256 bool isNoData = false;
257 for ( qgssize i = 0; i < count; i++ )
258 {
259 const double val = inputBlock->valueAndNoData( i, isNoData );
260 if ( isNoData )
261 {
262 outputBlockData[i] = myDefaultColor;
263 continue;
264 }
265
266 int red, green, blue, alpha;
267 if ( !fcn->shade( val, &red, &green, &blue, &alpha ) )
268 {
269 outputBlockData[i] = myDefaultColor;
270 continue;
271 }
272
273 if ( alpha < 255 )
274 {
275 // Working with premultiplied colors, so multiply values by alpha
276 red *= ( alpha / 255.0 );
277 blue *= ( alpha / 255.0 );
278 green *= ( alpha / 255.0 );
279 }
280
281 if ( !hasTransparency )
282 {
283 outputBlockData[i] = qRgba( red, green, blue, alpha );
284 }
285 else
286 {
287 //opacity
288 double currentOpacity = mOpacity;
290 {
291 currentOpacity *= mRasterTransparency->opacityForValue( val );
292 }
293 if ( mAlphaBand > 0 )
294 {
295 const double alpha = alphaBlock->value( i );
296 if ( alpha == 0 )
297 {
298 outputBlock->setColor( i, myDefaultColor );
299 continue;
300 }
301 else
302 {
303 currentOpacity *= alpha / 255.0;
304 }
305 }
306
307 outputBlockData[i] = qRgba( currentOpacity * red, currentOpacity * green, currentOpacity * blue, currentOpacity * alpha );
308 }
309 }
310
311 return outputBlock.release();
312}
313
314void QgsSingleBandPseudoColorRenderer::writeXml( QDomDocument &doc, QDomElement &parentElem ) const
315{
316 if ( parentElem.isNull() )
317 {
318 return;
319 }
320
321 QDomElement rasterRendererElem = doc.createElement( QStringLiteral( "rasterrenderer" ) );
322 _writeXml( doc, rasterRendererElem );
323 rasterRendererElem.setAttribute( QStringLiteral( "band" ), mBand );
324 if ( mShader )
325 {
326 mShader->writeXml( doc, rasterRendererElem ); //todo: include color ramp items directly in this renderer
327 }
328 rasterRendererElem.setAttribute( QStringLiteral( "classificationMin" ), QgsRasterBlock::printValue( mClassificationMin ) );
329 rasterRendererElem.setAttribute( QStringLiteral( "classificationMax" ), QgsRasterBlock::printValue( mClassificationMax ) );
330
331 parentElem.appendChild( rasterRendererElem );
332}
333
334QList< QPair< QString, QColor > > QgsSingleBandPseudoColorRenderer::legendSymbologyItems() const
335{
336 QList< QPair< QString, QColor > > symbolItems;
337 if ( mShader )
338 {
339 QgsRasterShaderFunction *shaderFunction = mShader->rasterShaderFunction();
340 if ( shaderFunction )
341 {
342 shaderFunction->legendSymbologyItems( symbolItems );
343 }
344 }
345 return symbolItems;
346}
347
349{
350 QList<int> bandList;
351 if ( mBand != -1 )
352 {
353 bandList << mBand;
354 }
355 return bandList;
356}
357
358void QgsSingleBandPseudoColorRenderer::toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const
359{
360 QgsSldExportContext context;
361 context.setExtraProperties( props );
362 toSld( doc, element, context );
363}
364
365bool QgsSingleBandPseudoColorRenderer::toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const
366{
367 // create base structure
368 QgsRasterRenderer::toSld( doc, element, context );
369
370 // look for RasterSymbolizer tag
371 const QDomNodeList elements = element.elementsByTagName( QStringLiteral( "sld:RasterSymbolizer" ) );
372 if ( elements.size() == 0 )
373 return false;
374
375 // there SHOULD be only one
376 QDomElement rasterSymbolizerElem = elements.at( 0 ).toElement();
377
378 // add Channel Selection tags
379 QDomElement channelSelectionElem = doc.createElement( QStringLiteral( "sld:ChannelSelection" ) );
380 rasterSymbolizerElem.appendChild( channelSelectionElem );
381
382 // for the mapped band
383 QDomElement channelElem = doc.createElement( QStringLiteral( "sld:GrayChannel" ) );
384 channelSelectionElem.appendChild( channelElem );
385
386 // set band
387 QDomElement sourceChannelNameElem = doc.createElement( QStringLiteral( "sld:SourceChannelName" ) );
388 sourceChannelNameElem.appendChild( doc.createTextNode( QString::number( mBand ) ) );
389 channelElem.appendChild( sourceChannelNameElem );
390
391 // add ColorMap tag
392 QDomElement colorMapElem = doc.createElement( QStringLiteral( "sld:ColorMap" ) );
393
394 // set type of ColorMap ramp [ramp, intervals, values]
395 // basing on interpolation algorithm of the raster shader
396 QString rampType = QStringLiteral( "ramp" );
397 const QgsColorRampShader *rampShader = dynamic_cast<const QgsColorRampShader *>( mShader->rasterShaderFunction() );
398 if ( !rampShader )
399 return false;
400
401 switch ( rampShader->colorRampType() )
402 {
404 rampType = QStringLiteral( "values" );
405 break;
407 rampType = QStringLiteral( "intervals" );
408 break;
410 rampType = QStringLiteral( "ramp" );
411 break;
412 }
413
414 colorMapElem.setAttribute( QStringLiteral( "type" ), rampType );
415 if ( rampShader->colorRampItemList().size() >= 255 )
416 colorMapElem.setAttribute( QStringLiteral( "extended" ), QStringLiteral( "true" ) );
417 rasterSymbolizerElem.appendChild( colorMapElem );
418
419 // for each color set a ColorMapEntry tag nested into "sld:ColorMap" tag
420 // e.g. <ColorMapEntry color="#EEBE2F" quantity="-300" label="label" opacity="0"/>
421 const QList<QgsColorRampShader::ColorRampItem> classes = rampShader->colorRampItemList();
422 QList<QgsColorRampShader::ColorRampItem>::const_iterator classDataIt = classes.constBegin();
423 for ( ; classDataIt != classes.constEnd(); ++classDataIt )
424 {
425 QDomElement colorMapEntryElem = doc.createElement( QStringLiteral( "sld:ColorMapEntry" ) );
426 colorMapElem.appendChild( colorMapEntryElem );
427
428 // set colorMapEntryElem attributes
429 colorMapEntryElem.setAttribute( QStringLiteral( "color" ), classDataIt->color.name() );
430 colorMapEntryElem.setAttribute( QStringLiteral( "quantity" ), classDataIt->value );
431 colorMapEntryElem.setAttribute( QStringLiteral( "label" ), classDataIt->label );
432 if ( classDataIt->color.alphaF() != 1.0 )
433 {
434 colorMapEntryElem.setAttribute( QStringLiteral( "opacity" ), QString::number( classDataIt->color.alphaF() ) );
435 }
436 }
437 return true;
438}
439
441{
442 if ( const QgsColorRampShader *shader = dynamic_cast< const QgsColorRampShader * >( mShader->rasterShaderFunction() ) )
443 {
444 QgsStyleColorRampEntity entity( shader->sourceColorRamp() );
445 if ( !visitor->visit( QgsStyleEntityVisitorInterface::StyleLeaf( &entity ) ) )
446 return false;
447 }
448
449 return true;
450}
451
452QList<QgsLayerTreeModelLegendNode *> QgsSingleBandPseudoColorRenderer::createLegendNodes( QgsLayerTreeLayer *nodeLayer )
453{
454 if ( !mShader )
455 return QList<QgsLayerTreeModelLegendNode *>();
456
457 const QgsColorRampShader *rampShader = dynamic_cast<const QgsColorRampShader *>( mShader->rasterShaderFunction() );
458 if ( !rampShader )
459 return QList<QgsLayerTreeModelLegendNode *>();
460
461 QList<QgsLayerTreeModelLegendNode *> res;
462
463 const QString name = displayBandName( mBand );
464 if ( !name.isEmpty() )
465 {
466 res << new QgsSimpleLegendNode( nodeLayer, name );
467 }
468
469 switch ( rampShader->colorRampType() )
470 {
472 // for interpolated shaders we use a ramp legend node unless the settings flag
473 // to use the continuous legend is not set, in that case we fall through
474 if ( ! rampShader->legendSettings() || rampShader->legendSettings()->useContinuousLegend() )
475 {
476 if ( !rampShader->colorRampItemList().isEmpty() )
477 {
478 res << new QgsColorRampLegendNode( nodeLayer, rampShader->createColorRamp(),
479 rampShader->legendSettings() ? *rampShader->legendSettings() : QgsColorRampLegendNodeSettings(),
480 rampShader->minimumValue(), rampShader->maximumValue() );
481 }
482 break;
483 }
484 [[fallthrough]];
487 {
488 // for all others we use itemised lists
489 const QList< QPair< QString, QColor > > items = legendSymbologyItems();
490 res.reserve( items.size() );
491 for ( const QPair< QString, QColor > &item : items )
492 {
493 res << new QgsRasterSymbolLegendNode( nodeLayer, item.second, item.first );
494 }
495 break;
496 }
497 }
498 return res;
499}
500
505
506bool QgsSingleBandPseudoColorRenderer::refresh( const QgsRectangle &extent, const QList<double> &min, const QList<double> &max, bool force )
507{
508 if ( !needsRefresh( extent ) && !force )
509 {
510 return false;
511 }
512
513 bool refreshed = false;
514 if ( min.size() >= 1 && max.size() >= 1 )
515 {
517
518 // Do not overwrite min/max with NaN if they were already set,
519 // for example when the style was already loaded from a raster attribute table
520 // in that case we need to respect the style from the attribute table and do
521 // not perform any reclassification.
522 bool refreshed = false;
523
524 if ( !std::isnan( min[0] ) )
525 {
526 setClassificationMin( min[0] );
527 refreshed = true;
528 }
529
530 if ( !std::isnan( max[0] ) )
531 {
532 setClassificationMax( max[0] );
533 refreshed = true;
534 }
535
536 QgsColorRampShader *rampShader = dynamic_cast<QgsColorRampShader *>( mShader->rasterShaderFunction() );
537 if ( rampShader && refreshed )
538 {
539 rampShader->classifyColorRamp( mBand, extent, input() );
540 }
541 }
542
543 return refreshed;
544}
545
QFlags< RasterRendererFlag > RasterRendererFlags
Flags which control behavior of raster renderers.
Definition qgis.h:1512
@ CumulativeCut
Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ].
Definition qgis.h:1548
@ StdDev
Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ].
Definition qgis.h:1547
@ MinimumMaximum
Real min-max values.
Definition qgis.h:1546
@ NotSet
User defined.
Definition qgis.h:1545
ShaderInterpolationMethod
Color ramp shader interpolation methods.
Definition qgis.h:1425
@ Exact
Assigns the color of the exact matching value in the color ramp item list.
Definition qgis.h:1428
@ Linear
Interpolates the color between two class breaks linearly.
Definition qgis.h:1426
@ Discrete
Assigns the color of the higher class for every pixel between two class breaks.
Definition qgis.h:1427
@ InternalLayerOpacityHandling
The renderer internally handles the raster layer's opacity, so the default layer level opacity handli...
Definition qgis.h:1503
@ Exact
Exact statistics.
Definition qgis.h:1576
@ Estimated
Approximated statistics.
Definition qgis.h:1577
ShaderClassificationMethod
Color ramp shader classification methods.
Definition qgis.h:1440
@ ARGB32_Premultiplied
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
Definition qgis.h:387
@ WholeRaster
Whole raster is used to compute statistics.
Definition qgis.h:1561
@ FixedCanvas
Current extent of the canvas (at the time of computation) is used to compute statistics.
Definition qgis.h:1562
Settings for a color ramp legend node.
bool useContinuousLegend() const
Returns true if a continuous gradient legend will be used.
A legend node which renders a color ramp.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Qgis::ShaderInterpolationMethod colorRampType() const
Returns the color ramp interpolation method.
const QgsColorRampLegendNodeSettings * legendSettings() const
Returns the color ramp shader legend settings.
QList< QgsColorRampShader::ColorRampItem > colorRampItemList() const
Returns the custom color map.
void setClip(bool clip)
Sets whether the shader should not render values out of range.
QgsColorRamp * createColorRamp() const
Creates a gradient color ramp from shader settings.
void classifyColorRamp(int classes=0, int band=-1, const QgsRectangle &extent=QgsRectangle(), QgsRasterInterface *input=nullptr)
Classify color ramp shader.
Abstract base class for color ramps.
Layer tree node points to a map layer.
Feedback object tailored for raster block reading.
Raster data container.
static QString printValue(double value, bool localized=false)
Print double value with all necessary significant digits.
QgsRasterInterface(QgsRasterInterface *input=nullptr)
QString displayBandName(int bandNumber) const
Generates a friendly, descriptive name for the specified bandNumber.
QgsRasterInterface * mInput
virtual QgsRectangle extent() const
Gets the extent of the interface.
virtual QgsRasterInterface * input() const
Current input.
void setLimits(Qgis::RasterRangeLimit limits)
Sets the limits.
void setExtent(Qgis::RasterRangeExtent extent)
Sets the extent.
void setStatAccuracy(Qgis::RasterRangeAccuracy accuracy)
Sets the statistics accuracy.
QgsRasterRenderer(QgsRasterInterface *input=nullptr, const QString &type=QString())
Constructor for QgsRasterRenderer.
double mOpacity
Global alpha value (0-1).
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.
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.
void _writeXml(QDomDocument &doc, QDomElement &rasterRendererElem) const
Write upper class info into rasterrenderer element (called by writeXml method of subclasses).
int bandCount() const override
Gets number of bands.
QgsRasterMinMaxOrigin mMinMaxOrigin
Origin of min/max values.
bool usesTransparency() const
void copyCommonProperties(const QgsRasterRenderer *other, bool copyMinMaxOrigin=true)
Copies common properties like opacity / transparency data from other renderer.
bool needsRefresh(const QgsRectangle &extent) const
Checks if the renderer needs to be refreshed according to extent.
virtual Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const
Used from subclasses to create SLD Rule elements following SLD v1.0 specs.
void readXml(const QDomElement &rendererElem) override
Sets base class members from xml. Usually called from create() methods of subclasses.
The raster shade function applies a shader to a pixel at render time - typically used to render grays...
virtual void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const
Returns legend symbology items if provided by renderer.
double maximumValue() const
Returns the minimum value for the raster shader.
virtual bool shade(double value, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlpha) const
Generates an new RGBA value based on one input value.
virtual void setMaximumValue(double value)
Sets the maximum value for the raster shader.
virtual void setMinimumValue(double value)
Sets the minimum value for the raster shader.
double minimumValue() const
Returns the maximum value for the raster shader.
Interface for all raster shaders.
void setRasterShaderFunction(QgsRasterShaderFunction *function)
A public method that allows the user to set their own shader function.
Implementation of legend node interface for displaying raster legend entries.
A rectangle specified with double values.
Implementation of legend node interface for displaying arbitrary labels with icons.
QgsSingleBandPseudoColorRenderer * clone() const override
Clone itself, create deep copy.
QList< QPair< QString, QColor > > legendSymbologyItems() const override
Returns symbology items if provided by renderer.
void writeXml(QDomDocument &doc, QDomElement &parentElem) const override
Write base class members to xml.
Q_DECL_DEPRECATED void setBand(int bandNo)
Sets the band used by the renderer.
void setShader(QgsRasterShader *shader)
Takes ownership of the shader.
QList< QgsLayerTreeModelLegendNode * > createLegendNodes(QgsLayerTreeLayer *nodeLayer) override
Creates a set of legend nodes representing the renderer.
QgsRasterShader * shader()
Returns the raster shader.
QList< int > usesBands() const override
Returns a list of band numbers used by the renderer.
bool refresh(const QgsRectangle &extent, const QList< double > &min, const QList< double > &max, bool forceRefresh=false) override
Refreshes the renderer according to the min and max values associated with the extent.
bool setInputBand(int band) override
Attempts to set the input band for the renderer.
QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr) override
Read block of data using given extent and size.
Qgis::RasterRendererFlags flags() const override
Returns flags which dictate renderer behavior.
QgsSingleBandPseudoColorRenderer(QgsRasterInterface *input, int band=-1, QgsRasterShader *shader=nullptr)
Note: takes ownership of QgsRasterShader.
int inputBand() const override
Returns the input band for the renderer, or -1 if no input band is available.
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
void createShader(QgsColorRamp *colorRamp=nullptr, Qgis::ShaderInterpolationMethod colorRampType=Qgis::ShaderInterpolationMethod::Linear, Qgis::ShaderClassificationMethod classificationMode=Qgis::ShaderClassificationMethod::Continuous, int classes=0, bool clip=false, const QgsRectangle &extent=QgsRectangle())
Creates a color ramp shader.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
bool canCreateRasterAttributeTable() const override
Returns true if the renderer is suitable for attribute table creation.
Q_DECL_DEPRECATED int band() const
Returns the band used by the renderer.
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const override
Used from subclasses to create SLD Rule elements following SLD v1.0 specs.
Holds SLD export options and other information related to SLD export of a QGIS layer style.
void setExtraProperties(const QVariantMap &properties)
Sets the open ended set of properties that can drive/inform the SLD encoding.
A color ramp entity for QgsStyle databases.
Definition qgsstyle.h:1429
An interface for classes which can visit style entity (e.g.
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
unsigned long long qgssize
Qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be har...
Definition qgis.h:7142
#define QgsDebugError(str)
Definition qgslogger.h:57
Contains information relating to the style entity currently being visited.