Skip to content

Commit

Permalink
Make rendering related debug messages us QgsDebugMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Feb 26, 2014
1 parent a813be1 commit 9c4a990
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 46 deletions.
49 changes: 24 additions & 25 deletions src/core/qgsmaprendererjob.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ QgsMapRendererSequentialJob::QgsMapRendererSequentialJob( const QgsMapSettings&
, mPainter( 0 ) , mPainter( 0 )
, mLabelingResults( 0 ) , mLabelingResults( 0 )
{ {
qDebug( "SEQUENTIAL construct" ); QgsDebugMsg( "SEQUENTIAL construct" );


mImage = QImage( mSettings.outputSize(), QImage::Format_ARGB32_Premultiplied ); mImage = QImage( mSettings.outputSize(), QImage::Format_ARGB32_Premultiplied );
} }


QgsMapRendererSequentialJob::~QgsMapRendererSequentialJob() QgsMapRendererSequentialJob::~QgsMapRendererSequentialJob()
{ {
qDebug( "SEQUENTIAL destruct" ); QgsDebugMsg( "SEQUENTIAL destruct" );
if ( isActive() ) if ( isActive() )
{ {
// still running! // still running!
qDebug( "SEQUENTIAL destruct -- still running! (cancelling)" ); QgsDebugMsg( "SEQUENTIAL destruct -- still running! (cancelling)" );
cancel(); cancel();
} }


Expand All @@ -78,8 +78,7 @@ void QgsMapRendererSequentialJob::start()


mErrors.clear(); mErrors.clear();


qDebug( "SEQUENTIAL START" ); QgsDebugMsg( "SEQUENTIAL START" );
qDebug( "%d,%d", mSettings.outputSize().width(), mSettings.outputSize().height() );


Q_ASSERT( mInternalJob == 0 && mPainter == 0 ); Q_ASSERT( mInternalJob == 0 && mPainter == 0 );


Expand All @@ -99,7 +98,7 @@ void QgsMapRendererSequentialJob::cancel()
if ( !isActive() ) if ( !isActive() )
return; return;


qDebug( "sequential - cancel internal" ); QgsDebugMsg( "sequential - cancel internal" );
mInternalJob->cancel(); mInternalJob->cancel();


Q_ASSERT( mInternalJob == 0 && mPainter == 0 ); Q_ASSERT( mInternalJob == 0 && mPainter == 0 );
Expand Down Expand Up @@ -138,7 +137,7 @@ QImage QgsMapRendererSequentialJob::renderedImage()


void QgsMapRendererSequentialJob::internalFinished() void QgsMapRendererSequentialJob::internalFinished()
{ {
qDebug( "SEQUENTIAL finished" ); QgsDebugMsg( "SEQUENTIAL finished" );


mPainter->end(); mPainter->end();
delete mPainter; delete mPainter;
Expand Down Expand Up @@ -169,12 +168,12 @@ QgsMapRendererCustomPainterJob::QgsMapRendererCustomPainterJob( const QgsMapSett
, mLabelingEngine( 0 ) , mLabelingEngine( 0 )
, mActive( false ) , mActive( false )
{ {
qDebug( "QPAINTER construct" ); QgsDebugMsg( "QPAINTER construct" );
} }


QgsMapRendererCustomPainterJob::~QgsMapRendererCustomPainterJob() QgsMapRendererCustomPainterJob::~QgsMapRendererCustomPainterJob()
{ {
qDebug( "QPAINTER destruct" ); QgsDebugMsg( "QPAINTER destruct" );
Q_ASSERT( !mFutureWatcher.isRunning() ); Q_ASSERT( !mFutureWatcher.isRunning() );
//cancel(); //cancel();


Expand All @@ -193,7 +192,7 @@ void QgsMapRendererCustomPainterJob::start()


mErrors.clear(); mErrors.clear();


qDebug( "QPAINTER run!" ); QgsDebugMsg( "QPAINTER run!" );


QgsDebugMsg( "Preparing list of layer jobs for rendering" ); QgsDebugMsg( "Preparing list of layer jobs for rendering" );
QTime prepareTime; QTime prepareTime;
Expand Down Expand Up @@ -243,11 +242,11 @@ void QgsMapRendererCustomPainterJob::cancel()
{ {
if ( !isActive() ) if ( !isActive() )
{ {
qDebug( "QPAINTER not running!" ); QgsDebugMsg( "QPAINTER not running!" );
return; return;
} }


qDebug( "QPAINTER cancelling" ); QgsDebugMsg( "QPAINTER cancelling" );
disconnect( &mFutureWatcher, SIGNAL( finished() ), this, SLOT( futureFinished() ) ); disconnect( &mFutureWatcher, SIGNAL( finished() ), this, SLOT( futureFinished() ) );


mLabelingRenderContext.setRenderingStopped( true ); mLabelingRenderContext.setRenderingStopped( true );
Expand All @@ -261,11 +260,11 @@ void QgsMapRendererCustomPainterJob::cancel()


mFutureWatcher.waitForFinished(); mFutureWatcher.waitForFinished();


qDebug( "QPAINER cancel waited %f ms", t.elapsed() / 1000.0 ); QgsDebugMsg( QString( "QPAINER cancel waited %1 ms" ).arg( t.elapsed() / 1000.0 ) );


futureFinished(); futureFinished();


qDebug( "QPAINTER cancelled" ); QgsDebugMsg( "QPAINTER cancelled" );
} }


void QgsMapRendererCustomPainterJob::waitForFinished() void QgsMapRendererCustomPainterJob::waitForFinished()
Expand All @@ -280,7 +279,7 @@ void QgsMapRendererCustomPainterJob::waitForFinished()


mFutureWatcher.waitForFinished(); mFutureWatcher.waitForFinished();


qDebug( "waitForFinished: %f ms", t.elapsed() / 1000.0 ); QgsDebugMsg( QString( "waitForFinished: %1 ms" ).arg( t.elapsed() / 1000.0 ) );


futureFinished(); futureFinished();
} }
Expand All @@ -301,7 +300,7 @@ void QgsMapRendererCustomPainterJob::futureFinished()
{ {
mActive = false; mActive = false;
mRenderingTime = mRenderingStart.elapsed(); mRenderingTime = mRenderingStart.elapsed();
qDebug( "QPAINTER futureFinished" ); QgsDebugMsg( "QPAINTER futureFinished" );


// final cleanup // final cleanup
cleanupJobs( mLayerJobs ); cleanupJobs( mLayerJobs );
Expand Down Expand Up @@ -357,7 +356,7 @@ void QgsMapRendererCustomPainterJob::doRender()


void QgsMapRendererJob::drawLabeling( const QgsMapSettings& settings, QgsRenderContext& renderContext, QgsPalLabeling* labelingEngine, QPainter* painter ) void QgsMapRendererJob::drawLabeling( const QgsMapSettings& settings, QgsRenderContext& renderContext, QgsPalLabeling* labelingEngine, QPainter* painter )
{ {
qDebug( "Draw labeling start" ); QgsDebugMsg( "Draw labeling start" );


QTime t; QTime t;
t.start(); t.start();
Expand All @@ -375,7 +374,7 @@ void QgsMapRendererJob::drawLabeling( const QgsMapSettings& settings, QgsRenderC


drawNewLabeling( settings, renderContext, labelingEngine ); drawNewLabeling( settings, renderContext, labelingEngine );


qDebug( "Draw labeling took (seconds): %f", t.elapsed() / 1000. ); QgsDebugMsg( QString( "Draw labeling took (seconds): %1" ).arg( t.elapsed() / 1000. ) );
} }




Expand Down Expand Up @@ -534,7 +533,7 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter* painter, QgsPalLabelin
if ( mCache ) if ( mCache )
{ {
bool cacheValid = mCache->init( mSettings.visibleExtent(), mSettings.scale() ); bool cacheValid = mCache->init( mSettings.visibleExtent(), mSettings.scale() );
qDebug( "CACHE VALID: %d", cacheValid ); QgsDebugMsg( QString( "CACHE VALID: %1" ).arg( cacheValid ) );
} }


mGeometryCaches.clear(); mGeometryCaches.clear();
Expand Down Expand Up @@ -677,7 +676,7 @@ void QgsMapRendererJob::cleanupJobs( LayerRenderJobs& jobs )


if ( mCache && !job.cached && !job.context.renderingStopped() ) if ( mCache && !job.cached && !job.context.renderingStopped() )
{ {
qDebug( "caching image for %s", job.layerId.toAscii().data() ); QgsDebugMsg( "caching image for " + job.layerId );
mCache->setCacheImage( job.layerId, *job.img ); mCache->setCacheImage( job.layerId, *job.img );
} }


Expand Down Expand Up @@ -756,7 +755,7 @@ void QgsMapRendererParallelJob::cancel()
if ( !isActive() ) if ( !isActive() )
return; return;


qDebug( "PARALLEL cancel at status %d", mStatus ); QgsDebugMsg( QString( "PARALLEL cancel at status %1" ).arg( mStatus ) );


mLabelingRenderContext.setRenderingStopped( true ); mLabelingRenderContext.setRenderingStopped( true );
for ( LayerRenderJobs::iterator it = mLayerJobs.begin(); it != mLayerJobs.end(); ++it ) for ( LayerRenderJobs::iterator it = mLayerJobs.begin(); it != mLayerJobs.end(); ++it )
Expand Down Expand Up @@ -799,7 +798,7 @@ void QgsMapRendererParallelJob::waitForFinished()


mFutureWatcher.waitForFinished(); mFutureWatcher.waitForFinished();


qDebug( "waitForFinished (1): %f ms", t.elapsed() / 1000.0 ); QgsDebugMsg( QString( "waitForFinished (1): %1 ms" ).arg( t.elapsed() / 1000.0 ) );


renderLayersFinished(); renderLayersFinished();
} }
Expand All @@ -813,7 +812,7 @@ void QgsMapRendererParallelJob::waitForFinished()


mLabelingFutureWatcher.waitForFinished(); mLabelingFutureWatcher.waitForFinished();


qDebug( "waitForFinished (2): %f ms", t.elapsed() / 1000.0 ); QgsDebugMsg( QString( "waitForFinished (2): %1 ms" ).arg( t.elapsed() / 1000.0 ) );


renderingFinished(); renderingFinished();
} }
Expand Down Expand Up @@ -848,7 +847,7 @@ void QgsMapRendererParallelJob::renderLayersFinished()


cleanupJobs( mLayerJobs ); cleanupJobs( mLayerJobs );


qDebug( "PARALLEL layers finished" ); QgsDebugMsg( "PARALLEL layers finished" );


if ( mSettings.testFlag( QgsMapSettings::DrawLabeling ) && !mLabelingRenderContext.renderingStopped() ) if ( mSettings.testFlag( QgsMapSettings::DrawLabeling ) && !mLabelingRenderContext.renderingStopped() )
{ {
Expand All @@ -868,7 +867,7 @@ void QgsMapRendererParallelJob::renderLayersFinished()


void QgsMapRendererParallelJob::renderingFinished() void QgsMapRendererParallelJob::renderingFinished()
{ {
qDebug( "PARALLEL finished" ); QgsDebugMsg( "PARALLEL finished" );


mStatus = Idle; mStatus = Idle;


Expand Down
23 changes: 7 additions & 16 deletions src/gui/qgsmapcanvas.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -566,25 +566,25 @@ void QgsMapCanvas::refresh()
{ {
if ( !mSettings.hasValidSettings() ) if ( !mSettings.hasValidSettings() )
{ {
qDebug( "CANVAS refresh - invalid settings -> nothing to do" ); QgsDebugMsg( "CANVAS refresh - invalid settings -> nothing to do" );
return; return;
} }


if ( !mRenderFlag || mFrozen ) // do we really need two flags controlling rendering? if ( !mRenderFlag || mFrozen ) // do we really need two flags controlling rendering?
{ {
qDebug( "CANVAS render flag off" ); QgsDebugMsg( "CANVAS render flag off" );
return; return;
} }


if ( mRefreshScheduled ) if ( mRefreshScheduled )
{ {
qDebug( "CANVAS refresh already scheduled" ); QgsDebugMsg( "CANVAS refresh already scheduled" );
return; return;
} }


mRefreshScheduled = true; mRefreshScheduled = true;


qDebug( "CANVAS refresh scheduling" ); QgsDebugMsg( "CANVAS refresh scheduling" );


// schedule a refresh // schedule a refresh
QTimer::singleShot( 1, this, SLOT( refreshMap() ) ); QTimer::singleShot( 1, this, SLOT( refreshMap() ) );
Expand Down Expand Up @@ -648,7 +648,7 @@ void QgsMapCanvas::refreshMap()
{ {
Q_ASSERT( mRefreshScheduled ); Q_ASSERT( mRefreshScheduled );


qDebug( "CANVAS refresh!" ); QgsDebugMsg( "CANVAS refresh!" );


stopRendering(); // if any... stopRendering(); // if any...


Expand Down Expand Up @@ -696,7 +696,7 @@ void QgsMapCanvas::layerRequestedRepaint()


void QgsMapCanvas::rendererJobFinished() void QgsMapCanvas::rendererJobFinished()
{ {
qDebug( "CANVAS finish! %d", !mJobCancelled ); QgsDebugMsg( QString( "CANVAS finish! %1" ).arg( !mJobCancelled ) );


mMapUpdateTimer.stop(); mMapUpdateTimer.stop();


Expand Down Expand Up @@ -746,8 +746,6 @@ void QgsMapCanvas::rendererJobFinished()


void QgsMapCanvas::mapUpdateTimeout() void QgsMapCanvas::mapUpdateTimeout()
{ {
qDebug( "CANVAS update timer!" );

mMap->setContent( mJob->renderedImage(), mSettings.visibleExtent() ); mMap->setContent( mJob->renderedImage(), mSettings.visibleExtent() );
} }


Expand All @@ -756,7 +754,7 @@ void QgsMapCanvas::stopRendering()
{ {
if ( mJob ) if ( mJob )
{ {
qDebug( "CANVAS stop rendering!" ); QgsDebugMsg( "CANVAS stop rendering!" );
mJobCancelled = true; mJobCancelled = true;
mJob->cancel(); mJob->cancel();
Q_ASSERT( mJob == 0 ); // no need to delete here: already deleted in finished() Q_ASSERT( mJob == 0 ); // no need to delete here: already deleted in finished()
Expand Down Expand Up @@ -1606,18 +1604,12 @@ void QgsMapCanvas::panActionEnd( QPoint releasePoint )
QgsPoint start = getCoordinateTransform()->toMapCoordinates( mCanvasProperties->rubberStartPoint ); QgsPoint start = getCoordinateTransform()->toMapCoordinates( mCanvasProperties->rubberStartPoint );
QgsPoint end = getCoordinateTransform()->toMapCoordinates( releasePoint ); QgsPoint end = getCoordinateTransform()->toMapCoordinates( releasePoint );


qDebug( "start %f,%f", start.x(), start.y() );
qDebug( "end %f,%f", end.x(), end.y() );

double dx = qAbs( end.x() - start.x() ); double dx = qAbs( end.x() - start.x() );
double dy = qAbs( end.y() - start.y() ); double dy = qAbs( end.y() - start.y() );


// modify the extent // modify the extent
QgsRectangle r = mapSettings().visibleExtent(); QgsRectangle r = mapSettings().visibleExtent();


qDebug( " -------------XXX diff: %f,%f", dx, dy );
qDebug( " ------------oldR: %f,%f", r.xMinimum(), r.yMinimum() );

if ( end.x() < start.x() ) if ( end.x() < start.x() )
{ {
r.setXMinimum( r.xMinimum() + dx ); r.setXMinimum( r.xMinimum() + dx );
Expand Down Expand Up @@ -1645,7 +1637,6 @@ void QgsMapCanvas::panActionEnd( QPoint releasePoint )
setExtent( r ); setExtent( r );


r = mapSettings().visibleExtent(); r = mapSettings().visibleExtent();
qDebug( " ------------newR: %f,%f", r.xMinimum(), r.yMinimum() );


refresh(); refresh();
} }
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsmapcanvasmap.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void QgsMapCanvasMap::paint( QPainter* painter )
{ {
int w = qRound( boundingRect().width() ) - 2, h = qRound( boundingRect().height() ) - 2; // setRect() makes the size +2 :-( int w = qRound( boundingRect().width() ) - 2, h = qRound( boundingRect().height() ) - 2; // setRect() makes the size +2 :-(
if ( mImage.size() != QSize( w, h ) ) if ( mImage.size() != QSize( w, h ) )
qDebug( "map paint DIFFERENT SIZE: img %d,%d item %d,%d", mImage.width(), mImage.height(), w, h ); QgsDebugMsg( QString( "map paint DIFFERENT SIZE: img %1,%2 item %3,%4" ).arg( mImage.width() ).arg( mImage.height() ).arg( w ).arg( h ) );
painter->drawImage( QRect( 0, 0, w, h ), mImage ); painter->drawImage( QRect( 0, 0, w, h ), mImage );
} }


Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsmapoverviewcanvas.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -268,13 +268,13 @@ void QgsMapOverviewCanvas::refresh()


if ( mJob ) if ( mJob )
{ {
qDebug( "oveview - cancelling old" ); QgsDebugMsg( "oveview - cancelling old" );
mJob->cancel(); mJob->cancel();
qDebug( "oveview - deleting old" ); QgsDebugMsg( "oveview - deleting old" );
delete mJob; // get rid of previous job (if any) delete mJob; // get rid of previous job (if any)
} }


qDebug( "oveview - starting new" ); QgsDebugMsg( "oveview - starting new" );


// TODO: setup overview mode // TODO: setup overview mode
mJob = new QgsMapRendererSequentialJob( mSettings ); mJob = new QgsMapRendererSequentialJob( mSettings );
Expand All @@ -290,7 +290,7 @@ void QgsMapOverviewCanvas::refresh()


void QgsMapOverviewCanvas::mapRenderingFinished() void QgsMapOverviewCanvas::mapRenderingFinished()
{ {
qDebug( "overview - finished" ); QgsDebugMsg( "overview - finished" );
mPixmap = QPixmap::fromImage( mJob->renderedImage() ); mPixmap = QPixmap::fromImage( mJob->renderedImage() );


delete mJob; delete mJob;
Expand Down

0 comments on commit 9c4a990

Please sign in to comment.