diff --git a/pcbnew/router/pns_hole.h b/pcbnew/router/pns_hole.h index 91c8bf6582..fbc85b3d5d 100644 --- a/pcbnew/router/pns_hole.h +++ b/pcbnew/router/pns_hole.h @@ -61,7 +61,7 @@ public: ITEM* ParentPadVia() const { return m_parentPadVia; } - BOARD_ITEM* Parent() const override + BOARD_ITEM* BoardItem() const override { if( m_parent ) return m_parent; diff --git a/pcbnew/router/pns_item.h b/pcbnew/router/pns_item.h index fb6eceb929..71ff3a28d9 100644 --- a/pcbnew/router/pns_item.h +++ b/pcbnew/router/pns_item.h @@ -165,7 +165,7 @@ public: } /** - * Return true if the item's type matches the mask \a aKindMask. + * @return true if the item's type matches the mask \a aKindMask. */ bool OfKind( int aKindMask ) const { @@ -173,12 +173,17 @@ public: } /** - * Returns the kind of the item, as string + * @return the kind of the item, as string */ std::string KindStr() const; void SetParent( BOARD_ITEM* aParent ) { m_parent = aParent; } - virtual BOARD_ITEM* Parent() const { return m_parent; } + BOARD_ITEM* Parent() const { return m_parent; } + + /** + * @return the BOARD_ITEM, even if it's not the direct parent. + */ + virtual BOARD_ITEM* BoardItem() const { return m_parent; } void SetNet( int aNet ) { m_net = aNet; } int Net() const { return m_net; } diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index e18bb20f36..6fa8cdd769 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -110,7 +110,6 @@ public: virtual int DpCoupledNet( int aNet ) override; virtual int DpNetPolarity( int aNet ) override; virtual bool DpNetPair( const PNS::ITEM* aItem, int& aNetP, int& aNetN ) override; - virtual bool IsDiffPair( const PNS::ITEM* aA, const PNS::ITEM* aB ) override; virtual bool IsInNetTie( const PNS::ITEM* aA ) override; virtual bool IsNetTieExclusion( const PNS::ITEM* aItem, const VECTOR2I& aCollisionPos, @@ -172,26 +171,9 @@ PNS_PCBNEW_RULE_RESOLVER::~PNS_PCBNEW_RULE_RESOLVER() } -bool PNS_PCBNEW_RULE_RESOLVER::IsDiffPair( const PNS::ITEM* aA, const PNS::ITEM* aB ) -{ - int net_p, net_n; - - if( !DpNetPair( aA, net_p, net_n ) ) - return false; - - if( aA->Net() == net_p && aB->Net() == net_n ) - return true; - - if( aB->Net() == net_p && aA->Net() == net_n ) - return true; - - return false; -} - - bool PNS_PCBNEW_RULE_RESOLVER::IsInNetTie( const PNS::ITEM* aA ) { - BOARD_ITEM* item = aA->Parent(); + BOARD_ITEM* item = aA->BoardItem(); return item && item->GetParentFootprint() && item->GetParentFootprint()->IsNetTie(); } @@ -204,10 +186,11 @@ bool PNS_PCBNEW_RULE_RESOLVER::IsNetTieExclusion( const PNS::ITEM* aItem, wxCHECK( aItem && aCollidingItem, false ); std::shared_ptr drcEngine = m_board->GetDesignSettings().m_DRCEngine; - BOARD_ITEM* collidingItem = aCollidingItem->Parent(); + BOARD_ITEM* item = aItem->BoardItem(); + BOARD_ITEM* collidingItem = aCollidingItem->BoardItem(); FOOTPRINT* collidingFp = collidingItem->GetParentFootprint(); - FOOTPRINT* itemFp = aItem->Parent() ? aItem->Parent()->GetParentFootprint() : nullptr; + FOOTPRINT* itemFp = item ? item->GetParentFootprint() : nullptr; if( collidingFp && itemFp && ( collidingFp == itemFp ) && itemFp->IsNetTie() ) { @@ -290,7 +273,7 @@ static bool isEdge( const PNS::ITEM* aItem ) if ( !aItem ) return false; - const BOARD_ITEM *parent = aItem->Parent(); + const BOARD_ITEM *parent = aItem->BoardItem(); return parent && ( parent->IsOnLayer( Edge_Cuts ) || parent->IsOnLayer( Margin ) ); } @@ -321,8 +304,8 @@ bool PNS_PCBNEW_RULE_RESOLVER::QueryConstraint( PNS::CONSTRAINT_TYPE aType, default: return false; // should not happen } - BOARD_ITEM* parentA = aItemA ? aItemA->Parent() : nullptr; - BOARD_ITEM* parentB = aItemB ? aItemB->Parent() : nullptr; + BOARD_ITEM* parentA = aItemA ? aItemA->BoardItem() : nullptr; + BOARD_ITEM* parentB = aItemB ? aItemB->BoardItem() : nullptr; DRC_CONSTRAINT hostConstraint; // A track being routed may not have a BOARD_ITEM associated yet. @@ -1409,7 +1392,7 @@ bool PNS_KICAD_IFACE_BASE::IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer if( aLayer < 0 ) return true; - if( !aItem->OfKind( PNS::ITEM::HOLE_T ) && aItem->Parent() ) + if( aItem->Parent() ) { switch( aItem->Parent()->Type() ) { diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index 591ba3b826..66d2fd87b6 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -1579,9 +1579,6 @@ ITEM *NODE::FindItemByParent( const BOARD_ITEM* aParent ) { for( ITEM* item : *l_cur ) { - if( item->OfKind( PNS::ITEM::HOLE_T ) && static_cast( item )->ParentPadVia() ) - continue; - if( item->Parent() == aParent ) return item; } diff --git a/pcbnew/router/pns_node.h b/pcbnew/router/pns_node.h index 20ea54aa1a..6b936a4a87 100644 --- a/pcbnew/router/pns_node.h +++ b/pcbnew/router/pns_node.h @@ -142,8 +142,6 @@ public: virtual int DpNetPolarity( int aNet ) = 0; virtual bool DpNetPair( const ITEM* aItem, int& aNetP, int& aNetN ) = 0; - virtual bool IsDiffPair( const ITEM* aA, const ITEM* aB ) = 0; - virtual bool IsInNetTie( const ITEM* aA ) = 0; virtual bool IsNetTieExclusion( const PNS::ITEM* aItem, const VECTOR2I& aCollisionPos, const PNS::ITEM* aCollidingItem )= 0; diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 8035a208cd..4dad5711a1 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -250,7 +250,7 @@ bool ROUTER::isStartingPointRoutable( const VECTOR2I& aWhere, ITEM* aStartItem, for( ITEM* item : candidates.Items() ) { // Edge cuts are put on all layers, but they're not *really* on all layers - if( item->Parent() && item->Parent()->GetLayer() == Edge_Cuts ) + if( item->BoardItem() && item->BoardItem()->GetLayer() == Edge_Cuts ) continue; if( !item->Layers().Overlaps( aLayer ) ) @@ -263,7 +263,7 @@ bool ROUTER::isStartingPointRoutable( const VECTOR2I& aWhere, ITEM* aStartItem, } else { - BOARD_ITEM* parent = item->Parent(); + BOARD_ITEM* parent = item->BoardItem(); switch( parent->Type() ) { diff --git a/pcbnew/router/router_preview_item.cpp b/pcbnew/router/router_preview_item.cpp index 7deafd81c3..ff283385f3 100644 --- a/pcbnew/router/router_preview_item.cpp +++ b/pcbnew/router/router_preview_item.cpp @@ -43,7 +43,7 @@ ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const PNS::ITEM* aItem, KIGFX::VIEW* a m_shape( nullptr ), m_hole( nullptr ) { - BOARD_ITEM* boardItem = aItem ? aItem->Parent() : nullptr; + BOARD_ITEM* boardItem = aItem ? aItem->BoardItem() : nullptr; // A PNS::SOLID for an edge-cut item must have 0 width for collision calculations, but when // highlighting an edge we want to show it with its parent PCB_SHAPE's shape. diff --git a/qa/unittests/pcbnew/test_pns_basics.cpp b/qa/unittests/pcbnew/test_pns_basics.cpp index d6c6b9a0bf..d48cde11b5 100644 --- a/qa/unittests/pcbnew/test_pns_basics.cpp +++ b/qa/unittests/pcbnew/test_pns_basics.cpp @@ -138,8 +138,6 @@ public: { return false; } - virtual bool IsDiffPair( const PNS::ITEM* aA, const PNS::ITEM* aB ) override { return false; } - virtual bool QueryConstraint( PNS::CONSTRAINT_TYPE aType, const PNS::ITEM* aItemA, const PNS::ITEM* aItemB, int aLayer, PNS::CONSTRAINT* aConstraint ) override