Remove special cases for footprint editor. BOARD_COMMIT handles them.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16236
This commit is contained in:
Jeff Young 2023-12-02 20:06:42 +00:00
parent b13590f4c0
commit 6e245d5eb4
1 changed files with 24 additions and 44 deletions

View File

@ -2135,17 +2135,7 @@ void EDIT_TOOL::DeleteItems( const PCB_SELECTION& aItems, bool aIsCut )
case PCB_DIM_RADIAL_T: case PCB_DIM_RADIAL_T:
case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_ORTHOGONAL_T:
case PCB_GROUP_T: case PCB_GROUP_T:
if( parentFP ) commit.Remove( board_item );
{
commit.Modify( parentFP );
getView()->Remove( board_item );
parentFP->Remove( board_item );
}
else
{
commit.Remove( board_item );
}
break; break;
case PCB_PAD_T: case PCB_PAD_T:
@ -2159,48 +2149,38 @@ void EDIT_TOOL::DeleteItems( const PCB_SELECTION& aItems, bool aIsCut )
break; break;
case PCB_ZONE_T: case PCB_ZONE_T:
if( parentFP ) // We process the zones special so that cutouts can be deleted when the delete
// tool is called from inside a cutout when the zone is selected.
// Only interact with cutouts when deleting and a single item is selected
if( !aIsCut && aItems.GetSize() == 1 )
{ {
commit.Modify( parentFP ); VECTOR2I curPos = getViewControls()->GetCursorPosition();
getView()->Remove( board_item ); ZONE* zone = static_cast<ZONE*>( board_item );
parentFP->Remove( board_item );
} int outlineIdx, holeIdx;
else
{ if( zone->HitTestCutout( curPos, &outlineIdx, &holeIdx ) )
// We process the zones special so that cutouts can be deleted when the delete
// tool is called from inside a cutout when the zone is selected.
// Only interact with cutouts when deleting and a single item is selected
if( !aIsCut && aItems.GetSize() == 1 )
{ {
VECTOR2I curPos = getViewControls()->GetCursorPosition(); // Remove the cutout
ZONE* zone = static_cast<ZONE*>( board_item ); commit.Modify( zone );
zone->RemoveCutout( outlineIdx, holeIdx );
zone->UnFill();
int outlineIdx, holeIdx; // TODO Refill zone when KiCad supports auto re-fill
if( zone->HitTestCutout( curPos, &outlineIdx, &holeIdx ) ) // Update the display
{ zone->HatchBorder();
// Remove the cutout canvas()->Refresh();
commit.Modify( zone );
zone->RemoveCutout( outlineIdx, holeIdx );
zone->UnFill();
// TODO Refill zone when KiCad supports auto re-fill // Restore the selection on the original zone
m_toolMgr->RunAction<EDA_ITEM*>( PCB_ACTIONS::selectItem, zone );
// Update the display break;
zone->HatchBorder();
canvas()->Refresh();
// Restore the selection on the original zone
m_toolMgr->RunAction<EDA_ITEM*>( PCB_ACTIONS::selectItem, zone );
break;
}
} }
// Remove the entire zone otherwise
commit.Remove( board_item );
} }
// Remove the entire zone otherwise
commit.Remove( board_item );
break; break;
case PCB_GENERATOR_T: case PCB_GENERATOR_T: