PCB Editor: Unroute Footprint
Also works on selected pads. Fixes: https://gitlab.com/kicad/code/kicad/-/issues/1955
This commit is contained in:
parent
9304607624
commit
ca0c9f12e0
|
@ -168,6 +168,12 @@ bool EDIT_TOOL::Init()
|
|||
PCB_PAD_T,
|
||||
PCB_ZONE_T };
|
||||
|
||||
static std::vector<KICAD_T> unroutableTypes = { PCB_TRACE_T,
|
||||
PCB_ARC_T,
|
||||
PCB_VIA_T,
|
||||
PCB_PAD_T,
|
||||
PCB_FOOTPRINT_T };
|
||||
|
||||
static std::vector<KICAD_T> trackTypes = { PCB_TRACE_T,
|
||||
PCB_ARC_T,
|
||||
PCB_VIA_T };
|
||||
|
@ -178,6 +184,8 @@ bool EDIT_TOOL::Init()
|
|||
|
||||
menu.AddItem( PCB_ACTIONS::move, SELECTION_CONDITIONS::NotEmpty
|
||||
&& notMovingCondition );
|
||||
menu.AddItem( PCB_ACTIONS::unrouteSelected, SELECTION_CONDITIONS::NotEmpty
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( unroutableTypes ) );
|
||||
menu.AddItem( PCB_ACTIONS::breakTrack, SELECTION_CONDITIONS::Count( 1 )
|
||||
&& SELECTION_CONDITIONS::OnlyTypes( trackTypes ) );
|
||||
menu.AddItem( PCB_ACTIONS::drag45Degree, SELECTION_CONDITIONS::Count( 1 )
|
||||
|
|
|
@ -1286,6 +1286,12 @@ TOOL_ACTION PCB_ACTIONS::selectConnection( "pcbnew.InteractiveSelection.SelectCo
|
|||
_( "Selects a connection or expands an existing selection to junctions, pads, or entire connections" ),
|
||||
BITMAPS::add_tracks );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::unrouteSelected( "pcbnew.InteractiveSelection.unrouteSelected",
|
||||
AS_GLOBAL, 0, "",
|
||||
_( "Unroute Selected" ),
|
||||
_( "Unroutes selected items to the nearest pad." ),
|
||||
BITMAPS::general_deletions );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::syncSelection( "pcbnew.InteractiveSelection.SyncSelection",
|
||||
AS_GLOBAL );
|
||||
|
||||
|
|
|
@ -79,6 +79,9 @@ public:
|
|||
/// entire connection.
|
||||
static TOOL_ACTION selectConnection;
|
||||
|
||||
/// Removes all tracks from the selected items to the first pad
|
||||
static TOOL_ACTION unrouteSelected;
|
||||
|
||||
/// Select all connections belonging to a single net.
|
||||
static TOOL_ACTION selectNet;
|
||||
|
||||
|
|
|
@ -1087,6 +1087,42 @@ void connectedItemFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector,
|
|||
}
|
||||
|
||||
|
||||
int PCB_SELECTION_TOOL::unrouteSelected( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
std::deque<EDA_ITEM*> selectedItems = m_selection.GetItems();
|
||||
|
||||
// Get all footprints and pads
|
||||
std::vector<BOARD_CONNECTED_ITEM*> toUnroute;
|
||||
|
||||
for( EDA_ITEM* item : selectedItems )
|
||||
{
|
||||
if( item->Type() == PCB_FOOTPRINT_T )
|
||||
{
|
||||
for( PAD* pad : static_cast<FOOTPRINT*>( item )->Pads() )
|
||||
toUnroute.push_back( pad );
|
||||
}
|
||||
else if( BOARD_CONNECTED_ITEM::ClassOf( item ) )
|
||||
{
|
||||
toUnroute.push_back( static_cast<BOARD_CONNECTED_ITEM*>( item ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Clear selection so we don't delete our footprints/pads
|
||||
ClearSelection( true );
|
||||
|
||||
// Get the tracks on our list of pads, then delete them
|
||||
selectAllConnectedTracks( toUnroute, STOP_CONDITION::STOP_AT_PAD );
|
||||
m_toolMgr->RunAction( ACTIONS::doDelete, true );
|
||||
|
||||
// Reselect our footprint/pads as they were in our original selection
|
||||
for( EDA_ITEM* item : selectedItems )
|
||||
if( item->Type() == PCB_FOOTPRINT_T || item->Type() == PCB_PAD_T )
|
||||
select( item );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int PCB_SELECTION_TOOL::expandConnection( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
unsigned initialCount = 0;
|
||||
|
@ -2949,6 +2985,7 @@ void PCB_SELECTION_TOOL::setTransitions()
|
|||
|
||||
Go( &PCB_SELECTION_TOOL::filterSelection, PCB_ACTIONS::filterSelection.MakeEvent() );
|
||||
Go( &PCB_SELECTION_TOOL::expandConnection, PCB_ACTIONS::selectConnection.MakeEvent() );
|
||||
Go( &PCB_SELECTION_TOOL::unrouteSelected, PCB_ACTIONS::unrouteSelected.MakeEvent() );
|
||||
Go( &PCB_SELECTION_TOOL::selectNet, PCB_ACTIONS::selectNet.MakeEvent() );
|
||||
Go( &PCB_SELECTION_TOOL::selectNet, PCB_ACTIONS::deselectNet.MakeEvent() );
|
||||
Go( &PCB_SELECTION_TOOL::syncSelection, PCB_ACTIONS::syncSelection.MakeEvent() );
|
||||
|
|
|
@ -288,6 +288,11 @@ private:
|
|||
*/
|
||||
int expandConnection( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Unroute the selected board connected items.
|
||||
*/
|
||||
int unrouteSelected( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Select all copper connections belonging to the same net(s) as the items in the selection.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue