Skip to content
Permalink
Browse files

Make rendering related debug messages us QgsDebugMsg

  • Loading branch information
wonder-sk committed Feb 26, 2014
1 parent a813be1 commit 9c4a990fe31332892714aef602d78afab0438448
Showing with 36 additions and 46 deletions.
  1. +24 −25 src/core/qgsmaprendererjob.cpp
  2. +7 −16 src/gui/qgsmapcanvas.cpp
  3. +1 −1 src/gui/qgsmapcanvasmap.cpp
  4. +4 −4 src/gui/qgsmapoverviewcanvas.cpp
@@ -47,18 +47,18 @@ QgsMapRendererSequentialJob::QgsMapRendererSequentialJob( const QgsMapSettings&
, mPainter( 0 )
, mLabelingResults( 0 )
{
qDebug( "SEQUENTIAL construct" );
QgsDebugMsg( "SEQUENTIAL construct" );

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

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

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

mErrors.clear();

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

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

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

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

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

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

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

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

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

mErrors.clear();

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

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

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

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

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();

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

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

mFutureWatcher.waitForFinished();

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

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

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

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

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

drawNewLabeling( settings, renderContext, labelingEngine );

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


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

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

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 );
}

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

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

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

mFutureWatcher.waitForFinished();

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

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

mLabelingFutureWatcher.waitForFinished();

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

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

cleanupJobs( mLayerJobs );

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

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

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

mStatus = Idle;

@@ -566,25 +566,25 @@ void QgsMapCanvas::refresh()
{
if ( !mSettings.hasValidSettings() )
{
qDebug( "CANVAS refresh - invalid settings -> nothing to do" );
QgsDebugMsg( "CANVAS refresh - invalid settings -> nothing to do" );
return;
}

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

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

mRefreshScheduled = true;

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

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

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

stopRendering(); // if any...

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

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

mMapUpdateTimer.stop();

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

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

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

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

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

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

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

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

refresh();
}
@@ -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 :-(
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 );
}

@@ -268,13 +268,13 @@ void QgsMapOverviewCanvas::refresh()

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

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

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

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

delete mJob;

0 comments on commit 9c4a990

Please sign in to comment.
You can’t perform that action at this time.