2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file hotkeys_board_editor.cpp
|
|
|
|
*/
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "wxPcbStruct.h"
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "pcbcommon.h"
|
|
|
|
|
|
|
|
#include "class_board.h"
|
|
|
|
#include "class_module.h"
|
|
|
|
#include "class_track.h"
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "pcbnew.h"
|
|
|
|
#include "pcbnew_id.h"
|
2010-11-24 15:10:33 +00:00
|
|
|
#include "hotkeys.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
/* How to add a new hotkey:
|
|
|
|
* see hotkeys.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-09-07 09:27:02 +00:00
|
|
|
void PCB_EDIT_FRAME::RecordMacros(wxDC* aDC, int aNumber)
|
|
|
|
{
|
2011-09-29 16:49:40 +00:00
|
|
|
assert( aNumber >= 0 );
|
|
|
|
assert( aNumber < 10 );
|
2011-09-07 09:27:02 +00:00
|
|
|
wxString msg, tmp;
|
|
|
|
|
|
|
|
if( m_RecordingMacros < 0 )
|
|
|
|
{
|
2011-09-16 14:13:02 +00:00
|
|
|
m_RecordingMacros = aNumber;
|
2011-09-29 16:49:40 +00:00
|
|
|
m_Macros[aNumber].m_StartPosition = GetScreen()->GetCrossHairPosition( false );
|
2011-09-07 09:27:02 +00:00
|
|
|
m_Macros[aNumber].m_Record.clear();
|
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
msg.Printf( wxT( "%s %d" ), _( "Recording macros" ), aNumber );
|
|
|
|
SetStatusText( msg );
|
2011-09-07 09:27:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_RecordingMacros = -1;
|
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
msg.Printf( wxT( "%s %d %s" ), _( "Macros" ), aNumber, _( "recorded" ) );
|
|
|
|
SetStatusText( msg );
|
2011-09-07 09:27:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
void PCB_EDIT_FRAME::CallMacros( wxDC* aDC, const wxPoint& aPosition, int aNumber )
|
2011-09-07 09:27:02 +00:00
|
|
|
{
|
|
|
|
PCB_SCREEN* screen = GetScreen();
|
|
|
|
wxPoint tPosition;
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
msg.Printf( wxT( "%s %d" ), _( "Call macros" ), aNumber );
|
2011-09-07 09:27:02 +00:00
|
|
|
SetStatusText( msg );
|
|
|
|
|
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetEventObject( this );
|
|
|
|
|
|
|
|
tPosition = screen->GetNearestGridPosition( aPosition );
|
|
|
|
|
|
|
|
DrawPanel->CrossHairOff( aDC );
|
|
|
|
screen->SetMousePosition( tPosition );
|
|
|
|
GeneralControl( aDC, tPosition );
|
|
|
|
|
2011-09-16 14:13:02 +00:00
|
|
|
for( std::list<MACROS_RECORD>::iterator i = m_Macros[aNumber].m_Record.begin();
|
|
|
|
i != m_Macros[aNumber].m_Record.end();
|
|
|
|
i++ )
|
2011-09-07 09:27:02 +00:00
|
|
|
{
|
2011-09-10 09:44:11 +00:00
|
|
|
wxPoint tmpPos = screen->GetNearestGridPosition( tPosition + i->m_Position );
|
2011-09-07 09:27:02 +00:00
|
|
|
|
|
|
|
screen->SetMousePosition( tmpPos );
|
|
|
|
|
|
|
|
GeneralControl( aDC, tmpPos, i->m_HotkeyCode );
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd.SetId( ID_ZOOM_REDRAW );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
|
|
|
|
DrawPanel->CrossHairOn( aDC );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition,
|
|
|
|
EDA_ITEM* aItem )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
if( aHotkeyCode == 0 )
|
|
|
|
return;
|
|
|
|
|
2011-02-01 15:46:25 +00:00
|
|
|
wxPoint pos;
|
2010-11-24 15:10:33 +00:00
|
|
|
bool itemCurrentlyEdited = (GetCurItem() && GetCurItem()->m_Flags);
|
|
|
|
MODULE* module = NULL;
|
|
|
|
int evt_type = 0; //Used to post a wxCommandEvent on demand
|
2011-02-01 15:46:25 +00:00
|
|
|
PCB_SCREEN* screen = GetScreen();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
/* Convert lower to upper case
|
|
|
|
* (the usual toupper function has problem with non ascii codes like function keys
|
|
|
|
*/
|
|
|
|
if( (aHotkeyCode >= 'a') && (aHotkeyCode <= 'z') )
|
|
|
|
aHotkeyCode += 'A' - 'a';
|
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY* HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, common_Hotkey_List );
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
if( HK_Descr == NULL )
|
|
|
|
HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, board_edit_Hotkey_List );
|
|
|
|
|
|
|
|
if( HK_Descr == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-09-16 14:13:02 +00:00
|
|
|
if( (m_RecordingMacros != -1)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_RECORD_MACROS_1)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_CALL_MACROS_1)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_RECORD_MACROS_2)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_CALL_MACROS_2)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_RECORD_MACROS_3)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_CALL_MACROS_3)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_RECORD_MACROS_4)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_CALL_MACROS_4)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_RECORD_MACROS_5)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_CALL_MACROS_5)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_RECORD_MACROS_6)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_CALL_MACROS_6)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_RECORD_MACROS_7)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_CALL_MACROS_7)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_RECORD_MACROS_8)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_CALL_MACROS_8)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_RECORD_MACROS_9)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_CALL_MACROS_9)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_RECORD_MACROS_0)
|
|
|
|
&& (HK_Descr->m_Idcommand != HK_CALL_MACROS_0) )
|
2011-09-07 09:27:02 +00:00
|
|
|
{
|
|
|
|
MACROS_RECORD macros_record;
|
|
|
|
macros_record.m_HotkeyCode = aHotkeyCode;
|
|
|
|
macros_record.m_Idcommand = HK_Descr->m_Idcommand;
|
2011-09-16 14:13:02 +00:00
|
|
|
macros_record.m_Position = screen->GetNearestGridPosition( aPosition ) -
|
|
|
|
m_Macros[m_RecordingMacros].m_StartPosition;
|
|
|
|
m_Macros[m_RecordingMacros].m_Record.push_back( macros_record );
|
2011-09-07 09:27:02 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
// Create a wxCommandEvent that will be posted in some hot keys functions
|
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetEventObject( this );
|
|
|
|
|
2011-09-09 11:02:03 +00:00
|
|
|
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
int ll;
|
2011-09-09 11:02:03 +00:00
|
|
|
unsigned int cnt;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
switch( HK_Descr->m_Idcommand )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case HK_NOT_FOUND:
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
2011-09-07 09:27:02 +00:00
|
|
|
case HK_RECORD_MACROS_0:
|
2011-09-16 14:13:02 +00:00
|
|
|
RecordMacros( aDC, 0 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RECORD_MACROS_1:
|
2011-09-16 14:13:02 +00:00
|
|
|
RecordMacros( aDC, 1 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RECORD_MACROS_2:
|
2011-09-16 14:13:02 +00:00
|
|
|
RecordMacros( aDC, 2 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RECORD_MACROS_3:
|
2011-09-16 14:13:02 +00:00
|
|
|
RecordMacros( aDC, 3 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RECORD_MACROS_4:
|
2011-09-16 14:13:02 +00:00
|
|
|
RecordMacros( aDC, 4 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RECORD_MACROS_5:
|
2011-09-16 14:13:02 +00:00
|
|
|
RecordMacros( aDC, 5 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RECORD_MACROS_6:
|
2011-09-16 14:13:02 +00:00
|
|
|
RecordMacros( aDC, 6 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RECORD_MACROS_7:
|
2011-09-16 14:13:02 +00:00
|
|
|
RecordMacros( aDC, 7 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RECORD_MACROS_8:
|
2011-09-16 14:13:02 +00:00
|
|
|
RecordMacros( aDC, 8 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RECORD_MACROS_9:
|
2011-09-16 14:13:02 +00:00
|
|
|
RecordMacros( aDC, 9 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CALL_MACROS_0:
|
2011-09-16 14:13:02 +00:00
|
|
|
CallMacros( aDC, screen->GetCrossHairPosition( false ), 0 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CALL_MACROS_1:
|
2011-09-16 14:13:02 +00:00
|
|
|
CallMacros( aDC, screen->GetCrossHairPosition( false ), 1 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CALL_MACROS_2:
|
2011-09-16 14:13:02 +00:00
|
|
|
CallMacros( aDC, screen->GetCrossHairPosition( false ), 2 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CALL_MACROS_3:
|
2011-09-16 14:13:02 +00:00
|
|
|
CallMacros( aDC, screen->GetCrossHairPosition( false ), 3 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CALL_MACROS_4:
|
2011-09-16 14:13:02 +00:00
|
|
|
CallMacros( aDC, screen->GetCrossHairPosition( false ), 4 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CALL_MACROS_5:
|
2011-09-16 14:13:02 +00:00
|
|
|
CallMacros( aDC, screen->GetCrossHairPosition( false ), 5 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CALL_MACROS_6:
|
2011-09-16 14:13:02 +00:00
|
|
|
CallMacros( aDC, screen->GetCrossHairPosition( false ), 6 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CALL_MACROS_7:
|
2011-09-16 14:13:02 +00:00
|
|
|
CallMacros( aDC, screen->GetCrossHairPosition( false ), 7 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CALL_MACROS_8:
|
2011-09-16 14:13:02 +00:00
|
|
|
CallMacros( aDC, screen->GetCrossHairPosition( false ), 8 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CALL_MACROS_9:
|
2011-09-16 14:13:02 +00:00
|
|
|
CallMacros( aDC, screen->GetCrossHairPosition( false ), 9 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 11:02:03 +00:00
|
|
|
case HK_SWITCH_TRACK_WIDTH_TO_NEXT:
|
2011-09-16 14:13:02 +00:00
|
|
|
GetBoard()->m_TrackWidthSelector = ( GetBoard()->m_TrackWidthSelector + 1 ) %
|
|
|
|
GetBoard()->m_TrackWidthList.size();
|
2011-09-09 11:02:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_TRACK_WIDTH_TO_PREVIOUS:
|
|
|
|
if( GetBoard()->m_TrackWidthSelector == 0 )
|
|
|
|
GetBoard()->m_TrackWidthSelector = GetBoard()->m_TrackWidthList.size();
|
|
|
|
|
|
|
|
GetBoard()->m_TrackWidthSelector--;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_GRID_TO_FASTGRID1:
|
|
|
|
if( m_SelGridBox )
|
|
|
|
{
|
|
|
|
m_SelGridBox->SetSelection( m_FastGrid1 );
|
|
|
|
cmd.SetEventType( wxEVT_COMMAND_COMBOBOX_SELECTED );
|
|
|
|
OnSelectGrid( cmd );
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-09-09 11:02:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_GRID_TO_FASTGRID2:
|
|
|
|
if( m_SelGridBox )
|
|
|
|
{
|
|
|
|
m_SelGridBox->SetSelection( m_FastGrid2 );
|
|
|
|
cmd.SetEventType( wxEVT_COMMAND_COMBOBOX_SELECTED );
|
|
|
|
OnSelectGrid( cmd );
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-09-09 11:02:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_GRID_TO_NEXT:
|
|
|
|
if( m_SelGridBox )
|
|
|
|
{
|
2011-09-16 14:13:02 +00:00
|
|
|
m_SelGridBox->SetSelection( ( m_SelGridBox->GetSelection() + 1 ) %
|
|
|
|
m_SelGridBox->GetCount() );
|
2011-09-09 11:02:03 +00:00
|
|
|
cmd.SetEventType( wxEVT_COMMAND_COMBOBOX_SELECTED );
|
|
|
|
OnSelectGrid( cmd );
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-09-09 11:02:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_GRID_TO_PREVIOUS:
|
|
|
|
if( m_SelGridBox )
|
|
|
|
{
|
|
|
|
cnt = m_SelGridBox->GetSelection();
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-09-09 11:02:03 +00:00
|
|
|
if ( cnt == 0 )
|
|
|
|
cnt = m_SelGridBox->GetCount() - 1;
|
|
|
|
else
|
|
|
|
cnt--;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-09-09 11:02:03 +00:00
|
|
|
m_SelGridBox->SetSelection( cnt );
|
|
|
|
cmd.SetEventType( wxEVT_COMMAND_COMBOBOX_SELECTED );
|
|
|
|
OnSelectGrid( cmd );
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-09-09 11:02:03 +00:00
|
|
|
break;
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
case HK_SWITCH_LAYER_TO_PREVIOUS:
|
|
|
|
ll = getActiveLayer();
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( (ll <= LAYER_N_BACK) || (ll > LAYER_N_FRONT) )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( GetBoard()->GetCopperLayerCount() < 2 ) // Single layer
|
|
|
|
ll = LAYER_N_BACK;
|
|
|
|
else if( ll == LAYER_N_FRONT )
|
2011-09-16 14:13:02 +00:00
|
|
|
ll = MAX( LAYER_N_BACK, GetBoard()->GetCopperLayerCount() - 2 );
|
2010-11-24 15:10:33 +00:00
|
|
|
else
|
|
|
|
ll--;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
SwitchLayer( aDC, ll );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_NEXT:
|
|
|
|
ll = getActiveLayer();
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( (ll < LAYER_N_BACK) || (ll >= LAYER_N_FRONT) )
|
|
|
|
break;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( GetBoard()->GetCopperLayerCount() < 2 ) // Single layer
|
|
|
|
ll = LAYER_N_BACK;
|
|
|
|
else if( ll >= GetBoard()->GetCopperLayerCount() - 2 )
|
|
|
|
ll = LAYER_N_FRONT;
|
|
|
|
else
|
|
|
|
ll++;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
SwitchLayer( aDC, ll );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_COMPONENT:
|
|
|
|
SwitchLayer( aDC, LAYER_N_FRONT );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_COPPER:
|
|
|
|
SwitchLayer( aDC, LAYER_N_BACK );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER1:
|
|
|
|
SwitchLayer( aDC, LAYER_N_2 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER2:
|
|
|
|
SwitchLayer( aDC, LAYER_N_3 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER3:
|
|
|
|
SwitchLayer( aDC, LAYER_N_4 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER4:
|
|
|
|
SwitchLayer( aDC, LAYER_N_5 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER5:
|
|
|
|
SwitchLayer( aDC, LAYER_N_6 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER6:
|
|
|
|
SwitchLayer( aDC, LAYER_N_7 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_HELP: // Display Current hotkey list
|
|
|
|
DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_IN:
|
|
|
|
evt_type = ID_POPUP_ZOOM_IN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_OUT:
|
|
|
|
evt_type = ID_POPUP_ZOOM_OUT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_REDRAW:
|
|
|
|
evt_type = ID_ZOOM_REDRAW;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_AUTO:
|
|
|
|
evt_type = ID_ZOOM_PAGE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_CENTER:
|
|
|
|
evt_type = ID_POPUP_ZOOM_CENTER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ADD_MODULE:
|
2011-02-21 13:54:29 +00:00
|
|
|
evt_type = ID_PCB_MODULE_BUTT;
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_UNDO:
|
|
|
|
case HK_REDO:
|
|
|
|
if( !itemCurrentlyEdited )
|
|
|
|
{
|
2011-02-01 15:46:25 +00:00
|
|
|
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent );
|
2010-11-24 15:10:33 +00:00
|
|
|
wxPostEvent( this, event );
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RESET_LOCAL_COORD: /*Reset the relative coord */
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition();
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_UNITS:
|
|
|
|
g_UserUnit = (g_UserUnit == INCHES) ? MILLIMETRES : INCHES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_TRACK_DISPLAY_MODE:
|
|
|
|
DisplayOpt.DisplayPcbTrackFill ^= 1;
|
|
|
|
DisplayOpt.DisplayPcbTrackFill &= 1;
|
|
|
|
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
|
|
|
|
DrawPanel->Refresh();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_DELETE:
|
|
|
|
OnHotkeyDeleteItem( aDC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_BACK_SPACE:
|
|
|
|
if( /*m_ID_current_state == ID_TRACK_BUTT &&*/ (getActiveLayer() <= LAYER_N_FRONT) )
|
|
|
|
{
|
|
|
|
if( !itemCurrentlyEdited )
|
|
|
|
{
|
|
|
|
// 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.
|
|
|
|
BOARD_ITEM * item = PcbGeneralLocateAndDisplay();
|
|
|
|
|
|
|
|
// don't let backspace delete modules!!
|
|
|
|
if( item && item->IsTrack() )
|
|
|
|
{
|
|
|
|
Delete_Segment( aDC, (TRACK*) item );
|
|
|
|
SetCurItem( NULL );
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
OnModify();
|
|
|
|
}
|
|
|
|
else if( GetCurItem()->IsTrack() )
|
|
|
|
{
|
|
|
|
// then an element is being edited - remove the last segment.
|
|
|
|
// simple lines for debugger:
|
|
|
|
TRACK* track = (TRACK*) GetCurItem();
|
|
|
|
track = Delete_Segment( aDC, track );
|
|
|
|
SetCurItem( track );
|
|
|
|
OnModify();
|
|
|
|
}
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_END_TRACK:
|
2011-02-21 13:54:29 +00:00
|
|
|
if( itemCurrentlyEdited && GetCurItem()->IsTrack() && GetCurItem()->IsNew() )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
// A new track is in progress: call to End_Route()
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2010-11-24 15:10:33 +00:00
|
|
|
End_Route( (TRACK*) GetCurItem(), aDC );
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_GET_AND_MOVE_FOOTPRINT:
|
|
|
|
if( !itemCurrentlyEdited )
|
|
|
|
evt_type = ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_FIND_ITEM:
|
|
|
|
if( !itemCurrentlyEdited )
|
|
|
|
evt_type = ID_FIND_ITEMS;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_LOAD_BOARD:
|
|
|
|
if( !itemCurrentlyEdited )
|
|
|
|
evt_type = ID_LOAD_FILE ;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SAVE_BOARD:
|
|
|
|
if( !itemCurrentlyEdited )
|
|
|
|
evt_type = ID_SAVE_BOARD;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ADD_MICROVIA: // Place a micro via if a track is in progress
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() != ID_TRACK_BUTT )
|
2010-11-24 15:10:33 +00:00
|
|
|
return;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-02-01 15:46:25 +00:00
|
|
|
if( !itemCurrentlyEdited ) // no track in progress: nothing to do
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( GetCurItem()->Type() != PCB_TRACE_T ) // Should not occur
|
2010-11-24 15:10:33 +00:00
|
|
|
return;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
if( !GetCurItem()->IsNew() )
|
2010-11-24 15:10:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// place micro via and switch layer
|
|
|
|
if( IsMicroViaAcceptable() )
|
|
|
|
evt_type = ID_POPUP_PCB_PLACE_MICROVIA;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ADD_VIA: // Switch to alternate layer and Place a via if a track is in progress
|
|
|
|
if( !itemCurrentlyEdited ) // no track in progress: switch layer only
|
|
|
|
{
|
|
|
|
Other_Layer_Route( NULL, aDC );
|
|
|
|
break;
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() != ID_TRACK_BUTT )
|
2010-11-24 15:10:33 +00:00
|
|
|
return;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( GetCurItem()->Type() != PCB_TRACE_T )
|
2010-11-24 15:10:33 +00:00
|
|
|
return;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
if( !GetCurItem()->IsNew() )
|
2010-11-24 15:10:33 +00:00
|
|
|
return;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
evt_type = ID_POPUP_PCB_PLACE_VIA;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_TRACK_POSTURE:
|
|
|
|
/* change the position of initial segment when creating new tracks
|
|
|
|
* switch from _/ to -\ .
|
|
|
|
*/
|
|
|
|
evt_type = ID_POPUP_PCB_SWITCH_TRACK_POSTURE ;
|
|
|
|
break;
|
|
|
|
|
2011-08-30 09:42:42 +00:00
|
|
|
case HK_DRAG_TRACK_KEEP_SLOPE:
|
|
|
|
OnHotkeyMoveItem( HK_DRAG_TRACK_KEEP_SLOPE );
|
|
|
|
break;
|
|
|
|
|
2011-09-07 09:27:02 +00:00
|
|
|
case HK_PLACE_ITEM:
|
|
|
|
OnHotkeyPlaceItem( aDC );
|
|
|
|
break;
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
case HK_ADD_NEW_TRACK: // Start new track
|
|
|
|
if( getActiveLayer() > LAYER_N_FRONT )
|
|
|
|
break;
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() != ID_TRACK_BUTT && !itemCurrentlyEdited )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
cmd.SetId( ID_TRACK_BUTT );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
}
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() != ID_TRACK_BUTT )
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if( !itemCurrentlyEdited ) // no track in progress:
|
|
|
|
{
|
|
|
|
TRACK* track = Begin_Route( NULL, aDC );
|
|
|
|
SetCurItem( track );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( track )
|
|
|
|
DrawPanel->m_AutoPAN_Request = true;
|
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
else if( GetCurItem()->IsNew() )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
TRACK* track = Begin_Route( (TRACK*) GetCurItem(), aDC );
|
|
|
|
|
|
|
|
// 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 );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
DrawPanel->m_AutoPAN_Request = true;
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_EDIT_ITEM: // Edit board item
|
|
|
|
OnHotkeyEditItem( HK_EDIT_ITEM );
|
|
|
|
break;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
if( !itemCurrentlyEdited )
|
2011-02-01 15:46:25 +00:00
|
|
|
{
|
|
|
|
pos = screen->RefPos( true );
|
2011-09-16 18:54:04 +00:00
|
|
|
module = GetBoard()->GetFootprint( pos, screen->m_Active_Layer, true );
|
2011-02-01 15:46:25 +00:00
|
|
|
}
|
2011-10-01 19:24:27 +00:00
|
|
|
else if( GetCurItem()->Type() == PCB_MODULE_T )
|
2011-02-01 15:46:25 +00:00
|
|
|
{
|
2010-11-24 15:10:33 +00:00
|
|
|
module = (MODULE*) GetCurItem();
|
2011-02-01 15:46:25 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( module )
|
|
|
|
{
|
|
|
|
SetCurItem( module );
|
|
|
|
module->SetLocked( !module->IsLocked() );
|
|
|
|
module->DisplayInfo( this );
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_DRAG_ITEM: // Start drag module or track segment
|
|
|
|
OnHotkeyMoveItem( HK_DRAG_ITEM );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_MOVE_ITEM: // Start move item
|
|
|
|
OnHotkeyMoveItem( HK_MOVE_ITEM );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ROTATE_ITEM: // Rotation
|
|
|
|
OnHotkeyRotateItem( HK_ROTATE_ITEM );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_FLIP_FOOTPRINT: // move to other side
|
|
|
|
OnHotkeyRotateItem( HK_FLIP_FOOTPRINT );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( evt_type != 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
evt.SetEventObject( this );
|
|
|
|
evt.SetId( evt_type );
|
2011-09-07 09:27:02 +00:00
|
|
|
GetEventHandler()->ProcessEvent( evt );
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
bool PCB_EDIT_FRAME::OnHotkeyDeleteItem( wxDC* aDC )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM* item = GetCurItem();
|
|
|
|
bool ItemFree = (item == NULL) || (item->m_Flags == 0);
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
switch( GetToolId() )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
case ID_TRACK_BUTT:
|
|
|
|
if( getActiveLayer() > LAYER_N_FRONT )
|
|
|
|
return false;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( ItemFree )
|
|
|
|
{
|
|
|
|
item = PcbGeneralLocateAndDisplay();
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( item && !item->IsTrack( ) )
|
|
|
|
return false;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
Delete_Track( aDC, (TRACK*) item );
|
|
|
|
}
|
|
|
|
else if( item->IsTrack( ) )
|
|
|
|
{
|
|
|
|
// simple lines for debugger:
|
|
|
|
TRACK* track = (TRACK*) item;
|
|
|
|
track = Delete_Segment( aDC, track );
|
|
|
|
SetCurItem( track );
|
|
|
|
OnModify();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_PCB_MODULE_BUTT:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( ItemFree )
|
|
|
|
{
|
2011-02-01 15:46:25 +00:00
|
|
|
wxPoint pos = GetScreen()->RefPos( false );
|
2011-09-16 18:54:04 +00:00
|
|
|
MODULE* module = GetBoard()->GetFootprint( pos, ALL_LAYERS, false );
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( module == NULL )
|
|
|
|
return false;
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( !IsOK( this, _( "Delete module?" ) ) )
|
|
|
|
return false;
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
RemoveStruct( module, aDC );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if( ItemFree )
|
|
|
|
{
|
|
|
|
item = PcbGeneralLocateAndDisplay();
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( item == NULL )
|
|
|
|
return false;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( (item->Type() == PCB_MODULE_T) && !IsOK( this, _( "Delete module?" ) ) )
|
2010-11-24 15:10:33 +00:00
|
|
|
return false;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
RemoveStruct( item, aDC );
|
|
|
|
}
|
|
|
|
else
|
2011-09-14 15:08:44 +00:00
|
|
|
return false;
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OnModify();
|
|
|
|
SetCurItem( NULL );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
bool PCB_EDIT_FRAME::OnHotkeyEditItem( int aIdCommand )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
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() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_VIA_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_EDIT_TRACKSEG;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_EDIT_TEXTEPCB;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_EDIT_MODULE;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
// Post a EDIT_MODULE event here to prevent pads
|
|
|
|
// from being edited by hotkeys.
|
|
|
|
// Process_Special_Functions takes care of finding
|
|
|
|
// the parent.
|
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_EDIT_MODULE;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_EDIT_MIRE;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_DIMENSION_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_EDIT_DIMENSION;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_EDIT_TEXTMODULE;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_EDIT_DRAWING;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_AREA_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_EDIT_ZONE_PARAMS;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( evt_type != 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
evt.SetEventObject( this );
|
|
|
|
evt.SetId( evt_type );
|
2011-09-07 09:27:02 +00:00
|
|
|
GetEventHandler()->ProcessEvent( evt );
|
2010-11-24 15:10:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
bool PCB_EDIT_FRAME::OnHotkeyMoveItem( int aIdCommand )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
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() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_VIA_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_TRACK_NODE;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_DRAG_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_DRAG_TRACK_SEGMENT;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-08-30 09:42:42 +00:00
|
|
|
if( aIdCommand == HK_DRAG_TRACK_KEEP_SLOPE )
|
|
|
|
evt_type = ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_MODULE_REQUEST;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_DRAG_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_DRAG_MODULE_REQUEST;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
// Post MODULE_REQUEST events here to prevent pads
|
|
|
|
// from being moved or dragged by hotkeys.
|
|
|
|
// Process_Special_Functions takes care of finding
|
|
|
|
// the parent.
|
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_MODULE_REQUEST;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_DRAG_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_DRAG_MODULE_REQUEST;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_MIRE_REQUEST;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_AREA_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_ZONE_OUTLINES;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_DRAG_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_DRAG_ZONE_OUTLINE_SEGMENT;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_DRAWING_REQUEST;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( evt_type != 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
evt.SetEventObject( this );
|
|
|
|
evt.SetId( evt_type );
|
2011-09-07 09:27:02 +00:00
|
|
|
GetEventHandler()->ProcessEvent( evt );
|
2010-11-24 15:10:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-09-07 09:27:02 +00:00
|
|
|
bool PCB_EDIT_FRAME::OnHotkeyPlaceItem( wxDC* aDC )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = GetCurItem();
|
|
|
|
bool no_tool = GetToolId() == ID_NO_TOOL_SELECTED;
|
|
|
|
bool itemCurrentlyEdited = item && item->m_Flags;
|
|
|
|
|
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
|
|
|
|
|
|
|
if( itemCurrentlyEdited )
|
|
|
|
{
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = true;
|
|
|
|
DrawPanel->CrossHairOff( aDC );
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_VIA_T:
|
2011-09-07 09:27:02 +00:00
|
|
|
if( item->m_Flags & IS_DRAGGED )
|
|
|
|
PlaceDraggedOrMovedTrackSegment( (TRACK*) item, aDC );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2011-09-07 09:27:02 +00:00
|
|
|
Place_Texte_Pcb( (TEXTE_PCB*) item, aDC );
|
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2011-09-07 09:27:02 +00:00
|
|
|
PlaceTexteModule( (TEXTE_MODULE*) item, aDC );
|
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2011-09-07 09:27:02 +00:00
|
|
|
PlacePad( (D_PAD*) item, aDC );
|
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2011-09-16 14:13:02 +00:00
|
|
|
PlaceModule( (MODULE*) item, aDC );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
|
|
|
PlaceTarget( (PCB_TARGET*) item, aDC );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
2011-09-07 09:27:02 +00:00
|
|
|
if( no_tool ) // when no tools: existing item moving.
|
|
|
|
Place_DrawItem( (DRAWSEGMENT*) item, aDC );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = false;
|
|
|
|
DrawPanel->CrossHairOn( aDC );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-09-07 09:27:02 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
bool PCB_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
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() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
|
|
|
evt_type = ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_FLIP_FOOTPRINT ) // move to other side
|
|
|
|
evt_type = ID_POPUP_PCB_CHANGE_SIDE_MODULE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
|
|
|
evt_type = ID_POPUP_PCB_ROTATE_TEXTEPCB;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
|
|
|
evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( evt_type != 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
evt.SetEventObject( this );
|
|
|
|
evt.SetId( evt_type );
|
2011-09-07 09:27:02 +00:00
|
|
|
GetEventHandler()->ProcessEvent( evt );
|
2010-11-24 15:10:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|