2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

QgsRasterRenderer::QgsRasterRenderer( QgsRasterInterface* input, const QString& type )
: QgsRasterInterface( input, QgsRasterInterface::RendererRole ),
mType( type ), mZoomedInResampler( 0 ), mZoomedOutResampler( 0 ), mOpacity( 1.0 ), mRasterTransparency( 0 ),
mType( type ), mOpacity( 1.0 ), mRasterTransparency( 0 ),
mAlphaBand( -1 ), mInvertColor( false ), mMaxOversampling( 2.0 )
{
}
Expand Down
17 changes: 1 addition & 16 deletions src/core/raster/qgsrasterrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface
virtual ~QgsRasterRenderer();

virtual QString type() const { return mType; }
//virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel ) = 0;

virtual void * readBlock( int bandNo, QgsRectangle const & extent, int width, int height )
{
Expand Down Expand Up @@ -74,14 +73,7 @@ class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface
/**Write upper class info into rasterrenderer element (called by writeXML method of subclasses)*/
void _writeXML( QDomDocument& doc, QDomElement& rasterRendererElem ) const;


QgsRasterInterface* mProvider;
QString mType;
/**Resampler used if screen resolution is higher than raster resolution (zoomed in). 0 means no resampling (nearest neighbour)*/
QgsRasterResampler* mZoomedInResampler;
/**Resampler used if raster resolution is higher than raster resolution (zoomed out). 0 mean no resampling (nearest neighbour)*/
QgsRasterResampler* mZoomedOutResampler;
//QMap<int, RasterPartInfo> mRasterPartInfos;

/**Global alpha value (0-1)*/
double mOpacity;
Expand All @@ -95,11 +87,6 @@ class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface

/**Maximum boundary for oversampling (to avoid too much data traffic). Default: 2.0*/
double mMaxOversampling;

private:
/**Remove part into and release memory*/
void removePartInfo( int bandNumer );
void projectImage( const QImage& srcImg, QImage& dstImage, QgsRasterProjector* prj ) const;
};

inline double QgsRasterRenderer::readValue( void *data, QgsRasterInterface::DataType type, int index )
Expand All @@ -111,9 +98,7 @@ inline double QgsRasterRenderer::readValue( void *data, QgsRasterInterface::Data

if ( !data )
{
// TODO
//return mInput->noDataValue();
return 0;
return mInput->noDataValue();
}

switch ( type )
Expand Down
29 changes: 13 additions & 16 deletions src/core/raster/qgsrasterresamplefilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* *
***************************************************************************/

#include "qgsrasterdataprovider.h"
#include "qgsrasterresamplefilter.h"
#include "qgsrasterresampler.h"
#include "qgsrasterprojector.h"
Expand All @@ -40,21 +41,19 @@ QgsRasterResampleFilter::QgsRasterResampleFilter( QgsRasterInterface* input )

QgsRasterResampleFilter::~QgsRasterResampleFilter()
{
// TODO: currently we are using pointer to renderer, enable once moved here
//delete mZoomedInResampler;
//delete mZoomedOutResampler;
//delete mRasterTransparency;
delete mZoomedInResampler;
delete mZoomedOutResampler;
}

void QgsRasterResampleFilter::setZoomedInResampler( QgsRasterResampler* r )
{
//delete mZoomedInResampler;
delete mZoomedInResampler;
mZoomedInResampler = r;
}

void QgsRasterResampleFilter::setZoomedOutResampler( QgsRasterResampler* r )
{
//delete mZoomedOutResampler;
delete mZoomedOutResampler;
mZoomedOutResampler = r;
}

Expand All @@ -67,18 +66,16 @@ void * QgsRasterResampleFilter::readBlock( int bandNo, QgsRectangle const & ext

if ( mZoomedInResampler || mZoomedOutResampler )
{
// TODO: we must get it somehow from pipe (via projector), for now
oversampling = 2.;
/*
QgsRectangle providerExtent = mInput->extent();
if ( viewPort->mSrcCRS.isValid() && viewPort->mDestCRS.isValid() && viewPort->mSrcCRS != viewPort->mDestCRS )
QgsRasterDataProvider *provider = dynamic_cast<QgsRasterDataProvider*>( mInput->srcInput() );
// Do not oversample if data source does not have fixed resolution (WMS)
if ( provider && ( provider->capabilities() & QgsRasterDataProvider::Size ) )
{
QgsCoordinateTransform t( viewPort->mSrcCRS, viewPort->mDestCRS );
providerExtent = t.transformBoundingBox( providerExtent );
double xRes = extent.width() / width;
double providerXRes = provider->extent().width() / provider->xSize();
double pixelRatio = xRes / providerXRes;
oversampling = ( pixelRatio > mMaxOversampling ) ? mMaxOversampling : pixelRatio;
QgsDebugMsg( QString( "xRes = %1 providerXRes = %2 pixelRatio = %3 oversampling = %4" ).arg( xRes ).arg( providerXRes ).arg( pixelRatio ).arg( oversampling ) );
}
double pixelRatio = mapToPixel->mapUnitsPerPixel() / ( providerExtent.width() / mInput->xSize() );
oversampling = ( pixelRatio > mMaxOversampling ) ? mMaxOversampling : pixelRatio;
*/
}

//set oversampling back to 1.0 if no resampler for zoomed in / zoomed out (nearest neighbour)
Expand Down
11 changes: 0 additions & 11 deletions src/core/raster/qgsrasterresamplefilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@
#include "qgsrasterdataprovider.h"
#include "qgsrasterinterface.h"

class QPainter;
class QgsMapToPixel;
class QgsRasterResampler;
class QgsRasterProjector;
class QgsRasterTransparency;
class QgsRasterViewPort;

class QDomElement;

Expand Down Expand Up @@ -55,16 +50,10 @@ class QgsRasterResampleFilter : public QgsRasterInterface
void readXML( const QDomElement& resamplefilterElem );

protected:

/**Write upper class info into <rasterresamplefilter> element (called by writeXML method of subclasses)*/
//void _writeXML( QDomDocument& doc, QDomElement& rasterRendererElem ) const;


/**Resampler used if screen resolution is higher than raster resolution (zoomed in). 0 means no resampling (nearest neighbour)*/
QgsRasterResampler* mZoomedInResampler;
/**Resampler used if raster resolution is higher than raster resolution (zoomed out). 0 mean no resampling (nearest neighbour)*/
QgsRasterResampler* mZoomedOutResampler;
//QMap<int, RasterPartInfo> mRasterPartInfos;

/**Maximum boundary for oversampling (to avoid too much data traffic). Default: 2.0*/
double mMaxOversampling;
Expand Down
2 changes: 0 additions & 2 deletions src/core/raster/qgssinglebandcolordatarenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class CORE_EXPORT QgsSingleBandColorDataRenderer: public QgsRasterRenderer

static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input );

//virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

void * readBlock( int bandNo, QgsRectangle const & extent, int width, int height );

void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;
Expand Down
3 changes: 0 additions & 3 deletions src/core/raster/qgssinglebandgrayrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ class CORE_EXPORT QgsSingleBandGrayRenderer: public QgsRasterRenderer
QgsSingleBandGrayRenderer( QgsRasterInterface* input, int grayBand );
~QgsSingleBandGrayRenderer();

//static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterDataProvider* provider );
static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input );

//virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

void * readBlock( int bandNo, QgsRectangle const & extent, int width, int height );

int grayBand() const { return mGrayBand; }
Expand Down
2 changes: 0 additions & 2 deletions src/core/raster/qgssinglebandpseudocolorrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class CORE_EXPORT QgsSingleBandPseudoColorRenderer: public QgsRasterRenderer

static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input );

//virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

void * readBlock( int bandNo, QgsRectangle const & extent, int width, int height );

/**Takes ownership of the shader*/
Expand Down