Skip to content
Permalink
Browse files

Make the non-preview layout 3D maps renders work again

  • Loading branch information
wonder-sk committed Aug 24, 2018
1 parent 832d27c commit 7bdcab67bf5063d9f159fc68546ce69b7721f6aa
Showing with 22 additions and 3 deletions.
  1. +22 −3 src/3d/qgslayoutitem3dmap.cpp
@@ -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() ) ),
@@ -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 )

0 comments on commit 7bdcab6

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