Skip to content

Commit

Permalink
raster cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Apr 20, 2013
1 parent 97d39b5 commit 47894ff
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 93 deletions.
27 changes: 0 additions & 27 deletions src/core/raster/qgspalettedrasterrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
Expand All @@ -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 )
Expand All @@ -178,7 +169,6 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
}
else if ( mAlphaBand == mBand )
{
//transparencyData = rasterData;
alphaBlock = inputBlock;
}

Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/core/raster/qgspalettedrasterrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand Down
3 changes: 0 additions & 3 deletions src/core/raster/qgsrasterblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
13 changes: 0 additions & 13 deletions src/core/raster/qgsrasterrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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 ) );
}

Expand All @@ -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 )
{
Expand All @@ -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() )
{
Expand Down
26 changes: 4 additions & 22 deletions src/core/raster/qgsrasterrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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 ); }

Expand Down Expand Up @@ -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
1 change: 0 additions & 1 deletion src/core/raster/qgsrasterrendererregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ bool QgsRasterRendererRegistry::rendererData( const QString& rendererName, QgsRa

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

Expand Down
1 change: 0 additions & 1 deletion src/core/raster/qgsrasterrendererregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <QString>

class QDomElement;
//class QgsRasterDataProvider;
class QgsRasterInterface;
class QgsRasterLayer;
class QgsRasterRenderer;
Expand Down
23 changes: 0 additions & 23 deletions src/core/raster/qgsrastertransparency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 ) );
Expand Down
1 change: 0 additions & 1 deletion src/core/raster/qgssinglebandpseudocolorrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgsrasterfilewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <QTime>
#include <QDesktopServices>

#include "cpl_conv.h"

//qgis includes...
#include <qgsrasterchecker.h>
#include <qgsrasterlayer.h>
Expand Down
1 change: 1 addition & 0 deletions tests/src/core/testqgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QTime>
#include <QDesktopServices>

#include "cpl_conv.h"

//qgis includes...
#include <qgsrasterlayer.h>
Expand Down
1 change: 1 addition & 0 deletions tests/src/core/testqgsrastersublayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <QDesktopServices>

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

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

0 comments on commit 47894ff

Please sign in to comment.