2 changes: 1 addition & 1 deletion python/core/qgsrasterdataprovider.sip
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* sense for Raster layers.
*/

class QgsRasterDataProvider : QgsDataProvider
class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
{
%TypeHeaderCode
#include <qgsrasterdataprovider.h>
Expand Down
32 changes: 32 additions & 0 deletions python/core/qgsrasterinterface.sip
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,39 @@ class QgsRasterInterface
{
%TypeHeaderCode
#include <qgsrasterinterface.h>
#include <qgsrasterresamplefilter.h>
//#include <qgsrasternuller.h>
#include <qgsrasterrenderer.h>
#include <qgsrasterprojector.h>
#include <qgsrasterdataprovider.h>

// QgsRasterRenderer subclass headers must be here because ConvertToSubClassCode
// from QgsRasterRenderer is probably included
#include <qgspalettedrasterrenderer.h>
#include <qgsmultibandcolorrenderer.h>
#include <qgssinglebandpseudocolorrenderer.h>
#include <qgssinglebandgrayrenderer.h>
#include <qgssinglebandcolordatarenderer.h>
%End

%ConvertToSubClassCode
if (dynamic_cast<QgsRasterResampleFilter*>(sipCpp) != NULL)
sipClass = sipClass_QgsRasterResampleFilter;
// if (dynamic_cast<QgsRasterNuller*>(sipCpp) != NULL)
// sipClass = sipClass_QgsRasterNuller;
if (dynamic_cast<QgsRasterRenderer*>(sipCpp) != NULL)
sipClass = sipClass_QgsRasterRenderer;
if (dynamic_cast<QgsRasterProjector*>(sipCpp) != NULL)
sipClass = sipClass_QgsRasterProjector;
if (dynamic_cast<QgsRasterDataProvider*>(sipCpp) != NULL)
{
sipClass = sipClass_QgsRasterDataProvider;
*sipCppRet = static_cast<QgsRasterDataProvider*>(sipCpp);
}
else
sipClass = 0;
%End

public:

enum DataType
Expand Down
2 changes: 2 additions & 0 deletions python/core/qgsrasterlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ public:
void setRenderer( QgsRasterRenderer* renderer /Transfer/ );
QgsRasterRenderer* renderer();

QgsRasterPipe * pipe();

/** \brief Accessor to find out how many standard deviations are being plotted */
double standardDeviations() const;

Expand Down
6 changes: 3 additions & 3 deletions python/core/qgsrasterpipe.sip
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class QgsRasterPipe

~QgsRasterPipe();

bool insert( int idx, QgsRasterInterface* theInterface );
bool insert( int idx, QgsRasterInterface* theInterface /Transfer/ );

bool replace( int idx, QgsRasterInterface* theInterface );
bool replace( int idx, QgsRasterInterface* theInterface /Transfer/ );

bool set( QgsRasterInterface * theInterface );
bool set( QgsRasterInterface * theInterface /Transfer/ );

bool remove( int idx );

Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsrasterprojector.sip
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/** Raster projector */

class QgsRasterProjector
class QgsRasterProjector : QgsRasterInterface
{
%TypeHeaderCode
#include <qgsrasterprojector.h>
Expand Down
9 changes: 6 additions & 3 deletions python/core/qgsrasterrenderer.sip
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class QgsRasterRenderer
class QgsRasterRenderer : QgsRasterInterface
{
%TypeHeaderCode
#include "qgsrasterrenderer.h"
Expand All @@ -7,6 +7,7 @@ class QgsRasterRenderer
#include "qgssinglebandpseudocolorrenderer.h"
#include "qgssinglebandgrayrenderer.h"
#include "qgssinglebandcolordatarenderer.h"
#include "qgsrasterinterface.h"
%End

%ConvertToSubClassCode
Expand All @@ -18,8 +19,8 @@ class QgsRasterRenderer
sipClass = sipClass_QgsSingleBandPseudoColorRenderer;
else if (dynamic_cast<QgsSingleBandGrayRenderer*>(sipCpp) != NULL)
sipClass = sipClass_QgsSingleBandGrayRenderer;
else if (dynamic_cast<QgsSingleBandGrayRenderer*>(sipCpp) != NULL)
sipClass = sipClass_QgsSingleBandGrayRenderer;
else if (dynamic_cast<QgsSingleBandGrayRenderer*>(sipCpp) != NULL)
sipClass = sipClass_QgsSingleBandGrayRenderer;
else
sipClass = 0;
%End
Expand All @@ -32,6 +33,8 @@ class QgsRasterRenderer
virtual QString type() const;
virtual void * readBlock( int bandNo, const QgsRectangle & extent, int width, int height );

QgsRasterInterface::DataType dataType( int bandNo ) const;

bool usesTransparency() const;

void setOpacity( double opacity );
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsrasterresamplefilter.sip
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/** Raster resample filter */

class QgsRasterResampleFilter
class QgsRasterResampleFilter : QgsRasterInterface
{
%TypeHeaderCode
#include <qgsrasterresamplefilter.h>
Expand Down
2 changes: 2 additions & 0 deletions src/core/raster/qgsrasterinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <QImage>

#include "qgslogger.h"
#include "qgsrectangle.h"

#include "gdal.h"
Expand Down Expand Up @@ -116,6 +117,7 @@ class CORE_EXPORT QgsRasterInterface
virtual DataType dataType( int bandNo ) const
{
Q_UNUSED( bandNo );
QgsDebugMsg( "Entered" );
return UnknownDataType;
}

Expand Down
15 changes: 9 additions & 6 deletions src/core/raster/qgsrasterpipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,15 @@ bool QgsRasterPipe::replace( int idx, QgsRasterInterface* theInterface )

QgsRasterPipe::Role QgsRasterPipe::interfaceRole( QgsRasterInterface * interface ) const
{
if ( dynamic_cast<QgsRasterDataProvider *>( interface ) ) return ProviderRole;
if ( dynamic_cast<QgsRasterRenderer *>( interface ) ) return RendererRole;
if ( dynamic_cast<QgsRasterResampleFilter *>( interface ) ) return ResamplerRole;
if ( dynamic_cast<QgsRasterProjector *>( interface ) ) return ProjectorRole;
if ( dynamic_cast<QgsRasterNuller *>( interface ) ) return NullerRole;
return UnknownRole;
Role role = UnknownRole;
if ( dynamic_cast<QgsRasterDataProvider *>( interface ) ) role = ProviderRole;
else if ( dynamic_cast<QgsRasterRenderer *>( interface ) ) role = RendererRole;
else if ( dynamic_cast<QgsRasterResampleFilter *>( interface ) ) role = ResamplerRole;
else if ( dynamic_cast<QgsRasterProjector *>( interface ) ) role = ProjectorRole;
else if ( dynamic_cast<QgsRasterNuller *>( interface ) ) role = NullerRole;

QgsDebugMsg( QString( "%1 role = %2" ).arg( typeid( *interface ).name() ).arg( role ) );
return role;
}

void QgsRasterPipe::setRole( QgsRasterInterface * theInterface, int idx )
Expand Down
2 changes: 2 additions & 0 deletions src/core/raster/qgsrasterrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ int QgsRasterRenderer::bandCount() const

QgsRasterInterface::DataType QgsRasterRenderer::dataType( int bandNo ) const
{
QgsDebugMsg( "Entered" );

if ( mOn ) return QgsRasterInterface::ARGB32_Premultiplied;

if ( mInput ) return mInput->dataType( bandNo );
Expand Down
3 changes: 2 additions & 1 deletion src/core/raster/qgsrasterresamplefilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ bool QgsRasterResampleFilter::setInput( QgsRasterInterface* input )
return false;
}

if ( input->dataType( 1 ) != QgsRasterInterface::ARGB32_Premultiplied )
if ( input->dataType( 1 ) != QgsRasterInterface::ARGB32_Premultiplied &&
input->dataType( 1 ) != QgsRasterInterface::ARGB32 )
{
QgsDebugMsg( "Unknown input data type" );
return false;
Expand Down
5 changes: 4 additions & 1 deletion tests/src/python/test_qgscomposermap.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def testCase(self):
rasterFileInfo = QFileInfo(TEST_DATA_DIR+QDir().separator().toAscii()+"landsat.tif")
mRasterLayer = QgsRasterLayer(rasterFileInfo.filePath(), rasterFileInfo.completeBaseName())
rasterRenderer = QgsMultiBandColorRenderer( mRasterLayer.dataProvider(), 2, 3, 4 )
mRasterLayer.setRenderer( rasterRenderer )
#mRasterLayer.setRenderer( rasterRenderer )
pipe = mRasterLayer.pipe()
assert pipe.set( rasterRenderer ), "Cannot set pipe renderer"

QgsMapLayerRegistry.instance().addMapLayer( mRasterLayer )

# create composition with composer map
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsrasterfilewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def write(self, theRasterName):

projector = QgsRasterProjector()
projector.setCRS( provider.crs(), provider.crs() )
if not pipe.insert( 2, projector.clone() ):
if not pipe.insert( 2, projector ):
print "Cannot set pipe projector"
return False

Expand Down