Skip to content

Commit

Permalink
PyQGIS: wrapped raster shaders (color ramp, freak out, pseudocolor)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12856 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Feb 1, 2010
1 parent 121044e commit 704f2b8
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 5 deletions.
6 changes: 3 additions & 3 deletions python/core/qgsrastershader.sip
Expand Up @@ -28,13 +28,13 @@ public:
*
*/
/** \brief generates and new RGB value based on one input value */
bool shade(double, int*, int*, int*);
bool shade(double, int* /Out/, int* /Out/, int* /Out/);
/** \brief generates and new RGB value based on original RGB value */
bool shade(double, double, double, int*, int*, int*);
bool shade(double, double, double, int* /Out/, int* /Out/, int* /Out/);
/** \brief A public method that allows the user to set their own shader function */
void setRasterShaderFunction(QgsRasterShaderFunction*);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
void setMinimumValue(double);
};
};
117 changes: 115 additions & 2 deletions python/core/qgsrastershaderfunction.sip
Expand Up @@ -10,12 +10,125 @@ public:
virtual ~QgsRasterShaderFunction();

/** \brief generates and new RGB value based on one input value */
virtual bool shade(double, int*, int*, int*);
virtual bool shade(double, int* /Out/, int* /Out/, int* /Out/);
/** \brief generates and new RGB value based on original RGB value */
virtual bool shade(double, double, double, int*, int*, int*);
virtual bool shade(double, double, double, int* /Out/, int* /Out/, int* /Out/);

/** \brief Set the maximum value */
virtual void setMaximumValue(double);
/** \brief Return the minimum value */
virtual void setMinimumValue(double);
};

//////////////

class QgsColorRampShader : QgsRasterShaderFunction
{
%TypeHeaderCode
#include <qgscolorrampshader.h>
%End

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

//An entry for classification based upon value.
//Such a classification is typically used for
//single band layers where a pixel value represents
//not a color but a quantity, e.g. temperature or elevation
struct ColorRampItem
{
QString label;
double value;
QColor color;

// compare operator for sorting
//bool operator<( const ColorRampItem& other ) const;
};

enum ColorRamp_TYPE
{
INTERPOLATED,
DISCRETE,
EXACT
};

/** \brief Get the custom colormap*/
QList<QgsColorRampShader::ColorRampItem> colorRampItemList() const;

/** \brief Get the color ramp type */
QgsColorRampShader::ColorRamp_TYPE colorRampType();

/** \brief Get the color ramp type as a string */
QString colorRampTypeAsQString();

/** \brief Get the maximum size the color cache can be*/
int maximumColorCacheSize();

/** \brief Set custom colormap */
void setColorRampItemList( const QList<QgsColorRampShader::ColorRampItem>& theList );

/** \brief Set the color ramp type*/
void setColorRampType( QgsColorRampShader::ColorRamp_TYPE theColorRampType );

/** \brief Set the color ramp type*/
void setColorRampType( QString );

/** \brief Set the maximum size the color cache can be */
void setMaximumColorCacheSize( int theSize );

/** \brief Generates and new RGB value based on one input value */
bool shade( double, int* /Out/, int* /Out/, int* /Out/);

/** \brief Generates and new RGB value based on original RGB value */
bool shade( double, double, double, int* /Out/, int* /Out/, int* /Out/);

};

//////////////

class QgsFreakOutShader : QgsRasterShaderFunction
{
%TypeHeaderCode
#include <qgsfreakoutshader.h>
%End

public:
QgsFreakOutShader( double theMinimumValue = 0.0, double theMaximumValue = 255.0 );

/** \brief generates and new RGB value based on one input value */
bool shade( double, int* /Out/, int* /Out/, int* /Out/);

/** \brief generates and new RGB value based on original RGB value */
bool shade( double, double, double, int* /Out/, int* /Out/, int* /Out/);

/** \brief Set the maximum value */
void setMaximumValue( double );

/** \brief Return the minimum value */
void setMinimumValue( double );
};

//////////////

class QgsPseudoColorShader : QgsRasterShaderFunction
{
%TypeHeaderCode
#include <qgspseudocolorshader.h>
%End

public:
QgsPseudoColorShader( double theMinimumValue = 0.0, double theMaximumValue = 255.0 );

/** \brief generates and new RGB value based on one input value */
bool shade( double, int* /Out/, int* /Out/, int* /Out/);

/** \brief generates and new RGB value based on original RGB value */
bool shade( double, double, double, int* /Out/, int* /Out/, int* /Out/);

/** \brief Set the maximum value */
void setMaximumValue( double );

/** \brief Return the minimum value */
void setMinimumValue( double );

};

0 comments on commit 704f2b8

Please sign in to comment.