mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
Auto-enable user layers that have custom FPEditor names.
This commit is contained in:
parent
1b40ddaba5
commit
3380afd9fd
@ -528,6 +528,40 @@ void FOOTPRINT_EDIT_FRAME::restoreLastFootprint()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT_EDIT_FRAME::updateEnabledLayers()
|
||||||
|
{
|
||||||
|
// 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.
|
||||||
|
GetBoard()->SetCopperLayerCount( 3 );
|
||||||
|
GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
|
||||||
|
|
||||||
|
// Don't drop pre-existing user layers
|
||||||
|
LSET enabledLayers = GetBoard()->GetEnabledLayers();
|
||||||
|
|
||||||
|
m_originalFootprintCopy->RunOnDescendants(
|
||||||
|
[&]( BOARD_ITEM* child )
|
||||||
|
{
|
||||||
|
LSET childLayers = child->GetLayerSet() & LSET::UserDefinedLayersMask();
|
||||||
|
|
||||||
|
for( PCB_LAYER_ID layer : childLayers )
|
||||||
|
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 )
|
void FOOTPRINT_EDIT_FRAME::ReloadFootprint( FOOTPRINT* aFootprint )
|
||||||
{
|
{
|
||||||
GetBoard()->DeleteAllFootprints();
|
GetBoard()->DeleteAllFootprints();
|
||||||
@ -542,37 +576,18 @@ void FOOTPRINT_EDIT_FRAME::ReloadFootprint( FOOTPRINT* aFootprint )
|
|||||||
// ("old" footprints can have null uuids that create issues in fp editor)
|
// ("old" footprints can have null uuids that create issues in fp editor)
|
||||||
aFootprint->FixUuids();
|
aFootprint->FixUuids();
|
||||||
|
|
||||||
// Enable one internal layer, because footprints support keepout areas that can be on
|
updateEnabledLayers();
|
||||||
// internal layers only (therefore on the first internal layer). This is needed to handle
|
|
||||||
// these keepout in internal layers only.
|
|
||||||
GetBoard()->SetCopperLayerCount( 3 );
|
|
||||||
GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
|
|
||||||
|
|
||||||
// Don't drop pre-existing user layers
|
|
||||||
LSET enabledLayers = GetBoard()->GetEnabledLayers();
|
|
||||||
|
|
||||||
aFootprint->RunOnDescendants(
|
|
||||||
[&]( BOARD_ITEM* child )
|
|
||||||
{
|
|
||||||
LSET childLayers = child->GetLayerSet() & LSET::UserDefinedLayersMask();
|
|
||||||
|
|
||||||
for( PCB_LAYER_ID layer : childLayers )
|
|
||||||
enabledLayers.set( layer );
|
|
||||||
} );
|
|
||||||
|
|
||||||
GetBoard()->SetEnabledLayers( enabledLayers );
|
|
||||||
|
|
||||||
// Footprint Editor layer visibility is kept in the view, not the board (because the board
|
// 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).
|
// 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 );
|
GetCanvas()->GetView()->SetLayerVisible( layer, true );
|
||||||
|
|
||||||
const wxString libName = aFootprint->GetFPID().GetLibNickname();
|
const wxString libName = aFootprint->GetFPID().GetLibNickname();
|
||||||
|
|
||||||
if( IsCurrentFPFromBoard() )
|
if( IsCurrentFPFromBoard() )
|
||||||
{
|
{
|
||||||
const wxString msg = wxString::Format( _( "Editing %s from board. Saving will update the "
|
const wxString msg = wxString::Format( _( "Editing %s from board. Saving will update the board only." ),
|
||||||
"board only." ),
|
|
||||||
aFootprint->GetReference() );
|
aFootprint->GetReference() );
|
||||||
const wxString openLibLink = wxString::Format( _( "Open in library %s" ),
|
const wxString openLibLink = wxString::Format( _( "Open in library %s" ),
|
||||||
UnescapeString( libName ) );
|
UnescapeString( libName ) );
|
||||||
@ -1447,8 +1462,7 @@ void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( int aFlags )
|
|||||||
GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
|
GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
|
||||||
|
|
||||||
GetBoard()->GetDesignSettings() = cfg->m_DesignSettings;
|
GetBoard()->GetDesignSettings() = cfg->m_DesignSettings;
|
||||||
GetBoard()->SetCopperLayerCount( 3 );
|
updateEnabledLayers();
|
||||||
GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
|
|
||||||
|
|
||||||
GetCanvas()->GetView()->UpdateAllLayersColor();
|
GetCanvas()->GetView()->UpdateAllLayersColor();
|
||||||
GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||||
|
@ -322,6 +322,8 @@ protected:
|
|||||||
void restoreLastFootprint();
|
void restoreLastFootprint();
|
||||||
void retainLastFootprint();
|
void retainLastFootprint();
|
||||||
|
|
||||||
|
void updateEnabledLayers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief (Re)Create the menubar for the Footprint Editor frame
|
* @brief (Re)Create the menubar for the Footprint Editor frame
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user