2014-10-23 17:53:38 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2012 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
|
|
|
/**
|
2018-01-31 16:09:26 +00:00
|
|
|
* @file footprint_editor_onclick.cpp
|
2011-09-23 13:57:12 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_edge_mod.h>
|
2018-01-24 21:27:56 +00:00
|
|
|
#include <origin_viewitem.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbnew_id.h>
|
2018-01-24 21:27:56 +00:00
|
|
|
#include <tools/pcbnew_control.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <hotkeys.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2018-02-16 19:26:55 +00:00
|
|
|
#include <dialog_edit_footprint_for_fp_editor.h>
|
2012-04-09 09:16:47 +00:00
|
|
|
#include <menus_helpers.h>
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-01-26 07:43:59 +00:00
|
|
|
BOARD_ITEM* item = GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( DC );
|
2011-02-23 13:48:19 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( item && item->GetFlags() ) // Move item command in progress
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-24 12:35:14 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
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 ), DC );
|
2011-02-24 12:35:14 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
|
2014-09-10 15:18:42 +00:00
|
|
|
Place_EdgeMod( static_cast<EDGE_MODULE*>( item ) );
|
2011-02-24 12:35:14 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
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 ), DC );
|
2011-02-24 12:35:14 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-24 12:35:14 +00:00
|
|
|
default:
|
2019-01-02 04:43:13 +00:00
|
|
|
wxLogDebug( wxT( "WinEDA_ModEditFrame::OnLeftClick err:Struct %d, m_Flag %X" ),
|
2011-12-21 13:42:02 +00:00
|
|
|
item->Type(), item->GetFlags() );
|
|
|
|
item->ClearFlags();
|
2011-02-24 12:35:14 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2012-07-17 15:29:29 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT )
|
|
|
|
&& !wxGetKeyState( WXK_CONTROL ) )
|
|
|
|
item = ModeditLocateAndDisplay();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-07-17 15:29:29 +00:00
|
|
|
SetCurItem( item );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2012-07-17 15:29:29 +00:00
|
|
|
item = GetCurItem();
|
|
|
|
bool no_item_edited = item == NULL || item->GetFlags() == 0;
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
switch( GetToolId() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_MODEDIT_CIRCLE_TOOL:
|
|
|
|
case ID_MODEDIT_ARC_TOOL:
|
|
|
|
case ID_MODEDIT_LINE_TOOL:
|
2012-07-17 15:29:29 +00:00
|
|
|
if( no_item_edited )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-05-22 17:51:18 +00:00
|
|
|
STROKE_T shape = S_SEGMENT;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_MODEDIT_CIRCLE_TOOL )
|
2007-08-20 01:20:48 +00:00
|
|
|
shape = S_CIRCLE;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_MODEDIT_ARC_TOOL )
|
2007-08-20 01:20:48 +00:00
|
|
|
shape = S_ARC;
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
SetCurItem( Begin_Edge_Module( (EDGE_MODULE*) NULL, DC, shape ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
else if( item->IsNew() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-14 04:29:25 +00:00
|
|
|
if( ( (EDGE_MODULE*) item )->GetShape() == S_CIRCLE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-01-26 07:43:59 +00:00
|
|
|
End_Edge_Module( (EDGE_MODULE*) item );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2013-09-20 15:29:32 +00:00
|
|
|
m_canvas->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-12-14 04:29:25 +00:00
|
|
|
else if( ( (EDGE_MODULE*) item )->GetShape() == S_ARC )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-01-26 07:43:59 +00:00
|
|
|
End_Edge_Module( (EDGE_MODULE*) item );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2013-09-20 15:29:32 +00:00
|
|
|
m_canvas->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-12-14 04:29:25 +00:00
|
|
|
else if( ( (EDGE_MODULE*) item )->GetShape() == S_SEGMENT )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-05-22 17:51:18 +00:00
|
|
|
SetCurItem( Begin_Edge_Module( (EDGE_MODULE*) item, DC, S_SEGMENT ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
2019-01-02 04:43:13 +00:00
|
|
|
wxLogDebug( wxT( "ProcessCommand error: unknown shape" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_MODEDIT_DELETE_TOOL:
|
2012-07-17 15:29:29 +00:00
|
|
|
if( ! no_item_edited ) // Item in edit, cannot delete it
|
2009-08-04 18:21:32 +00:00
|
|
|
break;
|
2013-02-22 23:29:44 +00:00
|
|
|
|
2012-07-17 15:29:29 +00:00
|
|
|
item = ModeditLocateAndDisplay();
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2013-02-22 23:29:44 +00:00
|
|
|
if( item && item->Type() != PCB_MODULE_T ) // Cannot delete the module itself
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
|
2011-01-26 07:43:59 +00:00
|
|
|
RemoveStruct( item );
|
2009-08-04 18:21:32 +00:00
|
|
|
SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_MODEDIT_ANCHOR_TOOL:
|
2013-08-03 05:15:23 +00:00
|
|
|
{
|
|
|
|
MODULE* module = GetBoard()->m_Modules;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
if( module == NULL // No module loaded
|
|
|
|
|| (module->GetFlags() != 0) )
|
|
|
|
break;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( module, UR_CHANGED );
|
2009-08-11 14:10:34 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// set the new relative internal local coordinates of footprint items
|
|
|
|
wxPoint moveVector = module->GetPosition() - GetCrossHairPosition();
|
|
|
|
module->MoveAnchorPosition( moveVector );
|
2013-03-23 13:30:00 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Usually, we do not need to change twice the anchor position,
|
|
|
|
// so deselect the active tool
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCurItem( NULL );
|
2015-02-12 03:22:24 +00:00
|
|
|
m_canvas->Refresh();
|
2013-08-03 05:15:23 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_MODEDIT_PLACE_GRID_COORD:
|
2018-01-24 21:27:56 +00:00
|
|
|
PCBNEW_CONTROL::SetGridOrigin( GetGalCanvas()->GetView(), this,
|
|
|
|
new KIGFX::ORIGIN_VIEWITEM( GetBoard()->GetGridOrigin(), UR_TRANSIENT ),
|
|
|
|
GetCrossHairPosition() );
|
|
|
|
m_canvas->Refresh();
|
2010-07-13 10:42:32 +00:00
|
|
|
break;
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_MODEDIT_TEXT_TOOL:
|
2010-07-29 20:00:24 +00:00
|
|
|
if( GetBoard()->m_Modules == NULL )
|
|
|
|
break;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
|
2009-01-05 05:21:35 +00:00
|
|
|
CreateTextModule( GetBoard()->m_Modules, DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_MODEDIT_PAD_TOOL:
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard()->m_Modules )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
|
2009-01-05 05:21:35 +00:00
|
|
|
AddPad( GetBoard()->m_Modules, true );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2017-03-09 09:09:13 +00:00
|
|
|
case ID_MODEDIT_MEASUREMENT_TOOL:
|
2019-01-02 04:43:13 +00:00
|
|
|
DisplayError( this, _( "Measurement Tool not available in Legacy Toolset" ) );
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2017-03-09 09:09:13 +00:00
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
default:
|
2019-01-02 04:43:13 +00:00
|
|
|
wxLogDebug( wxT( "FOOTPRINT_EDIT_FRAME::ProcessCommand error" ) );
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOn( DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-01-26 07:43:59 +00:00
|
|
|
BOARD_ITEM* item = GetCurItem();
|
2009-08-11 14:10:34 +00:00
|
|
|
wxString msg;
|
2012-03-26 23:47:08 +00:00
|
|
|
bool blockActive = !GetScreen()->m_BlockLocate.IsIdle();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
// Simple location of elements where possible.
|
2011-12-21 13:42:02 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-01-26 07:43:59 +00:00
|
|
|
SetCurItem( item = ModeditLocateAndDisplay() );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
// End command in progress.
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() != ID_NO_TOOL_SELECTED )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( item && item->GetFlags() )
|
|
|
|
AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ),
|
|
|
|
KiBitmap( cancel_xpm ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2011-12-21 13:42:02 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, _( "End Tool" ),
|
2012-03-20 14:17:58 +00:00
|
|
|
KiBitmap( cursor_xpm ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
PopMenu->AppendSeparator();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( (item && item->GetFlags()) || blockActive )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-01-26 07:43:59 +00:00
|
|
|
if( blockActive ) // Put block commands in list
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
|
2011-09-08 05:58:45 +00:00
|
|
|
_( "Cancel Block" ), KiBitmap( cancel_xpm ) );
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_ZOOM_BLOCK,
|
2018-02-09 16:28:33 +00:00
|
|
|
_( "Zoom Block" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( zoom_area_xpm ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
PopMenu->AppendSeparator();
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PLACE_BLOCK,
|
2014-02-07 19:32:08 +00:00
|
|
|
_( "Place Block" ), KiBitmap( checked_ok_xpm ) );
|
2017-07-04 08:08:33 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_DUPLICATE_BLOCK,
|
|
|
|
_( "Duplicate Block (shift + drag mouse)" ),
|
2017-06-02 09:51:11 +00:00
|
|
|
KiBitmap( copy_xpm ) );
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_MIRROR_X_BLOCK,
|
|
|
|
_( "Mirror Block (alt + drag mouse)" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( mirror_h_xpm ) );
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_ROTATE_BLOCK,
|
|
|
|
_( "Rotate Block (ctrl + drag mouse)" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( rotate_ccw_xpm ) );
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_DELETE_BLOCK,
|
|
|
|
_( "Delete Block (shift+ctrl + drag mouse)" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( delete_xpm ) );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2018-02-09 16:28:33 +00:00
|
|
|
msg = AddHotkeyName( _("Move Block Exactly..." ),
|
2018-02-14 22:07:59 +00:00
|
|
|
g_Module_Editor_Hotkeys_Descr, HK_MOVE_ITEM_EXACT );
|
2015-02-12 03:22:24 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_MOVE_BLOCK_EXACT,
|
|
|
|
msg, KiBitmap( move_xpm ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
|
2011-09-08 05:58:45 +00:00
|
|
|
_( "Cancel" ), KiBitmap( cancel_xpm ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
PopMenu->AppendSeparator();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
if( blockActive )
|
2007-10-07 18:24:15 +00:00
|
|
|
return true;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
if( item )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-03-28 19:12:46 +00:00
|
|
|
STATUS_FLAGS flags = item->GetFlags();
|
2012-02-09 20:33:38 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-09 20:33:38 +00:00
|
|
|
case PCB_MODULE_T:
|
|
|
|
{
|
|
|
|
wxMenu* transform_choice = new wxMenu;
|
2017-07-20 12:37:11 +00:00
|
|
|
AddMenuItem( transform_choice, ID_MODEDIT_MODULE_ROTATE, _( "Rotate Counterclockwise" ),
|
2017-06-02 09:51:11 +00:00
|
|
|
KiBitmap( rotate_ccw_xpm ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
AddMenuItem( transform_choice, ID_MODEDIT_MODULE_MIRROR, _( "Mirror" ),
|
2017-07-03 15:13:13 +00:00
|
|
|
KiBitmap( mirror_h_xpm ) );
|
2018-02-09 16:28:33 +00:00
|
|
|
AddMenuItem( transform_choice, ID_MODEDIT_MODULE_MOVE_EXACT, _( "Move Exactly..." ),
|
2017-07-04 15:17:55 +00:00
|
|
|
KiBitmap( move_exactly_xpm ) );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2018-02-14 22:07:59 +00:00
|
|
|
msg = AddHotkeyName( _( "Edit Footprint" ), g_Module_Editor_Hotkeys_Descr, HK_EDIT_ITEM );
|
2013-03-01 19:59:29 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_EDIT_MODULE_PRMS, msg, KiBitmap( edit_module_xpm ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
AddMenuItem( PopMenu, transform_choice, ID_MODEDIT_TRANSFORM_MODULE,
|
2014-10-08 05:50:56 +00:00
|
|
|
_( "Transform Footprint" ), KiBitmap( edit_xpm ) );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
case PCB_PAD_T:
|
|
|
|
if( !flags )
|
|
|
|
{
|
2018-02-14 22:07:59 +00:00
|
|
|
msg = AddHotkeyName( _("Move Pad" ), g_Module_Editor_Hotkeys_Descr, HK_MOVE_ITEM );
|
2012-02-09 20:33:38 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_MOVE_PAD_REQUEST, msg, KiBitmap( move_pad_xpm ) );
|
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2018-02-14 22:07:59 +00:00
|
|
|
msg = AddHotkeyName( _("Edit Pad..." ), g_Module_Editor_Hotkeys_Descr, HK_EDIT_ITEM );
|
2012-02-09 20:33:38 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_EDIT_PAD, msg, KiBitmap( options_pad_xpm ) );
|
2017-02-03 18:56:56 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_COPY_PAD_SETTINGS,
|
2018-02-12 23:42:37 +00:00
|
|
|
_( "Copy Pad Properties" ), KiBitmap( copy_pad_settings_xpm ) );
|
2017-02-03 18:56:56 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_APPLY_PAD_SETTINGS,
|
2018-07-05 16:14:19 +00:00
|
|
|
_( "Paste Pad Properties" ), KiBitmap( apply_pad_settings_xpm ) );
|
2018-02-14 22:07:59 +00:00
|
|
|
msg = AddHotkeyName( _("Delete Pad" ), g_Module_Editor_Hotkeys_Descr, HK_DELETE );
|
2012-02-09 20:33:38 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_DELETE_PAD, msg, KiBitmap( delete_pad_xpm ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2018-02-14 22:07:59 +00:00
|
|
|
msg = AddHotkeyName( _( "Duplicate Pad" ), g_Module_Editor_Hotkeys_Descr, HK_DUPLICATE_ITEM );
|
2017-07-04 15:17:55 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_DUPLICATE_ITEM, msg, KiBitmap( duplicate_xpm ) );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2018-02-14 22:07:59 +00:00
|
|
|
msg = AddHotkeyName( _("Move Pad Exactly..." ), g_Module_Editor_Hotkeys_Descr, HK_MOVE_ITEM_EXACT );
|
2015-02-12 03:22:24 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_MOVE_EXACT, msg, KiBitmap( move_pad_xpm ) );
|
|
|
|
|
2018-02-14 22:07:59 +00:00
|
|
|
msg = AddHotkeyName( _("Create Pad Array..." ), g_Module_Editor_Hotkeys_Descr, HK_CREATE_ARRAY );
|
2017-07-04 15:17:55 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_CREATE_ARRAY, msg, KiBitmap( array_xpm ) );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
if( !flags )
|
|
|
|
{
|
|
|
|
PopMenu->AppendSeparator();
|
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS,
|
2018-02-12 23:42:37 +00:00
|
|
|
_( "Push Pad Properties..." ), KiBitmap( push_pad_settings_xpm ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
break;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
|
|
|
if( !flags )
|
|
|
|
{
|
2018-02-14 22:07:59 +00:00
|
|
|
msg = AddHotkeyName( _("Move" ), g_Module_Editor_Hotkeys_Descr,
|
2012-02-09 20:33:38 +00:00
|
|
|
HK_MOVE_ITEM );
|
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST, msg,
|
2017-07-04 15:17:55 +00:00
|
|
|
KiBitmap( move_xpm ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2018-02-14 22:07:59 +00:00
|
|
|
msg = AddHotkeyName( _("Rotate Clockwise" ), g_Module_Editor_Hotkeys_Descr,
|
2012-02-09 20:33:38 +00:00
|
|
|
HK_ROTATE_ITEM );
|
2017-06-02 09:51:11 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_ROTATE_TEXTMODULE, msg, KiBitmap( rotate_cw_xpm ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
{
|
2015-02-12 03:22:24 +00:00
|
|
|
// Do not show option to replicate value or reference fields
|
2015-02-12 03:22:24 +00:00
|
|
|
// (there can only be one of each)
|
|
|
|
|
|
|
|
const MODULE* module = static_cast<MODULE*>( item->GetParent() );
|
|
|
|
const TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
|
|
|
|
|
|
|
|
if( &module->Reference() != text && &module->Value() != text )
|
|
|
|
{
|
2017-07-04 15:17:55 +00:00
|
|
|
msg = AddHotkeyName( _( "Duplicate" ),
|
2018-02-14 22:07:59 +00:00
|
|
|
g_Module_Editor_Hotkeys_Descr, HK_DUPLICATE_ITEM );
|
2015-02-12 03:22:24 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_DUPLICATE_ITEM,
|
2017-07-04 15:17:55 +00:00
|
|
|
msg, KiBitmap( duplicate_xpm ) );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2018-02-09 16:28:33 +00:00
|
|
|
msg = AddHotkeyName( _("Create Array..." ),
|
2018-02-14 22:07:59 +00:00
|
|
|
g_Module_Editor_Hotkeys_Descr, HK_CREATE_ARRAY );
|
2015-02-12 03:22:24 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_CREATE_ARRAY,
|
2017-07-04 15:17:55 +00:00
|
|
|
msg, KiBitmap( array_xpm ) );
|
2015-02-12 03:22:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-14 22:07:59 +00:00
|
|
|
msg = AddHotkeyName( _("Move Exactly..." ), g_Module_Editor_Hotkeys_Descr, HK_MOVE_ITEM_EXACT );
|
2017-07-04 15:17:55 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_MOVE_EXACT, msg, KiBitmap( move_exactly_xpm ) );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
if( !flags )
|
2010-08-29 17:55:53 +00:00
|
|
|
{
|
2018-02-14 22:07:59 +00:00
|
|
|
msg = AddHotkeyName( _("Edit..." ), g_Module_Editor_Hotkeys_Descr,
|
2012-02-09 20:33:38 +00:00
|
|
|
HK_EDIT_ITEM );
|
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_EDIT_TEXTMODULE, msg, KiBitmap( edit_text_xpm ) );
|
|
|
|
|
2014-09-10 15:18:42 +00:00
|
|
|
if( ( static_cast<TEXTE_MODULE*>( item ) )->GetType() == TEXTE_MODULE::TEXT_is_DIVERS )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2018-02-14 22:07:59 +00:00
|
|
|
msg = AddHotkeyName( _("Delete" ), g_Module_Editor_Hotkeys_Descr,
|
2012-02-09 20:33:38 +00:00
|
|
|
HK_DELETE );
|
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_DELETE_TEXTMODULE, msg,
|
2017-07-03 15:13:13 +00:00
|
|
|
KiBitmap( delete_xpm ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
2010-08-29 17:55:53 +00:00
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
break;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2010-08-29 17:55:53 +00:00
|
|
|
{
|
2012-02-09 20:33:38 +00:00
|
|
|
if( (flags & IS_NEW) )
|
2018-02-09 16:28:33 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_STOP_CURRENT_DRAWING, _( "End Edge" ),
|
2014-02-07 19:32:08 +00:00
|
|
|
KiBitmap( checked_ok_xpm ) );
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
if( !flags )
|
|
|
|
{
|
2018-02-14 22:07:59 +00:00
|
|
|
msg = AddHotkeyName( _("Move" ), g_Module_Editor_Hotkeys_Descr, HK_MOVE_ITEM );
|
2017-07-04 15:17:55 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_MOVE_EDGE, msg, KiBitmap( move_xpm ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2018-03-08 20:33:03 +00:00
|
|
|
msg = AddHotkeyName( _( "Duplicate" ), g_Module_Editor_Hotkeys_Descr, HK_DUPLICATE_ITEM );
|
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_DUPLICATE_ITEM, msg, KiBitmap( duplicate_xpm ) );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2018-03-08 20:33:03 +00:00
|
|
|
msg = AddHotkeyName( _("Move Exactly..." ), g_Module_Editor_Hotkeys_Descr, HK_MOVE_ITEM_EXACT );
|
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_MOVE_EXACT, msg, KiBitmap( move_exactly_xpm ) );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2018-03-08 20:33:03 +00:00
|
|
|
msg = AddHotkeyName( _("Create Array..." ), g_Module_Editor_Hotkeys_Descr, HK_CREATE_ARRAY );
|
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_CREATE_ARRAY, msg, KiBitmap( array_xpm ) );
|
|
|
|
}
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
if( ( flags & (IS_NEW | IS_MOVED) ) == IS_MOVED )
|
2018-02-09 16:28:33 +00:00
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_PLACE_EDGE, _( "Place Edge" ),
|
2014-02-07 19:32:08 +00:00
|
|
|
KiBitmap( checked_ok_xpm ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2018-03-08 20:33:03 +00:00
|
|
|
if( !flags )
|
|
|
|
{
|
|
|
|
msg = AddHotkeyName( _("Edit..." ), g_Module_Editor_Hotkeys_Descr, HK_EDIT_ITEM );
|
|
|
|
AddMenuItem( PopMenu, ID_POPUP_MODEDIT_EDIT_BODY_ITEM,
|
|
|
|
msg, KiBitmap( options_segment_xpm ) );
|
|
|
|
|
|
|
|
msg = AddHotkeyName( _("Delete" ), g_Module_Editor_Hotkeys_Descr, HK_DELETE );
|
|
|
|
AddMenuItem( PopMenu, ID_POPUP_PCB_DELETE_EDGE, msg, KiBitmap( delete_xpm ) );
|
|
|
|
|
|
|
|
wxMenu* edit_global_mnu = new wxMenu;
|
|
|
|
AddMenuItem( PopMenu, edit_global_mnu, ID_POPUP_MODEDIT_GLOBAL_EDIT_EDGE,
|
|
|
|
_( "Global Changes" ), KiBitmap( edit_xpm ) );
|
|
|
|
AddMenuItem( edit_global_mnu, ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE,
|
|
|
|
_( "Change Body Items Width" ), KiBitmap( width_segment_xpm ) );
|
|
|
|
AddMenuItem( edit_global_mnu, ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE,
|
|
|
|
_( "Change Body Items Layer..." ), KiBitmap( select_layer_pair_xpm ) );
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
case PCB_LINE_T:
|
|
|
|
case PCB_TEXT_T:
|
|
|
|
case PCB_VIA_T:
|
|
|
|
case PCB_TRACE_T:
|
2018-09-29 17:58:31 +00:00
|
|
|
case PCB_SEGZONE_T:
|
2012-02-09 20:33:38 +00:00
|
|
|
case PCB_MARKER_T:
|
|
|
|
case PCB_DIMENSION_T:
|
|
|
|
case PCB_TARGET_T:
|
2019-01-02 04:43:13 +00:00
|
|
|
wxLogDebug( wxT( "FOOTPRINT_EDIT_FRAME::OnRightClick Error: Unexpected DrawType %d" ),
|
2012-02-12 19:39:37 +00:00
|
|
|
item->Type() );
|
2012-02-09 20:33:38 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
case SCREEN_T:
|
|
|
|
case TYPE_NOT_INIT:
|
|
|
|
case PCB_T:
|
2019-01-02 04:43:13 +00:00
|
|
|
wxLogDebug( wxT( "FOOTPRINT_EDIT_FRAME::OnRightClick Error: illegal DrawType %d" ),
|
2012-02-09 20:33:38 +00:00
|
|
|
item->Type() );
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
default:
|
2019-01-02 04:43:13 +00:00
|
|
|
wxLogDebug( wxT( "FOOTPRINT_EDIT_FRAME::OnRightClick Error: unknown DrawType %d" ),
|
2012-02-09 20:33:38 +00:00
|
|
|
item->Type() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
PopMenu->AppendSeparator();
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2012-02-12 19:39:37 +00:00
|
|
|
/*
|
|
|
|
* Called on a mouse left button double click
|
|
|
|
*/
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-01-26 07:43:59 +00:00
|
|
|
BOARD_ITEM* item = GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
switch( GetToolId() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
2011-12-21 13:42:02 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-01-26 07:43:59 +00:00
|
|
|
item = ModeditLocateAndDisplay();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() != 0 ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2007-10-16 19:05:33 +00:00
|
|
|
// Item found
|
2011-01-26 07:43:59 +00:00
|
|
|
SetCurItem( item );
|
2014-07-09 11:50:27 +00:00
|
|
|
OnEditItemRequest( DC, item );
|
2007-08-20 01:20:48 +00:00
|
|
|
break; // end case 0
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
case ID_PCB_ADD_LINE_BUTT:
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-21 13:54:29 +00:00
|
|
|
if( item && item->IsNew() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-01-26 07:43:59 +00:00
|
|
|
End_Edge_Module( (EDGE_MODULE*) item );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2013-09-20 15:29:32 +00:00
|
|
|
m_canvas->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem )
|
|
|
|
{
|
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case PCB_PAD_T:
|
2014-09-10 15:18:42 +00:00
|
|
|
InstallPadOptionsFrame( static_cast<D_PAD*>( aItem ) );
|
2014-07-09 11:50:27 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_MODULE_T:
|
2018-09-13 15:39:14 +00:00
|
|
|
editFootprintProperties( (MODULE*) aItem );
|
2014-07-09 11:50:27 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2017-04-16 11:53:56 +00:00
|
|
|
m_canvas->Refresh();
|
2014-07-09 11:50:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_MODULE_TEXT_T:
|
2018-06-06 10:05:56 +00:00
|
|
|
InstallTextOptionsFrame( aItem, aDC );
|
2014-07-09 11:50:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_MODULE_EDGE_T :
|
2018-09-12 19:39:37 +00:00
|
|
|
InstallGraphicItemPropertiesDialog( aItem );
|
2014-07-09 11:50:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|