Re-enabling lock/unlock context menus in legacy

This partially reverts 36d36de and 3bac100, moving the legacy footprint
lock/unlock code from the autorouter (which remains disabled) to
pcb_edit_frame.
This commit is contained in:
Seth Hillbrand 2018-05-02 09:06:10 -07:00
parent 76d3b6f04a
commit 6b973f42eb
3 changed files with 71 additions and 0 deletions

View File

@ -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;

View File

@ -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 ) );
}
}

View File

@ -71,6 +71,7 @@
#include <tools/pcb_actions.h>
#include <wildcards_and_files_ext.h>
#include <kicad_string.h>
#if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
#include <python_scripting.h>
@ -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();
}
}
}
}