From d40fe127aa1d77f5ec45b0d174c721546c2b5300 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 25 Jan 2021 01:19:35 +0000 Subject: [PATCH] Update pad locked status when adding footprints from schematic. Also fixes some latent bugs with not updating the local ratsnest visibility in other places, and the netcode in update PCB from schematic. Fixes https://gitlab.com/kicad/code/kicad/issues/7202 --- pcbnew/dialogs/panel_edit_options_base.cpp | 2 +- pcbnew/dialogs/panel_edit_options_base.fbp | 2 +- pcbnew/footprint_viewer_frame.cpp | 5 ++++- .../netlist_reader/board_netlist_updater.cpp | 21 ++++++++++++------- pcbnew/tools/board_editor_control.cpp | 4 +++- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/pcbnew/dialogs/panel_edit_options_base.cpp b/pcbnew/dialogs/panel_edit_options_base.cpp index aea7b2a4b4..f30349b462 100644 --- a/pcbnew/dialogs/panel_edit_options_base.cpp +++ b/pcbnew/dialogs/panel_edit_options_base.cpp @@ -39,7 +39,7 @@ PANEL_EDIT_OPTIONS_BASE::PANEL_EDIT_OPTIONS_BASE( wxWindow* parent, wxWindowID i bSizerBoardEdit = new wxBoxSizer( wxVERTICAL ); m_autoLockPads = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_ANY, _("Lock pads of newly added footprints"), wxDefaultPosition, wxDefaultSize, 0 ); - m_autoLockPads->SetToolTip( _("If checked, when a footprint is added to the board, the pads will be freely moveable.") ); + m_autoLockPads->SetToolTip( _("If checked, when a footprint is added to the board, its pads will be locked and not movable with respect to the footprint.") ); bSizerBoardEdit->Add( m_autoLockPads, 0, wxBOTTOM, 15 ); diff --git a/pcbnew/dialogs/panel_edit_options_base.fbp b/pcbnew/dialogs/panel_edit_options_base.fbp index aae3795b15..1e739387f8 100644 --- a/pcbnew/dialogs/panel_edit_options_base.fbp +++ b/pcbnew/dialogs/panel_edit_options_base.fbp @@ -286,7 +286,7 @@ ; ; forward_declare 0 - If checked, when a footprint is added to the board, the pads will be freely moveable. + If checked, when a footprint is added to the board, its pads will be locked and not movable with respect to the footprint. wxFILTER_NONE wxDefaultValidator diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 8106d00571..8252dac01e 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -738,10 +738,13 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent ) newFootprint->SetLink( niluuid ); newFootprint->SetFlags(IS_NEW ); // whatever - // Pads in the library all have orphaned nets. Replace with Default. for( PAD* pad : newFootprint->Pads() ) { + // Set the pads ratsnest settings to the global settings + pad->SetLocalRatsnestVisible( pcbframe->GetDisplayOptions().m_ShowGlobalRatsnest ); pad->SetLocked( !pcbframe->Settings().m_AddUnlockedPads ); + + // Pads in the library all have orphaned nets. Replace with Default. pad->SetNetCode( 0 ); } diff --git a/pcbnew/netlist_reader/board_netlist_updater.cpp b/pcbnew/netlist_reader/board_netlist_updater.cpp index c4b86a3660..808431ae91 100644 --- a/pcbnew/netlist_reader/board_netlist_updater.cpp +++ b/pcbnew/netlist_reader/board_netlist_updater.cpp @@ -41,15 +41,14 @@ #include #include #include - -#include "pcb_netlist.h" +#include +#include +#include #include #include #include "board_netlist_updater.h" -#include - BOARD_NETLIST_UPDATER::BOARD_NETLIST_UPDATER( PCB_EDIT_FRAME* aFrame, BOARD* aBoard ) : m_frame( aFrame ), @@ -168,11 +167,15 @@ FOOTPRINT* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent ) aComponent->GetFPID().Format().wx_str() ); m_reporter->Report( msg, RPT_SEVERITY_ACTION ); - // Set the pads ratsnest settings to the global settings - bool set_ratsnest = m_frame->GetDisplayOptions().m_ShowGlobalRatsnest; - for( PAD* pad : footprint->Pads() ) - pad->SetLocalRatsnestVisible( set_ratsnest ); + { + // Set the pads ratsnest settings to the global settings + pad->SetLocalRatsnestVisible( m_frame->GetDisplayOptions().m_ShowGlobalRatsnest ); + pad->SetLocked( !m_frame->Settings().m_AddUnlockedPads ); + + // Pads in the library all have orphaned nets. Replace with Default. + pad->SetNetCode( 0 ); + } m_newFootprintsCount++; @@ -187,7 +190,9 @@ FOOTPRINT* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent ) return footprint; } else + { delete footprint; + } return NULL; } diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index cd1876b4af..6384831ff6 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -902,10 +902,12 @@ int BOARD_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent ) // Set parent so that clearance can be loaded fp->SetParent( board ); - // Pads in the library all have orphaned nets. Replace with Default. for( PAD* pad : fp->Pads() ) { + pad->SetLocalRatsnestVisible( m_frame->GetDisplayOptions().m_ShowGlobalRatsnest ); pad->SetLocked( !m_frame->Settings().m_AddUnlockedPads ); + + // Pads in the library all have orphaned nets. Replace with Default. pad->SetNetCode( 0 ); }