Pcbnew: Added move and rotate hot keys in board editor. hotkeys.cpp code cleaned. Fixed a bug that can crash Pcbnew when switching track posture.

This commit is contained in:
jean-pierre charras 2010-08-17 12:44:00 +02:00
commit 6f009e8f99
15 changed files with 467 additions and 393 deletions

View File

@ -257,7 +257,14 @@ public:
wxDC* DC ); wxDC* DC );
void AddPad( MODULE* Module, bool draw ); void AddPad( MODULE* Module, bool draw );
void DeletePad( D_PAD* Pad ); /** Function DeletePad
* Delete the pad aPad.
* Refresh the modified screen area
* Refresh modified parameters of the parent module (bounding box, last date)
* @param aPad = the pad to delete
* @param aQuery = true to promt for confirmation, false to delete silently
*/
void DeletePad( D_PAD* aPad, bool aQuery = true );
void StartMovePad( D_PAD* Pad, wxDC* DC ); void StartMovePad( D_PAD* Pad, wxDC* DC );
void RotatePad( D_PAD* Pad, wxDC* DC ); void RotatePad( D_PAD* Pad, wxDC* DC );
void PlacePad( D_PAD* Pad, wxDC* DC ); void PlacePad( D_PAD* Pad, wxDC* DC );

View File

@ -253,10 +253,44 @@ public:
*/ */
void SetLastNetListRead( const wxString& aNetListFile ); void SetLastNetListRead( const wxString& aNetListFile );
void OnHotKey( wxDC* DC, /** Function OnHotKey.
int hotkey, * ** Commands are case insensitive **
EDA_BaseStruct* DrawStruct ); * Some commands are relatives to the item under the mouse cursor
bool OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct ); * @param aDC = current device context
* @param aHotkeyCode = hotkey code (ascii or wxWidget code for special keys)
* @param aItem = NULL or pointer on a EDA_BaseStruct under the mouse cursor
*/
void OnHotKey( wxDC* aDC,
int aHotkeyCode,
EDA_BaseStruct* aItem );
/** Function OnHotkeyDeleteItem
* Delete the item found under the mouse cursor
* 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.
* @param aDC = current device context
* @return true if an item was deleted
*/
bool OnHotkeyDeleteItem( wxDC* aDC );
/** Function OnHotkeyMoveItem
* Moves or drag the item (footprint, track, text .. ) found under the mouse cursor
* Only a footprint or a track can be dragged
* @param aIdCommand = the hotkey command id
* @return true if an item was moved
*/
bool OnHotkeyMoveItem( int aIdCommand );
/** Function OnHotkeyRotateItem
* Rotate the item (text or footprint) found under the mouse cursor
* @param aIdCommand = the hotkey command id
* @return true if an item was moved
*/
bool OnHotkeyRotateItem( int aIdCommand );
void OnCloseWindow( wxCloseEvent& Event ); void OnCloseWindow( wxCloseEvent& Event );
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );

View File

@ -36,20 +36,56 @@ wxString ModulesMaskSelection = wxT( "*" );
void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event ) void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
wxPoint pos;
INSTALL_DC( dc, DrawPanel );
bool on_state; bool on_state;
if( m_HToolBar == NULL ) if( m_HToolBar == NULL )
return; return;
wxGetMousePosition( &pos.x, &pos.y ); INSTALL_DC( dc, DrawPanel );
switch( id ) switch( id )
{ {
case ID_TOOLBARH_PCB_AUTOPLACE: case ID_TOOLBARH_PCB_MODE_MODULE:
case ID_TOOLBARH_PCB_AUTOROUTE: on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_MODE_MODULE );
break; if( on_state )
{
m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_TRACKS, FALSE );
m_HTOOL_current_state = ID_TOOLBARH_PCB_MODE_MODULE;
}
else
m_HTOOL_current_state = 0;
return;
case ID_TOOLBARH_PCB_MODE_TRACKS:
on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_MODE_TRACKS );
if( on_state )
{
m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_MODULE, FALSE );
m_HTOOL_current_state = ID_TOOLBARH_PCB_MODE_TRACKS;
}
else
m_HTOOL_current_state = 0;
return;
case ID_POPUP_PCB_AUTOROUTE_SELECT_LAYERS:
return;
case ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE:
FixeModule( (MODULE*) GetScreen()->GetCurItem(), TRUE );
return;
case ID_POPUP_PCB_AUTOPLACE_FREE_MODULE:
FixeModule( (MODULE*) GetScreen()->GetCurItem(), FALSE );
return;
case ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES:
FixeModule( NULL, FALSE );
return;
case ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES:
FixeModule( NULL, TRUE );
return;
case ID_POPUP_CANCEL_CURRENT_COMMAND: case ID_POPUP_CANCEL_CURRENT_COMMAND:
if( DrawPanel->ManageCurseur if( DrawPanel->ManageCurseur
@ -71,44 +107,6 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
switch( id ) switch( id )
{ {
case ID_TOOLBARH_PCB_AUTOPLACE:
on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_AUTOPLACE );
if( on_state )
{
m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_AUTOROUTE, FALSE );
m_HTOOL_current_state = ID_TOOLBARH_PCB_AUTOPLACE;
}
else
m_HTOOL_current_state = 0;
break;
case ID_TOOLBARH_PCB_AUTOROUTE:
on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_AUTOROUTE );
if( on_state )
{
m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_AUTOPLACE, FALSE );
m_HTOOL_current_state = ID_TOOLBARH_PCB_AUTOROUTE;
}
else
m_HTOOL_current_state = 0;
break;
case ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE:
FixeModule( (MODULE*) GetScreen()->GetCurItem(), TRUE );
break;
case ID_POPUP_PCB_AUTOPLACE_FREE_MODULE:
FixeModule( (MODULE*) GetScreen()->GetCurItem(), FALSE );
break;
case ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES:
FixeModule( NULL, FALSE );
break;
case ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES:
FixeModule( NULL, TRUE );
break;
case ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE: case ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE:
AutoPlaceModule( (MODULE*) GetScreen()->GetCurItem(), AutoPlaceModule( (MODULE*) GetScreen()->GetCurItem(),
PLACE_1_MODULE, &dc ); PLACE_1_MODULE, &dc );
@ -158,9 +156,6 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
Reset_Noroutable( &dc ); Reset_Noroutable( &dc );
break; break;
case ID_POPUP_PCB_AUTOROUTE_SELECT_LAYERS:
break;
default: default:
DisplayError( this, wxT( "AutoPlace command error" ) ); DisplayError( this, wxT( "AutoPlace command error" ) );
break; break;
@ -168,16 +163,12 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
GetBoard()->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST; GetBoard()->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST;
Compile_Ratsnest( &dc, true ); Compile_Ratsnest( &dc, true );
SetToolbars();
} }
/* Routine allocation of components in a rectangular format 4 / 3, /* Function to move components in a rectangular area format 4 / 3,
* Starting from the mouse cursor * starting from the mouse cursor
* The components with the FIXED status are not normally dives * The components with the FIXED status set are not moved
* According to the flags:
* All modules (not fixed) will be left
* Only PCB modules are not left
*/ */
void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
{ {

View File

@ -83,7 +83,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
{ {
switch( m_HTOOL_current_state ) switch( m_HTOOL_current_state )
{ {
case ID_TOOLBARH_PCB_AUTOPLACE: case ID_TOOLBARH_PCB_MODE_MODULE:
scanList = GENERAL_COLLECTOR::ModuleItems; scanList = GENERAL_COLLECTOR::ModuleItems;
break; break;

View File

@ -348,9 +348,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_SWITCH_TRACK_POSTURE: case ID_POPUP_PCB_SWITCH_TRACK_POSTURE:
/* change the position of initial segment when creating new tracks /* change the position of initial segment when creating new tracks
* switch from _/ to -\ . * switch from _/ to -\ .
* If a track is in progress, it will be redrawn
*/ */
if( DrawPanel->ManageCurseur == ShowNewTrackWhenMovingCursor )
ShowNewTrackWhenMovingCursor( DrawPanel, &dc, false ); ShowNewTrackWhenMovingCursor( DrawPanel, &dc, false );
g_Alternate_Track_Posture = !g_Alternate_Track_Posture; g_Alternate_Track_Posture = !g_Alternate_Track_Posture;
if( DrawPanel->ManageCurseur == ShowNewTrackWhenMovingCursor )
ShowNewTrackWhenMovingCursor( DrawPanel, &dc, false ); ShowNewTrackWhenMovingCursor( DrawPanel, &dc, false );
break; break;

View File

@ -118,7 +118,7 @@ void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item )
switch( Item->Type() ) switch( Item->Type() )
{ {
case TYPE_PAD: case TYPE_PAD:
DeletePad( (D_PAD*) Item ); DeletePad( (D_PAD*) Item, false );
break; break;
case TYPE_TEXTE_MODULE: case TYPE_TEXTE_MODULE:

View File

@ -24,7 +24,7 @@
* default key value is the default hotkey for this command. Can be overrided by the user hotkey list file * 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 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. * Add the new code in the switch in OnHotKey() function.
* when the variable PopupOn is true, an item is currently edited. * 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 * 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.) * ( For example, one cannot start a new wire when a component is moving.)
* *
@ -76,18 +76,15 @@ static Ki_HotkeyInfo HkEndTrack( wxT( "End Track" ), HK_END_TRACK, WXK_END );
static Ki_HotkeyInfo HkEditBoardItem( wxT( "Edit Item" ), HK_EDIT_ITEM, 'E' ); static Ki_HotkeyInfo HkEditBoardItem( wxT( "Edit Item" ), HK_EDIT_ITEM, 'E' );
static Ki_HotkeyInfo HkFlipFootprint( wxT( "Flip Footprint" ), HK_FLIP_FOOTPRINT, static Ki_HotkeyInfo HkFlipFootprint( wxT( "Flip Footprint" ), HK_FLIP_FOOTPRINT,
'F' ); 'F' );
static Ki_HotkeyInfo HkRotateFootprint( wxT( "Rotate Footprint" ), static Ki_HotkeyInfo HkRotateItem( wxT( "Rotate Item" ), HK_ROTATE_ITEM, 'R' );
HK_ROTATE_FOOTPRINT, 'R' ); static Ki_HotkeyInfo HkMoveItem( wxT( "Move Item" ), HK_MOVE_ITEM, 'M' );
static Ki_HotkeyInfo HkMoveFootprint( wxT( "Move Footprint" ), HK_MOVE_FOOTPRINT_OR_TRACK, static Ki_HotkeyInfo HkDragFootprint( wxT( "Drag Footprint" ), HK_DRAG_ITEM,
'M' );
static Ki_HotkeyInfo HkDragFootprint( wxT( "Drag Footprint" ), HK_DRAG_FOOTPRINT_OR_TRACK,
'G' ); 'G' );
static Ki_HotkeyInfo HkGetAndMoveFootprint( wxT( "Get and Move Footprint" ), static Ki_HotkeyInfo HkGetAndMoveFootprint( wxT( "Get and Move Footprint" ),
HK_GET_AND_MOVE_FOOTPRINT, 'T' ); HK_GET_AND_MOVE_FOOTPRINT, 'T' );
static Ki_HotkeyInfo HkLock_Unlock_Footprint( wxT( "Lock/Unlock Footprint" ), static Ki_HotkeyInfo HkLock_Unlock_Footprint( wxT( "Lock/Unlock Footprint" ),
HK_LOCK_UNLOCK_FOOTPRINT, 'L' ); HK_LOCK_UNLOCK_FOOTPRINT, 'L' );
static Ki_HotkeyInfo HkDelete( wxT( "Delete Track or Footprint" ), HK_DELETE, static Ki_HotkeyInfo HkDelete( wxT( "Delete Track or Footprint" ), HK_DELETE, WXK_DELETE );
WXK_DELETE );
static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ), static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ),
HK_RESET_LOCAL_COORD, ' ' ); HK_RESET_LOCAL_COORD, ' ' );
@ -162,8 +159,8 @@ Ki_HotkeyInfo* s_board_edit_Hotkey_List[] =
&HkBackspace, &HkBackspace,
&HkAddNewTrack, &HkAddVia, &HkAddMicroVia, &HkAddNewTrack, &HkAddVia, &HkAddMicroVia,
&HkSwitchTrackPosture, &HkSwitchTrackPosture,
&HkEndTrack, &HkMoveFootprint, &HkEndTrack, &HkMoveItem,
&HkFlipFootprint, &HkRotateFootprint, &HkDragFootprint, &HkFlipFootprint, &HkRotateItem, &HkDragFootprint,
&HkGetAndMoveFootprint, &HkLock_Unlock_Footprint, &HkSavefile, &HkGetAndMoveFootprint, &HkLock_Unlock_Footprint, &HkSavefile,
&HkLoadfile, &HkFindItem, &HkEditBoardItem, &HkLoadfile, &HkFindItem, &HkEditBoardItem,
&HkSwitch2CopperLayer, &HkSwitch2InnerLayer1, &HkSwitch2CopperLayer, &HkSwitch2InnerLayer1,
@ -210,45 +207,41 @@ struct Ki_HotkeyInfoSectionDescriptor s_Module_Editor_Hokeys_Descr[] =
NULL, NULL, NULL NULL, NULL, NULL
} }; } };
/***********************************************************/ /** Function OnHotKey.
void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct ) * ** Commands are case insensitive **
/***********************************************************/ * Some commands are relatives to the item under the mouse cursor
* @param aDC = current device context
/* Hot keys. Some commands are relatives to the item under the mouse cursor
* Commands are case insensitive
* @param DC = current device context
* @param hotkey = hotkey code (ascii or wxWidget code for special keys) * @param hotkey = hotkey code (ascii or wxWidget code for special keys)
* @param DrawStruct = NULL or pointer on a EDA_BaseStruct under the mouse cursor * @param aItem = NULL or pointer on a EDA_BaseStruct under the mouse cursor
*/ */
void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_BaseStruct* aItem )
{ {
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); if( aHotkeyCode == 0 )
cmd.SetEventObject( this );
bool PopupOn = (GetCurItem() && GetCurItem()->m_Flags);
bool ItemFree = (GetCurItem() == 0 || GetCurItem()->m_Flags == 0);
if( hotkey == 0 )
return; return;
bool itemCurrentlyEdited = (GetCurItem() && GetCurItem()->m_Flags);
MODULE* module = NULL; MODULE* module = NULL;
int evt_type = 0; //Used to post a wxCommandEvent on demand
/* Convert lower to upper case /* Convert lower to upper case
* (the usual toupper function has problem with non ascii codes like function keys * (the usual toupper function has problem with non ascii codes like function keys
*/ */
if( (hotkey >= 'a') && (hotkey <= 'z') ) if( (aHotkeyCode >= 'a') && (aHotkeyCode <= 'z') )
hotkey += 'A' - 'a'; aHotkeyCode += 'A' - 'a';
Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( hotkey, s_Common_Hotkey_List ); Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, s_Common_Hotkey_List );
if( HK_Descr == NULL ) if( HK_Descr == NULL )
HK_Descr = GetDescriptorFromHotkey( hotkey, s_board_edit_Hotkey_List ); HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, s_board_edit_Hotkey_List );
if( HK_Descr == NULL ) if( HK_Descr == NULL )
return; return;
// Create a wxCommandEvent that will be posted in some hot keys functions
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
int ll; int ll;
switch( HK_Descr->m_Idcommand ) switch( HK_Descr->m_Idcommand )
@ -270,7 +263,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
GetBoard()->GetCopperLayerCount() - 2 ); GetBoard()->GetCopperLayerCount() - 2 );
else else
ll--; ll--;
SwitchLayer( DC, ll ); SwitchLayer( aDC, ll );
break; break;
case HK_SWITCH_LAYER_TO_NEXT: case HK_SWITCH_LAYER_TO_NEXT:
@ -283,39 +276,39 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
ll = LAYER_N_FRONT; ll = LAYER_N_FRONT;
else else
ll++; ll++;
SwitchLayer( DC, ll ); SwitchLayer( aDC, ll );
break; break;
case HK_SWITCH_LAYER_TO_COMPONENT: case HK_SWITCH_LAYER_TO_COMPONENT:
SwitchLayer( DC, LAYER_N_FRONT ); SwitchLayer( aDC, LAYER_N_FRONT );
break; break;
case HK_SWITCH_LAYER_TO_COPPER: case HK_SWITCH_LAYER_TO_COPPER:
SwitchLayer( DC, LAYER_N_BACK ); SwitchLayer( aDC, LAYER_N_BACK );
break; break;
case HK_SWITCH_LAYER_TO_INNER1: case HK_SWITCH_LAYER_TO_INNER1:
SwitchLayer( DC, LAYER_N_2 ); SwitchLayer( aDC, LAYER_N_2 );
break; break;
case HK_SWITCH_LAYER_TO_INNER2: case HK_SWITCH_LAYER_TO_INNER2:
SwitchLayer( DC, LAYER_N_3 ); SwitchLayer( aDC, LAYER_N_3 );
break; break;
case HK_SWITCH_LAYER_TO_INNER3: case HK_SWITCH_LAYER_TO_INNER3:
SwitchLayer( DC, LAYER_N_4 ); SwitchLayer( aDC, LAYER_N_4 );
break; break;
case HK_SWITCH_LAYER_TO_INNER4: case HK_SWITCH_LAYER_TO_INNER4:
SwitchLayer( DC, LAYER_N_5 ); SwitchLayer( aDC, LAYER_N_5 );
break; break;
case HK_SWITCH_LAYER_TO_INNER5: case HK_SWITCH_LAYER_TO_INNER5:
SwitchLayer( DC, LAYER_N_6 ); SwitchLayer( aDC, LAYER_N_6 );
break; break;
case HK_SWITCH_LAYER_TO_INNER6: case HK_SWITCH_LAYER_TO_INNER6:
SwitchLayer( DC, LAYER_N_7 ); SwitchLayer( aDC, LAYER_N_7 );
break; break;
case HK_HELP: // Display Current hotkey list case HK_HELP: // Display Current hotkey list
@ -323,38 +316,32 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
break; break;
case HK_ZOOM_IN: case HK_ZOOM_IN:
cmd.SetId( ID_POPUP_ZOOM_IN ); evt_type = ID_POPUP_ZOOM_IN;
GetEventHandler()->ProcessEvent( cmd );
break; break;
case HK_ZOOM_OUT: case HK_ZOOM_OUT:
cmd.SetId( ID_POPUP_ZOOM_OUT ); evt_type = ID_POPUP_ZOOM_OUT;
GetEventHandler()->ProcessEvent( cmd );
break; break;
case HK_ZOOM_REDRAW: case HK_ZOOM_REDRAW:
cmd.SetId( ID_ZOOM_REDRAW ); evt_type = ID_ZOOM_REDRAW;
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_ZOOM_CENTER:
cmd.SetId( ID_POPUP_ZOOM_CENTER );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_ADD_MODULE:
cmd.SetId( ID_COMPONENT_BUTT );
GetEventHandler()->ProcessEvent( cmd );
break; break;
case HK_ZOOM_AUTO: case HK_ZOOM_AUTO:
cmd.SetId( ID_ZOOM_PAGE ); evt_type = ID_ZOOM_PAGE;
GetEventHandler()->ProcessEvent( cmd ); break;
case HK_ZOOM_CENTER:
evt_type = ID_POPUP_ZOOM_CENTER;
break;
case HK_ADD_MODULE:
evt_type = ID_COMPONENT_BUTT;
break; break;
case HK_UNDO: case HK_UNDO:
case HK_REDO: case HK_REDO:
if( ItemFree ) if( !itemCurrentlyEdited )
{ {
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED,
HK_Descr->m_IdMenuEvent ); HK_Descr->m_IdMenuEvent );
@ -378,26 +365,24 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
break; break;
case HK_DELETE: case HK_DELETE:
OnHotkeyDeleteItem( DC, DrawStruct ); OnHotkeyDeleteItem( aDC );
break; break;
case HK_BACK_SPACE: case HK_BACK_SPACE:
if( m_ID_current_state == ID_TRACK_BUTT && getActiveLayer() if( m_ID_current_state == ID_TRACK_BUTT && (getActiveLayer() <= LAYER_N_FRONT) )
<= LAYER_N_FRONT )
{ {
if( ItemFree ) if( !itemCurrentlyEdited )
{ {
// no track is currently being edited - select a segment and remove it. // no track is currently being edited - select a segment and remove it.
// @todo: possibly? pass the HK command code to PcbGeneralLocateAndDisplay() so it can restrict its search to specific item types. // @todo: possibly? pass the HK command code to PcbGeneralLocateAndDisplay()
// @todo: use PcbGeneralLocateAndDisplay() everywhere in this source file. // so it can restrict its search to specific item types.
aItem = PcbGeneralLocateAndDisplay();
DrawStruct = PcbGeneralLocateAndDisplay();
// don't let backspace delete modules!! // don't let backspace delete modules!!
if( DrawStruct && (DrawStruct->Type() == TYPE_TRACK if( aItem && (aItem->Type() == TYPE_TRACK
|| DrawStruct->Type() == TYPE_VIA) ) || aItem->Type() == TYPE_VIA) )
{ {
Delete_Segment( DC, (TRACK*) DrawStruct ); Delete_Segment( aDC, (TRACK*) aItem );
SetCurItem( NULL ); SetCurItem( NULL );
} }
OnModify(); OnModify();
@ -407,7 +392,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
// then an element is being edited - remove the last segment. // then an element is being edited - remove the last segment.
// simple lines for debugger: // simple lines for debugger:
TRACK* track = (TRACK*) GetCurItem(); TRACK* track = (TRACK*) GetCurItem();
track = Delete_Segment( DC, track ); track = Delete_Segment( aDC, track );
SetCurItem( track ); SetCurItem( track );
OnModify(); OnModify();
} }
@ -415,57 +400,39 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
break; break;
case HK_END_TRACK: case HK_END_TRACK:
if( !ItemFree && (GetCurItem()->Type() == TYPE_TRACK) if( itemCurrentlyEdited && (GetCurItem()->Type() == TYPE_TRACK)
&& ( (GetCurItem()->m_Flags & IS_NEW) != 0 ) ) && ( (GetCurItem()->m_Flags & IS_NEW) != 0 ) )
{ {
// A new track is in progress: call to End_Route() // A new track is in progress: call to End_Route()
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
End_Route( (TRACK*) GetCurItem(), DC ); End_Route( (TRACK*) GetCurItem(), aDC );
} }
break; break;
case HK_GET_AND_MOVE_FOOTPRINT: case HK_GET_AND_MOVE_FOOTPRINT:
if( ItemFree ) if( !itemCurrentlyEdited )
{ evt_type = ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST;
wxCommandEvent evt;
evt.SetId( ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST );
Process_Special_Functions( evt );
}
break; break;
case HK_FIND_ITEM: case HK_FIND_ITEM:
if( ItemFree ) if( !itemCurrentlyEdited )
{ evt_type = ID_FIND_ITEMS;
wxCommandEvent evt;
evt.SetId( ID_FIND_ITEMS );
Process_Special_Functions( evt );
}
break; break;
case HK_LOAD_BOARD: case HK_LOAD_BOARD:
if( ItemFree ) if( !itemCurrentlyEdited )
{ evt_type = ID_LOAD_FILE ;
// try not to duplicate save, load code etc.
wxCommandEvent evt;
evt.SetId( ID_LOAD_FILE );
Files_io( evt );
}
break; break;
case HK_SAVE_BOARD: case HK_SAVE_BOARD:
if( ItemFree ) if( !itemCurrentlyEdited )
{ evt_type = ID_SAVE_BOARD;
// try not to duplicate save, load code etc.
wxCommandEvent evt;
evt.SetId( ID_SAVE_BOARD );
Files_io( evt );
}
break; break;
case HK_ADD_MICROVIA: // Place a micro via if a track is in progress case HK_ADD_MICROVIA: // Place a micro via if a track is in progress
if( m_ID_current_state != ID_TRACK_BUTT ) if( m_ID_current_state != ID_TRACK_BUTT )
return; return;
if( ItemFree ) // no track in progress: nothing to do if( !itemCurrentlyEdited ) // no track in progress: nothing to do
break; break;
if( GetCurItem()->Type() != TYPE_TRACK ) // Should not occur if( GetCurItem()->Type() != TYPE_TRACK ) // Should not occur
return; return;
@ -474,47 +441,36 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
// place micro via and switch layer // place micro via and switch layer
if( IsMicroViaAcceptable() ) if( IsMicroViaAcceptable() )
{ evt_type = ID_POPUP_PCB_PLACE_MICROVIA;
int v_type = GetBoard()->GetBoardDesignSettings()->m_CurrentViaType;
GetBoard()->GetBoardDesignSettings()->m_CurrentViaType = VIA_MICROVIA;
Other_Layer_Route( (TRACK*) GetCurItem(), DC );
GetBoard()->GetBoardDesignSettings()->m_CurrentViaType = v_type;
if( DisplayOpt.ContrastModeDisplay )
DrawPanel->Refresh();
}
break; break;
case HK_ADD_VIA: // Switch to alternate layer and Place a via if a track is in progress 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 ) if( m_ID_current_state != ID_TRACK_BUTT )
return; return;
if( ItemFree ) // no track in progress: switch layer only if( !itemCurrentlyEdited ) // no track in progress: switch layer only
{ {
Other_Layer_Route( NULL, DC ); Other_Layer_Route( NULL, aDC );
break; break;
} }
if( GetCurItem()->Type() != TYPE_TRACK ) if( GetCurItem()->Type() != TYPE_TRACK )
return; return;
if( (GetCurItem()->m_Flags & IS_NEW) == 0 ) if( (GetCurItem()->m_Flags & IS_NEW) == 0 )
return; return;
Other_Layer_Route( (TRACK*) GetCurItem(), DC ); // place via and switch layer evt_type = ID_POPUP_PCB_PLACE_VIA;
if( DisplayOpt.ContrastModeDisplay )
DrawPanel->Refresh();
break; break;
case HK_SWITCH_TRACK_POSTURE: case HK_SWITCH_TRACK_POSTURE:
/* change the position of initial segment when creating new tracks /* change the position of initial segment when creating new tracks
* switch from _/ to -\ . * switch from _/ to -\ .
*/ */
ShowNewTrackWhenMovingCursor( DrawPanel, DC, false ); evt_type = ID_POPUP_PCB_SWITCH_TRACK_POSTURE ;
g_Alternate_Track_Posture = !g_Alternate_Track_Posture;
ShowNewTrackWhenMovingCursor( DrawPanel, DC, false );
break; break;
case HK_ADD_NEW_TRACK: // Start new track case HK_ADD_NEW_TRACK: // Start new track
if( getActiveLayer() > LAYER_N_FRONT ) if( getActiveLayer() > LAYER_N_FRONT )
break; break;
if( m_ID_current_state != ID_TRACK_BUTT && ItemFree ) if( m_ID_current_state != ID_TRACK_BUTT && !itemCurrentlyEdited )
{ {
cmd.SetId( ID_TRACK_BUTT ); cmd.SetId( ID_TRACK_BUTT );
GetEventHandler()->ProcessEvent( cmd ); GetEventHandler()->ProcessEvent( cmd );
@ -523,16 +479,16 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
if( m_ID_current_state != ID_TRACK_BUTT ) if( m_ID_current_state != ID_TRACK_BUTT )
break; break;
if( ItemFree ) // no track in progress: if( !itemCurrentlyEdited ) // no track in progress:
{ {
TRACK* track = Begin_Route( NULL, DC ); TRACK* track = Begin_Route( NULL, aDC );
SetCurItem( track ); SetCurItem( track );
if( track ) if( track )
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
} }
else if( GetCurItem()->m_Flags & IS_NEW ) else if( GetCurItem()->m_Flags & IS_NEW )
{ {
TRACK* track = Begin_Route( (TRACK*) GetCurItem(), DC ); TRACK* track = Begin_Route( (TRACK*) GetCurItem(), aDC );
// SetCurItem() must not write to the msg panel // SetCurItem() must not write to the msg panel
// because a track info is displayed while moving the mouse cursor // because a track info is displayed while moving the mouse cursor
@ -543,20 +499,21 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
break; break;
case HK_EDIT_ITEM: // Edit board item case HK_EDIT_ITEM: // Edit board item
if( ItemFree ) if( !itemCurrentlyEdited )
{ {
BOARD_ITEM* item = PcbGeneralLocateAndDisplay(); BOARD_ITEM* item = PcbGeneralLocateAndDisplay();
if( item == NULL ) if( item == NULL )
break; break;
//An item is found, and some can be edited: //An item is found, and some can be edited:
OnEditItemRequest( DC, item ); OnEditItemRequest( aDC, item );
} }
break; break;
// Footprint edition: // Footprint edition:
case HK_LOCK_UNLOCK_FOOTPRINT: // toggle module "MODULE_is_LOCKED" status: case HK_LOCK_UNLOCK_FOOTPRINT: // toggle module "MODULE_is_LOCKED" status:
// get any module, locked or not locked and toggle its locked status // get any module, locked or not locked and toggle its locked status
if( ItemFree ) if( !itemCurrentlyEdited )
module = Locate_Prefered_Module( GetBoard(), CURSEUR_OFF_GRILLE module = Locate_Prefered_Module( GetBoard(), CURSEUR_OFF_GRILLE
| VISIBLE_ONLY ); | VISIBLE_ONLY );
else if( GetCurItem()->Type() == TYPE_MODULE ) else if( GetCurItem()->Type() == TYPE_MODULE )
@ -569,133 +526,35 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
} }
break; break;
case HK_DRAG_FOOTPRINT_OR_TRACK: // Start move (and drag) module or track segment case HK_DRAG_ITEM: // Start drag module or track segment
case HK_MOVE_FOOTPRINT_OR_TRACK: // Start move module or track segment OnHotkeyMoveItem( HK_DRAG_ITEM );
if( PopupOn )
break;
// Fall through on hot key
case HK_ROTATE_FOOTPRINT: // Rotation
case HK_FLIP_FOOTPRINT: // move to other side
int exit = 0;
if( m_ID_current_state == ID_TRACK_BUTT )
{
if( ItemFree )
DrawStruct = PcbGeneralLocateAndDisplay();
else
DrawStruct = GetCurItem();
if( DrawStruct && (DrawStruct->Type() == TYPE_TRACK
|| DrawStruct->Type() == TYPE_VIA) )
switch( HK_Descr->m_Idcommand )
{
case HK_DRAG_FOOTPRINT_OR_TRACK: // Start drag track segment
DrawPanel->MouseToCursorSchema();
//Start_DragTrackSegmentAndKeepSlope( (TRACK*) DrawStruct,DC );
Start_MoveOneNodeOrSegment( (TRACK*) DrawStruct, DC,
ID_POPUP_PCB_DRAG_TRACK_SEGMENT );
break; break;
// fall through case HK_MOVE_ITEM: // Start move item
case HK_MOVE_FOOTPRINT_OR_TRACK: // Start move track segment OnHotkeyMoveItem( HK_MOVE_ITEM );
DrawPanel->MouseToCursorSchema();
Start_MoveOneNodeOrSegment( (TRACK*) DrawStruct, DC,
ID_POPUP_PCB_MOVE_TRACK_NODE );
break;
}
else
exit = 1;
}
else if( !exit )
{
if( ItemFree )
{
module = Locate_Prefered_Module( GetBoard(), 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( GetBoard(),
CURSEUR_OFF_GRILLE | VISIBLE_ONLY );
if( module )
{
// 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 );
}
module = NULL;
}
}
}
else if( GetCurItem()->Type() == TYPE_MODULE )
{
module = (MODULE*) GetCurItem();
// @todo: might need to add a layer check in if() below
if( (GetCurItem()->m_Flags == 0) && module->IsLocked() )
module = NULL; // do not move, rotate ... it.
}
if( module == NULL )
break; break;
/* I'd like to make sending to EESCHEMA edge triggered, but the case HK_ROTATE_ITEM: // Rotation
* simple mouse click on a module when the arrow icon is in play OnHotkeyRotateItem( HK_ROTATE_ITEM );
* does not set GetCurItem() at this time, nor does a mouse click
* when the local ratsnest icon is in play set GetCurItem(), and these
* actions also call SendMessageToEESCHEMA().
* if( GetCurItem() != module )
*/
{
// Send the module via socket to EESCHEMA's search facility.
SendMessageToEESCHEMA( module );
SetCurItem( module );
}
switch( HK_Descr->m_Idcommand )
{
case HK_ROTATE_FOOTPRINT: // Rotation
if( module->m_Flags == 0 ) // not currently in edit, prepare undo command
SaveCopyInUndoList( module, UR_ROTATED, module->m_Pos );
Rotate_Module( DC, module, 900, TRUE );
break; break;
case HK_FLIP_FOOTPRINT: // move to other side case HK_FLIP_FOOTPRINT: // move to other side
if( module->m_Flags == 0 ) // not currently in edit, prepare undo command OnHotkeyRotateItem( HK_FLIP_FOOTPRINT );
SaveCopyInUndoList( module, UR_FLIPPED, module->m_Pos );
Change_Side_Module( module, DC );
break;
case HK_DRAG_FOOTPRINT_OR_TRACK: // Start move (and drag) module
g_Drag_Pistes_On = TRUE;
// fall through
case HK_MOVE_FOOTPRINT_OR_TRACK: // Start move module
GetScreen()->m_Curseur = module->m_Pos;
DrawPanel->MouseToCursorSchema();
StartMove_Module( module, DC );
break; break;
} }
module->DisplayInfo( this ); if( evt_type != 0 )
break; {
} wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
evt.SetEventObject( this );
evt.SetId( evt_type );
wxPostEvent( this, evt );
} }
} }
/***********************************************************/ /***********************************************************/
void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey, void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int hotkey,
EDA_BaseStruct* DrawStruct ) EDA_BaseStruct* DrawStruct )
/***********************************************************/ /***********************************************************/
@ -706,7 +565,8 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey,
if( hotkey == 0 ) if( hotkey == 0 )
return; return;
bool ItemFree = (GetCurItem() == 0 || GetCurItem()->m_Flags == 0); BOARD_ITEM* item = GetCurItem();
bool ItemFree = (item == 0) || (item->m_Flags == 0);
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this ); cmd.SetEventObject( this );
@ -779,41 +639,42 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey,
} }
/******************************************************************************/ /** Function OnHotkeyDeleteItem
bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct ) * Delete the item found under the mouse cursor
/******************************************************************************/
/* Delete the item foun under the mouse cursor
* Depending on the current active tool:: * Depending on the current active tool::
* Tool track * Tool track
* if a track is in progress: Delete the last segment * if a track is in progress: Delete the last segment
* else delete the entire track * else delete the entire track
* Tool module (footprint): * Tool module (footprint):
* Delete the module. * Delete the module.
* @param aDC = current device context
* @return true if an item was deleted
*/ */
bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* aDC )
{ {
bool ItemFree = (GetCurItem() == NULL) || (GetCurItem()->m_Flags == 0); BOARD_ITEM* item = GetCurItem();
bool ItemFree = (item == NULL) || (item->m_Flags == 0);
switch( m_ID_current_state ) switch( m_ID_current_state )
{ {
case ID_TRACK_BUTT: case ID_TRACK_BUTT:
if( getActiveLayer() > LAYER_N_FRONT ) if( getActiveLayer() > LAYER_N_FRONT )
return FALSE; return false;
if( ItemFree ) if( ItemFree )
{ {
DrawStruct = PcbGeneralLocateAndDisplay(); item = PcbGeneralLocateAndDisplay();
if( DrawStruct && DrawStruct->Type() != TYPE_TRACK ) if( item && item->Type() != TYPE_TRACK )
return FALSE; return false;
Delete_Track( DC, (TRACK*) DrawStruct ); Delete_Track( aDC, (TRACK*) item );
} }
else if( GetCurItem()->Type() == TYPE_TRACK ) else if( item->Type() == TYPE_TRACK )
{ {
// simple lines for debugger: // simple lines for debugger:
TRACK* track = (TRACK*) GetCurItem(); TRACK* track = (TRACK*) item;
track = Delete_Segment( DC, track ); track = Delete_Segment( aDC, track );
SetCurItem( track ); SetCurItem( track );
OnModify(); OnModify();
return TRUE; return true;
} }
break; break;
@ -823,20 +684,185 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct )
MODULE* module = Locate_Prefered_Module( GetBoard(), MODULE* module = Locate_Prefered_Module( GetBoard(),
CURSEUR_ON_GRILLE ); CURSEUR_ON_GRILLE );
if( module == NULL ) if( module == NULL )
return FALSE; return false;
if( !IsOK( this, _( "Delete module?" ) ) ) if( !IsOK( this, _( "Delete module?" ) ) )
return FALSE; return false;
RemoveStruct( module, DC ); RemoveStruct( module, aDC );
} }
else else
return FALSE; return false;
break; break;
default: default:
return FALSE; return false;
} }
OnModify(); OnModify();
SetCurItem( NULL ); SetCurItem( NULL );
return TRUE; return true;
}
/** Function OnHotkeyMoveItem
* 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
* @param aIdCommand = the hotkey command id
* @return true if an item was moved
*/
bool WinEDA_PcbFrame::OnHotkeyMoveItem( int aIdCommand )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->m_Flags;
if( itemCurrentlyEdited )
return false;
item = PcbGeneralLocateAndDisplay();
if( item == NULL )
return false;
SetCurItem( item );
int evt_type = 0; //Used to post a wxCommandEvent on demand
switch( item->Type() )
{
case TYPE_TRACK:
case TYPE_VIA:
if( aIdCommand == HK_MOVE_ITEM )
evt_type = ID_POPUP_PCB_MOVE_TRACK_NODE;
if( aIdCommand == HK_DRAG_ITEM )
evt_type = ID_POPUP_PCB_DRAG_TRACK_SEGMENT;
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;
}
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;
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;
case TYPE_TEXTE:
evt_type = ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST;
break;
case TYPE_MIRE:
evt_type = ID_POPUP_PCB_MOVE_MIRE_REQUEST;
break;
case TYPE_ZONE_CONTAINER:
evt_type = ID_POPUP_PCB_MOVE_ZONE_OUTLINES;
break;
case TYPE_TEXTE_MODULE:
evt_type = ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST;
break;
case TYPE_DRAWSEGMENT:
evt_type = ID_POPUP_PCB_MOVE_DRAWING_REQUEST;
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;
}
/** Function OnHotkeyRotateItem
* Rotate the item (text or footprint) found under the mouse cursor
* Note:
* this command can be used with an item currently in edit
* Only some items can be rotated (footprints and texts)
* @param aIdCommand = the hotkey command id
* @return true if an item was moved
*/
bool WinEDA_PcbFrame::OnHotkeyRotateItem( int aIdCommand )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->m_Flags;
int evt_type = 0; // Used to post a wxCommandEvent on demand
if( !itemCurrentlyEdited )
item = PcbGeneralLocateAndDisplay();
if( item == NULL )
return false;
SetCurItem( item );
switch( item->Type() )
{
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;
}
break;
case TYPE_TEXTE:
evt_type = ID_POPUP_PCB_ROTATE_TEXTEPCB;
break;
case TYPE_TEXTE_MODULE:
evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE;
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;
} }

View File

@ -13,9 +13,9 @@
enum hotkey_id_commnand { enum hotkey_id_commnand {
HK_DELETE = HK_COMMON_END, HK_DELETE = HK_COMMON_END,
HK_BACK_SPACE, HK_BACK_SPACE,
HK_ROTATE_FOOTPRINT, HK_ROTATE_ITEM,
HK_MOVE_FOOTPRINT_OR_TRACK, HK_MOVE_ITEM,
HK_DRAG_FOOTPRINT_OR_TRACK, HK_DRAG_ITEM,
HK_FLIP_FOOTPRINT, HK_FLIP_FOOTPRINT,
HK_GET_AND_MOVE_FOOTPRINT, HK_GET_AND_MOVE_FOOTPRINT,
HK_LOCK_UNLOCK_FOOTPRINT, HK_LOCK_UNLOCK_FOOTPRINT,
@ -48,7 +48,6 @@ enum hotkey_id_commnand {
HK_SWITCH_LAYER_TO_INNER13, HK_SWITCH_LAYER_TO_INNER13,
HK_SWITCH_LAYER_TO_INNER14, HK_SWITCH_LAYER_TO_INNER14,
HK_ADD_MODULE, HK_ADD_MODULE,
HK_MOVE_TRACK,
HK_SLIDE_TRACK HK_SLIDE_TRACK
}; };

View File

@ -518,7 +518,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_DELETE_PAD: case ID_POPUP_PCB_DELETE_PAD:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
DeletePad( (D_PAD*) GetScreen()->GetCurItem() ); DeletePad( (D_PAD*) GetScreen()->GetCurItem(), false );
SetCurItem( NULL ); SetCurItem( NULL );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;

View File

@ -116,19 +116,13 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ),
break; break;
case ID_MODEDIT_DELETE_ITEM_BUTT: case ID_MODEDIT_DELETE_ITEM_BUTT:
if( DrawStruct == NULL || // No item to delete
// Item in edit, cannot delete it (DrawStruct->m_Flags != 0) ) // Item in edit, cannot delete it
if( DrawStruct && (DrawStruct->m_Flags != 0) )
break; break;
DrawStruct = ModeditLocateAndDisplay(); if( DrawStruct->Type() != TYPE_MODULE ) // Cannot delete the module itself
if( DrawStruct == NULL || (DrawStruct->m_Flags != 0) )
break;
if( DrawStruct->Type() != TYPE_MODULE ) //GetBoard()->m_Modules )
{ {
// Cannot delete the module itself
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
RemoveStruct( DrawStruct ); RemoveStruct( DrawStruct );
DrawStruct = NULL;
SetCurItem( NULL ); SetCurItem( NULL );
} }
break; break;

View File

@ -227,30 +227,36 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw )
} }
/* Function to delete the pad. */ /** Function DeletePad
void WinEDA_BasePcbFrame::DeletePad( D_PAD* Pad ) * Delete the pad aPad.
* Refresh the modified screen area
* Refresh modified parameters of the parent module (bounding box, last date)
* @param aPad = the pad to delete
* @param aQuery = true to promt for confirmation, false to delete silently
*/
void WinEDA_BasePcbFrame::DeletePad( D_PAD* aPad, bool aQuery )
{ {
MODULE* Module; MODULE* Module;
wxString line;
if( Pad == NULL ) if( aPad == NULL )
return; return;
Module = (MODULE*) Pad->GetParent(); Module = (MODULE*) aPad->GetParent();
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
line.Printf( _( "Delete Pad (module %s %s) " ), if( aQuery )
{
wxString msg;
msg.Printf( _( "Delete Pad (module %s %s) " ),
GetChars( Module->m_Reference->m_Text ), GetChars( Module->m_Reference->m_Text ),
GetChars( Module->m_Value->m_Text ) ); GetChars( Module->m_Value->m_Text ) );
if( !IsOK( this, line ) ) if( !IsOK( this, msg ) )
return; return;
}
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
aPad->DeleteStructure();
Pad->DeleteStructure();
DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); DrawPanel->PostDirtyRect( Module->GetBoundingBox() );
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
OnModify(); OnModify();

View File

@ -120,7 +120,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
case TYPE_MODULE: case TYPE_MODULE:
createPopUpMenuForFootprints( (MODULE*) item, aPopMenu ); createPopUpMenuForFootprints( (MODULE*) item, aPopMenu );
if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOPLACE ) if( m_HTOOL_current_state == ID_TOOLBARH_PCB_MODE_MODULE )
{ {
aPopMenu->AppendSeparator(); aPopMenu->AppendSeparator();
@ -146,7 +146,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
_( "Auto Place Module" ) ); _( "Auto Place Module" ) );
} }
if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE ) if( m_HTOOL_current_state == ID_TOOLBARH_PCB_MODE_TRACKS )
{ {
if( !flags ) if( !flags )
aPopMenu->Append( ID_POPUP_PCB_AUTOROUTE_MODULE, _( "Autoroute Module" ) ); aPopMenu->Append( ID_POPUP_PCB_AUTOROUTE_MODULE, _( "Autoroute Module" ) );
@ -169,8 +169,9 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
} }
if( !flags ) if( !flags )
{ {
msg = AddHotkeyName( _( "Move Drawing" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST, ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST,
_( "Move Drawing" ), move_xpm ); msg, move_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_DRAWING, _( "Edit Drawing" ), edit_xpm ); ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_DRAWING, _( "Edit Drawing" ), edit_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING, _( ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING, _(
"Delete Drawing" ), delete_xpm ); "Delete Drawing" ), delete_xpm );
@ -225,8 +226,8 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
case TYPE_MIRE: case TYPE_MIRE:
if( !flags ) if( !flags )
{ {
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_MIRE_REQUEST, msg = AddHotkeyName( _( "Move Target" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
_( "Move Target" ), move_xpm ); ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_MIRE_REQUEST, msg, move_xpm );
msg = AddHotkeyName( _( "Edit Target" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); msg = AddHotkeyName( _( "Edit Target" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_MIRE, ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_MIRE,
msg, edit_xpm ); msg, edit_xpm );
@ -317,7 +318,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
break; break;
case 0: case 0:
if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOPLACE ) if( m_HTOOL_current_state == ID_TOOLBARH_PCB_MODE_MODULE )
{ {
wxMenu* commands = new wxMenu; wxMenu* commands = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU( aPopMenu, commands, ADD_MENUITEM_WITH_SUBMENU( aPopMenu, commands,
@ -341,7 +342,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
aPopMenu->AppendSeparator(); aPopMenu->AppendSeparator();
} }
if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE ) if( m_HTOOL_current_state == ID_TOOLBARH_PCB_MODE_TRACKS )
{ {
wxMenu* commands = new wxMenu; wxMenu* commands = new wxMenu;
aPopMenu->Append( ID_POPUP_PCB_AUTOROUTE_COMMANDS, _( "Autoroute" ), commands ); aPopMenu->Append( ID_POPUP_PCB_AUTOROUTE_COMMANDS, _( "Autoroute" ), commands );
@ -601,8 +602,9 @@ void WinEDA_PcbFrame::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu
_( "Remove Filled Areas in Zone" ), fill_zone_xpm ); _( "Remove Filled Areas in Zone" ), fill_zone_xpm );
} }
msg = AddHotkeyName( _( "Move Zone" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_MOVE_ZONE_OUTLINES, ADD_MENUITEM( zones_menu, ID_POPUP_PCB_MOVE_ZONE_OUTLINES,
_( "Move Zone" ), move_xpm ); msg, move_xpm );
msg = AddHotkeyName( _( "Edit Zone Params" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); msg = AddHotkeyName( _( "Edit Zone Params" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_EDIT_ZONE_PARAMS, ADD_MENUITEM( zones_menu, ID_POPUP_PCB_EDIT_ZONE_PARAMS,
@ -636,14 +638,14 @@ void WinEDA_PcbFrame::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* men
ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_footprint, -1, msg, module_xpm ); ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_footprint, -1, msg, module_xpm );
if( !flags ) if( !flags )
{ {
msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_FOOTPRINT_OR_TRACK ); msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_MOVE_MODULE_REQUEST, ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_MOVE_MODULE_REQUEST,
msg, move_module_xpm ); msg, move_module_xpm );
msg = AddHotkeyName( _( "Drag" ), s_Board_Editor_Hokeys_Descr, HK_DRAG_FOOTPRINT_OR_TRACK ); msg = AddHotkeyName( _( "Drag" ), s_Board_Editor_Hokeys_Descr, HK_DRAG_ITEM );
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_DRAG_MODULE_REQUEST, ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_DRAG_MODULE_REQUEST,
msg, drag_module_xpm ); msg, drag_module_xpm );
} }
msg = AddHotkeyName( _( "Rotate +" ), s_Board_Editor_Hokeys_Descr, HK_ROTATE_FOOTPRINT ); msg = AddHotkeyName( _( "Rotate +" ), s_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM );
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE, ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE,
msg, rotate_module_pos_xpm ); msg, rotate_module_pos_xpm );
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE, ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE,
@ -681,11 +683,15 @@ void WinEDA_PcbFrame::createPopUpMenuForFpTexts( TEXTE_MODULE* FpText, wxMenu* m
ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_Fp_text, -1, msg, footprint_text_xpm ); ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_Fp_text, -1, msg, footprint_text_xpm );
if( !flags ) if( !flags )
{
msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST, ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST,
_( "Move" ), move_field_xpm ); msg, move_field_xpm );
}
msg = AddHotkeyName( _( "Rotate" ), s_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM );
ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_ROTATE_TEXTMODULE, ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_ROTATE_TEXTMODULE,
_( "Rotate" ), rotate_field_xpm ); msg, rotate_field_xpm );
if( !flags ) if( !flags )
{ {
msg = AddHotkeyName( _( "Edit" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); msg = AddHotkeyName( _( "Edit" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
@ -734,10 +740,12 @@ void WinEDA_PcbFrame::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu )
sub_menu_Pad = new wxMenu; sub_menu_Pad = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_Pad, -1, msg, pad_xpm ); ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_Pad, -1, msg, pad_xpm );
msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_MOVE_PAD_REQUEST, ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_MOVE_PAD_REQUEST,
_( "Move" ), move_pad_xpm ); msg, move_pad_xpm );
msg = AddHotkeyName( _( "Drag" ), s_Board_Editor_Hokeys_Descr, HK_DRAG_ITEM );
ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_DRAG_PAD_REQUEST, ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_DRAG_PAD_REQUEST,
_( "Drag" ), drag_pad_xpm ); msg, drag_pad_xpm );
msg = AddHotkeyName( _( "Edit Pad" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); msg = AddHotkeyName( _( "Edit Pad" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_EDIT_PAD, msg, options_pad_xpm ); ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_EDIT_PAD, msg, options_pad_xpm );
@ -761,7 +769,7 @@ void WinEDA_PcbFrame::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu )
ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_DELETE_PAD, ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_DELETE_PAD,
_( "Delete" ), delete_pad_xpm ); _( "Delete" ), delete_pad_xpm );
if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE ) if( m_HTOOL_current_state == ID_TOOLBARH_PCB_MODE_TRACKS )
{ {
menu->Append( ID_POPUP_PCB_AUTOROUTE_PAD, _( "Autoroute Pad" ) ); menu->Append( ID_POPUP_PCB_AUTOROUTE_PAD, _( "Autoroute Pad" ) );
menu->Append( ID_POPUP_PCB_AUTOROUTE_NET, _( "Autoroute Net" ) ); menu->Append( ID_POPUP_PCB_AUTOROUTE_NET, _( "Autoroute Net" ) );
@ -791,11 +799,13 @@ void WinEDA_PcbFrame::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu )
if( !flags ) if( !flags )
{ {
msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST, ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST,
_( "Move" ), move_text_xpm ); msg, move_text_xpm );
} }
msg = AddHotkeyName( _( "Rotate" ), s_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM );
ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_ROTATE_TEXTEPCB, ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_ROTATE_TEXTEPCB,
_( "Rotate" ), rotate_pos_xpm ); msg, rotate_pos_xpm );
msg = AddHotkeyName( _( "Edit" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); msg = AddHotkeyName( _( "Edit" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_EDIT_TEXTEPCB, ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_EDIT_TEXTEPCB,
msg, edit_text_xpm ); msg, edit_text_xpm );

View File

@ -183,8 +183,8 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFrame, WinEDA_BasePcbFrame )
WinEDA_PcbFrame::Tracks_and_Vias_Size_Event ) WinEDA_PcbFrame::Tracks_and_Vias_Size_Event )
EVT_KICAD_CHOICEBOX( ID_AUX_TOOLBAR_PCB_VIA_SIZE, EVT_KICAD_CHOICEBOX( ID_AUX_TOOLBAR_PCB_VIA_SIZE,
WinEDA_PcbFrame::Tracks_and_Vias_Size_Event ) WinEDA_PcbFrame::Tracks_and_Vias_Size_Event )
EVT_TOOL( ID_TOOLBARH_PCB_AUTOPLACE, WinEDA_PcbFrame::AutoPlace ) EVT_TOOL( ID_TOOLBARH_PCB_MODE_MODULE, WinEDA_PcbFrame::AutoPlace )
EVT_TOOL( ID_TOOLBARH_PCB_AUTOROUTE, WinEDA_PcbFrame::AutoPlace ) EVT_TOOL( ID_TOOLBARH_PCB_MODE_TRACKS, WinEDA_PcbFrame::AutoPlace )
EVT_TOOL( ID_TOOLBARH_PCB_FREEROUTE_ACCESS, EVT_TOOL( ID_TOOLBARH_PCB_FREEROUTE_ACCESS,
WinEDA_PcbFrame::Access_to_External_Tool ) WinEDA_PcbFrame::Access_to_External_Tool )

View File

@ -215,8 +215,8 @@ enum pcbnew_ids
ID_MENU_PCB_SWAP_LAYERS, ID_MENU_PCB_SWAP_LAYERS,
ID_GEN_EXPORT_FILE_VRML, ID_GEN_EXPORT_FILE_VRML,
ID_TOOLBARH_PCB_AUTOPLACE, ID_TOOLBARH_PCB_MODE_MODULE,
ID_TOOLBARH_PCB_AUTOROUTE, ID_TOOLBARH_PCB_MODE_TRACKS,
ID_TOOLBARH_PCB_FREEROUTE_ACCESS, ID_TOOLBARH_PCB_FREEROUTE_ACCESS,
ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR,

View File

@ -216,8 +216,12 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
#endif #endif
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
msg = AddHotkeyName( HELP_UNDO, s_Board_Editor_Hokeys_Descr,
HK_UNDO, false );
m_HToolBar->AddTool( wxID_UNDO, wxEmptyString, wxBitmap( undo_xpm ), m_HToolBar->AddTool( wxID_UNDO, wxEmptyString, wxBitmap( undo_xpm ),
HELP_UNDO ); HELP_UNDO );
msg = AddHotkeyName( HELP_REDO, s_Board_Editor_Hokeys_Descr,
HK_REDO, false );
m_HToolBar->AddTool( wxID_REDO, wxEmptyString, wxBitmap( redo_xpm ), m_HToolBar->AddTool( wxID_REDO, wxEmptyString, wxBitmap( redo_xpm ),
HELP_REDO ); HELP_REDO );
@ -270,13 +274,13 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
*LayerPairBitmap, SEL_LAYER_HELP ); *LayerPairBitmap, SEL_LAYER_HELP );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_TOOLBARH_PCB_AUTOPLACE, wxEmptyString, m_HToolBar->AddTool( ID_TOOLBARH_PCB_MODE_MODULE, wxEmptyString,
wxBitmap( mode_module_xpm ), wxBitmap( mode_module_xpm ),
_( "Manual and automatic move or place of modules" ), _( "Mode footprint: manual and automatic move and place modules" ),
wxITEM_CHECK ); wxITEM_CHECK );
m_HToolBar->AddTool( ID_TOOLBARH_PCB_AUTOROUTE, wxEmptyString, m_HToolBar->AddTool( ID_TOOLBARH_PCB_MODE_TRACKS, wxEmptyString,
wxBitmap( mode_track_xpm ), wxBitmap( mode_track_xpm ),
_( "Mode Track and Autorouting" ), wxITEM_CHECK ); _( "Mode track: autorouting" ), wxITEM_CHECK );
// Fast call to FreeROUTE Web Bases router // Fast call to FreeROUTE Web Bases router
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();