Skip to content
Permalink
Browse files

Role removed from QgsRasterInterface, the logic moved to QgsRasterPipe

  • Loading branch information
blazek committed Jul 1, 2012
1 parent 71f3cfe commit d2b01bc5eb2ea268b2187f3721e64a11b0ebc117
@@ -105,14 +105,14 @@ void * QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & exten
}

QgsRasterDataProvider::QgsRasterDataProvider()
: QgsRasterInterface( 0, QgsRasterInterface::ProviderRole )
: QgsRasterInterface( 0 )
, mDpi( -1 )
{
}

QgsRasterDataProvider::QgsRasterDataProvider( QString const & uri )
: QgsDataProvider( uri )
, QgsRasterInterface( 0, QgsRasterInterface::ProviderRole )
, QgsRasterInterface( 0 )
, mDpi( -1 )
{
}
@@ -26,7 +26,7 @@ QgsRasterProjector::QgsRasterProjector(
int theDestRows, int theDestCols,
double theMaxSrcXRes, double theMaxSrcYRes,
QgsRectangle theExtent )
: QgsRasterInterface( 0, QgsRasterInterface::ProjectorRole )
: QgsRasterInterface( 0 )
, mSrcCRS( theSrcCRS )
, mDestCRS( theDestCRS )
, mCoordinateTransform( theDestCRS, theSrcCRS )
@@ -47,7 +47,7 @@ QgsRasterProjector::QgsRasterProjector(
QgsCoordinateReferenceSystem theDestCRS,
double theMaxSrcXRes, double theMaxSrcYRes,
QgsRectangle theExtent )
: QgsRasterInterface( 0, QgsRasterInterface::ProjectorRole )
: QgsRasterInterface( 0 )
, mSrcCRS( theSrcCRS )
, mDestCRS( theDestCRS )
, mCoordinateTransform( theDestCRS, theSrcCRS )
@@ -59,7 +59,7 @@ QgsRasterProjector::QgsRasterProjector(
}

QgsRasterProjector::QgsRasterProjector()
: QgsRasterInterface( 0, QgsRasterInterface::ProjectorRole )
: QgsRasterInterface( 0)
, pHelperTop( 0 ), pHelperBottom( 0 )
{
QgsDebugMsg( "Entered" );
@@ -21,9 +21,8 @@
#include "qgslogger.h"
#include "qgsrasterinterface.h"

QgsRasterInterface::QgsRasterInterface( QgsRasterInterface * input, Role role )
QgsRasterInterface::QgsRasterInterface( QgsRasterInterface * input )
: mInput( input )
, mRole( role )
, mTimeMinSize( 150 )
{
}
@@ -60,7 +59,7 @@ void * QgsRasterInterface::block( int bandNo, QgsRectangle const & extent, int
}
// QTime counts only in miliseconds
mTime[bandNo] = time.elapsed();
QgsDebugMsg( QString( "mRole = %1 bandNo = %2 time = %3" ).arg( mRole ).arg( bandNo ).arg( mTime[bandNo] ) );
QgsDebugMsg( QString( "bandNo = %2 time = %3" ).arg( bandNo ).arg( mTime[bandNo] ) );
}
return b;
}
@@ -79,7 +78,7 @@ double QgsRasterInterface::time( int bandNo )
{
t = mTime.value( bandNo );
}
QgsDebugMsg( QString( "mRole = %1 bandNo = %2 time = %3" ).arg( mRole ).arg( bandNo ).arg( t ) );
QgsDebugMsg( QString( "bandNo = %2 time = %3" ).arg( bandNo ).arg( t ) );
return t;
}

@@ -30,18 +30,6 @@ class CORE_EXPORT QgsRasterInterface
{
public:

/** Role is used to identify certain type of interface in pipe and replace
* it with another of the same Role for example
*/
enum Role
{
UnknownRole = 0,
ProviderRole = 1,
RendererRole = 2,
ResamplerRole = 3,
ProjectorRole = 4
};

/** Data types.
* This is modified and extended copy of GDALDataType.
*/
@@ -67,13 +55,10 @@ class CORE_EXPORT QgsRasterInterface
TypeCount = 14 /* maximum type # + 1 */
};

QgsRasterInterface( QgsRasterInterface * input = 0, Role role = UnknownRole );
QgsRasterInterface( QgsRasterInterface * input = 0 );

virtual ~QgsRasterInterface();

/** Interface role */
Role role() { return mRole; }

int typeSize( int dataType ) const
{
// Modified and extended copy from GDAL
@@ -174,9 +159,6 @@ class CORE_EXPORT QgsRasterInterface
double avgTime();

protected:
// Role of interface
Role mRole;

// QgsRasterInterface used as input
QgsRasterInterface* mInput;

@@ -853,12 +853,12 @@ void QgsRasterLayer::draw( QPainter * theQPainter,
}
*/

QgsRasterProjector *projector = dynamic_cast<QgsRasterProjector *>( mPipe.filter( QgsRasterInterface::ProjectorRole ) );
QgsRasterProjector *projector = mPipe.projector();
// TODO: add in init?
if ( !projector )
{
projector = new QgsRasterProjector;
mPipe.insertOrReplace( projector );
mPipe.setFilter( projector );
}

// TODO add a method to interface to get provider and get provider
@@ -1022,7 +1022,7 @@ QList< QPair< QString, QColor > > QgsRasterLayer::legendSymbologyItems() const
//{
// mRenderer->legendSymbologyItems( symbolList );
//}
QgsRasterRenderer *renderer = dynamic_cast<QgsRasterRenderer *>( mPipe.filter( QgsRasterInterface::RendererRole ) );
QgsRasterRenderer *renderer = mPipe.renderer();
if ( renderer )
{
renderer->legendSymbologyItems( symbolList );
@@ -1671,7 +1671,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider )
{
return;
}
mPipe.insertOrReplace( mDataProvider );
mPipe.setFilter( mDataProvider );

if ( provider == "gdal" )
{
@@ -2116,30 +2116,14 @@ void QgsRasterLayer::setTransparentBandName( QString const & )
void QgsRasterLayer::setRenderer( QgsRasterRenderer* theRenderer )
{
QgsDebugMsg( "Entered" );
//delete mRenderer;
//mRenderer = renderer;
mPipe.insertOrReplace( theRenderer );

/*
if ( !mResampleFilter )
{
mResampleFilter = new QgsRasterResampleFilter( mRenderer );
}
else
{
mResampleFilter->setInput( mRenderer );
}
*/
mPipe.setFilter( theRenderer );
}

// not sure if we want it
void QgsRasterLayer::setResampleFilter( QgsRasterResampleFilter* resampleFilter )
{
QgsDebugMsg( "Entered" );
//delete mResampleFilter;
//mResampleFilter = resampleFilter;
//mResampleFilter->setInput( mRenderer );
mPipe.insertOrReplace( resampleFilter );
mPipe.setFilter( resampleFilter );
}

void QgsRasterLayer::showProgress( int theValue )
@@ -2307,7 +2291,7 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
{
//mRenderer = rendererEntry.rendererCreateFunction( rasterRendererElem, dataProvider() );
QgsRasterRenderer *renderer = rendererEntry.rendererCreateFunction( rasterRendererElem, dataProvider() );
mPipe.insertOrReplace( renderer );
mPipe.setFilter( renderer );
}
}
}
@@ -2317,7 +2301,7 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
//mResampleFilter = new QgsRasterResampleFilter( mRenderer );

QgsRasterResampleFilter * resampleFilter = new QgsRasterResampleFilter();
mPipe.insertOrReplace( resampleFilter );
mPipe.setFilter( resampleFilter );

//max oversampling
QDomElement resampleElem = layer_node.firstChildElement( "rasterresampler" );
@@ -2506,13 +2490,13 @@ bool QgsRasterLayer::writeSymbology( QDomNode & layer_node, QDomDocument & docum
//{
//mRenderer->writeXML( document, layerElem );
//}
QgsRasterRenderer *renderer = dynamic_cast<QgsRasterRenderer *>( mPipe.filter( QgsRasterInterface::RendererRole ) );
QgsRasterRenderer *renderer = mPipe.renderer();
if ( renderer )
{
renderer->writeXML( document, layerElem );
}

QgsRasterResampleFilter *resampleFilter = dynamic_cast<QgsRasterResampleFilter *>( mPipe.filter( QgsRasterInterface::ResamplerRole ) );
QgsRasterResampleFilter *resampleFilter = mPipe.resampleFilter();
if ( resampleFilter )
{
QDomElement layerElem = layer_node.toElement();
@@ -352,17 +352,13 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer

/**Set raster renderer. Takes ownership of the renderer object*/
void setRenderer( QgsRasterRenderer* theRenderer );
//const QgsRasterRenderer* renderer() const { return mRenderer; }
//QgsRasterRenderer* renderer() { return mRenderer; }
const QgsRasterRenderer* renderer() const { return dynamic_cast<QgsRasterRenderer*>( mPipe.filter( QgsRasterInterface::RendererRole ) ); }
QgsRasterRenderer* renderer() { return dynamic_cast<QgsRasterRenderer*>( mPipe.filter( QgsRasterInterface::RendererRole ) ); }
//const QgsRasterRenderer* renderer() const { return mPipe.renderer(); }
QgsRasterRenderer* renderer() const { return mPipe.renderer(); }

/**Set raster resample filter. Takes ownership of the resample filter object*/
void setResampleFilter( QgsRasterResampleFilter* resampleFilter );
//const QgsRasterResampleFilter* resampleFilter() const { return mResampleFilter; }
//QgsRasterResampleFilter * resampleFilter() { return mResampleFilter; }
const QgsRasterResampleFilter* resampleFilter() const { return dynamic_cast<QgsRasterResampleFilter*>( mPipe.filter( QgsRasterInterface::ResamplerRole ) ); }
QgsRasterResampleFilter * resampleFilter() { return dynamic_cast<QgsRasterResampleFilter*>( mPipe.filter( QgsRasterInterface::ResamplerRole ) ); }
//const QgsRasterResampleFilter* resampleFilter() const { return mPipe.resampleFilter(); }
QgsRasterResampleFilter * resampleFilter() const { return mPipe.resampleFilter(); }

/** Get raster pipe */
QgsRasterPipe * pipe() { return &mPipe; }

0 comments on commit d2b01bc

Please sign in to comment.
You can’t perform that action at this time.