PNS/Router Tool: Refactor Continue From End
This commit is contained in:
parent
1be0deb58f
commit
6252840abd
|
@ -542,6 +542,38 @@ bool ROUTER::Finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ROUTER::ContinueFromEnd()
|
||||||
|
{
|
||||||
|
LINE_PLACER* placer = dynamic_cast<LINE_PLACER*>( Placer() );
|
||||||
|
|
||||||
|
if( placer == nullptr )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
LINE current = placer->Trace();
|
||||||
|
int currentLayer = GetCurrentLayer();
|
||||||
|
VECTOR2I currentEnd = placer->CurrentEnd();
|
||||||
|
VECTOR2I otherEnd;
|
||||||
|
LAYER_RANGE otherEndLayers;
|
||||||
|
|
||||||
|
// Get the anchor nearest to the end of the trace the user is routing
|
||||||
|
if( !getNearestRatnestAnchor( otherEnd, otherEndLayers ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CommitRouting();
|
||||||
|
|
||||||
|
// Commit whatever we've fixed and restart routing from the other end
|
||||||
|
int nextLayer = otherEndLayers.Overlaps( currentLayer ) ? currentLayer : otherEndLayers.Start();
|
||||||
|
|
||||||
|
if( !StartRouting( otherEnd, ¤t, nextLayer ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Attempt to route to our current position
|
||||||
|
Move( currentEnd, ¤t );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ROUTER::moveDragging( const VECTOR2I& aP, ITEM* aEndItem )
|
bool ROUTER::moveDragging( const VECTOR2I& aP, ITEM* aEndItem )
|
||||||
{
|
{
|
||||||
m_iface->EraseView();
|
m_iface->EraseView();
|
||||||
|
|
|
@ -144,6 +144,7 @@ public:
|
||||||
bool StartRouting( const VECTOR2I& aP, ITEM* aItem, int aLayer );
|
bool StartRouting( const VECTOR2I& aP, ITEM* aItem, int aLayer );
|
||||||
bool Move( const VECTOR2I& aP, ITEM* aItem );
|
bool Move( const VECTOR2I& aP, ITEM* aItem );
|
||||||
bool Finish();
|
bool Finish();
|
||||||
|
bool ContinueFromEnd();
|
||||||
bool FixRoute( const VECTOR2I& aP, ITEM* aItem, bool aForceFinish = false );
|
bool FixRoute( const VECTOR2I& aP, ITEM* aItem, bool aForceFinish = false );
|
||||||
void BreakSegment( ITEM *aItem, const VECTOR2I& aP );
|
void BreakSegment( ITEM *aItem, const VECTOR2I& aP );
|
||||||
|
|
||||||
|
|
|
@ -1293,50 +1293,18 @@ void ROUTER_TOOL::performRouting()
|
||||||
}
|
}
|
||||||
else if( evt->IsAction( &PCB_ACTIONS::routerContinueFromEnd ) )
|
else if( evt->IsAction( &PCB_ACTIONS::routerContinueFromEnd ) )
|
||||||
{
|
{
|
||||||
PNS::LINE_PLACER* placer = dynamic_cast<PNS::LINE_PLACER*>( m_router->Placer() );
|
bool needsAppend = m_router->Placer()->HasPlacedAnything();
|
||||||
|
|
||||||
if( placer == nullptr )
|
if( m_router->ContinueFromEnd() )
|
||||||
break;
|
|
||||||
|
|
||||||
// Get our current line and position and nearest ratsnest to them if it exists
|
|
||||||
PNS::LINE current = placer->Trace();
|
|
||||||
VECTOR2I currentEnd = placer->CurrentEnd();
|
|
||||||
VECTOR2I otherEnd;
|
|
||||||
LAYER_RANGE otherEndLayers;
|
|
||||||
|
|
||||||
if( !getNearestRatnestAnchor( otherEnd, otherEndLayers ) )
|
|
||||||
break;
|
|
||||||
|
|
||||||
if( evt->IsAction( &PCB_ACTIONS::routerContinueFromEnd ) )
|
|
||||||
{
|
{
|
||||||
// Commit routing will put the router on no layer, so save it
|
syncRouterAndFrameLayer();
|
||||||
int currentLayer = m_router->GetCurrentLayer();
|
m_startSnapPoint = m_router->Placer()->CurrentStart();
|
||||||
|
|
||||||
// Commit whatever we've fixed and restart routing from the other end
|
|
||||||
if( m_router->Placer()->HasPlacedAnything() )
|
|
||||||
{
|
|
||||||
m_router->CommitRouting();
|
|
||||||
m_iface->SetCommitFlags( APPEND_UNDO );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_router->StopRouting();
|
|
||||||
|
|
||||||
if( otherEndLayers.Overlaps( currentLayer ) )
|
|
||||||
m_router->StartRouting( otherEnd, ¤t, currentLayer );
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_router->StartRouting( otherEnd, ¤t, otherEndLayers.Start() );
|
|
||||||
syncRouterAndFrameLayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_startSnapPoint = otherEnd;
|
|
||||||
|
|
||||||
// Attempt to route to our current position
|
|
||||||
m_router->Move( currentEnd, ¤t );
|
|
||||||
VECTOR2I moveResultPoint = m_router->Placer()->CurrentEnd();
|
|
||||||
|
|
||||||
// Warp the mouse to wherever we actually ended up routing to
|
// Warp the mouse to wherever we actually ended up routing to
|
||||||
controls()->WarpMouseCursor( currentEnd, true, true );
|
controls()->WarpMouseCursor( m_router->Placer()->CurrentEnd(), true, true );
|
||||||
|
|
||||||
|
// We want the next router commit to be one undo at the UI layer
|
||||||
|
m_iface->SetCommitFlags( needsAppend ? APPEND_UNDO : 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( evt->IsClick( BUT_LEFT ) || evt->IsDrag( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
|
else if( evt->IsClick( BUT_LEFT ) || evt->IsDrag( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
|
||||||
|
|
Loading…
Reference in New Issue