diff --git a/pcbnew/connectivity/connectivity_data.cpp b/pcbnew/connectivity/connectivity_data.cpp index 281ee38507..42717a13f5 100644 --- a/pcbnew/connectivity/connectivity_data.cpp +++ b/pcbnew/connectivity/connectivity_data.cpp @@ -613,25 +613,30 @@ bool CONNECTIVITY_DATA::TestTrackEndpointDangling( TRACK* aTrack, wxPoint* aPos } -const std::vector CONNECTIVITY_DATA::GetConnectedItems( - const BOARD_CONNECTED_ITEM* aItem, const VECTOR2I& aAnchor, KICAD_T aTypes[] ) +const std::vector CONNECTIVITY_DATA::GetConnectedItemsAtAnchor( + const BOARD_CONNECTED_ITEM* aItem, const VECTOR2I& aAnchor, const KICAD_T aTypes[] ) const { auto& entry = m_connAlgo->ItemEntry( aItem ); std::vector rv; for( auto cnItem : entry.GetItems() ) { - for( auto anchor : cnItem->Anchors() ) + for( auto connected : cnItem->ConnectedItems() ) { - if( anchor->Pos() == aAnchor ) + for( auto anchor : connected->Anchors() ) { - for( int i = 0; aTypes[i] > 0; i++ ) + if( anchor->Pos() == aAnchor ) { - if( cnItem->Valid() && cnItem->Parent()->Type() == aTypes[i] ) + for( int i = 0; aTypes[i] > 0; i++ ) { - rv.push_back( cnItem->Parent() ); - break; + if( connected->Valid() && connected->Parent()->Type() == aTypes[i] ) + { + rv.push_back( connected->Parent() ); + break; + } } + + break; } } } diff --git a/pcbnew/connectivity/connectivity_data.h b/pcbnew/connectivity/connectivity_data.h index 64618643af..8cc03a8358 100644 --- a/pcbnew/connectivity/connectivity_data.h +++ b/pcbnew/connectivity/connectivity_data.h @@ -195,7 +195,17 @@ public: void GetConnectedPads( const BOARD_CONNECTED_ITEM* aItem, std::set* pads ) const; - const std::vector GetConnectedItems( const BOARD_CONNECTED_ITEM* aItem, const VECTOR2I& aAnchor, KICAD_T aTypes[] ); + /** + * Function GetConnectedItemsAtAnchor() + * Returns a list of items connected to a source item aItem at position aAnchor + * @param aItem is the reference item to find other connected items. + * @param aAnchor is the position to find connected items on. + * @param aTypes allows one to filter by item types. + * @return + */ + const std::vector GetConnectedItemsAtAnchor( const BOARD_CONNECTED_ITEM* aItem, + const VECTOR2I& aAnchor, + const KICAD_T aTypes[] ) const; void GetUnconnectedEdges( std::vector& aEdges ) const;