2013-10-14 15:29:16 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras@wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file hotkeys_board_editor.cpp
|
|
|
|
*/
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <pcbcommon.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_track.h>
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <hotkeys.h>
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
2012-12-01 20:03:33 +00:00
|
|
|
wxASSERT( aNumber >= 0 && aNumber < 10 );
|
|
|
|
wxString msg;
|
2011-09-07 09:27:02 +00:00
|
|
|
|
|
|
|
if( m_RecordingMacros < 0 )
|
|
|
|
{
|
2011-09-16 14:13:02 +00:00
|
|
|
m_RecordingMacros = aNumber;
|
2013-08-03 05:15:23 +00:00
|
|
|
m_Macros[aNumber].m_StartPosition = GetCrossHairPosition( false );
|
2011-09-07 09:27:02 +00:00
|
|
|
m_Macros[aNumber].m_Record.clear();
|
|
|
|
|
2012-12-01 20:03:33 +00:00
|
|
|
msg.Printf( _( "Recording macro %d" ), aNumber );
|
2011-09-29 16:49:40 +00:00
|
|
|
SetStatusText( msg );
|
2011-09-07 09:27:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_RecordingMacros = -1;
|
|
|
|
|
2012-12-01 20:03:33 +00:00
|
|
|
msg.Printf( _( "Macro %d recorded" ), aNumber );
|
2011-09-29 16:49:40 +00:00
|
|
|
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
|
|
|
{
|
|
|
|
wxPoint tPosition;
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
2012-12-01 20:03:33 +00:00
|
|
|
msg.Printf( _( "Call macro %d" ), aNumber );
|
2011-09-07 09:27:02 +00:00
|
|
|
SetStatusText( msg );
|
|
|
|
|
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetEventObject( this );
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
tPosition = GetNearestGridPosition( aPosition );
|
2011-09-07 09:27:02 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( aDC );
|
2013-08-03 05:15:23 +00:00
|
|
|
SetMousePosition( tPosition );
|
2011-09-07 09:27:02 +00:00
|
|
|
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
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint tmpPos = GetNearestGridPosition( tPosition + i->m_Position );
|
2011-09-07 09:27:02 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
SetMousePosition( tmpPos );
|
2011-09-07 09:27:02 +00:00
|
|
|
|
|
|
|
GeneralControl( aDC, tmpPos, i->m_HotkeyCode );
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd.SetId( ID_ZOOM_REDRAW );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOn( aDC );
|
2011-09-07 09:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2013-09-20 10:52:33 +00:00
|
|
|
bool itemCurrentlyEdited = GetCurItem() && GetCurItem()->GetFlags();
|
2010-11-24 15:10:33 +00:00
|
|
|
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 );
|
|
|
|
|
2011-12-17 21:21:03 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( HK_Descr == NULL )
|
|
|
|
return;
|
|
|
|
|
2012-12-01 20:03:33 +00:00
|
|
|
int hk_id = HK_Descr->m_Idcommand;
|
|
|
|
|
|
|
|
if( (m_RecordingMacros != -1) &&
|
|
|
|
!( hk_id > HK_MACRO_ID_BEGIN && hk_id < HK_MACRO_ID_END) )
|
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;
|
2013-08-03 05:15:23 +00:00
|
|
|
macros_record.m_Position = GetNearestGridPosition( aPosition ) -
|
2013-10-14 15:29:16 +00:00
|
|
|
m_Macros[m_RecordingMacros].m_StartPosition;
|
2011-09-16 14:13:02 +00:00
|
|
|
m_Macros[m_RecordingMacros].m_Record.push_back( macros_record );
|
2012-12-01 20:03:33 +00:00
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Add key [%c] in macro %d" ), aHotkeyCode, m_RecordingMacros );
|
|
|
|
SetStatusText( msg );
|
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 );
|
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM ll;
|
2011-09-09 11:02:03 +00:00
|
|
|
unsigned int cnt;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2012-12-01 20:03:33 +00:00
|
|
|
switch( hk_id )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case HK_NOT_FOUND:
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
2011-09-07 09:27:02 +00:00
|
|
|
case HK_RECORD_MACROS_0:
|
|
|
|
case HK_RECORD_MACROS_1:
|
|
|
|
case HK_RECORD_MACROS_2:
|
|
|
|
case HK_RECORD_MACROS_3:
|
|
|
|
case HK_RECORD_MACROS_4:
|
|
|
|
case HK_RECORD_MACROS_5:
|
|
|
|
case HK_RECORD_MACROS_6:
|
|
|
|
case HK_RECORD_MACROS_7:
|
|
|
|
case HK_RECORD_MACROS_8:
|
|
|
|
case HK_RECORD_MACROS_9:
|
2012-12-01 20:03:33 +00:00
|
|
|
RecordMacros( aDC, hk_id - HK_RECORD_MACROS_0 );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CALL_MACROS_0:
|
|
|
|
case HK_CALL_MACROS_1:
|
|
|
|
case HK_CALL_MACROS_2:
|
|
|
|
case HK_CALL_MACROS_3:
|
|
|
|
case HK_CALL_MACROS_4:
|
|
|
|
case HK_CALL_MACROS_5:
|
|
|
|
case HK_CALL_MACROS_6:
|
|
|
|
case HK_CALL_MACROS_7:
|
|
|
|
case HK_CALL_MACROS_8:
|
|
|
|
case HK_CALL_MACROS_9:
|
2013-08-03 05:15:23 +00:00
|
|
|
CallMacros( aDC, GetCrossHairPosition( false ), hk_id - HK_CALL_MACROS_0 );
|
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-12-29 20:11:42 +00:00
|
|
|
if( GetCanvas()->IsMouseCaptured() )
|
|
|
|
GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );
|
2011-12-22 15:41:16 +00:00
|
|
|
|
2013-10-14 15:29:16 +00:00
|
|
|
if( GetBoard()->GetTrackWidthIndex() < GetBoard()->m_TrackWidthList.size() - 1 )
|
2013-04-25 07:05:33 +00:00
|
|
|
GetBoard()->SetTrackWidthIndex( GetBoard()->GetTrackWidthIndex() + 1 );
|
|
|
|
else
|
|
|
|
GetBoard()->SetTrackWidthIndex( 0 );
|
2011-12-22 15:41:16 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
if( GetCanvas()->IsMouseCaptured() )
|
|
|
|
GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );
|
2011-12-22 15:41:16 +00:00
|
|
|
|
2011-09-09 11:02:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_TRACK_WIDTH_TO_PREVIOUS:
|
2011-12-29 20:11:42 +00:00
|
|
|
if( GetCanvas()->IsMouseCaptured() )
|
|
|
|
GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );
|
2011-12-22 15:41:16 +00:00
|
|
|
|
2013-04-25 07:05:33 +00:00
|
|
|
if( GetBoard()->GetTrackWidthIndex() <= 0 )
|
|
|
|
GetBoard()->SetTrackWidthIndex( GetBoard()->m_TrackWidthList.size() -1 );
|
|
|
|
else
|
|
|
|
GetBoard()->SetTrackWidthIndex( GetBoard()->GetTrackWidthIndex() - 1 );
|
2011-12-22 15:41:16 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
if( GetCanvas()->IsMouseCaptured() )
|
|
|
|
GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );
|
2011-12-22 15:41:16 +00:00
|
|
|
|
2011-09-09 11:02:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_GRID_TO_FASTGRID1:
|
2011-12-14 20:03:15 +00:00
|
|
|
if( m_gridSelectBox )
|
2011-09-09 11:02:03 +00:00
|
|
|
{
|
2011-12-14 20:03:15 +00:00
|
|
|
m_gridSelectBox->SetSelection( m_FastGrid1 );
|
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_FASTGRID2:
|
2011-12-14 20:03:15 +00:00
|
|
|
if( m_gridSelectBox )
|
2011-09-09 11:02:03 +00:00
|
|
|
{
|
2011-12-14 20:03:15 +00:00
|
|
|
m_gridSelectBox->SetSelection( m_FastGrid2 );
|
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_NEXT:
|
2011-12-14 20:03:15 +00:00
|
|
|
if( m_gridSelectBox )
|
2011-09-09 11:02:03 +00:00
|
|
|
{
|
2011-12-14 20:03:15 +00:00
|
|
|
m_gridSelectBox->SetSelection( ( m_gridSelectBox->GetSelection() + 1 ) %
|
|
|
|
m_gridSelectBox->GetCount() );
|
2011-09-09 11:02:03 +00:00
|
|
|
cmd.SetEventType( wxEVT_COMMAND_COMBOBOX_SELECTED );
|
|
|
|
OnSelectGrid( cmd );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_GRID_TO_PREVIOUS:
|
2011-12-14 20:03:15 +00:00
|
|
|
if( m_gridSelectBox )
|
2011-09-09 11:02:03 +00:00
|
|
|
{
|
2011-12-14 20:03:15 +00:00
|
|
|
cnt = m_gridSelectBox->GetSelection();
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-09-09 11:02:03 +00:00
|
|
|
if ( cnt == 0 )
|
2011-12-14 20:03:15 +00:00
|
|
|
cnt = m_gridSelectBox->GetCount() - 1;
|
2011-09-09 11:02:03 +00:00
|
|
|
else
|
|
|
|
cnt--;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
m_gridSelectBox->SetSelection( cnt );
|
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;
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
case HK_SWITCH_LAYER_TO_PREVIOUS:
|
2013-09-20 14:32:11 +00:00
|
|
|
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 )
|
2013-03-31 13:27:46 +00:00
|
|
|
ll = std::max( LAYER_N_BACK, FIRST_COPPER_LAYER + GetBoard()->GetCopperLayerCount() - 2 );
|
2010-11-24 15:10:33 +00:00
|
|
|
else
|
2013-03-31 13:27:46 +00:00
|
|
|
--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:
|
2013-09-20 14:32:11 +00:00
|
|
|
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
|
2013-03-31 13:27:46 +00:00
|
|
|
++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;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case HK_RESET_LOCAL_COORD: // Set the relative coord
|
|
|
|
GetScreen()->m_O_Curseur = GetCrossHairPosition();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SET_GRID_ORIGIN:
|
|
|
|
SetGridOrigin( GetCrossHairPosition() );
|
|
|
|
OnModify(); // because grid origin is saved in board, show as modified
|
2013-08-03 16:16:57 +00:00
|
|
|
m_canvas->Refresh();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RESET_GRID_ORIGIN:
|
|
|
|
SetGridOrigin( wxPoint(0,0) );
|
|
|
|
OnModify(); // because grid origin is saved in board, show as modified
|
2013-08-03 05:15:23 +00:00
|
|
|
m_canvas->Refresh();
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_UNITS:
|
2012-02-15 13:10:52 +00:00
|
|
|
evt_type = (g_UserUnit == INCHES) ?
|
|
|
|
ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH;
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_TRACK_DISPLAY_MODE:
|
|
|
|
DisplayOpt.DisplayPcbTrackFill ^= 1;
|
|
|
|
DisplayOpt.DisplayPcbTrackFill &= 1;
|
|
|
|
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
|
2013-09-20 15:29:32 +00:00
|
|
|
m_canvas->Refresh();
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_DELETE:
|
|
|
|
OnHotkeyDeleteItem( aDC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_BACK_SPACE:
|
2013-09-20 10:52:33 +00:00
|
|
|
if( IsCopperLayer( getActiveLayer() ) )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
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-12-22 13:28:11 +00:00
|
|
|
m_canvas->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;
|
|
|
|
|
2013-08-28 16:14:39 +00:00
|
|
|
case HK_ADD_BLIND_BURIED_VIA:
|
|
|
|
case HK_ADD_THROUGH_VIA: // Switch to alternate layer and Place a via if a track is in progress
|
|
|
|
if( GetBoard()->GetDesignSettings().m_BlindBuriedViaAllowed &&
|
2013-09-20 10:52:33 +00:00
|
|
|
hk_id == HK_ADD_BLIND_BURIED_VIA )
|
2013-08-28 16:14:39 +00:00
|
|
|
GetBoard()->GetDesignSettings().m_CurrentViaType = VIA_BLIND_BURIED;
|
|
|
|
else
|
|
|
|
GetBoard()->GetDesignSettings().m_CurrentViaType = VIA_THROUGH;
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( !itemCurrentlyEdited ) // no track in progress: switch layer only
|
|
|
|
{
|
|
|
|
Other_Layer_Route( NULL, aDC );
|
2012-02-20 18:46:56 +00:00
|
|
|
if( DisplayOpt.ContrastModeDisplay )
|
2013-09-20 15:29:32 +00:00
|
|
|
m_canvas->Refresh();
|
2010-11-24 15:10:33 +00:00
|
|
|
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
|
|
|
|
2013-08-28 16:14:39 +00:00
|
|
|
evt_type = hk_id == HK_ADD_BLIND_BURIED_VIA ?
|
|
|
|
ID_POPUP_PCB_PLACE_BLIND_BURIED_VIA : ID_POPUP_PCB_PLACE_THROUGH_VIA;
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2013-09-20 10:52:33 +00:00
|
|
|
case HK_SEL_LAYER_AND_ADD_THROUGH_VIA:
|
|
|
|
case HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA:
|
|
|
|
if( GetCurItem() == NULL || !GetCurItem()->IsNew() ||
|
|
|
|
GetCurItem()->Type() != PCB_TRACE_T )
|
|
|
|
break;
|
|
|
|
|
|
|
|
evt_type = hk_id == HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA ?
|
|
|
|
ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_BLIND_BURIED_VIA :
|
|
|
|
ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_THROUGH_VIA;
|
2010-11-24 15:10:33 +00:00
|
|
|
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;
|
|
|
|
|
2012-12-01 20:03:33 +00:00
|
|
|
case HK_ADD_NEW_TRACK: // Start new track, if possible
|
|
|
|
OnHotkeyBeginRoute( aDC );
|
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
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint pos = 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() );
|
2012-12-06 10:13:19 +00:00
|
|
|
OnModify();
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( module );
|
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;
|
|
|
|
|
2012-07-04 19:50:47 +00:00
|
|
|
case HK_COPY_ITEM:
|
|
|
|
evt_type = OnHotkeyCopyItem();
|
|
|
|
break;
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
case HK_ROTATE_ITEM: // Rotation
|
|
|
|
OnHotkeyRotateItem( HK_ROTATE_ITEM );
|
|
|
|
break;
|
|
|
|
|
2012-05-30 17:38:52 +00:00
|
|
|
case HK_FLIP_ITEM:
|
|
|
|
OnHotkeyRotateItem( HK_FLIP_ITEM );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
2012-05-30 17:38:52 +00:00
|
|
|
|
2012-02-19 17:33:06 +00:00
|
|
|
case HK_SWITCH_HIGHCONTRAST_MODE: // switch to high contrast mode and refresh the canvas
|
|
|
|
DisplayOpt.ContrastModeDisplay = !DisplayOpt.ContrastModeDisplay;
|
2013-09-20 15:29:32 +00:00
|
|
|
m_canvas->Refresh();
|
2012-07-04 19:50:47 +00:00
|
|
|
break;
|
2013-09-06 08:19:53 +00:00
|
|
|
|
|
|
|
case HK_CANVAS_CAIRO:
|
|
|
|
evt_type = ID_MENU_CANVAS_CAIRO;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CANVAS_OPENGL:
|
|
|
|
evt_type = ID_MENU_CANVAS_OPENGL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CANVAS_DEFAULT:
|
|
|
|
evt_type = ID_MENU_CANVAS_DEFAULT;
|
|
|
|
break;
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2011-12-21 13:42:02 +00:00
|
|
|
bool ItemFree = (item == NULL) || (item->GetFlags() == 0);
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
switch( GetToolId() )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
case ID_TRACK_BUTT:
|
2013-09-20 14:32:11 +00:00
|
|
|
if( getActiveLayer() > LAYER_N_FRONT )
|
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
|
|
|
if( ItemFree )
|
|
|
|
{
|
|
|
|
item = PcbGeneralLocateAndDisplay();
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2013-10-14 15:29:16 +00:00
|
|
|
if( item && !item->IsTrack() )
|
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
|
|
|
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 )
|
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint pos = RefPos( false );
|
2013-03-31 13:27:46 +00:00
|
|
|
MODULE* module = GetBoard()->GetFootprint( pos, UNDEFINED_LAYER, 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
|
|
|
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
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-07-04 19:50:47 +00:00
|
|
|
|
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();
|
2011-12-21 13:42:02 +00:00
|
|
|
bool itemCurrentlyEdited = item && item->GetFlags();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
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 )
|
2013-03-01 19:59:29 +00:00
|
|
|
evt_type = ID_POPUP_PCB_EDIT_MODULE_PRMS;
|
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:
|
2012-12-27 16:42:41 +00:00
|
|
|
// Until dec 2012 a EDIT_MODULE event is posted here to prevent pads
|
2010-11-24 15:10:33 +00:00
|
|
|
// from being edited by hotkeys.
|
2012-12-27 16:42:41 +00:00
|
|
|
// Process_Special_Functions takes care of finding the parent.
|
|
|
|
// After dec 2012 a EDIT_PAD event is posted, because there is no
|
|
|
|
// reason to not allow pad edit by hotkey
|
|
|
|
// (pad coordinates are no more modified by rounding, in nanometer version
|
|
|
|
// when using inches or mm in dialog)
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aIdCommand == HK_EDIT_ITEM )
|
2012-12-27 16:42:41 +00:00
|
|
|
evt_type = ID_POPUP_PCB_EDIT_PAD;
|
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
|
|
|
|
2012-07-04 19:50:47 +00:00
|
|
|
int PCB_EDIT_FRAME::OnHotkeyCopyItem()
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = GetCurItem();
|
|
|
|
bool itemCurrentlyEdited = item && item->GetFlags();
|
|
|
|
|
|
|
|
if( itemCurrentlyEdited )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
item = PcbGeneralLocateAndDisplay();
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
SetCurItem( item );
|
|
|
|
|
|
|
|
int eventId = 0;
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_TEXT_T:
|
|
|
|
eventId = ID_POPUP_PCB_COPY_TEXTEPCB;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
eventId = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return eventId;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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();
|
2011-12-21 13:42:02 +00:00
|
|
|
bool itemCurrentlyEdited = item && item->GetFlags();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
if( itemCurrentlyEdited )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
item = PcbGeneralLocateAndDisplay();
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
SetCurItem( item );
|
|
|
|
|
2013-08-05 20:47:34 +00:00
|
|
|
int evt_type = 0; // Used to post a wxCommandEvent on demand
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_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:
|
2013-08-05 20:47:34 +00:00
|
|
|
{
|
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_MODULE_REQUEST;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2013-08-05 20:47:34 +00:00
|
|
|
if( aIdCommand == HK_DRAG_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_DRAG_MODULE_REQUEST;
|
|
|
|
}
|
|
|
|
break;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
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;
|
|
|
|
|
2011-11-24 19:57:41 +00:00
|
|
|
case PCB_DIMENSION_T:
|
|
|
|
if( aIdCommand == HK_MOVE_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_TEXT_DIMENSION_REQUEST;
|
|
|
|
break;
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( evt_type != 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
evt.SetEventObject( this );
|
|
|
|
evt.SetId( evt_type );
|
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;
|
2011-12-21 13:42:02 +00:00
|
|
|
bool itemCurrentlyEdited = item && item->GetFlags();
|
2011-09-07 09:27:02 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2011-09-07 09:27:02 +00:00
|
|
|
|
|
|
|
if( itemCurrentlyEdited )
|
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( true );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( aDC );
|
2011-09-07 09:27:02 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_VIA_T:
|
2011-12-21 13:42:02 +00:00
|
|
|
if( item->IsDragging() )
|
2011-09-07 09:27:02 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOn( aDC );
|
2011-09-07 09:27:02 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2013-10-14 15:29:16 +00:00
|
|
|
|
2012-12-01 20:03:33 +00:00
|
|
|
TRACK * PCB_EDIT_FRAME::OnHotkeyBeginRoute( wxDC* aDC )
|
|
|
|
{
|
2013-09-20 14:32:11 +00:00
|
|
|
if( getActiveLayer() > LAYER_N_FRONT )
|
2012-12-01 20:03:33 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
bool itemCurrentlyEdited = (GetCurItem() && GetCurItem()->GetFlags());
|
|
|
|
|
|
|
|
// Ensure the track tool is active
|
|
|
|
if( GetToolId() != ID_TRACK_BUTT && !itemCurrentlyEdited )
|
|
|
|
{
|
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetEventObject( this );
|
|
|
|
cmd.SetId( ID_TRACK_BUTT );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( GetToolId() != ID_TRACK_BUTT )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
TRACK* track = NULL;
|
|
|
|
|
|
|
|
if( !itemCurrentlyEdited ) // no track in progress:
|
|
|
|
{
|
|
|
|
track = Begin_Route( NULL, aDC );
|
|
|
|
SetCurItem( track );
|
|
|
|
|
|
|
|
if( track )
|
|
|
|
m_canvas->SetAutoPanRequest( true );
|
|
|
|
}
|
|
|
|
else if( GetCurItem()->IsNew() )
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
|
|
|
|
m_canvas->SetAutoPanRequest( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
return track;
|
|
|
|
}
|
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();
|
2011-12-21 13:42:02 +00:00
|
|
|
bool itemCurrentlyEdited = item && item->GetFlags();
|
2010-11-24 15:10:33 +00:00
|
|
|
int evt_type = 0; // Used to post a wxCommandEvent on demand
|
|
|
|
|
2013-10-14 15:29:16 +00:00
|
|
|
// Allows block rotate operation on hot key.
|
|
|
|
if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
|
|
|
{
|
|
|
|
evt_type = ID_POPUP_ROTATE_BLOCK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !itemCurrentlyEdited )
|
|
|
|
item = PcbGeneralLocateAndDisplay();
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2013-10-14 15:29:16 +00:00
|
|
|
if( item == NULL )
|
|
|
|
return false;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2013-10-14 15:29:16 +00:00
|
|
|
SetCurItem( item );
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2013-10-14 15:29:16 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_MODULE_T:
|
|
|
|
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
|
|
|
evt_type = ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2013-10-14 15:29:16 +00:00
|
|
|
if( aIdCommand == HK_FLIP_ITEM ) // move to other side
|
|
|
|
evt_type = ID_POPUP_PCB_CHANGE_SIDE_MODULE;
|
|
|
|
break;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2013-10-14 15:29:16 +00:00
|
|
|
case PCB_TEXT_T:
|
|
|
|
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
|
|
|
evt_type = ID_POPUP_PCB_ROTATE_TEXTEPCB;
|
|
|
|
else if( aIdCommand == HK_FLIP_ITEM )
|
|
|
|
evt_type = ID_POPUP_PCB_FLIP_TEXTEPCB;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2013-10-14 15:29:16 +00:00
|
|
|
break;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2013-10-14 15:29:16 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
|
|
|
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
|
|
|
|
evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2013-10-14 15:29:16 +00:00
|
|
|
break;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2013-10-14 15:29:16 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-11-24 15:10:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|