Skip to content

Commit d952ba4

Browse files
authoredSep 5, 2018
[3d] Use layout item bg color as 3D scene bg color
1 parent 4b411e0 commit d952ba4

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed
 

‎src/3d/qgslayoutitem3dmap.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ void QgsLayoutItem3DMap::draw( QgsLayoutItemRenderContext &context )
106106
return;
107107
}
108108

109+
if ( mSettings->backgroundColor() != backgroundColor() )
110+
{
111+
mSettings->setBackgroundColor( backgroundColor() );
112+
mCapturedImage = QImage();
113+
}
114+
109115
if ( !mCapturedImage.isNull() )
110116
{
111117
painter->drawImage( r, mCapturedImage );

‎src/app/layout/qgslayout3dmapwidget.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,23 @@ void QgsLayout3DMapWidget::updateCameraPoseWidgetsFromItem()
115115
void QgsLayout3DMapWidget::copy3DMapSettings()
116116
{
117117
Qgs3DMapCanvasDockWidget *dock = _dock3DViewFromSender( sender() );
118+
if ( !dock )
119+
return;
118120

119-
// if this is the first settings passed on, also copy camera details
121+
Qgs3DMapSettings *settings = new Qgs3DMapSettings( *dock->mapCanvas3D()->map() );
122+
123+
// first setting passed on
120124
if ( !mMap3D->mapSettings() )
121125
{
126+
// copy background color
127+
mMap3D->setBackgroundColor( settings->backgroundColor() );
128+
129+
// copy camera position details
122130
mMap3D->setCameraPose( dock->mapCanvas3D()->cameraController()->cameraPose() );
123131
updateCameraPoseWidgetsFromItem();
124132
}
125133

126-
if ( dock )
127-
mMap3D->setMapSettings( new Qgs3DMapSettings( *dock->mapCanvas3D()->map() ) );
134+
mMap3D->setMapSettings( settings );
128135
}
129136

130137
void QgsLayout3DMapWidget::copeCameraPose()

‎tests/src/3d/testqgslayout3dmap.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ void TestQgsLayout3DMap::testBasic()
114114
l.initializeDefaults();
115115

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

0 commit comments

Comments
 (0)
Please sign in to comment.