diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 1e07c80bff..ba238b8157 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -157,6 +157,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_MOVE_MODULE_REQUEST: case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST: case ID_POPUP_PCB_MOVE_PCB_TARGET_REQUEST: + case ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES: + case ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE: + case ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES: + case ID_POPUP_PCB_AUTOPLACE_FREE_MODULE: break; case ID_POPUP_CANCEL_CURRENT_COMMAND: @@ -1301,6 +1305,21 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) true, GetCrossHairPosition() ); } break; + case ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE: + LockModule( (MODULE*) GetScreen()->GetCurItem(), true ); + break; + + case ID_POPUP_PCB_AUTOPLACE_FREE_MODULE: + LockModule( (MODULE*) GetScreen()->GetCurItem(), false ); + break; + + case ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES: + LockModule( NULL, false ); + break; + + case ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES: + LockModule( NULL, true ); + break; default: wxString msg; diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 689b8f7b90..4cca8684f5 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -400,6 +400,10 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) _( "Spread out All Footprints" ), KiBitmap( move_xpm ) ); commands->Append( ID_POPUP_PCB_SPREAD_NEW_MODULES, _( "Spread out Footprints not Already on Board" ) ); + AddMenuItem( commands, ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES, + _( "Unlock All Footprints" ), KiBitmap( unlocked_xpm ) ); + AddMenuItem( commands, ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES, + _( "Lock All Footprints" ), KiBitmap( locked_xpm ) ); if( !trackFound ) { @@ -798,6 +802,24 @@ void PCB_EDIT_FRAME::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* menu AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_EXCHANGE_FOOTPRINTS, _( "Change Footprint..." ), KiBitmap( exchange_xpm ) ); } + + sub_menu_footprint->AppendSeparator(); + + if( !aModule->IsLocked() ) + { + msg = AddHotkeyName( _("Lock Footprint" ), g_Board_Editor_Hotkeys_Descr, + HK_LOCK_UNLOCK_FOOTPRINT ); + AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE, msg, + KiBitmap( locked_xpm ) ); + } + else + { + msg = AddHotkeyName( _( "Unlock Footprint" ), g_Board_Editor_Hotkeys_Descr, + HK_LOCK_UNLOCK_FOOTPRINT ); + AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_AUTOPLACE_FREE_MODULE, msg, + KiBitmap( unlocked_xpm ) ); + } + } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 4e8226bd9a..8468e10d23 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -71,6 +71,7 @@ #include #include +#include #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON) #include @@ -274,6 +275,10 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) PCB_EDIT_FRAME::Process_Special_Functions ) EVT_MENU( ID_POPUP_PCB_SPREAD_ALL_MODULES, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_MENU( ID_POPUP_PCB_SPREAD_NEW_MODULES, PCB_EDIT_FRAME::Process_Special_Functions ) + EVT_MENU( ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE, PCB_EDIT_FRAME::Process_Special_Functions ) + EVT_MENU( ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES, PCB_EDIT_FRAME::Process_Special_Functions ) + EVT_MENU( ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES, PCB_EDIT_FRAME::Process_Special_Functions ) + EVT_MENU( ID_POPUP_PCB_AUTOPLACE_FREE_MODULE, PCB_EDIT_FRAME::Process_Special_Functions ) // User interface update event handlers. EVT_UPDATE_UI( ID_SAVE_BOARD, PCB_EDIT_FRAME::OnUpdateSave ) @@ -1376,3 +1381,28 @@ void PCB_EDIT_FRAME::SetIconScale( int aScale ) Layout(); SendSizeEvent(); } + + +void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked ) +{ + const wxString ModulesMaskSelection = wxT( "*" ); + if( aModule ) + { + aModule->SetLocked( aLocked ); + SetMsgPanel( aModule ); + OnModify(); + } + else + { + aModule = GetBoard()->m_Modules; + + for( ; aModule != NULL; aModule = aModule->Next() ) + { + if( WildCompareString( ModulesMaskSelection, aModule->GetReference() ) ) + { + aModule->SetLocked( aLocked ); + OnModify(); + } + } + } +}