Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Python bindings:
- recreate on changed .sip file
- wrapped QgsColorTable


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6776 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Mar 8, 2007
1 parent 2627281 commit 80e3d03
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 5 deletions.
6 changes: 5 additions & 1 deletion python/CMakeLists.txt
Expand Up @@ -28,6 +28,8 @@ ADD_CUSTOM_TARGET (python ALL DEPENDS ${BINDINGS_CORE_LIB} ${BINDINGS_GUI_LIB})
# don't run python before the libs are built
ADD_DEPENDENCIES (python qgis_core qgis_gui)

FILE(GLOB CORE_SIP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/core/*.sip")
FILE(GLOB GUI_SIP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/gui/*.sip")

# Step 1: during configuration
# create file configure.py from configure.py.in
Expand All @@ -41,7 +43,9 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/configure.py.in
ADD_CUSTOM_COMMAND(OUTPUT ${BINDINGS_CORE_MAKEFILE} ${BINDINGS_GUI_MAKEFILE} PRE_BUILD
COMMAND ${PYTHON_EXECUTABLE}
ARGS ${CMAKE_CURRENT_BINARY_DIR}/configure.py
DEPENDS ${QGIS_CORE_LIB} ${QGIS_GUI_LIB} ${CMAKE_CURRENT_BINARY_DIR}/configure.py)
DEPENDS ${QGIS_CORE_LIB} ${QGIS_GUI_LIB}
${CMAKE_CURRENT_BINARY_DIR}/configure.py
${CORE_SIP_FILES} ${GUI_SIP_FILES})

# Step 3: run make in core and gui subdirs
ADD_CUSTOM_COMMAND(OUTPUT ${BINDINGS_CORE_LIB} PRE_LINK
Expand Down
2 changes: 1 addition & 1 deletion python/core/core.sip
Expand Up @@ -9,7 +9,7 @@

%Include qgis.sip
%Include qgsapplication.sip
// TODO: %Include qgscolortable.sip
%Include qgscolortable.sip
%Include qgscontexthelp.sip
%Include qgscoordinatetransform.sip
%Include qgsdataprovider.sip
Expand Down
69 changes: 69 additions & 0 deletions python/core/qgscolortable.sip
@@ -0,0 +1,69 @@

class QgsColorTable
{
%TypeHeaderCode
#include <qgscolortable.h>
%End

public:
/**
* \brief Constructor.
* \param interp color table interpretation
*/
QgsColorTable ( int interp = Rgb );

/** \brief The destuctor. */
~QgsColorTable();

/** \brief Color table interpretation. */
// This is taken from GDAL, GPI_RGB is mapped to Rgba
enum Interp {
Gray = 0, // Use c1 as grayscale value.
Rgb, // Use c1 as red, c2 as green, c3 as blue
Rgba, // Use c1 as red, c2 as green, c3 as blue and c4 as alpha.
Cmyk, // Use c1 as cyan, c2 as magenta, c3 as yellow and c4 as black.
Hls // c1 hue, c2 lightness, c3 saturation; should be His ?
};

/**
* \brief Color table is defined
* \return true if at least one rule is defined
* \false no rule defined
*/
bool defined ( );

/** \brief Get color table interpretation */
int interpretation ( );

/** \brief Add a discrete color */
void add ( unsigned int index, unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4 = 0 );

/** \brief Add a ramp rule */
void add ( double min, double max,
unsigned char min_c1, unsigned char min_c2, unsigned char min_c3, unsigned char min_c4,
unsigned char max_c1, unsigned char max_c2, unsigned char max_c3, unsigned char max_c4);

/** \brief Get color
* \return true color was found
* \return false color was no found
*/
bool color ( double value, int *c1, int *c2, int *c3 );

/** \brief Sort ramp rules */
void sort ( );

/** \brief Print to stderr - for debuging */
void print ( );

/** \brief Minimum value */
double rmin();

/** \brief Maximum value */
double rmax();

/** \brief Clear the color table */
void clear();
void gack();

};

4 changes: 1 addition & 3 deletions python/core/qgsrasterbandstats.sip
Expand Up @@ -37,14 +37,12 @@ class QgsRasterBandStats
int elementCountInt;
/** \brief Store the histogram for a given layer */
typedef QVector<int> HistogramVector;
// TODO: why SIP says its unsupported?
//HistogramVector * histogramVector;
/** \brief whteher histogram values are estimated or completely calculated */
bool histogramEstimatedFlag;
/** whehter histogram compuation should include out of range values */
bool histogramOutOfRangeFlag;
/** Color table */
// TODO: not working
//QgsColorTable colorTable;
QgsColorTable colorTable;
};

0 comments on commit 80e3d03

Please sign in to comment.