Skip to content
Permalink
Browse files

more removed std::couts

git-svn-id: http://svn.osgeo.org/qgis/trunk@5209 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Apr 7, 2006
1 parent 0fa3f4e commit d1549cac4d271eaa95ebf3c58674cc1d928fe912
@@ -53,9 +53,6 @@ QgsLabelAttributes::QgsLabelAttributes( bool def )
mBorderWidthIsSet( false ),
mBorderStyleIsSet( false )
{
#ifdef QGISDEBUG
std::cerr << "QgsLabelAttributes::QgsLabelAttributes()" << std::endl;
#endif

if ( def ) { // set defaults
setText ( "Label" );
@@ -27,9 +27,8 @@
#define QgsDebugMsgLevel(str, level) QgsLogger::debug(QString(str), level,\
__FILE__, __FUNCTION__, __LINE__);
#else
#define QgsDebugMsg(str)
#define QgsDebugMsgVal(str, val, level)
#define QgsDebugMsgLevel(str, level) ""
#define QgsDebugMsg(str)
#define QgsDebugMsgLevel(str, level)
#endif

/**QgsLogger is a class to print debug/warning/error messages to the console. The advantage of this class over std::cout, std::cerr & co. is that the output can be controlled with environment variables:
@@ -20,6 +20,7 @@
#include <assert.h>
#include <math.h>
#include <qstring.h>
#include "qgslogger.h"
#include "qgsrect.h"
#include "qgsscalecalculator.h"

@@ -66,9 +67,7 @@ double QgsScaleCalculator::calculate(QgsRect &mapExtent, int canvasWidth)
assert("bad map units");
break;
}
#ifdef QGISDEBUG
std::cerr << "Using conversionFactor of " << conversionFactor << std::endl;
#endif
QgsDebugMsg("Using conversionFactor of " + QString::number(conversionFactor));
double scale = (delta * conversionFactor)/(canvasWidth/mDpi);
return scale;
}
@@ -97,10 +96,6 @@ double QgsScaleCalculator::calculateGeographicDistance(QgsRect &mapExtent)
double R = ra* sqrt(1-pow(e,2))/(1 - pow(e,2)*pow(sin(lat1*rads),2));
double d = c *R; // kilometers;
double meters = d * 1000.0;


#ifdef QGISDEBUG
std::cerr << "Distance across map extent (m): " << meters << std::endl;
#endif
QgsDebugMsg("Distance across map extent (m): " + QString::number(meters));
return meters;
}
@@ -48,9 +48,6 @@ static const char * const ident_ =

QgsLabel::QgsLabel( std::vector<QgsField> const & fields )
{
#ifdef QGISDEBUG
std::cerr << "QgsLabel::QgsLabel()" << std::endl;
#endif

mField = fields;
mLabelField.resize ( LabelFieldCount );
@@ -14,7 +14,7 @@
***************************************************************************/
/* $Id$ */


#include "qgslogger.h"
#include "qgsmaplayerset.h"
#include "qgsmaplayerregistry.h"
#include "qgsproject.h"
@@ -29,10 +29,7 @@ void QgsMapLayerSet::setLayerSet(const std::deque<QString>& layers)

void QgsMapLayerSet::updateFullExtent()
{
#ifdef QGISDEBUG
std::cout << "QgsMapLayerSet::updateFullExtent() called !" << std::endl;
#endif

QgsDebugMsg("QgsMapLayerSet::updateFullExtent() called !");
QgsMapLayerRegistry* registry = QgsMapLayerRegistry::instance();
bool projectionsEnabled = (QgsProject::instance()->readNumEntry("SpatialRefSys","/ProjectionsEnabled",0)!=0);

@@ -48,16 +45,13 @@ void QgsMapLayerSet::updateFullExtent()
QgsMapLayer * lyr = registry->mapLayer(*it);
if (lyr == NULL)
{
std::cout << "WARNING: layer '" << (*it).toLocal8Bit().data()
<< "' not found in map layer registry!" << std::endl;
QgsLogger::warning("WARNING: layer '" + (*it) + "' not found in map layer registry!");
}
else
{

#ifdef QGISDEBUG
std::cout << "Updating extent using " << lyr->name().toLocal8Bit().data() << std::endl;
std::cout << "Input extent: " << lyr->extent().stringRep().toLocal8Bit().data() << std::endl;
#endif
QgsDebugMsg("Updating extent using " + lyr->name());
QgsDebugMsg("Input extent: " + lyr->extent().stringRep());

// Layer extents are stored in the coordinate system (CS) of the
// layer. The extent must be projected to the canvas CS prior to passing
// on to the updateFullExtent function
@@ -72,7 +66,8 @@ void QgsMapLayerSet::updateFullExtent()
}
catch (QgsCsException &cse)
{
qDebug( "Transform error caught in %s line %d:\n%s", __FILE__, __LINE__, cse.what());
QgsLogger::warning("Transform error caught in " + QString(__FILE__) + " line " +\
QString::number(__LINE__) + QString(cse.what()));
}
}
else
@@ -16,6 +16,7 @@

#include <cmath>

#include "qgslogger.h"
#include "qgsmaprender.h"
#include "qgsscalecalculator.h"
#include "qgsmaptopixel.h"
@@ -143,14 +144,18 @@ void QgsMapRender::adjustExtentToSize()
}

#ifdef QGISDEBUG
std::cout << "========== Current Scale ==========" << std::endl;
std::cout << "Current extent is " << mExtent.stringRep().toLocal8Bit().data() << std::endl;
std::cout << "MuppX is: " << muppX << "\n" << "MuppY is: " << muppY << std::endl;
std::cout << "Pixmap width: " << myWidth << ", height: " << myHeight << std::endl;
std::cout << "Extent width: " << mExtent.width() << ", height: " << mExtent.height() << std::endl;
std::cout << "whitespace: " << whitespace << std::endl;
QgsDebugMsg("========== Current Scale ==========");
QgsDebugMsg("Current extent is " + mExtent.stringRep());
QgsLogger::debug("MuppX", muppX, 1, __FILE__, __FUNCTION__, __LINE__);
QgsLogger::debug("MuppY", muppY, 1, __FILE__, __FUNCTION__, __LINE__);
QgsLogger::debug("Pixmap width", myWidth, 1, __FILE__, __FUNCTION__, __LINE__);
QgsLogger::debug("Pixmap height", myHeight, 1, __FILE__, __FUNCTION__, __LINE__);
QgsLogger::debug("Extent width", mExtent.width(), 1, __FILE__, __FUNCTION__, __LINE__);
QgsLogger::debug("Extent height", mExtent.height(), 1, __FILE__, __FUNCTION__, __LINE__);
QgsLogger::debug("whitespace: ", whitespace, 1, __FILE__, __FUNCTION__, __LINE__);
#endif


// update extent
mExtent.setXmin(dxmin);
mExtent.setXmax(dxmax);
@@ -161,8 +166,7 @@ void QgsMapRender::adjustExtentToSize()
mScale = mScaleCalculator->calculate(mExtent, myWidth);

#ifdef QGISDEBUG
std::cout << "Scale (assuming meters as map units) = 1:" << mScale << std::endl;
std::cout << "------------------------------------------ " << std::endl;
QgsLogger::debug("Scale (assuming meters as map units) = 1", mScale, 1, __FILE__, __FUNCTION__, __LINE__);
#endif

mCoordXForm->setParameters(mMupp, dxmin, dymin, myHeight);
@@ -171,14 +175,11 @@ void QgsMapRender::adjustExtentToSize()

void QgsMapRender::render(QPainter* painter)
{

#ifdef QGISDEBUG
std::cout << "========== Rendering ==========" << std::endl;
#endif
QgsDebugMsg("========== Rendering ==========");

if (mExtent.isEmpty())
{
std::cout << "empty extent... not rendering" << endl;
QgsLogger::warning("empty extent... not rendering");
return;
}

@@ -191,7 +192,7 @@ void QgsMapRender::render(QPainter* painter)
int myRenderCounter = 0;

#ifdef QGISDEBUG
std::cout << "QgsMapRender::render: Starting to render layer stack." << std::endl;
QgsDebugMsg("QgsMapRender::render: Starting to render layer stack.");
QTime renderTime;
renderTime.start();
#endif
@@ -201,49 +202,41 @@ void QgsMapRender::render(QPainter* painter)

while (li != layers.end())
{
#ifdef QGISDEBUG
std::cout << "QgsMapRender::render: at layer item '" << (*li).toLocal8Bit().data() << "'." << std::endl;
#endif
QgsDebugMsg("QgsMapRender::render: at layer item '" + (*li));

// This call is supposed to cause the progress bar to
// advance. However, it seems that updating the progress bar is
// incompatible with having a QPainter active (the one that is
// passed into this function), as Qt produces a number of errors
// when try to do so. I'm (Gavin) not sure how to fix this, but
// added these comments and debug statement to help others...
std::cerr << "If there is a QPaintEngine error here, it is caused by an"
<< " emit call just after line " << __LINE__
<< " in file " << __FILE__ << ".\n";
QgsDebugMsg("If there is a QPaintEngine error here, it is caused by an emit call");

emit setProgress(myRenderCounter++,layers.size());
QgsMapLayer *ml = QgsMapLayerRegistry::instance()->mapLayer(*li);

if (!ml)
{
#ifdef QGISDEBUG
std::cout << "QgsMapRender::render: layer not found in registry!" << std::endl;
#endif
QgsLogger::warning("QgsMapRender::render: layer not found in registry!");
li++;
continue;
}

#ifdef QGISDEBUG
std::cout << "QgsMapRender::render: Rendering layer " << ml->name().toLocal8Bit().data() << '\n'
<< " Layer minscale " << ml->minScale()
<< ", maxscale " << ml->maxScale() << '\n'
<< " Scale dep. visibility enabled? "
<< ml->scaleBasedVisibility() << '\n'
<< " Input extent: " << ml->extent().stringRep().toLocal8Bit().data()
<< std::endl;
QgsDebugMsg("QgsMapRender::render: Rendering layer " + ml->name());
QgsLogger::debug(" Layer minscale ", ml->minScale(), 1, __FILE__, __FUNCTION__, __LINE__);
QgsLogger::debug(" Layer maxscale ", ml->maxScale(), 1, __FILE__, __FUNCTION__, __LINE__);
QgsLogger::debug(" Scale dep. visibility enabled? ", ml->scaleBasedVisibility(), 1,\
__FILE__, __FUNCTION__, __LINE__);
QgsLogger::debug(" Input extent: " + ml->extent().stringRep(), 1, __FILE__, __FUNCTION__, __LINE__);
try
{
std::cout << " Transformed extent: "
<< ml->coordinateTransform()->transformBoundingBox(ml->extent()).stringRep().toLocal8Bit().data()
<< std::endl;
QgsDebugMsg(" Transformed extent: " + ml->coordinateTransform()->transformBoundingBox(ml->extent()).stringRep());
}
catch (QgsCsException &cse)
{
qDebug( "Transform error caught in %s line %d:\n%s", __FILE__, __LINE__, cse.what());
QgsLogger::warning("Transform error caught in " + QString(__FILE__) + " line " + QString(__LINE__) +\
QString(cse.what()));
}
#endif

@@ -273,10 +266,8 @@ void QgsMapRender::render(QPainter* painter)
}
else
{
#ifdef QGISDEBUG
std::cout << "QgsMapRender::render: Layer not rendered because it is not within "
<< "the defined visibility scale range" << std::endl;
#endif
QgsDebugMsg("QgsMapRender::render: Layer not rendered because it is not within the defined \
visibility scale range")
}

} // if (ml->visible())
@@ -285,9 +276,7 @@ void QgsMapRender::render(QPainter* painter)

} // while (li != end)

#ifdef QGISDEBUG
std::cout << "QgsMapRender::render: Done rendering map layers" << std::endl;
#endif
QgsDebugMsg("QgsMapRender::render: Done rendering map layers");

if (!mOverview)
{
@@ -321,8 +310,8 @@ void QgsMapRender::render(QPainter* painter)
emit setProgress(1,1);

#ifdef QGISDEBUG
std::cout << "QgsMapRender::render: Rendering done in " <<
renderTime.elapsed() / 1000.0 << " seconds" << std::endl;
QgsLogger::debug("QgsMapRender::render: Rendering done in (seconds)", renderTime.elapsed() / 1000.0, 1,\
__FILE__, __FUNCTION__, __LINE__);
#endif

mDrawing = false;
@@ -902,19 +902,14 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * th
msg += cse.what();
qWarning(msg.toLocal8Bit().data());
}

#ifdef QGISDEBUG
std::cerr << "Total features processed is " << featureCount << std::endl;
#endif
QgsDebugMsg("Total features processed is " + QString::number(featureCount));
// XXX Something in our draw event is triggering an additional draw event when resizing [TE 01/26/06]
// XXX Calling this will begin processing the next draw event causing image havoc and recursion crashes.
//qApp->processEvents();
}
else
{
#ifdef QGISDEBUG
qWarning("Warning, QgsRenderer is null in QgsVectorLayer::draw()");
#endif
QgsLogger::warning("QgsRenderer is null in QgsVectorLayer::draw()");
}
}

@@ -2120,9 +2115,7 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )

// show the extent
QString s = mbr->stringRep();
#ifdef QGISDEBUG
std::cout << "Extent of layer: " << s.toLocal8Bit().data() << std::endl;
#endif
QgsDebugMsg("Extent of layer: " + s);
// store the extent
layerExtent.setXmax(mbr->xMax());
layerExtent.setXmin(mbr->xMin());
@@ -2138,16 +2131,11 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )

if (providerKey == "postgres")
{
#ifdef QGISDEBUG
std::cout << "Beautifying layer name " << layerName.toLocal8Bit().data() << std::endl;
#endif
QgsDebugMsg("Beautifying layer name " + layerName);
// adjust the display name for postgres layers
layerName = layerName.mid(layerName.find(".") + 1);
layerName = layerName.left(layerName.find("(") - 1); // Take one away, to avoid a trailing space
#ifdef QGISDEBUG
std::cout << "Beautified name is " << layerName.toLocal8Bit().data() << std::endl;
#endif

QgsDebugMsg("Beautifying layer name " + layerName);
}

// upper case the first letter of the layer name
@@ -3238,10 +3226,8 @@ void QgsVectorLayer::setCoordinateSystem()
//slot is defined inthe maplayer superclass
connect(mCoordinateTransform, SIGNAL(invalidTransformInput()), this, SLOT(invalidTransformInput()));

#ifdef QGISDEBUG
std::cout << "QgsVectorLayer::setCoordinateSystem ------------------------------------------------start" << std::endl;
std::cout << "QgsVectorLayer::setCoordinateSystem ----- Computing Coordinate System" << std::endl;
#endif
QgsDebugMsg("QgsVectorLayer::setCoordinateSystem ------------------------------------------------start");
QgsDebugMsg("QgsVectorLayer::setCoordinateSystem ----- Computing Coordinate System");
//
// Get the layers project info and set up the QgsCoordinateTransform
// for this layer
@@ -3255,18 +3241,13 @@ void QgsVectorLayer::setCoordinateSystem()
{
mySourceWKT=QString("");
}

#ifdef QGISDEBUG
std::cout << "QgsVectorLayer::setCoordinateSystem --- using wkt\n" << mySourceWKT.toLocal8Bit().data() << std::endl;
#endif
QgsDebugMsg("QgsVectorLayer::setCoordinateSystem --- using wkt " + mySourceWKT);
mCoordinateTransform->sourceSRS().createFromWkt(mySourceWKT);
//mCoordinateTransform->sourceSRS()->createFromWkt(getProjectionWKT());
}
else
{
#ifdef QGISDEBUG
std::cout << "QgsVectorLayer::setCoordinateSystem --- using srid " << srid << std::endl;
#endif
QgsDebugMsg("QgsVectorLayer::setCoordinateSystem --- using srid " + QString::number(srid));
mCoordinateTransform->sourceSRS().createFromSrid(srid);
}

@@ -3287,9 +3268,7 @@ void QgsVectorLayer::setCoordinateSystem()
// the same as the input projection, otherwise set the output to the
// project srs

#ifdef QGISDEBUG
std::cout << "Layer registry has " << QgsMapLayerRegistry::instance()->count() << " layers " << std::endl;
#endif
QgsDebugMsg("Layer registry has " + QString::number(QgsMapLayerRegistry::instance()->count()) + " layers ");
if (QgsMapLayerRegistry::instance()->count() ==0)
{
mCoordinateTransform->destSRS().createFromProj4(
@@ -1520,7 +1520,7 @@ const std::list<std::pair<QString, QString> >& attributes)
OGRDataSource::DestroyDataSource(dataSource);

#ifdef QGISDEBUG
QgsLogger::debug("GDAL Version number", GDAL_VERSION_NUM, __FILE__, __FUNCTION__, __LINE__);
QgsLogger::debug("GDAL Version number", GDAL_VERSION_NUM, 1, __FILE__, __FUNCTION__, __LINE__);
#endif
#if GDAL_VERSION_NUM >= 1310
if(reference)

0 comments on commit d1549ca

Please sign in to comment.
You can’t perform that action at this time.