Move duplicate item and block to modern toolset.

This commit is contained in:
Jeff Young 2019-04-26 19:37:47 +01:00
parent a80f7432b7
commit 4e0208dfba
18 changed files with 147 additions and 209 deletions

View File

@ -128,7 +128,7 @@ enum id_eeschema_frm
ID_TB_OPTIONS_BUS_WIRES_ORIENT,
/* Schematic editor context menu IDs. */
ID_POPUP_SCH_DUPLICATE_ITEM,
ID_POPUP_SCH_DUPLICATE,
ID_POPUP_START_RANGE,
ID_POPUP_SCH_DELETE,

View File

@ -177,9 +177,8 @@ static EDA_HOTKEY HkEditComponentWithLibedit( _HKI( "Edit with Symbol Editor" ),
static EDA_HOTKEY HkMove( _HKI( "Move Schematic Item" ), HK_MOVE_COMPONENT_OR_ITEM, 'M',
ID_SCH_MOVE_ITEM );
static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate Symbol or Label" ),
HK_DUPLICATE_ITEM, 'C',
ID_POPUP_SCH_DUPLICATE_ITEM );
static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate" ), HK_DUPLICATE, 'D' + GR_KB_CTRL,
ID_POPUP_SCH_DUPLICATE );
static EDA_HOTKEY HkDrag( _HKI( "Drag Item" ), HK_DRAG, 'G', ID_SCH_DRAG_ITEM );
static EDA_HOTKEY HkMove2Drag( _HKI( "Move Block -> Drag Block" ),
@ -203,7 +202,7 @@ static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ), HK_ZOOM_SELECTIO
static EDA_HOTKEY HkCreatePin( _HKI( "Create Pin" ), HK_LIBEDIT_CREATE_PIN, 'P' );
static EDA_HOTKEY HkInsertPin( _HKI( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT );
static EDA_HOTKEY HkMoveLibItem( _HKI( "Move Library Item" ), HK_LIBEDIT_MOVE_GRAPHIC_ITEM, 'M' );
static EDA_HOTKEY HkViewDoc( _HKI( "Show Datasheet" ), HK_LIBEDIT_VIEW_DOC, 'D' + GR_KB_CTRL,
static EDA_HOTKEY HkViewDoc( _HKI( "Show Datasheet" ), HK_LIBEDIT_VIEW_DOC, 'D',
ID_LIBEDIT_VIEW_DOC );
// Autoplace fields
@ -217,7 +216,8 @@ static EDA_HOTKEY HkUpdatePcbFromSch( _HKI( "Update PCB from Schematic" ), HK_UP
static EDA_HOTKEY HkHighlightConnection( _HKI( "Highlight Connection" ), ID_HOTKEY_HIGHLIGHT,
'B' + GR_KB_CTRL );
static EDA_HOTKEY HkUnfoldBus( _HKI( "Unfold Bus" ), HK_UNFOLD_BUS, 'D', ID_SCH_UNFOLD_BUS );
static EDA_HOTKEY HkUnfoldBus( _HKI( "Unfold Bus" ), HK_UNFOLD_BUS, 'D' + GR_KB_CTRL,
ID_SCH_UNFOLD_BUS );
// Common: hotkeys_basic.h
static EDA_HOTKEY HkNew( _HKI( "New" ), HK_NEW, GR_KB_CTRL + 'N', (int) wxID_NEW );
@ -492,16 +492,6 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_DELETE:
if( blocInProgress )
{
cmd.SetId( ID_POPUP_DELETE_BLOCK );
GetEventHandler()->ProcessEvent( cmd );
}
else
GetToolManager()->RunAction( SCH_ACTIONS::remove, true );
break;
case HK_REPEAT_LAST:
if( notBusy )
RepeatDrawItem();
@ -542,29 +532,6 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
}
break;
case HK_DUPLICATE_ITEM: // Duplicate component or text/label
if( itemInEdit )
break;
if( aItem == NULL )
{
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
aItem = selTool->SelectPoint( aPosition, SCH_COLLECTOR::CopyableItems );
if( aItem == NULL )
break;
}
cmd.SetId( hotKey->m_IdMenuEvent );
wxPostEvent( this, cmd );
break;
case HK_DRAG: // Start drag
case HK_MOVE_COMPONENT_OR_ITEM: // Start move schematic item.
if( ! notBusy )
break;
// Fall through
case HK_EDIT:
// Edit schematic item. Do not allow sheet editing when mowing because sheet editing
// can be complex.
@ -576,10 +543,6 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_EDIT_COMPONENT_REFERENCE: // Edit component value reference.
case HK_EDIT_COMPONENT_FOOTPRINT: // Edit component footprint field.
case HK_SHOW_COMPONENT_DATASHEET: // Show component datasheet in browser.
case HK_MIRROR_Y: // Mirror Y
case HK_MIRROR_X: // Mirror X
case HK_ORIENT_NORMAL_COMPONENT: // Orient 0, no mirror (Component)
case HK_ROTATE: // Rotate schematic item.
case HK_EDIT_COMPONENT_WITH_LIBEDIT: // Call Libedit and load the current component
case HK_AUTOPLACE_FIELDS: // Autoplace all fields around component
case HK_UNFOLD_BUS: // Unfold a bus wire

View File

@ -56,7 +56,7 @@ enum hotkey_id_commnand {
HK_MIRROR_Y,
HK_ORIENT_NORMAL_COMPONENT,
HK_MOVE_COMPONENT_OR_ITEM,
HK_DUPLICATE_ITEM,
HK_DUPLICATE,
HK_DRAG,
HK_ADD_NEW_COMPONENT,
HK_ADD_NEW_POWER,

View File

@ -416,8 +416,8 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, SYMBOL_LIB
if( !Component->GetEditFlags() )
{
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr,
HK_DUPLICATE_ITEM );
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE_ITEM, msg, KiBitmap( duplicate_xpm ) );
HK_DUPLICATE );
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE, msg, KiBitmap( duplicate_xpm ) );
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_CMP, msg, KiBitmap( delete_xpm ) );
}
@ -537,8 +537,8 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
HK_DRAG );
AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr,
HK_DUPLICATE_ITEM );
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE_ITEM, msg, KiBitmap( duplicate_xpm ) );
HK_DUPLICATE );
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE, msg, KiBitmap( duplicate_xpm ) );
}
msg = AddHotkeyName( _( "Rotate Clockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
@ -573,8 +573,8 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
msg = AddHotkeyName( _( "Copy" ), g_Schematic_Hotkeys_Descr,
HK_DUPLICATE_ITEM );
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE_ITEM, msg, KiBitmap( copy_xpm ) );
HK_DUPLICATE );
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE, msg, KiBitmap( copy_xpm ) );
}
msg = AddHotkeyName( _( "Rotate Clockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
@ -607,8 +607,8 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr, HK_DUPLICATE_ITEM );
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE_ITEM, msg, KiBitmap( duplicate_xpm ) );
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr, HK_DUPLICATE );
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE, msg, KiBitmap( duplicate_xpm ) );
}
msg = AddHotkeyName( _( "Rotate Counterclockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
@ -639,8 +639,8 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
{
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr, HK_DUPLICATE_ITEM );
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE_ITEM, msg, KiBitmap( duplicate_xpm ) );
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr, HK_DUPLICATE );
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE, msg, KiBitmap( duplicate_xpm ) );
}
msg = AddHotkeyName( _( "Rotate Counterclockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );

View File

@ -232,8 +232,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
EVT_MENU( ID_POPUP_SCH_SELECT_ON_PCB, SCH_EDIT_FRAME::SelectAllFromSheet )
EVT_MENU( ID_POPUP_SCH_DUPLICATE_ITEM, SCH_EDIT_FRAME::OnDuplicateItem )
EVT_MENU( ID_CONFIG_SAVE, SCH_EDIT_FRAME::Process_Config )
EVT_MENU( ID_CONFIG_READ, SCH_EDIT_FRAME::Process_Config )
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, SCH_EDIT_FRAME::Process_Config )
@ -272,7 +270,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( wxID_REPLACE, SCH_EDIT_FRAME::OnFindItems )
EVT_TOOL( ID_BACKANNO_ITEMS, SCH_EDIT_FRAME::OnLoadCmpToFootprintLinkFile )
EVT_TOOL( ID_UPDATE_FIELDS, SCH_EDIT_FRAME::OnUpdateFields )
EVT_TOOL( ID_SCH_MOVE_ITEM, SCH_EDIT_FRAME::OnMoveItem )
EVT_TOOL( ID_AUTOPLACE_FIELDS, SCH_EDIT_FRAME::OnAutoplaceFields )
EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )

View File

@ -327,113 +327,6 @@ void SCH_EDIT_FRAME::OnUnfoldBus( wxCommandEvent& event )
}
void SCH_EDIT_FRAME::OnDuplicateItem( wxCommandEvent& event )
{
SCH_ITEM* curr_item = GetScreen()->GetCurItem();
if( !curr_item || curr_item->GetEditFlags() )
return;
GetCanvas()->GetViewControls()->SetCursorPosition( GetCrossHairPosition() );
switch( curr_item->Type() )
{
case SCH_COMPONENT_T:
{
SCH_COMPONENT* newitem = new SCH_COMPONENT( *( (SCH_COMPONENT*) curr_item ) );
newitem->SetTimeStamp( GetNewTimeStamp() );
newitem->ClearAnnotation( NULL );
newitem->SetFlags( IS_NEW );
// Draw the new part, MoveItem() expects it to be already on screen.
PrepareMoveItem( newitem );
}
break;
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIER_LABEL_T:
{
SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone();
newitem->SetFlags( IS_NEW );
// Draw the new item, MoveItem() expects it to be already on screen.
PrepareMoveItem( newitem );
}
break;
default:
break;
}
}
void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
{
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
SCH_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem();
// trying to move an item when there is a block at the same time is not acceptable
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
return;
if( item == NULL )
{
// If we didn't get here by a hot key, then something has gone wrong.
if( aEvent.GetInt() == 0 )
return;
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
item = selTool->SelectPoint( data->GetPosition(), SCH_COLLECTOR::MovableItems );
// Exit if no item found at the current location or the item is already being edited.
if( item == NULL || item->GetEditFlags() != 0 )
return;
}
SetCrossHairPosition( item->GetPosition(), false );
GetCanvas()->GetViewControls()->WarpCursor( GetCrossHairPosition(), true );
switch( item->Type() )
{
case SCH_LINE_T:
break;
case SCH_JUNCTION_T:
case SCH_NO_CONNECT_T:
case SCH_BUS_BUS_ENTRY_T:
case SCH_BUS_WIRE_ENTRY_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_TEXT_T:
case SCH_COMPONENT_T:
case SCH_SHEET_PIN_T:
case SCH_FIELD_T:
case SCH_SHEET_T:
case SCH_BITMAP_T:
PrepareMoveItem( item );
break;
case SCH_MARKER_T:
// Moving a marker has no sense
break;
default:
// Unknown items cannot be moved
wxFAIL_MSG( wxString::Format( "Cannot move item type %d", item->Type() ) );
break;
}
if( GetToolId() == ID_NO_TOOL_SELECTED )
SetRepeatItem( NULL );
}
void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
{
SCH_SCREEN* screen = GetScreen();

View File

@ -203,6 +203,9 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
case ID_SCH_MIRROR_Y:
return SCH_ACTIONS::mirrorY.MakeEvent();
case ID_POPUP_SCH_DUPLICATE:
return SCH_ACTIONS::duplicate.MakeEvent();
}
return OPT<TOOL_EVENT>();

View File

@ -112,7 +112,6 @@ public:
static TOOL_ACTION finishDrawing;
// Editing
static TOOL_ACTION editActivate;
static TOOL_ACTION move;
static TOOL_ACTION duplicate;
static TOOL_ACTION rotateCW;

View File

@ -36,39 +36,31 @@
#include <sch_view.h>
#include <sch_item_struct.h>
#include <sch_edit_frame.h>
TOOL_ACTION SCH_ACTIONS::editActivate( "eeschema.InteractiveEdit",
AS_GLOBAL, 0,
_( "Edit Activate" ), "", move_xpm, AF_ACTIVATE );
#include <list_operations.h>
TOOL_ACTION SCH_ACTIONS::move( "eeschema.InteractiveEdit.move",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MOVE_COMPONENT_OR_ITEM ),
_( "Move" ), _( "Moves the selected item(s)" ), move_xpm, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::duplicate( "eeschema.InteractiveEdit.duplicate",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DUPLICATE_ITEM ),
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DUPLICATE ),
_( "Duplicate" ), _( "Duplicates the selected item(s)" ), duplicate_xpm );
TOOL_ACTION SCH_ACTIONS::rotateCW( "eeschema.InteractiveEdit.rotateCW",
AS_GLOBAL, 0,
_( "Rotate Clockwise" ), _( "Rotates selected item(s) clockwise" ),
rotate_cw_xpm, AF_NONE );
_( "Rotate Clockwise" ), _( "Rotates selected item(s) clockwise" ), rotate_cw_xpm );
TOOL_ACTION SCH_ACTIONS::rotateCCW( "eeschema.InteractiveEdit.rotateCCW",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROTATE ),
_( "Rotate" ), _( "Rotates selected item(s) counter-clockwise" ),
rotate_ccw_xpm, AF_NONE );
_( "Rotate" ), _( "Rotates selected item(s) counter-clockwise" ), rotate_ccw_xpm );
TOOL_ACTION SCH_ACTIONS::mirrorX( "eeschema.InteractiveEdit.mirrorX",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MIRROR_X ),
_( "Mirror X" ), _( "Mirrors selected item(s) across the X axis" ),
mirror_h_xpm, AF_NONE );
_( "Mirror X" ), _( "Mirrors selected item(s) across the X axis" ), mirror_h_xpm );
TOOL_ACTION SCH_ACTIONS::mirrorY( "eeschema.InteractiveEdit.mirrorY",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MIRROR_Y ),
_( "Mirror Y" ), _( "Mirrors selected item(s) across the Y axis" ),
mirror_v_xpm, AF_NONE );
_( "Mirror Y" ), _( "Mirrors selected item(s) across the Y axis" ), mirror_v_xpm );
TOOL_ACTION SCH_ACTIONS::properties( "eeschema.InteractiveEdit.properties",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT ),
@ -76,7 +68,7 @@ TOOL_ACTION SCH_ACTIONS::properties( "eeschema.InteractiveEdit.properties",
TOOL_ACTION SCH_ACTIONS::remove( "eeschema.InteractiveEdit.remove",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DELETE ),
_( "Delete" ), _( "Deletes selected item(s)" ), delete_xpm, AF_NONE );
_( "Delete" ), _( "Deletes selected item(s)" ), delete_xpm );
SCH_EDIT_TOOL::SCH_EDIT_TOOL() :
@ -88,7 +80,7 @@ SCH_EDIT_TOOL::SCH_EDIT_TOOL() :
m_menu( *this ),
m_dragging( false )
{
};
}
SCH_EDIT_TOOL::~SCH_EDIT_TOOL()
@ -161,8 +153,7 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
{
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
if( evt->IsAction( &SCH_ACTIONS::editActivate ) || evt->IsAction( &SCH_ACTIONS::move )
|| evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
if( evt->IsAction( &SCH_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
{
if( m_dragging && evt->Category() == TC_MOUSE )
{
@ -624,6 +615,96 @@ int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
}
int SCH_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
{
SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
SELECTION selection = selTool->RequestSelection( SCH_COLLECTOR::DraggableItems );
if( selection.GetSize() == 0 )
return 0;
std::vector<SCH_ITEM*> newItems;
// Keep track of existing sheet paths. Duplicating a selection can modify this list
bool hasSheetCopied = false;
SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
{
SCH_ITEM* oldItem = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
SCH_ITEM* newItem = DuplicateStruct( oldItem );
newItems.push_back( newItem );
m_frame->SaveCopyInUndoList( newItem, UR_NEW, ii > 0 );
switch( newItem->Type() )
{
case SCH_JUNCTION_T:
case SCH_LINE_T:
case SCH_BUS_BUS_ENTRY_T:
case SCH_BUS_WIRE_ENTRY_T:
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_MARKER_T:
case SCH_NO_CONNECT_T:
newItem->SetParent( m_frame->GetScreen() );
m_frame->AddToScreen( newItem );
break;
case SCH_SHEET_T:
{
SCH_SHEET* sheet = (SCH_SHEET*) newItem;
// Duplicate sheet names and sheet time stamps are not valid. Use a time stamp
// based sheet name and update the time stamp for each sheet in the block.
timestamp_t timeStamp = GetNewTimeStamp();
sheet->SetName( wxString::Format( wxT( "sheet%8.8lX" ), (unsigned long)timeStamp ) );
sheet->SetTimeStamp( timeStamp );
sheet->SetParent( m_frame->GetScreen() );
m_frame->AddToScreen( sheet );
hasSheetCopied = true;
break;
}
case SCH_COMPONENT_T:
{
SCH_COMPONENT* component = (SCH_COMPONENT*) newItem;
component->SetTimeStamp( GetNewTimeStamp() );
component->ClearAnnotation( NULL );
component->SetParent( m_frame->GetScreen() );
m_frame->AddToScreen( component );
break;
}
default:
break;
}
}
if( hasSheetCopied )
{
// We clear annotation of new sheet paths.
// Annotation of new components added in current sheet is already cleared.
SCH_SCREENS screensList( g_RootSheet );
screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
}
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
m_toolMgr->RunAction( SCH_ACTIONS::selectItems, true, &newItems );
TOOL_EVENT evt = SCH_ACTIONS::move.MakeEvent();
Main( evt );
return 0;
}
int SCH_EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
{
SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
@ -645,7 +726,7 @@ int SCH_EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
m_frame->GetScreen()->SetCurItem( nullptr );
m_frame->SetRepeatItem( nullptr );
m_frame->DeleteItem( item );
m_frame->DeleteItem( item, ii > 0 );
if( itemHasConnections )
m_frame->TestDanglingEnds();
@ -671,8 +752,8 @@ void SCH_EDIT_TOOL::updateView( EDA_ITEM* aItem )
void SCH_EDIT_TOOL::setTransitions()
{
Go( &SCH_EDIT_TOOL::Main, SCH_ACTIONS::editActivate.MakeEvent() );
Go( &SCH_EDIT_TOOL::Main, SCH_ACTIONS::move.MakeEvent() );
Go( &SCH_EDIT_TOOL::Duplicate, SCH_ACTIONS::duplicate.MakeEvent() );
Go( &SCH_EDIT_TOOL::Rotate, SCH_ACTIONS::rotateCW.MakeEvent() );
Go( &SCH_EDIT_TOOL::Rotate, SCH_ACTIONS::rotateCCW.MakeEvent() );
Go( &SCH_EDIT_TOOL::Mirror, SCH_ACTIONS::mirrorX.MakeEvent() );

View File

@ -54,13 +54,15 @@ public:
/**
* Function Main()
*
* Main loop in which events are handled.
* Runs an interactive move of the selected items, or the item under the cursor.
*/
int Main( const TOOL_EVENT& aEvent );
int Rotate( const TOOL_EVENT& aEvent );
int Mirror( const TOOL_EVENT& aEvent );
int Duplicate( const TOOL_EVENT& aEvent );
/**
* Function Remove()
*

View File

@ -499,12 +499,12 @@ bool SCH_SELECTION_TOOL::selectMultiple()
int SCH_SELECTION_TOOL::SelectItems( const TOOL_EVENT& aEvent )
{
PICKED_ITEMS_LIST* pickedItems = aEvent.Parameter<PICKED_ITEMS_LIST*>();
std::vector<SCH_ITEM*>* items = aEvent.Parameter<std::vector<SCH_ITEM*>*>();
if( pickedItems )
if( items )
{
for( unsigned ii = 0; ii < pickedItems->GetCount(); ii++ )
select( (SCH_ITEM*) pickedItems->GetPickedItem( ii ) );
for( SCH_ITEM* item : *items )
select( item );
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
}
@ -532,12 +532,12 @@ int SCH_SELECTION_TOOL::SelectItem( const TOOL_EVENT& aEvent )
int SCH_SELECTION_TOOL::UnselectItems( const TOOL_EVENT& aEvent )
{
PICKED_ITEMS_LIST* pickedItems = aEvent.Parameter<PICKED_ITEMS_LIST*>();
std::vector<SCH_ITEM*>* items = aEvent.Parameter<std::vector<SCH_ITEM*>*>();
if( pickedItems )
if( items )
{
for( unsigned ii = 0; ii < pickedItems->GetCount(); ii++ )
unselect( (SCH_ITEM*) pickedItems->GetPickedItem( ii ) );
for( SCH_ITEM* item : *items )
unselect( item );
m_toolMgr->ProcessEvent( EVENTS::UnselectedEvent );
}

View File

@ -313,7 +313,7 @@ bool FOOTPRINT_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMen
msg = AddHotkeyName( _("Delete Pad" ), g_Module_Editor_Hotkeys_Descr, HK_DELETE );
AddMenuItem( PopMenu, ID_POPUP_PCB_DELETE_PAD, msg, KiBitmap( delete_pad_xpm ) );
msg = AddHotkeyName( _( "Duplicate Pad" ), g_Module_Editor_Hotkeys_Descr, HK_DUPLICATE_ITEM );
msg = AddHotkeyName( _( "Duplicate Pad" ), g_Module_Editor_Hotkeys_Descr, HK_DUPLICATE );
AddMenuItem( PopMenu, ID_POPUP_PCB_DUPLICATE_ITEM, msg, KiBitmap( duplicate_xpm ) );
msg = AddHotkeyName( _("Move Pad Exactly..." ), g_Module_Editor_Hotkeys_Descr, HK_MOVE_ITEM_EXACT );
@ -355,7 +355,7 @@ bool FOOTPRINT_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMen
if( &module->Reference() != text && &module->Value() != text )
{
msg = AddHotkeyName( _( "Duplicate" ),
g_Module_Editor_Hotkeys_Descr, HK_DUPLICATE_ITEM );
g_Module_Editor_Hotkeys_Descr, HK_DUPLICATE );
AddMenuItem( PopMenu, ID_POPUP_PCB_DUPLICATE_ITEM,
msg, KiBitmap( duplicate_xpm ) );
@ -396,7 +396,7 @@ bool FOOTPRINT_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMen
msg = AddHotkeyName( _("Move" ), g_Module_Editor_Hotkeys_Descr, HK_MOVE_ITEM );
AddMenuItem( PopMenu, ID_POPUP_PCB_MOVE_EDGE, msg, KiBitmap( move_xpm ) );
msg = AddHotkeyName( _( "Duplicate" ), g_Module_Editor_Hotkeys_Descr, HK_DUPLICATE_ITEM );
msg = AddHotkeyName( _( "Duplicate" ), g_Module_Editor_Hotkeys_Descr, HK_DUPLICATE );
AddMenuItem( PopMenu, ID_POPUP_PCB_DUPLICATE_ITEM, msg, KiBitmap( duplicate_xpm ) );
msg = AddHotkeyName( _("Move Exactly..." ), g_Module_Editor_Hotkeys_Descr, HK_MOVE_ITEM_EXACT );

View File

@ -144,7 +144,7 @@ static EDA_HOTKEY HkMoveItemExact( _HKI( "Move Item Exactly" ), HK_MOVE_ITEM_EXA
'M' + GR_KB_CTRL );
static EDA_HOTKEY HkPositionItemRelative( _HKI( "Position Item Relative" ), HK_POSITION_RELATIVE,
'P' + GR_KB_SHIFT );
static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate Item" ), HK_DUPLICATE_ITEM, 'D' + GR_KB_CTRL );
static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate Item" ), HK_DUPLICATE, 'D' + GR_KB_CTRL );
static EDA_HOTKEY HkDuplicateItemAndIncrement( _HKI( "Duplicate Item and Increment" ),
HK_DUPLICATE_ITEM_AND_INCREMENT,
'D' + GR_KB_SHIFTCTRL );

View File

@ -70,7 +70,7 @@ enum hotkey_id_commnand {
HK_FIND_ITEM,
HK_EDIT_ITEM,
HK_EDIT_MODULE_WITH_MODEDIT,
HK_DUPLICATE_ITEM,
HK_DUPLICATE,
HK_DUPLICATE_ITEM_AND_INCREMENT,
HK_CREATE_ARRAY,
HK_PLACE_ITEM,

View File

@ -479,7 +479,7 @@ bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
break;
case HK_MOVE_ITEM_EXACT:
case HK_DUPLICATE_ITEM:
case HK_DUPLICATE:
case HK_DUPLICATE_ITEM_AND_INCREMENT:
case HK_CREATE_ARRAY:
OnHotkeyDuplicateOrArrayItem( HK_Descr->m_Idcommand );
@ -1093,7 +1093,7 @@ bool PCB_EDIT_FRAME::OnHotkeyDuplicateOrArrayItem( int aIdCommand )
evt_type = ID_POPUP_PCB_DUPLICATE_ITEM_AND_INCREMENT;
break;
case HK_DUPLICATE_ITEM:
case HK_DUPLICATE:
if( canDuplicate )
evt_type = ID_POPUP_PCB_DUPLICATE_ITEM;
break;

View File

@ -193,7 +193,7 @@ bool FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPos
OnHotkeyRotateItem( HK_ROTATE_ITEM );
break;
case HK_DUPLICATE_ITEM:
case HK_DUPLICATE:
case HK_DUPLICATE_ITEM_AND_INCREMENT:
OnHotkeyDuplicateItem( HK_Descr->m_Idcommand );
break;
@ -391,7 +391,7 @@ bool FOOTPRINT_EDIT_FRAME::OnHotkeyDuplicateItem( int aIdCommand )
case PCB_PAD_T:
case PCB_MODULE_EDGE_T:
case PCB_MODULE_TEXT_T:
if( aIdCommand == HK_DUPLICATE_ITEM )
if( aIdCommand == HK_DUPLICATE )
evt_type = ID_POPUP_PCB_DUPLICATE_ITEM;
else
evt_type = ID_POPUP_PCB_DUPLICATE_ITEM_AND_INCREMENT;

View File

@ -167,7 +167,7 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
msg, KiBitmap( move_xpm ) );
msg = AddHotkeyName( _( "Duplicate" ), g_Board_Editor_Hotkeys_Descr,
HK_DUPLICATE_ITEM );
HK_DUPLICATE );
AddMenuItem( aPopMenu, ID_POPUP_PCB_DUPLICATE_ITEM,
msg, KiBitmap( duplicate_xpm ) );
@ -238,7 +238,7 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
msg, KiBitmap( move_xpm ) );
msg = AddHotkeyName( _( "Duplicate" ), g_Board_Editor_Hotkeys_Descr,
HK_DUPLICATE_ITEM );
HK_DUPLICATE );
AddMenuItem( aPopMenu, ID_POPUP_PCB_DUPLICATE_ITEM,
msg, KiBitmap( duplicate_xpm ) );
@ -269,7 +269,7 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
msg, KiBitmap( move_exactly_xpm ) );
msg = AddHotkeyName( _( "Duplicate" ), g_Board_Editor_Hotkeys_Descr,
HK_DUPLICATE_ITEM );
HK_DUPLICATE );
AddMenuItem( aPopMenu, ID_POPUP_PCB_DUPLICATE_ITEM,
msg, KiBitmap( duplicate_xpm ) );
@ -470,7 +470,7 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu )
msg, KiBitmap( drag_xpm ) );
msg = AddHotkeyName( _( "Duplicate" ), g_Board_Editor_Hotkeys_Descr,
HK_DUPLICATE_ITEM );
HK_DUPLICATE );
AddMenuItem( PopMenu, ID_POPUP_PCB_DUPLICATE_ITEM,
msg, KiBitmap( duplicate_xpm ) );
@ -771,7 +771,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* menu
msg, KiBitmap( move_exactly_xpm ) );
msg = AddHotkeyName( _( "Duplicate" ), g_Board_Editor_Hotkeys_Descr,
HK_DUPLICATE_ITEM );
HK_DUPLICATE );
AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_DUPLICATE_ITEM,
msg, KiBitmap( duplicate_xpm ) );

View File

@ -88,7 +88,7 @@ TOOL_ACTION PCB_ACTIONS::move( "pcbnew.InteractiveEdit.move",
_( "Move" ), _( "Moves the selected item(s)" ), move_xpm, AF_ACTIVATE );
TOOL_ACTION PCB_ACTIONS::duplicate( "pcbnew.InteractiveEdit.duplicate",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DUPLICATE_ITEM ),
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DUPLICATE ),
_( "Duplicate" ), _( "Duplicates the selected item(s)" ), duplicate_xpm );
TOOL_ACTION PCB_ACTIONS::duplicateIncrement( "pcbnew.InteractiveEdit.duplicateIncrementPads",