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)
 
std::shared_ptr< CN_CLUSTERGetCluster () const
 
bool IsDangling () 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 53 of file connectivity_items.h.

Constructor & Destructor Documentation

CN_ANCHOR::CN_ANCHOR ( )
inline

Definition at line 56 of file connectivity_items.h.

References m_item.

57  {
58  m_item = nullptr;
59  }
CN_ITEM * m_item
Item owning the anchor.
CN_ANCHOR::CN_ANCHOR ( const VECTOR2I aPos,
CN_ITEM aItem 
)
inline

Definition at line 61 of file connectivity_items.h.

References m_item, m_pos, and Valid().

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

Member Function Documentation

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

Definition at line 112 of file connectivity_items.h.

References IsDangling(), and m_cluster.

113  {
114  return m_cluster;
115  }
std::shared_ptr< CN_CLUSTER > m_cluster
Cluster to which the anchor belongs.
const bool& CN_ANCHOR::GetNoLine ( ) const
inline

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

Definition at line 102 of file connectivity_items.h.

References m_noline.

103  {
104  return m_noline;
105  }
bool m_noline
Whether it the node can be a target for ratsnest lines.
int CN_ANCHOR::GetTag ( ) const
inline

Returns tag, common identifier for connected nodes.

Definition at line 84 of file connectivity_items.h.

References m_tag.

85  {
86  return m_tag;
87  }
int m_tag
Tag for quick connection resolution.
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 251 of file connectivity_items.cpp.

References CN_ITEM::Parent(), and PCB_VIA_T.

Referenced by GetCluster().

252 {
253  if( !m_cluster )
254  return true;
255 
256  // the minimal number of items connected to item_ref
257  // at this anchor point to decide the anchor is *not* dangling
258  size_t minimal_count = 1;
259  size_t connected_count = m_item->ConnectedItems().size();
260 
261  // a via can be removed if connected to only one other item.
262  if( Parent()->Type() == PCB_VIA_T )
263  return connected_count < 2;
264 
265  if( m_item->AnchorCount() == 1 )
266  return connected_count < minimal_count;
267 
268  // Only items with multiple anchors might have additional items connected that we
269  // should ignore for this calculation.
270  for( auto item : m_item->ConnectedItems() )
271  {
272  if( !item->Parent()->HitTest( wxPoint( Pos().x, Pos().y ) ) )
273  connected_count--;
274  }
275 
276  return connected_count < minimal_count;
277 }
std::shared_ptr< CN_CLUSTER > m_cluster
Cluster to which the anchor belongs.
BOARD_CONNECTED_ITEM * Parent() const
const CONNECTED_ITEMS & ConnectedItems() const
CN_ITEM * m_item
Item owning the anchor.
virtual int AnchorCount() const
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
const VECTOR2I & Pos() const
CN_ITEM* CN_ANCHOR::Item ( ) const
inline

Definition at line 71 of file connectivity_items.h.

References m_item, and Parent().

72  {
73  return m_item;
74  }
CN_ITEM * m_item
Item owning the anchor.
BOARD_CONNECTED_ITEM * CN_ANCHOR::Parent ( ) const

Definition at line 235 of file connectivity_items.cpp.

Referenced by CN_ZONE::ContainsPoint(), and Item().

236 {
237  assert( m_item->Valid() );
238  return m_item->Parent();
239 }
bool Valid() const
BOARD_CONNECTED_ITEM * Parent() const
CN_ITEM * m_item
Item owning the anchor.
const VECTOR2I& CN_ANCHOR::Pos ( ) const
inline

Definition at line 78 of file connectivity_items.h.

References m_pos.

79  {
80  return m_pos;
81  }
VECTOR2I m_pos
Position of the anchor.
void CN_ANCHOR::SetCluster ( std::shared_ptr< CN_CLUSTER aCluster)
inline

Definition at line 107 of file connectivity_items.h.

References m_cluster.

108  {
109  m_cluster = aCluster;
110  }
std::shared_ptr< CN_CLUSTER > m_cluster
Cluster to which the anchor belongs.
void CN_ANCHOR::SetNoLine ( bool  aEnable)
inline

Decides whether this node can be a ratsnest line target.

Definition at line 96 of file connectivity_items.h.

References m_noline.

Referenced by CONNECTIVITY_DATA::ClearDynamicRatsnest().

97  {
98  m_noline = aEnable;
99  }
bool m_noline
Whether it the node can be a target for ratsnest lines.
void CN_ANCHOR::SetTag ( int  aTag)
inline

Sets tag, common identifier for connected nodes.

Definition at line 90 of file connectivity_items.h.

References m_tag.

91  {
92  m_tag = aTag;
93  }
int m_tag
Tag for quick connection resolution.
bool CN_ANCHOR::Valid ( ) const

Definition at line 242 of file connectivity_items.cpp.

Referenced by CN_ANCHOR().

243 {
244  if( !m_item )
245  return false;
246 
247  return m_item->Valid();
248 }
bool Valid() const
CN_ITEM * m_item
Item owning the anchor.

Member Data Documentation

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

Cluster to which the anchor belongs.

Definition at line 144 of file connectivity_items.h.

Referenced by GetCluster(), and SetCluster().

CN_ITEM* CN_ANCHOR::m_item = nullptr
private

Item owning the anchor.

Definition at line 135 of file connectivity_items.h.

Referenced by CN_ANCHOR(), and Item().

bool CN_ANCHOR::m_noline = false
private

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

Definition at line 141 of file connectivity_items.h.

Referenced by GetNoLine(), and SetNoLine().

VECTOR2I CN_ANCHOR::m_pos
private

Position of the anchor.

Definition at line 132 of file connectivity_items.h.

Referenced by CN_ANCHOR(), and Pos().

int CN_ANCHOR::m_tag = -1
private

Tag for quick connection resolution.

Definition at line 138 of file connectivity_items.h.

Referenced by GetTag(), and SetTag().

const int CN_ANCHOR::TAG_UNCONNECTED = -1
static

Definition at line 128 of file connectivity_items.h.


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