Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix a few warnings and indentation
git-svn-id: http://svn.osgeo.org/qgis/trunk@15393 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 8, 2011
1 parent 3109508 commit 4dc5e26
Show file tree
Hide file tree
Showing 18 changed files with 767 additions and 695 deletions.
32 changes: 16 additions & 16 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -516,7 +516,7 @@ void QgsRasterLayerProperties::sync()
break;
}

if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterDataProvider::ARGBDataType )
{
delete tabPageSymbology;
delete tabPageColormap;
Expand All @@ -525,12 +525,12 @@ void QgsRasterLayerProperties::sync()
tabBar->setCurrentWidget( tabPageMetadata );
}

if ( ! ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::BuildPyramids ) )
if ( !( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::BuildPyramids ) )
{
delete tabPagePyramids;
}

if ( ! ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Histogram ) )
if ( !( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Histogram ) )
{
delete tabPageHistogram;
}
Expand Down Expand Up @@ -562,8 +562,8 @@ void QgsRasterLayerProperties::sync()
//
// Populate the various controls on the form
//
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
{
if ( mRasterLayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGBDataType )
{
QgsDebugMsg( "colorShadingAlgorithm = " + QString::number( mRasterLayer->colorShadingAlgorithm() ) );
if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandPseudoColor ||
mRasterLayer->drawingStyle() == QgsRasterLayer::PalettedColor ||
Expand Down Expand Up @@ -593,7 +593,7 @@ void QgsRasterLayerProperties::sync()
}
}

if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
if ( mRasterLayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGBDataType )
{
if ( rbtnThreeBand->isChecked() )
{
Expand Down Expand Up @@ -782,7 +782,7 @@ void QgsRasterLayerProperties::sync()

//display the raster dimensions and no data value
if ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Size )
{
{
lblColumns->setText( tr( "Columns: %1" ).arg( mRasterLayer->width() ) );
lblRows->setText( tr( "Rows: %1" ).arg( mRasterLayer->height() ) );
}
Expand All @@ -793,8 +793,8 @@ void QgsRasterLayerProperties::sync()
lblRows->setText( tr( "Rows: " ) + tr( "n/a" ) );
}

if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
{
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterDataProvider::ARGBDataType )
{
lblNoData->setText( tr( "No-Data Value: " ) + tr( "n/a" ) );
}
else
Expand Down Expand Up @@ -843,7 +843,7 @@ void QgsRasterLayerProperties::syncColormapTab()
return;
}

if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterDataProvider::ARGBDataType )
{
return;
}
Expand Down Expand Up @@ -935,7 +935,7 @@ bool QgsRasterLayerProperties::validUserDefinedMinMax()
*/
void QgsRasterLayerProperties::apply()
{
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
if ( mRasterLayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGBDataType )
{
QgsDebugMsg( "apply processing symbology tab" );
/*
Expand Down Expand Up @@ -1425,7 +1425,7 @@ void QgsRasterLayerProperties::apply()
mRasterLayer->triggerRepaint();

//Because Min Max values can be set during the redraw if a strech is requested we need to resync after apply
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
if ( mRasterLayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGBDataType )
{
if ( QgsContrastEnhancement::NoEnhancement != mRasterLayer->contrastEnhancementAlgorithm() )
{
Expand Down Expand Up @@ -1668,7 +1668,7 @@ void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked()

void QgsRasterLayerProperties::on_cboxColorMap_currentIndexChanged( const QString& theText )
{
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterDataProvider::ARGBDataType )
{
return;
}
Expand Down Expand Up @@ -2586,9 +2586,9 @@ void QgsRasterLayerProperties::on_pbtnLoadColorMapFromFile_clicked()

void QgsRasterLayerProperties::on_pbtnLoadMinMax_clicked()
{
if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandGray
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandSingleBandGray
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandColor )
if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandGray
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandSingleBandGray
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandColor )
{
QgsRasterBandStats myRasterBandStats;
double myMinimumMaximum[2];
Expand Down
31 changes: 17 additions & 14 deletions src/core/qgsrasterdataprovider.cpp
Expand Up @@ -23,12 +23,13 @@
#include <QTime>
#include <QMap>

void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *data )
void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *data )
{
QgsDebugMsg("Entered");
QgsDebugMsg( "Entered" );
QgsDebugMsg( "viewExtent = " + viewExtent.toString() );

if ( ! theSrcCRS.isValid() || ! theDestCRS.isValid() ) {
if ( ! theSrcCRS.isValid() || ! theDestCRS.isValid() )
{
readBlock( bandNo, viewExtent, width, height, data );
return;
}
Expand All @@ -38,21 +39,21 @@ void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & viewExt

double mMaxSrcXRes = 0;
double mMaxSrcYRes = 0;
if ( capabilities() & QgsRasterDataProvider::ExactResolution )

if ( capabilities() & QgsRasterDataProvider::ExactResolution )
{
mMaxSrcXRes = extent().width()/xSize();
mMaxSrcYRes = extent().height()/ySize();
mMaxSrcXRes = extent().width() / xSize();
mMaxSrcYRes = extent().height() / ySize();
}

QgsRasterProjector myProjector = QgsRasterProjector ( theSrcCRS, theDestCRS, viewExtent, height, width, mMaxSrcXRes, mMaxSrcYRes );
QgsRasterProjector myProjector = QgsRasterProjector( theSrcCRS, theDestCRS, viewExtent, height, width, mMaxSrcXRes, mMaxSrcYRes );

QgsDebugMsg( QString( "create projector time (ms): %1" ).arg( time.elapsed() ) );

// TODO: init data by nulls

// Allocate memory for not projected source data
int mySize = dataTypeSize(bandNo)/8;
int mySize = dataTypeSize( bandNo ) / 8;
void *mySrcData = malloc( mySize * myProjector.srcRows() * myProjector.srcCols() );

time.restart();
Expand All @@ -67,13 +68,15 @@ void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & viewExt
int mySrcCol;
int mySrcOffset;
int myDestOffset;
for ( int r = 0; r < height; r++) {
for ( int c = 0; c < width; c++) {
myProjector.srcRowCol ( r, c, &mySrcRow, &mySrcCol );
for ( int r = 0; r < height; r++ )
{
for ( int c = 0; c < width; c++ )
{
myProjector.srcRowCol( r, c, &mySrcRow, &mySrcCol );
mySrcOffset = mySize * ( mySrcRow * myProjector.srcCols() + mySrcCol );
myDestOffset = mySize * ( r * width + c );
// retype to char is just to avoid g++ warning
memcpy( (char*) data + myDestOffset, (char*)mySrcData + mySrcOffset, mySize );
// retype to char is just to avoid g++ warning
memcpy(( char* ) data + myDestOffset, ( char* )mySrcData + mySrcOffset, mySize );
}
}
QgsDebugMsg( QString( "reproject block time (ms): %1" ).arg( time.elapsed() ) );
Expand Down
101 changes: 53 additions & 48 deletions src/core/qgsrasterdataprovider.h
Expand Up @@ -81,29 +81,29 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
/*! Complex Float64 */ CFloat64 = 11,
/*! Color, alpha, red, green, blue, 4 bytes */ ARGBDataType = 12,
TypeCount = 13 /* maximum type # + 1 */
};
};

// This is modified copy of GDALColorInterp
enum ColorInterpretation
{
UndefinedColorInterpretation=0,
/*! Greyscale */ GrayIndex=1,
/*! Paletted (see associated color table) */ PaletteIndex=2,
/*! Red band of RGBA image */ RedBand=3,
/*! Green band of RGBA image */ GreenBand=4,
/*! Blue band of RGBA image */ BlueBand=5,
/*! Alpha (0=transparent, 255=opaque) */ AlphaBand=6,
/*! Hue band of HLS image */ HueBand=7,
/*! Saturation band of HLS image */ SaturationBand=8,
/*! Lightness band of HLS image */ LightnessBand=9,
/*! Cyan band of CMYK image */ CyanBand=10,
/*! Magenta band of CMYK image */ MagentaBand=11,
/*! Yellow band of CMYK image */ YellowBand=12,
/*! Black band of CMLY image */ BlackBand=13,
/*! Y Luminance */ YCbCr_YBand=14,
/*! Cb Chroma */ YCbCr_CbBand=15,
/*! Cr Chroma */ YCbCr_CrBand=16,
/*! Max current value */ ColorInterpretationMax=16
UndefinedColorInterpretation = 0,
/*! Greyscale */ GrayIndex = 1,
/*! Paletted (see associated color table) */ PaletteIndex = 2,
/*! Red band of RGBA image */ RedBand = 3,
/*! Green band of RGBA image */ GreenBand = 4,
/*! Blue band of RGBA image */ BlueBand = 5,
/*! Alpha (0=transparent, 255=opaque) */ AlphaBand = 6,
/*! Hue band of HLS image */ HueBand = 7,
/*! Saturation band of HLS image */ SaturationBand = 8,
/*! Lightness band of HLS image */ LightnessBand = 9,
/*! Cyan band of CMYK image */ CyanBand = 10,
/*! Magenta band of CMYK image */ MagentaBand = 11,
/*! Yellow band of CMYK image */ YellowBand = 12,
/*! Black band of CMLY image */ BlackBand = 13,
/*! Y Luminance */ YCbCr_YBand = 14,
/*! Cb Chroma */ YCbCr_CbBand = 15,
/*! Cr Chroma */ YCbCr_CrBand = 16,
/*! Max current value */ ColorInterpretationMax = 16
};

QgsRasterDataProvider();
Expand Down Expand Up @@ -164,23 +164,23 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
// TODO: Get the file masks supported by this provider, suitable for feeding into the file open dialog box

/** Returns data type for the band specified by number */
virtual int dataType ( int bandNo ) const
virtual int dataType( int bandNo ) const
{
return srcDataType ( bandNo );
return srcDataType( bandNo );
}

/** Returns source data type for the band specified by number,
* source data type may be shorter than dataType
* source data type may be shorter than dataType
*/
virtual int srcDataType ( int bandNo ) const
virtual int srcDataType( int bandNo ) const
{
return QgsRasterDataProvider::UnknownDataType;
}

int typeSize ( int dataType ) const
int typeSize( int dataType ) const
{
// modified copy from GDAL
switch( dataType )
switch ( dataType )
{
case Byte:
return 8;
Expand Down Expand Up @@ -210,24 +210,27 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
return 0;
}
}
int dataTypeSize ( int bandNo ) const
int dataTypeSize( int bandNo ) const
{
return typeSize ( dataType ( bandNo ) );
return typeSize( dataType( bandNo ) );
}

/** Get numbur of bands */
virtual int bandCount() const {
virtual int bandCount() const
{
return 1;
}

/** Returns data type for the band specified by number */
virtual int colorInterpretation ( int theBandNo ) const {
virtual int colorInterpretation( int theBandNo ) const
{
return QgsRasterDataProvider::UndefinedColorInterpretation;
}

QString colorName ( int colorInterpretation ) const {
QString colorName( int colorInterpretation ) const
{
// Modified copy from GDAL
switch( colorInterpretation )
switch ( colorInterpretation )
{
case UndefinedColorInterpretation:
return "Undefined";
Expand Down Expand Up @@ -285,23 +288,24 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
}
}
/** Reload data (data could change) */
virtual bool reload ( ) { return true; }
virtual bool reload( ) { return true; }

virtual QString colorInterpretationName ( int theBandNo ) const {
return colorName ( colorInterpretation ( theBandNo ) );
virtual QString colorInterpretationName( int theBandNo ) const
{
return colorName( colorInterpretation( theBandNo ) );
}

/** Get block size */
virtual int xBlockSize() const { return 0; }
virtual int yBlockSize() const { return 0; }

/** Get raster size */
virtual int xSize() const { return 0; }
virtual int ySize() const { return 0; }

/** read block of data */
// TODO clarify what happens on the last block (the part outside raster)
virtual void readBlock( int bandNo, int xBlock, int yBlock, void *data ){}
virtual void readBlock( int bandNo, int xBlock, int yBlock, void *data ) {}

/** read block of data using give extent and size */
virtual void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, void *data ) {};
Expand All @@ -312,30 +316,31 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
/** value representing null data */
virtual double noDataValue() const { return 0; }

virtual double minimumValue(int bandNo)const { return 0; }
virtual double maximumValue(int bandNo)const { return 0; }
virtual double minimumValue( int bandNo )const { return 0; }
virtual double maximumValue( int bandNo )const { return 0; }

virtual QList<QgsColorRampShader::ColorRampItem> colorTable(int bandNo)const { return QList<QgsColorRampShader::ColorRampItem>(); }
virtual QList<QgsColorRampShader::ColorRampItem> colorTable( int bandNo )const { return QList<QgsColorRampShader::ColorRampItem>(); }

// Defined in parent
/** \brief Returns the sublayers of this layer - Useful for providers that manage their own layers, such as WMS */
virtual QStringList subLayers() const {
virtual QStringList subLayers() const
{
return QStringList();
}

/** \brief Populate the histogram vector for a given band */

virtual void populateHistogram( int theBandNoInt,
QgsRasterBandStats & theBandStats,
int theBinCountInt = 256,
bool theIgnoreOutOfRangeFlag = true,
bool theThoroughBandScanFlag = false
) {};
QgsRasterBandStats & theBandStats,
int theBinCountInt = 256,
bool theIgnoreOutOfRangeFlag = true,
bool theThoroughBandScanFlag = false
) {};

/** \brief Create pyramid overviews */
virtual QString buildPyramids( const QList<QgsRasterPyramid> & thePyramidList,
const QString & theResamplingMethod = "NEAREST",
bool theTryInternalFlag = false ) { return "FAILED_NOT_SUPPORTED"; };
const QString & theResamplingMethod = "NEAREST",
bool theTryInternalFlag = false ) { return "FAILED_NOT_SUPPORTED"; };

/** \brief Accessor for ths raster layers pyramid list. A pyramid list defines the
* POTENTIAL pyramids that can be in a raster. To know which of the pyramid layers
Expand All @@ -346,7 +351,7 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider


/** \brief helper function to create zero padded band names */
QString generateBandName( int theBandNumber )
QString generateBandName( int theBandNumber )
{
return tr( "Band" ) + QString( " %1" ) .arg( theBandNumber, 1 + ( int ) log10(( float ) bandCount() ), 10, QChar( '0' ) );
}
Expand Down

0 comments on commit 4dc5e26

Please sign in to comment.