QGIS API Documentation 3.41.0-Master (25ec5511245)
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Attributes | List of all members
QgsColorRampShader Class Reference

A ramp shader will color a raster pixel based on a list of values ranges in a ramp. More...

#include <qgscolorrampshader.h>

Inheritance diagram for QgsColorRampShader:
Inheritance graph
[legend]

Classes

struct  ColorRampItem
 

Public Member Functions

 QgsColorRampShader (const QgsColorRampShader &other)
 
 QgsColorRampShader (double minimumValue=0.0, double maximumValue=255.0, QgsColorRamp *colorRamp=nullptr, Qgis::ShaderInterpolationMethod type=Qgis::ShaderInterpolationMethod::Linear, Qgis::ShaderClassificationMethod classificationMode=Qgis::ShaderClassificationMethod::Continuous)
 Creates a new color ramp shader.
 
 ~QgsColorRampShader () override
 
Qgis::ShaderClassificationMethod classificationMode () const
 Returns the classification mode.
 
void classifyColorRamp (int band=-1, const QgsRectangle &extent=QgsRectangle(), QgsRasterInterface *input=nullptr)
 Classify color ramp shader.
 
void classifyColorRamp (int classes=0, int band=-1, const QgsRectangle &extent=QgsRectangle(), QgsRasterInterface *input=nullptr)
 Classify color ramp shader.
 
bool clip () const
 Returns whether the shader will clip values which are out of range.
 
QList< QgsColorRampShader::ColorRampItemcolorRampItemList () const
 Returns the custom color map.
 
Qgis::ShaderInterpolationMethod colorRampType () const
 Returns the color ramp interpolation method.
 
QString colorRampTypeAsQString () const
 Returns the color ramp type as a string.
 
QgsColorRampcreateColorRamp () const
 Creates a gradient color ramp from shader settings.
 
bool isEmpty () const
 Whether the color ramp contains any items.
 
const QgsColorRampLegendNodeSettingslegendSettings () const
 Returns the color ramp shader legend settings.
 
void legendSymbologyItems (QList< QPair< QString, QColor > > &symbolItems) const override
 Returns legend symbology items if provided by renderer.
 
QgsColorRampShaderoperator= (const QgsColorRampShader &other)
 
bool operator== (const QgsColorRampShader &other) const
 
void readXml (const QDomElement &elem, const QgsReadWriteContext &context=QgsReadWriteContext())
 Reads configuration from the given DOM element.
 
void setClassificationMode (Qgis::ShaderClassificationMethod classificationMode)
 Sets the classification mode.
 
void setClip (bool clip)
 Sets whether the shader should not render values out of range.
 
void setColorRampItemList (const QList< QgsColorRampShader::ColorRampItem > &list)
 Sets a custom color map.
 
void setColorRampType (const QString &type)
 Sets the color ramp type.
 
void setColorRampType (Qgis::ShaderInterpolationMethod colorRampType)
 Sets the color ramp interpolation method.
 
void setLegendSettings (QgsColorRampLegendNodeSettings *settings)
 Sets the color ramp shader legend settings.
 
void setSourceColorRamp (QgsColorRamp *colorramp)
 Set the source color ramp.
 
bool shade (double redValue, double greenValue, double blueValue, double alphaValue, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue) const override
 Generates an new RGBA value based on an original RGBA value.
 
bool shade (double value, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue) const override
 Generates an new RGBA value based on one input value.
 
QgsColorRampsourceColorRamp () const
 Returns the source color ramp.
 
QDomElement writeXml (QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext()) const
 Writes configuration to a new DOM element.
 
- Public Member Functions inherited from QgsRasterShaderFunction
 QgsRasterShaderFunction (double minimumValue=0.0, double maximumValue=255.0)
 
virtual ~QgsRasterShaderFunction ()=default
 
int labelPrecision () const
 Returns label precision.
 
double maximumValue () const
 Returns the minimum value for the raster shader.
 
double minimumMaximumRange () const
 
double minimumValue () const
 Returns the maximum value for the raster shader.
 
void setLabelPrecision (int labelPrecision)
 Sets label precision to labelPrecision.
 
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.
 

Protected Attributes

std::unique_ptr< QgsColorRampmSourceColorRamp
 Source color ramp.
 
- Protected Attributes inherited from QgsRasterShaderFunction
int mLabelPrecision = 6
 Label precision.
 
double mMaximumValue
 User defineable maximum value for the shading function.
 
double mMinimumMaximumRange
 Minimum maximum range for the shading function.
 
double mMinimumValue
 User defineable minimum value for the shading function.
 

Detailed Description

A ramp shader will color a raster pixel based on a list of values ranges in a ramp.

Definition at line 43 of file qgscolorrampshader.h.

Constructor & Destructor Documentation

◆ QgsColorRampShader() [1/2]

QgsColorRampShader::QgsColorRampShader ( double  minimumValue = 0.0,
double  maximumValue = 255.0,
QgsColorRamp colorRamp = nullptr,
Qgis::ShaderInterpolationMethod  type = Qgis::ShaderInterpolationMethod::Linear,
Qgis::ShaderClassificationMethod  classificationMode = Qgis::ShaderClassificationMethod::Continuous 
)

Creates a new color ramp shader.

Parameters
minimumValueminimum value for the raster shader
maximumValuemaximum value for the raster shader
typeinterpolation type used
classificationModemethod used to classify the color ramp shader
colorRampvector color ramp used to classify the color ramp shader. Ownership is transferred to the shader.

Definition at line 35 of file qgscolorrampshader.cpp.

◆ ~QgsColorRampShader()

QgsColorRampShader::~QgsColorRampShader ( )
overridedefault

◆ QgsColorRampShader() [2/2]

QgsColorRampShader::QgsColorRampShader ( const QgsColorRampShader other)

Definition at line 48 of file qgscolorrampshader.cpp.

Member Function Documentation

◆ classificationMode()

Qgis::ShaderClassificationMethod QgsColorRampShader::classificationMode ( ) const
inline

Returns the classification mode.

See also
setClassificationMode()

Definition at line 214 of file qgscolorrampshader.h.

◆ classifyColorRamp() [1/2]

void QgsColorRampShader::classifyColorRamp ( int  band = -1,
const QgsRectangle extent = QgsRectangle(),
QgsRasterInterface input = nullptr 
)

Classify color ramp shader.

Parameters
bandraster band used in classification (quantile mode only)
extentextent used in classification (quantile mode only)
inputraster input used in classification (quantile mode only)

Definition at line 375 of file qgscolorrampshader.cpp.

◆ classifyColorRamp() [2/2]

void QgsColorRampShader::classifyColorRamp ( int  classes = 0,
int  band = -1,
const QgsRectangle extent = QgsRectangle(),
QgsRasterInterface input = nullptr 
)

Classify color ramp shader.

Parameters
classesnumber of classes
bandraster band used in classification (only used in quantile mode)
extentextent used in classification (only used in quantile mode)
inputraster input used in classification (only used in quantile mode)

Definition at line 186 of file qgscolorrampshader.cpp.

◆ clip()

bool QgsColorRampShader::clip ( ) const
inline

Returns whether the shader will clip values which are out of range.

See also
setClip()

Definition at line 227 of file qgscolorrampshader.h.

◆ colorRampItemList()

QList< QgsColorRampShader::ColorRampItem > QgsColorRampShader::colorRampItemList ( ) const
inline

Returns the custom color map.

See also
setColorRampItemList()

Definition at line 113 of file qgscolorrampshader.h.

◆ colorRampType()

Qgis::ShaderInterpolationMethod QgsColorRampShader::colorRampType ( ) const
inline

Returns the color ramp interpolation method.

See also
setColorRampType()

Definition at line 120 of file qgscolorrampshader.h.

◆ colorRampTypeAsQString()

QString QgsColorRampShader::colorRampTypeAsQString ( ) const

Returns the color ramp type as a string.

Definition at line 84 of file qgscolorrampshader.cpp.

◆ createColorRamp()

QgsColorRamp * QgsColorRampShader::createColorRamp ( ) const

Creates a gradient color ramp from shader settings.

Since
QGIS 3.18

Definition at line 137 of file qgscolorrampshader.cpp.

◆ isEmpty()

bool QgsColorRampShader::isEmpty ( ) const

Whether the color ramp contains any items.

Since
QGIS 3.4

Definition at line 111 of file qgscolorrampshader.cpp.

◆ legendSettings()

const QgsColorRampLegendNodeSettings * QgsColorRampShader::legendSettings ( ) const

Returns the color ramp shader legend settings.

See also
setLegendSettings()
Since
QGIS 3.18

Definition at line 640 of file qgscolorrampshader.cpp.

◆ legendSymbologyItems()

void QgsColorRampShader::legendSymbologyItems ( QList< QPair< QString, QColor > > &  symbolItems) const
overridevirtual

Returns legend symbology items if provided by renderer.

Reimplemented from QgsRasterShaderFunction.

Definition at line 553 of file qgscolorrampshader.cpp.

◆ operator=()

QgsColorRampShader & QgsColorRampShader::operator= ( const QgsColorRampShader other)

Definition at line 64 of file qgscolorrampshader.cpp.

◆ operator==()

bool QgsColorRampShader::operator== ( const QgsColorRampShader other) const
inline

Definition at line 63 of file qgscolorrampshader.h.

◆ readXml()

void QgsColorRampShader::readXml ( const QDomElement &  elem,
const QgsReadWriteContext context = QgsReadWriteContext() 
)

Reads configuration from the given DOM element.

Since
QGIS 3.4

Definition at line 598 of file qgscolorrampshader.cpp.

◆ setClassificationMode()

void QgsColorRampShader::setClassificationMode ( Qgis::ShaderClassificationMethod  classificationMode)
inline

Sets the classification mode.

See also
classificationMode()

Definition at line 207 of file qgscolorrampshader.h.

◆ setClip()

void QgsColorRampShader::setClip ( bool  clip)
inline

Sets whether the shader should not render values out of range.

Parameters
clipset to true to clip values which are out of range.
See also
clip()

Definition at line 221 of file qgscolorrampshader.h.

◆ setColorRampItemList()

void QgsColorRampShader::setColorRampItemList ( const QList< QgsColorRampShader::ColorRampItem > &  list)

Sets a custom color map.

See also
colorRampItemList()

Definition at line 98 of file qgscolorrampshader.cpp.

◆ setColorRampType() [1/2]

void QgsColorRampShader::setColorRampType ( const QString &  type)

Sets the color ramp type.

Definition at line 116 of file qgscolorrampshader.cpp.

◆ setColorRampType() [2/2]

void QgsColorRampShader::setColorRampType ( Qgis::ShaderInterpolationMethod  colorRampType)

Sets the color ramp interpolation method.

See also
colorRampType()

Definition at line 106 of file qgscolorrampshader.cpp.

◆ setLegendSettings()

void QgsColorRampShader::setLegendSettings ( QgsColorRampLegendNodeSettings settings)

Sets the color ramp shader legend settings.

Ownership of settings is transferred.

See also
legendSettings()
Since
QGIS 3.18

Definition at line 645 of file qgscolorrampshader.cpp.

◆ setSourceColorRamp()

void QgsColorRampShader::setSourceColorRamp ( QgsColorRamp colorramp)

Set the source color ramp.

Ownership is transferred to the shader.

See also
sourceColorRamp()

Definition at line 181 of file qgscolorrampshader.cpp.

◆ shade() [1/2]

bool QgsColorRampShader::shade ( double  redValue,
double  greenValue,
double  blueValue,
double  alphaValue,
int *  returnRedValue,
int *  returnGreenValue,
int *  returnBlueValue,
int *  returnAlpha 
) const
overridevirtual

Generates an new RGBA value based on an original RGBA value.

Parameters
redValueThe red component of the original value to base a new RGBA value on
greenValueThe green component of the original value to base a new RGBA value on
blueValueThe blue component of the original value to base a new RGBA value on
alphaValueThe alpha component of the original value to base a new RGBA value on
returnRedValueThe red component of the new RGBA value
returnGreenValueThe green component of the new RGBA value
returnBlueValueThe blue component of the new RGBA value
returnAlphaThe alpha component of the new RGBA value
Returns
true if the return values are valid otherwise false

Reimplemented from QgsRasterShaderFunction.

Definition at line 535 of file qgscolorrampshader.cpp.

◆ shade() [2/2]

bool QgsColorRampShader::shade ( double  value,
int *  returnRedValue,
int *  returnGreenValue,
int *  returnBlueValue,
int *  returnAlpha 
) const
overridevirtual

Generates an new RGBA value based on one input value.

Parameters
valueThe original value to base a new RGBA value on
returnRedValueThe red component of the new RGBA value
returnGreenValueThe green component of the new RGBA value
returnBlueValueThe blue component of the new RGBA value
returnAlphaThe alpha component of the new RGBA value
Returns
true if the return values are valid otherwise false

Reimplemented from QgsRasterShaderFunction.

Definition at line 380 of file qgscolorrampshader.cpp.

◆ sourceColorRamp()

QgsColorRamp * QgsColorRampShader::sourceColorRamp ( ) const

Returns the source color ramp.

See also
setSourceColorRamp()

Definition at line 132 of file qgscolorrampshader.cpp.

◆ writeXml()

QDomElement QgsColorRampShader::writeXml ( QDomDocument &  doc,
const QgsReadWriteContext context = QgsReadWriteContext() 
) const

Writes configuration to a new DOM element.

Since
QGIS 3.4

Definition at line 562 of file qgscolorrampshader.cpp.

Member Data Documentation

◆ mSourceColorRamp

std::unique_ptr<QgsColorRamp> QgsColorRampShader::mSourceColorRamp
protected

Source color ramp.

Definition at line 250 of file qgscolorrampshader.h.


The documentation for this class was generated from the following files: