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,19 +621,26 @@ 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 )
{ {
BOARD* brd = myframe->GetBoard(); // 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
LSET visibleLayers = brd->GetVisibleLayers(); if( myframe->IsType( FRAME_PCB_EDITOR ) )
if( visibleLayers.test( aLayer ) != isVisible )
{ {
visibleLayers.set( aLayer, isVisible ); BOARD* brd = myframe->GetBoard();
brd->SetVisibleLayers( visibleLayers ); LSET visibleLayers = brd->GetVisibleLayers();
if( visibleLayers.test( aLayer ) != isVisible )
{
visibleLayers.set( aLayer, isVisible );
brd->SetVisibleLayers( visibleLayers );
if( myframe->GetCanvas() )
myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
}
}
else
if( myframe->GetCanvas() ) if( myframe->GetCanvas() )
myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible ); myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
}
if( isFinal ) if( isFinal )
myframe->GetCanvas()->Refresh(); myframe->GetCanvas()->Refresh();