Skip to content

Commit

Permalink
[3d] Use layout item bg color as 3D scene bg color
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Sep 5, 2018
1 parent 4b411e0 commit d952ba4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/3d/qgslayoutitem3dmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
13 changes: 10 additions & 3 deletions src/app/layout/qgslayout3dmapwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions tests/src/3d/testqgslayout3dmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit d952ba4

Please sign in to comment.