Skip to content
Permalink
Browse files

[3d] Use layout item bg color as 3D scene bg color

  • Loading branch information
nirvn committed Sep 5, 2018
1 parent 4b411e0 commit d952ba422ed6a6283ea43f3c93fc9b646d75de9e
Showing with 17 additions and 3 deletions.
  1. +6 −0 src/3d/qgslayoutitem3dmap.cpp
  2. +10 −3 src/app/layout/qgslayout3dmapwidget.cpp
  3. +1 −0 tests/src/3d/testqgslayout3dmap.cpp
@@ -106,6 +106,12 @@ void QgsLayoutItem3DMap::draw( QgsLayoutItemRenderContext &context )
return;
}

if ( mSettings->backgroundColor() != backgroundColor() )
{
mSettings->setBackgroundColor( backgroundColor() );
mCapturedImage = QImage();
}

if ( !mCapturedImage.isNull() )
{
painter->drawImage( r, mCapturedImage );
@@ -115,16 +115,23 @@ void QgsLayout3DMapWidget::updateCameraPoseWidgetsFromItem()
void QgsLayout3DMapWidget::copy3DMapSettings()
{
Qgs3DMapCanvasDockWidget *dock = _dock3DViewFromSender( sender() );
if ( !dock )
return;

// if this is the first settings passed on, also copy camera details
Qgs3DMapSettings *settings = new Qgs3DMapSettings( *dock->mapCanvas3D()->map() );

// first setting passed on
if ( !mMap3D->mapSettings() )
{
// copy background color
mMap3D->setBackgroundColor( settings->backgroundColor() );

// copy camera position details
mMap3D->setCameraPose( dock->mapCanvas3D()->cameraController()->cameraPose() );
updateCameraPoseWidgetsFromItem();
}

if ( dock )
mMap3D->setMapSettings( new Qgs3DMapSettings( *dock->mapCanvas3D()->map() ) );
mMap3D->setMapSettings( settings );
}

void QgsLayout3DMapWidget::copeCameraPose()
@@ -114,6 +114,7 @@ void TestQgsLayout3DMap::testBasic()
l.initializeDefaults();

QgsLayoutItem3DMap *map3dItem = new QgsLayoutItem3DMap( &l );
map3dItem->setBackgroundColor( QColor( 0, 0, 0 ) );
map3dItem->attemptSetSceneRect( QRectF( 0, 0, 297, 210 ) );
map3dItem->setCameraPose( cam );
map3dItem->setMapSettings( map );

0 comments on commit d952ba4

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