@@ -28,13 +28,15 @@ email : tim@linfiniti.com
28
28
#include " qgsmaplayer.h"
29
29
#include " plugin.h"
30
30
#include " qgsproject.h"
31
+ #include " qgslogger.h"
31
32
#include " qgsmapcanvas.h"
32
33
#include " qgsmaprender.h"
33
34
#include " qgsapplication.h"
34
35
35
36
// qt includes
36
37
#include < QPainter>
37
38
#include < QMenu>
39
+ #include < QDir>
38
40
39
41
// non qt includes
40
42
#include < iostream>
@@ -110,15 +112,13 @@ void QgsNorthArrowPlugin::initGui()
110
112
111
113
void QgsNorthArrowPlugin::projectRead ()
112
114
{
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
117
117
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 );
122
122
}
123
123
124
124
// method defined in interface
@@ -156,18 +156,25 @@ void QgsNorthArrowPlugin::refreshCanvas()
156
156
157
157
void QgsNorthArrowPlugin::renderNorthArrow (QPainter * theQPainter)
158
158
{
159
- #ifdef QGISDEBUG
160
- std::cout << " Rendering n-arrow" << std::endl;
161
- #endif
159
+
162
160
// Large IF statement controlled by enable check box
163
161
if (mEnable )
164
162
{
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
+
165
172
QPixmap myQPixmap; // to store the north arrow image in
166
173
167
- QString myFileNameQString = QgsApplication::pkgDataPath () +
168
- " /images/north_arrows/default.png" ;
174
+ QString myFileNameQString = QDir::cleanPath ( QgsApplication::pkgDataPath () +
175
+ " /images/north_arrows/default.png" ) ;
169
176
170
- // std::cout << "Trying to load " << myFileNameQString << std::cout ;
177
+ QgsDebugMsg ( " Trying to load " + myFileNameQString) ;
171
178
if (myQPixmap.load (myFileNameQString))
172
179
{
173
180
@@ -200,9 +207,8 @@ void QgsNorthArrowPlugin::renderNorthArrow(QPainter * theQPainter)
200
207
int myHeight = theQPainter->device ()->height ();
201
208
int myWidth = theQPainter->device ()->width ();
202
209
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
+
206
212
// Determine placement of label from form combo box
207
213
switch (mPlacementIndex )
208
214
{
@@ -221,8 +227,7 @@ void QgsNorthArrowPlugin::renderNorthArrow(QPainter * theQPainter)
221
227
myHeight-myQPixmap.height ());
222
228
break ;
223
229
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" );
226
231
}
227
232
// rotate the canvas by the north arrow rotation amount
228
233
theQPainter->rotate ( mRotationInt );
@@ -321,6 +326,7 @@ bool QgsNorthArrowPlugin::calculateNorthDirection()
321
326
{
322
327
UNUSED (e);
323
328
// just give up
329
+ QgsDebugMsg (" Transformation error, quitting" );
324
330
return false ;
325
331
}
326
332
0 commit comments