QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
|
A ramp shader will color a raster pixel based on a list of values ranges in a ramp. More...
#include <qgscolorrampshader.h>
Classes | |
struct | ColorRampItem |
Public Types | |
enum | ClassificationMode { Continuous = 1 , EqualInterval = 2 , Quantile = 3 } |
Classification modes used to create the color ramp shader. More... | |
enum | Type { Interpolated , Discrete , Exact } |
Supported methods for color interpolation. More... | |
Public Member Functions | |
QgsColorRampShader (const QgsColorRampShader &other) | |
Copy constructor. | |
QgsColorRampShader (double minimumValue=0.0, double maximumValue=255.0, QgsColorRamp *colorRamp=nullptr, Type type=Interpolated, ClassificationMode classificationMode=Continuous) | |
Creates a new color ramp shader. | |
~QgsColorRampShader () override | |
ClassificationMode | 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::ColorRampItem > | colorRampItemList () const |
Returns the custom colormap. | |
Type | colorRampType () const |
Returns the color ramp type. | |
QString | colorRampTypeAsQString () const |
Returns the color ramp type as a string. | |
QgsColorRamp * | createColorRamp () const |
Creates a gradient color ramp from shader settings. | |
bool | isEmpty () const |
Whether the color ramp contains any items. | |
const QgsColorRampLegendNodeSettings * | legendSettings () 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. | |
QgsColorRampShader & | operator= (const QgsColorRampShader &other) |
Assignment operator. | |
bool | operator== (const QgsColorRampShader &other) const |
void | readXml (const QDomElement &elem, const QgsReadWriteContext &context=QgsReadWriteContext()) |
Reads configuration from the given DOM element. | |
void | setClassificationMode (ClassificationMode classificationMode) |
Sets 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 colormap. | |
void | setColorRampType (const QString &type) |
Sets the color ramp type. | |
void | setColorRampType (QgsColorRampShader::Type colorRampType) |
Sets the color ramp type. | |
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 and new RGB value based on original RGB value. | |
bool | shade (double value, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue) const override |
Generates and new RGB value based on one input value. | |
QgsColorRamp * | sourceColorRamp () 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< QgsColorRamp > | mSourceColorRamp |
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. | |
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Definition at line 42 of file qgscolorrampshader.h.
Classification modes used to create the color ramp shader.
Enumerator | |
---|---|
Continuous | Uses breaks from color palette. |
EqualInterval | Uses equal interval. |
Quantile | Uses quantile (i.e. equal pixel) count. |
Definition at line 56 of file qgscolorrampshader.h.
Supported methods for color interpolation.
Definition at line 48 of file qgscolorrampshader.h.
QgsColorRampShader::QgsColorRampShader | ( | double | minimumValue = 0.0 , |
double | maximumValue = 255.0 , |
||
QgsColorRamp * | colorRamp = nullptr , |
||
Type | type = Interpolated , |
||
ClassificationMode | classificationMode = Continuous |
||
) |
Creates a new color ramp shader.
minimumValue | minimum value for the raster shader |
maximumValue | maximum value for the raster shader |
type | interpolation type used |
classificationMode | method used to classify the color ramp shader |
colorRamp | vector color ramp used to classify the color ramp shader. Ownership is transferred to the shader. |
Definition at line 36 of file qgscolorrampshader.cpp.
|
overridedefault |
QgsColorRampShader::QgsColorRampShader | ( | const QgsColorRampShader & | other | ) |
Copy constructor.
Definition at line 49 of file qgscolorrampshader.cpp.
|
inline |
Returns the classification mode.
Definition at line 216 of file qgscolorrampshader.h.
void QgsColorRampShader::classifyColorRamp | ( | int | band = -1 , |
const QgsRectangle & | extent = QgsRectangle() , |
||
QgsRasterInterface * | input = nullptr |
||
) |
Classify color ramp shader.
band | raster band used in classification (quantile mode only) |
extent | extent used in classification (quantile mode only) |
input | raster input used in classification (quantile mode only) |
Definition at line 376 of file qgscolorrampshader.cpp.
void QgsColorRampShader::classifyColorRamp | ( | int | classes = 0 , |
int | band = -1 , |
||
const QgsRectangle & | extent = QgsRectangle() , |
||
QgsRasterInterface * | input = nullptr |
||
) |
Classify color ramp shader.
classes | number of classes |
band | raster band used in classification (only used in quantile mode) |
extent | extent used in classification (only used in quantile mode) |
input | raster input used in classification (only used in quantile mode) |
Definition at line 187 of file qgscolorrampshader.cpp.
|
inline |
Returns whether the shader will clip values which are out of range.
Definition at line 229 of file qgscolorrampshader.h.
|
inline |
Returns the custom colormap.
Definition at line 131 of file qgscolorrampshader.h.
|
inline |
Returns the color ramp type.
Definition at line 134 of file qgscolorrampshader.h.
QString QgsColorRampShader::colorRampTypeAsQString | ( | ) | const |
Returns the color ramp type as a string.
Definition at line 85 of file qgscolorrampshader.cpp.
QgsColorRamp * QgsColorRampShader::createColorRamp | ( | ) | const |
Creates a gradient color ramp from shader settings.
Definition at line 138 of file qgscolorrampshader.cpp.
bool QgsColorRampShader::isEmpty | ( | ) | const |
Whether the color ramp contains any items.
Definition at line 112 of file qgscolorrampshader.cpp.
const QgsColorRampLegendNodeSettings * QgsColorRampShader::legendSettings | ( | ) | const |
Returns the color ramp shader legend settings.
Definition at line 641 of file qgscolorrampshader.cpp.
|
overridevirtual |
Returns legend symbology items if provided by renderer.
Reimplemented from QgsRasterShaderFunction.
Definition at line 554 of file qgscolorrampshader.cpp.
QgsColorRampShader & QgsColorRampShader::operator= | ( | const QgsColorRampShader & | other | ) |
Assignment operator.
Definition at line 65 of file qgscolorrampshader.cpp.
|
inline |
Definition at line 85 of file qgscolorrampshader.h.
void QgsColorRampShader::readXml | ( | const QDomElement & | elem, |
const QgsReadWriteContext & | context = QgsReadWriteContext() |
||
) |
Reads configuration from the given DOM element.
Definition at line 599 of file qgscolorrampshader.cpp.
|
inline |
Sets classification mode.
Definition at line 213 of file qgscolorrampshader.h.
|
inline |
Sets whether the shader should not render values out of range.
clip | set to true to clip values which are out of range. |
Definition at line 223 of file qgscolorrampshader.h.
void QgsColorRampShader::setColorRampItemList | ( | const QList< QgsColorRampShader::ColorRampItem > & | list | ) |
Sets a custom colormap.
Definition at line 99 of file qgscolorrampshader.cpp.
void QgsColorRampShader::setColorRampType | ( | const QString & | type | ) |
Sets the color ramp type.
Definition at line 117 of file qgscolorrampshader.cpp.
void QgsColorRampShader::setColorRampType | ( | QgsColorRampShader::Type | colorRampType | ) |
Sets the color ramp type.
Definition at line 107 of file qgscolorrampshader.cpp.
void QgsColorRampShader::setLegendSettings | ( | QgsColorRampLegendNodeSettings * | settings | ) |
Sets the color ramp shader legend settings.
Ownership of settings is transferred.
Definition at line 646 of file qgscolorrampshader.cpp.
void QgsColorRampShader::setSourceColorRamp | ( | QgsColorRamp * | colorramp | ) |
Set the source color ramp.
Ownership is transferred to the shader.
Definition at line 182 of file qgscolorrampshader.cpp.
|
overridevirtual |
Generates and new RGB value based on original RGB value.
Reimplemented from QgsRasterShaderFunction.
Definition at line 536 of file qgscolorrampshader.cpp.
|
overridevirtual |
Generates and new RGB value based on one input value.
Reimplemented from QgsRasterShaderFunction.
Definition at line 381 of file qgscolorrampshader.cpp.
QgsColorRamp * QgsColorRampShader::sourceColorRamp | ( | ) | const |
Returns the source color ramp.
Definition at line 133 of file qgscolorrampshader.cpp.
QDomElement QgsColorRampShader::writeXml | ( | QDomDocument & | doc, |
const QgsReadWriteContext & | context = QgsReadWriteContext() |
||
) | const |
Writes configuration to a new DOM element.
Definition at line 563 of file qgscolorrampshader.cpp.
|
protected |
Source color ramp.
Definition at line 252 of file qgscolorrampshader.h.