pcbnew: Break track in edit mode

Enables the ability to break a track into two segments when operating in
the edit mode rather than in router.

Fixes: lp:1779788
* https://bugs.launchpad.net/kicad/+bug/1779788
This commit is contained in:
Seth Hillbrand 2018-12-13 20:43:51 -07:00
parent f452eafcd6
commit 0a26388901
4 changed files with 59 additions and 0 deletions

View File

@ -116,6 +116,12 @@ TOOL_ACTION PCB_ACTIONS::routerInlineDrag( "pcbnew.InteractiveRouter.InlineDrag"
_( "Drag Track/Via" ), _( "Drags tracks and vias without breaking connections" ),
drag_xpm );
TOOL_ACTION PCB_ACTIONS::inlineBreakTrack( "pcbnew.InteractiveRouter.InlineBreakTrack",
AS_GLOBAL, 0,
_( "Break Track" ),
_( "Splits the track segment into two segments connected at the cursor position." ),
break_line_xpm );
TOOL_ACTION PCB_ACTIONS::breakTrack( "pcbnew.InteractiveRouter.BreakTrack",
AS_GLOBAL, 0,
_( "Break Track" ),
@ -885,6 +891,7 @@ void ROUTER_TOOL::setTransitions()
Go( &ROUTER_TOOL::DpDimensionsDialog, PCB_ACTIONS::routerActivateDpDimensionsDialog.MakeEvent() );
Go( &ROUTER_TOOL::SettingsDialog, PCB_ACTIONS::routerActivateSettingsDialog.MakeEvent() );
Go( &ROUTER_TOOL::InlineDrag, PCB_ACTIONS::routerInlineDrag.MakeEvent() );
Go( &ROUTER_TOOL::InlineBreakTrack, PCB_ACTIONS::inlineBreakTrack.MakeEvent() );
Go( &ROUTER_TOOL::onViaCommand, ACT_PlaceThroughVia.MakeEvent() );
Go( &ROUTER_TOOL::onViaCommand, ACT_PlaceBlindVia.MakeEvent() );
@ -1207,6 +1214,50 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
}
int ROUTER_TOOL::InlineBreakTrack( const TOOL_EVENT& aEvent )
{
const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
if( selection.Size() != 1 )
return 0;
const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
if( item->Type() != PCB_TRACE_T )
return 0;
Init();
Activate();
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
m_router->SyncWorld();
m_startItem = m_router->GetWorld()->FindItemByParent( item );
m_startSnapPoint = snapToItem( true, m_startItem, controls()->GetCursorPosition() );
if( m_startItem && m_startItem->IsLocked() )
{
KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
wxOK | wxCANCEL | wxICON_WARNING );
dlg.SetOKLabel( _( "Break Track" ) );
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
if( dlg.ShowModal() == wxID_CANCEL )
return 0;
}
frame()->UndoRedoBlock( true );
breakTrack();
if( m_router->RoutingInProgress() )
m_router->StopRouting();
frame()->UndoRedoBlock( false );
return 0;
}
int ROUTER_TOOL::CustomTrackWidthDialog( const TOOL_EVENT& aEvent )
{
BOARD_DESIGN_SETTINGS& bds = board()->GetDesignSettings();

View File

@ -36,6 +36,7 @@ public:
int RouteSingleTrace( const TOOL_EVENT& aEvent );
int RouteDiffPair( const TOOL_EVENT& aEvent );
int InlineBreakTrack( const TOOL_EVENT& aEvent );
bool CanInlineDrag();
int InlineDrag( const TOOL_EVENT& aEvent );

View File

@ -253,6 +253,8 @@ bool EDIT_TOOL::Init()
CONDITIONAL_MENU& menu = m_selectionTool->GetToolMenu().GetMenu();
menu.AddItem( PCB_ACTIONS::move, SELECTION_CONDITIONS::NotEmpty );
menu.AddItem( PCB_ACTIONS::inlineBreakTrack, SELECTION_CONDITIONS::Count( 1 )
&& SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
menu.AddItem( PCB_ACTIONS::drag45Degree, SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
menu.AddItem( PCB_ACTIONS::dragFreeAngle, SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
menu.AddItem( PCB_ACTIONS::rotateCcw, SELECTION_CONDITIONS::NotEmpty );

View File

@ -132,7 +132,12 @@ public:
static TOOL_ACTION remove;
static TOOL_ACTION removeAlt;
/// Break a single track into two segments at the cursor
static TOOL_ACTION breakTrack;
/// Breaks track when router is not activated
static TOOL_ACTION inlineBreakTrack;
static TOOL_ACTION drag45Degree;
static TOOL_ACTION dragFreeAngle;