Pcbnew: also show clearance outlines in FP editor

Not having these shown makes it easy to accidentally
enable them without noticing.
This commit is contained in:
John Beard 2025-01-02 01:33:33 +08:00
parent 06e0e16336
commit ea12689e29
2 changed files with 38 additions and 9 deletions

View File

@ -289,8 +289,31 @@ COLOR4D FOOTPRINT_EDIT_FRAME::GetGridColor()
void FOOTPRINT_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer )
{
const PCB_LAYER_ID oldLayer = GetActiveLayer();
if( oldLayer == aLayer )
return;
PCB_BASE_FRAME::SetActiveLayer( aLayer );
/*
* Follow the PCB editor logic for showing/hiding clearance layers: show only for
* the active copper layer or a front/back non-copper layer.
*/
const auto getClearanceLayerForActive = []( PCB_LAYER_ID aActiveLayer ) -> std::optional<int>
{
if( IsCopperLayer( aActiveLayer ) )
return CLEARANCE_LAYER_FOR( aActiveLayer );
return std::nullopt;
};
if( std::optional<int> oldClearanceLayer = getClearanceLayerForActive( oldLayer ) )
GetCanvas()->GetView()->SetLayerVisible( *oldClearanceLayer, false );
if( std::optional<int> newClearanceLayer = getClearanceLayerForActive( aLayer ) )
GetCanvas()->GetView()->SetLayerVisible( *newClearanceLayer, true );
m_appearancePanel->OnLayerChanged();
m_toolManager->RunAction( PCB_ACTIONS::layerChanged ); // notify other tools

View File

@ -1493,7 +1493,7 @@ void PCB_EDIT_FRAME::SetGridColor( const COLOR4D& aColor )
void PCB_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer )
{
PCB_LAYER_ID oldLayer = GetActiveLayer();
const PCB_LAYER_ID oldLayer = GetActiveLayer();
if( oldLayer == aLayer )
return;
@ -1508,7 +1508,9 @@ void PCB_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer )
/*
* Only show pad, via and track clearances when a copper layer is active
* and then only show the clearance layer for that copper layer.
* and then only show the clearance layer for that copper layer. For
* front/back non-copper layers, show the clearance layer for the outer
* layer on that side.
*
* For pads/vias, this is to avoid clutter when there are pad/via layers
* that vary in flash (i.e. clearance from the hole or pad edge), padstack
@ -1518,15 +1520,19 @@ void PCB_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer )
* have their own set of independent clearance layers to allow track clearance
* to be shown for more layers.
*/
if( IsCopperLayer( oldLayer ) )
const auto getClearanceLayerForActive = []( PCB_LAYER_ID aActiveLayer ) -> std::optional<int>
{
GetCanvas()->GetView()->SetLayerVisible( CLEARANCE_LAYER_FOR( oldLayer ), false );
}
if( IsCopperLayer( aActiveLayer ) )
return CLEARANCE_LAYER_FOR( aActiveLayer );
if( IsCopperLayer( aLayer ) )
{
GetCanvas()->GetView()->SetLayerVisible( CLEARANCE_LAYER_FOR( aLayer ), true );
}
return std::nullopt;
};
if( std::optional<int> oldClearanceLayer = getClearanceLayerForActive( oldLayer ) )
GetCanvas()->GetView()->SetLayerVisible( *oldClearanceLayer, false );
if( std::optional<int> newClearanceLayer = getClearanceLayerForActive( aLayer ) )
GetCanvas()->GetView()->SetLayerVisible( *newClearanceLayer, true );
GetCanvas()->GetView()->UpdateAllItemsConditionally(
[&]( KIGFX::VIEW_ITEM* aItem ) -> int