Added precomipler directives to disable stdout debug info if DEBUG is not set.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@670 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2004-02-01 09:41:44 +00:00
parent 2174bea6b3
commit b78995e3e8
2 changed files with 71 additions and 2 deletions

View File

@ -51,8 +51,18 @@ and the code easy to read (especially by people who did not write it!).
The [name] part of the variable should be short and descriptive, usually a noun.
The [type] part of the variable should be the type class of the variable written out in full.
DEBUG DIRECTIVES:
When compiling you can make sure DEBUG is defined by including -DDEBUG in the gcc command (e.g. gcc -DDEBUG myprog.c ) if you
wish to see edbug messages printed to stdout.
*/
#include <qpainter.h>
#include <qimage.h>
#include <qfont.h>
@ -72,7 +82,6 @@ QgsRasterLayer::QgsRasterLayer(QString path, QString baseName)
//popMenu is the contextmenu obtained by right clicking on the legend
//it is a member of the qgsmaplayer base class
popMenu=0;
//std::cout << "QgsRasterLayer::QgsRasterLayer()" << std::endl;
// set the layer name (uppercase first character)
QString layerTitle = baseName;
@ -86,7 +95,6 @@ QgsRasterLayer::QgsRasterLayer(QString path, QString baseName)
valid = FALSE;
return;
}
//std::cout << "Raster Count: " << gdalDataset->GetRasterCount() << std::endl;
if( gdalDataset->GetGeoTransform( adfGeoTransform ) == CE_None )
{
@ -229,19 +237,27 @@ unsigned int QgsRasterLayer::getTransparency()
that in muliband layers more than one "Undefined" band can exist! */
bool QgsRasterLayer::hasBand(QString theBandName)
{
#ifdef DEBUG
std::cout << "Looking for band : " << theBandName << std::endl;
#endif
for (int i = 1; i <= gdalDataset->GetRasterCount(); i++)
{
GDALRasterBand *myGdalBand = gdalDataset->GetRasterBand( i );
QString myColorQString = GDALGetColorInterpretationName(myGdalBand->GetColorInterpretation());
#ifdef DEBUG
std::cout << "band : " << i << std::endl;
#endif
if (myColorQString==theBandName)
{
#ifdef DEBUG
std::cout << "band : " << i << std::endl;
std::cout << "Found band : " << theBandName << std::endl;
#endif
return true;
}
#ifdef DEBUG
std::cout << "Found unmatched band : " << i << " " << myColorQString << std::endl;
#endif
}
return false;
}
@ -398,7 +414,9 @@ void QgsRasterLayer::draw(QPainter * theQPainter, QgsRect * theViewExtent, QgsCo
}
else
{
#ifdef DEBUG
std::cout << "PALETTED_SINGLE_BAND_GRAY drawing type detected..." << std::endl;
#endif
int myBandNoInt=1;
drawPalettedSingleBandGray(theQPainter, myRasterViewPort, myBandNoInt,grayBandNameQString);
@ -424,11 +442,15 @@ void QgsRasterLayer::draw(QPainter * theQPainter, QgsRect * theViewExtent, QgsCo
break;
// a layer containing 2 or more bands, but using only one band to produce a grayscale image
case MULTI_BAND_SINGLE_BAND_GRAY:
#ifdef DEBUG
std::cout << "MULTI_BAND_SINGLE_BAND_GRAY drawing type detected..." << std::endl;
#endif
//check the band is set!
if (grayBandNameQString==tr("Not Set"))
{
#ifdef DEBUG
std::cout << "MULTI_BAND_SINGLE_BAND_GRAY Not Set detected..." << grayBandNameQString << std::endl;
#endif
break;
}
else
@ -476,7 +498,9 @@ void QgsRasterLayer::drawSingleBandGray(QPainter * theQPainter,
RasterViewPort * theRasterViewPort,
int theBandNoInt)
{
#ifdef DEBUG
std::cout << "QgsRasterLayer::drawSingleBandGray called for layer " << theBandNoInt << std::endl;
#endif
//create the outout image that the layer will be drawn on before placing it in the qcanvas
GDALRasterBand *myGdalBand = gdalDataset->GetRasterBand( theBandNoInt );
// QPixmap * myQPixmap=new QPixmap(theRasterViewPort->drawableAreaXDimInt,theRasterViewPort->drawableAreaYDimInt);
@ -500,9 +524,13 @@ void QgsRasterLayer::drawSingleBandGray(QPainter * theQPainter,
QImage myQImage=QImage(theRasterViewPort->drawableAreaXDimInt,theRasterViewPort->drawableAreaYDimInt,32);
myQImage.setAlphaBuffer(true);
#ifdef DEBUG
std::cout << "draw gray band Retrieving stats" << std::endl;
#endif
RasterBandStats myRasterBandStats = getRasterBandStats(theBandNoInt);
#ifdef DEBUG
std::cout << "draw gray band Git stats" << std::endl;
#endif
double myRangeDouble=myRasterBandStats.rangeDouble;
// print each point in myGdalScanData with equal parts R, G ,B o make it show as gray
for (int myColumnInt = 0; myColumnInt < theRasterViewPort->drawableAreaYDimInt; myColumnInt++)
@ -538,7 +566,9 @@ void QgsRasterLayer::drawSingleBandGray(QPainter * theQPainter,
void QgsRasterLayer::drawSingleBandPseudoColor(QPainter * theQPainter, RasterViewPort * theRasterViewPort, int theBandNoInt)
{
#ifdef DEBUG
std::cout << "QgsRasterLayer::drawSingleBandPseudoColor called" << std::endl;
#endif
GDALRasterBand *myGdalBand = gdalDataset->GetRasterBand( theBandNoInt );
//create the outout image that the layer will be drawn on before placing it in the qcanvas
@ -699,7 +729,9 @@ void QgsRasterLayer::drawPalettedSingleBandGray(QPainter * theQPainter,
int theBandNoInt,
QString theColorQString)
{
#ifdef DEBUG
std::cout << "QgsRasterLayer::drawPalettedSingleBandGray called" << std::endl;
#endif
// read entire clipped area of raster band
// treat myGdalScanData as a pseudo-multidimensional array
// RasterIO() takes care of scaling down image
@ -780,7 +812,9 @@ void QgsRasterLayer::drawPalettedSingleBandPseudoColor(QPainter * theQPainter,
int theBandNoInt,
QString theColorQString)
{
#ifdef DEBUG
std::cout << "QgsRasterLayer::drawPalettedSingleBandPseudoColor called" << std::endl;
#endif
// read entire clipped area of raster band
// treat myGdalScanData as a pseudo-multidimensional array
// RasterIO() takes care of scaling down image
@ -965,7 +999,9 @@ void QgsRasterLayer::drawPalettedMultiBandColor(QPainter * theQPainter,
RasterViewPort * theRasterViewPort,
int theBandNoInt)
{
#ifdef DEBUG
std::cout << "QgsRasterLayer::drawPalettedMultiBandColor called" << std::endl;
#endif
// read entire clipped area of raster band
// treat myGdalScanData as a pseudo-multidimensional array
@ -1066,7 +1102,9 @@ void QgsRasterLayer::drawMultiBandSingleBandPseudoColor(QPainter * theQPainter,
void QgsRasterLayer::drawMultiBandColor(QPainter * theQPainter,
RasterViewPort * theRasterViewPort)
{
#ifdef DEBUG
std::cout << "QgsRasterLayer::drawMultiBandColor called" << std::endl;
#endif
int myRedBandNoInt = getRasterBandNumber(redBandNameQString);
int myGreenBandNoInt = getRasterBandNumber(greenBandNameQString);
@ -1254,7 +1292,9 @@ const bool QgsRasterLayer::hasStats(int theBandNoInt)
const RasterBandStats QgsRasterLayer::getRasterBandStats(int theBandNoInt)
{
#ifdef DEBUG
std::cout << "QgsRasterLayer::calculate stats for band " << theBandNoInt << std::endl;
#endif
//check if we have received a valid band number
if ((gdalDataset->GetRasterCount() < theBandNoInt) && rasterLayerType!=PALETTE)
{

View File

@ -190,14 +190,18 @@ QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer * lyr) : QgsRaste
else //all other layer types use band name entries only
{
#ifdef DEBUG
std::cout << "Populating combos for non paletted layer" << std::endl;
#endif
int myBandCountInt = 1;
for ( QStringList::Iterator myIterator = myBandNameQStringList.begin();
myIterator != myBandNameQStringList.end();
++myIterator )
{
QString myQString=*myIterator;
#ifdef DEBUG
std::cout << "Inserting : " << myQString << std::endl;
#endif
cboGray->insertItem(myQString);
cboRed->insertItem(myQString);
cboGreen->insertItem(myQString);
@ -261,12 +265,16 @@ void QgsRasterLayerProperties::apply()
if(cboColorMap->currentText()==tr("Pseudocolor"))
{
#ifdef DEBUG
std::cout << "Setting Raster Drawing Style to :: SINGLE_BAND_PSEUDO_COLOR" << std::endl;
#endif
rasterLayer->setDrawingStyle(QgsRasterLayer::SINGLE_BAND_PSEUDO_COLOR);
}
else
{
#ifdef DEBUG
std::cout << "Setting Raster Drawing Style to :: SINGLE_BAND_GRAY" << std::endl;
#endif
rasterLayer->setDrawingStyle(QgsRasterLayer::SINGLE_BAND_GRAY);
}
}
@ -277,12 +285,19 @@ void QgsRasterLayerProperties::apply()
{
if(cboColorMap->currentText()==tr("Pseudocolor"))
{
#ifdef DEBUG
std::cout << "Setting Raster Drawing Style to :: PALETTED_SINGLE_BAND_PSEUDO_COLOR" << std::endl;
#endif
rasterLayer->setDrawingStyle(QgsRasterLayer::PALETTED_SINGLE_BAND_PSEUDO_COLOR);
}
else
{
#ifdef DEBUG
std::cout << "Setting Raster Drawing Style to :: PALETTED_SINGLE_BAND_GRAY" << std::endl;
#endif
#ifdef DEBUG
std::cout << "Combo value : " << cboGray->currentText() << " GrayBand Mapping : " << rasterLayer->getGrayBandName() << std::endl;
#endif
rasterLayer->setDrawingStyle(QgsRasterLayer::PALETTED_SINGLE_BAND_GRAY);
}
@ -295,13 +310,17 @@ void QgsRasterLayerProperties::apply()
{
if(cboColorMap->currentText()==tr("Pseudocolor"))
{
#ifdef DEBUG
std::cout << "Setting Raster Drawing Style to ::MULTI_BAND_SINGLE_BAND_PSEUDO_COLOR " << std::endl;
#endif
rasterLayer->setDrawingStyle(QgsRasterLayer::MULTI_BAND_SINGLE_BAND_PSEUDO_COLOR);
}
else
{
#ifdef DEBUG
std::cout << "Setting Raster Drawing Style to :: MULTI_BAND_SINGLE_BAND_GRAY" << std::endl;
std::cout << "Combo value : " << cboGray->currentText() << " GrayBand Mapping : " << rasterLayer->getGrayBandName() << std::endl;
#endif
rasterLayer->setDrawingStyle(QgsRasterLayer::MULTI_BAND_SINGLE_BAND_GRAY);
}
}
@ -312,13 +331,17 @@ void QgsRasterLayerProperties::apply()
if (rasterLayer->rasterLayerType==QgsRasterLayer::PALETTE)
{
#ifdef DEBUG
std::cout << "Setting Raster Drawing Style to :: PALETTED_MULTI_BAND_COLOR" << std::endl;
#endif
rasterLayer->setDrawingStyle(QgsRasterLayer::PALETTED_MULTI_BAND_COLOR);
}
else if (rasterLayer->rasterLayerType==QgsRasterLayer::MULTIBAND)
{
#ifdef DEBUG
std::cout << "Setting Raster Drawing Style to :: MULTI_BAND_COLOR" << std::endl;
#endif
rasterLayer->setDrawingStyle(QgsRasterLayer::MULTI_BAND_COLOR);
}
@ -620,11 +643,15 @@ void QgsRasterLayerProperties::fillStatsTable()
myIteratorInt <= myBandCountInt;
++myIteratorInt)
{
#ifdef DEBUG
std::cout << "Raster properties : checking if band " << myIteratorInt << " has stats? ";
#endif
//check if full stats for this layer have already been collected
if (!rasterLayer->hasStats(myIteratorInt)) //not collected
{
#ifdef DEBUG
std::cout << ".....no" <<std::endl;
#endif
tblStats->setText(myRowInt,0,"Band");
tblStats->setText(myRowInt,1,rasterLayer->getRasterBandName(myIteratorInt));
++myRowInt;
@ -638,7 +665,9 @@ void QgsRasterLayerProperties::fillStatsTable()
}
else // collected - show full detail
{
#ifdef DEBUG
std::cout << ".....yes" <<std::endl;
#endif
RasterBandStats myRasterBandStats=rasterLayer->getRasterBandStats(myIteratorInt);
tblStats->setText(myRowInt,0,"Band");