[QGIS Commit] r14022 - in trunk/qgis: python/core src/core/raster
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Aug 7 10:28:20 EDT 2010
Author: wonder
Date: 2010-08-07 14:28:20 +0000 (Sat, 07 Aug 2010)
New Revision: 14022
Modified:
trunk/qgis/python/core/qgsrasterlayer.sip
trunk/qgis/python/core/qgsrastershader.sip
trunk/qgis/python/core/qgsrastershaderfunction.sip
trunk/qgis/src/core/raster/qgsrasterlayer.cpp
trunk/qgis/src/core/raster/qgsrasterlayer.h
trunk/qgis/src/core/raster/qgsrastershader.cpp
trunk/qgis/src/core/raster/qgsrastershader.h
Log:
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++
Modified: trunk/qgis/python/core/qgsrasterlayer.sip
===================================================================
--- trunk/qgis/python/core/qgsrasterlayer.sip 2010-08-07 14:02:55 UTC (rev 14021)
+++ trunk/qgis/python/core/qgsrasterlayer.sip 2010-08-07 14:28:20 UTC (rev 14022)
@@ -426,8 +426,9 @@
/** \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 );
Modified: trunk/qgis/python/core/qgsrastershader.sip
===================================================================
--- trunk/qgis/python/core/qgsrastershader.sip 2010-08-07 14:02:55 UTC (rev 14021)
+++ trunk/qgis/python/core/qgsrastershader.sip 2010-08-07 14:28:20 UTC (rev 14022)
@@ -31,8 +31,9 @@
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 */
Modified: trunk/qgis/python/core/qgsrastershaderfunction.sip
===================================================================
--- trunk/qgis/python/core/qgsrastershaderfunction.sip 2010-08-07 14:02:55 UTC (rev 14021)
+++ trunk/qgis/python/core/qgsrastershaderfunction.sip 2010-08-07 14:28:20 UTC (rev 14022)
@@ -3,8 +3,23 @@
{
%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();
Modified: trunk/qgis/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.cpp 2010-08-07 14:02:55 UTC (rev 14021)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.cpp 2010-08-07 14:28:20 UTC (rev 14022)
@@ -3525,12 +3525,6 @@
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 );
Modified: trunk/qgis/src/core/raster/qgsrasterlayer.h
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.h 2010-08-07 14:02:55 UTC (rev 14021)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.h 2010-08-07 14:28:20 UTC (rev 14022)
@@ -449,8 +449,8 @@
/** \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 @@
/** \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) */
Modified: trunk/qgis/src/core/raster/qgsrastershader.cpp
===================================================================
--- trunk/qgis/src/core/raster/qgsrastershader.cpp 2010-08-07 14:02:55 UTC (rev 14021)
+++ trunk/qgis/src/core/raster/qgsrastershader.cpp 2010-08-07 14:28:20 UTC (rev 14022)
@@ -31,6 +31,7 @@
QgsRasterShader::~QgsRasterShader()
{
+ delete mRasterShaderFunction;
}
/**
@@ -84,6 +85,7 @@
if ( 0 != theFunction )
{
+ delete mRasterShaderFunction;
mRasterShaderFunction = theFunction;
}
}
Modified: trunk/qgis/src/core/raster/qgsrastershader.h
===================================================================
--- trunk/qgis/src/core/raster/qgsrastershader.h 2010-08-07 14:02:55 UTC (rev 14021)
+++ trunk/qgis/src/core/raster/qgsrastershader.h 2010-08-07 14:28:20 UTC (rev 14022)
@@ -56,7 +56,8 @@
/** \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 */
More information about the QGIS-commit
mailing list