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
|
2016-02-29 21:12:03 +00:00
|
|
|
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-10-14 15:29:16 +00:00
|
|
|
*
|
|
|
|
* 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>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.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>
|
2014-09-10 15:18:42 +00:00
|
|
|
#include <class_pcb_text.h>
|
2017-10-31 15:38:10 +00:00
|
|
|
#include <class_pcb_target.h>
|
2014-09-10 15:18:42 +00:00
|
|
|
#include <class_drawsegment.h>
|
2018-01-24 21:27:56 +00:00
|
|
|
#include <origin_viewitem.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>
|
2014-12-06 21:21:13 +00:00
|
|
|
#include <class_zone.h>
|
2015-05-12 09:05:36 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2018-01-24 21:27:56 +00:00
|
|
|
#include <tools/pcbnew_control.h>
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
/* How to add a new hotkey:
|
|
|
|
* see hotkeys.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2015-05-05 18:39:42 +00:00
|
|
|
EDA_HOTKEY* PCB_EDIT_FRAME::GetHotKeyDescription( int aCommand ) const
|
|
|
|
{
|
|
|
|
EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List );
|
|
|
|
|
|
|
|
if( HK_Descr == NULL )
|
|
|
|
HK_Descr = GetDescriptorFromCommand( aCommand, board_edit_Hotkey_List );
|
|
|
|
|
|
|
|
return HK_Descr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-29 20:23:40 +00:00
|
|
|
bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition,
|
2011-03-01 19:26:17 +00:00
|
|
|
EDA_ITEM* aItem )
|
2010-11-24 15:10:33 +00:00
|
|
|
{
|
|
|
|
if( aHotkeyCode == 0 )
|
2014-08-29 20:23:40 +00:00
|
|
|
return false;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
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();
|
2017-10-30 17:21:07 +00:00
|
|
|
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
|
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 )
|
2014-08-29 20:23:40 +00:00
|
|
|
return false;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2012-12-01 20:03:33 +00:00
|
|
|
int hk_id = HK_Descr->m_Idcommand;
|
|
|
|
|
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 );
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_NUM ll;
|
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:
|
2014-08-29 20:23:40 +00:00
|
|
|
return false;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
2014-04-03 07:40:55 +00:00
|
|
|
case HK_LEFT_CLICK:
|
|
|
|
OnLeftClick( aDC, aPosition );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_LEFT_DCLICK: // Simulate a double left click: generate 2 events
|
|
|
|
OnLeftClick( aDC, aPosition );
|
|
|
|
OnLeftDClick( aDC, aPosition );
|
|
|
|
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
|
|
|
|
2014-05-13 09:22:51 +00:00
|
|
|
if( GetDesignSettings().GetTrackWidthIndex() < GetDesignSettings().m_TrackWidthList.size() - 1 )
|
|
|
|
GetDesignSettings().SetTrackWidthIndex( GetDesignSettings().GetTrackWidthIndex() + 1 );
|
2013-04-25 07:05:33 +00:00
|
|
|
else
|
2014-05-13 09:22:51 +00:00
|
|
|
GetDesignSettings().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
|
|
|
|
2014-05-13 09:22:51 +00:00
|
|
|
if( GetDesignSettings().GetTrackWidthIndex() <= 0 )
|
|
|
|
GetDesignSettings().SetTrackWidthIndex( GetDesignSettings().m_TrackWidthList.size() -1 );
|
2013-04-25 07:05:33 +00:00
|
|
|
else
|
2014-05-13 09:22:51 +00:00
|
|
|
GetDesignSettings().SetTrackWidthIndex( GetDesignSettings().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:
|
2014-03-21 17:00:11 +00:00
|
|
|
SetFastGrid1();
|
2011-09-09 11:02:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_GRID_TO_FASTGRID2:
|
2014-03-21 17:00:11 +00:00
|
|
|
SetFastGrid2();
|
2011-09-09 11:02:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_GRID_TO_NEXT:
|
2014-03-21 17:00:11 +00:00
|
|
|
SetNextGrid();
|
2011-09-09 11:02:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_GRID_TO_PREVIOUS:
|
2014-03-21 17:00:11 +00:00
|
|
|
SetPrevGrid();
|
2011-09-09 11:02:03 +00:00
|
|
|
break;
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
case HK_SWITCH_LAYER_TO_PREVIOUS:
|
2014-03-21 10:17:47 +00:00
|
|
|
ll = GetActiveLayer();
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !IsCopperLayer( ll ) )
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( ll == F_Cu )
|
|
|
|
ll = B_Cu;
|
|
|
|
else if( ll == B_Cu )
|
2014-06-29 13:05:51 +00:00
|
|
|
ll = ToLAYER_ID( GetBoard()->GetCopperLayerCount() - 2 );
|
2010-11-24 15:10:33 +00:00
|
|
|
else
|
2014-06-24 16:17:18 +00:00
|
|
|
ll = ll - 1;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2014-06-29 13:05:51 +00:00
|
|
|
SwitchLayer( aDC, ToLAYER_ID( ll ) );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_NEXT:
|
2014-03-21 10:17:47 +00:00
|
|
|
ll = GetActiveLayer();
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !IsCopperLayer( ll ) )
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( ll == B_Cu )
|
|
|
|
ll = F_Cu;
|
|
|
|
else if( ++ll >= GetBoard()->GetCopperLayerCount() - 1 )
|
|
|
|
ll = B_Cu;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2014-06-29 13:05:51 +00:00
|
|
|
SwitchLayer( aDC, ToLAYER_ID( ll ) );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_COMPONENT:
|
2014-06-24 16:17:18 +00:00
|
|
|
SwitchLayer( aDC, F_Cu );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_COPPER:
|
2014-06-24 16:17:18 +00:00
|
|
|
SwitchLayer( aDC, B_Cu );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER1:
|
2014-06-24 16:17:18 +00:00
|
|
|
SwitchLayer( aDC, In1_Cu );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER2:
|
2014-06-24 16:17:18 +00:00
|
|
|
SwitchLayer( aDC, In2_Cu );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER3:
|
2014-06-24 16:17:18 +00:00
|
|
|
SwitchLayer( aDC, In3_Cu );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER4:
|
2014-06-24 16:17:18 +00:00
|
|
|
SwitchLayer( aDC, In4_Cu );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER5:
|
2014-06-24 16:17:18 +00:00
|
|
|
SwitchLayer( aDC, In5_Cu );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_INNER6:
|
2014-06-24 16:17:18 +00:00
|
|
|
SwitchLayer( aDC, In6_Cu );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_HELP: // Display Current hotkey list
|
2018-02-14 22:07:59 +00:00
|
|
|
DisplayHotkeyList( this, g_Board_Editor_Hotkeys_Descr );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_IN:
|
2018-01-12 10:40:55 +00:00
|
|
|
evt_type = ID_KEY_ZOOM_IN;
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_OUT:
|
2018-01-12 10:40:55 +00:00
|
|
|
evt_type = ID_KEY_ZOOM_OUT;
|
2010-11-24 15:10:33 +00:00
|
|
|
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;
|
|
|
|
|
2016-06-08 11:19:53 +00:00
|
|
|
case HK_ZOOM_SELECTION:
|
|
|
|
evt_type = ID_ZOOM_SELECTION;
|
|
|
|
break;
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
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:
|
2018-01-24 21:27:56 +00:00
|
|
|
PCBNEW_CONTROL::SetGridOrigin( GetGalCanvas()->GetView(), this,
|
|
|
|
new KIGFX::ORIGIN_VIEWITEM( GetGridOrigin(), UR_TRANSIENT ),
|
|
|
|
GetCrossHairPosition() );
|
2013-08-03 16:16:57 +00:00
|
|
|
m_canvas->Refresh();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RESET_GRID_ORIGIN:
|
2018-01-24 21:27:56 +00:00
|
|
|
PCBNEW_CONTROL::SetGridOrigin( GetGalCanvas()->GetView(), this,
|
|
|
|
new KIGFX::ORIGIN_VIEWITEM( GetGridOrigin(), UR_TRANSIENT ),
|
|
|
|
wxPoint( 0, 0 ) );
|
2013-08-03 05:15:23 +00:00
|
|
|
m_canvas->Refresh();
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_UNITS:
|
2018-02-02 15:44:53 +00:00
|
|
|
evt_type = (GetUserUnits() == INCHES) ?
|
2012-02-15 13:10:52 +00:00
|
|
|
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:
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_DisplayPcbTrackFill = !displ_opts->m_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:
|
2014-03-21 10:17:47 +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_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;
|
|
|
|
|
2018-02-14 22:50:41 +00:00
|
|
|
case HK_OPEN:
|
2010-11-24 15:10:33 +00:00
|
|
|
if( !itemCurrentlyEdited )
|
|
|
|
evt_type = ID_LOAD_FILE ;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
|
|
|
|
2018-02-14 22:50:41 +00:00
|
|
|
case HK_SAVE:
|
2010-11-24 15:10:33 +00:00
|
|
|
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 )
|
2014-08-29 20:23:40 +00:00
|
|
|
return true;
|
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
|
2014-08-29 20:23:40 +00:00
|
|
|
return true;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
if( !GetCurItem()->IsNew() )
|
2014-08-29 20:23:40 +00:00
|
|
|
return true;
|
2010-11-24 15:10:33 +00:00
|
|
|
|
|
|
|
// 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 );
|
2015-01-10 10:27:49 +00:00
|
|
|
if( displ_opts->m_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 )
|
2014-08-29 20:23:40 +00:00
|
|
|
return true;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( GetCurItem()->Type() != PCB_TRACE_T )
|
2014-08-29 20:23:40 +00:00
|
|
|
return true;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
if( !GetCurItem()->IsNew() )
|
2014-08-29 20:23:40 +00:00
|
|
|
return true;
|
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;
|
|
|
|
|
2015-03-14 07:43:36 +00:00
|
|
|
case HK_EDIT_MODULE_WITH_MODEDIT: // Edit module with module editor
|
|
|
|
OnHotkeyEditItem( HK_EDIT_MODULE_WITH_MODEDIT );
|
|
|
|
break;
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
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:
|
2016-01-14 17:52:27 +00:00
|
|
|
OnHotkeyFlipItem( HK_FLIP_ITEM );
|
2010-11-24 15:10:33 +00:00
|
|
|
break;
|
2012-05-30 17:38:52 +00:00
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
case HK_MOVE_ITEM_EXACT:
|
|
|
|
case HK_DUPLICATE_ITEM:
|
|
|
|
case HK_DUPLICATE_ITEM_AND_INCREMENT:
|
|
|
|
case HK_CREATE_ARRAY:
|
|
|
|
OnHotkeyDuplicateOrArrayItem( HK_Descr->m_Idcommand );
|
|
|
|
break;
|
|
|
|
|
2012-02-19 17:33:06 +00:00
|
|
|
case HK_SWITCH_HIGHCONTRAST_MODE: // switch to high contrast mode and refresh the canvas
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_ContrastModeDisplay = !displ_opts->m_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;
|
|
|
|
|
2015-12-22 21:25:59 +00:00
|
|
|
case HK_CANVAS_LEGACY:
|
|
|
|
evt_type = ID_MENU_CANVAS_LEGACY;
|
2013-09-06 08:19:53 +00:00
|
|
|
break;
|
2016-06-09 05:48:49 +00:00
|
|
|
|
2014-12-06 21:21:13 +00:00
|
|
|
case HK_ZONE_FILL_OR_REFILL:
|
|
|
|
evt_type = ID_POPUP_PCB_FILL_ALL_ZONES;
|
|
|
|
break;
|
2016-06-09 05:48:49 +00:00
|
|
|
|
2014-12-06 21:21:13 +00:00
|
|
|
case HK_ZONE_REMOVE_FILLED:
|
|
|
|
evt_type = ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES;
|
|
|
|
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
|
|
|
}
|
2014-08-29 20:23:40 +00:00
|
|
|
|
|
|
|
return true;
|
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:
|
2014-08-31 16:19:07 +00:00
|
|
|
if( !IsCopperLayer ( GetActiveLayer() ) )
|
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
|
|
|
|
2016-02-29 21:12:03 +00:00
|
|
|
if( module == NULL || module->IsLocked() )
|
2010-11-24 15:10:33 +00:00
|
|
|
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
|
|
|
|
2016-02-29 21:12:03 +00:00
|
|
|
// Shouldn't there be a check for locked tracks and vias here?
|
|
|
|
if( item == NULL || (item->Type() == PCB_MODULE_T && (MODULE*)item->IsLocked()) )
|
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
|
2016-02-29 21:12:03 +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 )
|
2014-09-28 14:44:47 +00:00
|
|
|
{
|
|
|
|
// Be sure the corresponding netclass is selected before edit:
|
|
|
|
SetCurrentNetClass( ( (BOARD_CONNECTED_ITEM*)item )->GetNetClassName() );
|
2010-11-24 15:10:33 +00:00
|
|
|
evt_type = ID_POPUP_PCB_EDIT_TRACKSEG;
|
2014-09-28 14:44:47 +00:00
|
|
|
}
|
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;
|
2015-03-14 07:43:36 +00:00
|
|
|
else if( aIdCommand == HK_EDIT_MODULE_WITH_MODEDIT )
|
|
|
|
evt_type = ID_POPUP_PCB_EDIT_MODULE_WITH_MODEDIT;
|
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 )
|
2017-10-31 15:38:10 +00:00
|
|
|
evt_type = ID_POPUP_PCB_EDIT_PCB_TARGET;
|
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 )
|
2017-10-31 15:38:10 +00:00
|
|
|
evt_type = ID_POPUP_PCB_MOVE_PCB_TARGET_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;
|
|
|
|
}
|
|
|
|
|
2016-02-29 21:12:03 +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() )
|
2014-09-10 15:18:42 +00:00
|
|
|
PlaceDraggedOrMovedTrackSegment( static_cast<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:
|
2014-09-10 15:18:42 +00:00
|
|
|
Place_Texte_Pcb( static_cast<TEXTE_PCB*>( item ), aDC );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2014-09-10 15:18:42 +00:00
|
|
|
PlaceTexteModule( static_cast<TEXTE_MODULE*>( item ), aDC );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2014-09-10 15:18:42 +00:00
|
|
|
PlacePad( static_cast<D_PAD*>( item ), aDC );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2014-09-10 15:18:42 +00:00
|
|
|
PlaceModule( static_cast<MODULE*>( item ), aDC );
|
2011-09-07 09:27:02 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2014-09-10 15:18:42 +00:00
|
|
|
PlaceTarget( static_cast<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.
|
2014-09-10 15:18:42 +00:00
|
|
|
Place_DrawItem( static_cast<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 )
|
|
|
|
{
|
2014-08-31 16:19:07 +00:00
|
|
|
if( !IsCopperLayer( GetActiveLayer() ) )
|
2012-12-01 20:03:33 +00:00
|
|
|
return NULL;
|
|
|
|
|
2014-08-31 16:19:07 +00:00
|
|
|
bool itemCurrentlyEdited = GetCurItem() && GetCurItem()->GetFlags();
|
2012-12-01 20:03:33 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
2016-01-14 17:52:27 +00:00
|
|
|
|
|
|
|
bool PCB_EDIT_FRAME::OnHotkeyFlipItem( int aIdCommand )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = GetCurItem();
|
|
|
|
bool itemCurrentlyEdited = item && item->GetFlags();
|
|
|
|
int evt_type = 0; // Used to post a wxCommandEvent on demand
|
|
|
|
|
|
|
|
wxASSERT( aIdCommand == HK_FLIP_ITEM );
|
|
|
|
|
|
|
|
if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
|
|
|
{
|
|
|
|
evt_type = ID_POPUP_FLIP_BLOCK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !itemCurrentlyEdited )
|
|
|
|
item = PcbGeneralLocateAndDisplay();
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
SetCurItem( item );
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_MODULE_T:
|
|
|
|
evt_type = ID_POPUP_PCB_CHANGE_SIDE_MODULE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_TEXT_T:
|
|
|
|
evt_type = ID_POPUP_PCB_FLIP_TEXTEPCB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( evt_type != 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
evt.SetEventObject( this );
|
|
|
|
evt.SetId( evt_type );
|
|
|
|
GetEventHandler()->ProcessEvent( evt );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-01-14 17:52:27 +00:00
|
|
|
wxASSERT( aIdCommand == HK_ROTATE_ITEM );
|
|
|
|
|
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:
|
2016-01-14 17:52:27 +00:00
|
|
|
evt_type = ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE;
|
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_TEXT_T:
|
2016-01-14 17:52:27 +00:00
|
|
|
evt_type = ID_POPUP_PCB_ROTATE_TEXTEPCB;
|
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:
|
2016-01-14 17:52:27 +00:00
|
|
|
evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE;
|
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;
|
|
|
|
}
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2016-02-29 21:12:03 +00:00
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
bool PCB_EDIT_FRAME::OnHotkeyDuplicateOrArrayItem( int aIdCommand )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = GetCurItem();
|
|
|
|
bool itemCurrentlyEdited = item && item->GetFlags();
|
|
|
|
|
|
|
|
if( itemCurrentlyEdited )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
item = PcbGeneralLocateAndDisplay();
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
SetCurItem( item );
|
|
|
|
|
|
|
|
int evt_type = 0; // Used to post a wxCommandEvent on demand
|
|
|
|
|
|
|
|
bool canDuplicate = true;
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
// Only handle items we know we can handle
|
|
|
|
case PCB_PAD_T:
|
|
|
|
canDuplicate = false;
|
|
|
|
// no break
|
|
|
|
case PCB_MODULE_T:
|
|
|
|
case PCB_LINE_T:
|
|
|
|
case PCB_TEXT_T:
|
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_ZONE_AREA_T:
|
|
|
|
case PCB_TARGET_T:
|
|
|
|
case PCB_DIMENSION_T:
|
|
|
|
switch( aIdCommand )
|
|
|
|
{
|
|
|
|
case HK_CREATE_ARRAY:
|
|
|
|
if( canDuplicate )
|
|
|
|
evt_type = ID_POPUP_PCB_CREATE_ARRAY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_DUPLICATE_ITEM_AND_INCREMENT:
|
|
|
|
if( canDuplicate )
|
|
|
|
evt_type = ID_POPUP_PCB_DUPLICATE_ITEM_AND_INCREMENT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_DUPLICATE_ITEM:
|
|
|
|
if( canDuplicate )
|
|
|
|
evt_type = ID_POPUP_PCB_DUPLICATE_ITEM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_MOVE_ITEM_EXACT:
|
|
|
|
evt_type = ID_POPUP_PCB_MOVE_EXACT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// We don't handle other commands here
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-03-18 10:49:49 +00:00
|
|
|
evt_type = 0;
|
2015-02-12 03:22:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PostCommandMenuEvent( evt_type );
|
|
|
|
}
|