Skip to content

Commit

Permalink
fixes for QgsRasterInterface subclassing in Python
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Sep 18, 2012
1 parent 5eb1e2d commit 9c6ebdd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
15 changes: 12 additions & 3 deletions python/core/qgsrasterinterface.sip
Expand Up @@ -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 );
};

5 changes: 5 additions & 0 deletions src/core/raster/qgsrasterfilewriter.cpp
Expand Up @@ -12,6 +12,8 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <typeinfo>

#include "qgsrasterfilewriter.h"
#include "qgsproviderregistry.h"
#include "qgsrasterinterface.h"
Expand Down Expand Up @@ -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;

Expand Down
15 changes: 13 additions & 2 deletions src/core/raster/qgsrasterinterface.h
Expand Up @@ -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; }

Expand All @@ -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.
Expand Down

0 comments on commit 9c6ebdd

Please sign in to comment.