16
16
17
17
#include < cmath>
18
18
19
+ #include " qgslogger.h"
19
20
#include " qgsmaprender.h"
20
21
#include " qgsscalecalculator.h"
21
22
#include " qgsmaptopixel.h"
@@ -143,14 +144,18 @@ void QgsMapRender::adjustExtentToSize()
143
144
}
144
145
145
146
#ifdef QGISDEBUG
146
- std::cout << " ========== Current Scale ==========" << std::endl;
147
- std::cout << " Current extent is " << mExtent .stringRep ().toLocal8Bit ().data () << std::endl;
148
- std::cout << " MuppX is: " << muppX << " \n " << " MuppY is: " << muppY << std::endl;
149
- std::cout << " Pixmap width: " << myWidth << " , height: " << myHeight << std::endl;
150
- std::cout << " Extent width: " << mExtent .width () << " , height: " << mExtent .height () << std::endl;
151
- std::cout << " whitespace: " << whitespace << std::endl;
147
+ QgsDebugMsg (" ========== Current Scale ==========" );
148
+ QgsDebugMsg (" Current extent is " + mExtent .stringRep ());
149
+ QgsLogger::debug (" MuppX" , muppX, 1 , __FILE__, __FUNCTION__, __LINE__);
150
+ QgsLogger::debug (" MuppY" , muppY, 1 , __FILE__, __FUNCTION__, __LINE__);
151
+ QgsLogger::debug (" Pixmap width" , myWidth, 1 , __FILE__, __FUNCTION__, __LINE__);
152
+ QgsLogger::debug (" Pixmap height" , myHeight, 1 , __FILE__, __FUNCTION__, __LINE__);
153
+ QgsLogger::debug (" Extent width" , mExtent .width (), 1 , __FILE__, __FUNCTION__, __LINE__);
154
+ QgsLogger::debug (" Extent height" , mExtent .height (), 1 , __FILE__, __FUNCTION__, __LINE__);
155
+ QgsLogger::debug (" whitespace: " , whitespace, 1 , __FILE__, __FUNCTION__, __LINE__);
152
156
#endif
153
157
158
+
154
159
// update extent
155
160
mExtent .setXmin (dxmin);
156
161
mExtent .setXmax (dxmax);
@@ -161,8 +166,7 @@ void QgsMapRender::adjustExtentToSize()
161
166
mScale = mScaleCalculator ->calculate (mExtent , myWidth);
162
167
163
168
#ifdef QGISDEBUG
164
- std::cout << " Scale (assuming meters as map units) = 1:" << mScale << std::endl;
165
- std::cout << " ------------------------------------------ " << std::endl;
169
+ QgsLogger::debug (" Scale (assuming meters as map units) = 1" , mScale , 1 , __FILE__, __FUNCTION__, __LINE__);
166
170
#endif
167
171
168
172
mCoordXForm ->setParameters (mMupp , dxmin, dymin, myHeight);
@@ -171,14 +175,11 @@ void QgsMapRender::adjustExtentToSize()
171
175
172
176
void QgsMapRender::render (QPainter* painter)
173
177
{
174
-
175
- #ifdef QGISDEBUG
176
- std::cout << " ========== Rendering ==========" << std::endl;
177
- #endif
178
+ QgsDebugMsg (" ========== Rendering ==========" );
178
179
179
180
if (mExtent .isEmpty ())
180
181
{
181
- std::cout << " empty extent... not rendering" << endl ;
182
+ QgsLogger::warning ( " empty extent... not rendering" ) ;
182
183
return ;
183
184
}
184
185
@@ -191,7 +192,7 @@ void QgsMapRender::render(QPainter* painter)
191
192
int myRenderCounter = 0 ;
192
193
193
194
#ifdef QGISDEBUG
194
- std::cout << " QgsMapRender::render: Starting to render layer stack." << std::endl ;
195
+ QgsDebugMsg ( " QgsMapRender::render: Starting to render layer stack." ) ;
195
196
QTime renderTime;
196
197
renderTime.start ();
197
198
#endif
@@ -201,49 +202,41 @@ void QgsMapRender::render(QPainter* painter)
201
202
202
203
while (li != layers.end ())
203
204
{
204
- #ifdef QGISDEBUG
205
- std::cout << " QgsMapRender::render: at layer item '" << (*li).toLocal8Bit ().data () << " '." << std::endl;
206
- #endif
205
+ QgsDebugMsg (" QgsMapRender::render: at layer item '" + (*li));
207
206
208
207
// This call is supposed to cause the progress bar to
209
208
// advance. However, it seems that updating the progress bar is
210
209
// incompatible with having a QPainter active (the one that is
211
210
// passed into this function), as Qt produces a number of errors
212
211
// when try to do so. I'm (Gavin) not sure how to fix this, but
213
212
// added these comments and debug statement to help others...
214
- std::cerr << " If there is a QPaintEngine error here, it is caused by an"
215
- << " emit call just after line " << __LINE__
216
- << " in file " << __FILE__ << " .\n " ;
213
+ QgsDebugMsg (" If there is a QPaintEngine error here, it is caused by an emit call" );
217
214
218
215
emit setProgress (myRenderCounter++,layers.size ());
219
216
QgsMapLayer *ml = QgsMapLayerRegistry::instance ()->mapLayer (*li);
220
217
221
218
if (!ml)
222
219
{
223
- #ifdef QGISDEBUG
224
- std::cout << " QgsMapRender::render: layer not found in registry!" << std::endl;
225
- #endif
220
+ QgsLogger::warning (" QgsMapRender::render: layer not found in registry!" );
226
221
li++;
227
222
continue ;
228
223
}
229
224
230
225
#ifdef QGISDEBUG
231
- std::cout << " QgsMapRender::render: Rendering layer " << ml->name ().toLocal8Bit ().data () << ' \n '
232
- << " Layer minscale " << ml->minScale ()
233
- << " , maxscale " << ml->maxScale () << ' \n '
234
- << " Scale dep. visibility enabled? "
235
- << ml->scaleBasedVisibility () << ' \n '
236
- << " Input extent: " << ml->extent ().stringRep ().toLocal8Bit ().data ()
237
- << std::endl;
226
+ QgsDebugMsg (" QgsMapRender::render: Rendering layer " + ml->name ());
227
+ QgsLogger::debug (" Layer minscale " , ml->minScale (), 1 , __FILE__, __FUNCTION__, __LINE__);
228
+ QgsLogger::debug (" Layer maxscale " , ml->maxScale (), 1 , __FILE__, __FUNCTION__, __LINE__);
229
+ QgsLogger::debug (" Scale dep. visibility enabled? " , ml->scaleBasedVisibility (), 1 ,\
230
+ __FILE__, __FUNCTION__, __LINE__);
231
+ QgsLogger::debug (" Input extent: " + ml->extent ().stringRep (), 1 , __FILE__, __FUNCTION__, __LINE__);
238
232
try
239
233
{
240
- std::cout << " Transformed extent: "
241
- << ml->coordinateTransform ()->transformBoundingBox (ml->extent ()).stringRep ().toLocal8Bit ().data ()
242
- << std::endl;
234
+ QgsDebugMsg (" Transformed extent: " + ml->coordinateTransform ()->transformBoundingBox (ml->extent ()).stringRep ());
243
235
}
244
236
catch (QgsCsException &cse)
245
237
{
246
- qDebug ( " Transform error caught in %s line %d:\n %s" , __FILE__, __LINE__, cse.what ());
238
+ QgsLogger::warning (" Transform error caught in " + QString (__FILE__) + " line " + QString (__LINE__) +\
239
+ QString (cse.what ()));
247
240
}
248
241
#endif
249
242
@@ -273,10 +266,8 @@ void QgsMapRender::render(QPainter* painter)
273
266
}
274
267
else
275
268
{
276
- #ifdef QGISDEBUG
277
- std::cout << " QgsMapRender::render: Layer not rendered because it is not within "
278
- << " the defined visibility scale range" << std::endl;
279
- #endif
269
+ QgsDebugMsg (" QgsMapRender::render: Layer not rendered because it is not within the defined \
270
+ visibility scale range" )
280
271
}
281
272
282
273
} // if (ml->visible())
@@ -285,9 +276,7 @@ void QgsMapRender::render(QPainter* painter)
285
276
286
277
} // while (li != end)
287
278
288
- #ifdef QGISDEBUG
289
- std::cout << " QgsMapRender::render: Done rendering map layers" << std::endl;
290
- #endif
279
+ QgsDebugMsg (" QgsMapRender::render: Done rendering map layers" );
291
280
292
281
if (!mOverview )
293
282
{
@@ -321,8 +310,8 @@ void QgsMapRender::render(QPainter* painter)
321
310
emit setProgress (1 ,1 );
322
311
323
312
#ifdef QGISDEBUG
324
- std::cout << " QgsMapRender::render: Rendering done in " <<
325
- renderTime. elapsed () / 1000.0 << " seconds " << std::endl ;
313
+ QgsLogger::debug ( " QgsMapRender::render: Rendering done in (seconds) " , renderTime. elapsed () / 1000.0 , 1 ,\
314
+ __FILE__, __FUNCTION__, __LINE__) ;
326
315
#endif
327
316
328
317
mDrawing = false ;
0 commit comments