Browse Source

Auto-enable user layers that have custom FPEditor names.

revert-0c36e162
Jeff Young 7 months ago
parent
commit
3380afd9fd
  1. 52
      pcbnew/footprint_edit_frame.cpp
  2. 2
      pcbnew/footprint_edit_frame.h

52
pcbnew/footprint_edit_frame.cpp

@ -528,20 +528,8 @@ void FOOTPRINT_EDIT_FRAME::restoreLastFootprint()
}
void FOOTPRINT_EDIT_FRAME::ReloadFootprint( FOOTPRINT* aFootprint )
void FOOTPRINT_EDIT_FRAME::updateEnabledLayers()
{
GetBoard()->DeleteAllFootprints();
m_originalFootprintCopy.reset( static_cast<FOOTPRINT*>( aFootprint->Clone() ) );
m_originalFootprintCopy->SetParent( nullptr );
m_footprintNameWhenLoaded = aFootprint->GetFPID().GetUniStringLibItemName();
PCB_BASE_EDIT_FRAME::AddFootprintToBoard( aFootprint );
// Ensure item UUIDs are valid
// ("old" footprints can have null uuids that create issues in fp editor)
aFootprint->FixUuids();
// Enable one internal layer, because footprints support keepout areas that can be on
// internal layers only (therefore on the first internal layer). This is needed to handle
// these keepout in internal layers only.
@ -551,7 +539,7 @@ void FOOTPRINT_EDIT_FRAME::ReloadFootprint( FOOTPRINT* aFootprint )
// Don't drop pre-existing user layers
LSET enabledLayers = GetBoard()->GetEnabledLayers();
aFootprint->RunOnDescendants(
m_originalFootprintCopy->RunOnDescendants(
[&]( BOARD_ITEM* child )
{
LSET childLayers = child->GetLayerSet() & LSET::UserDefinedLayersMask();
@ -560,19 +548,46 @@ void FOOTPRINT_EDIT_FRAME::ReloadFootprint( FOOTPRINT* aFootprint )
enabledLayers.set( layer );
} );
// Enable any layers that the user has gone to the trouble to name
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
FOOTPRINT_EDITOR_SETTINGS* cfg = mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" );
for( const PCB_LAYER_ID& user : LSET::UserDefinedLayersMask() )
{
if( cfg->m_DesignSettings.m_UserLayerNames.contains( LSET::Name( user ).ToStdString() ) )
enabledLayers.set( user );
}
GetBoard()->SetEnabledLayers( enabledLayers );
}
void FOOTPRINT_EDIT_FRAME::ReloadFootprint( FOOTPRINT* aFootprint )
{
GetBoard()->DeleteAllFootprints();
m_originalFootprintCopy.reset( static_cast<FOOTPRINT*>( aFootprint->Clone() ) );
m_originalFootprintCopy->SetParent( nullptr );
m_footprintNameWhenLoaded = aFootprint->GetFPID().GetUniStringLibItemName();
PCB_BASE_EDIT_FRAME::AddFootprintToBoard( aFootprint );
// Ensure item UUIDs are valid
// ("old" footprints can have null uuids that create issues in fp editor)
aFootprint->FixUuids();
updateEnabledLayers();
// Footprint Editor layer visibility is kept in the view, not the board (because the board
// just delegates to the project file, which we don't have).
for( PCB_LAYER_ID layer : enabledLayers )
for( PCB_LAYER_ID layer : GetBoard()->GetEnabledLayers() )
GetCanvas()->GetView()->SetLayerVisible( layer, true );
const wxString libName = aFootprint->GetFPID().GetLibNickname();
if( IsCurrentFPFromBoard() )
{
const wxString msg = wxString::Format( _( "Editing %s from board. Saving will update the "
"board only." ),
const wxString msg = wxString::Format( _( "Editing %s from board. Saving will update the board only." ),
aFootprint->GetReference() );
const wxString openLibLink = wxString::Format( _( "Open in library %s" ),
UnescapeString( libName ) );
@ -1447,8 +1462,7 @@ void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( int aFlags )
GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
GetBoard()->GetDesignSettings() = cfg->m_DesignSettings;
GetBoard()->SetCopperLayerCount( 3 );
GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
updateEnabledLayers();
GetCanvas()->GetView()->UpdateAllLayersColor();
GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );

2
pcbnew/footprint_edit_frame.h

@ -322,6 +322,8 @@ protected:
void restoreLastFootprint();
void retainLastFootprint();
void updateEnabledLayers();
/**
* @brief (Re)Create the menubar for the Footprint Editor frame
*/

Loading…
Cancel
Save