Skip to content

Commit

Permalink
Make the non-preview layout 3D maps renders work again
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Aug 24, 2018
1 parent 832d27c commit 7bdcab6
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/3d/qgslayoutitem3dmap.cpp
Expand Up @@ -69,8 +69,11 @@ void QgsLayoutItem3DMap::draw( QgsLayoutItemRenderContext &context )

// we do not have a cached image of the rendered scene - let's request one from the engine

painter->drawText( r, Qt::AlignCenter, tr( "Loading" ) );
painter->restore();
if ( mLayout->renderContext().isPreviewRender() )
{
painter->drawText( r, Qt::AlignCenter, tr( "Loading" ) );
painter->restore();
}

QSizeF sizePixels = mLayout->renderContext().measurementConverter().convert( sizeWithUnits(), QgsUnitTypes::LayoutPixels ).toQSizeF();
QSize sizePixelsInt = QSize( static_cast<int>( std::ceil( sizePixels.width() ) ),
Expand All @@ -94,7 +97,23 @@ void QgsLayoutItem3DMap::draw( QgsLayoutItemRenderContext &context )

mScene->cameraController()->setCameraPose( mCameraPose );

onSceneStateChanged();
if ( mLayout->renderContext().isPreviewRender() )
{
onSceneStateChanged();
}
else
{
// we can't just request a capture and hope it will arrive at some point later.
// this is not a preview, we need the rendered scene now!
if ( mDrawing )
return;
mDrawing = true;
Qgs3DUtils::captureSceneImage( *mEngine.get(), mScene );
QImage img = Qgs3DUtils::captureSceneImage( *mEngine.get(), mScene );
painter->drawImage( r, img );
painter->restore();
mDrawing = false;
}
}

void QgsLayoutItem3DMap::onImageCaptured( const QImage &img )
Expand Down

0 comments on commit 7bdcab6

Please sign in to comment.