2007-08-03 18:59:14 +00:00
|
|
|
/***************/
|
|
|
|
/* hotkeys.cpp */
|
|
|
|
/***************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2010-08-10 18:34:26 +00:00
|
|
|
#include "module_editor_frame.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "pcbnew_id.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
#include "hotkeys.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "protos.h"
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
/* How to add a new hotkey:
|
|
|
|
* add a new id in the enum hotkey_id_commnand like MY_NEW_ID_FUNCTION.
|
|
|
|
* add a new Ki_HotkeyInfo entry like:
|
|
|
|
* static Ki_HotkeyInfo HkMyNewEntry(wxT("Command Label"), MY_NEW_ID_FUNCTION, default key value);
|
|
|
|
* "Command Label" is the name used in hotkey list display, and the identifier in the hotkey list file
|
|
|
|
* MY_NEW_ID_FUNCTION is an equivalent id function used in the switch in OnHotKey() function.
|
|
|
|
* default key value is the default hotkey for this command. Can be overrided by the user hotkey list file
|
|
|
|
* add the HkMyNewEntry pointer in the s_board_edit_Hotkey_List list ( or/and the s_module_edit_Hotkey_List list)
|
|
|
|
* Add the new code in the switch in OnHotKey() function.
|
2010-08-12 19:41:13 +00:00
|
|
|
* Note: when the variable itemCurrentlyEdited is true, an item is currently edited.
|
|
|
|
* This can be useful if the new function cannot be executed while an item is currently being edited
|
|
|
|
* ( For example, one cannot start a new wire when a component is moving.)
|
2007-08-30 08:15:05 +00:00
|
|
|
*
|
2007-09-06 11:52:26 +00:00
|
|
|
* Note: If an hotkey is a special key, be sure the corresponding wxWidget keycode (WXK_XXXX)
|
2007-08-30 08:15:05 +00:00
|
|
|
* is handled in the hotkey_name_descr s_Hotkey_Name_List list (see hotkeys_basic.cpp)
|
|
|
|
* and see this list for some ascii keys (space ...)
|
|
|
|
*/
|
2007-08-20 10:55:09 +00:00
|
|
|
|
|
|
|
/* local variables */
|
|
|
|
/* Hotkey list: */
|
2009-12-02 09:59:49 +00:00
|
|
|
static Ki_HotkeyInfo HkSwitch2CopperLayer( wxT( "Switch to Copper layer" ),
|
2009-12-08 13:41:20 +00:00
|
|
|
HK_SWITCH_LAYER_TO_COPPER, WXK_PAGEDOWN );
|
2009-12-02 09:59:49 +00:00
|
|
|
static Ki_HotkeyInfo HkSwitch2ComponentLayer( wxT( "Switch to Component layer" ),
|
2009-12-08 13:41:20 +00:00
|
|
|
HK_SWITCH_LAYER_TO_COMPONENT, WXK_PAGEUP );
|
2009-12-02 09:59:49 +00:00
|
|
|
static Ki_HotkeyInfo HkSwitch2InnerLayer1( wxT( "Switch to Inner layer 1" ),
|
|
|
|
HK_SWITCH_LAYER_TO_INNER1, WXK_F5 );
|
|
|
|
static Ki_HotkeyInfo HkSwitch2InnerLayer2( wxT( "Switch to Inner layer 2" ),
|
|
|
|
HK_SWITCH_LAYER_TO_INNER2, WXK_F6 );
|
|
|
|
static Ki_HotkeyInfo HkSwitch2InnerLayer3( wxT( "Switch to Inner layer 3" ),
|
|
|
|
HK_SWITCH_LAYER_TO_INNER3, WXK_F7 );
|
|
|
|
static Ki_HotkeyInfo HkSwitch2InnerLayer4( wxT( "Switch to Inner layer 4" ),
|
|
|
|
HK_SWITCH_LAYER_TO_INNER4, WXK_F8 );
|
|
|
|
static Ki_HotkeyInfo HkSwitch2InnerLayer5( wxT( "Switch to Inner layer 5" ),
|
|
|
|
HK_SWITCH_LAYER_TO_INNER5, WXK_F9 );
|
|
|
|
static Ki_HotkeyInfo HkSwitch2InnerLayer6( wxT( "Switch to Inner layer 6" ),
|
|
|
|
HK_SWITCH_LAYER_TO_INNER6, WXK_F10 );
|
|
|
|
|
|
|
|
static Ki_HotkeyInfo HkSwitch2NextCopperLayer( wxT( "Switch to Next Layer" ),
|
|
|
|
HK_SWITCH_LAYER_TO_NEXT, '+' );
|
|
|
|
static Ki_HotkeyInfo HkSwitch2PreviousCopperLayer( wxT(
|
|
|
|
"Switch to Previous Layer" ),
|
|
|
|
HK_SWITCH_LAYER_TO_PREVIOUS, '-' );
|
|
|
|
|
|
|
|
static Ki_HotkeyInfo HkSavefile( wxT( "Save board" ), HK_SAVE_BOARD, 'S'
|
|
|
|
+ GR_KB_CTRL );
|
|
|
|
static Ki_HotkeyInfo HkLoadfile( wxT( "Load board" ), HK_LOAD_BOARD, 'L'
|
|
|
|
+ GR_KB_CTRL );
|
|
|
|
static Ki_HotkeyInfo HkFindItem( wxT( "Find Item" ), HK_FIND_ITEM, 'F'
|
|
|
|
+ GR_KB_CTRL );
|
|
|
|
static Ki_HotkeyInfo HkBackspace( wxT( "Delete track segment" ), HK_BACK_SPACE,
|
|
|
|
WXK_BACK );
|
2009-12-03 19:11:34 +00:00
|
|
|
static Ki_HotkeyInfo HkAddNewTrack( wxT( "Add new track" ), HK_ADD_NEW_TRACK, 'X' );
|
2009-12-02 09:59:49 +00:00
|
|
|
static Ki_HotkeyInfo HkAddVia( wxT( "Add Via" ), HK_ADD_VIA, 'V' );
|
2010-06-16 15:01:45 +00:00
|
|
|
static Ki_HotkeyInfo HkSwitchTrackPosture( wxT( "Switch Track Posture" ),
|
2010-08-12 19:41:13 +00:00
|
|
|
HK_SWITCH_TRACK_POSTURE, '/' );
|
2009-12-02 09:59:49 +00:00
|
|
|
static Ki_HotkeyInfo HkAddMicroVia( wxT( "Add MicroVia" ), HK_ADD_MICROVIA, 'V'
|
|
|
|
+ GR_KB_CTRL );
|
|
|
|
static Ki_HotkeyInfo HkEndTrack( wxT( "End Track" ), HK_END_TRACK, WXK_END );
|
2010-08-10 18:34:26 +00:00
|
|
|
static Ki_HotkeyInfo HkEditBoardItem( wxT( "Edit Item" ), HK_EDIT_ITEM, 'E' );
|
2009-12-02 09:59:49 +00:00
|
|
|
static Ki_HotkeyInfo HkFlipFootprint( wxT( "Flip Footprint" ), HK_FLIP_FOOTPRINT,
|
|
|
|
'F' );
|
2010-08-12 19:41:13 +00:00
|
|
|
static Ki_HotkeyInfo HkRotateItem( wxT( "Rotate Item" ), HK_ROTATE_ITEM, 'R' );
|
|
|
|
static Ki_HotkeyInfo HkMoveItem( wxT( "Move Item" ), HK_MOVE_ITEM, 'M' );
|
2010-08-17 10:41:44 +00:00
|
|
|
static Ki_HotkeyInfo HkDragFootprint( wxT( "Drag Footprint" ), HK_DRAG_ITEM,
|
2009-12-02 09:59:49 +00:00
|
|
|
'G' );
|
|
|
|
static Ki_HotkeyInfo HkGetAndMoveFootprint( wxT( "Get and Move Footprint" ),
|
|
|
|
HK_GET_AND_MOVE_FOOTPRINT, 'T' );
|
|
|
|
static Ki_HotkeyInfo HkLock_Unlock_Footprint( wxT( "Lock/Unlock Footprint" ),
|
|
|
|
HK_LOCK_UNLOCK_FOOTPRINT, 'L' );
|
2010-08-12 19:41:13 +00:00
|
|
|
static Ki_HotkeyInfo HkDelete( wxT( "Delete Track or Footprint" ), HK_DELETE, WXK_DELETE );
|
2009-12-02 09:59:49 +00:00
|
|
|
static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ),
|
|
|
|
HK_RESET_LOCAL_COORD, ' ' );
|
2010-01-19 20:43:44 +00:00
|
|
|
|
2010-02-16 10:42:57 +00:00
|
|
|
/* Fit on Screen */
|
|
|
|
#if !defined( __WXMAC__ )
|
2009-09-27 14:09:26 +00:00
|
|
|
static Ki_HotkeyInfo HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME );
|
2010-02-16 10:42:57 +00:00
|
|
|
#else
|
|
|
|
static Ki_HotkeyInfo HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, GR_KB_CTRL + '0' );
|
|
|
|
#endif
|
|
|
|
|
2009-12-02 09:59:49 +00:00
|
|
|
static Ki_HotkeyInfo HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
|
2010-02-16 10:42:57 +00:00
|
|
|
|
|
|
|
/* Refresh Screen */
|
|
|
|
#if !defined( __WXMAC__ )
|
2009-12-02 09:59:49 +00:00
|
|
|
static Ki_HotkeyInfo HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 );
|
2010-02-16 10:42:57 +00:00
|
|
|
#else
|
|
|
|
static Ki_HotkeyInfo HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, GR_KB_CTRL + 'R' );
|
|
|
|
#endif
|
2010-01-19 20:43:44 +00:00
|
|
|
|
|
|
|
/* Zoom In */
|
|
|
|
#if !defined( __WXMAC__ )
|
2009-12-02 09:59:49 +00:00
|
|
|
static Ki_HotkeyInfo HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
|
2010-01-19 20:43:44 +00:00
|
|
|
#else
|
|
|
|
static Ki_HotkeyInfo HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, GR_KB_CTRL + '+' );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Zoom Out */
|
|
|
|
#if !defined( __WXMAC__ )
|
|
|
|
static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
|
|
|
|
#else
|
|
|
|
static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, GR_KB_CTRL + '-' );
|
|
|
|
#endif
|
|
|
|
|
2009-12-02 09:59:49 +00:00
|
|
|
static Ki_HotkeyInfo HkHelp( wxT( "Help: this message" ), HK_HELP, '?' );
|
2010-01-19 20:43:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Undo */
|
|
|
|
static Ki_HotkeyInfo HkUndo( wxT( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z',
|
|
|
|
(int) wxID_UNDO );
|
|
|
|
|
|
|
|
/* Redo */
|
|
|
|
#if !defined( __WXMAC__ )
|
|
|
|
static Ki_HotkeyInfo HkRedo( wxT( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y',
|
|
|
|
(int) wxID_REDO );
|
|
|
|
#else
|
|
|
|
static Ki_HotkeyInfo HkRedo( wxT( "Redo" ), HK_REDO,
|
|
|
|
GR_KB_SHIFT + GR_KB_CTRL + 'Z',
|
|
|
|
(int) wxID_REDO );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2009-12-02 09:59:49 +00:00
|
|
|
static Ki_HotkeyInfo HkSwitchUnits( wxT( "Switch Units" ), HK_SWITCH_UNITS, 'U'
|
|
|
|
+ GR_KB_CTRL );
|
|
|
|
static Ki_HotkeyInfo HkTrackDisplayMode( wxT( "Track Display Mode" ),
|
|
|
|
HK_SWITCH_TRACK_DISPLAY_MODE, 'K' );
|
|
|
|
static Ki_HotkeyInfo HkAddModule( wxT( "Add Module" ), HK_ADD_MODULE, 'O' );
|
2007-08-20 10:55:09 +00:00
|
|
|
|
2007-09-10 04:51:01 +00:00
|
|
|
// List of common hotkey descriptors
|
2010-01-19 20:43:44 +00:00
|
|
|
Ki_HotkeyInfo* s_Common_Hotkey_List[] =
|
2009-12-02 09:59:49 +00:00
|
|
|
{
|
|
|
|
&HkHelp, &HkZoomIn, &HkZoomOut,
|
|
|
|
&HkZoomRedraw, &HkZoomCenter, &HkZoomAuto,
|
2010-01-19 20:43:44 +00:00
|
|
|
&HkSwitchUnits, &HkResetLocalCoord,
|
|
|
|
&HkUndo, &HkRedo,
|
|
|
|
NULL
|
2009-12-02 09:59:49 +00:00
|
|
|
};
|
2007-08-20 10:55:09 +00:00
|
|
|
|
|
|
|
// List of hotkey descriptors for pcbnew
|
2009-12-02 09:59:49 +00:00
|
|
|
Ki_HotkeyInfo* s_board_edit_Hotkey_List[] =
|
|
|
|
{
|
|
|
|
&HkTrackDisplayMode, &HkDelete,
|
2009-12-03 12:28:04 +00:00
|
|
|
&HkBackspace,
|
2009-12-08 13:41:20 +00:00
|
|
|
&HkAddNewTrack, &HkAddVia, &HkAddMicroVia,
|
2010-06-16 15:01:45 +00:00
|
|
|
&HkSwitchTrackPosture,
|
2010-08-12 19:41:13 +00:00
|
|
|
&HkEndTrack, &HkMoveItem,
|
|
|
|
&HkFlipFootprint, &HkRotateItem, &HkDragFootprint,
|
2009-12-02 09:59:49 +00:00
|
|
|
&HkGetAndMoveFootprint, &HkLock_Unlock_Footprint, &HkSavefile,
|
2010-08-10 18:34:26 +00:00
|
|
|
&HkLoadfile, &HkFindItem, &HkEditBoardItem,
|
|
|
|
&HkSwitch2CopperLayer, &HkSwitch2InnerLayer1,
|
2009-12-02 09:59:49 +00:00
|
|
|
&HkSwitch2InnerLayer2, &HkSwitch2InnerLayer3, &HkSwitch2InnerLayer4,
|
|
|
|
&HkSwitch2InnerLayer5, &HkSwitch2InnerLayer6, &HkSwitch2ComponentLayer,
|
|
|
|
&HkSwitch2NextCopperLayer, &HkSwitch2PreviousCopperLayer,&HkAddModule,
|
2009-12-03 19:11:34 +00:00
|
|
|
NULL
|
2009-12-02 09:59:49 +00:00
|
|
|
};
|
2007-08-20 10:55:09 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
// List of hotkey descriptors for the module editor
|
2009-06-19 20:13:22 +00:00
|
|
|
Ki_HotkeyInfo* s_module_edit_Hotkey_List[] = { NULL };
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
// list of sections and corresponding hotkey list for pcbnew (used to create an hotkey config file)
|
2009-12-08 13:41:20 +00:00
|
|
|
struct Ki_HotkeyInfoSectionDescriptor s_Pcbnew_Editor_Hokeys_Descr[] =
|
|
|
|
{ {
|
|
|
|
&g_CommonSectionTag, s_Common_Hotkey_List, "Common keys"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&g_BoardEditorSectionTag, s_board_edit_Hotkey_List, "Board editor keys"
|
|
|
|
},{
|
|
|
|
&g_ModuleEditSectionTag, s_module_edit_Hotkey_List, "Footprint editor keys"
|
|
|
|
},{
|
|
|
|
NULL, NULL, NULL
|
|
|
|
} };
|
2007-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
// list of sections and corresponding hotkey list for the board editor (used to list current hotkeys)
|
2009-12-08 13:41:20 +00:00
|
|
|
struct Ki_HotkeyInfoSectionDescriptor s_Board_Editor_Hokeys_Descr[] =
|
|
|
|
{ {
|
2010-01-19 20:43:44 +00:00
|
|
|
&g_CommonSectionTag, s_Common_Hotkey_List,
|
2009-12-08 13:41:20 +00:00
|
|
|
NULL
|
|
|
|
},{
|
|
|
|
&g_BoardEditorSectionTag, s_board_edit_Hotkey_List, NULL
|
|
|
|
},{
|
|
|
|
NULL, NULL, NULL
|
|
|
|
} };
|
2007-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
// list of sections and corresponding hotkey list for the footprint editor (used to list current hotkeys)
|
2010-01-19 20:43:44 +00:00
|
|
|
struct Ki_HotkeyInfoSectionDescriptor s_Module_Editor_Hokeys_Descr[] =
|
2009-12-08 13:41:20 +00:00
|
|
|
{ {
|
|
|
|
&g_CommonSectionTag, s_Common_Hotkey_List, NULL
|
|
|
|
},{
|
|
|
|
&g_ModuleEditSectionTag, s_module_edit_Hotkey_List, NULL
|
|
|
|
},{
|
|
|
|
NULL, NULL, NULL
|
|
|
|
} };
|
2007-09-06 11:52:26 +00:00
|
|
|
|
2010-08-12 19:41:13 +00:00
|
|
|
/** Function OnHotKey.
|
|
|
|
* ** Commands are case insensitive **
|
|
|
|
* Some commands are relatives to the item under the mouse cursor
|
|
|
|
* @param aDC = current device context
|
2007-09-21 03:38:25 +00:00
|
|
|
* @param hotkey = hotkey code (ascii or wxWidget code for special keys)
|
2010-08-12 19:41:13 +00:00
|
|
|
* @param aItem = NULL or pointer on a EDA_BaseStruct under the mouse cursor
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2010-08-12 19:41:13 +00:00
|
|
|
void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_BaseStruct* aItem )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-08-12 19:41:13 +00:00
|
|
|
if( aHotkeyCode == 0 )
|
2009-12-02 09:59:49 +00:00
|
|
|
return;
|
|
|
|
|
2010-08-12 19:41:13 +00:00
|
|
|
bool itemCurrentlyEdited = (GetCurItem() && GetCurItem()->m_Flags);
|
|
|
|
|
2009-12-02 09:59:49 +00:00
|
|
|
MODULE* module = NULL;
|
2010-08-17 10:41:44 +00:00
|
|
|
int evt_type = 0; //Used to post a wxCommandEvent on demand
|
2009-12-02 09:59:49 +00:00
|
|
|
|
2010-01-19 20:43:44 +00:00
|
|
|
/* Convert lower to upper case
|
|
|
|
* (the usual toupper function has problem with non ascii codes like function keys
|
|
|
|
*/
|
2010-08-12 19:41:13 +00:00
|
|
|
if( (aHotkeyCode >= 'a') && (aHotkeyCode <= 'z') )
|
|
|
|
aHotkeyCode += 'A' - 'a';
|
2009-12-02 09:59:49 +00:00
|
|
|
|
2010-08-12 19:41:13 +00:00
|
|
|
Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, s_Common_Hotkey_List );
|
2009-12-02 09:59:49 +00:00
|
|
|
|
|
|
|
if( HK_Descr == NULL )
|
2010-08-12 19:41:13 +00:00
|
|
|
HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, s_board_edit_Hotkey_List );
|
2009-12-02 09:59:49 +00:00
|
|
|
|
|
|
|
if( HK_Descr == NULL )
|
|
|
|
return;
|
|
|
|
|
2010-08-12 19:41:13 +00:00
|
|
|
// Create a wxCommandEvent that will be posted in some hot keys functions
|
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetEventObject( this );
|
|
|
|
|
|
|
|
int ll;
|
2009-12-02 09:59:49 +00:00
|
|
|
|
|
|
|
switch( HK_Descr->m_Idcommand )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case HK_NOT_FOUND:
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_PREVIOUS:
|
2010-02-19 13:23:58 +00:00
|
|
|
ll = getActiveLayer();
|
2009-12-07 03:46:13 +00:00
|
|
|
if( (ll <= LAYER_N_BACK) || (ll > LAYER_N_FRONT) )
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
2009-12-07 03:46:13 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
if( GetBoard()->GetCopperLayerCount() < 2 ) // Single layer
|
2009-12-07 03:46:13 +00:00
|
|
|
ll = LAYER_N_BACK;
|
|
|
|
else if( ll == LAYER_N_FRONT )
|
|
|
|
ll = MAX( LAYER_N_BACK,
|
2010-01-31 20:01:46 +00:00
|
|
|
GetBoard()->GetCopperLayerCount() - 2 );
|
2009-12-02 09:59:49 +00:00
|
|
|
else
|
|
|
|
ll--;
|
2010-08-12 19:41:13 +00:00
|
|
|
SwitchLayer( aDC, ll );
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_NEXT:
|
2010-02-19 13:23:58 +00:00
|
|
|
ll = getActiveLayer();
|
2009-12-07 03:46:13 +00:00
|
|
|
if( (ll < LAYER_N_BACK) || (ll >= LAYER_N_FRONT) )
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
2010-01-31 20:01:46 +00:00
|
|
|
if( GetBoard()->GetCopperLayerCount() < 2 ) // Single layer
|
2009-12-07 03:46:13 +00:00
|
|
|
ll = LAYER_N_BACK;
|
2010-01-31 20:01:46 +00:00
|
|
|
else if( ll >= GetBoard()->GetCopperLayerCount() - 2 )
|
2009-12-07 03:46:13 +00:00
|
|
|
ll = LAYER_N_FRONT;
|
2009-12-02 09:59:49 +00:00
|
|
|
else
|
|
|
|
ll++;
|
2010-08-12 19:41:13 +00:00
|
|
|
SwitchLayer( aDC, ll );
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_COMPONENT:
|
2010-08-12 19:41:13 +00:00
|
|
|
SwitchLayer( aDC, LAYER_N_FRONT );
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_COPPER:
|
2010-08-12 19:41:13 +00:00
|
|
|
SwitchLayer( aDC, LAYER_N_BACK );
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER1:
|
2010-08-12 19:41:13 +00:00
|
|
|
SwitchLayer( aDC, LAYER_N_2 );
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER2:
|
2010-08-12 19:41:13 +00:00
|
|
|
SwitchLayer( aDC, LAYER_N_3 );
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER3:
|
2010-08-12 19:41:13 +00:00
|
|
|
SwitchLayer( aDC, LAYER_N_4 );
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER4:
|
2010-08-12 19:41:13 +00:00
|
|
|
SwitchLayer( aDC, LAYER_N_5 );
|
|
|
|
break;
|
2009-12-02 09:59:49 +00:00
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER5:
|
2010-08-12 19:41:13 +00:00
|
|
|
SwitchLayer( aDC, LAYER_N_6 );
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER6:
|
2010-08-12 19:41:13 +00:00
|
|
|
SwitchLayer( aDC, LAYER_N_7 );
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_HELP: // Display Current hotkey list
|
|
|
|
DisplayHotkeyList( this, s_Board_Editor_Hokeys_Descr );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_IN:
|
2010-08-17 10:41:44 +00:00
|
|
|
evt_type = ID_POPUP_ZOOM_IN;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_OUT:
|
2010-08-17 10:41:44 +00:00
|
|
|
evt_type = ID_POPUP_ZOOM_OUT;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_REDRAW:
|
2010-08-17 10:41:44 +00:00
|
|
|
evt_type = ID_ZOOM_REDRAW;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
case HK_ZOOM_AUTO:
|
|
|
|
evt_type = ID_ZOOM_PAGE;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
case HK_ZOOM_CENTER:
|
|
|
|
evt_type = ID_POPUP_ZOOM_CENTER;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
case HK_ADD_MODULE:
|
|
|
|
evt_type = ID_COMPONENT_BUTT;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-01-19 20:43:44 +00:00
|
|
|
case HK_UNDO:
|
|
|
|
case HK_REDO:
|
2010-08-12 19:41:13 +00:00
|
|
|
if( !itemCurrentlyEdited )
|
2010-01-19 20:43:44 +00:00
|
|
|
{
|
|
|
|
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED,
|
|
|
|
HK_Descr->m_IdMenuEvent );
|
|
|
|
wxPostEvent( this, event );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-12-02 09:59:49 +00:00
|
|
|
case HK_RESET_LOCAL_COORD: /*Reset the relative coord */
|
|
|
|
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_UNITS:
|
2010-07-12 14:07:09 +00:00
|
|
|
g_UserUnit = (g_UserUnit == INCHES) ? MILLIMETRES : INCHES;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_TRACK_DISPLAY_MODE:
|
|
|
|
DisplayOpt.DisplayPcbTrackFill ^= 1;
|
|
|
|
DisplayOpt.DisplayPcbTrackFill &= 1;
|
|
|
|
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
|
2010-02-19 13:23:58 +00:00
|
|
|
DrawPanel->Refresh();
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_DELETE:
|
2010-08-12 19:41:13 +00:00
|
|
|
OnHotkeyDeleteItem( aDC );
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_BACK_SPACE:
|
2010-08-17 10:41:44 +00:00
|
|
|
if( m_ID_current_state == ID_TRACK_BUTT && (getActiveLayer() <= LAYER_N_FRONT) )
|
2009-12-02 09:59:49 +00:00
|
|
|
{
|
2010-08-12 19:41:13 +00:00
|
|
|
if( !itemCurrentlyEdited )
|
2009-12-02 09:59:49 +00:00
|
|
|
{
|
|
|
|
// no track is currently being edited - select a segment and remove it.
|
2010-08-17 10:41:44 +00:00
|
|
|
// @todo: possibly? pass the HK command code to PcbGeneralLocateAndDisplay()
|
|
|
|
// so it can restrict its search to specific item types.
|
2010-08-12 19:41:13 +00:00
|
|
|
aItem = PcbGeneralLocateAndDisplay();
|
2009-12-02 09:59:49 +00:00
|
|
|
|
|
|
|
// don't let backspace delete modules!!
|
2010-08-12 19:41:13 +00:00
|
|
|
if( aItem && (aItem->Type() == TYPE_TRACK
|
|
|
|
|| aItem->Type() == TYPE_VIA) )
|
2009-12-02 09:59:49 +00:00
|
|
|
{
|
2010-08-12 19:41:13 +00:00
|
|
|
Delete_Segment( aDC, (TRACK*) aItem );
|
2009-12-02 09:59:49 +00:00
|
|
|
SetCurItem( NULL );
|
|
|
|
}
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2009-12-02 09:59:49 +00:00
|
|
|
}
|
|
|
|
else if( GetCurItem()->Type() == TYPE_TRACK )
|
|
|
|
{
|
|
|
|
// then an element is being edited - remove the last segment.
|
|
|
|
// simple lines for debugger:
|
|
|
|
TRACK* track = (TRACK*) GetCurItem();
|
2010-08-12 19:41:13 +00:00
|
|
|
track = Delete_Segment( aDC, track );
|
2009-12-02 09:59:49 +00:00
|
|
|
SetCurItem( track );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2009-12-02 09:59:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_END_TRACK:
|
2010-08-12 19:41:13 +00:00
|
|
|
if( itemCurrentlyEdited && (GetCurItem()->Type() == TYPE_TRACK)
|
2009-12-02 09:59:49 +00:00
|
|
|
&& ( (GetCurItem()->m_Flags & IS_NEW) != 0 ) )
|
|
|
|
{
|
|
|
|
// A new track is in progress: call to End_Route()
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2010-08-12 19:41:13 +00:00
|
|
|
End_Route( (TRACK*) GetCurItem(), aDC );
|
2009-12-02 09:59:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_GET_AND_MOVE_FOOTPRINT:
|
2010-08-12 19:41:13 +00:00
|
|
|
if( !itemCurrentlyEdited )
|
2010-08-17 10:41:44 +00:00
|
|
|
evt_type = ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_FIND_ITEM:
|
2010-08-12 19:41:13 +00:00
|
|
|
if( !itemCurrentlyEdited )
|
2010-08-17 10:41:44 +00:00
|
|
|
evt_type = ID_FIND_ITEMS;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_LOAD_BOARD:
|
2010-08-12 19:41:13 +00:00
|
|
|
if( !itemCurrentlyEdited )
|
2010-08-17 10:41:44 +00:00
|
|
|
evt_type = ID_LOAD_FILE ;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SAVE_BOARD:
|
2010-08-12 19:41:13 +00:00
|
|
|
if( !itemCurrentlyEdited )
|
2010-08-17 10:41:44 +00:00
|
|
|
evt_type = ID_SAVE_BOARD;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ADD_MICROVIA: // Place a micro via if a track is in progress
|
|
|
|
if( m_ID_current_state != ID_TRACK_BUTT )
|
|
|
|
return;
|
2010-08-12 19:41:13 +00:00
|
|
|
if( !itemCurrentlyEdited ) // no track in progress: nothing to do
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
2010-08-12 19:41:13 +00:00
|
|
|
if( GetCurItem()->Type() != TYPE_TRACK ) // Should not occur
|
2009-12-02 09:59:49 +00:00
|
|
|
return;
|
|
|
|
if( (GetCurItem()->m_Flags & IS_NEW) == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// place micro via and switch layer
|
2010-01-31 20:01:46 +00:00
|
|
|
if( IsMicroViaAcceptable() )
|
2010-08-17 10:41:44 +00:00
|
|
|
evt_type = ID_POPUP_PCB_PLACE_MICROVIA;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ADD_VIA: // Switch to alternate layer and Place a via if a track is in progress
|
|
|
|
if( m_ID_current_state != ID_TRACK_BUTT )
|
|
|
|
return;
|
2010-08-12 19:41:13 +00:00
|
|
|
if( !itemCurrentlyEdited ) // no track in progress: switch layer only
|
2009-12-02 09:59:49 +00:00
|
|
|
{
|
2010-08-12 19:41:13 +00:00
|
|
|
Other_Layer_Route( NULL, aDC );
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if( GetCurItem()->Type() != TYPE_TRACK )
|
|
|
|
return;
|
|
|
|
if( (GetCurItem()->m_Flags & IS_NEW) == 0 )
|
|
|
|
return;
|
2010-08-17 10:41:44 +00:00
|
|
|
evt_type = ID_POPUP_PCB_PLACE_VIA;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-07-11 16:24:44 +00:00
|
|
|
case HK_SWITCH_TRACK_POSTURE:
|
|
|
|
/* change the position of initial segment when creating new tracks
|
|
|
|
* switch from _/ to -\ .
|
|
|
|
*/
|
2010-08-17 10:41:44 +00:00
|
|
|
evt_type = ID_POPUP_PCB_SWITCH_TRACK_POSTURE ;
|
2010-06-16 15:01:45 +00:00
|
|
|
break;
|
|
|
|
|
2009-12-03 12:28:04 +00:00
|
|
|
case HK_ADD_NEW_TRACK: // Start new track
|
2010-02-19 13:23:58 +00:00
|
|
|
if( getActiveLayer() > LAYER_N_FRONT )
|
2009-12-03 19:11:34 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-12 19:41:13 +00:00
|
|
|
if( m_ID_current_state != ID_TRACK_BUTT && !itemCurrentlyEdited )
|
2009-12-03 12:28:04 +00:00
|
|
|
{
|
2009-12-03 19:11:34 +00:00
|
|
|
cmd.SetId( ID_TRACK_BUTT );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_ID_current_state != ID_TRACK_BUTT )
|
|
|
|
break;
|
2009-12-07 03:46:13 +00:00
|
|
|
|
2010-08-12 19:41:13 +00:00
|
|
|
if( !itemCurrentlyEdited ) // no track in progress:
|
2009-12-08 13:41:20 +00:00
|
|
|
{
|
2010-08-12 19:41:13 +00:00
|
|
|
TRACK* track = Begin_Route( NULL, aDC );
|
2009-12-08 13:41:20 +00:00
|
|
|
SetCurItem( track );
|
|
|
|
if( track )
|
2009-12-03 12:28:04 +00:00
|
|
|
DrawPanel->m_AutoPAN_Request = true;
|
2009-12-08 13:41:20 +00:00
|
|
|
}
|
|
|
|
else if( GetCurItem()->m_Flags & IS_NEW )
|
|
|
|
{
|
2010-08-12 19:41:13 +00:00
|
|
|
TRACK* track = Begin_Route( (TRACK*) GetCurItem(), aDC );
|
2009-12-08 13:41:20 +00:00
|
|
|
|
|
|
|
// SetCurItem() must not write to the msg panel
|
|
|
|
// because a track info is displayed while moving the mouse cursor
|
|
|
|
if( track ) // A new segment was created
|
|
|
|
SetCurItem( track, false );
|
|
|
|
DrawPanel->m_AutoPAN_Request = true;
|
|
|
|
}
|
2009-12-03 12:28:04 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-10 18:34:26 +00:00
|
|
|
case HK_EDIT_ITEM: // Edit board item
|
2010-08-12 19:41:13 +00:00
|
|
|
if( !itemCurrentlyEdited )
|
2010-08-10 18:34:26 +00:00
|
|
|
{
|
2010-08-12 19:41:13 +00:00
|
|
|
BOARD_ITEM* item = PcbGeneralLocateAndDisplay();
|
|
|
|
if( item == NULL )
|
2010-08-10 18:34:26 +00:00
|
|
|
break;
|
2010-08-12 19:41:13 +00:00
|
|
|
|
2010-08-10 18:34:26 +00:00
|
|
|
//An item is found, and some can be edited:
|
2010-08-12 19:41:13 +00:00
|
|
|
OnEditItemRequest( aDC, item );
|
2010-08-10 18:34:26 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-12-02 09:59:49 +00:00
|
|
|
// Footprint edition:
|
|
|
|
case HK_LOCK_UNLOCK_FOOTPRINT: // toggle module "MODULE_is_LOCKED" status:
|
|
|
|
// get any module, locked or not locked and toggle its locked status
|
2010-08-12 19:41:13 +00:00
|
|
|
if( !itemCurrentlyEdited )
|
2009-12-02 09:59:49 +00:00
|
|
|
module = Locate_Prefered_Module( GetBoard(), CURSEUR_OFF_GRILLE
|
|
|
|
| VISIBLE_ONLY );
|
|
|
|
else if( GetCurItem()->Type() == TYPE_MODULE )
|
|
|
|
module = (MODULE*) GetCurItem();
|
|
|
|
if( module )
|
|
|
|
{
|
|
|
|
SetCurItem( module );
|
|
|
|
module->SetLocked( !module->IsLocked() );
|
|
|
|
module->DisplayInfo( this );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
case HK_DRAG_ITEM: // Start drag module or track segment
|
|
|
|
OnHotkeyMoveItem( HK_DRAG_ITEM );
|
2010-08-12 19:41:13 +00:00
|
|
|
break;
|
2009-12-02 09:59:49 +00:00
|
|
|
|
2010-08-12 19:41:13 +00:00
|
|
|
case HK_MOVE_ITEM: // Start move item
|
2010-08-17 10:41:44 +00:00
|
|
|
OnHotkeyMoveItem( HK_MOVE_ITEM );
|
2010-08-12 19:41:13 +00:00
|
|
|
break;
|
2009-12-02 09:59:49 +00:00
|
|
|
|
2010-08-12 19:41:13 +00:00
|
|
|
case HK_ROTATE_ITEM: // Rotation
|
2010-08-17 10:41:44 +00:00
|
|
|
OnHotkeyRotateItem( HK_ROTATE_ITEM );
|
2010-08-12 19:41:13 +00:00
|
|
|
break;
|
2009-12-02 09:59:49 +00:00
|
|
|
|
2010-08-12 19:41:13 +00:00
|
|
|
case HK_FLIP_FOOTPRINT: // move to other side
|
2010-08-17 10:41:44 +00:00
|
|
|
OnHotkeyRotateItem( HK_FLIP_FOOTPRINT );
|
2010-08-12 19:41:13 +00:00
|
|
|
break;
|
2009-12-02 09:59:49 +00:00
|
|
|
}
|
2010-08-17 10:41:44 +00:00
|
|
|
|
|
|
|
if( evt_type != 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
evt.SetEventObject( this );
|
|
|
|
evt.SetId( evt_type );
|
|
|
|
wxPostEvent( this, evt );
|
|
|
|
}
|
2007-06-15 16:08:55 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-12-02 09:59:49 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************/
|
2010-08-12 19:41:13 +00:00
|
|
|
void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int hotkey,
|
2009-12-02 09:59:49 +00:00
|
|
|
EDA_BaseStruct* DrawStruct )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************/
|
2007-08-03 18:59:14 +00:00
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
/* Hot keys. Some commands are relative to the item under the mouse cursor
|
|
|
|
* Commands are case insensitive
|
2007-08-03 18:59:14 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-12-02 09:59:49 +00:00
|
|
|
if( hotkey == 0 )
|
|
|
|
return;
|
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
BOARD_ITEM* item = GetCurItem();
|
|
|
|
bool ItemFree = (item == 0) || (item->m_Flags == 0);
|
2009-12-02 09:59:49 +00:00
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetEventObject( this );
|
|
|
|
|
|
|
|
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
|
|
|
|
if( (hotkey >= 'a') && (hotkey <= 'z') )
|
|
|
|
hotkey += 'A' - 'a';
|
|
|
|
|
2010-01-19 20:43:44 +00:00
|
|
|
Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( hotkey, s_Common_Hotkey_List );
|
|
|
|
|
2009-12-02 09:59:49 +00:00
|
|
|
if( HK_Descr == NULL )
|
|
|
|
HK_Descr = GetDescriptorFromHotkey( hotkey, s_module_edit_Hotkey_List );
|
2010-01-19 20:43:44 +00:00
|
|
|
|
2009-12-02 09:59:49 +00:00
|
|
|
if( HK_Descr == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch( HK_Descr->m_Idcommand )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case HK_NOT_FOUND:
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_HELP: // Display Current hotkey list
|
|
|
|
DisplayHotkeyList( this, s_Module_Editor_Hokeys_Descr );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RESET_LOCAL_COORD: /*Reset the relative coord */
|
|
|
|
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_UNITS:
|
2010-07-12 14:07:09 +00:00
|
|
|
g_UserUnit = (g_UserUnit == INCHES) ? MILLIMETRES : INCHES;
|
2009-12-02 09:59:49 +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;
|
|
|
|
|
2010-01-19 20:43:44 +00:00
|
|
|
case HK_UNDO:
|
|
|
|
case HK_REDO:
|
|
|
|
if( ItemFree )
|
|
|
|
{
|
|
|
|
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED,
|
|
|
|
HK_Descr->m_IdMenuEvent );
|
|
|
|
wxPostEvent( this, event );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-12-02 09:59:49 +00:00
|
|
|
case HK_ZOOM_AUTO:
|
|
|
|
cmd.SetId( ID_ZOOM_PAGE );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-12-02 09:59:49 +00:00
|
|
|
|
2010-08-12 19:41:13 +00:00
|
|
|
/** Function OnHotkeyDeleteItem
|
|
|
|
* Delete the item found under the mouse cursor
|
2007-09-06 11:52:26 +00:00
|
|
|
* Depending on the current active tool::
|
|
|
|
* Tool track
|
|
|
|
* if a track is in progress: Delete the last segment
|
|
|
|
* else delete the entire track
|
|
|
|
* Tool module (footprint):
|
|
|
|
* Delete the module.
|
2010-08-12 19:41:13 +00:00
|
|
|
* @param aDC = current device context
|
|
|
|
* @return true if an item was deleted
|
2007-08-03 18:59:14 +00:00
|
|
|
*/
|
2010-08-12 19:41:13 +00:00
|
|
|
bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* aDC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-08-17 10:41:44 +00:00
|
|
|
BOARD_ITEM* item = GetCurItem();
|
|
|
|
bool ItemFree = (item == NULL) || (item->m_Flags == 0);
|
2009-12-02 09:59:49 +00:00
|
|
|
|
|
|
|
switch( m_ID_current_state )
|
|
|
|
{
|
|
|
|
case ID_TRACK_BUTT:
|
2010-02-19 13:23:58 +00:00
|
|
|
if( getActiveLayer() > LAYER_N_FRONT )
|
2010-08-12 19:41:13 +00:00
|
|
|
return false;
|
2009-12-02 09:59:49 +00:00
|
|
|
if( ItemFree )
|
|
|
|
{
|
2010-08-17 10:41:44 +00:00
|
|
|
item = PcbGeneralLocateAndDisplay();
|
|
|
|
if( item && item->Type() != TYPE_TRACK )
|
2010-08-12 19:41:13 +00:00
|
|
|
return false;
|
2010-08-17 10:41:44 +00:00
|
|
|
Delete_Track( aDC, (TRACK*) item );
|
2009-12-02 09:59:49 +00:00
|
|
|
}
|
2010-08-17 10:41:44 +00:00
|
|
|
else if( item->Type() == TYPE_TRACK )
|
2009-12-02 09:59:49 +00:00
|
|
|
{
|
|
|
|
// simple lines for debugger:
|
2010-08-17 10:41:44 +00:00
|
|
|
TRACK* track = (TRACK*) item;
|
2010-08-12 19:41:13 +00:00
|
|
|
track = Delete_Segment( aDC, track );
|
2009-12-02 09:59:49 +00:00
|
|
|
SetCurItem( track );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2010-08-12 19:41:13 +00:00
|
|
|
return true;
|
2009-12-02 09:59:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_COMPONENT_BUTT:
|
|
|
|
if( ItemFree )
|
|
|
|
{
|
|
|
|
MODULE* module = Locate_Prefered_Module( GetBoard(),
|
|
|
|
CURSEUR_ON_GRILLE );
|
|
|
|
if( module == NULL )
|
2010-08-12 19:41:13 +00:00
|
|
|
return false;
|
2009-12-02 09:59:49 +00:00
|
|
|
if( !IsOK( this, _( "Delete module?" ) ) )
|
2010-08-12 19:41:13 +00:00
|
|
|
return false;
|
|
|
|
RemoveStruct( module, aDC );
|
2009-12-02 09:59:49 +00:00
|
|
|
}
|
|
|
|
else
|
2010-08-12 19:41:13 +00:00
|
|
|
return false;
|
2009-12-02 09:59:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-08-12 19:41:13 +00:00
|
|
|
return false;
|
2009-12-02 09:59:49 +00:00
|
|
|
}
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2009-12-02 09:59:49 +00:00
|
|
|
SetCurItem( NULL );
|
2010-08-12 19:41:13 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Function OnHotkeyMoveItem
|
2010-08-17 10:41:44 +00:00
|
|
|
* Move or drag the item (footprint, track, text .. ) found under the mouse cursor
|
|
|
|
* An item can be moved (or dragged) only if there is no item currently edited
|
|
|
|
* Only a footprint, a pad or a track can be dragged
|
2010-08-12 19:41:13 +00:00
|
|
|
* @param aIdCommand = the hotkey command id
|
|
|
|
* @return true if an item was moved
|
|
|
|
*/
|
2010-08-17 10:41:44 +00:00
|
|
|
bool WinEDA_PcbFrame::OnHotkeyMoveItem( int aIdCommand )
|
2010-08-12 19:41:13 +00:00
|
|
|
{
|
2010-08-17 10:41:44 +00:00
|
|
|
BOARD_ITEM* item = GetCurItem();
|
|
|
|
bool itemCurrentlyEdited = item && item->m_Flags;
|
2010-08-12 19:41:13 +00:00
|
|
|
|
|
|
|
if( itemCurrentlyEdited )
|
|
|
|
return false;
|
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
item = PcbGeneralLocateAndDisplay();
|
2010-08-12 19:41:13 +00:00
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
SetCurItem( item );
|
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
int evt_type = 0; //Used to post a wxCommandEvent on demand
|
|
|
|
|
2010-08-12 19:41:13 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case TYPE_TRACK:
|
|
|
|
case TYPE_VIA:
|
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
2010-08-17 10:41:44 +00:00
|
|
|
evt_type = ID_POPUP_PCB_MOVE_TRACK_NODE;
|
|
|
|
if( aIdCommand == HK_DRAG_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_DRAG_TRACK_SEGMENT;
|
2010-08-12 19:41:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPE_MODULE:
|
|
|
|
{
|
|
|
|
MODULE* module = (MODULE*) item;
|
|
|
|
|
|
|
|
// a footprint is found, but locked or on an other layer
|
|
|
|
if( module->IsLocked() )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Footprint %s found, but locked" ),
|
|
|
|
module->m_Reference->m_Text.GetData() );
|
|
|
|
DisplayInfoMessage( this, msg );
|
|
|
|
break;
|
|
|
|
}
|
2010-08-17 10:41:44 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_MODULE_REQUEST;
|
|
|
|
if( aIdCommand == HK_DRAG_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_DRAG_MODULE_REQUEST;
|
|
|
|
}
|
|
|
|
break;
|
2010-08-12 19:41:13 +00:00
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
case TYPE_PAD:
|
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_PAD_REQUEST;
|
|
|
|
if( aIdCommand == HK_DRAG_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_DRAG_PAD_REQUEST;
|
|
|
|
break;
|
2010-08-12 19:41:13 +00:00
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
case TYPE_TEXTE:
|
2010-08-17 17:45:45 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST;
|
2010-08-17 10:41:44 +00:00
|
|
|
break;
|
2010-08-12 19:41:13 +00:00
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
case TYPE_MIRE:
|
2010-08-17 17:45:45 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_MIRE_REQUEST;
|
2010-08-17 10:41:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPE_ZONE_CONTAINER:
|
2010-08-17 17:45:45 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_ZONE_OUTLINES;
|
|
|
|
if( aIdCommand == HK_DRAG_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_DRAG_ZONE_OUTLINE_SEGMENT;
|
2010-08-17 10:41:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPE_TEXTE_MODULE:
|
2010-08-17 17:45:45 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST;
|
2010-08-17 10:41:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPE_DRAWSEGMENT:
|
2010-08-17 17:45:45 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_DRAWING_REQUEST;
|
2010-08-17 10:41:44 +00:00
|
|
|
break;
|
2010-08-12 19:41:13 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
if( evt_type != 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
evt.SetEventObject( this );
|
|
|
|
evt.SetId( evt_type );
|
|
|
|
wxPostEvent( this, evt );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-12 19:41:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Function OnHotkeyRotateItem
|
|
|
|
* Rotate the item (text or footprint) found under the mouse cursor
|
2010-08-17 10:41:44 +00:00
|
|
|
* Note:
|
|
|
|
* this command can be used with an item currently in edit
|
|
|
|
* Only some items can be rotated (footprints and texts)
|
2010-08-12 19:41:13 +00:00
|
|
|
* @param aIdCommand = the hotkey command id
|
|
|
|
* @return true if an item was moved
|
|
|
|
*/
|
2010-08-17 10:41:44 +00:00
|
|
|
bool WinEDA_PcbFrame::OnHotkeyRotateItem( int aIdCommand )
|
2010-08-12 19:41:13 +00:00
|
|
|
{
|
2010-08-17 10:41:44 +00:00
|
|
|
BOARD_ITEM* item = GetCurItem();
|
|
|
|
bool itemCurrentlyEdited = item && item->m_Flags;
|
|
|
|
int evt_type = 0; // Used to post a wxCommandEvent on demand
|
2010-08-12 19:41:13 +00:00
|
|
|
|
|
|
|
if( !itemCurrentlyEdited )
|
2010-08-17 10:41:44 +00:00
|
|
|
item = PcbGeneralLocateAndDisplay();
|
2010-08-12 19:41:13 +00:00
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
if( item == NULL )
|
2010-08-12 19:41:13 +00:00
|
|
|
return false;
|
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
SetCurItem( item );
|
|
|
|
|
|
|
|
switch( item->Type() )
|
2010-08-12 19:41:13 +00:00
|
|
|
{
|
2010-08-17 10:41:44 +00:00
|
|
|
case TYPE_MODULE:
|
|
|
|
{
|
|
|
|
MODULE* module = (MODULE*) item;
|
|
|
|
if( module->IsLocked() )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Footprint %s is locked" ),
|
|
|
|
module->m_Reference->m_Text.GetData() );
|
|
|
|
DisplayInfoMessage( this, msg );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
|
|
|
evt_type = ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE;
|
|
|
|
if( aIdCommand == HK_FLIP_FOOTPRINT ) // move to other side
|
|
|
|
evt_type = ID_POPUP_PCB_CHANGE_SIDE_MODULE;
|
2010-08-12 19:41:13 +00:00
|
|
|
}
|
2010-08-17 10:41:44 +00:00
|
|
|
break;
|
2010-08-12 19:41:13 +00:00
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
case TYPE_TEXTE:
|
2010-08-17 17:45:45 +00:00
|
|
|
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
|
|
|
evt_type = ID_POPUP_PCB_ROTATE_TEXTEPCB;
|
2010-08-17 10:41:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPE_TEXTE_MODULE:
|
2010-08-17 17:45:45 +00:00
|
|
|
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
|
|
|
evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE;
|
2010-08-12 19:41:13 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
default:
|
2010-08-12 19:41:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
if( evt_type != 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
evt.SetEventObject( this );
|
|
|
|
evt.SetId( evt_type );
|
|
|
|
wxPostEvent( this, evt );
|
|
|
|
return true;
|
|
|
|
}
|
2010-08-12 19:41:13 +00:00
|
|
|
|
2010-08-17 10:41:44 +00:00
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|