QGIS API Documentation
2.0.1-Dufour
|
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 | ColorRamp_TYPE { INTERPOLATED, DISCRETE, EXACT } |
Public Member Functions | |
QgsColorRampShader (double theMinimumValue=0.0, double theMaximumValue=255.0) | |
QList < QgsColorRampShader::ColorRampItem > | colorRampItemList () const |
Get the custom colormap. | |
QgsColorRampShader::ColorRamp_TYPE | colorRampType () const |
Get the color ramp type. | |
QString | colorRampTypeAsQString () |
Get the color ramp type as a string. | |
int | maximumColorCacheSize () |
Get the maximum size the color cache can be. | |
void | setColorRampItemList (const QList< QgsColorRampShader::ColorRampItem > &theList) |
Set custom colormap. | |
void | setColorRampType (QgsColorRampShader::ColorRamp_TYPE theColorRampType) |
Set the color ramp type. | |
void | setColorRampType (QString) |
Set the color ramp type. | |
void | setMaximumColorCacheSize (int theSize) |
Set the maximum size the color cache can be. | |
bool | shade (double, int *, int *, int *, int *) |
Generates and new RGB value based on one input value. | |
bool | shade (double, double, double, double, int *, int *, int *, int *) |
Generates and new RGB value based on original RGB value. | |
void | legendSymbologyItems (QList< QPair< QString, QColor > > &symbolItems) const |
void | setClip (bool clip) |
bool | clip () const |
Public Member Functions inherited from QgsRasterShaderFunction | |
QgsRasterShaderFunction (double theMinimumValue=0.0, double theMaximumValue=255.0) | |
virtual | ~QgsRasterShaderFunction () |
virtual void | setMaximumValue (double) |
Set the maximum value. | |
virtual void | setMinimumValue (double) |
Return the minimum value. | |
double | minimumMaximumRange () const |
double | minimumValue () const |
double | maximumValue () const |
Private Member Functions | |
bool | discreteColor (double, int *, int *, int *, int *) |
Gets the color for a pixel value from the classification vector mValueClassification. | |
bool | exactColor (double, int *, int *, int *, int *) |
Gets the color for a pixel value from the classification vector mValueClassification. | |
bool | interpolatedColor (double, int *, int *, int *, int *) |
Gets the color for a pixel value from the classification vector mValueClassification. |
Private Attributes | |
int | mCurrentColorRampItemIndex |
Current index from which to start searching the color table. | |
QList < QgsColorRampShader::ColorRampItem > | mColorRampItemList |
This vector holds the information for classification based on values. | |
QgsColorRampShader::ColorRamp_TYPE | mColorRampType |
The color ramp type. | |
QMap< double, QColor > | mColorCache |
Cache of values that have already been looked up. | |
int | mMaximumColorCacheSize |
Maximum size of the color cache. | |
bool | mClip |
Do not render values out of range. |
Additional Inherited Members | |
Protected Attributes inherited from QgsRasterShaderFunction | |
double | mMaximumValue |
User defineable maximum value for the shading function. | |
double | mMinimumValue |
User defineable minimum value for the shading function. | |
double | mMinimumMaximumRange |
Minimum maximum range 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 32 of file qgscolorrampshader.h.
Definition at line 57 of file qgscolorrampshader.h.
QgsColorRampShader::QgsColorRampShader | ( | double | theMinimumValue = 0.0 , |
double | theMaximumValue = 255.0 |
||
) |
Definition at line 28 of file qgscolorrampshader.cpp.
References mCurrentColorRampItemIndex, mMaximumColorCacheSize, and QgsDebugMsg.
|
inline |
Definition at line 97 of file qgscolorrampshader.h.
Referenced by QgsSingleBandPseudoColorRendererWidget::setFromRenderer(), and QgsRasterShader::writeXML().
|
inline |
Get the custom colormap.
Definition at line 65 of file qgscolorrampshader.h.
Referenced by QgsSingleBandPseudoColorRendererWidget::setFromRenderer(), and QgsRasterShader::writeXML().
|
inline |
Get the color ramp type.
Definition at line 68 of file qgscolorrampshader.h.
Referenced by QgsSingleBandPseudoColorRendererWidget::setFromRenderer().
QString QgsColorRampShader::colorRampTypeAsQString | ( | ) |
Get the color ramp type as a string.
Definition at line 35 of file qgscolorrampshader.cpp.
References DISCRETE, EXACT, INTERPOLATED, and mColorRampType.
Referenced by QgsRasterShader::writeXML().
|
private |
Gets the color for a pixel value from the classification vector mValueClassification.
Assigns the color of the lower class for every pixel between two class breaks.
Definition at line 52 of file qgscolorrampshader.cpp.
References QgsColorRampShader::ColorRampItem::color, DOUBLE_DIFF_THRESHOLD, mColorCache, mColorRampItemList, mCurrentColorRampItemIndex, mMaximumColorCacheSize, and QgsColorRampShader::ColorRampItem::value.
Referenced by shade().
|
private |
Gets the color for a pixel value from the classification vector mValueClassification.
Assigns the color of the exact matching value in the color ramp item list
Definition at line 96 of file qgscolorrampshader.cpp.
References QgsColorRampShader::ColorRampItem::color, DOUBLE_DIFF_THRESHOLD, mColorCache, mColorRampItemList, mCurrentColorRampItemIndex, mMaximumColorCacheSize, and QgsColorRampShader::ColorRampItem::value.
Referenced by shade().
|
private |
Gets the color for a pixel value from the classification vector mValueClassification.
Interpolates the color between two class breaks linearly.
Definition at line 146 of file qgscolorrampshader.cpp.
References QgsColorRampShader::ColorRampItem::color, DOUBLE_DIFF_THRESHOLD, mClip, mColorCache, mColorRampItemList, mCurrentColorRampItemIndex, mMaximumColorCacheSize, and QgsColorRampShader::ColorRampItem::value.
Referenced by shade().
|
virtual |
Reimplemented from QgsRasterShaderFunction.
Definition at line 307 of file qgscolorrampshader.cpp.
References mColorRampItemList.
|
inline |
Get the maximum size the color cache can be.
Definition at line 74 of file qgscolorrampshader.h.
|
inline |
Definition at line 96 of file qgscolorrampshader.h.
Referenced by QgsRasterShader::readXML(), and QgsSingleBandPseudoColorRendererWidget::renderer().
void QgsColorRampShader::setColorRampItemList | ( | const QList< QgsColorRampShader::ColorRampItem > & | theList | ) |
Set custom colormap.
Definition at line 220 of file qgscolorrampshader.cpp.
References mColorCache, and mColorRampItemList.
Referenced by QgsSingleBandPseudoColorRenderer::clone(), QgsRasterLayer::paletteAsPixmap(), QgsRasterShader::readXML(), QgsSingleBandPseudoColorRendererWidget::renderer(), and QgsRasterLayer::setDataProvider().
void QgsColorRampShader::setColorRampType | ( | QgsColorRampShader::ColorRamp_TYPE | theColorRampType | ) |
Set the color ramp type.
Definition at line 227 of file qgscolorrampshader.cpp.
References mColorCache, and mColorRampType.
Referenced by QgsSingleBandPseudoColorRenderer::clone(), QgsRasterLayer::paletteAsPixmap(), QgsRasterShader::readXML(), QgsSingleBandPseudoColorRendererWidget::renderer(), and QgsRasterLayer::setDataProvider().
void QgsColorRampShader::setColorRampType | ( | QString | theType | ) |
Set the color ramp type.
Definition at line 234 of file qgscolorrampshader.cpp.
References DISCRETE, EXACT, INTERPOLATED, mColorCache, and mColorRampType.
|
inline |
Set the maximum size the color cache can be.
Definition at line 86 of file qgscolorrampshader.h.
|
virtual |
Generates and new RGB value based on one input value.
Reimplemented from QgsRasterShaderFunction.
Definition at line 252 of file qgscolorrampshader.cpp.
References discreteColor(), EXACT, exactColor(), INTERPOLATED, interpolatedColor(), mColorCache, mColorRampItemList, mColorRampType, and mCurrentColorRampItemIndex.
Referenced by QgsRasterLayer::paletteAsPixmap().
|
virtual |
Generates and new RGB value based on original RGB value.
Reimplemented from QgsRasterShaderFunction.
Definition at line 290 of file qgscolorrampshader.cpp.
|
private |
Do not render values out of range.
Definition at line 137 of file qgscolorrampshader.h.
Referenced by interpolatedColor().
|
private |
Cache of values that have already been looked up.
Definition at line 115 of file qgscolorrampshader.h.
Referenced by discreteColor(), exactColor(), interpolatedColor(), setColorRampItemList(), setColorRampType(), and shade().
|
private |
This vector holds the information for classification based on values.
Each item holds a value, a label and a color. The member mDiscreteClassification holds if one color is applied for all values between two class breaks (true) or if the item values are (linearly) interpolated for values between the item values (false)
Definition at line 109 of file qgscolorrampshader.h.
Referenced by discreteColor(), exactColor(), interpolatedColor(), legendSymbologyItems(), setColorRampItemList(), and shade().
|
private |
The color ramp type.
Definition at line 112 of file qgscolorrampshader.h.
Referenced by colorRampTypeAsQString(), setColorRampType(), and shade().
|
private |
Current index from which to start searching the color table.
Definition at line 101 of file qgscolorrampshader.h.
Referenced by discreteColor(), exactColor(), interpolatedColor(), QgsColorRampShader(), and shade().
|
private |
Maximum size of the color cache.
The color cache could eat a ton of memory if you have 32-bit data
Definition at line 119 of file qgscolorrampshader.h.
Referenced by discreteColor(), exactColor(), interpolatedColor(), and QgsColorRampShader().