Make moving pads independent of footprint much harder with new setting

It is still possible to move a pad independent of footprint through
the pad properties dialog. This is a much more conscious decision
than using the move tools.

ADDED: "Allow free pads" preference setting in pcbnew, default to off.
When enabled, allows moving unlocked pads independent of the footprint
(i.e. previous behaviour). When disabled (default), any attempt to move
a pad will move the parent footprint instead.

REMOVED: "Lock pads of newly added footprints" preference setting in
pcbnew. (Pad lock state is now loaded from the footprint definition)

CHANGED: There are now only two possible lock states for a footprint:
locked and unlocked. The lock state of the pads in the footprint is
now independent of the footprint lock state.

Also fixed a latent bug that would allow a pad to be moved when the
parent footprint was locked (see m_selectionTool->RequestSelection
lambdas in edit_tool.cpp)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/7739
This commit is contained in:
Roberto Fernandez Bautista 2021-03-27 14:44:51 +00:00 committed by Jeff Young
parent ff371af810
commit 7077e59395
16 changed files with 134 additions and 120 deletions

View File

@ -227,8 +227,7 @@ bool DIALOG_FOOTPRINT_FP_EDITOR::TransferDataToWindow()
wxGridTableMessage tmsg( m_texts, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_texts->GetNumberRows() ); wxGridTableMessage tmsg( m_texts, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_texts->GetNumberRows() );
m_itemsGrid->ProcessTableMessage( tmsg ); m_itemsGrid->ProcessTableMessage( tmsg );
// Module Properties // Footprint Properties
m_AutoPlaceCtrl->SetSelection( m_footprint->IsLocked() ? 1 : 0 ); m_AutoPlaceCtrl->SetSelection( m_footprint->IsLocked() ? 1 : 0 );
m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Enable hotkey move commands and Auto Placement" ) ); m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Enable hotkey move commands and Auto Placement" ) );
m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable hotkey move commands and Auto Placement" ) ); m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable hotkey move commands and Auto Placement" ) );

View File

@ -132,10 +132,10 @@ DIALOG_FOOTPRINT_FP_EDITOR_BASE::DIALOG_FOOTPRINT_FP_EDITOR_BASE( wxWindow* pare
wxBoxSizer* bSizerProperties; wxBoxSizer* bSizerProperties;
bSizerProperties = new wxBoxSizer( wxHORIZONTAL ); bSizerProperties = new wxBoxSizer( wxHORIZONTAL );
wxString m_AutoPlaceCtrlChoices[] = { _("Free"), _("Lock footprint") }; wxString m_AutoPlaceCtrlChoices[] = { _("Unlock footprint"), _("Lock footprint") };
int m_AutoPlaceCtrlNChoices = sizeof( m_AutoPlaceCtrlChoices ) / sizeof( wxString ); int m_AutoPlaceCtrlNChoices = sizeof( m_AutoPlaceCtrlChoices ) / sizeof( wxString );
m_AutoPlaceCtrl = new wxRadioBox( m_PanelGeneral, wxID_ANY, _("Move and Place"), wxDefaultPosition, wxDefaultSize, m_AutoPlaceCtrlNChoices, m_AutoPlaceCtrlChoices, 1, wxRA_SPECIFY_COLS ); m_AutoPlaceCtrl = new wxRadioBox( m_PanelGeneral, wxID_ANY, _("Move and Place"), wxDefaultPosition, wxDefaultSize, m_AutoPlaceCtrlNChoices, m_AutoPlaceCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_AutoPlaceCtrl->SetSelection( 0 ); m_AutoPlaceCtrl->SetSelection( 1 );
bSizerProperties->Add( m_AutoPlaceCtrl, 1, wxTOP|wxRIGHT|wxLEFT, 5 ); bSizerProperties->Add( m_AutoPlaceCtrl, 1, wxTOP|wxRIGHT|wxLEFT, 5 );
m_sizerAP = new wxStaticBoxSizer( new wxStaticBox( m_PanelGeneral, wxID_ANY, _("Auto-placement Rules") ), wxVERTICAL ); m_sizerAP = new wxStaticBoxSizer( new wxStaticBox( m_PanelGeneral, wxID_ANY, _("Auto-placement Rules") ), wxVERTICAL );

View File

@ -868,7 +868,7 @@
<property name="caption"></property> <property name="caption"></property>
<property name="caption_visible">1</property> <property name="caption_visible">1</property>
<property name="center_pane">0</property> <property name="center_pane">0</property>
<property name="choices">&quot;Free&quot; &quot;Lock footprint&quot;</property> <property name="choices">&quot;Unlock footprint&quot; &quot;Lock footprint&quot;</property>
<property name="close_button">1</property> <property name="close_button">1</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
@ -900,7 +900,7 @@
<property name="pin_button">1</property> <property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="resize">Resizable</property> <property name="resize">Resizable</property>
<property name="selection">0</property> <property name="selection">1</property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property> <property name="style">wxRA_SPECIFY_COLS</property>

View File

@ -326,21 +326,11 @@ bool DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow()
updateOrientationControl(); updateOrientationControl();
if( m_footprint->IsLocked() ) m_AutoPlaceCtrl->SetSelection( m_footprint->IsLocked() ? 1 : 0 );
m_AutoPlaceCtrl->SetSelection( 2 );
else if( allPadsLocked( m_footprint ) )
m_AutoPlaceCtrl->SetSelection( 1 );
else
m_AutoPlaceCtrl->SetSelection( 0 );
m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Footprint can be freely moved and oriented on the " m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Footprint can be freely moved and oriented on the "
"canvas. At least some of the footprint's pads are " "canvas." ) );
"unlocked and can be moved with respect to the " m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Footprint is locked: it cannot be freely moved and "
"footprint." ) );
m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Footprint can be freely moved and oriented on the "
"canvas, but all of its pads are locked with respect "
"to their position within in the footprint." ) );
m_AutoPlaceCtrl->SetItemToolTip( 2, _( "Footprint is locked: it cannot be freely moved and "
"oriented on the canvas and can only be selected when " "oriented on the canvas and can only be selected when "
"the 'Locked items' checkbox is enabled in the " "the 'Locked items' checkbox is enabled in the "
"selection filter." ) ); "selection filter." ) );
@ -735,13 +725,7 @@ bool DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow()
// Set Footprint Position // Set Footprint Position
wxPoint pos( m_posX.GetValue(), m_posY.GetValue() ); wxPoint pos( m_posX.GetValue(), m_posY.GetValue() );
m_footprint->SetPosition( pos ); m_footprint->SetPosition( pos );
m_footprint->SetLocked( m_AutoPlaceCtrl->GetSelection() == 2 ); m_footprint->SetLocked( m_AutoPlaceCtrl->GetSelection() == 1 );
if( m_AutoPlaceCtrl->GetSelection() == 1 )
{
for( PAD* pad : m_footprint->Pads() )
pad->SetLocked( true );
}
int attributes = 0; int attributes = 0;

View File

@ -192,7 +192,7 @@ DIALOG_FOOTPRINT_PROPERTIES_BASE::DIALOG_FOOTPRINT_PROPERTIES_BASE( wxWindow* pa
wxBoxSizer* bSizerMiddle; wxBoxSizer* bSizerMiddle;
bSizerMiddle = new wxBoxSizer( wxVERTICAL ); bSizerMiddle = new wxBoxSizer( wxVERTICAL );
wxString m_AutoPlaceCtrlChoices[] = { _("Free"), _("Lock pads"), _("Lock footprint") }; wxString m_AutoPlaceCtrlChoices[] = { _("Unlock footprint"), _("Lock footprint") };
int m_AutoPlaceCtrlNChoices = sizeof( m_AutoPlaceCtrlChoices ) / sizeof( wxString ); int m_AutoPlaceCtrlNChoices = sizeof( m_AutoPlaceCtrlChoices ) / sizeof( wxString );
m_AutoPlaceCtrl = new wxRadioBox( m_PanelGeneral, wxID_ANY, _("Move and Place"), wxDefaultPosition, wxDefaultSize, m_AutoPlaceCtrlNChoices, m_AutoPlaceCtrlChoices, 1, wxRA_SPECIFY_COLS ); m_AutoPlaceCtrl = new wxRadioBox( m_PanelGeneral, wxID_ANY, _("Move and Place"), wxDefaultPosition, wxDefaultSize, m_AutoPlaceCtrlNChoices, m_AutoPlaceCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_AutoPlaceCtrl->SetSelection( 0 ); m_AutoPlaceCtrl->SetSelection( 0 );

View File

@ -1446,11 +1446,11 @@
</object> </object>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP</property> <property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxBoxSizer" expanded="0"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizerMiddle</property> <property name="name">bSizerMiddle</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
@ -1473,7 +1473,7 @@
<property name="caption"></property> <property name="caption"></property>
<property name="caption_visible">1</property> <property name="caption_visible">1</property>
<property name="center_pane">0</property> <property name="center_pane">0</property>
<property name="choices">&quot;Free&quot; &quot;Lock pads&quot; &quot;Lock footprint&quot;</property> <property name="choices">&quot;Unlock footprint&quot; &quot;Lock footprint&quot;</property>
<property name="close_button">1</property> <property name="close_button">1</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>

View File

@ -38,7 +38,6 @@ PANEL_EDIT_OPTIONS::PANEL_EDIT_OPTIONS( PCB_BASE_EDIT_FRAME* aFrame, PAGED_DIALO
m_magneticPads->Show( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) != nullptr ); m_magneticPads->Show( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) != nullptr );
m_magneticGraphics->Show( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) != nullptr ); m_magneticGraphics->Show( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) != nullptr );
m_flipLeftRight->Show( dynamic_cast<PCB_EDIT_FRAME*>( m_frame ) != nullptr ); m_flipLeftRight->Show( dynamic_cast<PCB_EDIT_FRAME*>( m_frame ) != nullptr );
m_autoLockPads->Show( dynamic_cast<PCB_EDIT_FRAME*>( m_frame ) != nullptr );
#ifdef __WXOSX_MAC__ #ifdef __WXOSX_MAC__
m_mouseCmdsOSX->Show( true ); m_mouseCmdsOSX->Show( true );
@ -73,7 +72,6 @@ bool PANEL_EDIT_OPTIONS::TransferDataToWindow()
m_magneticTrackChoice->SetSelection( static_cast<int>( general_opts.m_MagneticItems.tracks ) ); m_magneticTrackChoice->SetSelection( static_cast<int>( general_opts.m_MagneticItems.tracks ) );
m_magneticGraphicsChoice->SetSelection( !general_opts.m_MagneticItems.graphics ); m_magneticGraphicsChoice->SetSelection( !general_opts.m_MagneticItems.graphics );
m_flipLeftRight->SetValue( general_opts.m_FlipLeftRight ); m_flipLeftRight->SetValue( general_opts.m_FlipLeftRight );
m_autoLockPads->SetValue( !general_opts.m_AddUnlockedPads );
switch( general_opts.m_TrackDragAction ) switch( general_opts.m_TrackDragAction )
{ {
@ -84,6 +82,7 @@ bool PANEL_EDIT_OPTIONS::TransferDataToWindow()
m_Show_Page_Limits->SetValue( m_frame->ShowPageLimits() ); m_Show_Page_Limits->SetValue( m_frame->ShowPageLimits() );
m_Auto_Refill_Zones->SetValue( general_opts.m_AutoRefillZones ); m_Auto_Refill_Zones->SetValue( general_opts.m_AutoRefillZones );
m_Allow_Free_Pads->SetValue( general_opts.m_AllowFreePads );
} }
else if( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) ) else if( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
{ {
@ -119,8 +118,8 @@ bool PANEL_EDIT_OPTIONS::TransferDataFromWindow()
m_frame->Settings().m_FlipLeftRight = m_flipLeftRight->GetValue(); m_frame->Settings().m_FlipLeftRight = m_flipLeftRight->GetValue();
m_frame->SetShowPageLimits( m_Show_Page_Limits->GetValue() ); m_frame->SetShowPageLimits( m_Show_Page_Limits->GetValue() );
m_frame->Settings().m_AddUnlockedPads = !m_autoLockPads->GetValue();
m_frame->Settings().m_AutoRefillZones = m_Auto_Refill_Zones->GetValue(); m_frame->Settings().m_AutoRefillZones = m_Auto_Refill_Zones->GetValue();
m_frame->Settings().m_AllowFreePads = m_Allow_Free_Pads->GetValue();
if( m_rbTrackDragMove->GetValue() ) if( m_rbTrackDragMove->GetValue() )
pcbnewSettings.m_TrackDragAction = TRACK_DRAG_ACTION::MOVE; pcbnewSettings.m_TrackDragAction = TRACK_DRAG_ACTION::MOVE;

View File

@ -38,11 +38,6 @@ PANEL_EDIT_OPTIONS_BASE::PANEL_EDIT_OPTIONS_BASE( wxWindow* parent, wxWindowID i
wxBoxSizer* bSizerBoardEdit; wxBoxSizer* bSizerBoardEdit;
bSizerBoardEdit = new wxBoxSizer( wxVERTICAL ); 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, its pads will be locked and not movable with respect to the footprint.") );
bSizerBoardEdit->Add( m_autoLockPads, 0, wxBOTTOM, 15 );
m_flipLeftRight = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_ANY, _("Flip board items L/R (default is T/B)"), wxDefaultPosition, wxDefaultSize, 0 ); m_flipLeftRight = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_ANY, _("Flip board items L/R (default is T/B)"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerBoardEdit->Add( m_flipLeftRight, 0, wxBOTTOM, 15 ); bSizerBoardEdit->Add( m_flipLeftRight, 0, wxBOTTOM, 15 );
@ -371,6 +366,11 @@ PANEL_EDIT_OPTIONS_BASE::PANEL_EDIT_OPTIONS_BASE( wxWindow* parent, wxWindowID i
sbSizer4->Add( m_Auto_Refill_Zones, 0, wxALL, 5 ); sbSizer4->Add( m_Auto_Refill_Zones, 0, wxALL, 5 );
m_Allow_Free_Pads = new wxCheckBox( sbSizer4->GetStaticBox(), wxID_ANY, _("Allow free pads"), wxDefaultPosition, wxDefaultSize, 0 );
m_Allow_Free_Pads->SetToolTip( _("If unchecked (default), any attempt to move unlocked pads will instead move the footprint as a whole.\nIf checked, unlocked pads can be moved freely with respect to the rest of the footprint. \nNote: Locked pads cannot be moved with respect to the parent footprint regardless of this setting.") );
sbSizer4->Add( m_Allow_Free_Pads, 0, wxALL, 5 );
pcbOptionsSizer->Add( sbSizer4, 1, wxEXPAND|wxTOP, 5 ); pcbOptionsSizer->Add( sbSizer4, 1, wxEXPAND|wxTOP, 5 );

View File

@ -232,70 +232,6 @@
<property name="name">bSizerBoardEdit</property> <property name="name">bSizerBoardEdit</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">15</property>
<property name="flag">wxBOTTOM</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Lock pads of newly added footprints</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_autoLockPads</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">If checked, when a footprint is added to the board, its pads will be locked and not movable with respect to the footprint.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">15</property> <property name="border">15</property>
<property name="flag">wxBOTTOM</property> <property name="flag">wxBOTTOM</property>
@ -3487,6 +3423,70 @@
<property name="window_style"></property> <property name="window_style"></property>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Allow free pads</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_Allow_Free_Pads</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip">If unchecked (default), any attempt to move unlocked pads will instead move the footprint as a whole.&#x0A;If checked, unlocked pads can be moved freely with respect to the rest of the footprint. &#x0A;Note: Locked pads cannot be moved with respect to the parent footprint regardless of this setting.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object> </object>
</object> </object>
</object> </object>

View File

@ -43,7 +43,6 @@ class PANEL_EDIT_OPTIONS_BASE : public wxPanel
wxCheckBox* m_magneticPads; wxCheckBox* m_magneticPads;
wxCheckBox* m_magneticGraphics; wxCheckBox* m_magneticGraphics;
wxCheckBox* m_autoLockPads;
wxCheckBox* m_flipLeftRight; wxCheckBox* m_flipLeftRight;
wxCheckBox* m_segments45OnlyCtrl; wxCheckBox* m_segments45OnlyCtrl;
wxStaticText* m_staticTextRotationAngle; wxStaticText* m_staticTextRotationAngle;
@ -67,6 +66,7 @@ class PANEL_EDIT_OPTIONS_BASE : public wxPanel
wxRadioButton* m_rbTrackDragFree; wxRadioButton* m_rbTrackDragFree;
wxCheckBox* m_Show_Page_Limits; wxCheckBox* m_Show_Page_Limits;
wxCheckBox* m_Auto_Refill_Zones; wxCheckBox* m_Auto_Refill_Zones;
wxCheckBox* m_Allow_Free_Pads;
public: public:

View File

@ -753,7 +753,6 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
{ {
// Set the pads ratsnest settings to the global settings // Set the pads ratsnest settings to the global settings
pad->SetLocalRatsnestVisible( pcbframe->GetDisplayOptions().m_ShowGlobalRatsnest ); pad->SetLocalRatsnestVisible( pcbframe->GetDisplayOptions().m_ShowGlobalRatsnest );
pad->SetLocked( !pcbframe->Settings().m_AddUnlockedPads );
// Pads in the library all have orphaned nets. Replace with Default. // Pads in the library all have orphaned nets. Replace with Default.
pad->SetNetCode( 0 ); pad->SetNetCode( 0 );

View File

@ -172,7 +172,6 @@ FOOTPRINT* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent )
{ {
// Set the pads ratsnest settings to the global settings // Set the pads ratsnest settings to the global settings
pad->SetLocalRatsnestVisible( m_frame->GetDisplayOptions().m_ShowGlobalRatsnest ); 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. // Pads in the library all have orphaned nets. Replace with Default.
pad->SetNetCode( 0 ); pad->SetNetCode( 0 );

View File

@ -67,11 +67,11 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
m_TrackDragAction( TRACK_DRAG_ACTION::DRAG ), m_TrackDragAction( TRACK_DRAG_ACTION::DRAG ),
m_Use45DegreeGraphicSegments( false ), m_Use45DegreeGraphicSegments( false ),
m_FlipLeftRight( false ), m_FlipLeftRight( false ),
m_AddUnlockedPads( false ),
m_PolarCoords( false ), m_PolarCoords( false ),
m_RotationAngle( 900 ), m_RotationAngle( 900 ),
m_ShowPageLimits( true ), m_ShowPageLimits( true ),
m_AutoRefillZones( true ), m_AutoRefillZones( true ),
m_AllowFreePads( false ),
m_PnsSettings( nullptr ), m_PnsSettings( nullptr ),
m_FootprintViewerAutoZoom( false ), m_FootprintViewerAutoZoom( false ),
m_FootprintViewerZoom( 1.0 ) m_FootprintViewerZoom( 1.0 )
@ -104,9 +104,6 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
m_params.emplace_back( new PARAM<bool>( "editing.flip_left_right", m_params.emplace_back( new PARAM<bool>( "editing.flip_left_right",
&m_FlipLeftRight, true ) ); &m_FlipLeftRight, true ) );
m_params.emplace_back( new PARAM<bool>( "editing.add_unlocked_pads",
&m_AddUnlockedPads, false ) );
m_params.emplace_back( new PARAM<bool>( "editing.magnetic_graphics", m_params.emplace_back( new PARAM<bool>( "editing.magnetic_graphics",
&m_MagneticItems.graphics, true ) ); &m_MagneticItems.graphics, true ) );
@ -131,6 +128,9 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
m_params.emplace_back( new PARAM<bool>( "editing.auto_fill_zones", m_params.emplace_back( new PARAM<bool>( "editing.auto_fill_zones",
&m_AutoRefillZones, true ) ); &m_AutoRefillZones, true ) );
m_params.emplace_back( new PARAM<bool>( "editing.allow_free_pads",
&m_AllowFreePads, false ) );
m_params.emplace_back( new PARAM<bool>( "pcb_display.graphic_items_fill", m_params.emplace_back( new PARAM<bool>( "pcb_display.graphic_items_fill",
&m_Display.m_DisplayGraphicsFill, true ) ); &m_Display.m_DisplayGraphicsFill, true ) );

View File

@ -281,9 +281,6 @@ public:
bool m_FlipLeftRight; // True: Flip footprints across Y axis bool m_FlipLeftRight; // True: Flip footprints across Y axis
// False: Flip footprints across X axis // False: Flip footprints across X axis
bool m_AddUnlockedPads; // True: Pads are unlocked when new footprints are added to the board
// False: Pads are locked in new footprints
bool m_PolarCoords; bool m_PolarCoords;
int m_RotationAngle; int m_RotationAngle;
@ -293,6 +290,10 @@ public:
///<@todo Implement real auto zone filling (not just after zone properties are edited) ///<@todo Implement real auto zone filling (not just after zone properties are edited)
bool m_AutoRefillZones; // Fill zones after editing the zone using the Zone Properties dialog bool m_AutoRefillZones; // Fill zones after editing the zone using the Zone Properties dialog
bool m_AllowFreePads; // True: unlocked pads can be moved freely with respect to the footprint.
// False (default): all pads are treated as locked for the purposes of
// movement and any attempt to move them will move the footprint instead.
wxString m_FootprintTextShownColumns; wxString m_FootprintTextShownColumns;
std::unique_ptr<PNS::ROUTING_SETTINGS> m_PnsSettings; std::unique_ptr<PNS::ROUTING_SETTINGS> m_PnsSettings;

View File

@ -1022,7 +1022,6 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
for( PAD* pad : fp->Pads() ) for( PAD* pad : fp->Pads() )
{ {
pad->SetLocalRatsnestVisible( m_frame->GetDisplayOptions().m_ShowGlobalRatsnest ); 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. // Pads in the library all have orphaned nets. Replace with Default.
pad->SetNetCode( 0 ); pad->SetNetCode( 0 );

View File

@ -634,7 +634,9 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
// Now filter out locked and grouped items. We cannot do this in the first RequestSelection() // Now filter out locked and grouped items. We cannot do this in the first RequestSelection()
// as we need the item_layers when a pad is the selection front. // as we need the item_layers when a pad is the selection front.
selection = m_selectionTool->RequestSelection( if( frame()->Settings().m_AllowFreePads )
{
selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool ) []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
{ {
std::set<BOARD_ITEM*> to_add; std::set<BOARD_ITEM*> to_add;
@ -642,14 +644,14 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
// Iterate from the back so we don't have to worry about removals. // Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i ) for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{ {
BOARD_ITEM* item = aCollector[ i ]; BOARD_ITEM* item = aCollector[i];
if( item->Type() == PCB_MARKER_T ) if( item->Type() == PCB_MARKER_T )
aCollector.Remove( item ); aCollector.Remove( item );
/// Locked pads do not get moved independently of the footprint // Locked pads do not get moved independently of the footprint
if( !sTool->IsFootprintEditor() && item->Type() == PCB_PAD_T && item->IsLocked() if( !sTool->IsFootprintEditor() && item->Type() == PCB_PAD_T
&& !item->GetParent()->IsLocked() ) && item->IsLocked() )
{ {
if( !aCollector.HasItem( item->GetParent() ) ) if( !aCollector.HasItem( item->GetParent() ) )
to_add.insert( item->GetParent() ); to_add.insert( item->GetParent() );
@ -662,6 +664,39 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
aCollector.Append( item ); aCollector.Append( item );
}, },
!m_isFootprintEditor /* prompt user regarding locked items only in pcb editor*/ ); !m_isFootprintEditor /* prompt user regarding locked items only in pcb editor*/ );
}
else
{
// Unlocked pads are treated as locked if the setting m_AllowFreePads is false
selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector,
PCB_SELECTION_TOOL* sTool )
{
std::set<BOARD_ITEM*> to_add;
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[i];
if( item->Type() == PCB_MARKER_T )
aCollector.Remove( item );
// Treat all pads as locked (i.e. cannot be moved indepenendtly of footprint)
if( !sTool->IsFootprintEditor() && item->Type() == PCB_PAD_T )
{
if( !aCollector.HasItem( item->GetParent() ) )
to_add.insert( item->GetParent() );
aCollector.Remove( item );
}
}
for( BOARD_ITEM* item : to_add )
aCollector.Append( item );
},
!m_isFootprintEditor /* prompt user regarding locked items only in pcb editor*/ );
}
if( selection.Empty() ) if( selection.Empty() )
return 0; return 0;
@ -1835,8 +1870,7 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
aCollector.Remove( item ); aCollector.Remove( item );
// We don't operate on pads; convert them to footprint selections // We don't operate on pads; convert them to footprint selections
if( !sTool->IsFootprintEditor() && item->Type() == PCB_PAD_T if( !sTool->IsFootprintEditor() && item->Type() == PCB_PAD_T )
&& !item->GetParent()->IsLocked() )
{ {
aCollector.Remove( item ); aCollector.Remove( item );