Skip to content
Permalink
Browse files

QgsRasterFace renamed to QgsRasterInterface, some singlebandgray cleanup

  • Loading branch information
blazek committed Jul 1, 2012
1 parent b69ff58 commit a9e1d765b4fa50da06100162500c76cbcb345cfb
@@ -160,7 +160,7 @@ SET(QGIS_CORE_SRCS
raster/qgslinearminmaxenhancement.cpp
raster/qgslinearminmaxenhancementwithclip.cpp
raster/qgspseudocolorshader.cpp
raster/qgsrasterface.cpp
raster/qgsrasterinterface.cpp
raster/qgsrasterlayer.cpp
raster/qgsrastertransparency.cpp
raster/qgsrastershader.cpp
@@ -388,7 +388,7 @@ SET(QGIS_CORE_HDRS
raster/qgspseudocolorshader.h
raster/qgsrasterpyramid.h
raster/qgsrasterbandstats.h
raster/qgsrasterface.h
raster/qgsrasterinterface.h
raster/qgsrasterlayer.h
raster/qgsrastertransparency.h
raster/qgsrastershader.h
@@ -25,7 +25,7 @@
#include "qgslogger.h"
#include "qgsrectangle.h"
#include "qgsdataprovider.h"
#include "qgsrasterface.h"
#include "qgsrasterinterface.h"
#include "qgscolorrampshader.h"
#include "qgsrasterpyramid.h"
#include "qgscoordinatereferencesystem.h"
@@ -48,7 +48,7 @@ class QByteArray;
* QgsVectorDataProvider, and does not yet make
* sense for Raster layers.
*/
class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRasterFace
class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRasterInterface
{

Q_OBJECT
@@ -30,15 +30,15 @@
#include "qgsrectangle.h"
#include "qgscoordinatereferencesystem.h"
#include "qgscoordinatetransform.h"
#include "qgsrasterface.h"
#include "qgsrasterinterface.h"

#include <cmath>

//class QgsRectangle;
class QgsPoint;

//class CORE_EXPORT QgsRasterProjector
class QgsRasterProjector : public QgsRasterFace
class QgsRasterProjector : public QgsRasterInterface
{
// Q_OBJECT
public:
@@ -24,7 +24,7 @@
#include <QImage>
#include <QSet>

QgsMultiBandColorRenderer::QgsMultiBandColorRenderer( QgsRasterFace* input, int redBand, int greenBand, int blueBand,
QgsMultiBandColorRenderer::QgsMultiBandColorRenderer( QgsRasterInterface* input, int redBand, int greenBand, int blueBand,
QgsContrastEnhancement* redEnhancement,
QgsContrastEnhancement* greenEnhancement,
QgsContrastEnhancement* blueEnhancement ):
@@ -55,7 +55,7 @@ void QgsMultiBandColorRenderer::setBlueContrastEnhancement( QgsContrastEnhanceme
delete mBlueContrastEnhancement; mBlueContrastEnhancement = ce;
}

QgsRasterRenderer* QgsMultiBandColorRenderer::create( const QDomElement& elem, QgsRasterFace* input )
QgsRasterRenderer* QgsMultiBandColorRenderer::create( const QDomElement& elem, QgsRasterInterface* input )
{
if ( elem.isNull() )
{
@@ -118,26 +118,26 @@ void * QgsMultiBandColorRenderer::readBlock( int bandNo, QgsRectangle const & e
&& mAlphaBand < 1 && !mRedContrastEnhancement && !mGreenContrastEnhancement && !mBlueContrastEnhancement
&& !mInvertColor );
*/
QgsRasterFace::DataType redType = QgsRasterFace::UnknownDataType;
QgsRasterInterface::DataType redType = QgsRasterInterface::UnknownDataType;

if ( mRedBand > 0 )
{
redType = ( QgsRasterFace::DataType )mInput->dataType( mRedBand );
redType = ( QgsRasterInterface::DataType )mInput->dataType( mRedBand );
}
QgsRasterFace::DataType greenType = QgsRasterFace::UnknownDataType;
QgsRasterInterface::DataType greenType = QgsRasterInterface::UnknownDataType;
if ( mGreenBand > 0 )
{
greenType = ( QgsRasterFace::DataType )mInput->dataType( mGreenBand );
greenType = ( QgsRasterInterface::DataType )mInput->dataType( mGreenBand );
}
QgsRasterFace::DataType blueType = QgsRasterFace::UnknownDataType;
QgsRasterInterface::DataType blueType = QgsRasterInterface::UnknownDataType;
if ( mBlueBand > 0 )
{
blueType = ( QgsRasterFace::DataType )mInput->dataType( mBlueBand );
blueType = ( QgsRasterInterface::DataType )mInput->dataType( mBlueBand );
}
QgsRasterFace::DataType transparencyType = QgsRasterFace::UnknownDataType;
QgsRasterInterface::DataType transparencyType = QgsRasterInterface::UnknownDataType;
if ( mAlphaBand > 0 )
{
transparencyType = ( QgsRasterFace::DataType )mInput->dataType( mAlphaBand );
transparencyType = ( QgsRasterInterface::DataType )mInput->dataType( mAlphaBand );
}

double oversamplingX = 1.0, oversamplingY = 1.0;
@@ -27,12 +27,12 @@ class QDomElement;
class CORE_EXPORT QgsMultiBandColorRenderer: public QgsRasterRenderer
{
public:
QgsMultiBandColorRenderer( QgsRasterFace* input, int redBand, int greenBand, int blueBand,
QgsMultiBandColorRenderer( QgsRasterInterface* input, int redBand, int greenBand, int blueBand,
QgsContrastEnhancement* redEnhancement = 0, QgsContrastEnhancement* greenEnhancement = 0,
QgsContrastEnhancement* blueEnhancement = 0 );
~QgsMultiBandColorRenderer();

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

//void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );
void * readBlock( int bandNo, QgsRectangle const & extent, int width, int height );
@@ -23,7 +23,7 @@
#include <QDomElement>
#include <QImage>

QgsPalettedRasterRenderer::QgsPalettedRasterRenderer( QgsRasterFace* input, int bandNumber,
QgsPalettedRasterRenderer::QgsPalettedRasterRenderer( QgsRasterInterface* input, int bandNumber,
QColor* colorArray, int nColors ):
QgsRasterRenderer( input, "paletted" ), mBandNumber( bandNumber ), mColors( colorArray ), mNColors( nColors )
{
@@ -34,7 +34,7 @@ QgsPalettedRasterRenderer::~QgsPalettedRasterRenderer()
delete[] mColors;
}

QgsRasterRenderer* QgsPalettedRasterRenderer::create( const QDomElement& elem, QgsRasterFace* input )
QgsRasterRenderer* QgsPalettedRasterRenderer::create( const QDomElement& elem, QgsRasterInterface* input )
{
if ( elem.isNull() )
{
@@ -88,13 +88,13 @@ void * QgsPalettedRasterRenderer::readBlock( int bandNo, QgsRectangle const & e
return 0;
}

QgsRasterFace::DataType transparencyType = QgsRasterFace::UnknownDataType;
QgsRasterInterface::DataType transparencyType = QgsRasterInterface::UnknownDataType;
if ( mAlphaBand > 0 )
{
transparencyType = ( QgsRasterFace::DataType )mInput->dataType( mAlphaBand );
transparencyType = ( QgsRasterInterface::DataType )mInput->dataType( mAlphaBand );
}

QgsRasterFace::DataType rasterType = ( QgsRasterFace::DataType )mInput->dataType( mBandNumber );
QgsRasterInterface::DataType rasterType = ( QgsRasterInterface::DataType )mInput->dataType( mBandNumber );
void* rasterData = mInput->readBlock( bandNo, extent, width, height );
double currentOpacity = mOpacity;

@@ -27,9 +27,9 @@ class CORE_EXPORT QgsPalettedRasterRenderer: public QgsRasterRenderer
{
public:
/**Renderer owns color array*/
QgsPalettedRasterRenderer( QgsRasterFace* input, int bandNumber, QColor* colorArray, int nColors );
QgsPalettedRasterRenderer( QgsRasterInterface* input, int bandNumber, QColor* colorArray, int nColors );
~QgsPalettedRasterRenderer();
static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterFace* input );
static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input );

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

@@ -32,7 +32,7 @@
#include <QImage>
#include <QPainter>

QgsRasterDrawer::QgsRasterDrawer( QgsRasterFace* input ): mInput( input )
QgsRasterDrawer::QgsRasterDrawer( QgsRasterInterface* input ): mInput( input )
{
}

@@ -19,7 +19,7 @@
#define QGSRASTERDRAWER_H

//#include "qgsrasterdataprovider.h"
#include "qgsrasterface.h"
#include "qgsrasterinterface.h"

#include <QMap>

@@ -49,13 +49,13 @@ class QgsRasterDrawer
QgsRasterProjector* prj; //raster projector (or 0 if no reprojection is done)
};

QgsRasterDrawer( QgsRasterFace* input );
QgsRasterDrawer( QgsRasterInterface* input );
~QgsRasterDrawer();

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

protected:
//inline double readValue( void *data, QgsRasterFace::DataType type, int index );
//inline double readValue( void *data, QgsRasterInterface::DataType type, int index );

/**Start reading of raster band. Raster data can then be retrieved by calling readNextRasterPart until it returns false.
@param bandNumer number of raster band to read
@@ -81,15 +81,15 @@ class QgsRasterDrawer
void drawImage( QPainter* p, QgsRasterViewPort* viewPort, const QImage& img, int topLeftCol, int topLeftRow ) const;
void stopRasterRead( int bandNumber );

QgsRasterFace* mInput;
QgsRasterInterface* mInput;
QMap<int, RasterPartInfo> mRasterPartInfos;

private:
/**Remove part into and release memory*/
void removePartInfo( int bandNumer );
};
/*
inline double QgsRasterDrawer::readValue( void *data, QgsRasterFace::DataType type, int index )
inline double QgsRasterDrawer::readValue( void *data, QgsRasterInterface::DataType type, int index )
{
if ( !mProvider )
{
@@ -103,25 +103,25 @@ inline double QgsRasterDrawer::readValue( void *data, QgsRasterFace::DataType ty
switch ( type )
{
case QgsRasterFace::Byte:
case QgsRasterInterface::Byte:
return ( double )(( GByte * )data )[index];
break;
case QgsRasterFace::UInt16:
case QgsRasterInterface::UInt16:
return ( double )(( GUInt16 * )data )[index];
break;
case QgsRasterFace::Int16:
case QgsRasterInterface::Int16:
return ( double )(( GInt16 * )data )[index];
break;
case QgsRasterFace::UInt32:
case QgsRasterInterface::UInt32:
return ( double )(( GUInt32 * )data )[index];
break;
case QgsRasterFace::Int32:
case QgsRasterInterface::Int32:
return ( double )(( GInt32 * )data )[index];
break;
case QgsRasterFace::Float32:
case QgsRasterInterface::Float32:
return ( double )(( float * )data )[index];
break;
case QgsRasterFace::Float64:
case QgsRasterInterface::Float64:
return ( double )(( double * )data )[index];
break;
default:
@@ -15,15 +15,27 @@
* *
***************************************************************************/

#include "qgsrasterface.h"
#include "qgsrasterinterface.h"
#include "qgslogger.h"

#include <QByteArray>

QgsRasterFace::QgsRasterFace( QgsRasterFace * input ): mInput( input )
QgsRasterInterface::QgsRasterInterface( QgsRasterInterface * input ): mInput( input )
{
}

QgsRasterFace::~QgsRasterFace()
QgsRasterInterface::~QgsRasterInterface()
{
}

QImage * QgsRasterInterface::createImage ( int width, int height, QImage::Format format )
{
// Qt has its own internal function depthForFormat(), unfortunately it is not public

QImage img( 1, 1, format );

// We ignore QImage::Format_Mono and QImage::Format_MonoLSB ( depth 1)
int size = width * height * img.bytesPerLine();
uchar * data = (uchar *) malloc ( size );
return new QImage( data, width, height, format );
}
@@ -19,14 +19,15 @@
#define QGSRASTERFACE_H

#include <QObject>
#include <QImage>

#include "qgsrectangle.h"

/** \ingroup core
* Base class for processing modules.
*/
// TODO: inherit from QObject? QgsRasterDataProvider inherits already from QObject
class CORE_EXPORT QgsRasterFace //: public QObject
class CORE_EXPORT QgsRasterInterface //: public QObject
{

//Q_OBJECT
@@ -93,9 +94,9 @@ class CORE_EXPORT QgsRasterFace //: public QObject
}


QgsRasterFace( QgsRasterFace * input = 0 );
QgsRasterInterface( QgsRasterInterface * input = 0 );

virtual ~QgsRasterFace();
virtual ~QgsRasterInterface();

/** Returns data type for the band specified by number */
virtual int dataType( int bandNo ) const
@@ -116,11 +117,16 @@ class CORE_EXPORT QgsRasterFace //: public QObject
return 0;
}

void setInput( QgsRasterFace* input ) { mInput = input; }
void setInput( QgsRasterInterface* input ) { mInput = input; }

/** Create a new image with extraneous data, such data may be used
* after the image is destroyed. The memory is not initialized.
*/
QImage * createImage ( int width, int height, QImage::Format format );

//protected:
// QgsRasterFace from used as input, data are read from it
QgsRasterFace* mInput;
// QgsRasterInterface from used as input, data are read from it
QgsRasterInterface* mInput;


};
@@ -101,6 +101,7 @@ QgsRasterLayer::QgsRasterLayer()
, mWidth( std::numeric_limits<int>::max() )
, mHeight( std::numeric_limits<int>::max() )
, mRenderer( 0 )
, mResampleFilter( 0 )
{
init();
mValid = false;
@@ -157,6 +158,7 @@ QgsRasterLayer::QgsRasterLayer( const QString & uri,
, mModified( false )
, mProviderKey( providerKey )
, mRenderer( 0 )
, mResampleFilter( 0 )
{
QgsDebugMsg( "Entered" );
init();
@@ -2092,6 +2094,7 @@ void QgsRasterLayer::setRenderer( QgsRasterRenderer* renderer )
else
{
mResampleFilter->setInput( mRenderer );
//mResampleFilter = new QgsRasterResampleFilter( mRenderer );
}
}

@@ -41,7 +41,7 @@
#include "qgsrastershader.h"
#include "qgscolorrampshader.h"
#include "qgsrastershaderfunction.h"
#include "qgsrasterface.h"
#include "qgsrasterinterface.h"
#include "qgsrasterdrawer.h"
#include "qgsrasterresamplefilter.h"
#include "qgsrasterdataprovider.h"
@@ -31,7 +31,7 @@
#include <QImage>
#include <QPainter>

QgsRasterRenderer::QgsRasterRenderer( QgsRasterFace* input, const QString& type ): QgsRasterFace( input ),
QgsRasterRenderer::QgsRasterRenderer( QgsRasterInterface* input, const QString& type ): QgsRasterInterface( input ),
mType( type ), mZoomedInResampler( 0 ), mZoomedOutResampler( 0 ), mOpacity( 1.0 ), mRasterTransparency( 0 ),
mAlphaBand( -1 ), mInvertColor( false ), mMaxOversampling( 2.0 )
{

0 comments on commit a9e1d76

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