Skip to content
Permalink
Browse files
Raster shader fixes:
- memory leaks when changing shader functions
- PyQGIS: subclassing of raster shader function instances
- PyQGIS: transfer ownership of the shader function to c++


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14022 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Aug 7, 2010
1 parent a92f86a commit 38e5d5914824b56f2a2505354fe8ea272f442d86
@@ -426,8 +426,9 @@ public:
/** \brief Mutator that allows the NO_DATA entry for this raster to be overridden */
void setNoDataValue( double theNoData );

/** \brief Set the raster shader function to a user defined function */
void setRasterShaderFunction( QgsRasterShaderFunction* theFunction );
/** \brief Set the raster shader function to a user defined function
\note ownership of the shader function is transfered to raster shader */
void setRasterShaderFunction( QgsRasterShaderFunction* theFunction /Transfer/ );

/** \brief Mutator for red band name (allows alternate mappings e.g. map blue as red color) */
void setRedBandName( const QString & theBandName );
@@ -31,8 +31,9 @@ public:
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 A public method that allows the user to set their own shader function */
void setRasterShaderFunction(QgsRasterShaderFunction*);
/** \brief A public method that allows the user to set their own shader function
\note Raster shader takes ownership of the shader function instance */
void setRasterShaderFunction(QgsRasterShaderFunction* /Transfer/);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
@@ -3,8 +3,23 @@ class QgsRasterShaderFunction
{
%TypeHeaderCode
#include <qgsrastershaderfunction.h>
#include <qgscolorrampshader.h>
#include <qgsfreakoutshader.h>
#include <qgspseudocolorshader.h>
%End

%ConvertToSubClassCode
if (dynamic_cast<QgsColorRampShader*>(sipCpp) != NULL)
sipClass = sipClass_QgsColorRampShader;
else if (dynamic_cast<QgsFreakOutShader*>(sipCpp) != NULL)
sipClass = sipClass_QgsFreakOutShader;
else if (dynamic_cast<QgsPseudoColorShader*>(sipCpp) != NULL)
sipClass = sipClass_QgsPseudoColorShader;
else
sipClass = 0;
%End


public:
QgsRasterShaderFunction(double theMinimumValue = 0.0, double theMaximumValue = 255.0);
virtual ~QgsRasterShaderFunction();
@@ -3525,12 +3525,6 @@ void QgsRasterLayer::setNoDataValue( double theNoDataValue )

void QgsRasterLayer::setRasterShaderFunction( QgsRasterShaderFunction* theFunction )
{
//Free old shader if it is not a userdefined shader
if ( mColorShadingAlgorithm != QgsRasterLayer::UserDefinedShader && 0 != mRasterShader->rasterShaderFunction() )
{
delete( mRasterShader->rasterShaderFunction() );
}

if ( theFunction )
{
mRasterShader->setRasterShaderFunction( theFunction );
@@ -449,8 +449,8 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer

/** \brief Compute the actual minimum maximum pixel values based on the current (last) display extent */
void computeMinimumMaximumFromLastExtent( QString theBand, double* theMinMax );
/** \brief Compute the actual minimum maximum pixel values based on the current (last) display extent

/** \brief Compute the actual minimum maximum pixel values based on the current (last) display extent
\note added in v1.6 */
void computeMinimumMaximumFromLastExtent( int theBand, double& theMin, double& theMax );

@@ -592,7 +592,8 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
/** \brief Mutator that allows the NO_DATA entry for this raster to be overridden */
void setNoDataValue( double theNoData );

/** \brief Set the raster shader function to a user defined function */
/** \brief Set the raster shader function to a user defined function
\note ownership of the shader function is transfered to raster shader */
void setRasterShaderFunction( QgsRasterShaderFunction* theFunction );

/** \brief Mutator for red band name (allows alternate mappings e.g. map blue as red color) */
@@ -31,6 +31,7 @@ QgsRasterShader::QgsRasterShader( double theMinimumValue, double theMaximumValue

QgsRasterShader::~QgsRasterShader()
{
delete mRasterShaderFunction;
}

/**
@@ -84,6 +85,7 @@ void QgsRasterShader::setRasterShaderFunction( QgsRasterShaderFunction* theFunct

if ( 0 != theFunction )
{
delete mRasterShaderFunction;
mRasterShaderFunction = theFunction;
}
}
@@ -56,7 +56,8 @@ class CORE_EXPORT QgsRasterShader
/** \brief generates and new RGB value based on original RGB value */
bool shade( double, double, double, int*, int*, int* );

/** \brief A public method that allows the user to set their own shader function */
/** \brief A public method that allows the user to set their own shader function
\note Raster shader takes ownership of the shader function instance */
void setRasterShaderFunction( QgsRasterShaderFunction* );

/** \brief Set the maximum value */

0 comments on commit 38e5d59

Please sign in to comment.