KiCad PCB EDA Suite
CN_ANCHOR Class Reference

#include <connectivity_items.h>

Public Member Functions

 CN_ANCHOR ()
 
 CN_ANCHOR (const VECTOR2I &aPos, CN_ITEM *aItem)
 
bool Valid () const
 
CN_ITEMItem () const
 
BOARD_CONNECTED_ITEMParent () const
 
const VECTOR2IPos () const
 
int GetTag () const
 Returns tag, common identifier for connected nodes. More...
 
void SetTag (int aTag)
 Sets tag, common identifier for connected nodes. More...
 
void SetNoLine (bool aEnable)
 Decides whether this node can be a ratsnest line target. More...
 
const bool & GetNoLine () const
 Returns true if this node can be a target for ratsnest lines. More...
 
void SetCluster (std::shared_ptr< CN_CLUSTER > aCluster)
 
const std::shared_ptr< CN_CLUSTER > & GetCluster () const
 
bool IsDangling () const
 has meaning only for tracks and vias. More...
 
int ConnectedItemsCount () const
 has meaning only for tracks and vias. More...
 

Static Public Attributes

static const int TAG_UNCONNECTED = -1
 

Private Attributes

VECTOR2I m_pos
 Position of the anchor. More...
 
CN_ITEMm_item = nullptr
 Item owning the anchor. More...
 
int m_tag = -1
 Tag for quick connection resolution. More...
 
bool m_noline = false
 Whether it the node can be a target for ratsnest lines. More...
 
std::shared_ptr< CN_CLUSTERm_cluster
 Cluster to which the anchor belongs. More...
 

Detailed Description

Definition at line 54 of file connectivity_items.h.

Constructor & Destructor Documentation

◆ CN_ANCHOR() [1/2]

CN_ANCHOR::CN_ANCHOR ( )
inline

Definition at line 57 of file connectivity_items.h.

58  {
59  m_item = nullptr;
60  }
CN_ITEM * m_item
Item owning the anchor.

References m_item.

◆ CN_ANCHOR() [2/2]

CN_ANCHOR::CN_ANCHOR ( const VECTOR2I aPos,
CN_ITEM aItem 
)
inline

Definition at line 62 of file connectivity_items.h.

63  {
64  m_pos = aPos;
65  m_item = aItem;
66  assert( m_item );
67  }
VECTOR2I m_pos
Position of the anchor.
CN_ITEM * m_item
Item owning the anchor.

References m_item, and m_pos.

Member Function Documentation

◆ ConnectedItemsCount()

int CN_ANCHOR::ConnectedItemsCount ( ) const

has meaning only for tracks and vias.

Returns
the count of items connected to this anchor

Definition at line 383 of file connectivity_items.cpp.

384 {
385  if( !m_cluster )
386  return 0;
387 
388  int connected_count = 0;
389 
390  for( auto item : m_item->ConnectedItems() )
391  {
392  if( item->Parent()->Type() == PCB_ZONE_AREA_T )
393  {
394  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item->Parent() );
395 
396  if( zone->HitTestFilledArea( wxPoint( Pos().x, Pos().y ) ) )
397  connected_count++;
398  }
399  else if( item->Parent()->HitTest( wxPoint( Pos().x, Pos().y ) ) )
400  connected_count++;
401  }
402 
403  return connected_count;
404 }
const CONNECTED_ITEMS & ConnectedItems() const
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
std::shared_ptr< CN_CLUSTER > m_cluster
Cluster to which the anchor belongs.
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
bool HitTestFilledArea(const wxPoint &aRefPos) const
Function HitTestFilledArea tests if the given wxPoint is within the bounds of a filled area of this z...
Definition: class_zone.cpp:684
CN_ITEM * m_item
Item owning the anchor.
const VECTOR2I & Pos() const

References CN_ITEM::ConnectedItems(), ZONE_CONTAINER::HitTestFilledArea(), m_cluster, m_item, PCB_ZONE_AREA_T, and Pos().

◆ GetCluster()

const std::shared_ptr<CN_CLUSTER>& CN_ANCHOR::GetCluster ( ) const
inline

Definition at line 113 of file connectivity_items.h.

114  {
115  return m_cluster;
116  }
std::shared_ptr< CN_CLUSTER > m_cluster
Cluster to which the anchor belongs.

References m_cluster.

◆ GetNoLine()

const bool& CN_ANCHOR::GetNoLine ( ) const
inline

Returns true if this node can be a target for ratsnest lines.

Definition at line 103 of file connectivity_items.h.

104  {
105  return m_noline;
106  }
bool m_noline
Whether it the node can be a target for ratsnest lines.

References m_noline.

◆ GetTag()

int CN_ANCHOR::GetTag ( ) const
inline

Returns tag, common identifier for connected nodes.

Definition at line 85 of file connectivity_items.h.

86  {
87  return m_tag;
88  }
int m_tag
Tag for quick connection resolution.

References m_tag.

◆ IsDangling()

bool CN_ANCHOR::IsDangling ( ) const

has meaning only for tracks and vias.

Returns
true if this anchor is dangling The anchor point is dangling if the parent is a track and this anchor point is not connected to another item ( track, vas pad or zone) or if the parent is a via and this anchor point is connected to only one track and not to another item

Definition at line 346 of file connectivity_items.cpp.

347 {
348  if( !m_cluster )
349  return true;
350 
351  // the minimal number of items connected to item_ref
352  // at this anchor point to decide the anchor is *not* dangling
353  size_t minimal_count = 1;
354  size_t connected_count = m_item->ConnectedItems().size();
355 
356  // a via can be removed if connected to only one other item.
357  if( Parent()->Type() == PCB_VIA_T )
358  return connected_count < 2;
359 
360  if( m_item->AnchorCount() == 1 )
361  return connected_count < minimal_count;
362 
363  // Items with multiple anchors have usually items connected to each anchor.
364  // We want only the item count of this anchor point
365  connected_count = 0;
366  for( auto item : m_item->ConnectedItems() )
367  {
368  if( item->Parent()->Type() == PCB_ZONE_AREA_T )
369  {
370  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item->Parent() );
371 
372  if( zone->HitTestFilledArea( (wxPoint) Pos() ) )
373  connected_count++;
374  }
375  else if( item->Parent()->HitTest( (wxPoint) Pos() ) )
376  connected_count++;
377  }
378 
379  return connected_count < minimal_count;
380 }
const CONNECTED_ITEMS & ConnectedItems() const
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
std::shared_ptr< CN_CLUSTER > m_cluster
Cluster to which the anchor belongs.
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
bool HitTestFilledArea(const wxPoint &aRefPos) const
Function HitTestFilledArea tests if the given wxPoint is within the bounds of a filled area of this z...
Definition: class_zone.cpp:684
virtual int AnchorCount() const
CN_ITEM * m_item
Item owning the anchor.
BOARD_CONNECTED_ITEM * Parent() const
const VECTOR2I & Pos() const
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97

References CN_ITEM::AnchorCount(), CN_ITEM::ConnectedItems(), ZONE_CONTAINER::HitTestFilledArea(), m_cluster, m_item, Parent(), PCB_VIA_T, PCB_ZONE_AREA_T, and Pos().

◆ Item()

CN_ITEM* CN_ANCHOR::Item ( ) const
inline

Definition at line 72 of file connectivity_items.h.

73  {
74  return m_item;
75  }
CN_ITEM * m_item
Item owning the anchor.

References m_item.

◆ Parent()

BOARD_CONNECTED_ITEM * CN_ANCHOR::Parent ( ) const

Definition at line 330 of file connectivity_items.cpp.

331 {
332  assert( m_item->Valid() );
333  return m_item->Parent();
334 }
BOARD_CONNECTED_ITEM * Parent() const
CN_ITEM * m_item
Item owning the anchor.
bool Valid() const

References m_item, CN_ITEM::Parent(), and CN_ITEM::Valid().

Referenced by IsDangling().

◆ Pos()

const VECTOR2I& CN_ANCHOR::Pos ( ) const
inline

Definition at line 79 of file connectivity_items.h.

80  {
81  return m_pos;
82  }
VECTOR2I m_pos
Position of the anchor.

References m_pos.

Referenced by ConnectedItemsCount(), and IsDangling().

◆ SetCluster()

void CN_ANCHOR::SetCluster ( std::shared_ptr< CN_CLUSTER aCluster)
inline

Definition at line 108 of file connectivity_items.h.

109  {
110  m_cluster = aCluster;
111  }
std::shared_ptr< CN_CLUSTER > m_cluster
Cluster to which the anchor belongs.

References m_cluster.

◆ SetNoLine()

void CN_ANCHOR::SetNoLine ( bool  aEnable)
inline

Decides whether this node can be a ratsnest line target.

Definition at line 97 of file connectivity_items.h.

98  {
99  m_noline = aEnable;
100  }
bool m_noline
Whether it the node can be a target for ratsnest lines.

References m_noline.

Referenced by CONNECTIVITY_DATA::ClearDynamicRatsnest().

◆ SetTag()

void CN_ANCHOR::SetTag ( int  aTag)
inline

Sets tag, common identifier for connected nodes.

Definition at line 91 of file connectivity_items.h.

92  {
93  m_tag = aTag;
94  }
int m_tag
Tag for quick connection resolution.

References m_tag.

◆ Valid()

bool CN_ANCHOR::Valid ( ) const

Definition at line 337 of file connectivity_items.cpp.

338 {
339  if( !m_item )
340  return false;
341 
342  return m_item->Valid();
343 }
CN_ITEM * m_item
Item owning the anchor.
bool Valid() const

References m_item, and CN_ITEM::Valid().

Member Data Documentation

◆ m_cluster

std::shared_ptr<CN_CLUSTER> CN_ANCHOR::m_cluster
private

Cluster to which the anchor belongs.

Definition at line 151 of file connectivity_items.h.

Referenced by ConnectedItemsCount(), GetCluster(), IsDangling(), and SetCluster().

◆ m_item

CN_ITEM* CN_ANCHOR::m_item = nullptr
private

Item owning the anchor.

Definition at line 142 of file connectivity_items.h.

Referenced by CN_ANCHOR(), ConnectedItemsCount(), IsDangling(), Item(), Parent(), and Valid().

◆ m_noline

bool CN_ANCHOR::m_noline = false
private

Whether it the node can be a target for ratsnest lines.

Definition at line 148 of file connectivity_items.h.

Referenced by GetNoLine(), and SetNoLine().

◆ m_pos

VECTOR2I CN_ANCHOR::m_pos
private

Position of the anchor.

Definition at line 139 of file connectivity_items.h.

Referenced by CN_ANCHOR(), and Pos().

◆ m_tag

int CN_ANCHOR::m_tag = -1
private

Tag for quick connection resolution.

Definition at line 145 of file connectivity_items.h.

Referenced by GetTag(), and SetTag().

◆ TAG_UNCONNECTED

const int CN_ANCHOR::TAG_UNCONNECTED = -1
static

Definition at line 135 of file connectivity_items.h.


The documentation for this class was generated from the following files: