Clean up delete and fix bug with juctions getting double-deleted.

This commit is contained in:
Jeff Young 2019-04-27 15:59:38 +01:00
parent de347998d1
commit 9e2bbcb8b6
4 changed files with 18 additions and 56 deletions

View File

@ -703,25 +703,6 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
}
break;
case HK_DELETE:
if( blocInProgress )
{
cmd.SetId( ID_POPUP_DELETE_BLOCK );
Process_Special_Functions( cmd );
}
else
{
if( !itemInEdit )
SetDrawItem( LocateItemUsingCursor( aPosition ) );
if( GetDrawItem() )
{
cmd.SetId( ID_POPUP_LIBEDIT_DELETE_ITEM );
Process_Special_Functions( cmd );
}
}
break;
case HK_LIBEDIT_MOVE_GRAPHIC_ITEM:
if( !itemInEdit && !blocInProgress )
{

View File

@ -76,7 +76,6 @@
case ID_POPUP_IMPORT_HLABEL_TO_SHEETPIN:
case ID_POPUP_SCH_INIT_CMP:
case ID_POPUP_SCH_EDIT_CONVERT_CMP:
case ID_POPUP_DELETE_BLOCK:
case ID_POPUP_PLACE_BLOCK:
case ID_POPUP_ZOOM_BLOCK:
case ID_POPUP_DRAG_BLOCK:
@ -187,21 +186,6 @@
break;
case ID_POPUP_SCH_DELETE_CMP:
case ID_SCH_DELETE:
if( item == NULL )
break;
DeleteItem( item );
SchematicCleanUp( true );
screen->SetCurItem( NULL );
SetRepeatItem( NULL );
TestDanglingEnds();
SetSheetNumberAndCount();
GetCanvas()->Refresh();
OnModify();
break;
case ID_POPUP_SCH_CLEANUP_SHEET:
if( item != NULL && item->Type() == SCH_SHEET_T )
{
@ -255,17 +239,6 @@
}
break;
case ID_POPUP_DELETE_BLOCK:
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
break;
m_canvas->MoveCursorToCrossHair();
screen->m_BlockLocate.SetCommand( BLOCK_DELETE );
screen->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( nullptr );
SetSheetNumberAndCount();
break;
case ID_POPUP_SCH_GETINFO_MARKER:
if( item && item->Type() == SCH_MARKER_T )
( (SCH_MARKER*) item )->DisplayMarkerInfo( this );

View File

@ -918,7 +918,7 @@ int SCH_EDIT_TOOL::RepeatDrawItem( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
{
SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
std::vector<SCH_ITEM*> lockedItems;
std::vector<SCH_ITEM*> items;
// get a copy instead of reference (we're going to clear the selection before removing items)
SELECTION selectionCopy = selTool->RequestSelection();
@ -932,16 +932,19 @@ int SCH_EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
for( unsigned ii = 0; ii < selectionCopy.GetSize(); ii++ )
{
SCH_ITEM* item = static_cast<SCH_ITEM*>( selectionCopy.GetItem( ii ) );
bool itemHasConnections = item->IsConnectable();
m_frame->GetScreen()->SetCurItem( nullptr );
m_frame->SetRepeatItem( nullptr );
// Junctions, in particular, may have already been deleted if deleting wires made
// them redundant
if( item->GetEditFlags() & STRUCT_DELETED )
continue;
m_frame->DeleteItem( item, ii > 0 );
if( itemHasConnections )
m_frame->TestDanglingEnds();
}
m_frame->GetScreen()->SetCurItem( nullptr );
m_frame->SetRepeatItem( nullptr );
m_frame->TestDanglingEnds();
m_frame->GetCanvas()->Refresh();
m_frame->OnModify();

View File

@ -431,9 +431,8 @@ bool SCH_SELECTION_TOOL::selectMultiple()
if( view->IsMirroredX() )
windowSelection = !windowSelection;
// Construct an EDA_RECT to determine BOARD_ITEM selection
EDA_RECT selectionRect( wxPoint( area.GetOrigin().x, area.GetOrigin().y ),
wxSize( width, height ) );
// Construct an EDA_RECT to determine SCH_ITEM selection
EDA_RECT selectionRect( (wxPoint)area.GetOrigin(), wxSize( width, height ) );
selectionRect.Normalize();
@ -739,6 +738,9 @@ void SCH_SELECTION_TOOL::toggleSelection( SCH_ITEM* aItem, bool aForce )
void SCH_SELECTION_TOOL::select( SCH_ITEM* aItem )
{
if( aItem->IsSelected() )
return;
highlight( aItem, SELECTED, &m_selection );
if( m_frame )
@ -759,6 +761,9 @@ void SCH_SELECTION_TOOL::select( SCH_ITEM* aItem )
void SCH_SELECTION_TOOL::unselect( SCH_ITEM* aItem )
{
if( !aItem->IsSelected() )
return;
unhighlight( aItem, SELECTED, &m_selection );
if( m_frame && m_frame->GetScreen()->GetCurItem() == aItem )