2007-08-03 18:59:14 +00:00
|
|
|
/***************/
|
|
|
|
/* hotkeys.cpp */
|
|
|
|
/***************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "pcbnew.h"
|
|
|
|
#include "id.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
/* Routines locales */
|
|
|
|
|
|
|
|
/* variables externes */
|
|
|
|
|
|
|
|
/***********************************************************/
|
2007-08-03 18:59:14 +00:00
|
|
|
void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
|
|
|
|
EDA_BaseStruct* DrawStruct )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************/
|
2007-08-03 18:59:14 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Gestion des commandes rapides (Raccourcis claviers) concernant l'element
|
2007-08-03 18:59:14 +00:00
|
|
|
* sous le courseur souris
|
|
|
|
* Les majuscules/minuscules sont indifferenciees
|
|
|
|
* touche DELETE: Effacement (Module ou piste selon commande en cours)
|
|
|
|
* touche V: Place via en cours de trace de piste
|
|
|
|
* touche R: Rotation module
|
|
|
|
* touche S: Change couche module (Composant <-> Cuivre)
|
|
|
|
* touche M: Start Move module
|
|
|
|
* touche G: Start Drag module
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-03 18:59:14 +00:00
|
|
|
bool PopupOn = GetScreen()->m_CurrentItem
|
|
|
|
&& GetScreen()->m_CurrentItem->m_Flags;
|
2007-08-04 20:05:54 +00:00
|
|
|
|
2007-08-03 18:59:14 +00:00
|
|
|
bool ItemFree = (GetScreen()->m_CurrentItem == 0 )
|
|
|
|
|| (GetScreen()->m_CurrentItem->m_Flags == 0);
|
2007-06-15 16:08:55 +00:00
|
|
|
|
2007-08-03 18:59:14 +00:00
|
|
|
if( hotkey == 0 )
|
|
|
|
return;
|
2007-06-15 16:08:55 +00:00
|
|
|
|
2007-08-03 18:59:14 +00:00
|
|
|
// code Ctrl A = 1, Ctr B = 2 ..., remapped, (more easy to understand in switch)
|
|
|
|
if( hotkey & GR_KB_CTRL )
|
|
|
|
hotkey += 'A' - 1;
|
2007-06-26 10:42:11 +00:00
|
|
|
|
2007-06-15 16:08:55 +00:00
|
|
|
MODULE* module = NULL;
|
|
|
|
|
2007-08-03 18:59:14 +00:00
|
|
|
if( hotkey <= 0xFF )
|
|
|
|
hotkey = toupper( hotkey );
|
|
|
|
|
|
|
|
switch( hotkey )
|
|
|
|
{
|
|
|
|
case WXK_DELETE:
|
|
|
|
case WXK_NUMPAD_DELETE:
|
|
|
|
OnHotkeyDeleteItem( DC, DrawStruct );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_BACK:
|
|
|
|
if( m_ID_current_state == ID_TRACK_BUTT && GetScreen()->m_Active_Layer <= CMP_N )
|
|
|
|
{
|
|
|
|
bool ItemFree = (GetScreen()->m_CurrentItem == NULL )
|
|
|
|
|| (GetScreen()->m_CurrentItem->m_Flags == 0);
|
|
|
|
if( ItemFree )
|
|
|
|
{
|
2007-08-04 20:05:54 +00:00
|
|
|
// no track is currently being edited - select a segment and remove it.
|
2007-08-03 18:59:14 +00:00
|
|
|
DrawStruct = PcbGeneralLocateAndDisplay();
|
|
|
|
|
2007-08-04 20:05:54 +00:00
|
|
|
// don't let backspace delete modules!!
|
2007-08-03 18:59:14 +00:00
|
|
|
if( DrawStruct && (DrawStruct->m_StructType == TYPETRACK
|
|
|
|
|| DrawStruct->m_StructType == TYPEVIA) )
|
|
|
|
Delete_Segment( DC, (TRACK*) DrawStruct );
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
|
|
|
else if( GetScreen()->m_CurrentItem->m_StructType == TYPETRACK )
|
|
|
|
{
|
2007-08-04 20:05:54 +00:00
|
|
|
// then an element is being edited - remove the last segment.
|
2007-08-03 18:59:14 +00:00
|
|
|
GetScreen()->m_CurrentItem =
|
|
|
|
Delete_Segment( DC, (TRACK*) GetScreen()->m_CurrentItem );
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_END:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
End_Route( (TRACK*) (GetScreen()->m_CurrentItem), DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'F' + GR_KB_CTRL:
|
|
|
|
{
|
|
|
|
wxCommandEvent evt;
|
|
|
|
evt.SetId( ID_FIND_ITEMS );
|
|
|
|
Process_Special_Functions( evt );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'O' + GR_KB_CTRL:
|
|
|
|
{
|
2007-08-04 20:05:54 +00:00
|
|
|
// try not to duplicate save, load code etc.
|
2007-08-03 18:59:14 +00:00
|
|
|
wxCommandEvent evt;
|
|
|
|
evt.SetId( ID_LOAD_FILE );
|
|
|
|
Files_io( evt );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'S' + GR_KB_CTRL:
|
2007-06-15 16:08:55 +00:00
|
|
|
{
|
2007-08-04 20:05:54 +00:00
|
|
|
// try not to duplicate save, load code etc.
|
2007-08-03 18:59:14 +00:00
|
|
|
wxCommandEvent evt;
|
|
|
|
evt.SetId( ID_SAVE_BOARD );
|
|
|
|
Files_io( evt );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'V': // Switch to alternate layer and Place a via if a track is in progress
|
|
|
|
if( m_ID_current_state != ID_TRACK_BUTT )
|
|
|
|
return;
|
|
|
|
if( ItemFree )
|
|
|
|
{
|
|
|
|
Other_Layer_Route( NULL, DC );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if( GetScreen()->m_CurrentItem->m_StructType != TYPETRACK )
|
|
|
|
return;
|
|
|
|
if( (GetScreen()->m_CurrentItem->m_Flags & IS_NEW) == 0 )
|
|
|
|
return;
|
|
|
|
Other_Layer_Route( (TRACK*) GetScreen()->m_CurrentItem, DC );
|
|
|
|
if( DisplayOpt.ContrastModeDisplay )
|
|
|
|
GetScreen()->SetRefreshReq();
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Footprint edition:
|
|
|
|
case 'L': // toggle module "MODULE_is_LOCKED" status:
|
|
|
|
// get any module, locked or not locked and toggle its locked status
|
|
|
|
if( ItemFree )
|
|
|
|
module = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE | VISIBLE_ONLY );
|
|
|
|
else if( GetScreen()->m_CurrentItem->m_StructType == TYPEMODULE )
|
|
|
|
module = (MODULE*) GetScreen()->m_CurrentItem;
|
|
|
|
if( module )
|
|
|
|
{
|
|
|
|
GetScreen()->m_CurrentItem = module;
|
|
|
|
module->SetLocked( !module->IsLocked() );
|
|
|
|
module->Display_Infos( this );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'G': // Start move (and drag) module
|
|
|
|
case 'M': // Start move module
|
|
|
|
if( PopupOn )
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'R': // Rotation
|
|
|
|
case 'S': // move to other side
|
|
|
|
if( ItemFree )
|
|
|
|
{
|
|
|
|
module = Locate_Prefered_Module( m_Pcb,
|
|
|
|
CURSEUR_OFF_GRILLE | IGNORE_LOCKED | VISIBLE_ONLY
|
|
|
|
#if defined (USE_MATCH_LAYER)
|
|
|
|
| MATCH_LAYER
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
if( module == NULL ) // no footprint found
|
|
|
|
{
|
|
|
|
module = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE );
|
2007-08-04 20:05:54 +00:00
|
|
|
if( module )
|
2007-08-03 18:59:14 +00:00
|
|
|
{
|
2007-08-04 20:05:54 +00:00
|
|
|
// a footprint is found, but locked or on an other layer
|
2007-08-03 18:59:14 +00:00
|
|
|
if( module->IsLocked() )
|
2007-08-04 20:05:54 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
msg.Printf( _("Footprint %s found, but locked"),
|
|
|
|
module->m_Reference->m_Text.GetData() );
|
|
|
|
|
|
|
|
DisplayInfo( this, msg );
|
|
|
|
}
|
2007-08-03 18:59:14 +00:00
|
|
|
module = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( GetScreen()->m_CurrentItem->m_StructType == TYPEMODULE )
|
|
|
|
{
|
|
|
|
module = (MODULE*) GetScreen()->m_CurrentItem;
|
|
|
|
|
|
|
|
// @todo: might need to add a layer check in if() below
|
|
|
|
if( (GetScreen()->m_CurrentItem->m_Flags == 0)
|
|
|
|
&& module->IsLocked() )
|
|
|
|
module = NULL; // do not move, rotate ... it.
|
|
|
|
}
|
|
|
|
if( module == NULL )
|
|
|
|
break;
|
|
|
|
|
|
|
|
GetScreen()->m_CurrentItem = module;
|
|
|
|
|
|
|
|
switch( hotkey )
|
|
|
|
{
|
|
|
|
case 'R': // Rotation
|
|
|
|
Rotate_Module( DC, module, 900, TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'S': // move to other side
|
|
|
|
Change_Side_Module( module, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'G': // Start move (and drag) module
|
|
|
|
g_Drag_Pistes_On = TRUE;
|
|
|
|
|
|
|
|
// fall through
|
|
|
|
|
|
|
|
case 'M': // Start move module
|
|
|
|
StartMove_Module( module, DC );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
module->Display_Infos( this );
|
|
|
|
break;
|
2007-06-15 16:08:55 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************/
|
2007-08-03 18:59:14 +00:00
|
|
|
void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey,
|
|
|
|
EDA_BaseStruct* DrawStruct )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************/
|
2007-08-03 18:59:14 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Gestion des commandes rapides (Raccourcis claviers) concernant l'element
|
2007-08-03 18:59:14 +00:00
|
|
|
* sous le courseur souris
|
|
|
|
* Les majuscules/minuscules sont indifferenciees
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-03 18:59:14 +00:00
|
|
|
bool PopupOn = GetScreen()->m_CurrentItem
|
|
|
|
&& GetScreen()->m_CurrentItem->m_Flags;
|
|
|
|
|
|
|
|
if( hotkey == 0 )
|
|
|
|
return;
|
2007-06-15 16:08:55 +00:00
|
|
|
|
2007-08-03 18:59:14 +00:00
|
|
|
switch( hotkey )
|
2007-06-15 16:08:55 +00:00
|
|
|
{
|
2007-08-03 18:59:14 +00:00
|
|
|
case WXK_DELETE:
|
|
|
|
case WXK_NUMPAD_DELETE:
|
|
|
|
if( PopupOn )
|
2007-06-15 16:08:55 +00:00
|
|
|
break;
|
2007-08-03 18:59:14 +00:00
|
|
|
break;
|
2007-06-15 16:08:55 +00:00
|
|
|
|
2007-08-03 18:59:14 +00:00
|
|
|
case 'r': // Rotation
|
|
|
|
case 'R':
|
|
|
|
break;
|
2007-06-15 16:08:55 +00:00
|
|
|
|
2007-08-03 18:59:14 +00:00
|
|
|
case 'y': // Mirror Y (drawlibpart)
|
|
|
|
case 'Y':
|
|
|
|
break;
|
2007-06-15 16:08:55 +00:00
|
|
|
|
2007-08-03 18:59:14 +00:00
|
|
|
case 'x': // Mirror X (drawlibpart)
|
|
|
|
case 'X':
|
|
|
|
break;
|
2007-06-15 16:08:55 +00:00
|
|
|
|
2007-08-03 18:59:14 +00:00
|
|
|
case 'n':
|
|
|
|
case 'N': // Orient 0, no mirror (drawlibpart)
|
|
|
|
break;
|
2007-06-15 16:08:55 +00:00
|
|
|
|
2007-08-03 18:59:14 +00:00
|
|
|
case 'm':
|
|
|
|
case 'M': // Start move drawlibpart
|
|
|
|
if( PopupOn )
|
2007-06-15 16:08:55 +00:00
|
|
|
break;
|
2007-08-03 18:59:14 +00:00
|
|
|
break;
|
2007-06-15 16:08:55 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-03 18:59:14 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************************************/
|
2007-08-03 18:59:14 +00:00
|
|
|
bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct )
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************************************/
|
2007-08-03 18:59:14 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Efface l'item pointe par la souris, en reponse a la touche "Del"
|
2007-08-03 18:59:14 +00:00
|
|
|
* Effet dependant de l'outil selectionne:
|
|
|
|
* Outil trace de pistes
|
|
|
|
* Efface le segment en cours ou la piste si pas d'element
|
|
|
|
* Outil module:
|
|
|
|
* Efface le module.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-03 18:59:14 +00:00
|
|
|
bool ItemFree = (GetScreen()->m_CurrentItem == NULL )
|
|
|
|
|| (GetScreen()->m_CurrentItem->m_Flags == 0);
|
2007-06-15 16:08:55 +00:00
|
|
|
|
2007-08-03 18:59:14 +00:00
|
|
|
switch( m_ID_current_state )
|
|
|
|
{
|
|
|
|
case ID_TRACK_BUTT:
|
|
|
|
if( GetScreen()->m_Active_Layer > CMP_N )
|
|
|
|
return FALSE;
|
|
|
|
if( ItemFree )
|
|
|
|
{
|
|
|
|
DrawStruct = PcbGeneralLocateAndDisplay();
|
|
|
|
if( DrawStruct && DrawStruct->m_StructType != TYPETRACK )
|
|
|
|
return FALSE;
|
|
|
|
Delete_Track( DC, (TRACK*) DrawStruct );
|
|
|
|
}
|
|
|
|
else if( GetScreen()->m_CurrentItem->m_StructType == TYPETRACK )
|
2007-06-15 16:08:55 +00:00
|
|
|
{
|
|
|
|
GetScreen()->m_CurrentItem =
|
2007-08-03 18:59:14 +00:00
|
|
|
Delete_Segment( DC, (TRACK*) GetScreen()->m_CurrentItem );
|
2007-06-15 16:08:55 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
return TRUE;
|
2007-08-03 18:59:14 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-06-15 16:08:55 +00:00
|
|
|
|
2007-08-03 18:59:14 +00:00
|
|
|
case ID_COMPONENT_BUTT:
|
|
|
|
if( ItemFree )
|
|
|
|
{
|
|
|
|
MODULE* module = Locate_Prefered_Module( m_Pcb, CURSEUR_ON_GRILLE );
|
|
|
|
if( module == NULL )
|
|
|
|
return FALSE;
|
|
|
|
if( !IsOK( this, _( "Delete module?" ) ) )
|
|
|
|
return FALSE;
|
|
|
|
RemoveStruct( module, DC );
|
2007-06-15 16:08:55 +00:00
|
|
|
}
|
2007-08-03 18:59:14 +00:00
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-06-15 16:08:55 +00:00
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
GetScreen()->m_CurrentItem = NULL;
|
|
|
|
return TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|