2011-09-29 16:49:40 +00:00
|
|
|
/**
|
|
|
|
* @file hotkeys_module_editor.cpp
|
|
|
|
*/
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <module_editor_frame.h>
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <class_board_design_settings.h>
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <hotkeys.h>
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
/* How to add a new hotkey:
|
|
|
|
* See hotkeys.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
|
|
|
EDA_ITEM* aItem )
|
2011-02-02 19:01:21 +00:00
|
|
|
{
|
|
|
|
if( aHotKey == 0 )
|
2010-11-24 15:10:33 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
bool blockActive = GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE;
|
2011-01-26 07:43:59 +00:00
|
|
|
BOARD_ITEM* item = GetCurItem();
|
2011-12-21 13:42:02 +00:00
|
|
|
bool ItemFree = (item == 0) || (item->GetFlags() == 0);
|
2010-11-24 15:10:33 +00:00
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetEventObject( this );
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
/* Convert lower to upper case (the usual toupper function has problem with non ascii
|
|
|
|
* codes like function keys */
|
2011-02-02 19:01:21 +00:00
|
|
|
if( (aHotKey >= 'a') && (aHotKey <= 'z') )
|
|
|
|
aHotKey += 'A' - 'a';
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY* HK_Descr = GetDescriptorFromHotkey( aHotKey, common_Hotkey_List );
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
if( HK_Descr == NULL )
|
2011-02-02 19:01:21 +00:00
|
|
|
HK_Descr = GetDescriptorFromHotkey( aHotKey, module_edit_Hotkey_List );
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
if( HK_Descr == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch( HK_Descr->m_Idcommand )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case HK_NOT_FOUND:
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case HK_HELP: // Display Current hotkey list
|
2010-11-24 15:10:33 +00:00
|
|
|
DisplayHotkeyList( this, g_Module_Editor_Hokeys_Descr );
|
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case HK_RESET_LOCAL_COORD: // set local (relative) coordinate origin
|
|
|
|
GetScreen()->m_O_Curseur = GetCrossHairPosition();
|
|
|
|
break;
|
|
|
|
|
2014-04-03 07:40:55 +00:00
|
|
|
case HK_LEFT_CLICK:
|
|
|
|
OnLeftClick( aDC, aPosition );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_LEFT_DCLICK: // Simulate a double left click: generate 2 events
|
|
|
|
OnLeftClick( aDC, aPosition );
|
|
|
|
OnLeftDClick( aDC, aPosition );
|
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case HK_SET_GRID_ORIGIN:
|
|
|
|
SetGridOrigin( GetCrossHairPosition() );
|
|
|
|
m_canvas->Refresh();
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-03 16:16:57 +00:00
|
|
|
case HK_RESET_GRID_ORIGIN:
|
|
|
|
SetGridOrigin( wxPoint(0,0) );
|
|
|
|
m_canvas->Refresh();
|
|
|
|
break;
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
case HK_SWITCH_UNITS:
|
2012-02-15 13:10:52 +00:00
|
|
|
cmd.SetId( (g_UserUnit == INCHES) ?
|
|
|
|
ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_IN:
|
|
|
|
cmd.SetId( ID_POPUP_ZOOM_IN );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_OUT:
|
|
|
|
cmd.SetId( ID_POPUP_ZOOM_OUT );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_REDRAW:
|
|
|
|
cmd.SetId( ID_ZOOM_REDRAW );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_CENTER:
|
|
|
|
cmd.SetId( ID_POPUP_ZOOM_CENTER );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_UNDO:
|
|
|
|
case HK_REDO:
|
2011-01-26 07:43:59 +00:00
|
|
|
if( ItemFree && !blockActive )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
2011-08-26 17:01:17 +00:00
|
|
|
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent );
|
2010-11-24 15:10:33 +00:00
|
|
|
wxPostEvent( this, event );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_AUTO:
|
|
|
|
cmd.SetId( ID_ZOOM_PAGE );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_EDIT_ITEM:
|
|
|
|
OnHotkeyEditItem( HK_EDIT_ITEM );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_DELETE:
|
|
|
|
OnHotkeyDeleteItem( HK_DELETE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_MOVE_ITEM:
|
|
|
|
OnHotkeyMoveItem( HK_MOVE_ITEM );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ROTATE_ITEM:
|
|
|
|
OnHotkeyRotateItem( HK_ROTATE_ITEM );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-26 07:43:59 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::OnHotkeyEditItem( int aIdCommand )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM* item = GetCurItem();
|
2011-12-21 13:42:02 +00:00
|
|
|
bool itemCurrentlyEdited = item && item->GetFlags();
|
2012-03-26 23:47:08 +00:00
|
|
|
bool blockActive = GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2011-01-26 07:43:59 +00:00
|
|
|
if( itemCurrentlyEdited || blockActive )
|
2010-11-24 15:10:33 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
item = ModeditLocateAndDisplay();
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
SetCurItem( item );
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
int evt_type = 0; // Used to post a wxCommandEvent on demand
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
2013-03-01 19:59:29 +00:00
|
|
|
evt_type = ID_POPUP_PCB_EDIT_MODULE_PRMS;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_EDIT_PAD;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_EDIT_TEXTMODULE;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2013-09-03 19:37:52 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
|
|
|
evt_type = ID_POPUP_MODEDIT_EDIT_BODY_ITEM;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( evt_type != 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
evt.SetEventObject( this );
|
|
|
|
evt.SetId( evt_type );
|
|
|
|
wxPostEvent( this, evt );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-01-26 07:43:59 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::OnHotkeyDeleteItem( int aIdCommand )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM* item = GetCurItem();
|
2011-12-21 13:42:02 +00:00
|
|
|
bool itemCurrentlyEdited = item && item->GetFlags();
|
2012-03-26 23:47:08 +00:00
|
|
|
bool blockActive = GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2011-01-26 07:43:59 +00:00
|
|
|
if( itemCurrentlyEdited || blockActive )
|
2010-11-24 15:10:33 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
item = ModeditLocateAndDisplay();
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
SetCurItem( item );
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
int evt_type = 0; // Used to post a wxCommandEvent on demand
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_DELETE )
|
|
|
|
evt_type = ID_POPUP_PCB_DELETE_PAD;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_DELETE )
|
|
|
|
evt_type = ID_POPUP_PCB_DELETE_TEXTMODULE;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_DELETE )
|
|
|
|
evt_type = ID_POPUP_PCB_DELETE_EDGE;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( evt_type != 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
evt.SetEventObject( this );
|
|
|
|
evt.SetId( evt_type );
|
|
|
|
wxPostEvent( this, evt );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-01-26 07:43:59 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::OnHotkeyMoveItem( int aIdCommand )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM* item = GetCurItem();
|
2011-12-21 13:42:02 +00:00
|
|
|
bool itemCurrentlyEdited = item && item->GetFlags();
|
2012-03-26 23:47:08 +00:00
|
|
|
bool blockActive = GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2011-01-26 07:43:59 +00:00
|
|
|
if( itemCurrentlyEdited || blockActive )
|
2010-11-24 15:10:33 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
item = ModeditLocateAndDisplay();
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
SetCurItem( item );
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
int evt_type = 0; // Used to post a wxCommandEvent on demand
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_PAD_REQUEST;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_EDGE;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( evt_type != 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
evt.SetEventObject( this );
|
|
|
|
evt.SetId( evt_type );
|
|
|
|
wxPostEvent( this, evt );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-01-26 07:43:59 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM* item = GetCurItem();
|
2011-12-21 13:42:02 +00:00
|
|
|
bool itemCurrentlyEdited = item && item->GetFlags();
|
2011-01-26 07:43:59 +00:00
|
|
|
int evt_type = 0; // Used to post a wxCommandEvent on demand
|
2012-03-26 23:47:08 +00:00
|
|
|
bool blockActive = GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE;
|
2011-01-26 07:43:59 +00:00
|
|
|
|
|
|
|
if( blockActive )
|
|
|
|
return false;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
if( !itemCurrentlyEdited )
|
|
|
|
item = ModeditLocateAndDisplay();
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
SetCurItem( item );
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
|
|
|
evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE;
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( evt_type != 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
evt.SetEventObject( this );
|
|
|
|
evt.SetId( evt_type );
|
|
|
|
wxPostEvent( this, evt );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|