Put a warning when routing can't start due to DRC violation.

Fixes https://gitlab.com/kicad/code/kicad/issues/4975
This commit is contained in:
Jeff Young 2020-11-01 23:46:09 +00:00
parent 409cd9d4ee
commit 8bfb255c96
3 changed files with 24 additions and 12 deletions

View File

@ -231,11 +231,12 @@ public:
bool aDifferentNetsOnly = true, bool aDifferentNetsOnly = true,
int aForceClearance = -1 ); int aForceClearance = -1 );
int QueryJoints( const BOX2I& aBox, std::vector<JOINT*> & aJoints, int aLayerMask = -1, int aKindMask = ITEM::ANY_T); int QueryJoints( const BOX2I& aBox,
std::vector<JOINT*>& aJoints,
int aLayerMask = -1,
int aKindMask = ITEM::ANY_T);
int QueryColliding( const ITEM* aItem, int QueryColliding( const ITEM* aItem, OBSTACLE_VISITOR& aVisitor );
OBSTACLE_VISITOR& aVisitor
);
/** /**
* Function NearestObstacle() * Function NearestObstacle()

View File

@ -170,12 +170,12 @@ bool ROUTER::StartDragging( const VECTOR2I& aP, ITEM_SET aStartItems, int aDragM
return true; 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 ) if( Settings().CanViolateDRC() && Settings().Mode() == RM_MarkObstacles )
return true; return true;
auto candidates = QueryHoverItems( aWhere ); ITEM_SET candidates = QueryHoverItems( aWhere );
for( ITEM* item : candidates.Items() ) for( ITEM* item : candidates.Items() )
{ {
@ -183,12 +183,27 @@ bool ROUTER::isStartingPointRoutable( const VECTOR2I& aWhere, int aLayer )
return false; 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; return true;
} }
bool ROUTER::StartRouting( const VECTOR2I& aP, ITEM* aStartItem, int aLayer ) 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." ) ); SetFailureReason( _( "The routing start point violates DRC." ) );
return false; return false;

View File

@ -152,8 +152,6 @@ public:
void CommitRouting(); void CommitRouting();
void StopRouting(); void StopRouting();
int GetClearance( const ITEM* aA, const ITEM* aB ) const;
NODE* GetWorld() const NODE* GetWorld() const
{ {
return m_world.get(); return m_world.get();
@ -161,8 +159,6 @@ public:
void FlipPosture(); 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 SwitchLayer( int layer );
void ToggleViaPlacement(); void ToggleViaPlacement();
@ -262,7 +258,7 @@ private:
void highlightCurrent( bool enabled ); void highlightCurrent( bool enabled );
void markViolations( NODE* aNode, ITEM_SET& aCurrent, NODE::ITEM_VECTOR& aRemoved ); 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; VECTOR2I m_currentEnd;
RouterState m_state; RouterState m_state;