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 LSET::AllCuMask(), BOARD_ITEM::GetLayerSet(), BOARD_ITEM::HitTest(), ZONE_CONTAINER::HitTestInsideZone(), CN_ITEM::Parent(), PCB_VIA_T, PCB_ZONE_AREA_T, and EDA_ITEM::Type().

Referenced by GetCluster().

252 {
253  if( !m_cluster )
254  return true;
255 
256  // Calculate the item count connected to this anchor.
257  // m_cluster groups all items connected, but they are not necessary connected
258  // at this coordinate point (they are only candidates)
259  BOARD_CONNECTED_ITEM* item_ref = Parent();
260  LSET layers = item_ref->GetLayerSet() & LSET::AllCuMask();
261 
262  // the number of items connected to item_ref at ths anchor point
263  int connected_items_count = 0;
264 
265  // the minimal number of items connected to item_ref
266  // at this anchor point to decide the anchor is *not* dangling
267  int minimal_count = 1;
268 
269  // a via can be removed if connected to only one other item.
270  // the minimal_count is therefore 2
271  if( item_ref->Type() == PCB_VIA_T )
272  minimal_count = 2;
273 
274  for( CN_ITEM* item : *m_cluster )
275  {
276  if( !item->Valid() )
277  continue;
278 
279  BOARD_CONNECTED_ITEM* brd_item = item->Parent();
280 
281  if( brd_item == item_ref )
282  continue;
283 
284  // count only items on the same layer at this coordinate (especially for zones)
285  if( !( brd_item->GetLayerSet() & layers ).any() )
286  continue;
287 
288  if( brd_item->Type() == PCB_ZONE_AREA_T )
289  {
290  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( brd_item );
291 
292  if( zone->HitTestInsideZone( wxPoint( Pos() ) ) )
293  connected_items_count++;
294  }
295  else if( brd_item->HitTest( wxPoint( Pos() ) ) )
296  connected_items_count++;
297  }
298 
299  return connected_items_count < minimal_count;
300 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:673
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
Class 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
BOARD_CONNECTED_ITEM * Parent() const
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
Class LSET is a set of PCB_LAYER_IDs.
bool HitTestInsideZone(const wxPoint &aPosition) const
Function HitTest tests if a point is inside the zone area, i.e.
Definition: class_zone.h:262
virtual LSET GetLayerSet() const
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
virtual bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
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: