Skip to content

Commit

Permalink
Make raster classes debug output less noisy
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 13, 2016
1 parent 4e9afce commit b2cc309
Show file tree
Hide file tree
Showing 22 changed files with 214 additions and 214 deletions.
14 changes: 7 additions & 7 deletions src/core/raster/qgsbrightnesscontrastfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ QgsBrightnessContrastFilter::~QgsBrightnessContrastFilter()

QgsBrightnessContrastFilter* QgsBrightnessContrastFilter::clone() const
{
QgsDebugMsg( "Entered" );
QgsDebugMsgLevel( "Entered", 4 );
QgsBrightnessContrastFilter * filter = new QgsBrightnessContrastFilter( nullptr );
filter->setBrightness( mBrightness );
filter->setContrast( mContrast );
Expand Down Expand Up @@ -74,19 +74,19 @@ QGis::DataType QgsBrightnessContrastFilter::dataType( int bandNo ) const

bool QgsBrightnessContrastFilter::setInput( QgsRasterInterface* input )
{
QgsDebugMsg( "Entered" );
QgsDebugMsgLevel( "Entered", 4 );

// Brightness filter can only work with single band ARGB32_Premultiplied
if ( !input )
{
QgsDebugMsg( "No input" );
QgsDebugMsgLevel( "No input", 4 );
return false;
}

if ( !mOn )
{
// In off mode we can connect to anything
QgsDebugMsg( "OK" );
QgsDebugMsgLevel( "OK", 4 );
mInput = input;
return true;
}
Expand All @@ -105,14 +105,14 @@ bool QgsBrightnessContrastFilter::setInput( QgsRasterInterface* input )
}

mInput = input;
QgsDebugMsg( "OK" );
QgsDebugMsgLevel( "OK", 4 );
return true;
}

QgsRasterBlock * QgsBrightnessContrastFilter::block( int bandNo, QgsRectangle const & extent, int width, int height )
{
Q_UNUSED( bandNo );
QgsDebugMsg( QString( "width = %1 height = %2 extent = %3" ).arg( width ).arg( height ).arg( extent.toString() ) );
QgsDebugMsgLevel( QString( "width = %1 height = %2 extent = %3" ).arg( width ).arg( height ).arg( extent.toString() ), 4 );

QgsRasterBlock *outputBlock = new QgsRasterBlock();
if ( !mInput )
Expand All @@ -132,7 +132,7 @@ QgsRasterBlock * QgsBrightnessContrastFilter::block( int bandNo, QgsRectangle c

if ( mBrightness == 0 && mContrast == 0 )
{
QgsDebugMsg( "No brightness changes." );
QgsDebugMsgLevel( "No brightness changes.", 4 );
delete outputBlock;
return inputBlock;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgscolorrampshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ QgsColorRampShader::QgsColorRampShader( double theMinimumValue, double theMaximu
, mColorRampType( INTERPOLATED )
, mClip( false )
{
QgsDebugMsg( "called." );
QgsDebugMsgLevel( "called.", 4 );
mMaximumColorCacheSize = 1024; //good starting value
mCurrentColorRampItemIndex = 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/raster/qgscontrastenhancement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ void QgsContrastEnhancement::setContrastEnhancementAlgorithm( ContrastEnhancemen
*/
void QgsContrastEnhancement::setContrastEnhancementFunction( QgsContrastEnhancementFunction* theFunction )
{
QgsDebugMsg( "called" );
QgsDebugMsgLevel( "called", 4 );

if ( theFunction )
{
Expand All @@ -310,7 +310,7 @@ void QgsContrastEnhancement::setContrastEnhancementFunction( QgsContrastEnhancem
*/
void QgsContrastEnhancement::setMaximumValue( double theValue, bool generateTable )
{
QgsDebugMsg( "called value: " + QString::number( theValue ) + " generate lookup table: " + QString::number( static_cast< int >( generateTable ) ) );
QgsDebugMsgLevel( "called value: " + QString::number( theValue ) + " generate lookup table: " + QString::number( static_cast< int >( generateTable ) ), 4 );

if ( theValue > maximumValuePossible( mRasterDataType ) )
{
Expand Down Expand Up @@ -342,7 +342,7 @@ void QgsContrastEnhancement::setMaximumValue( double theValue, bool generateTabl
*/
void QgsContrastEnhancement::setMinimumValue( double theValue, bool generateTable )
{
QgsDebugMsg( "called value: " + QString::number( theValue ) + " generate lookup table: " + QString::number( static_cast< int >( generateTable ) ) );
QgsDebugMsgLevel( "called value: " + QString::number( theValue ) + " generate lookup table: " + QString::number( static_cast< int >( generateTable ) ), 4 );

if ( theValue < minimumValuePossible( mRasterDataType ) )
{
Expand Down
12 changes: 6 additions & 6 deletions src/core/raster/qgshuesaturationfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ QgsHueSaturationFilter::~QgsHueSaturationFilter()

QgsHueSaturationFilter* QgsHueSaturationFilter::clone() const
{
QgsDebugMsg( "Entered hue/saturation filter" );
QgsDebugMsgLevel( "Entered hue/saturation filter", 4 );
QgsHueSaturationFilter * filter = new QgsHueSaturationFilter( nullptr );
filter->setSaturation( mSaturation );
filter->setGrayscaleMode( mGrayscaleMode );
Expand Down Expand Up @@ -83,7 +83,7 @@ QGis::DataType QgsHueSaturationFilter::dataType( int bandNo ) const

bool QgsHueSaturationFilter::setInput( QgsRasterInterface* input )
{
QgsDebugMsg( "Entered" );
QgsDebugMsgLevel( "Entered", 4 );

// Hue/saturation filter can only work with single band ARGB32_Premultiplied
if ( !input )
Expand All @@ -95,7 +95,7 @@ bool QgsHueSaturationFilter::setInput( QgsRasterInterface* input )
if ( !mOn )
{
// In off mode we can connect to anything
QgsDebugMsg( "OK" );
QgsDebugMsgLevel( "OK", 4 );
mInput = input;
return true;
}
Expand All @@ -114,14 +114,14 @@ bool QgsHueSaturationFilter::setInput( QgsRasterInterface* input )
}

mInput = input;
QgsDebugMsg( "OK" );
QgsDebugMsgLevel( "OK", 4 );
return true;
}

QgsRasterBlock * QgsHueSaturationFilter::block( int bandNo, QgsRectangle const & extent, int width, int height )
{
Q_UNUSED( bandNo );
QgsDebugMsg( QString( "width = %1 height = %2 extent = %3" ).arg( width ).arg( height ).arg( extent.toString() ) );
QgsDebugMsgLevel( QString( "width = %1 height = %2 extent = %3" ).arg( width ).arg( height ).arg( extent.toString() ), 4 );

QgsRasterBlock *outputBlock = new QgsRasterBlock();
if ( !mInput )
Expand All @@ -141,7 +141,7 @@ QgsRasterBlock * QgsHueSaturationFilter::block( int bandNo, QgsRectangle const

if ( mSaturation == 0 && mGrayscaleMode == GrayscaleOff && !mColorizeOn )
{
QgsDebugMsg( "No hue/saturation change." );
QgsDebugMsgLevel( "No hue/saturation change.", 4 );
delete outputBlock;
return inputBlock;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgspalettedrasterrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ QgsRasterRenderer* QgsPalettedRasterRenderer::create( const QDomElement& elem, Q
value = ( int )entryElem.attribute( "value", "0" ).toDouble();
if ( value >= nColors && value <= 10000 ) nColors = value + 1;
}
QgsDebugMsg( QString( "nColors = %1" ).arg( nColors ) );
QgsDebugMsgLevel( QString( "nColors = %1" ).arg( nColors ), 4 );

colors = new QRgb[ nColors ];

for ( int i = 0; i < nColors; ++i )
{
entryElem = paletteEntries.at( i ).toElement();
value = ( int )entryElem.attribute( "value", "0" ).toDouble();
QgsDebugMsg( entryElem.attribute( "color", "#000000" ) );
QgsDebugMsgLevel( entryElem.attribute( "color", "#000000" ), 4 );
if ( value >= 0 && value < nColors )
{
colors[value] = QColor( entryElem.attribute( "color", "#000000" ) ).rgba();
Expand Down
52 changes: 26 additions & 26 deletions src/core/raster/qgsrasterblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ QgsRasterBlock::QgsRasterBlock( QGis::DataType theDataType, int theWidth, int th

QgsRasterBlock::~QgsRasterBlock()
{
QgsDebugMsg( QString( "mData = %1" ).arg( reinterpret_cast< ulong >( mData ) ) );
QgsDebugMsgLevel( QString( "mData = %1" ).arg( reinterpret_cast< ulong >( mData ) ), 4 );
qgsFree( mData );
delete mImage;
qgsFree( mNoDataBitmap );
}

bool QgsRasterBlock::reset( QGis::DataType theDataType, int theWidth, int theHeight )
{
QgsDebugMsg( QString( "theWidth= %1 theHeight = %2 theDataType = %3" ).arg( theWidth ).arg( theHeight ).arg( theDataType ) );
QgsDebugMsgLevel( QString( "theWidth= %1 theHeight = %2 theDataType = %3" ).arg( theWidth ).arg( theHeight ).arg( theDataType ), 4 );
if ( !reset( theDataType, theWidth, theHeight, std::numeric_limits<double>::quiet_NaN() ) )
{
return false;
Expand All @@ -98,7 +98,7 @@ bool QgsRasterBlock::reset( QGis::DataType theDataType, int theWidth, int theHei

bool QgsRasterBlock::reset( QGis::DataType theDataType, int theWidth, int theHeight, double theNoDataValue )
{
QgsDebugMsg( QString( "theWidth= %1 theHeight = %2 theDataType = %3 theNoDataValue = %4" ).arg( theWidth ).arg( theHeight ).arg( theDataType ).arg( theNoDataValue ) );
QgsDebugMsgLevel( QString( "theWidth= %1 theHeight = %2 theDataType = %3 theNoDataValue = %4" ).arg( theWidth ).arg( theHeight ).arg( theDataType ).arg( theNoDataValue ), 4 );

qgsFree( mData );
mData = nullptr;
Expand All @@ -116,9 +116,9 @@ bool QgsRasterBlock::reset( QGis::DataType theDataType, int theWidth, int theHei

if ( typeIsNumeric( theDataType ) )
{
QgsDebugMsg( "Numeric type" );
QgsDebugMsgLevel( "Numeric type", 4 );
qgssize tSize = typeSize( theDataType );
QgsDebugMsg( QString( "allocate %1 bytes" ).arg( tSize * theWidth * theHeight ) );
QgsDebugMsgLevel( QString( "allocate %1 bytes" ).arg( tSize * theWidth * theHeight ), 4 );
mData = qgsMalloc( tSize * theWidth * theHeight );
if ( !mData )
{
Expand All @@ -128,7 +128,7 @@ bool QgsRasterBlock::reset( QGis::DataType theDataType, int theWidth, int theHei
}
else if ( typeIsColor( theDataType ) )
{
QgsDebugMsg( "Color type" );
QgsDebugMsgLevel( "Color type", 4 );
QImage::Format format = imageFormat( theDataType );
mImage = new QImage( theWidth, theHeight, format );
}
Expand All @@ -145,8 +145,8 @@ bool QgsRasterBlock::reset( QGis::DataType theDataType, int theWidth, int theHei
mHeight = theHeight;
mHasNoDataValue = true;
mNoDataValue = theNoDataValue;
QgsDebugMsg( QString( "mWidth= %1 mHeight = %2 mDataType = %3 mData = %4 mImage = %5" ).arg( mWidth ).arg( mHeight ).arg( mDataType )
.arg( reinterpret_cast< ulong >( mData ) ).arg( reinterpret_cast< ulong >( mImage ) ) );
QgsDebugMsgLevel( QString( "mWidth= %1 mHeight = %2 mDataType = %3 mData = %4 mImage = %5" ).arg( mWidth ).arg( mHeight ).arg( mDataType )
.arg( reinterpret_cast< ulong >( mData ) ).arg( reinterpret_cast< ulong >( mImage ) ), 4 );
return true;
}

Expand Down Expand Up @@ -178,8 +178,8 @@ QGis::DataType QgsRasterBlock::dataType( QImage::Format theFormat )

bool QgsRasterBlock::isEmpty() const
{
QgsDebugMsg( QString( "mWidth= %1 mHeight = %2 mDataType = %3 mData = %4 mImage = %5" ).arg( mWidth ).arg( mHeight ).arg( mDataType )
.arg( reinterpret_cast< ulong >( mData ) ).arg( reinterpret_cast< ulong >( mImage ) ) );
QgsDebugMsgLevel( QString( "mWidth= %1 mHeight = %2 mDataType = %3 mData = %4 mImage = %5" ).arg( mWidth ).arg( mHeight ).arg( mDataType )
.arg( reinterpret_cast< ulong >( mData ) ).arg( reinterpret_cast< ulong >( mImage ) ), 4 );
if ( mWidth == 0 || mHeight == 0 ||
( typeIsNumeric( mDataType ) && !mData ) ||
( typeIsColor( mDataType ) && !mImage ) )
Expand Down Expand Up @@ -265,10 +265,10 @@ QGis::DataType QgsRasterBlock::typeWithNoDataValue( QGis::DataType dataType, dou
newDataType = QGis::Float64;
break;
default:
QgsDebugMsg( QString( "Unknow data type %1" ).arg( dataType ) );
QgsDebugMsg( QString( "Unknown data type %1" ).arg( dataType ) );
return QGis::UnknownDataType;
}
QgsDebugMsg( QString( "newDataType = %1 noDataValue = %2" ).arg( newDataType ).arg( *noDataValue ) );
QgsDebugMsgLevel( QString( "newDataType = %1 noDataValue = %2" ).arg( newDataType ).arg( *noDataValue ), 4 );
return newDataType;
}

Expand Down Expand Up @@ -424,7 +424,7 @@ bool QgsRasterBlock::setIsNoData( qgssize index )

bool QgsRasterBlock::setIsNoData()
{
QgsDebugMsg( "Entered" );
QgsDebugMsgLevel( "Entered", 4 );
if ( typeIsNumeric( mDataType ) )
{
if ( mHasNoDataValue )
Expand All @@ -435,7 +435,7 @@ bool QgsRasterBlock::setIsNoData()
return false;
}

QgsDebugMsg( "set mData to mNoDataValue" );
QgsDebugMsgLevel( "set mData to mNoDataValue", 4 );
int dataTypeSize = typeSize( mDataType );
QByteArray noDataByteArray = valueBytes( mDataType, mNoDataValue );

Expand All @@ -455,7 +455,7 @@ bool QgsRasterBlock::setIsNoData()
return false;
}
}
QgsDebugMsg( "set mNoDataBitmap to 1" );
QgsDebugMsgLevel( "set mNoDataBitmap to 1", 4 );
memset( mNoDataBitmap, 0xff, mNoDataBitmapSize );
}
return true;
Expand All @@ -468,7 +468,7 @@ bool QgsRasterBlock::setIsNoData()
QgsDebugMsg( "Image not allocated" );
return false;
}
QgsDebugMsg( "Fill image" );
QgsDebugMsgLevel( "Fill image", 4 );
mImage->fill( mNoDataColor );
return true;
}
Expand All @@ -485,7 +485,7 @@ bool QgsRasterBlock::setIsNoDataExcept( const QRect & theExceptRect )
bottom = qMax( 0, qMin( bottom, mHeight - 1 ) );
right = qMax( 0, qMin( right, mWidth - 1 ) );

QgsDebugMsg( "Entered" );
QgsDebugMsgLevel( "Entered", 4 );
if ( typeIsNumeric( mDataType ) )
{
if ( mHasNoDataValue )
Expand All @@ -496,7 +496,7 @@ bool QgsRasterBlock::setIsNoDataExcept( const QRect & theExceptRect )
return false;
}

QgsDebugMsg( "set mData to mNoDataValue" );
QgsDebugMsgLevel( "set mData to mNoDataValue", 4 );
int dataTypeSize = typeSize( mDataType );
QByteArray noDataByteArray = valueBytes( mDataType, mNoDataValue );

Expand Down Expand Up @@ -537,7 +537,7 @@ bool QgsRasterBlock::setIsNoDataExcept( const QRect & theExceptRect )
return false;
}
}
QgsDebugMsg( "set mNoDataBitmap to 1" );
QgsDebugMsgLevel( "set mNoDataBitmap to 1", 4 );

char *nodataRow = new char[mNoDataBitmapWidth]; // full row of no data
// TODO: we can simply set all bytes to 11111111 (~0) I think
Expand Down Expand Up @@ -591,7 +591,7 @@ bool QgsRasterBlock::setIsNoDataExcept( const QRect & theExceptRect )
return false;
}

QgsDebugMsg( QString( "Fill image depth = %1" ).arg( mImage->depth() ) );
QgsDebugMsgLevel( QString( "Fill image depth = %1" ).arg( mImage->depth() ), 4 );

// TODO: support different depths
if ( mImage->depth() != 32 )
Expand Down Expand Up @@ -666,7 +666,7 @@ char * QgsRasterBlock::bits( qgssize index )
// Not testing type to avoid too much overhead because this method is called per pixel
if ( index >= static_cast< qgssize >( mWidth )*mHeight )
{
QgsDebugMsg( QString( "Index %1 out of range (%2 x %3)" ).arg( index ).arg( mWidth ).arg( mHeight ) );
QgsDebugMsgLevel( QString( "Index %1 out of range (%2 x %3)" ).arg( index ).arg( mWidth ).arg( mHeight ), 4 );
return nullptr;
}
if ( mData )
Expand Down Expand Up @@ -898,7 +898,7 @@ bool QgsRasterBlock::createNoDataBitmap()
{
mNoDataBitmapWidth = mWidth / 8 + 1;
mNoDataBitmapSize = static_cast< qgssize >( mNoDataBitmapWidth ) * mHeight;
QgsDebugMsg( QString( "allocate %1 bytes" ).arg( mNoDataBitmapSize ) );
QgsDebugMsgLevel( QString( "allocate %1 bytes" ).arg( mNoDataBitmapSize ), 4 );
mNoDataBitmap = reinterpret_cast< char* >( qgsMalloc( mNoDataBitmapSize ) );
if ( !mNoDataBitmap )
{
Expand All @@ -917,12 +917,12 @@ QString QgsRasterBlock::toString() const

QRect QgsRasterBlock::subRect( const QgsRectangle & theExtent, int theWidth, int theHeight, const QgsRectangle & theSubExtent )
{
QgsDebugMsg( "theExtent = " + theExtent.toString() );
QgsDebugMsg( "theSubExtent = " + theSubExtent.toString() );
QgsDebugMsgLevel( "theExtent = " + theExtent.toString(), 4 );
QgsDebugMsgLevel( "theSubExtent = " + theSubExtent.toString(), 4 );
double xRes = theExtent.width() / theWidth;
double yRes = theExtent.height() / theHeight;

QgsDebugMsg( QString( "theWidth = %1 theHeight = %2 xRes = %3 yRes = %4" ).arg( theWidth ).arg( theHeight ).arg( xRes ).arg( yRes ) );
QgsDebugMsgLevel( QString( "theWidth = %1 theHeight = %2 xRes = %3 yRes = %4" ).arg( theWidth ).arg( theHeight ).arg( xRes ).arg( yRes ), 4 );

int top = 0;
int bottom = theHeight - 1;
Expand All @@ -947,6 +947,6 @@ QRect QgsRasterBlock::subRect( const QgsRectangle & theExtent, int theWidth, int
right = qRound(( theSubExtent.xMaximum() - theExtent.xMinimum() ) / xRes ) - 1;
}
QRect subRect = QRect( left, top, right - left + 1, bottom - top + 1 );
QgsDebugMsg( QString( "subRect: %1 %2 %3 %4" ).arg( subRect.x() ).arg( subRect.y() ).arg( subRect.width() ).arg( subRect.height() ) );
QgsDebugMsgLevel( QString( "subRect: %1 %2 %3 %4" ).arg( subRect.x() ).arg( subRect.y() ).arg( subRect.width() ).arg( subRect.height() ), 4 );
return subRect;
}
Loading

0 comments on commit b2cc309

Please sign in to comment.