18 changes: 9 additions & 9 deletions src/core/qgsrasterdataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,21 +451,21 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast
/**Writes into the provider datasource*/
virtual bool write( void* data, int band, int width, int height, int xOffset, int yOffset )
{
Q_UNUSED( data );
Q_UNUSED( band );
Q_UNUSED( width );
Q_UNUSED( height );
Q_UNUSED( xOffset );
Q_UNUSED( yOffset );
return false;
Q_UNUSED( data );
Q_UNUSED( band );
Q_UNUSED( width );
Q_UNUSED( height );
Q_UNUSED( xOffset );
Q_UNUSED( yOffset );
return false;
}

/** Creates a new dataset with mDataSourceURI
@return true in case of success*/
virtual bool create( const QString& format, int nBands,
QgsRasterDataProvider::DataType type,
QgsRasterDataProvider::DataType type,
int width, int height, double* geoTransform,
const QgsCoordinateReferenceSystem& crs,
const QgsCoordinateReferenceSystem& crs,
QStringList createOptions = QStringList() /*e.v. color table*/ )
{
Q_UNUSED( format );
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsrasterprojector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ QgsRasterProjector::QgsRasterProjector(
, mDestExtent( theDestExtent )
, mExtent( theExtent )
, mDestRows( theDestRows ), mDestCols( theDestCols )
, mMaxSrcXRes( theMaxSrcXRes ), mMaxSrcYRes( theMaxSrcYRes )
, pHelperTop( 0 ), pHelperBottom( 0 )
, mMaxSrcXRes( theMaxSrcXRes ), mMaxSrcYRes( theMaxSrcYRes )
{
QgsDebugMsg( "Entered" );
QgsDebugMsg( "theDestExtent = " + theDestExtent.toString() );
Expand All @@ -53,8 +53,8 @@ QgsRasterProjector::QgsRasterProjector(
, mDestCRS( theDestCRS )
, mCoordinateTransform( theDestCRS, theSrcCRS )
, mExtent( theExtent )
, mMaxSrcXRes( theMaxSrcXRes ), mMaxSrcYRes( theMaxSrcYRes )
, pHelperTop( 0 ), pHelperBottom( 0 )
, mMaxSrcXRes( theMaxSrcXRes ), mMaxSrcYRes( theMaxSrcYRes )
{
QgsDebugMsg( "Entered" );
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsscaleutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ bool QgsScaleUtils::loadScaleList( const QString &fileName, QStringList &scales,
if ( !doc.setContent( &file, true, &errorStr, &errorLine, &errorColumn ) )
{
errorMessage = QString( "Parse error at line %1, column %2:\n%3" )
.arg( errorLine )
.arg( errorColumn )
.arg( errorStr );
.arg( errorLine )
.arg( errorColumn )
.arg( errorStr );
return false;
}

Expand Down
8 changes: 1 addition & 7 deletions src/core/raster/qgsmultibandcolorrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ QgsRasterRenderer* QgsMultiBandColorRenderer::create( const QDomElement& elem, Q

void * QgsMultiBandColorRenderer::readBlock( int bandNo, QgsRectangle const & extent, int width, int height )
{
Q_UNUSED( bandNo );
if ( !mInput )
{
return 0;
Expand Down Expand Up @@ -136,7 +137,6 @@ void * QgsMultiBandColorRenderer::readBlock( int bandNo, QgsRectangle const & e
transparencyType = ( QgsRasterInterface::DataType )mInput->dataType( mAlphaBand );
}

double oversamplingX = 1.0, oversamplingY = 1.0;
QSet<int> bands;
if ( mRedBand > 0 )
{
Expand Down Expand Up @@ -203,9 +203,6 @@ void * QgsMultiBandColorRenderer::readBlock( int bandNo, QgsRectangle const & e
int redVal = 0;
int greenVal = 0;
int blueVal = 0;
int redDataVal = 0;
int greenDataVal = 0;
int blueDataVal = 0;
QRgb defaultColor = qRgba( 255, 255, 255, 0 );
double currentOpacity = mOpacity; //opacity (between 0 and 1)

Expand All @@ -227,17 +224,14 @@ void * QgsMultiBandColorRenderer::readBlock( int bandNo, QgsRectangle const & e
if ( mRedBand > 0 )
{
redVal = readValue( redData, redType, currentRasterPos );
redDataVal = redVal;
}
if ( mGreenBand > 0 )
{
greenVal = readValue( greenData, greenType, currentRasterPos );
greenDataVal = greenVal;
}
if ( mBlueBand > 0 )
{
blueVal = readValue( blueData, blueType, currentRasterPos );
blueDataVal = blueVal;
}

//apply default color if red, green or blue not in displayable range
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterdrawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class QPainter;
class QImage;
class QgsMapToPixel;
class QgsRasterViewPort;
struct QgsRasterViewPort;
class QgsRasterIterator;

class QgsRasterDrawer
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterfilewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeImageRaster( QgsRaste
void* blueData = VSIMalloc( mMaxTileWidth * mMaxTileHeight );
void* alphaData = VSIMalloc( mMaxTileWidth * mMaxTileHeight );
QgsRectangle mapRect;
int iterLeft, iterTop, iterCols, iterRows;
int iterLeft = 0, iterTop = 0, iterCols = 0, iterRows = 0;
int fileIndex = 0;

//create destProvider for whole dataset here
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterfilewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CORE_EXPORT QgsRasterFileWriter
int maxTileWidth() const { return mMaxTileWidth; }

void setMaxTileHeight( int h ) { mMaxTileHeight = h; }
int maxTileHeight() const { return mMaxTileHeight; }
int maxTileHeight() const { return mMaxTileHeight; }

// for now not putting createOptions in all methods, use createOptions()
void setCreateOptions( const QStringList& list ) { mCreateOptions = list; }
Expand All @@ -72,7 +72,7 @@ class CORE_EXPORT QgsRasterFileWriter
QgsRasterDataProvider* createPartProvider( const QgsRectangle& extent, int nCols, int iterCols, int iterRows,
int iterLeft, int iterTop,
const QString& outputUrl, int fileIndex, int nBands, QgsRasterInterface::DataType type,
const QgsCoordinateReferenceSystem& crs );
const QgsCoordinateReferenceSystem& crs );

/**Init VRT (for tiled mode) or create global output provider (single-file mode)*/
QgsRasterDataProvider* initOutput( int nCols, int nRows, const QgsCoordinateReferenceSystem& crs, double* geoTransform, int nBands,
Expand Down
21 changes: 21 additions & 0 deletions src/core/raster/qgsrasterinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ bool QgsRasterInterface::typeIsNumeric( DataType dataType ) const
case CFloat32:
case CFloat64:
return true;

case UnknownDataType:
case ARGB32:
case ARGB32_Premultiplied:
case TypeCount:
return false;
}
return false;
}
Expand All @@ -61,6 +67,21 @@ bool QgsRasterInterface::typeIsColor( DataType dataType ) const
case ARGB32:
case ARGB32_Premultiplied:
return true;

case UnknownDataType:
case Byte:
case UInt16:
case Int16:
case UInt32:
case Int32:
case Float32:
case CInt16:
case Float64:
case CInt32:
case CFloat32:
case CFloat64:
case TypeCount:
return false;
}
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasteriterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
class QgsMapToPixel;
class QgsRasterInterface;
class QgsRasterProjector;
class QgsRasterViewPort;
struct QgsRasterViewPort;

class QgsRasterIterator
class CORE_EXPORT QgsRasterIterator
{
public:
//Stores information about reading of a raster band. Columns and rows are in unsampled coordinates
Expand Down
27 changes: 11 additions & 16 deletions src/core/raster/qgsrasterpipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ bool QgsRasterPipe::set( QgsRasterInterface* theInterface )

if ( !theInterface ) return false;

QgsRasterDataProvider * provider = dynamic_cast<QgsRasterDataProvider *>( theInterface );
QgsRasterRenderer * renderer;
QgsRasterResampleFilter * resampleFilter;
QgsRasterProjector * projector;

Role role = interfaceRole( theInterface );

// We dont know where to place unknown interface
Expand Down Expand Up @@ -179,34 +174,34 @@ bool QgsRasterPipe::set( QgsRasterInterface* theInterface )
return insert( idx, theInterface ); // insert may still fail and return false
}

QgsRasterInterface * QgsRasterPipe::interface( Role role ) const
QgsRasterInterface * QgsRasterPipe::iface( Role role ) const
{
QgsDebugMsg( QString( "role = %1" ).arg( role ) );
if ( mRoleMap.contains( role ) )
{
QgsDebugMsg( QString( "role = %1" ).arg( role ) );
if ( mRoleMap.contains( role ) )
{
return mInterfaces.value( mRoleMap.value( role ) );
}
return 0;
return mInterfaces.value( mRoleMap.value( role ) );
}
return 0;
}

QgsRasterDataProvider * QgsRasterPipe::provider() const
{
return dynamic_cast<QgsRasterDataProvider *>( interface( ProviderRole ) );
return dynamic_cast<QgsRasterDataProvider *>( iface( ProviderRole ) );
}

QgsRasterRenderer * QgsRasterPipe::renderer() const
{
return dynamic_cast<QgsRasterRenderer *>( interface( RendererRole ) );
return dynamic_cast<QgsRasterRenderer *>( iface( RendererRole ) );
}

QgsRasterResampleFilter * QgsRasterPipe::resampleFilter() const
{
return dynamic_cast<QgsRasterResampleFilter *>( interface( ResamplerRole ) );
return dynamic_cast<QgsRasterResampleFilter *>( iface( ResamplerRole ) );
}

QgsRasterProjector * QgsRasterPipe::projector() const
{
return dynamic_cast<QgsRasterProjector*>( interface( ProjectorRole ) );
return dynamic_cast<QgsRasterProjector*>( iface( ProjectorRole ) );
}

bool QgsRasterPipe::remove( int idx )
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterpipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class CORE_EXPORT QgsRasterPipe
bool set( QgsRasterInterface * theInterface );

/** Get known interface by role */
QgsRasterInterface * interface( Role role ) const;
QgsRasterInterface * iface( Role role ) const;

/** Remove and delete interface at given index if possible */
bool remove( int idx );
Expand Down Expand Up @@ -99,7 +99,7 @@ class CORE_EXPORT QgsRasterPipe

private:
/** Get known parent type_info of interface parent */
Role interfaceRole( QgsRasterInterface * interface ) const;
Role interfaceRole( QgsRasterInterface * iface ) const;

// Interfaces in pipe, the first is always provider
QVector<QgsRasterInterface*> mInterfaces;
Expand Down
3 changes: 1 addition & 2 deletions src/core/raster/qgsrasterrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface
/**Get symbology items if provided by renderer*/
virtual void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const { Q_UNUSED( symbolItems ); }

virtual void writeXML( QDomDocument& doc, QDomElement& parentElem ) const {}

virtual void writeXML( QDomDocument&, QDomElement& ) const {}
/**Sets base class members from xml. Usually called from create() methods of subclasses*/
void readXML( const QDomElement& rendererElem );

Expand Down
5 changes: 3 additions & 2 deletions src/core/raster/qgsrasterresamplefilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ bool QgsRasterResampleFilter::setInput( QgsRasterInterface* input )

if ( input->dataType( 1 ) != QgsRasterInterface::ARGB32_Premultiplied )
{
return false;
QgsDebugMsg( "Unknown input data type" );
return false;
}

mInput = input;
Expand All @@ -113,6 +113,7 @@ void QgsRasterResampleFilter::setZoomedOutResampler( QgsRasterResampler* r )

void * QgsRasterResampleFilter::readBlock( int bandNo, QgsRectangle const & extent, int width, int height )
{
Q_UNUSED( bandNo );
QgsDebugMsg( "Entered" );
if ( !mInput ) return 0;

Expand Down Expand Up @@ -190,7 +191,7 @@ void QgsRasterResampleFilter::writeXML( QDomDocument& doc, QDomElement& parentEl

QDomElement rasterRendererElem = doc.createElement( "rasterresampler" );

rasterRendererElem.setAttribute( "maxOversampling", mMaxOversampling );
rasterRendererElem.setAttribute( "maxOversampling", QString::number( mMaxOversampling ) );
if ( mZoomedInResampler )
{
rasterRendererElem.setAttribute( "zoomedInResampler", mZoomedInResampler->type() );
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterresamplefilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class QgsRasterResampler;

class QDomElement;

class QgsRasterResampleFilter : public QgsRasterInterface
class CORE_EXPORT QgsRasterResampleFilter : public QgsRasterInterface
{
public:
QgsRasterResampleFilter( QgsRasterInterface* input = 0 );
Expand Down
2 changes: 0 additions & 2 deletions src/core/raster/qgssinglebandcolordatarenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ void * QgsSingleBandColorDataRenderer::readBlock( int bandNo, QgsRectangle cons

bool hasTransparency = usesTransparency();

QgsRasterInterface::DataType rasterType = ( QgsRasterInterface::DataType )mInput->dataType( mBand );

void* rasterData = mInput->block( bandNo, extent, width, height );

currentRasterPos = 0;
Expand Down
20 changes: 11 additions & 9 deletions src/core/raster/qgssinglebandgrayrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void QgsSingleBandGrayRenderer::setContrastEnhancement( QgsContrastEnhancement*

void * QgsSingleBandGrayRenderer::readBlock( int bandNo, QgsRectangle const & extent, int width, int height )
{
Q_UNUSED( bandNo );
if ( !mInput )
{
return 0;
Expand All @@ -79,14 +80,15 @@ void * QgsSingleBandGrayRenderer::readBlock( int bandNo, QgsRectangle const & e

void* alphaData = 0;
double currentAlpha = mOpacity;
int grayVal, grayValOrig;
int grayVal;
QRgb myDefaultColor = qRgba( 0, 0, 0, 0 );

if ( mAlphaBand > 0 && mGrayBand != mAlphaBand )
{
alphaData = mInput->block( mAlphaBand, extent, width, height );
if ( !alphaData ) {
free ( rasterData );
if ( !alphaData )
{
free( rasterData );
return 0;
}
}
Expand All @@ -95,7 +97,7 @@ void * QgsSingleBandGrayRenderer::readBlock( int bandNo, QgsRectangle const & e
alphaData = rasterData;
}

QImage *img = createImage ( width, height, QImage::Format_ARGB32_Premultiplied );
QImage *img = createImage( width, height, QImage::Format_ARGB32_Premultiplied );
QRgb* imageScanLine = 0;
int currentRasterPos = 0;

Expand All @@ -104,7 +106,7 @@ void * QgsSingleBandGrayRenderer::readBlock( int bandNo, QgsRectangle const & e
imageScanLine = ( QRgb* )( img->scanLine( i ) );
for ( int j = 0; j < width; ++j )
{
grayValOrig = grayVal = readValue( rasterData, rasterType, currentRasterPos );
grayVal = readValue( rasterData, rasterType, currentRasterPos );

//alpha
currentAlpha = mOpacity;
Expand Down Expand Up @@ -145,13 +147,13 @@ void * QgsSingleBandGrayRenderer::readBlock( int bandNo, QgsRectangle const & e
}
}

free ( rasterData );
if ( mAlphaBand > 0 && mGrayBand != mAlphaBand )
free( rasterData );
if ( mAlphaBand > 0 && mGrayBand != mAlphaBand )
{
free ( alphaData );
free( alphaData );
}

void * data = (void *)img->bits();
void * data = ( void * )img->bits();
delete img;
return data; // OK, the image was created with extraneous data
}
Expand Down
1 change: 1 addition & 0 deletions src/core/raster/qgssinglebandpseudocolorrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ QgsRasterRenderer* QgsSingleBandPseudoColorRenderer::create( const QDomElement&

void * QgsSingleBandPseudoColorRenderer::readBlock( int bandNo, QgsRectangle const & extent, int width, int height )
{
Q_UNUSED( bandNo );
if ( !mInput || !mShader )
{
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsattributeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
item = new QListWidgetItem( it.key() );
item->setData( Qt::UserRole, it.value() );
item->setCheckState( checkList.contains( it.value() ) ? Qt::Checked : Qt::Unchecked );
}
}
else
{
item = new QListWidgetItem( it.value() );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ QgsMapCanvas::~QgsMapCanvas()
it++;
}

delete mScene;
mScene->deleteLater(); // crashes in python tests on windows

delete mMapRenderer;
// mCanvasProperties auto-deleted via std::auto_ptr
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsrasterformatsaveoptionswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ bool QgsRasterFormatSaveOptionsWidget::validateOptions( bool gui )
{
// print error string?
char** papszOptions = papszFromStringList( createOptions );
ok = ( GDALValidateCreationOptions( myGdalDriver, papszOptions ) == TRUE );
ok = GDALValidateCreationOptions( myGdalDriver, papszOptions );
CSLDestroy( papszOptions );
if ( gui )
{
Expand Down
10 changes: 5 additions & 5 deletions src/providers/gdal/qgsgdalprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2174,10 +2174,10 @@ char** papszFromStringList( const QStringList& list )
return papszRetList;
}

bool QgsGdalProvider::create( const QString& format, int nBands,
QgsRasterDataProvider::DataType type,
int width, int height, double* geoTransform,
const QgsCoordinateReferenceSystem& crs,
bool QgsGdalProvider::create( const QString& format, int nBands,
QgsRasterDataProvider::DataType type,
int width, int height, double* geoTransform,
const QgsCoordinateReferenceSystem& crs,
QStringList createOptions )
{
//get driver
Expand All @@ -2187,7 +2187,7 @@ bool QgsGdalProvider::create( const QString& format, int nBands,
return false;
}

//create dataset
//create dataset
char **papszOptions = papszFromStringList( createOptions );
GDALDatasetH dataset = GDALCreate( driver, dataSourceUri().toLocal8Bit().data(), width, height, nBands, ( GDALDataType )type, papszOptions );
CSLDestroy( papszOptions );
Expand Down
6 changes: 3 additions & 3 deletions src/providers/gdal/qgsgdalprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ class QgsGdalProvider : public QgsRasterDataProvider

/** Creates a new dataset with mDataSourceURI
@return true in case of success*/
bool create( const QString& format, int nBands,
QgsRasterDataProvider::DataType type,
int width, int height, double* geoTransform,
bool create( const QString& format, int nBands,
QgsRasterDataProvider::DataType type,
int width, int height, double* geoTransform,
const QgsCoordinateReferenceSystem& crs,
QStringList createOptions = QStringList() );

Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void TestQgsRasterLayer::checkStats()
QVERIFY( mpRasterLayer->bandStatistics( 1 ).minimumValue == 0 );
QVERIFY( mpRasterLayer->bandStatistics( 1 ).maximumValue == 9 );
QVERIFY( mpRasterLayer->bandStatistics( 1 ).mean == 4.5 );
QVERIFY( fabs( mpRasterLayer->bandStatistics( 1 ).stdDev - 2.87228132326901431 )
QVERIFY( fabs( mpRasterLayer->bandStatistics( 1 ).stdDev - 2.87228132326901431 )
< 0.0000000000000001 );
mReport += "<h2>Check Stats</h2>\n";
mReport += "<p>Passed</p>";
Expand Down
36 changes: 19 additions & 17 deletions tests/src/python/test_qgisapp.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import unittest
from utilities import (getQgisTestApp,
setCanvasCrs,
GEOCRS,
GOOGLECRS
)
QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp()

class TestQGisApp(unittest.TestCase):
from utilities import getQgisTestApp

def testValidThemeName(self):
"""That can set the app to use a valid theme"""
QGISAPP.setThemeName('gis')
myExpectedResult = 'gis'
myResult = QGISAPP.themeName()
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
(myExpectedResult, myResult))
QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp()

mySettings = QGISAPP.showSettings()
print mySettings
class TestQGisApp(unittest.TestCase):

assert myExpectedResult == myResult, myMessage
# Can this work at all?
# The theme resources are built into the executable and should only be
# available to plugins and not in test applications.
#
# def testValidThemeName(self):
# """That can set the app to use a valid theme"""
# QGISAPP.setThemeName('gis')
# myExpectedResult = 'gis'
# myResult = QGISAPP.themeName()
# myMessage = ('Expected:\n%s\nGot:\n%s\n' %
# (myExpectedResult, myResult))
#
# mySettings = QGISAPP.showSettings()
# print mySettings
#
# assert myExpectedResult == myResult, myMessage

def testInvalidThemeName(self):
"""That setting the app to use an invalid theme will fallback to 'default'"""
Expand Down