Improved error messages for diff-pair routing.

Fixes: lp:1542592
* https://bugs.launchpad.net/kicad/+bug/1542592
This commit is contained in:
Jeff Young 2018-05-19 01:50:52 +01:00
parent 6b1df2e992
commit 2bd0a027a2
4 changed files with 42 additions and 7 deletions

View File

@ -437,7 +437,8 @@ OPT_VECTOR2I DIFF_PAIR_PLACER::getDanglingAnchor( NODE* aNode, ITEM* aItem )
bool DIFF_PAIR_PLACER::findDpPrimitivePair( const VECTOR2I& aP, ITEM* aItem, DP_PRIMITIVE_PAIR& aPair )
bool DIFF_PAIR_PLACER::findDpPrimitivePair( const VECTOR2I& aP, ITEM* aItem,
DP_PRIMITIVE_PAIR& aPair, wxString* aErrorMsg )
{
int netP, netN;
@ -446,7 +447,15 @@ bool DIFF_PAIR_PLACER::findDpPrimitivePair( const VECTOR2I& aP, ITEM* aItem, DP_
bool result = m_world->GetRuleResolver()->DpNetPair( aItem, netP, netN );
if( !result )
{
if( aErrorMsg )
{
*aErrorMsg = _( "Unable to find complementary differential pair "
"nets. Make sure the names of the nets belonging "
"to a differential pair end with either _N/_P or +/-." );
}
return false;
}
int refNet = aItem->Net();
int coupledNet = ( refNet == netP ) ? netN : netP;
@ -459,7 +468,15 @@ bool DIFF_PAIR_PLACER::findDpPrimitivePair( const VECTOR2I& aP, ITEM* aItem, DP_
wxLogTrace( "PNS", "refAnchor %p", aItem );
if( !refAnchor )
{
if( aErrorMsg )
{
*aErrorMsg = _( "Can't find a suitable starting point. If starting "
"from an existing differential pair make sure you are "
"at the end. " );
}
return false;
}
std::set<ITEM*> coupledItems;
@ -503,7 +520,18 @@ bool DIFF_PAIR_PLACER::findDpPrimitivePair( const VECTOR2I& aP, ITEM* aItem, DP_
}
}
return found;
if( !found )
{
if( aErrorMsg )
{
*aErrorMsg = wxString::Format( _( "Can't find a suitable starting point "
"for coupled net \"%s\"." ),
m_world->GetRuleResolver()->NetName( coupledNet ) );
}
return false;
}
return true;
}
@ -522,6 +550,7 @@ int DIFF_PAIR_PLACER::gap() const
bool DIFF_PAIR_PLACER::Start( const VECTOR2I& aP, ITEM* aStartItem )
{
VECTOR2I p( aP );
wxString msg;
if( !aStartItem )
{
@ -533,11 +562,9 @@ bool DIFF_PAIR_PLACER::Start( const VECTOR2I& aP, ITEM* aStartItem )
setWorld( Router()->GetWorld() );
m_currentNode = m_world;
if( !findDpPrimitivePair( aP, aStartItem, m_start ) )
if( !findDpPrimitivePair( aP, aStartItem, m_start, &msg ) )
{
Router()->SetFailureReason( _( "Unable to find complementary differential pair "
"net. Make sure the names of the nets belonging "
"to a differential pair end with either _N/_P or +/-." ) );
Router()->SetFailureReason( msg );
return false;
}

View File

@ -226,7 +226,7 @@ private:
const VIA makeVia ( const VECTOR2I& aP, int aNet );
bool findDpPrimitivePair( const VECTOR2I& aP, ITEM* aItem, DP_PRIMITIVE_PAIR& aPair );
bool findDpPrimitivePair( const VECTOR2I& aP, ITEM* aItem, DP_PRIMITIVE_PAIR& aPair, wxString* aErrorMsg = nullptr );
OPT_VECTOR2I getDanglingAnchor( NODE* aNode, ITEM* aItem );
bool attemptWalk( NODE* aNode, DIFF_PAIR* aCurrent, DIFF_PAIR& aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly );
bool propagateDpHeadForces ( const VECTOR2I& aP, VECTOR2I& aNewP );

View File

@ -76,6 +76,7 @@ public:
virtual int DpCoupledNet( int aNet ) override;
virtual int DpNetPolarity( int aNet ) override;
virtual bool DpNetPair( PNS::ITEM* aItem, int& aNetP, int& aNetN ) override;
virtual wxString NetName( int aNet ) override;
private:
struct CLEARANCE_ENT
@ -315,6 +316,12 @@ int PNS_PCBNEW_RULE_RESOLVER::DpCoupledNet( int aNet )
}
wxString PNS_PCBNEW_RULE_RESOLVER::NetName( int aNet )
{
return m_board->FindNet( aNet )->GetNetname();
}
int PNS_PCBNEW_RULE_RESOLVER::DpNetPolarity( int aNet )
{
wxString refName = m_board->FindNet( aNet )->GetNetname();

View File

@ -65,6 +65,7 @@ public:
virtual int DpCoupledNet( int aNet ) = 0;
virtual int DpNetPolarity( int aNet ) = 0;
virtual bool DpNetPair( ITEM* aItem, int& aNetP, int& aNetN ) = 0;
virtual wxString NetName( int aNet ) = 0;
};
/**