Skip to content

Commit be1aaa2

Browse files
author
wonder
committed
PyQGIS: wrapped raster shaders (color ramp, freak out, pseudocolor)
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12856 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent ab9c0e9 commit be1aaa2

File tree

2 files changed

+118
-5
lines changed

2 files changed

+118
-5
lines changed

python/core/qgsrastershader.sip

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ public:
2828
*
2929
*/
3030
/** \brief generates and new RGB value based on one input value */
31-
bool shade(double, int*, int*, int*);
31+
bool shade(double, int* /Out/, int* /Out/, int* /Out/);
3232
/** \brief generates and new RGB value based on original RGB value */
33-
bool shade(double, double, double, int*, int*, int*);
33+
bool shade(double, double, double, int* /Out/, int* /Out/, int* /Out/);
3434
/** \brief A public method that allows the user to set their own shader function */
3535
void setRasterShaderFunction(QgsRasterShaderFunction*);
3636
/** \brief Set the maximum value */
3737
void setMaximumValue(double);
3838
/** \brief Return the minimum value */
3939
void setMinimumValue(double);
40-
};
40+
};

python/core/qgsrastershaderfunction.sip

+115-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,125 @@ public:
1010
virtual ~QgsRasterShaderFunction();
1111

1212
/** \brief generates and new RGB value based on one input value */
13-
virtual bool shade(double, int*, int*, int*);
13+
virtual bool shade(double, int* /Out/, int* /Out/, int* /Out/);
1414
/** \brief generates and new RGB value based on original RGB value */
15-
virtual bool shade(double, double, double, int*, int*, int*);
15+
virtual bool shade(double, double, double, int* /Out/, int* /Out/, int* /Out/);
1616

1717
/** \brief Set the maximum value */
1818
virtual void setMaximumValue(double);
1919
/** \brief Return the minimum value */
2020
virtual void setMinimumValue(double);
2121
};
22+
23+
//////////////
24+
25+
class QgsColorRampShader : QgsRasterShaderFunction
26+
{
27+
%TypeHeaderCode
28+
#include <qgscolorrampshader.h>
29+
%End
30+
31+
public:
32+
QgsColorRampShader( double theMinimumValue = 0.0, double theMaximumValue = 255.0 );
33+
34+
//An entry for classification based upon value.
35+
//Such a classification is typically used for
36+
//single band layers where a pixel value represents
37+
//not a color but a quantity, e.g. temperature or elevation
38+
struct ColorRampItem
39+
{
40+
QString label;
41+
double value;
42+
QColor color;
43+
44+
// compare operator for sorting
45+
//bool operator<( const ColorRampItem& other ) const;
46+
};
47+
48+
enum ColorRamp_TYPE
49+
{
50+
INTERPOLATED,
51+
DISCRETE,
52+
EXACT
53+
};
54+
55+
/** \brief Get the custom colormap*/
56+
QList<QgsColorRampShader::ColorRampItem> colorRampItemList() const;
57+
58+
/** \brief Get the color ramp type */
59+
QgsColorRampShader::ColorRamp_TYPE colorRampType();
60+
61+
/** \brief Get the color ramp type as a string */
62+
QString colorRampTypeAsQString();
63+
64+
/** \brief Get the maximum size the color cache can be*/
65+
int maximumColorCacheSize();
66+
67+
/** \brief Set custom colormap */
68+
void setColorRampItemList( const QList<QgsColorRampShader::ColorRampItem>& theList );
69+
70+
/** \brief Set the color ramp type*/
71+
void setColorRampType( QgsColorRampShader::ColorRamp_TYPE theColorRampType );
72+
73+
/** \brief Set the color ramp type*/
74+
void setColorRampType( QString );
75+
76+
/** \brief Set the maximum size the color cache can be */
77+
void setMaximumColorCacheSize( int theSize );
78+
79+
/** \brief Generates and new RGB value based on one input value */
80+
bool shade( double, int* /Out/, int* /Out/, int* /Out/);
81+
82+
/** \brief Generates and new RGB value based on original RGB value */
83+
bool shade( double, double, double, int* /Out/, int* /Out/, int* /Out/);
84+
85+
};
86+
87+
//////////////
88+
89+
class QgsFreakOutShader : QgsRasterShaderFunction
90+
{
91+
%TypeHeaderCode
92+
#include <qgsfreakoutshader.h>
93+
%End
94+
95+
public:
96+
QgsFreakOutShader( double theMinimumValue = 0.0, double theMaximumValue = 255.0 );
97+
98+
/** \brief generates and new RGB value based on one input value */
99+
bool shade( double, int* /Out/, int* /Out/, int* /Out/);
100+
101+
/** \brief generates and new RGB value based on original RGB value */
102+
bool shade( double, double, double, int* /Out/, int* /Out/, int* /Out/);
103+
104+
/** \brief Set the maximum value */
105+
void setMaximumValue( double );
106+
107+
/** \brief Return the minimum value */
108+
void setMinimumValue( double );
109+
};
110+
111+
//////////////
112+
113+
class QgsPseudoColorShader : QgsRasterShaderFunction
114+
{
115+
%TypeHeaderCode
116+
#include <qgspseudocolorshader.h>
117+
%End
118+
119+
public:
120+
QgsPseudoColorShader( double theMinimumValue = 0.0, double theMaximumValue = 255.0 );
121+
122+
/** \brief generates and new RGB value based on one input value */
123+
bool shade( double, int* /Out/, int* /Out/, int* /Out/);
124+
125+
/** \brief generates and new RGB value based on original RGB value */
126+
bool shade( double, double, double, int* /Out/, int* /Out/, int* /Out/);
127+
128+
/** \brief Set the maximum value */
129+
void setMaximumValue( double );
130+
131+
/** \brief Return the minimum value */
132+
void setMinimumValue( double );
133+
134+
};

0 commit comments

Comments
 (0)