Implement drag in modern toolset.
This commit is contained in:
parent
57a491357f
commit
de347998d1
|
@ -128,10 +128,7 @@ enum id_eeschema_frm
|
||||||
ID_TB_OPTIONS_BUS_WIRES_ORIENT,
|
ID_TB_OPTIONS_BUS_WIRES_ORIENT,
|
||||||
|
|
||||||
/* Schematic editor context menu IDs. */
|
/* Schematic editor context menu IDs. */
|
||||||
ID_POPUP_SCH_DUPLICATE,
|
|
||||||
|
|
||||||
ID_POPUP_START_RANGE,
|
ID_POPUP_START_RANGE,
|
||||||
ID_POPUP_SCH_DELETE,
|
|
||||||
ID_POPUP_SCH_BREAK_WIRE,
|
ID_POPUP_SCH_BREAK_WIRE,
|
||||||
ID_POPUP_SCH_BEGIN_WIRE,
|
ID_POPUP_SCH_BEGIN_WIRE,
|
||||||
ID_POPUP_SCH_BEGIN_BUS,
|
ID_POPUP_SCH_BEGIN_BUS,
|
||||||
|
@ -197,8 +194,10 @@ enum id_eeschema_frm
|
||||||
ID_SCH_EDIT_COMPONENT_VALUE,
|
ID_SCH_EDIT_COMPONENT_VALUE,
|
||||||
ID_SCH_EDIT_COMPONENT_REFERENCE,
|
ID_SCH_EDIT_COMPONENT_REFERENCE,
|
||||||
ID_SCH_EDIT_COMPONENT_FOOTPRINT,
|
ID_SCH_EDIT_COMPONENT_FOOTPRINT,
|
||||||
ID_SCH_MOVE_ITEM,
|
ID_SCH_MOVE,
|
||||||
ID_SCH_DRAG_ITEM,
|
ID_SCH_DRAG,
|
||||||
|
ID_SCH_DUPLICATE,
|
||||||
|
ID_SCH_DELETE,
|
||||||
ID_SCH_UNFOLD_BUS,
|
ID_SCH_UNFOLD_BUS,
|
||||||
|
|
||||||
ID_AUTOPLACE_FIELDS,
|
ID_AUTOPLACE_FIELDS,
|
||||||
|
|
|
@ -175,12 +175,12 @@ static EDA_HOTKEY HkEditComponentWithLibedit( _HKI( "Edit with Symbol Editor" ),
|
||||||
ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP );
|
ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP );
|
||||||
|
|
||||||
static EDA_HOTKEY HkMove( _HKI( "Move Schematic Item" ), HK_MOVE_COMPONENT_OR_ITEM, 'M',
|
static EDA_HOTKEY HkMove( _HKI( "Move Schematic Item" ), HK_MOVE_COMPONENT_OR_ITEM, 'M',
|
||||||
ID_SCH_MOVE_ITEM );
|
ID_SCH_MOVE );
|
||||||
|
|
||||||
static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate" ), HK_DUPLICATE, 'D' + GR_KB_CTRL,
|
static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate" ), HK_DUPLICATE, 'D' + GR_KB_CTRL,
|
||||||
ID_POPUP_SCH_DUPLICATE );
|
ID_SCH_DUPLICATE );
|
||||||
|
|
||||||
static EDA_HOTKEY HkDrag( _HKI( "Drag Item" ), HK_DRAG, 'G', ID_SCH_DRAG_ITEM );
|
static EDA_HOTKEY HkDrag( _HKI( "Drag Item" ), HK_DRAG, 'G', ID_SCH_DRAG );
|
||||||
static EDA_HOTKEY HkMove2Drag( _HKI( "Move Block -> Drag Block" ),
|
static EDA_HOTKEY HkMove2Drag( _HKI( "Move Block -> Drag Block" ),
|
||||||
HK_MOVEBLOCK_TO_DRAGBLOCK, '\t', ID_POPUP_DRAG_BLOCK );
|
HK_MOVEBLOCK_TO_DRAGBLOCK, '\t', ID_POPUP_DRAG_BLOCK );
|
||||||
static EDA_HOTKEY HkInsert( _HKI( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT );
|
static EDA_HOTKEY HkInsert( _HKI( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT );
|
||||||
|
|
|
@ -229,7 +229,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
||||||
switch( item->Type() )
|
switch( item->Type() )
|
||||||
{
|
{
|
||||||
case SCH_NO_CONNECT_T:
|
case SCH_NO_CONNECT_T:
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete No Connect" ),
|
AddMenuItem( PopMenu, ID_SCH_DELETE, _( "Delete No Connect" ),
|
||||||
KiBitmap( delete_xpm ) );
|
KiBitmap( delete_xpm ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
||||||
|
|
||||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, _( "Edit..." ),
|
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, _( "Edit..." ),
|
||||||
KiBitmap( edit_xpm ) );
|
KiBitmap( edit_xpm ) );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Drawing" ),
|
AddMenuItem( PopMenu, ID_SCH_DELETE, _( "Delete Drawing" ),
|
||||||
KiBitmap( delete_xpm ) );
|
KiBitmap( delete_xpm ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field )
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = AddHotkeyName( name, g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
|
msg = AddHotkeyName( name, g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
|
||||||
AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_MOVE, msg, KiBitmap( move_xpm ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( Field->GetId() )
|
switch( Field->GetId() )
|
||||||
|
@ -390,9 +390,9 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, SYMBOL_LIB
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Move %s" ), Component->GetField( REFERENCE )->GetText() );
|
msg.Printf( _( "Move %s" ), Component->GetField( REFERENCE )->GetText() );
|
||||||
msg = AddHotkeyName( msg, g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
|
msg = AddHotkeyName( msg, g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
|
||||||
AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_MOVE, msg, KiBitmap( move_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
|
msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
|
||||||
AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DRAG, msg, KiBitmap( drag_xpm ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenu* orientmenu = new wxMenu;
|
wxMenu* orientmenu = new wxMenu;
|
||||||
|
@ -417,7 +417,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, SYMBOL_LIB
|
||||||
{
|
{
|
||||||
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr,
|
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr,
|
||||||
HK_DUPLICATE );
|
HK_DUPLICATE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE, msg, KiBitmap( duplicate_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DUPLICATE, msg, KiBitmap( duplicate_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_CMP, msg, KiBitmap( delete_xpm ) );
|
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_CMP, msg, KiBitmap( delete_xpm ) );
|
||||||
}
|
}
|
||||||
|
@ -532,13 +532,13 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
|
||||||
{
|
{
|
||||||
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr,
|
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr,
|
||||||
HK_MOVE_COMPONENT_OR_ITEM );
|
HK_MOVE_COMPONENT_OR_ITEM );
|
||||||
AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_MOVE, msg, KiBitmap( move_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr,
|
msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr,
|
||||||
HK_DRAG );
|
HK_DRAG );
|
||||||
AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DRAG, msg, KiBitmap( drag_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr,
|
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr,
|
||||||
HK_DUPLICATE );
|
HK_DUPLICATE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE, msg, KiBitmap( duplicate_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DUPLICATE, msg, KiBitmap( duplicate_xpm ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Rotate Clockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
|
msg = AddHotkeyName( _( "Rotate Clockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
|
||||||
|
@ -546,7 +546,7 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
|
||||||
msg = AddHotkeyName( _( "Edit..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
|
msg = AddHotkeyName( _( "Edit..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
|
||||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
||||||
|
|
||||||
// add menu change type text (to label, glabel, text):
|
// add menu change type text (to label, glabel, text):
|
||||||
AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
|
AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
|
||||||
|
@ -569,12 +569,12 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
|
||||||
{
|
{
|
||||||
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr,
|
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr,
|
||||||
HK_MOVE_COMPONENT_OR_ITEM );
|
HK_MOVE_COMPONENT_OR_ITEM );
|
||||||
AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_MOVE, msg, KiBitmap( move_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
|
msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
|
||||||
AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DRAG, msg, KiBitmap( drag_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Copy" ), g_Schematic_Hotkeys_Descr,
|
msg = AddHotkeyName( _( "Copy" ), g_Schematic_Hotkeys_Descr,
|
||||||
HK_DUPLICATE );
|
HK_DUPLICATE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE, msg, KiBitmap( copy_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DUPLICATE, msg, KiBitmap( copy_xpm ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Rotate Clockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
|
msg = AddHotkeyName( _( "Rotate Clockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
|
||||||
|
@ -582,7 +582,7 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
|
||||||
msg = AddHotkeyName( _( "Edit..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
|
msg = AddHotkeyName( _( "Edit..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
|
||||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
||||||
|
|
||||||
// add menu change type text (to label, glabel, text):
|
// add menu change type text (to label, glabel, text):
|
||||||
AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
|
AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
|
||||||
|
@ -604,11 +604,11 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
|
||||||
if( !Label->GetEditFlags() )
|
if( !Label->GetEditFlags() )
|
||||||
{
|
{
|
||||||
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
|
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
|
||||||
AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_MOVE, msg, KiBitmap( move_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
|
msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
|
||||||
AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DRAG, msg, KiBitmap( drag_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr, HK_DUPLICATE );
|
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr, HK_DUPLICATE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE, msg, KiBitmap( duplicate_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DUPLICATE, msg, KiBitmap( duplicate_xpm ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Rotate Counterclockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
|
msg = AddHotkeyName( _( "Rotate Counterclockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
|
||||||
|
@ -616,7 +616,7 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
|
||||||
msg = AddHotkeyName( _( "Edit..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
|
msg = AddHotkeyName( _( "Edit..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
|
||||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
||||||
|
|
||||||
// add menu change type text (to label, glabel, text):
|
// add menu change type text (to label, glabel, text):
|
||||||
AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
|
AddMenuItem( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
|
||||||
|
@ -638,9 +638,9 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
|
||||||
if( !Text->GetEditFlags() )
|
if( !Text->GetEditFlags() )
|
||||||
{
|
{
|
||||||
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
|
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
|
||||||
AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_MOVE, msg, KiBitmap( move_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr, HK_DUPLICATE );
|
msg = AddHotkeyName( _( "Duplicate" ), g_Schematic_Hotkeys_Descr, HK_DUPLICATE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DUPLICATE, msg, KiBitmap( duplicate_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DUPLICATE, msg, KiBitmap( duplicate_xpm ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Rotate Counterclockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
|
msg = AddHotkeyName( _( "Rotate Counterclockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
|
||||||
|
@ -648,7 +648,7 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
|
||||||
msg = AddHotkeyName( _( "Edit..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
|
msg = AddHotkeyName( _( "Edit..." ), g_Schematic_Hotkeys_Descr, HK_EDIT );
|
||||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
||||||
|
|
||||||
/* add menu change type text (to label, glabel, text),
|
/* add menu change type text (to label, glabel, text),
|
||||||
* but only if this is a single line text
|
* but only if this is a single line text
|
||||||
|
@ -673,12 +673,12 @@ void SCH_EDIT_FRAME::addJunctionMenuEntries( wxMenu* aMenu, SCH_JUNCTION* aJunct
|
||||||
SCH_SCREEN* screen = GetScreen();
|
SCH_SCREEN* screen = GetScreen();
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Delete Junction" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
msg = AddHotkeyName( _( "Delete Junction" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
||||||
AddMenuItem( aMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
AddMenuItem( aMenu, ID_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
||||||
|
|
||||||
if( !aJunction->IsNew() )
|
if( !aJunction->IsNew() )
|
||||||
{
|
{
|
||||||
if( m_collectedItems.IsDraggableJunction() )
|
if( m_collectedItems.IsDraggableJunction() )
|
||||||
AddMenuItem( aMenu, ID_SCH_DRAG_ITEM, _( "Drag Junction" ), KiBitmap( drag_xpm ) );
|
AddMenuItem( aMenu, ID_SCH_DRAG, _( "Drag Junction" ), KiBitmap( drag_xpm ) );
|
||||||
|
|
||||||
if( screen->GetWire( aJunction->GetPosition(), EXCLUDE_END_POINTS_T ) )
|
if( screen->GetWire( aJunction->GetPosition(), EXCLUDE_END_POINTS_T ) )
|
||||||
AddMenuItem( aMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ),
|
AddMenuItem( aMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ),
|
||||||
|
@ -716,10 +716,10 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame )
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Drag Wire" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
|
msg = AddHotkeyName( _( "Drag Wire" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
|
||||||
AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DRAG, msg, KiBitmap( drag_xpm ) );
|
||||||
PopMenu->AppendSeparator();
|
PopMenu->AppendSeparator();
|
||||||
msg = AddHotkeyName( _( "Delete Wire" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
msg = AddHotkeyName( _( "Delete Wire" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ),
|
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ),
|
||||||
KiBitmap( delete_node_xpm ) );
|
KiBitmap( delete_node_xpm ) );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
|
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
|
||||||
|
@ -766,7 +766,7 @@ void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame )
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Delete Bus" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
msg = AddHotkeyName( _( "Delete Bus" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_bus_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DELETE, msg, KiBitmap( delete_bus_xpm ) );
|
||||||
|
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Bus" ), KiBitmap( break_bus_xpm ) );
|
AddMenuItem( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Bus" ), KiBitmap( break_bus_xpm ) );
|
||||||
|
|
||||||
|
@ -812,10 +812,10 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
|
||||||
PopMenu->AppendSeparator();
|
PopMenu->AppendSeparator();
|
||||||
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr,
|
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr,
|
||||||
HK_MOVE_COMPONENT_OR_ITEM );
|
HK_MOVE_COMPONENT_OR_ITEM );
|
||||||
AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_MOVE, msg, KiBitmap( move_xpm ) );
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
|
msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hotkeys_Descr, HK_DRAG );
|
||||||
AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DRAG, msg, KiBitmap( drag_xpm ) );
|
||||||
|
|
||||||
PopMenu->AppendSeparator();
|
PopMenu->AppendSeparator();
|
||||||
msg = AddHotkeyName( _( "Select Items On PCB" ), g_Schematic_Hotkeys_Descr,
|
msg = AddHotkeyName( _( "Select Items On PCB" ), g_Schematic_Hotkeys_Descr,
|
||||||
|
@ -862,7 +862,7 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
|
||||||
|
|
||||||
PopMenu->AppendSeparator();
|
PopMenu->AppendSeparator();
|
||||||
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_sheet_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DELETE, msg, KiBitmap( delete_sheet_xpm ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,13 +874,13 @@ void AddMenusForSheetPin( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet )
|
||||||
if( !PinSheet->GetEditFlags() )
|
if( !PinSheet->GetEditFlags() )
|
||||||
{
|
{
|
||||||
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
|
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
|
||||||
AddMenuItem( PopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_MOVE, msg, KiBitmap( move_xpm ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, _( "Edit..." ), KiBitmap( edit_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, _( "Edit..." ), KiBitmap( edit_xpm ) );
|
||||||
|
|
||||||
if( !PinSheet->GetEditFlags() )
|
if( !PinSheet->GetEditFlags() )
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete" ), KiBitmap( delete_xpm ) );
|
AddMenuItem( PopMenu, ID_SCH_DELETE, _( "Delete" ), KiBitmap( delete_xpm ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -936,7 +936,7 @@ void AddMenusForBlock( wxMenu* PopMenu, SCH_EDIT_FRAME* frame )
|
||||||
|
|
||||||
void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_FRAME* aFrame )
|
void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_FRAME* aFrame )
|
||||||
{
|
{
|
||||||
AddMenuItem( aPopMenu, ID_POPUP_SCH_DELETE, _( "Delete Marker" ), KiBitmap( delete_xpm ) );
|
AddMenuItem( aPopMenu, ID_SCH_DELETE, _( "Delete Marker" ), KiBitmap( delete_xpm ) );
|
||||||
AddMenuItem( aPopMenu, ID_POPUP_SCH_GETINFO_MARKER, _( "Marker Error Info" ),
|
AddMenuItem( aPopMenu, ID_POPUP_SCH_GETINFO_MARKER, _( "Marker Error Info" ),
|
||||||
KiBitmap( info_xpm ) );
|
KiBitmap( info_xpm ) );
|
||||||
}
|
}
|
||||||
|
@ -950,7 +950,7 @@ void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap )
|
||||||
{
|
{
|
||||||
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr,
|
msg = AddHotkeyName( _( "Move" ), g_Schematic_Hotkeys_Descr,
|
||||||
HK_MOVE_COMPONENT_OR_ITEM );
|
HK_MOVE_COMPONENT_OR_ITEM );
|
||||||
AddMenuItem( aPopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
|
AddMenuItem( aPopMenu, ID_SCH_MOVE, msg, KiBitmap( move_xpm ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Rotate Counterclockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
|
msg = AddHotkeyName( _( "Rotate Counterclockwise" ), g_Schematic_Hotkeys_Descr, HK_ROTATE );
|
||||||
|
@ -968,7 +968,7 @@ void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap )
|
||||||
{
|
{
|
||||||
aPopMenu->AppendSeparator();
|
aPopMenu->AppendSeparator();
|
||||||
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
||||||
AddMenuItem( aPopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
AddMenuItem( aPopMenu, ID_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -981,7 +981,7 @@ void AddMenusForBusEntry( wxMenu* aPopMenu, SCH_BUS_ENTRY_BASE* aBusEntry )
|
||||||
{
|
{
|
||||||
msg = AddHotkeyName( _( "Move Bus Entry" ), g_Schematic_Hotkeys_Descr,
|
msg = AddHotkeyName( _( "Move Bus Entry" ), g_Schematic_Hotkeys_Descr,
|
||||||
HK_MOVE_COMPONENT_OR_ITEM );
|
HK_MOVE_COMPONENT_OR_ITEM );
|
||||||
AddMenuItem( aPopMenu, ID_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
|
AddMenuItem( aPopMenu, ID_SCH_MOVE, msg, KiBitmap( move_xpm ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aBusEntry->GetBusEntryShape() == '\\' )
|
if( aBusEntry->GetBusEntryShape() == '\\' )
|
||||||
|
@ -992,5 +992,5 @@ void AddMenusForBusEntry( wxMenu* aPopMenu, SCH_BUS_ENTRY_BASE* aBusEntry )
|
||||||
_( "Set Bus Entry Shape \\" ), KiBitmap( change_entry_orient_xpm ) );
|
_( "Set Bus Entry Shape \\" ), KiBitmap( change_entry_orient_xpm ) );
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Delete Bus Entry" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
msg = AddHotkeyName( _( "Delete Bus Entry" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
||||||
AddMenuItem( aPopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
AddMenuItem( aPopMenu, ID_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ const KICAD_T SCH_COLLECTOR::MovableItems[] = {
|
||||||
SCH_NO_CONNECT_T,
|
SCH_NO_CONNECT_T,
|
||||||
SCH_BUS_BUS_ENTRY_T,
|
SCH_BUS_BUS_ENTRY_T,
|
||||||
SCH_BUS_WIRE_ENTRY_T,
|
SCH_BUS_WIRE_ENTRY_T,
|
||||||
// SCH_LINE_T,
|
SCH_LINE_T,
|
||||||
SCH_BITMAP_T,
|
SCH_BITMAP_T,
|
||||||
SCH_TEXT_T,
|
SCH_TEXT_T,
|
||||||
SCH_LABEL_T,
|
SCH_LABEL_T,
|
||||||
|
|
|
@ -282,7 +282,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||||
#endif /* KICAD_SPICE */
|
#endif /* KICAD_SPICE */
|
||||||
|
|
||||||
EVT_MENU( ID_CANCEL_CURRENT_COMMAND, SCH_EDIT_FRAME::OnCancelCurrentCommand )
|
EVT_MENU( ID_CANCEL_CURRENT_COMMAND, SCH_EDIT_FRAME::OnCancelCurrentCommand )
|
||||||
EVT_MENU( ID_SCH_DRAG_ITEM, SCH_EDIT_FRAME::OnDragItem )
|
|
||||||
EVT_MENU_RANGE( ID_SCH_EDIT_ITEM, ID_SCH_EDIT_COMPONENT_FOOTPRINT,
|
EVT_MENU_RANGE( ID_SCH_EDIT_ITEM, ID_SCH_EDIT_COMPONENT_FOOTPRINT,
|
||||||
SCH_EDIT_FRAME::OnEditItem )
|
SCH_EDIT_FRAME::OnEditItem )
|
||||||
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
|
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
|
||||||
|
|
|
@ -803,11 +803,6 @@ private:
|
||||||
*/
|
*/
|
||||||
void SelectAllFromSheet( wxCommandEvent& aEvent );
|
void SelectAllFromSheet( wxCommandEvent& aEvent );
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle the #ID_SCH_DRAG_ITEM event used to drag schematic items.
|
|
||||||
*/
|
|
||||||
void OnDragItem( wxCommandEvent& aEvent );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the keyboard hotkey for unfolding a bus
|
* Handles the keyboard hotkey for unfolding a bus
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -327,12 +327,6 @@ void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset )
|
||||||
wxPoint start = m_start;
|
wxPoint start = m_start;
|
||||||
wxPoint end = m_end;
|
wxPoint end = m_end;
|
||||||
|
|
||||||
if( ( m_Flags & STARTPOINT ) == 0 )
|
|
||||||
start += offset;
|
|
||||||
|
|
||||||
if( ( m_Flags & ENDPOINT ) == 0 )
|
|
||||||
end += offset;
|
|
||||||
|
|
||||||
GRLine( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y, width, color,
|
GRLine( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y, width, color,
|
||||||
getwxPenStyle( (PlotDashType) GetLineStyle() ) );
|
getwxPenStyle( (PlotDashType) GetLineStyle() ) );
|
||||||
}
|
}
|
||||||
|
@ -559,34 +553,6 @@ bool SCH_LINE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_LINE::IsSelectStateChanged( const wxRect& aRect )
|
|
||||||
{
|
|
||||||
bool previousState = IsSelected();
|
|
||||||
|
|
||||||
if( aRect.Contains( m_start ) && aRect.Contains( m_end ) )
|
|
||||||
{
|
|
||||||
SetFlags( SELECTED );
|
|
||||||
ClearFlags( STARTPOINT | ENDPOINT );
|
|
||||||
}
|
|
||||||
else if( aRect.Contains( m_start ) )
|
|
||||||
{
|
|
||||||
ClearFlags( STARTPOINT );
|
|
||||||
SetFlags( SELECTED | ENDPOINT );
|
|
||||||
}
|
|
||||||
else if( aRect.Contains( m_end ) )
|
|
||||||
{
|
|
||||||
ClearFlags( ENDPOINT );
|
|
||||||
SetFlags( SELECTED | STARTPOINT );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ClearFlags( SELECTED | STARTPOINT | ENDPOINT );
|
|
||||||
}
|
|
||||||
|
|
||||||
return previousState != IsSelected();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool SCH_LINE::IsConnectable() const
|
bool SCH_LINE::IsConnectable() const
|
||||||
{
|
{
|
||||||
if( m_Layer == LAYER_WIRE || m_Layer == LAYER_BUS )
|
if( m_Layer == LAYER_WIRE || m_Layer == LAYER_BUS )
|
||||||
|
|
|
@ -164,8 +164,6 @@ public:
|
||||||
|
|
||||||
bool IsDangling() const override { return m_startIsDangling || m_endIsDangling; }
|
bool IsDangling() const override { return m_startIsDangling || m_endIsDangling; }
|
||||||
|
|
||||||
bool IsSelectStateChanged( const wxRect& aRect ) override;
|
|
||||||
|
|
||||||
bool IsConnectable() const override;
|
bool IsConnectable() const override;
|
||||||
|
|
||||||
void GetConnectionPoints(std::vector< wxPoint >& aPoints ) const override;
|
void GetConnectionPoints(std::vector< wxPoint >& aPoints ) const override;
|
||||||
|
|
|
@ -759,16 +759,9 @@ void SCH_SCREEN::GetHierarchicalItems( EDA_ITEMS& aItems )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// JEY TODO: obsolete once LibEdit is moved to modern toolset
|
||||||
void SCH_SCREEN::SelectBlockItems()
|
void SCH_SCREEN::SelectBlockItems()
|
||||||
{
|
{
|
||||||
auto addConnections = [ this ]( SCH_ITEM* item ) -> void
|
|
||||||
{
|
|
||||||
std::vector< wxPoint > connections;
|
|
||||||
item->GetConnectionPoints( connections );
|
|
||||||
for( auto conn : connections )
|
|
||||||
addConnectedItemsToBlock( item, conn );
|
|
||||||
};
|
|
||||||
|
|
||||||
PICKED_ITEMS_LIST* pickedlist = &m_BlockLocate.GetItems();
|
PICKED_ITEMS_LIST* pickedlist = &m_BlockLocate.GetItems();
|
||||||
|
|
||||||
if( pickedlist->GetCount() == 0 )
|
if( pickedlist->GetCount() == 0 )
|
||||||
|
@ -781,125 +774,6 @@ void SCH_SCREEN::SelectBlockItems()
|
||||||
SCH_ITEM* item = (SCH_ITEM*) pickedlist->GetPickedItem( ii );
|
SCH_ITEM* item = (SCH_ITEM*) pickedlist->GetPickedItem( ii );
|
||||||
item->SetFlags( SELECTED );
|
item->SetFlags( SELECTED );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !m_BlockLocate.IsDragging() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Select all the items in the screen connected to the items in the block.
|
|
||||||
// be sure end lines that are on the block limits are seen inside this block
|
|
||||||
m_BlockLocate.Inflate( 1 );
|
|
||||||
unsigned last_select_id = pickedlist->GetCount();
|
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < last_select_id; ii++ )
|
|
||||||
{
|
|
||||||
SCH_ITEM* item = (SCH_ITEM*)pickedlist->GetPickedItem( ii );
|
|
||||||
item->SetFlags( IS_DRAGGED );
|
|
||||||
|
|
||||||
if( item->Type() == SCH_LINE_T )
|
|
||||||
{
|
|
||||||
item->IsSelectStateChanged( m_BlockLocate );
|
|
||||||
|
|
||||||
if( !item->IsSelected() )
|
|
||||||
{ // This is a special case:
|
|
||||||
// this selected wire has no ends in block.
|
|
||||||
// But it was selected (because it intersects the selecting area),
|
|
||||||
// so we must keep it selected and select items connected to it
|
|
||||||
// Note: another option could be: remove it from drag list
|
|
||||||
item->SetFlags( SELECTED | SKIP_STRUCT );
|
|
||||||
addConnections( item );
|
|
||||||
}
|
|
||||||
|
|
||||||
pickedlist->SetPickerFlags( item->GetFlags(), ii );
|
|
||||||
}
|
|
||||||
else if( item->IsConnectable() )
|
|
||||||
{
|
|
||||||
addConnections( item );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Select the items that are connected to a block object that was added
|
|
||||||
// to our selection list in the last step.
|
|
||||||
for( unsigned ii = last_select_id; ii < pickedlist->GetCount(); ii++ )
|
|
||||||
{
|
|
||||||
SCH_ITEM* item = (SCH_ITEM*)pickedlist->GetPickedItem( ii );
|
|
||||||
|
|
||||||
if( item->Type() == SCH_COMPONENT_T ||
|
|
||||||
item->Type() == SCH_BUS_BUS_ENTRY_T ||
|
|
||||||
item->Type() == SCH_BUS_WIRE_ENTRY_T ||
|
|
||||||
item->Type() == SCH_SHEET_T ||
|
|
||||||
( item->Type() == SCH_LINE_T && !( item->GetFlags() & ( ENDPOINT | STARTPOINT ) ) ) )
|
|
||||||
{
|
|
||||||
item->SetFlags( IS_DRAGGED );
|
|
||||||
addConnections( item );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_BlockLocate.Inflate( -1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SCH_SCREEN::addConnectedItemsToBlock( const SCH_ITEM* aItem, const wxPoint& position )
|
|
||||||
{
|
|
||||||
SCH_ITEM* item;
|
|
||||||
ITEM_PICKER picker;
|
|
||||||
|
|
||||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
|
||||||
{
|
|
||||||
|
|
||||||
if( !item->IsConnectable() || ( item->GetFlags() & SKIP_STRUCT )
|
|
||||||
|| !item->CanConnect( aItem ) || item == aItem )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// A line having 2 ends, it can be tested twice: one time per end
|
|
||||||
if( item->Type() == SCH_LINE_T )
|
|
||||||
{
|
|
||||||
SCH_LINE* line = (SCH_LINE*) item;
|
|
||||||
|
|
||||||
if( !item->HitTest( position ) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// First time through. Flags set to denote an end that is not moving
|
|
||||||
if( !item->IsSelected() )
|
|
||||||
item->SetFlags( CANDIDATE | STARTPOINT | ENDPOINT );
|
|
||||||
|
|
||||||
if( line->GetStartPoint() == position )
|
|
||||||
item->ClearFlags( STARTPOINT );
|
|
||||||
else if( line->GetEndPoint() == position )
|
|
||||||
item->ClearFlags( ENDPOINT );
|
|
||||||
else
|
|
||||||
// This picks up items such as labels that can connect to the middle of a line
|
|
||||||
item->ClearFlags( STARTPOINT | ENDPOINT );
|
|
||||||
}
|
|
||||||
// We want to move a mid-connected label or bus entry when the full line is being moved
|
|
||||||
else if( !item->IsSelected()
|
|
||||||
&& aItem->Type() == SCH_LINE_T
|
|
||||||
&& !( aItem->GetFlags() & ( ENDPOINT | STARTPOINT ) ) )
|
|
||||||
{
|
|
||||||
std::vector< wxPoint > connections;
|
|
||||||
item->GetConnectionPoints( connections );
|
|
||||||
|
|
||||||
for( auto conn : connections )
|
|
||||||
{
|
|
||||||
if( aItem->HitTest( conn ) )
|
|
||||||
{
|
|
||||||
item->SetFlags( CANDIDATE );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( item->IsSelected() )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if( ( item->GetFlags() & CANDIDATE ) || item->IsConnected( position ) ) // Deal with all non-line items
|
|
||||||
{
|
|
||||||
item->ClearFlags( CANDIDATE );
|
|
||||||
item->SetFlags( SELECTED );
|
|
||||||
picker.SetItem( item );
|
|
||||||
picker.SetFlags( item->GetFlags() );
|
|
||||||
m_BlockLocate.GetItems().PushItem( picker );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -102,18 +102,6 @@ private:
|
||||||
/// List of bus aliases stored in this screen
|
/// List of bus aliases stored in this screen
|
||||||
std::unordered_set< std::shared_ptr< BUS_ALIAS > > m_aliases;
|
std::unordered_set< std::shared_ptr< BUS_ALIAS > > m_aliases;
|
||||||
|
|
||||||
/**
|
|
||||||
* Add items connected at \a aPosition to the block pick list.
|
|
||||||
* <p>
|
|
||||||
* This method tests all connectable unselected items in the screen that are connected to
|
|
||||||
* \a aPosition and adds them to the block selection pick list. This is used when a block
|
|
||||||
* drag is being performed to ensure connections to items in the block are not lost.
|
|
||||||
*</p>
|
|
||||||
* @param aItem = The item we are connecting from
|
|
||||||
* @param aPosition = The connection point to test.
|
|
||||||
*/
|
|
||||||
void addConnectedItemsToBlock( const SCH_ITEM* aItem, const wxPoint& aPosition );
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -95,7 +95,7 @@
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_SCH_DELETE_CMP:
|
case ID_POPUP_SCH_DELETE_CMP:
|
||||||
case ID_POPUP_SCH_DELETE:
|
case ID_SCH_DELETE:
|
||||||
// Stop the current command (if any) but keep the current tool
|
// Stop the current command (if any) but keep the current tool
|
||||||
m_canvas->EndMouseCapture();
|
m_canvas->EndMouseCapture();
|
||||||
break;
|
break;
|
||||||
|
@ -188,7 +188,7 @@
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_SCH_DELETE_CMP:
|
case ID_POPUP_SCH_DELETE_CMP:
|
||||||
case ID_POPUP_SCH_DELETE:
|
case ID_SCH_DELETE:
|
||||||
if( item == NULL )
|
if( item == NULL )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -255,18 +255,6 @@
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_PLACE_BLOCK:
|
|
||||||
m_canvas->SetAutoPanRequest( false );
|
|
||||||
m_canvas->MoveCursorToCrossHair();
|
|
||||||
HandleBlockPlace( nullptr );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_POPUP_ZOOM_BLOCK:
|
|
||||||
screen->m_BlockLocate.SetCommand( BLOCK_ZOOM );
|
|
||||||
screen->m_BlockLocate.SetMessageBlock( this );
|
|
||||||
HandleBlockEnd( nullptr );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_POPUP_DELETE_BLOCK:
|
case ID_POPUP_DELETE_BLOCK:
|
||||||
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
|
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
|
||||||
break;
|
break;
|
||||||
|
@ -278,26 +266,6 @@
|
||||||
SetSheetNumberAndCount();
|
SetSheetNumberAndCount();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_DUPLICATE_BLOCK:
|
|
||||||
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
|
|
||||||
break;
|
|
||||||
|
|
||||||
m_canvas->MoveCursorToCrossHair();
|
|
||||||
screen->m_BlockLocate.SetCommand( BLOCK_DUPLICATE );
|
|
||||||
screen->m_BlockLocate.SetMessageBlock( this );
|
|
||||||
HandleBlockEnd( nullptr );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_POPUP_DRAG_BLOCK:
|
|
||||||
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
|
|
||||||
break;
|
|
||||||
|
|
||||||
m_canvas->MoveCursorToCrossHair();
|
|
||||||
screen->m_BlockLocate.SetCommand( BLOCK_DRAG );
|
|
||||||
screen->m_BlockLocate.SetMessageBlock( this );
|
|
||||||
HandleBlockEnd( nullptr );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_POPUP_SCH_GETINFO_MARKER:
|
case ID_POPUP_SCH_GETINFO_MARKER:
|
||||||
if( item && item->Type() == SCH_MARKER_T )
|
if( item && item->Type() == SCH_MARKER_T )
|
||||||
( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
|
( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
|
||||||
|
@ -565,78 +533,6 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
|
|
||||||
{
|
|
||||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
|
||||||
SCH_SCREEN* screen = GetScreen();
|
|
||||||
SCH_ITEM* item = screen->GetCurItem();
|
|
||||||
|
|
||||||
// The easiest way to handle a menu or a hot key drag command
|
|
||||||
// is to simulate a block drag command
|
|
||||||
//
|
|
||||||
// When a drag item is requested, some items use a BLOCK_DRAG_ITEM drag type
|
|
||||||
// an some items use a BLOCK_DRAG drag type (mainly a junction)
|
|
||||||
// a BLOCK_DRAG collects all items in a block (here a 2x2 rect centered on the cursor)
|
|
||||||
// and BLOCK_DRAG_ITEM drag only the selected item
|
|
||||||
BLOCK_COMMAND_T dragType = BLOCK_DRAG_ITEM;
|
|
||||||
|
|
||||||
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::DraggableItems );
|
|
||||||
|
|
||||||
// Exit if no item found at the current location or the item is already being edited.
|
|
||||||
if( item == NULL || item->GetEditFlags() != 0 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// When a junction or a node is found, a BLOCK_DRAG is better
|
|
||||||
if( m_collectedItems.IsCorner() || m_collectedItems.IsNode( false )
|
|
||||||
|| m_collectedItems.IsDraggableJunction() )
|
|
||||||
{
|
|
||||||
dragType = BLOCK_DRAG;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch( item->Type() )
|
|
||||||
{
|
|
||||||
case SCH_BUS_BUS_ENTRY_T:
|
|
||||||
case SCH_BUS_WIRE_ENTRY_T:
|
|
||||||
case SCH_LINE_T:
|
|
||||||
case SCH_JUNCTION_T:
|
|
||||||
case SCH_COMPONENT_T:
|
|
||||||
case SCH_LABEL_T:
|
|
||||||
case SCH_GLOBAL_LABEL_T:
|
|
||||||
case SCH_HIER_LABEL_T:
|
|
||||||
case SCH_SHEET_T:
|
|
||||||
case SCH_TEXT_T:
|
|
||||||
m_canvas->MoveCursorToCrossHair();
|
|
||||||
|
|
||||||
if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
|
|
||||||
{
|
|
||||||
if( !HandleBlockBegin( nullptr, dragType, GetCrossHairPosition() ) )
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Give a non null size to the search block:
|
|
||||||
screen->m_BlockLocate.Inflate( 1 );
|
|
||||||
screen->m_BlockLocate.SetLastCursorPosition( GetCrossHairPosition() );
|
|
||||||
HandleBlockEnd( nullptr );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
wxFAIL_MSG( wxString( "Cannot drag schematic item type " ) + item->GetClass() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::OnUnfoldBusHotkey( wxCommandEvent& aEvent )
|
void SCH_EDIT_FRAME::OnUnfoldBusHotkey( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||||
|
|
|
@ -179,11 +179,13 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
||||||
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
|
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
|
||||||
return SCH_ACTIONS::deleteItemCursor.MakeEvent();
|
return SCH_ACTIONS::deleteItemCursor.MakeEvent();
|
||||||
|
|
||||||
case ID_POPUP_MOVE_BLOCK:
|
case ID_SCH_MOVE:
|
||||||
case ID_SCH_MOVE_ITEM:
|
|
||||||
return SCH_ACTIONS::move.MakeEvent();
|
return SCH_ACTIONS::move.MakeEvent();
|
||||||
|
|
||||||
case ID_POPUP_SCH_DELETE:
|
case ID_SCH_DRAG:
|
||||||
|
return SCH_ACTIONS::drag.MakeEvent();
|
||||||
|
|
||||||
|
case ID_SCH_DELETE:
|
||||||
return SCH_ACTIONS::remove.MakeEvent();
|
return SCH_ACTIONS::remove.MakeEvent();
|
||||||
|
|
||||||
case ID_SIM_PROBE:
|
case ID_SIM_PROBE:
|
||||||
|
@ -204,7 +206,7 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
||||||
case ID_SCH_MIRROR_Y:
|
case ID_SCH_MIRROR_Y:
|
||||||
return SCH_ACTIONS::mirrorY.MakeEvent();
|
return SCH_ACTIONS::mirrorY.MakeEvent();
|
||||||
|
|
||||||
case ID_POPUP_SCH_DUPLICATE:
|
case ID_SCH_DUPLICATE:
|
||||||
return SCH_ACTIONS::duplicate.MakeEvent();
|
return SCH_ACTIONS::duplicate.MakeEvent();
|
||||||
|
|
||||||
case ID_REPEAT_BUTT:
|
case ID_REPEAT_BUTT:
|
||||||
|
|
|
@ -113,6 +113,7 @@ public:
|
||||||
|
|
||||||
// Editing
|
// Editing
|
||||||
static TOOL_ACTION move;
|
static TOOL_ACTION move;
|
||||||
|
static TOOL_ACTION drag;
|
||||||
static TOOL_ACTION duplicate;
|
static TOOL_ACTION duplicate;
|
||||||
static TOOL_ACTION repeatDrawItem;
|
static TOOL_ACTION repeatDrawItem;
|
||||||
static TOOL_ACTION rotateCW;
|
static TOOL_ACTION rotateCW;
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <sch_text.h>
|
#include <sch_text.h>
|
||||||
#include <sch_bitmap.h>
|
#include <sch_bitmap.h>
|
||||||
#include <sch_view.h>
|
#include <sch_view.h>
|
||||||
|
#include <sch_line.h>
|
||||||
#include <sch_item_struct.h>
|
#include <sch_item_struct.h>
|
||||||
#include <sch_edit_frame.h>
|
#include <sch_edit_frame.h>
|
||||||
#include <list_operations.h>
|
#include <list_operations.h>
|
||||||
|
@ -42,6 +43,10 @@ TOOL_ACTION SCH_ACTIONS::move( "eeschema.InteractiveEdit.move",
|
||||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MOVE_COMPONENT_OR_ITEM ),
|
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MOVE_COMPONENT_OR_ITEM ),
|
||||||
_( "Move" ), _( "Moves the selected item(s)" ), move_xpm, AF_ACTIVATE );
|
_( "Move" ), _( "Moves the selected item(s)" ), move_xpm, AF_ACTIVATE );
|
||||||
|
|
||||||
|
TOOL_ACTION SCH_ACTIONS::drag( "eeschema.InteractiveEdit.drag",
|
||||||
|
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DRAG ),
|
||||||
|
_( "Drag" ), _( "Drags the selected item(s)" ), move_xpm, AF_ACTIVATE );
|
||||||
|
|
||||||
TOOL_ACTION SCH_ACTIONS::duplicate( "eeschema.InteractiveEdit.duplicate",
|
TOOL_ACTION SCH_ACTIONS::duplicate( "eeschema.InteractiveEdit.duplicate",
|
||||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DUPLICATE ),
|
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DUPLICATE ),
|
||||||
_( "Duplicate" ), _( "Duplicates the selected item(s)" ), duplicate_xpm );
|
_( "Duplicate" ), _( "Duplicates the selected item(s)" ), duplicate_xpm );
|
||||||
|
@ -82,7 +87,7 @@ SCH_EDIT_TOOL::SCH_EDIT_TOOL() :
|
||||||
m_controls( nullptr ),
|
m_controls( nullptr ),
|
||||||
m_frame( nullptr ),
|
m_frame( nullptr ),
|
||||||
m_menu( *this ),
|
m_menu( *this ),
|
||||||
m_dragging( false )
|
m_moveInProgress( false )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +124,7 @@ bool SCH_EDIT_TOOL::Init()
|
||||||
|
|
||||||
void SCH_EDIT_TOOL::Reset( RESET_REASON aReason )
|
void SCH_EDIT_TOOL::Reset( RESET_REASON aReason )
|
||||||
{
|
{
|
||||||
m_dragging = false;
|
m_moveInProgress = false;
|
||||||
|
|
||||||
// Init variables used by every drawing tool
|
// Init variables used by every drawing tool
|
||||||
m_view = static_cast<KIGFX::SCH_VIEW*>( getView() );
|
m_view = static_cast<KIGFX::SCH_VIEW*>( getView() );
|
||||||
|
@ -140,7 +145,7 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::MovableItems );
|
SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::MovableItems );
|
||||||
bool unselect = selection.IsHover();
|
bool unselect = selection.IsHover();
|
||||||
|
|
||||||
if( m_dragging || selection.Empty() )
|
if( selection.Empty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
@ -148,6 +153,7 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
controls->SetAutoPan( true );
|
controls->SetAutoPan( true );
|
||||||
|
|
||||||
bool restore_state = false;
|
bool restore_state = false;
|
||||||
|
bool isDragOperation = aEvent.IsAction( &SCH_ACTIONS::drag );
|
||||||
VECTOR2I totalMovement;
|
VECTOR2I totalMovement;
|
||||||
OPT_TOOL_EVENT evt = aEvent;
|
OPT_TOOL_EVENT evt = aEvent;
|
||||||
VECTOR2I prevPos;
|
VECTOR2I prevPos;
|
||||||
|
@ -157,39 +163,20 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( evt->IsAction( &SCH_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
|
if( evt->IsAction( &SCH_ACTIONS::move ) || evt->IsAction( &SCH_ACTIONS::drag )
|
||||||
|
|| evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
if( m_dragging && evt->Category() == TC_MOUSE )
|
if( !m_moveInProgress ) // Prepare to start moving/dragging
|
||||||
{
|
|
||||||
m_cursor = controls->GetCursorPosition();
|
|
||||||
VECTOR2I movement( m_cursor - prevPos );
|
|
||||||
selection.SetReferencePoint( m_cursor );
|
|
||||||
|
|
||||||
totalMovement += movement;
|
|
||||||
prevPos = m_cursor;
|
|
||||||
|
|
||||||
// Drag items to the current cursor position
|
|
||||||
for( int i = 0; i < selection.GetSize(); ++i )
|
|
||||||
{
|
|
||||||
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( i ) );
|
|
||||||
|
|
||||||
// Don't double move pins, fields, etc.
|
|
||||||
if( item->GetParent() && item->GetParent()->IsSelected() )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
moveItem( item, movement );
|
|
||||||
updateView( item );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_frame->UpdateMsgPanel();
|
|
||||||
}
|
|
||||||
else if( !m_dragging ) // Prepare to start dragging
|
|
||||||
{
|
{
|
||||||
|
//
|
||||||
// Save items, so changes can be undone
|
// Save items, so changes can be undone
|
||||||
|
//
|
||||||
for( int i = 0; i < selection.GetSize(); ++i )
|
for( int i = 0; i < selection.GetSize(); ++i )
|
||||||
{
|
{
|
||||||
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( i ) );
|
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( i ) );
|
||||||
|
|
||||||
|
item->ClearFlags( STARTPOINT | ENDPOINT );
|
||||||
|
|
||||||
// No need to save children of selected items
|
// No need to save children of selected items
|
||||||
if( item->GetParent() && item->GetParent()->IsSelected() )
|
if( item->GetParent() && item->GetParent()->IsSelected() )
|
||||||
continue;
|
continue;
|
||||||
|
@ -198,7 +185,28 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
saveCopyInUndoList( item, UR_CHANGED, i > 0 );
|
saveCopyInUndoList( item, UR_CHANGED, i > 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark dangling pins at the edges of the block:
|
//
|
||||||
|
// Add connections to the selection for a drag; mark the edges of the block
|
||||||
|
// with dangling pins for a move
|
||||||
|
//
|
||||||
|
if( isDragOperation )
|
||||||
|
{
|
||||||
|
for( unsigned i = 0; i < selection.GetSize(); ++i )
|
||||||
|
{
|
||||||
|
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( i ) );
|
||||||
|
|
||||||
|
if( item->IsConnectable() )
|
||||||
|
{
|
||||||
|
std::vector<wxPoint> connections;
|
||||||
|
item->GetConnectionPoints( connections );
|
||||||
|
|
||||||
|
for( wxPoint point : connections )
|
||||||
|
selectConnectedDragItems( item, point );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
std::vector<DANGLING_END_ITEM> internalPoints;
|
std::vector<DANGLING_END_ITEM> internalPoints;
|
||||||
|
|
||||||
for( int i = 0; i < selection.GetSize(); ++i )
|
for( int i = 0; i < selection.GetSize(); ++i )
|
||||||
|
@ -212,12 +220,15 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( i ) );
|
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( i ) );
|
||||||
item->UpdateDanglingState( internalPoints );
|
item->UpdateDanglingState( internalPoints );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set up the starting position and move/drag offset
|
||||||
|
//
|
||||||
m_cursor = controls->GetCursorPosition();
|
m_cursor = controls->GetCursorPosition();
|
||||||
|
|
||||||
if( selection.HasReferencePoint() )
|
if( selection.HasReferencePoint() )
|
||||||
{
|
{
|
||||||
// start moving with the reference point attached to the cursor
|
|
||||||
VECTOR2I delta = m_cursor - selection.GetReferencePoint();
|
VECTOR2I delta = m_cursor - selection.GetReferencePoint();
|
||||||
|
|
||||||
// Drag items to the current cursor position
|
// Drag items to the current cursor position
|
||||||
|
@ -229,7 +240,7 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
if( item->GetParent() && item->GetParent()->IsSelected() )
|
if( item->GetParent() && item->GetParent()->IsSelected() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
moveItem( item, delta );
|
moveItem( item, delta, isDragOperation );
|
||||||
updateView( item );
|
updateView( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,8 +248,8 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else if( selection.Size() == 1 )
|
else if( selection.Size() == 1 )
|
||||||
{
|
{
|
||||||
// Set the current cursor position to the first dragged item origin, so the
|
// Set the current cursor position to the first dragged item origin,
|
||||||
// movement vector could be computed later
|
// so the movement vector can be computed later
|
||||||
updateModificationPoint( selection );
|
updateModificationPoint( selection );
|
||||||
m_cursor = originalCursorPos;
|
m_cursor = originalCursorPos;
|
||||||
}
|
}
|
||||||
|
@ -251,13 +262,40 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
prevPos = m_cursor;
|
prevPos = m_cursor;
|
||||||
controls->SetAutoPan( true );
|
controls->SetAutoPan( true );
|
||||||
m_dragging = true;
|
m_moveInProgress = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else /* m_moveInProgress */
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Follow the mouse
|
||||||
|
//
|
||||||
|
m_cursor = controls->GetCursorPosition();
|
||||||
|
VECTOR2I movement( m_cursor - prevPos );
|
||||||
|
selection.SetReferencePoint( m_cursor );
|
||||||
|
|
||||||
|
totalMovement += movement;
|
||||||
|
prevPos = m_cursor;
|
||||||
|
|
||||||
|
for( int i = 0; i < selection.GetSize(); ++i )
|
||||||
|
{
|
||||||
|
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( i ) );
|
||||||
|
|
||||||
|
// Don't double move pins, fields, etc.
|
||||||
|
if( item->GetParent() && item->GetParent()->IsSelected() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
moveItem( item, movement, isDragOperation );
|
||||||
|
updateView( item );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_frame->UpdateMsgPanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsCancel() || evt->IsActivate() )
|
else if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsCancel() || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( m_dragging )
|
if( m_moveInProgress )
|
||||||
restore_state = true;
|
restore_state = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -274,14 +312,12 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
if( evt->IsAction( &SCH_ACTIONS::remove ) )
|
if( evt->IsAction( &SCH_ACTIONS::remove ) )
|
||||||
{
|
{
|
||||||
// exit the loop, as there is no further processing for removed items
|
// Exit on a remove operation; there is no further processing for removed items.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( evt->IsAction( &SCH_ACTIONS::duplicate ) )
|
else if( evt->IsAction( &SCH_ACTIONS::duplicate ) )
|
||||||
{
|
{
|
||||||
// On duplicate, stop moving this item
|
// Exit on a duplicate action; it will start its own move operation.
|
||||||
// The duplicate tool should then select the new item and start
|
|
||||||
// a new move procedure
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,9 +334,8 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
controls->SetSnapping( false );
|
controls->SetSnapping( false );
|
||||||
controls->SetAutoPan( false );
|
controls->SetAutoPan( false );
|
||||||
|
|
||||||
m_dragging = false;
|
m_moveInProgress = false;
|
||||||
|
|
||||||
// Discard reference point when selection is "dropped" onto the board (ie: not dragging anymore)
|
|
||||||
selection.ClearReferencePoint();
|
selection.ClearReferencePoint();
|
||||||
|
|
||||||
for( auto item : selection )
|
for( auto item : selection )
|
||||||
|
@ -321,14 +356,113 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_TOOL::moveItem( SCH_ITEM* aItem, VECTOR2I delta )
|
void SCH_EDIT_TOOL::selectConnectedDragItems( SCH_ITEM* aSourceItem, wxPoint aPoint )
|
||||||
{
|
{
|
||||||
KICAD_T itemType = aItem->Type();
|
for( SCH_ITEM* item = m_frame->GetScreen()->GetDrawItems(); item; item = item->Next() )
|
||||||
|
{
|
||||||
|
if( item->IsSelected() || !item->IsConnectable() || !item->CanConnect( aSourceItem ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T )
|
bool doSelect = false;
|
||||||
aItem->Move( wxPoint( delta.x, -delta.y ) );
|
|
||||||
|
switch( item->Type() )
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case SCH_LINE_T:
|
||||||
|
{
|
||||||
|
// Select wires/busses that are connected at one end and/or the other. Any
|
||||||
|
// unconnected ends must be flagged (STARTPOINT or ENDPOINT).
|
||||||
|
SCH_LINE* line = (SCH_LINE*) item;
|
||||||
|
|
||||||
|
if( !line->IsSelected() )
|
||||||
|
line->SetFlags( STARTPOINT | ENDPOINT );
|
||||||
|
|
||||||
|
if( line->GetStartPoint() == aPoint )
|
||||||
|
{
|
||||||
|
line->ClearFlags( STARTPOINT );
|
||||||
|
|
||||||
|
if( !line->IsSelected() )
|
||||||
|
doSelect = true;
|
||||||
|
}
|
||||||
|
else if( line->GetEndPoint() == aPoint )
|
||||||
|
{
|
||||||
|
line->ClearFlags( ENDPOINT );
|
||||||
|
|
||||||
|
if( !line->IsSelected() )
|
||||||
|
doSelect = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SCH_SHEET_T:
|
||||||
|
// Dragging a sheet just because it's connected to something else feels a bit like
|
||||||
|
// the tail wagging the dog, but this could be moved down to the next case.
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SCH_COMPONENT_T:
|
||||||
|
case SCH_NO_CONNECT_T:
|
||||||
|
case SCH_JUNCTION_T:
|
||||||
|
// Select connected items that have no wire between them.
|
||||||
|
if( aSourceItem->Type() != SCH_LINE_T && item->IsConnected( aPoint ) )
|
||||||
|
doSelect = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SCH_LABEL_T:
|
||||||
|
case SCH_GLOBAL_LABEL_T:
|
||||||
|
case SCH_HIER_LABEL_T:
|
||||||
|
case SCH_BUS_WIRE_ENTRY_T:
|
||||||
|
case SCH_BUS_BUS_ENTRY_T:
|
||||||
|
// Select labels and bus entries that are connected to a wire being moved.
|
||||||
|
if( aSourceItem->Type() == SCH_LINE_T )
|
||||||
|
{
|
||||||
|
std::vector<wxPoint> connections;
|
||||||
|
item->GetConnectionPoints( connections );
|
||||||
|
|
||||||
|
for( wxPoint& point : connections )
|
||||||
|
{
|
||||||
|
if( aSourceItem->HitTest( point ) )
|
||||||
|
doSelect = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( doSelect )
|
||||||
|
{
|
||||||
|
m_toolMgr->RunAction( SCH_ACTIONS::selectItem, true, item );
|
||||||
|
saveCopyInUndoList( item, UR_CHANGED, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_EDIT_TOOL::moveItem( SCH_ITEM* aItem, VECTOR2I aDelta, bool isDrag )
|
||||||
|
{
|
||||||
|
switch( aItem->Type() )
|
||||||
|
{
|
||||||
|
case SCH_LINE_T:
|
||||||
|
{
|
||||||
|
SCH_LINE* line = (SCH_LINE*) aItem;
|
||||||
|
|
||||||
|
if( isDrag && ( line->GetFlags() & STARTPOINT ) )
|
||||||
|
line->MoveEnd( (wxPoint)aDelta );
|
||||||
|
else if( isDrag && ( line->GetFlags() & ENDPOINT ) )
|
||||||
|
line->MoveStart( (wxPoint)aDelta );
|
||||||
else
|
else
|
||||||
aItem->Move( (wxPoint)delta );
|
line->Move( (wxPoint)aDelta );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SCH_PIN_T:
|
||||||
|
case SCH_FIELD_T:
|
||||||
|
aItem->Move( wxPoint( aDelta.x, -aDelta.y ) );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
aItem->Move( (wxPoint)aDelta );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
aItem->SetFlags( IS_MOVED );
|
aItem->SetFlags( IS_MOVED );
|
||||||
}
|
}
|
||||||
|
@ -336,7 +470,7 @@ void SCH_EDIT_TOOL::moveItem( SCH_ITEM* aItem, VECTOR2I delta )
|
||||||
|
|
||||||
bool SCH_EDIT_TOOL::updateModificationPoint( SELECTION& aSelection )
|
bool SCH_EDIT_TOOL::updateModificationPoint( SELECTION& aSelection )
|
||||||
{
|
{
|
||||||
if( m_dragging && aSelection.HasReferencePoint() )
|
if( m_moveInProgress && aSelection.HasReferencePoint() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// When there is only one item selected, the reference point is its position...
|
// When there is only one item selected, the reference point is its position...
|
||||||
|
@ -840,6 +974,7 @@ void SCH_EDIT_TOOL::saveCopyInUndoList( SCH_ITEM* aItem, UNDO_REDO_T aType, bool
|
||||||
void SCH_EDIT_TOOL::setTransitions()
|
void SCH_EDIT_TOOL::setTransitions()
|
||||||
{
|
{
|
||||||
Go( &SCH_EDIT_TOOL::Main, SCH_ACTIONS::move.MakeEvent() );
|
Go( &SCH_EDIT_TOOL::Main, SCH_ACTIONS::move.MakeEvent() );
|
||||||
|
Go( &SCH_EDIT_TOOL::Main, SCH_ACTIONS::drag.MakeEvent() );
|
||||||
Go( &SCH_EDIT_TOOL::Duplicate, SCH_ACTIONS::duplicate.MakeEvent() );
|
Go( &SCH_EDIT_TOOL::Duplicate, SCH_ACTIONS::duplicate.MakeEvent() );
|
||||||
Go( &SCH_EDIT_TOOL::RepeatDrawItem, SCH_ACTIONS::repeatDrawItem.MakeEvent() );
|
Go( &SCH_EDIT_TOOL::RepeatDrawItem, SCH_ACTIONS::repeatDrawItem.MakeEvent() );
|
||||||
Go( &SCH_EDIT_TOOL::Rotate, SCH_ACTIONS::rotateCW.MakeEvent() );
|
Go( &SCH_EDIT_TOOL::Rotate, SCH_ACTIONS::rotateCW.MakeEvent() );
|
||||||
|
|
|
@ -72,7 +72,12 @@ public:
|
||||||
int Remove( const TOOL_EVENT& aEvent );
|
int Remove( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void moveItem( SCH_ITEM* aItem, VECTOR2I delta );
|
void moveItem( SCH_ITEM* aItem, VECTOR2I aDelta, bool isDrag );
|
||||||
|
|
||||||
|
///> Selects additional items for a drag operation.
|
||||||
|
///> Connected items with no wire are selected (as there is no wire to adjust for the drag).
|
||||||
|
///> Connected wires are selected with any un-connected ends flagged (STARTPOINT or ENDPOINT).
|
||||||
|
void selectConnectedDragItems( SCH_ITEM* aSourceItem, wxPoint aPoint );
|
||||||
|
|
||||||
///> Returns the right modification point (e.g. for rotation), depending on the number of
|
///> Returns the right modification point (e.g. for rotation), depending on the number of
|
||||||
///> selected items.
|
///> selected items.
|
||||||
|
@ -98,7 +103,7 @@ private:
|
||||||
TOOL_MENU m_menu;
|
TOOL_MENU m_menu;
|
||||||
|
|
||||||
///> Flag determining if anything is being dragged right now
|
///> Flag determining if anything is being dragged right now
|
||||||
bool m_dragging;
|
bool m_moveInProgress;
|
||||||
|
|
||||||
///> Last cursor position (needed for getModificationPoint() to avoid changes
|
///> Last cursor position (needed for getModificationPoint() to avoid changes
|
||||||
///> of edit reference point).
|
///> of edit reference point).
|
||||||
|
|
Loading…
Reference in New Issue