From 8bfb255c96be6fa65514c5b46373a1e6a1f019f1 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 1 Nov 2020 23:46:09 +0000 Subject: [PATCH] Put a warning when routing can't start due to DRC violation. Fixes https://gitlab.com/kicad/code/kicad/issues/4975 --- pcbnew/router/pns_node.h | 9 +++++---- pcbnew/router/pns_router.cpp | 21 ++++++++++++++++++--- pcbnew/router/pns_router.h | 6 +----- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/pcbnew/router/pns_node.h b/pcbnew/router/pns_node.h index ba683ed763..1df13c3e7f 100644 --- a/pcbnew/router/pns_node.h +++ b/pcbnew/router/pns_node.h @@ -231,11 +231,12 @@ public: bool aDifferentNetsOnly = true, int aForceClearance = -1 ); - int QueryJoints( const BOX2I& aBox, std::vector & aJoints, int aLayerMask = -1, int aKindMask = ITEM::ANY_T); + int QueryJoints( const BOX2I& aBox, + std::vector& aJoints, + int aLayerMask = -1, + int aKindMask = ITEM::ANY_T); - int QueryColliding( const ITEM* aItem, - OBSTACLE_VISITOR& aVisitor - ); + int QueryColliding( const ITEM* aItem, OBSTACLE_VISITOR& aVisitor ); /** * Function NearestObstacle() diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index b770d7f60f..2282e2d6de 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -170,12 +170,12 @@ bool ROUTER::StartDragging( const VECTOR2I& aP, ITEM_SET aStartItems, int aDragM return true; } -bool ROUTER::isStartingPointRoutable( const VECTOR2I& aWhere, int aLayer ) +bool ROUTER::isStartingPointRoutable( const VECTOR2I& aWhere, ITEM* aStartItem, int aLayer ) { if( Settings().CanViolateDRC() && Settings().Mode() == RM_MarkObstacles ) return true; - auto candidates = QueryHoverItems( aWhere ); + ITEM_SET candidates = QueryHoverItems( aWhere ); for( ITEM* item : candidates.Items() ) { @@ -183,12 +183,27 @@ bool ROUTER::isStartingPointRoutable( const VECTOR2I& aWhere, int aLayer ) return false; } + if( m_mode == PNS_MODE_ROUTE_SINGLE ) + { + VECTOR2I startPoint = aStartItem->Anchor( 0 ); + SEGMENT dummyStartSeg( SEG( startPoint, startPoint ), aStartItem->Net() ); + + dummyStartSeg.SetWidth( m_sizes.TrackWidth() ); + + if( m_world->CheckColliding( &dummyStartSeg, ITEM::ANY_T ) ) + return false; + } + else if( m_mode == PNS_MODE_ROUTE_DIFF_PAIR ) + { + // TODO + } + return true; } bool ROUTER::StartRouting( const VECTOR2I& aP, ITEM* aStartItem, int aLayer ) { - if( ! isStartingPointRoutable( aP, aLayer ) ) + if( ! isStartingPointRoutable( aP, aStartItem, aLayer ) ) { SetFailureReason( _( "The routing start point violates DRC." ) ); return false; diff --git a/pcbnew/router/pns_router.h b/pcbnew/router/pns_router.h index d139b95b54..80b4e811d8 100644 --- a/pcbnew/router/pns_router.h +++ b/pcbnew/router/pns_router.h @@ -152,8 +152,6 @@ public: void CommitRouting(); void StopRouting(); - int GetClearance( const ITEM* aA, const ITEM* aB ) const; - NODE* GetWorld() const { return m_world.get(); @@ -161,8 +159,6 @@ public: void FlipPosture(); - void DisplayItem( const ITEM* aItem, int aColor = -1, int aClearance = -1, bool aEdit = false ); - void DeleteTraces( ITEM* aStartItem, bool aWholeTrack ); void SwitchLayer( int layer ); void ToggleViaPlacement(); @@ -262,7 +258,7 @@ private: void highlightCurrent( bool enabled ); void markViolations( NODE* aNode, ITEM_SET& aCurrent, NODE::ITEM_VECTOR& aRemoved ); - bool isStartingPointRoutable( const VECTOR2I& aWhere, int aLayer ); + bool isStartingPointRoutable( const VECTOR2I& aWhere, ITEM* aItem, int aLayer ); VECTOR2I m_currentEnd; RouterState m_state;