mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-11 12:40:12 +00:00
User layer bug fixes.
1) Don't set user layer count right after we've cleared the enabled user layers. (It will always be 0 by then.) 2) Allow un-enabled layers in some layer selectors. (Currently this is just the private layers selector. 3) Reset the appearance panel layers each time a footprint is loaded. Also, auto-enable any user layers that the footprint already has. 4) Footprint editor layer visibility is stored in the view, not in the boars (as is usual). Fixes https://gitlab.com/kicad/code/kicad/-/issues/20022
This commit is contained in:
parent
3051a40376
commit
305bb6302b
@ -1484,8 +1484,13 @@ void BOARD_DESIGN_SETTINGS::SetEnabledLayers( LSET aMask )
|
||||
m_enabledLayers = aMask;
|
||||
|
||||
// update layer counts to ensure their consistency with m_EnabledLayers
|
||||
m_copperLayerCount = (int) aMask.ClearNonCopperLayers().count();
|
||||
m_userDefinedLayerCount = (int) ( aMask & LSET::UserDefinedLayersMask() ).count();
|
||||
LSET copperLayers = aMask;
|
||||
copperLayers.ClearNonCopperLayers();
|
||||
|
||||
LSET userLayers = aMask & LSET::UserDefinedLayersMask();
|
||||
|
||||
m_copperLayerCount = (int) copperLayers.count();
|
||||
m_userDefinedLayerCount = (int) userLayers.count();
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,7 +66,7 @@ PRIVATE_LAYERS_GRID_TABLE::PRIVATE_LAYERS_GRID_TABLE( PCB_BASE_FRAME* aFrame ) :
|
||||
LSET forbiddenLayers = LSET::AllCuMask() | LSET::AllTechMask();
|
||||
forbiddenLayers.set( Edge_Cuts );
|
||||
forbiddenLayers.set( Margin );
|
||||
m_layerColAttr->SetEditor( new GRID_CELL_LAYER_SELECTOR( m_frame, forbiddenLayers ) );
|
||||
m_layerColAttr->SetEditor( new GRID_CELL_LAYER_SELECTOR( m_frame, forbiddenLayers, true ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -317,7 +317,10 @@ PANEL_FP_EDITOR_FIELD_DEFAULTS::PANEL_FP_EDITOR_FIELD_DEFAULTS( wxWindow*
|
||||
|
||||
attr = new wxGridCellAttr;
|
||||
attr->SetRenderer( new GRID_CELL_LAYER_RENDERER( nullptr ) );
|
||||
attr->SetEditor( new GRID_CELL_LAYER_SELECTOR( nullptr, LSET::AllTechMask() | LSET::AllCuMask() | Edge_Cuts | Margin ) );
|
||||
LSET forbiddenLayers = LSET::AllCuMask() | LSET::AllTechMask();
|
||||
forbiddenLayers.set( Edge_Cuts );
|
||||
forbiddenLayers.set( Margin );
|
||||
attr->SetEditor( new GRID_CELL_LAYER_SELECTOR( nullptr, forbiddenLayers ) );
|
||||
m_layerNameitemsGrid->SetColAttr( 0, attr );
|
||||
|
||||
|
||||
|
@ -184,15 +184,6 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
float proportion = GetFootprintEditorSettings()->m_AuiPanels.properties_splitter;
|
||||
m_propertiesPanel->SetSplitterProportion( proportion );
|
||||
|
||||
// Must be set after calling LoadSettings() to be sure these parameters are not dependent
|
||||
// on what is read in stored settings. 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()->SetEnabledLayers( GetBoard()->GetEnabledLayers().set( In1_Cu ) );
|
||||
GetBoard()->SetVisibleLayers( GetBoard()->GetEnabledLayers() );
|
||||
GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
|
||||
|
||||
SetActiveLayer( F_SilkS );
|
||||
|
||||
// Fetch a COPY of the config as a lot of these initializations are going to overwrite our
|
||||
@ -539,25 +530,52 @@ void FOOTPRINT_EDIT_FRAME::ReloadFootprint( FOOTPRINT* aFootprint )
|
||||
// ("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.
|
||||
GetBoard()->SetCopperLayerCount( 3 );
|
||||
GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
|
||||
|
||||
// Don't drop pre-existing user layers
|
||||
LSET enabledLayers = GetBoard()->GetEnabledLayers();
|
||||
enabledLayers.set( In1_Cu ); // we've already done this, but it needs doing again :shrug:
|
||||
|
||||
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
|
||||
// just delegates to the project file, which we don't have).
|
||||
for( PCB_LAYER_ID layer : enabledLayers )
|
||||
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." ),
|
||||
aFootprint->GetReference() );
|
||||
const wxString openLibLink =
|
||||
wxString::Format( _( "Open in library %s" ), UnescapeString( libName ) );
|
||||
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 ) );
|
||||
|
||||
const auto openLibraryCopy = [this]( wxHyperlinkEvent& aEvent )
|
||||
{
|
||||
GetToolManager()->RunAction( PCB_ACTIONS::editLibFpInFpEditor );
|
||||
};
|
||||
const auto openLibraryCopy =
|
||||
[this]( wxHyperlinkEvent& aEvent )
|
||||
{
|
||||
GetToolManager()->RunAction( PCB_ACTIONS::editLibFpInFpEditor );
|
||||
};
|
||||
|
||||
if( WX_INFOBAR* infobar = GetInfoBar() )
|
||||
{
|
||||
wxHyperlinkCtrl* button =
|
||||
new wxHyperlinkCtrl( infobar, wxID_ANY, openLibLink, wxEmptyString );
|
||||
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, openLibLink,
|
||||
wxEmptyString );
|
||||
button->Bind( wxEVT_COMMAND_HYPERLINK, openLibraryCopy );
|
||||
|
||||
infobar->RemoveAllButtons();
|
||||
@ -578,10 +596,11 @@ void FOOTPRINT_EDIT_FRAME::ReloadFootprint( FOOTPRINT* aFootprint )
|
||||
{
|
||||
wxString link = _( "Save as editable copy" );
|
||||
|
||||
const auto saveAsEditableCopy = [this, aFootprint]( wxHyperlinkEvent& aEvent )
|
||||
{
|
||||
SaveFootprintAs( aFootprint );
|
||||
};
|
||||
const auto saveAsEditableCopy =
|
||||
[this, aFootprint]( wxHyperlinkEvent& aEvent )
|
||||
{
|
||||
SaveFootprintAs( aFootprint );
|
||||
};
|
||||
|
||||
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, link, wxEmptyString );
|
||||
button->Bind( wxEVT_COMMAND_HYPERLINK, saveAsEditableCopy );
|
||||
@ -599,6 +618,7 @@ void FOOTPRINT_EDIT_FRAME::ReloadFootprint( FOOTPRINT* aFootprint )
|
||||
}
|
||||
|
||||
UpdateMsgPanel();
|
||||
UpdateUserInterface();
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,9 +110,11 @@ void GRID_CELL_LAYER_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC&
|
||||
// Note: this implementation is an adaptation of wxGridCellChoiceEditor
|
||||
|
||||
|
||||
GRID_CELL_LAYER_SELECTOR::GRID_CELL_LAYER_SELECTOR( PCB_BASE_FRAME* aFrame, LSET aMask ) :
|
||||
GRID_CELL_LAYER_SELECTOR::GRID_CELL_LAYER_SELECTOR( PCB_BASE_FRAME* aFrame, LSET aMask,
|
||||
bool aShowNonActivated ) :
|
||||
m_frame( aFrame ),
|
||||
m_mask( aMask ),
|
||||
m_showNonActivated( aShowNonActivated ),
|
||||
m_value( 0 )
|
||||
{
|
||||
}
|
||||
@ -134,6 +136,7 @@ void GRID_CELL_LAYER_SELECTOR::Create( wxWindow* aParent, wxWindowID aId,
|
||||
LayerBox()->SetLayersHotkeys( false );
|
||||
LayerBox()->SetBoardFrame( m_frame );
|
||||
LayerBox()->SetNotAllowedLayerSet( m_mask );
|
||||
LayerBox()->ShowNonActivatedLayers( m_showNonActivated );
|
||||
|
||||
wxGridCellEditor::Create(aParent, aId, aEventHandler);
|
||||
}
|
||||
|
@ -56,7 +56,8 @@ private:
|
||||
class GRID_CELL_LAYER_SELECTOR : public wxGridCellEditor
|
||||
{
|
||||
public:
|
||||
GRID_CELL_LAYER_SELECTOR( PCB_BASE_FRAME* aFrame, LSET forbiddenLayers );
|
||||
GRID_CELL_LAYER_SELECTOR( PCB_BASE_FRAME* aFrame, LSET forbiddenLayers,
|
||||
bool aShowNonActivated = false );
|
||||
|
||||
wxGridCellEditor* Clone() const override;
|
||||
void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
|
||||
@ -82,6 +83,7 @@ protected:
|
||||
|
||||
PCB_BASE_FRAME* m_frame;
|
||||
LSET m_mask;
|
||||
bool m_showNonActivated;
|
||||
int m_value;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS( GRID_CELL_LAYER_SELECTOR );
|
||||
|
Loading…
Reference in New Issue
Block a user