PNS: Improve behavior of dragging vias

- Fall back to walkaround when drag fails
- Properly check collisions with holes

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15117
This commit is contained in:
Jon Evans 2023-08-01 19:03:04 -04:00
parent 9741d57447
commit cc7d470f8b
3 changed files with 24 additions and 3 deletions

View File

@ -685,6 +685,11 @@ bool DRAGGER::dragShove( const VECTOR2I& aP )
m_draggedVia = newVia;
m_draggedItems.Clear();
// If drag didn't work (i.e. dragged onto a collision) try walkaround instead
if( !ok )
ok = dragViaWalkaround( m_draggedVia, m_lastNode, aP );
break;
}
}

View File

@ -1308,7 +1308,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
PNS_DBG( Dbg(), AddItem, &currentLine, RED, currentLine.Width(), wxString::Format( wxT( "current-coll-chk rank %d" ), currentLine.Rank() ) );
for( ITEM::PnsKind search_order : { ITEM::SOLID_T, ITEM::VIA_T, ITEM::SEGMENT_T } )
for( ITEM::PnsKind search_order : { ITEM::HOLE_T, ITEM::SOLID_T, ITEM::VIA_T, ITEM::SEGMENT_T } )
{
COLLISION_SEARCH_OPTIONS opts;
opts.m_kindMask = search_order;
@ -1343,6 +1343,12 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
ITEM* ni = nearest->m_item;
UNITS_PROVIDER up( pcbIUScale, EDA_UNITS::MILLIMETRES );
PNS_DBG( Dbg(), Message,
wxString::Format( wxT( "NI: %s (%s)" ), ni->Format(), ni->Parent()
? ni->Parent()->GetItemDescription( &up )
: "null" ) );
unwindLineStack( ni );
if( !ni->OfKind( ITEM::SOLID_T ) && ni->Rank() >= 0 && ni->Rank() > currentLine.Rank() )
@ -1793,13 +1799,21 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveDraggingVia( const VIA_HANDLE aOldVia, const VEC
st = shoveMainLoop();
if( st == SH_OK )
{
runOptimizer( m_currentNode );
// m_draggedVia will only be updated if pushOrShoveVia makes progress...
// this should probably be refactored/cleaned up.
PNS::VIA* viaCheck = m_draggedVia ? m_draggedVia : viaToDrag;
st = m_currentNode->CheckColliding( viaCheck ) ? SH_INCOMPLETE : SH_OK;
}
if( st == SH_OK || st == SH_HEAD_MODIFIED )
{
wxLogTrace( "PNS","setNewV %p", m_draggedVia );
if (!m_draggedVia)
if( !m_draggedVia )
m_draggedVia = viaToDrag;
aNewVia = m_draggedVia->MakeHandle();

View File

@ -638,7 +638,9 @@ void ROUTER_TOOL::saveRouterDebugLog()
for( auto item : removed )
{
fprintf(f, "removed %s\n", item->Parent()->m_Uuid.AsString().c_str().AsChar() );
fprintf(f, "removed %s\n", item->Parent() ?
item->Parent()->m_Uuid.AsString().c_str().AsChar() :
item->Format().c_str() );
}
for( auto item : added )