Skip to content

Commit

Permalink
raster sip fix for test unit
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Sep 13, 2012
1 parent c6a29fa commit 24a047d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
2 changes: 2 additions & 0 deletions python/core/qgsrasterlayer.sip
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
2 changes: 2 additions & 0 deletions python/core/qgsrasterrenderer.sip
Expand Up @@ -33,6 +33,8 @@ class QgsRasterRenderer : QgsRasterInterface
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: 2 additions & 0 deletions src/core/raster/qgsrasterinterface.h
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
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
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
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
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

0 comments on commit 24a047d

Please sign in to comment.