Skip to content

Commit a690af6

Browse files
StevenBStevenB
StevenB
authored and
StevenB
committedMay 9, 2008
Cleaned up a bunch of debug statments.
git-svn-id: http://svn.osgeo.org/qgis/trunk@8417 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent a906ffb commit a690af6

File tree

7 files changed

+99
-29
lines changed

7 files changed

+99
-29
lines changed
 

‎src/app/composer/qgscomposerlabel.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ QgsComposerLabel::QgsComposerLabel ( QgsComposition *composition, int id,
3131
{
3232
setupUi(this);
3333

34-
//std::cout << "QgsComposerLabel::QgsComposerLabel()" << std::endl;
34+
#ifdef QGISDEBUG
35+
std::cout << "QgsComposerLabel::QgsComposerLabel()" << std::endl;
36+
#endif
3537

3638
mComposition = composition;
3739
mId = id;
@@ -64,7 +66,9 @@ QgsComposerLabel::QgsComposerLabel ( QgsComposition *composition, int id,
6466
QgsComposerLabel::QgsComposerLabel ( QgsComposition *composition, int id )
6567
: QAbstractGraphicsShapeItem(0)
6668
{
67-
//std::cout << "QgsComposerLabel::QgsComposerLabel()" << std::endl;
69+
#ifdef QGISDEBUG
70+
std::cout << "QgsComposerLabel::QgsComposerLabel()" << std::endl;
71+
#endif
6872

6973
setupUi(this);
7074

@@ -86,7 +90,10 @@ QgsComposerLabel::QgsComposerLabel ( QgsComposition *composition, int id )
8690

8791
QgsComposerLabel::~QgsComposerLabel()
8892
{
89-
//std::cout << "QgsComposerLabel::~QgsComposerLabel" << std::endl;
93+
#ifdef QGISDEBUG
94+
std::cout << "QgsComposerLabel::~QgsComposerLabel" << std::endl;
95+
#endif
96+
//make ourselves disappear so there aren't any interesting effects when we get destroyed
9097
QGraphicsItem::hide();
9198
}
9299

@@ -96,7 +103,9 @@ QgsComposerLabel::~QgsComposerLabel()
96103
#define WIDTH_EXTENSION 1.0
97104
void QgsComposerLabel::paint ( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
98105
{
99-
//std::cout << "QgsComposerLabel::paint" << std::endl;
106+
#ifdef QGISDEBUG
107+
std::cout << "QgsComposerLabel::paint" << std::endl;
108+
#endif
100109

101110
float size = 25.4 * mComposition->scale() * mFont.pointSizeF() / 72;
102111

@@ -234,7 +243,9 @@ QRectF QgsComposerLabel::boundingRect ( void ) const
234243

235244
QPolygonF QgsComposerLabel::areaPoints() const
236245
{
237-
//std::cout << "QgsComposerLabel::areaPoints" << std::endl;
246+
#ifdef QGISDEBUG
247+
std::cout << "QgsComposerLabel::areaPoints" << std::endl;
248+
#endif
238249
QRectF r = boundingRect();
239250

240251
QPolygonF pa;
@@ -268,11 +279,12 @@ void QgsComposerLabel::on_mTextEdit_textChanged()
268279

269280
void QgsComposerLabel::setSelected ( bool s )
270281
{
271-
//std::cout << "QgsComposerLabel::setSelected" << std::endl;
282+
#ifdef QGISDEBUG
283+
std::cout << "QgsComposerLabel::setSelected" << std::endl;
284+
#endif
285+
272286
mSelected = s;
273287
QAbstractGraphicsShapeItem::update(); // show highlight
274-
275-
std::cout << "mSelected = " << mSelected << std::endl;
276288
}
277289

278290
bool QgsComposerLabel::selected( void )

‎src/app/composer/qgscomposermap.cpp

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@
4242
QgsComposerMap::QgsComposerMap ( QgsComposition *composition, int id, int x, int y, int width, int height )
4343
: QWidget(), QGraphicsRectItem(0,0,width,height,0)
4444
{
45-
std::cout << "QgsComposerMap::QgsComposerMap()" << std::endl;
46-
45+
#ifdef QGISDEBUG
46+
std::cout << "QgsComposerMap::QgsComposerMap()" << std::endl;
47+
#endif
4748
setupUi(this);
4849

4950
mComposition = composition;
@@ -119,7 +120,9 @@ void QgsComposerMap::init ()
119120

120121
QgsComposerMap::~QgsComposerMap()
121122
{
123+
#ifdef QGISDEBUG
122124
std::cerr << "QgsComposerMap::~QgsComposerMap" << std::endl;
125+
#endif
123126
}
124127

125128
/* This function is called by paint() and cache() to render the map. It does not override any functions
@@ -265,7 +268,9 @@ void QgsComposerMap::setUserExtent ( QgsRect const & rect )
265268

266269
void QgsComposerMap::cache ( void )
267270
{
271+
#ifdef QGISDEBUG
268272
std::cout << "QgsComposerMap::cache()" << std::endl;
273+
#endif
269274

270275
// Create preview on some reasonable size. It was slow with cca 1500x1500 points on 2x1.5GHz
271276
// Note: The resolution should also respect the line widths, it means that
@@ -278,8 +283,10 @@ void QgsComposerMap::cache ( void )
278283
// It can happen that extent is not initialised well -> check
279284
if ( h < 1 || h > 10000 ) h = w;
280285

286+
#ifdef QGISDEBUG
281287
std::cout << "extent = " << mExtent.width() << " x " << mExtent.height() << std::endl;
282288
std::cout << "cache = " << w << " x " << h << std::endl;
289+
#endif
283290

284291
mCacheExtent = QgsRect ( mExtent );
285292
double scale = mExtent.width() / w;
@@ -299,7 +306,9 @@ void QgsComposerMap::cache ( void )
299306
* on both the cache, screen render, and print.
300307
*/
301308

309+
#ifdef QGISDEBUG
302310
std::cout << "transform = " << transform.showParameters().toLocal8Bit().data() << std::endl;
311+
#endif
303312

304313
mCachePixmap.fill(QColor(255,255,255));
305314

@@ -317,21 +326,23 @@ void QgsComposerMap::paint ( QPainter* painter, const QStyleOptionGraphicsItem*
317326
if ( mDrawing ) return;
318327
mDrawing = true;
319328

329+
#ifdef QGISDEBUG
320330
std::cout << "QgsComposerMapt::paint mPlotStyle = " << plotStyle()
321331
<< " mPreviewMode = " << mPreviewMode << std::endl;
332+
#endif
322333

323334
if ( plotStyle() == QgsComposition::Preview && mPreviewMode == Cache ) { // Draw from cache
324-
std::cout << "use cache" << std::endl;
325-
326335
if ( !mCacheUpdated || mMapCanvas->layerCount() != mNumCachedLayers )
327336
{
328337
cache();
329338
}
330339

331340
// Scale so that the cache fills the map rectangle
332341
double scale = 1.0 * QGraphicsRectItem::rect().width() / mCachePixmap.width();
342+
#ifdef QGISDEBUG
333343
std::cout << "scale = " << scale << std::endl;
334-
344+
#endif
345+
335346
painter->save();
336347

337348
painter->translate(0, 0); //do we need this?
@@ -346,7 +357,9 @@ void QgsComposerMap::paint ( QPainter* painter, const QStyleOptionGraphicsItem*
346357
plotStyle() == QgsComposition::Print ||
347358
plotStyle() == QgsComposition::Postscript )
348359
{
360+
#ifdef QGISDEBUG
349361
std::cout << "render" << std::endl;
362+
#endif
350363

351364
double scale = mExtent.width() / QGraphicsRectItem::rect().width();
352365
QgsMapToPixel transform(scale, QGraphicsRectItem::rect().height(), mExtent.yMin(), mExtent.xMin() );
@@ -503,8 +516,9 @@ void QgsComposerMap::on_mWidthScaleLineEdit_editingFinished ( void ) { scaleChan
503516

504517
void QgsComposerMap::mapCanvasChanged ( void )
505518
{
519+
#ifdef QGISDEBUG
506520
std::cout << "QgsComposerMap::canvasChanged" << std::endl;
507-
521+
#endif
508522
mCacheUpdated = false;
509523
QGraphicsRectItem::update();
510524
}
@@ -562,9 +576,11 @@ void QgsComposerMap::recalculate ( void )
562576
mExtent.setYmax ( yc + height/2 );
563577
}
564578

579+
#ifdef QGISDEBUG
565580
std::cout << "mUserExtent = " << mUserExtent.stringRep().toLocal8Bit().data() << std::endl;
566581
std::cout << "mScale = " << mScale << std::endl;
567582
std::cout << "mExtent = " << mExtent.stringRep().toLocal8Bit().data() << std::endl;
583+
#endif
568584

569585
setOptions();
570586
mCacheUpdated = false;
@@ -581,8 +597,10 @@ void QgsComposerMap::on_mFrameCheckBox_clicked ( )
581597

582598

583599
void QgsComposerMap::setOptions ( void )
584-
{
600+
{
601+
#ifdef QGISDEBUG
585602
std::cout << "QgsComposerMap::setOptions" << std::endl;
603+
#endif
586604

587605
mNameLabel->setText ( mName );
588606

‎src/app/composer/qgscomposerpicture.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333

3434
#define PI 3.14159265358979323846
3535

36-
#define QGISDEBUG 1
37-
3836
QgsComposerPicture::QgsComposerPicture ( QgsComposition *composition,
3937
int id, QString file )
4038
: QWidget(composition),

‎src/app/composer/qgscomposerscalebar.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ QgsComposerScalebar::QgsComposerScalebar ( QgsComposition *composition, int id,
3636
{
3737
setupUi(this);
3838

39+
#ifdef QGISDEBUG
3940
std::cout << "QgsComposerScalebar::QgsComposerScalebar()" << std::endl;
41+
#endif
42+
4043
mId = id;
4144
mSelected = false;
4245

@@ -120,7 +123,9 @@ QgsComposerScalebar::QgsComposerScalebar ( QgsComposition *composition, int id )
120123
mMap(0),
121124
mBrush(QColor(150,150,150))
122125
{
126+
#ifdef QGISDEBUG
123127
std::cout << "QgsComposerScalebar::QgsComposerScalebar()" << std::endl;
128+
#endif
124129

125130
setupUi(this);
126131

@@ -410,7 +415,9 @@ void QgsComposerScalebar::moveBy(double x, double y)
410415

411416
void QgsComposerScalebar::recalculate(void)
412417
{
418+
#ifdef QGISDEBUG
413419
std::cout << "QgsComposerScalebar::recalculate" << std::endl;
420+
#endif
414421

415422
// !!! prepareGeometryChange() MUST BE called before the value returned by areaPoints() changes
416423
//Is this still true after the port to GraphicsView?
@@ -423,13 +430,17 @@ void QgsComposerScalebar::recalculate(void)
423430

424431
QRectF QgsComposerScalebar::boundingRect(void) const
425432
{
433+
#ifdef QGISDEBUG
426434
std::cout << "QgsComposerScalebar::boundingRect" << std::endl;
435+
#endif
427436
return mBoundingRect;
428437
}
429438

430439
QPolygonF QgsComposerScalebar::areaPoints(void) const
431440
{
441+
#ifdef QGISDEBUG
432442
std::cout << "QgsComposerScalebar::areaPoints" << std::endl;
443+
#endif
433444

434445
QRectF r = boundingRect();
435446
QPolygonF pa;
@@ -496,7 +507,10 @@ QWidget *QgsComposerScalebar::options(void)
496507

497508
bool QgsComposerScalebar::writeSettings(void)
498509
{
510+
#ifdef QGISDEBUG
499511
std::cout << "QgsComposerScalebar::writeSettings" << std::endl;
512+
#endif
513+
500514
QString path;
501515
path.sprintf("/composition_%d/scalebar_%d/", mComposition->id(), mId);
502516

‎src/app/composer/qgscomposervectorlegend.cpp

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ QgsComposerVectorLegend::QgsComposerVectorLegend ( QgsComposition *composition,
4141
{
4242
setupUi(this);
4343

44-
//std::cout << "QgsComposerVectorLegend::QgsComposerVectorLegend()" << std::endl;
44+
#ifdef QGISDEBUG
45+
std::cout << "QgsComposerVectorLegend::QgsComposerVectorLegend()" << std::endl;
46+
#endif
4547

4648
mComposition = composition;
4749
mId = id;
@@ -76,7 +78,9 @@ QgsComposerVectorLegend::QgsComposerVectorLegend ( QgsComposition *composition,
7678
QgsComposerVectorLegend::QgsComposerVectorLegend ( QgsComposition *composition, int id )
7779
: QGraphicsRectItem(0,0,10,10,0)
7880
{
79-
//std::cout << "QgsComposerVectorLegend::QgsComposerVectorLegend()" << std::endl;
81+
#ifdef QGISDEBUG
82+
std::cout << "QgsComposerVectorLegend::QgsComposerVectorLegend()" << std::endl;
83+
#endif
8084

8185
setupUi(this);
8286

@@ -142,7 +146,9 @@ QgsComposerVectorLegend::~QgsComposerVectorLegend()
142146
#define FONT_WORKAROUND_SCALE 10
143147
QRectF QgsComposerVectorLegend::render ( QPainter *p )
144148
{
145-
//std::cout << "QgsComposerVectorLegend::render p = " << p << std::endl;
149+
#ifdef QGISDEBUG
150+
std::cout << "QgsComposerVectorLegend::render p = " << p << std::endl;
151+
#endif
146152

147153
// Painter can be 0, create dummy to avoid many if below
148154
QPainter *painter = NULL;
@@ -350,7 +356,7 @@ QRectF QgsComposerVectorLegend::render ( QPainter *p )
350356
double groupStartHeight = height;
351357
for ( int j = groupLayers.size()-1; j >= 0; j-- )
352358
{
353-
std::cout << "layer = " << groupLayers[j] << std::endl;
359+
//std::cout << "layer = " << groupLayers[j] << std::endl;
354360

355361
double localHeight = groupStartHeight;
356362

@@ -463,9 +469,11 @@ QRectF QgsComposerVectorLegend::render ( QPainter *p )
463469

464470
void QgsComposerVectorLegend::cache ( void )
465471
{
472+
#ifdef QGISDEBUG
466473
std::cout << "QgsComposerVectorLegend::cache()" << std::endl;
474+
#endif
467475

468-
//typical boundingRect size is 15 units wide,
476+
//typical boundingRect size is 15 units wide,
469477
mCachePixmap = QPixmap((int)QGraphicsRectItem::rect().width(), (int)QGraphicsRectItem::rect().height() );
470478

471479

@@ -552,7 +560,9 @@ void QgsComposerVectorLegend::on_mTitleLineEdit_editingFinished ( void )
552560
void QgsComposerVectorLegend::on_mPreviewModeComboBox_activated ( int i )
553561
{
554562
mPreviewMode = (PreviewMode) i;
563+
#ifdef QGISDEBUG
555564
std::cout << "mPreviewMode = " << mPreviewMode << std::endl;
565+
#endif
556566
writeSettings();
557567
}
558568

@@ -586,7 +596,9 @@ void QgsComposerVectorLegend::on_mFrameCheckBox_stateChanged ( int )
586596

587597
void QgsComposerVectorLegend::recalculate ( void )
588598
{
599+
#ifdef QGISDEBUG
589600
std::cout << "QgsComposerVectorLegend::recalculate" << std::endl;
601+
#endif
590602

591603
// Recalculate sizes according to current font size
592604

@@ -596,9 +608,6 @@ void QgsComposerVectorLegend::recalculate ( void )
596608
mSectionFont = mFont;
597609
mSectionFont.setPointSizeFloat ( 1.2 * mFont.pointSizeFloat() );
598610

599-
std::cout << "font size = " << mFont.pointSizeFloat() << std::endl;
600-
std::cout << "title font size = " << mTitleFont.pointSizeFloat() << std::endl;
601-
602611
// Font size in canvas units
603612
float size = 25.4 * mComposition->scale() * mFont.pointSizeFloat() / 72;
604613

@@ -607,9 +616,14 @@ void QgsComposerVectorLegend::recalculate ( void )
607616
mSymbolWidth = 3.5 * size;
608617
mSymbolSpace = 0.4 * size;
609618

619+
#ifdef QGISDEBUG
620+
std::cout << "font size = " << mFont.pointSizeFloat() << std::endl;
621+
std::cout << "title font size = " << mTitleFont.pointSizeFloat() << std::endl;
622+
610623
std::cout << "mMargin = " << mMargin << " mSymbolHeight = " << mSymbolHeight
611624
<< "mSymbolWidth = " << mSymbolWidth << " mSymbolSpace = " << mSymbolSpace << std::endl;
612-
625+
#endif
626+
613627
QRectF r = render(0);
614628

615629
QGraphicsRectItem::setRect(0, 0, r.width(), r.height() );
@@ -695,7 +709,9 @@ bool QgsComposerVectorLegend::selected( void )
695709

696710
void QgsComposerVectorLegend::contextMenuEvent( QContextMenuEvent *event)
697711
{
712+
#ifdef QGISDEBUG
698713
std::cout << "QgsComposerVectorLegend::contextMenuEvent" << std::endl;
714+
#endif
699715

700716
QMenu layersPopupMenu( this);
701717
layersPopupMenu.addAction( tr("Combine selected layers"), this, SLOT(groupLayers()) );
@@ -748,7 +764,9 @@ void QgsComposerVectorLegend::setLayerGroup ( QString id, int group )
748764

749765
void QgsComposerVectorLegend::layerChanged ( QTreeWidgetItem *lvi )
750766
{
767+
#ifdef QGISDEBUG
751768
std::cout << "QgsComposerVectorLegend::layerChanged" << std::endl;
769+
#endif
752770

753771
if ( lvi == 0 ) return;
754772

@@ -764,15 +782,19 @@ void QgsComposerVectorLegend::layerChanged ( QTreeWidgetItem *lvi )
764782

765783
void QgsComposerVectorLegend::groupLayers ( void )
766784
{
785+
#ifdef QGISDEBUG
767786
std::cout << "QgsComposerVectorLegend::groupLayers" << std::endl;
787+
#endif
768788

769789
QTreeWidgetItemIterator it( mLayersListView );
770790
int count = 0;
771791
QTreeWidgetItem *lastItem = NULL;
772792
QString id;
773793
while ( *it ) {
774794
if ( (*it)->isSelected() ) {
795+
#ifdef QGISDEBUG
775796
std::cout << "selected: " << (*it)->text(0).toLocal8Bit().data() << " " << (*it)->text(2).toLocal8Bit().data() << std::endl;
797+
#endif
776798

777799
id = (*it)->text(2);
778800
setLayerGroup ( id, mNextLayerGroup );
@@ -787,11 +809,13 @@ void QgsComposerVectorLegend::groupLayers ( void )
787809
lastItem->setText(1,"" );
788810
}
789811

812+
#ifdef QGISDEBUG
790813
std::cout << "Groups:" << std::endl;
791814

792815
for ( std::map<QString,int>::iterator it3 = mLayersGroups.begin(); it3 != mLayersGroups.end(); ++it3 ) {
793816
std::cout << "layer: " << (it3->first).toLocal8Bit().data() << " group: " << it3->second << std::endl;
794817
}
818+
#endif
795819

796820
mNextLayerGroup++;
797821

@@ -810,7 +834,10 @@ QWidget *QgsComposerVectorLegend::options ( void )
810834

811835
bool QgsComposerVectorLegend::writeSettings ( void )
812836
{
837+
#ifdef QGISDEBUG
813838
std::cout << "QgsComposerVectorLegend::writeSettings" << std::endl;
839+
#endif
840+
814841
QString path;
815842
path.sprintf("/composition_%d/vectorlegend_%d/", mComposition->id(), mId );
816843

‎src/app/composer/qgscomposerview.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ void QgsComposerView::resizeEvent ( QResizeEvent * )
7272
* Really, we should do something like re-center the window.
7373
*/
7474
//mComposer->zoomFull();
75-
std::cout << "resize anchor: " << resizeAnchor() << std::endl;
75+
#ifdef QGISDEBUG
76+
std::cout << "resize anchor: " << resizeAnchor() << std::endl;
77+
#endif
7678
}
7779

7880
//TODO: add mouse wheel event forwarding

‎src/app/composer/qgscomposition.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,9 @@ void QgsComposition::mousePressEvent(QMouseEvent* e)
388388
void QgsComposition::mouseMoveEvent(QMouseEvent* e)
389389
{
390390
#ifdef QGISDEBUG
391-
#endif
392391
std::cerr << "QgsComposition::mouseMoveEvent() mTool = " << mTool << " mToolStep = "
393392
<< mToolStep << std::endl;
394-
393+
#endif
395394

396395
QPointF p = mView->mapToScene(e->pos());
397396

0 commit comments

Comments
 (0)
Please sign in to comment.