fixes for QgsRasterInterface subclassing in Python

This commit is contained in:
Radim Blazek 2012-09-18 21:01:39 +02:00
parent 5eb1e2d267
commit 9c6ebdd4ee
3 changed files with 30 additions and 5 deletions

View File

@ -84,22 +84,31 @@ class QgsRasterInterface
virtual double noDataValue() const;
//void * block( int bandNo, QgsRectangle const & extent, int width, int height );
virtual void * block( int bandNo, const QgsRectangle & extent, int width, int height );
//virtual void * readBlock( int bandNo, QgsRectangle const & extent, int width, int height );
virtual void * readBlock( int bandNo, const QgsRectangle & extent, int width, int height );
virtual bool setInput( QgsRasterInterface* input );
virtual QgsRasterInterface * input () const;
virtual bool on( );
virtual void setOn( bool on );
virtual QgsRasterInterface * srcInput();
QgsRasterInterface * srcInput();
QImage * createImage( int width, int height, QImage::Format format );
void setStatsOn( bool on );
double time( bool cumulative = false );
static QString printValue( double value );
protected:
static double readValue( void *data, QgsRasterInterface::DataType type, int index );
static void writeValue( void *data, QgsRasterInterface::DataType type, int index, double value );
};

View File

@ -12,6 +12,8 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <typeinfo>
#include "qgsrasterfilewriter.h"
#include "qgsproviderregistry.h"
#include "qgsrasterinterface.h"
@ -65,11 +67,14 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeRaster( const QgsRast
return SourceProviderError;
}
QgsDebugMsg( QString( "reading from %1" ).arg( typeid( *iface ).name() ) );
if ( !iface->srcInput() )
{
QgsDebugMsg( "iface->srcInput() == 0" );
return SourceProviderError;
}
QgsDebugMsg( QString( "srcInput = %1" ).arg( typeid( *( iface->srcInput() ) ).name() ) );
mProgressDialog = progressDialog;

View File

@ -178,6 +178,9 @@ class CORE_EXPORT QgsRasterInterface
* Returns true if set correctly, false if cannot use that input */
virtual bool setInput( QgsRasterInterface* input ) { mInput = input; return true; }
/** Current input */
virtual QgsRasterInterface * input() const { return mInput; }
/** Is on/off */
virtual bool on( ) { return mOn; }
@ -188,8 +191,16 @@ class CORE_EXPORT QgsRasterInterface
* It may be used to get info about original data, e.g. resolution to decide
* resampling etc.
*/
virtual const QgsRasterInterface * srcInput() const { return mInput ? mInput->srcInput() : this; }
virtual QgsRasterInterface * srcInput() { return mInput ? mInput->srcInput() : this; }
virtual const QgsRasterInterface * srcInput() const
{
QgsDebugMsg( "Entered" );
return mInput ? mInput->srcInput() : this;
}
virtual QgsRasterInterface * srcInput()
{
QgsDebugMsg( "Entered" );
return mInput ? mInput->srcInput() : this;
}
/** Create a new image with extraneous data, such data may be used
* after the image is destroyed. The memory is not initialized.