Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Member Functions | Private 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]
Collaboration diagram for QgsColorRampShader:
Collaboration graph
[legend]

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. More...
 
QgsColorRampShader::ColorRamp_TYPE colorRampType ()
 Get the color ramp type. More...
 
QString colorRampTypeAsQString ()
 Get the color ramp type as a string. More...
 
int maximumColorCacheSize ()
 Get the maximum size the color cache can be. More...
 
void setColorRampItemList (const QList< QgsColorRampShader::ColorRampItem > &theList)
 Set custom colormap. More...
 
void setColorRampType (QgsColorRampShader::ColorRamp_TYPE theColorRampType)
 Set the color ramp type. More...
 
void setColorRampType (QString)
 Set the color ramp type. More...
 
void setMaximumColorCacheSize (int theSize)
 Set the maximum size the color cache can be. More...
 
bool shade (double, int *, int *, int *)
 Generates and new RGB value based on one input value. More...
 
bool shade (double, double, double, int *, int *, int *)
 Generates and new RGB value based on original RGB value. More...
 
- 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. More...
 
virtual void setMinimumValue (double)
 Return the minimum value. More...
 

Private Member Functions

bool discreteColor (double, int *, int *, int *)
 Gets the color for a pixel value from the classification vector mValueClassification. More...
 
bool exactColor (double, int *, int *, int *)
 Gets the color for a pixel value from the classification vector mValueClassification. More...
 
bool interpolatedColor (double, int *, int *, int *)
 Gets the color for a pixel value from the classification vector mValueClassification. More...
 

Private Attributes

int mCurrentColorRampItemIndex
 Current index from which to start searching the color table. More...
 
QList
< QgsColorRampShader::ColorRampItem
mColorRampItemList
 This vector holds the information for classification based on values. More...
 
QgsColorRampShader::ColorRamp_TYPE mColorRampType
 The color ramp type. More...
 
QMap< double, QColor > mColorCache
 Cache of values that have already been looked up. More...
 
int mMaximumColorCacheSize
 Maximum size of the color cache. More...
 

Additional Inherited Members

- Protected Attributes inherited from QgsRasterShaderFunction
double mMaximumValue
 User defineable maximum value for the shading function. More...
 
double mMinimumValue
 User defineable minimum value for the shading function. More...
 
double mMinimumMaximumRange
 Minimum maximum range for the shading function. More...
 

Detailed Description

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.

Member Enumeration Documentation

Enumerator
INTERPOLATED 
DISCRETE 
EXACT 

Definition at line 57 of file qgscolorrampshader.h.

Constructor & Destructor Documentation

QgsColorRampShader::QgsColorRampShader ( double  theMinimumValue = 0.0,
double  theMaximumValue = 255.0 
)

Member Function Documentation

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

Get the custom colormap.

Definition at line 65 of file qgscolorrampshader.h.

QgsColorRampShader::ColorRamp_TYPE QgsColorRampShader::colorRampType ( )
inline

Get the color ramp type.

Definition at line 68 of file qgscolorrampshader.h.

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.

bool QgsColorRampShader::discreteColor ( double  theValue,
int *  theReturnRedValue,
int *  theReturnGreenValue,
int *  theReturnBlueValue 
)
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().

bool QgsColorRampShader::exactColor ( double  theValue,
int *  theReturnRedValue,
int *  theReturnGreenValue,
int *  theReturnBlueValue 
)
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 95 of file qgscolorrampshader.cpp.

References QgsColorRampShader::ColorRampItem::color, DOUBLE_DIFF_THRESHOLD, mColorCache, mColorRampItemList, mCurrentColorRampItemIndex, mMaximumColorCacheSize, and QgsColorRampShader::ColorRampItem::value.

Referenced by shade().

bool QgsColorRampShader::interpolatedColor ( double  theValue,
int *  theReturnRedValue,
int *  theReturnGreenValue,
int *  theReturnBlueValue 
)
private

Gets the color for a pixel value from the classification vector mValueClassification.

Interpolates the color between two class breaks linearly.

Definition at line 144 of file qgscolorrampshader.cpp.

References QgsColorRampShader::ColorRampItem::color, DOUBLE_DIFF_THRESHOLD, mColorCache, mColorRampItemList, mCurrentColorRampItemIndex, mMaximumColorCacheSize, and QgsColorRampShader::ColorRampItem::value.

Referenced by shade().

int QgsColorRampShader::maximumColorCacheSize ( )
inline

Get the maximum size the color cache can be.

Definition at line 74 of file qgscolorrampshader.h.

void QgsColorRampShader::setColorRampItemList ( const QList< QgsColorRampShader::ColorRampItem > &  theList)
void QgsColorRampShader::setColorRampType ( QgsColorRampShader::ColorRamp_TYPE  theColorRampType)

Set the color ramp type.

Definition at line 220 of file qgscolorrampshader.cpp.

References mColorCache, and mColorRampType.

Referenced by QgsRasterLayer::paletteAsPixmap(), QgsRasterLayer::readSymbology(), and QgsRasterLayer::setDataProvider().

void QgsColorRampShader::setColorRampType ( QString  theType)

Set the color ramp type.

Definition at line 227 of file qgscolorrampshader.cpp.

References DISCRETE, EXACT, INTERPOLATED, mColorCache, and mColorRampType.

void QgsColorRampShader::setMaximumColorCacheSize ( int  theSize)
inline

Set the maximum size the color cache can be.

Definition at line 86 of file qgscolorrampshader.h.

bool QgsColorRampShader::shade ( double  theValue,
int *  theReturnRedValue,
int *  theReturnGreenValue,
int *  theReturnBlueValue 
)
virtual

Generates and new RGB value based on one input value.

Reimplemented from QgsRasterShaderFunction.

Definition at line 245 of file qgscolorrampshader.cpp.

References discreteColor(), EXACT, exactColor(), INTERPOLATED, interpolatedColor(), mColorCache, mColorRampItemList, mColorRampType, and mCurrentColorRampItemIndex.

Referenced by QgsRasterLayer::paletteAsPixmap().

bool QgsColorRampShader::shade ( double  theRedValue,
double  theGreenValue,
double  theBlueValue,
int *  theReturnRedValue,
int *  theReturnGreenValue,
int *  theReturnBlueValue 
)
virtual

Generates and new RGB value based on original RGB value.

Reimplemented from QgsRasterShaderFunction.

Definition at line 282 of file qgscolorrampshader.cpp.

Member Data Documentation

QMap<double, QColor> QgsColorRampShader::mColorCache
private

Cache of values that have already been looked up.

Definition at line 110 of file qgscolorrampshader.h.

Referenced by discreteColor(), exactColor(), interpolatedColor(), setColorRampItemList(), setColorRampType(), and shade().

QList<QgsColorRampShader::ColorRampItem> QgsColorRampShader::mColorRampItemList
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 104 of file qgscolorrampshader.h.

Referenced by discreteColor(), exactColor(), interpolatedColor(), setColorRampItemList(), and shade().

QgsColorRampShader::ColorRamp_TYPE QgsColorRampShader::mColorRampType
private

The color ramp type.

Definition at line 107 of file qgscolorrampshader.h.

Referenced by colorRampTypeAsQString(), setColorRampType(), and shade().

int QgsColorRampShader::mCurrentColorRampItemIndex
private

Current index from which to start searching the color table.

Definition at line 96 of file qgscolorrampshader.h.

Referenced by discreteColor(), exactColor(), interpolatedColor(), QgsColorRampShader(), and shade().

int QgsColorRampShader::mMaximumColorCacheSize
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 114 of file qgscolorrampshader.h.

Referenced by discreteColor(), exactColor(), interpolatedColor(), and QgsColorRampShader().


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