Allow cancel from Route Selected operations.
ADDED: a new "Cancel Current Item" to move to the next
item. "Cancel" goes back to cancelling the entire op.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/22729
(cherry picked from commit 62c8ee9793)
This commit is contained in:
@@ -67,6 +67,7 @@ protected:
|
||||
virtual void updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads = false );
|
||||
virtual void updateEndItem( const TOOL_EVENT& aEvent );
|
||||
|
||||
protected:
|
||||
SIZES_SETTINGS m_savedSizes; // Stores sizes settings between router invocations
|
||||
ITEM* m_startItem;
|
||||
VECTOR2I m_startSnapPoint;
|
||||
|
||||
@@ -208,7 +208,8 @@ ROUTER_TOOL::ROUTER_TOOL() :
|
||||
TOOL_BASE( "pcbnew.InteractiveRouter" ),
|
||||
m_lastTargetLayer( UNDEFINED_LAYER ),
|
||||
m_originalActiveLayer( UNDEFINED_LAYER ),
|
||||
m_inRouterTool( false )
|
||||
m_inRouterTool( false ),
|
||||
m_inRouteSelected( false )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -498,6 +499,12 @@ bool ROUTER_TOOL::Init()
|
||||
return !m_router->RoutingInProgress();
|
||||
};
|
||||
|
||||
auto inRouteSelected =
|
||||
[this]( const SELECTION& )
|
||||
{
|
||||
return m_inRouteSelected;
|
||||
};
|
||||
|
||||
auto hasOtherEnd =
|
||||
[this]( const SELECTION& )
|
||||
{
|
||||
@@ -516,6 +523,7 @@ bool ROUTER_TOOL::Init()
|
||||
};
|
||||
|
||||
menu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways, 1 );
|
||||
menu.AddItem( PCB_ACTIONS::cancelCurrentItem, inRouteSelected, 1 );
|
||||
menu.AddSeparator( 1 );
|
||||
|
||||
menu.AddItem( PCB_ACTIONS::clearHighlight, haveHighlight, 2 );
|
||||
@@ -1449,10 +1457,11 @@ void ROUTER_TOOL::performRouting( VECTOR2D aStartPosition )
|
||||
m_router->FixRoute( m_endSnapPoint, m_endItem, forceFinish, forceCommit );
|
||||
break;
|
||||
}
|
||||
else if( evt->IsCancelInteractive() || evt->IsActivate()
|
||||
else if( evt->IsCancelInteractive() || evt->IsAction( &PCB_ACTIONS::cancelCurrentItem )
|
||||
|| evt->IsActivate()
|
||||
|| evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
|
||||
{
|
||||
if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() )
|
||||
if( evt->IsCancelInteractive() && ( m_inRouteSelected || !m_router->RoutingInProgress() ) )
|
||||
m_cancelled = true;
|
||||
|
||||
if( evt->IsActivate() && !evt->IsMoveTool() )
|
||||
@@ -1605,6 +1614,8 @@ int ROUTER_TOOL::RouteSelected( const TOOL_EVENT& aEvent )
|
||||
};
|
||||
|
||||
Activate();
|
||||
m_inRouteSelected = true;
|
||||
|
||||
// Must be done after Activate() so that it gets set into the correct context
|
||||
controls->ShowCursor( true );
|
||||
controls->ForceCursorPosition( false );
|
||||
@@ -1631,6 +1642,7 @@ int ROUTER_TOOL::RouteSelected( const TOOL_EVENT& aEvent )
|
||||
|
||||
// For putting sequential tracks that successfully autoroute into one undo commit
|
||||
bool groupStart = true;
|
||||
m_cancelled = false;
|
||||
|
||||
for( BOARD_CONNECTED_ITEM* item : itemList )
|
||||
{
|
||||
@@ -1695,15 +1707,22 @@ int ROUTER_TOOL::RouteSelected( const TOOL_EVENT& aEvent )
|
||||
// Start interactive routing. Will automatically finish if possible.
|
||||
performRouting( VECTOR2D() );
|
||||
|
||||
if( m_cancelled )
|
||||
break;
|
||||
|
||||
// Route didn't complete automatically, need to a new undo commit
|
||||
// for the next line so those can group as far as they autoroute
|
||||
if( !autoRouted )
|
||||
groupStart = true;
|
||||
}
|
||||
|
||||
if( m_cancelled )
|
||||
break;
|
||||
}
|
||||
|
||||
m_iface->SetCommitFlags( 0 );
|
||||
frame->PopTool( pushedEvent );
|
||||
m_inRouteSelected = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1949,7 +1968,8 @@ void ROUTER_TOOL::performDragging( int aMode )
|
||||
{
|
||||
m_menu->ShowContextMenu( selection() );
|
||||
}
|
||||
else if( evt->IsCancelInteractive() || evt->IsActivate() )
|
||||
else if( evt->IsCancelInteractive() || evt->IsAction( &PCB_ACTIONS::cancelCurrentItem )
|
||||
|| evt->IsActivate() )
|
||||
{
|
||||
if( evt->IsCancelInteractive() && !m_startItem )
|
||||
m_cancelled = true;
|
||||
@@ -2387,7 +2407,8 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
setCursor();
|
||||
|
||||
if( evt->IsCancelInteractive() || evt->IsActivate() )
|
||||
if( evt->IsCancelInteractive() || evt->IsAction( &PCB_ACTIONS::cancelCurrentItem )
|
||||
|| evt->IsActivate() )
|
||||
{
|
||||
if( wasLocked )
|
||||
item->SetLocked( true );
|
||||
|
||||
@@ -102,6 +102,7 @@ private:
|
||||
PCB_LAYER_ID m_originalActiveLayer;
|
||||
|
||||
bool m_inRouterTool; // Re-entrancy guard
|
||||
bool m_inRouteSelected;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2416,6 +2416,12 @@ TOOL_ACTION PCB_ACTIONS::routerAutorouteSelected( TOOL_ACTION_ARGS()
|
||||
.Flags( AF_ACTIVATE )
|
||||
.Parameter( PNS::PNS_MODE_ROUTE_SINGLE ) );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::cancelCurrentItem( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.InteractiveRouter.CancelCurrentItem" )
|
||||
.Scope( AS_GLOBAL )
|
||||
.FriendlyName( _( "Cancel Current Item" ) )
|
||||
.Tooltip( _( "Skip current item and route next selected item." ) ) );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::breakTrack( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.InteractiveRouter.BreakTrack" )
|
||||
.Scope( AS_GLOBAL )
|
||||
|
||||
@@ -267,6 +267,7 @@ public:
|
||||
static TOOL_ACTION routerRouteSelected;
|
||||
static TOOL_ACTION routerRouteSelectedFromEnd;
|
||||
static TOOL_ACTION routerAutorouteSelected;
|
||||
static TOOL_ACTION cancelCurrentItem;
|
||||
|
||||
/// Activation of the Push and Shove settings dialogs
|
||||
static TOOL_ACTION routerSettingsDialog;
|
||||
|
||||
Reference in New Issue
Block a user