Pcbnew, footprint editor: make switching layers visibility on/off working.

In footprint editor the board is a dummy board not managed by project settings,
so using its settings to manage layers visibility does not work.

Fixes #4924
https://gitlab.com/kicad/code/kicad/issues/4024
This commit is contained in:
jean-pierre charras 2020-07-18 10:31:06 +02:00
parent cc688a3e1d
commit a25f7cc0a4
1 changed files with 15 additions and 8 deletions

View File

@ -621,6 +621,10 @@ bool PCB_LAYER_WIDGET::OnLayerSelected()
void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal ) void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
{ {
// In other frames than board editor, the board is a dummy board.
// so changing board settings makes sense (and works) only for the board editor frame
if( myframe->IsType( FRAME_PCB_EDITOR ) )
{
BOARD* brd = myframe->GetBoard(); BOARD* brd = myframe->GetBoard();
LSET visibleLayers = brd->GetVisibleLayers(); LSET visibleLayers = brd->GetVisibleLayers();
@ -628,12 +632,15 @@ void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal
if( visibleLayers.test( aLayer ) != isVisible ) if( visibleLayers.test( aLayer ) != isVisible )
{ {
visibleLayers.set( aLayer, isVisible ); visibleLayers.set( aLayer, isVisible );
brd->SetVisibleLayers( visibleLayers ); brd->SetVisibleLayers( visibleLayers );
if( myframe->GetCanvas() ) if( myframe->GetCanvas() )
myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible ); myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
} }
}
else
if( myframe->GetCanvas() )
myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
if( isFinal ) if( isFinal )
myframe->GetCanvas()->Refresh(); myframe->GetCanvas()->Refresh();