Skip to content
Permalink
Browse files

raster cleanup

  • Loading branch information
blazek committed Apr 20, 2013
1 parent 97d39b5 commit 47894ff7338f5c8dd47052fb4ac16f767ed569d5
@@ -142,14 +142,6 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
return outputBlock;
}

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

//QGis::DataType rasterType = ( QGis::DataType )mInput->dataType( mBand );
//void* rasterData = mInput->block( bandNo, extent, width, height );
QgsRasterBlock *inputBlock = mInput->block( bandNo, extent, width, height );

if ( !inputBlock || inputBlock->isEmpty() )
@@ -163,7 +155,6 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con

//rendering is faster without considering user-defined transparency
bool hasTransparency = usesTransparency();
//void* transparencyData = 0;
QgsRasterBlock *alphaBlock = 0;

if ( mAlphaBand > 0 && mAlphaBand != mBand )
@@ -178,7 +169,6 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
}
else if ( mAlphaBand == mBand )
{
//transparencyData = rasterData;
alphaBlock = inputBlock;
}

@@ -189,23 +179,6 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
return outputBlock;
}

//create copy of color table with nodata values replaced by fully transparent color
// We dont have no data value anymore
#if 0
QVector<QRgb> colorTable( mNColors );
for ( int i = 0; i < mNColors; ++i )
{
if ( inputBlock->isNoDataValue( i ) )
{
colorTable[i] = QColor( 0, 0, 0, 0 ).rgba();
}
else
{
colorTable[i] = mColors[i];
}
}
#endif

QRgb myDefaultColor = NODATA_COLOR;

//use direct data access instead of QgsRasterBlock::setValue
@@ -36,8 +36,6 @@ class CORE_EXPORT QgsPalettedRasterRenderer: public QgsRasterRenderer
QgsRasterInterface * clone() const;
static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input );

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

QgsRasterBlock *block( int bandNo, const QgsRectangle & extent, int width, int height );

/**Returns number of colors*/
@@ -19,13 +19,10 @@

#include <QByteArray>
#include <QColor>
#include <QTime>

#include "qgslogger.h"
#include "qgsrasterblock.h"

#include "cpl_conv.h"

QgsRasterBlock::QgsRasterBlock()
: mValid( true )
, mDataType( QGis::UnknownDataType )
@@ -16,15 +16,7 @@
***************************************************************************/

#include "qgsrasterrenderer.h"
#include "qgsrasterresampler.h"
#include "qgsrasterprojector.h"
#include "qgsrastertransparency.h"
#include "qgsrasterviewport.h"
#include "qgsmaptopixel.h"

//resamplers
#include "qgsbilinearrasterresampler.h"
#include "qgscubicrasterresampler.h"

#include <QCoreApplication>
#include <QDomDocument>
@@ -97,8 +89,6 @@ bool QgsRasterRenderer::usesTransparency( ) const
{
return true;
}
// TODO: nodata per band
//return ( mAlphaBand > 0 || ( mRasterTransparency && !mRasterTransparency->isEmpty( mInput->noDataValue( 1 ) ) ) || !qgsDoubleNear( mOpacity, 1.0 ) );
return ( mAlphaBand > 0 || ( mRasterTransparency && !mRasterTransparency->isEmpty() ) || !qgsDoubleNear( mOpacity, 1.0 ) );
}

@@ -118,7 +108,6 @@ void QgsRasterRenderer::_writeXML( QDomDocument& doc, QDomElement& rasterRendere
rasterRendererElem.setAttribute( "type", mType );
rasterRendererElem.setAttribute( "opacity", QString::number( mOpacity ) );
rasterRendererElem.setAttribute( "alphaBand", mAlphaBand );
//rasterRendererElem.setAttribute( "invertColor", mInvertColor );

if ( mRasterTransparency )
{
@@ -136,9 +125,7 @@ void QgsRasterRenderer::readXML( const QDomElement& rendererElem )
mType = rendererElem.attribute( "type" );
mOpacity = rendererElem.attribute( "opacity", "1.0" ).toDouble();
mAlphaBand = rendererElem.attribute( "alphaBand", "-1" ).toInt();
//mInvertColor = rendererElem.attribute( "invertColor", "0" ).toInt();

//todo: read mRasterTransparency
QDomElement rasterTransparencyElem = rendererElem.firstChildElement( "rasterTransparency" );
if ( !rasterTransparencyElem.isNull() )
{
@@ -18,20 +18,15 @@
#ifndef QGSRASTERRENDERER_H
#define QGSRASTERRENDERER_H

#include "qgsrasterinterface.h"
#include "qgsrasterdataprovider.h"
#include <QPair>

#include "cpl_conv.h"
#include "qgsrasterdataprovider.h"
#include "qgsrasterinterface.h"

class QDomElement;

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

class QDomElement;

/** \ingroup core
* Raster renderer pipe that applies colours to a raster.
@@ -71,14 +66,6 @@ class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface

virtual bool setInput( QgsRasterInterface* input );

#if 0
virtual void * readBlock( int bandNo, const QgsRectangle &extent, int width, int height )
{
Q_UNUSED( bandNo ); Q_UNUSED( extent ); Q_UNUSED( width ); Q_UNUSED( height );
return 0;
}
#endif

virtual QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height ) = 0;

bool usesTransparency() const;
@@ -92,9 +79,6 @@ class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface
void setAlphaBand( int band ) { mAlphaBand = band; }
int alphaBand() const { return mAlphaBand; }

//void setInvertColor( bool invert ) { mInvertColor = invert; }
//bool invertColor() const { return mInvertColor; }

/**Get symbology items if provided by renderer*/
virtual void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const { Q_UNUSED( symbolItems ); }

@@ -122,8 +106,6 @@ class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface
/**Read alpha value from band. Is combined with value from raster transparency / global alpha value.
Default: -1 (not set)*/
int mAlphaBand;

//bool mInvertColor;
};

#endif // QGSRASTERRENDERER_H
@@ -92,7 +92,6 @@ bool QgsRasterRendererRegistry::rendererData( const QString& rendererName, QgsRa

QStringList QgsRasterRendererRegistry::renderersList() const
{
// return QStringList( mEntries.keys() );
return mSortedEntries;
}

@@ -23,7 +23,6 @@
#include <QString>

class QDomElement;
//class QgsRasterDataProvider;
class QgsRasterInterface;
class QgsRasterLayer;
class QgsRasterRenderer;
@@ -177,28 +177,6 @@ int QgsRasterTransparency::alphaValue( double theRedValue, double theGreenValue,
return theGlobalTransparency;
}

// TODO: nodata per band
#if 0
bool QgsRasterTransparency::isEmpty( double nodataValue ) const
{
// This was probably used when no data value was added by default to transparency list
// that is not true anamore
return (
( mTransparentSingleValuePixelList.isEmpty() ||
( mTransparentSingleValuePixelList.size() == 1 &&
( qgsDoubleNear( mTransparentSingleValuePixelList.at( 0 ).min, nodataValue ) ||
qgsDoubleNear( mTransparentSingleValuePixelList.at( 0 ).max, nodataValue ) ||
( nodataValue >= mTransparentSingleValuePixelList.at( 0 ).min &&
nodataValue <= mTransparentSingleValuePixelList.at( 0 ).max ) ) ) )
&&
( mTransparentThreeValuePixelList.isEmpty() ||
( mTransparentThreeValuePixelList.size() == 1 &&
qgsDoubleNear( mTransparentThreeValuePixelList.at( 0 ).red, nodataValue ) &&
qgsDoubleNear( mTransparentThreeValuePixelList.at( 0 ).green, nodataValue ) &&
qgsDoubleNear( mTransparentThreeValuePixelList.at( 0 ).blue, nodataValue ) ) ) );
}
#endif

bool QgsRasterTransparency::isEmpty( ) const
{
return mTransparentSingleValuePixelList.isEmpty();
@@ -214,7 +192,6 @@ void QgsRasterTransparency::writeXML( QDomDocument& doc, QDomElement& parentElem
for ( ; it != mTransparentSingleValuePixelList.constEnd(); ++it )
{
QDomElement pixelListElement = doc.createElement( "pixelListEntry" );
//pixelListElement.setAttribute( "pixelValue", QString::number( it->pixelValue, 'f' ) );
pixelListElement.setAttribute( "min", QgsRasterBlock::printValue( it->min ) );
pixelListElement.setAttribute( "max", QgsRasterBlock::printValue( it->max ) );
pixelListElement.setAttribute( "percentTransparent", QString::number( it->percentTransparent ) );
@@ -90,7 +90,6 @@ QgsRasterRenderer* QgsSingleBandPseudoColorRenderer::create( const QDomElement&
shader->readXML( rasterShaderElem );
}

//QgsRasterRenderer* r = new QgsSingleBandPseudoColorRenderer( input, band, shader );
QgsSingleBandPseudoColorRenderer* r = new QgsSingleBandPseudoColorRenderer( input, band, shader );
r->readXML( elem );

@@ -25,6 +25,8 @@
#include <QTime>
#include <QDesktopServices>

#include "cpl_conv.h"

//qgis includes...
#include <qgsrasterchecker.h>
#include <qgsrasterlayer.h>
@@ -25,6 +25,7 @@
#include <QTime>
#include <QDesktopServices>

#include "cpl_conv.h"

//qgis includes...
#include <qgsrasterlayer.h>
@@ -26,6 +26,7 @@
#include <QDesktopServices>

#include <gdal.h>
#include "cpl_conv.h"

//qgis includes...
#include <qgsrasterlayer.h>

0 comments on commit 47894ff

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