diff --git a/pcbnew/router/pns_diff_pair_placer.cpp b/pcbnew/router/pns_diff_pair_placer.cpp index 3d4f74b5b0..5f5b32ff7e 100644 --- a/pcbnew/router/pns_diff_pair_placer.cpp +++ b/pcbnew/router/pns_diff_pair_placer.cpp @@ -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 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; } diff --git a/pcbnew/router/pns_diff_pair_placer.h b/pcbnew/router/pns_diff_pair_placer.h index 6eb3ec8bc9..543f77b12f 100644 --- a/pcbnew/router/pns_diff_pair_placer.h +++ b/pcbnew/router/pns_diff_pair_placer.h @@ -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 ); diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index 4d70fdd22f..e9ac6953d1 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -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(); diff --git a/pcbnew/router/pns_node.h b/pcbnew/router/pns_node.h index b7278fa818..6ee8468af0 100644 --- a/pcbnew/router/pns_node.h +++ b/pcbnew/router/pns_node.h @@ -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; }; /**