Skip to content

Commit 2220a57

Browse files
author
homann
committed
Cleaned up and added debug output for north arrow plugin
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7982 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 4a737ec commit 2220a57

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

src/plugins/north_arrow/plugin.cpp

+25-19
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ email : tim@linfiniti.com
2828
#include "qgsmaplayer.h"
2929
#include "plugin.h"
3030
#include "qgsproject.h"
31+
#include "qgslogger.h"
3132
#include "qgsmapcanvas.h"
3233
#include "qgsmaprender.h"
3334
#include "qgsapplication.h"
3435

3536
// qt includes
3637
#include <QPainter>
3738
#include <QMenu>
39+
#include <QDir>
3840

3941
//non qt includes
4042
#include <iostream>
@@ -110,15 +112,13 @@ void QgsNorthArrowPlugin::initGui()
110112

111113
void QgsNorthArrowPlugin::projectRead()
112114
{
113-
#ifdef QGISDEBUG
114-
std::cout << "+++++++++ north arrow plugin - project read slot called...." << std::endl;
115-
#endif
116-
//default text to start with - try to fetch it from qgsproject
115+
QgsDebugMsg("+++++++++ north arrow plugin - project read slot called....");
116+
//default text to start with - try to fetch it from qgsproject
117117

118-
mRotationInt = QgsProject::instance()->readNumEntry("NorthArrow","/Rotation",0);
119-
mPlacementIndex = QgsProject::instance()->readNumEntry("NorthArrow","/Placement",0);
120-
mEnable = QgsProject::instance()->readBoolEntry("NorthArrow","/Enabled",true);
121-
mAutomatic = QgsProject::instance()->readBoolEntry("NorthArrow","/Automatic",true);
118+
mRotationInt = QgsProject::instance()->readNumEntry("NorthArrow","/Rotation",0);
119+
mPlacementIndex = QgsProject::instance()->readNumEntry("NorthArrow","/Placement",0);
120+
mEnable = QgsProject::instance()->readBoolEntry("NorthArrow","/Enabled",true);
121+
mAutomatic = QgsProject::instance()->readBoolEntry("NorthArrow","/Automatic",true);
122122
}
123123

124124
//method defined in interface
@@ -156,18 +156,25 @@ void QgsNorthArrowPlugin::refreshCanvas()
156156

157157
void QgsNorthArrowPlugin::renderNorthArrow(QPainter * theQPainter)
158158
{
159-
#ifdef QGISDEBUG
160-
std::cout << "Rendering n-arrow" << std::endl;
161-
#endif
159+
162160
//Large IF statement controlled by enable check box
163161
if (mEnable)
164162
{
163+
if (theQPainter->isActive())
164+
{
165+
QgsDebugMsg("Rendering north arrow on active painter");
166+
}
167+
else
168+
{
169+
QgsDebugMsg("Rendering north arrow on INactive painter!!!");
170+
}
171+
165172
QPixmap myQPixmap; //to store the north arrow image in
166173

167-
QString myFileNameQString = QgsApplication::pkgDataPath() +
168-
"/images/north_arrows/default.png";
174+
QString myFileNameQString = QDir::cleanPath( QgsApplication::pkgDataPath() +
175+
"/images/north_arrows/default.png" );
169176

170-
//std::cout << "Trying to load " << myFileNameQString << std::cout;
177+
QgsDebugMsg("Trying to load " + myFileNameQString);
171178
if (myQPixmap.load(myFileNameQString))
172179
{
173180

@@ -200,9 +207,8 @@ void QgsNorthArrowPlugin::renderNorthArrow(QPainter * theQPainter)
200207
int myHeight = theQPainter->device()->height();
201208
int myWidth = theQPainter->device()->width();
202209

203-
#ifdef QGISDEBUG
204-
std::cout << "Rendering n-arrow at " << mPlacementLabels.at(mPlacementIndex).toLocal8Bit().data() << std::endl;
205-
#endif
210+
QgsDebugMsg("Rendering north arrow at " + mPlacementLabels.at(mPlacementIndex));
211+
206212
//Determine placement of label from form combo box
207213
switch (mPlacementIndex)
208214
{
@@ -221,8 +227,7 @@ void QgsNorthArrowPlugin::renderNorthArrow(QPainter * theQPainter)
221227
myHeight-myQPixmap.height());
222228
break;
223229
default:
224-
std::cout << "Unable to determine where to put north arrow so defaulting to top left"
225-
<< std::endl;
230+
QgsDebugMsg("Unable to determine where to put north arrow so defaulting to top left");
226231
}
227232
//rotate the canvas by the north arrow rotation amount
228233
theQPainter->rotate( mRotationInt );
@@ -321,6 +326,7 @@ bool QgsNorthArrowPlugin::calculateNorthDirection()
321326
{
322327
UNUSED(e);
323328
// just give up
329+
QgsDebugMsg("Transformation error, quitting");
324330
return false;
325331
}
326332

0 commit comments

Comments
 (0)