KiCad PCB EDA Suite
CN_LIST Class Reference

#include <connectivity_items.h>

Public Types

using ITER = decltype(m_items)::iterator
 
using CONST_ITER = decltype(m_items)::const_iterator
 

Public Member Functions

 CN_LIST ()
 
void Clear ()
 
ITER begin ()
 
ITER end ()
 
CONST_ITER begin () const
 
CONST_ITER end () const
 
CN_ITEMoperator[] (int aIndex)
 
template<class T >
void FindNearby (CN_ITEM *aItem, T aFunc)
 
void SetHasInvalid (bool aInvalid=true)
 
void SetDirty (bool aDirty=true)
 
bool IsDirty () const
 
void RemoveInvalidItems (std::vector< CN_ITEM * > &aGarbage)
 
void ClearDirtyFlags ()
 
void MarkAllAsDirty ()
 
int Size () const
 
CN_ITEMAdd (D_PAD *pad)
 
CN_ITEMAdd (TRACK *track)
 
CN_ITEMAdd (ARC *track)
 
CN_ITEMAdd (VIA *via)
 
const std::vector< CN_ITEM * > Add (ZONE_CONTAINER *zone, PCB_LAYER_ID aLayer)
 

Protected Member Functions

void addItemtoTree (CN_ITEM *item)
 

Protected Attributes

std::vector< CN_ITEM * > m_items
 

Private Attributes

bool m_dirty
 
bool m_hasInvalid
 
CN_RTREE< CN_ITEM * > m_index
 

Detailed Description

Definition at line 403 of file connectivity_items.h.

Member Typedef Documentation

◆ CONST_ITER

using CN_LIST::CONST_ITER = decltype( m_items )::const_iterator

Definition at line 436 of file connectivity_items.h.

◆ ITER

using CN_LIST::ITER = decltype( m_items )::iterator

Definition at line 435 of file connectivity_items.h.

Constructor & Destructor Documentation

◆ CN_LIST()

CN_LIST::CN_LIST ( )
inline

Definition at line 420 of file connectivity_items.h.

421  {
422  m_dirty = false;
423  m_hasInvalid = false;
424  }

References m_dirty, and m_hasInvalid.

Member Function Documentation

◆ Add() [1/5]

CN_ITEM * CN_LIST::Add ( D_PAD pad)

Definition at line 195 of file connectivity_items.cpp.

196  {
197  if( !pad->IsOnCopperLayer() )
198  return nullptr;
199 
200  auto item = new CN_ITEM( pad, false, 1 );
201  item->AddAnchor( pad->ShapePos() );
202  item->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
203 
204  switch( pad->GetAttribute() )
205  {
206  case PAD_ATTRIB_SMD:
208  case PAD_ATTRIB_CONN:
209  {
210  LSET lmsk = pad->GetLayerSet();
211 
212  for( int i = 0; i <= MAX_CU_LAYERS; i++ )
213  {
214  if( lmsk[i] )
215  {
216  item->SetLayer( i );
217  break;
218  }
219  }
220  break;
221  }
222  default:
223  break;
224  }
225 
226  addItemtoTree( item );
227  m_items.push_back( item );
228  SetDirty();
229  return item;
230 }
std::vector< CN_ITEM * > m_items
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
void addItemtoTree(CN_ITEM *item)
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:81
void SetDirty(bool aDirty=true)
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:328
LSET is a set of PCB_LAYER_IDs.
bool IsOnCopperLayer() const override
Definition: class_pad.h:206
LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_pad.h:325
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:82
wxPoint ShapePos() const
Definition: class_pad.cpp:491
LAYER_RANGE.
Definition: pns_layerset.h:32

References addItemtoTree(), B_Cu, F_Cu, D_PAD::GetAttribute(), D_PAD::GetLayerSet(), D_PAD::IsOnCopperLayer(), m_items, MAX_CU_LAYERS, PAD_ATTRIB_CONN, PAD_ATTRIB_HOLE_NOT_PLATED, PAD_ATTRIB_SMD, SetDirty(), and D_PAD::ShapePos().

Referenced by CN_CONNECTIVITY_ALGO::Add().

◆ Add() [2/5]

CN_ITEM * CN_LIST::Add ( TRACK track)

Definition at line 232 of file connectivity_items.cpp.

233 {
234  auto item = new CN_ITEM( track, true );
235  m_items.push_back( item );
236  item->AddAnchor( track->GetStart() );
237  item->AddAnchor( track->GetEnd() );
238  item->SetLayer( track->GetLayer() );
239  addItemtoTree( item );
240  SetDirty();
241  return item;
242 }
std::vector< CN_ITEM * > m_items
const wxPoint & GetStart() const
Definition: class_track.h:118
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)
const wxPoint & GetEnd() const
Definition: class_track.h:115
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.

References addItemtoTree(), TRACK::GetEnd(), BOARD_ITEM::GetLayer(), TRACK::GetStart(), m_items, and SetDirty().

◆ Add() [3/5]

CN_ITEM * CN_LIST::Add ( ARC track)

Definition at line 244 of file connectivity_items.cpp.

245 {
246  auto item = new CN_ITEM( aArc, true );
247  m_items.push_back( item );
248  item->AddAnchor( aArc->GetStart() );
249  item->AddAnchor( aArc->GetEnd() );
250  item->SetLayer( aArc->GetLayer() );
251  addItemtoTree( item );
252  SetDirty();
253  return item;
254 }
std::vector< CN_ITEM * > m_items
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)

References addItemtoTree(), TRACK::GetEnd(), BOARD_ITEM::GetLayer(), TRACK::GetStart(), m_items, and SetDirty().

◆ Add() [4/5]

CN_ITEM * CN_LIST::Add ( VIA via)

Definition at line 256 of file connectivity_items.cpp.

257  {
258  auto item = new CN_ITEM( via, true, 1 );
259 
260  m_items.push_back( item );
261  item->AddAnchor( via->GetStart() );
262  item->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
263  addItemtoTree( item );
264  SetDirty();
265  return item;
266  }
std::vector< CN_ITEM * > m_items
const wxPoint & GetStart() const
Definition: class_track.h:118
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)
LAYER_RANGE.
Definition: pns_layerset.h:32

References addItemtoTree(), B_Cu, F_Cu, TRACK::GetStart(), m_items, and SetDirty().

◆ Add() [5/5]

const std::vector< CN_ITEM * > CN_LIST::Add ( ZONE_CONTAINER zone,
PCB_LAYER_ID  aLayer 
)

Definition at line 268 of file connectivity_items.cpp.

269  {
270  const auto& polys = zone->GetFilledPolysList( aLayer );
271 
272  std::vector<CN_ITEM*> rv;
273 
274  for( int j = 0; j < polys.OutlineCount(); j++ )
275  {
276  CN_ZONE* zitem = new CN_ZONE( zone, aLayer, false, j );
277  const auto& outline = zone->GetFilledPolysList( aLayer ).COutline( j );
278 
279  for( int k = 0; k < outline.PointCount(); k++ )
280  zitem->AddAnchor( outline.CPoint( k ) );
281 
282  m_items.push_back( zitem );
283  zitem->SetLayer( aLayer );
284  addItemtoTree( zitem );
285  rv.push_back( zitem );
286  SetDirty();
287  }
288 
289  return rv;
290  }
std::vector< CN_ITEM * > m_items
void addItemtoTree(CN_ITEM *item)
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:602
void SetDirty(bool aDirty=true)
void AddAnchor(const VECTOR2I &aPos)
void SetLayer(int aLayer)
Function SetLayer()
const SHAPE_LINE_CHAIN & COutline(int aIndex) const

References CN_ITEM::AddAnchor(), addItemtoTree(), SHAPE_POLY_SET::COutline(), ZONE_CONTAINER::GetFilledPolysList(), m_items, SetDirty(), and CN_ITEM::SetLayer().

◆ addItemtoTree()

void CN_LIST::addItemtoTree ( CN_ITEM item)
inlineprotected

Definition at line 414 of file connectivity_items.h.

415  {
416  m_index.Insert( item );
417  }
void Insert(T aItem)
Function Insert() Inserts an item into the tree.
CN_RTREE< CN_ITEM * > m_index

References CN_RTREE< T >::Insert(), and m_index.

Referenced by Add().

◆ begin() [1/2]

ITER CN_LIST::begin ( )
inline

Definition at line 438 of file connectivity_items.h.

438 { return m_items.begin(); };
std::vector< CN_ITEM * > m_items

References m_items.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters(), and CN_CONNECTIVITY_ALGO::searchConnections().

◆ begin() [2/2]

CONST_ITER CN_LIST::begin ( ) const
inline

Definition at line 441 of file connectivity_items.h.

442  {
443  return m_items.begin();
444  }
std::vector< CN_ITEM * > m_items

References m_items.

◆ Clear()

void CN_LIST::Clear ( )
inline

Definition at line 426 of file connectivity_items.h.

427  {
428  for( auto item : m_items )
429  delete item;
430 
431  m_items.clear();
432  m_index.RemoveAll();
433  }
std::vector< CN_ITEM * > m_items
void RemoveAll()
Function RemoveAll() Removes all items from the RTree.
CN_RTREE< CN_ITEM * > m_index

References m_index, m_items, and CN_RTREE< T >::RemoveAll().

Referenced by CN_CONNECTIVITY_ALGO::Clear().

◆ ClearDirtyFlags()

void CN_LIST::ClearDirtyFlags ( )
inline

Definition at line 476 of file connectivity_items.h.

477  {
478  for( auto item : m_items )
479  item->SetDirty( false );
480 
481  SetDirty( false );
482  }
std::vector< CN_ITEM * > m_items
void SetDirty(bool aDirty=true)

References m_items, and SetDirty().

Referenced by CN_CONNECTIVITY_ALGO::searchConnections().

◆ end() [1/2]

ITER CN_LIST::end ( )
inline

Definition at line 439 of file connectivity_items.h.

439 { return m_items.end(); };
std::vector< CN_ITEM * > m_items

References m_items.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters(), and CN_CONNECTIVITY_ALGO::searchConnections().

◆ end() [2/2]

CONST_ITER CN_LIST::end ( ) const
inline

Definition at line 446 of file connectivity_items.h.

447  {
448  return m_items.end();
449  }
std::vector< CN_ITEM * > m_items

References m_items.

◆ FindNearby()

template<class T >
void CN_LIST::FindNearby ( CN_ITEM aItem,
aFunc 
)
inline

Definition at line 454 of file connectivity_items.h.

455  {
456  m_index.Query( aItem->BBox(), aItem->Layers(), aFunc );
457  }
void Query(const BOX2I &aBounds, const LAYER_RANGE &aRange, Visitor &aVisitor)
Function Query() Executes a function object aVisitor for each item whose bounding box intersects with...
const LAYER_RANGE & Layers() const
Function Layers()
const BOX2I & BBox()
CN_RTREE< CN_ITEM * > m_index

References CN_ITEM::BBox(), CN_ITEM::Layers(), m_index, and CN_RTREE< T >::Query().

◆ IsDirty()

bool CN_LIST::IsDirty ( ) const
inline

Definition at line 469 of file connectivity_items.h.

470  {
471  return m_dirty;
472  }

References m_dirty.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters(), and CN_CONNECTIVITY_ALGO::searchConnections().

◆ MarkAllAsDirty()

void CN_LIST::MarkAllAsDirty ( )
inline

Definition at line 484 of file connectivity_items.h.

485  {
486  for( auto item : m_items )
487  item->SetDirty( true );
488 
489  SetDirty( true );
490  }
std::vector< CN_ITEM * > m_items
void SetDirty(bool aDirty=true)

References m_items, and SetDirty().

◆ operator[]()

CN_ITEM* CN_LIST::operator[] ( int  aIndex)
inline

Definition at line 451 of file connectivity_items.h.

451 { return m_items[aIndex]; }
std::vector< CN_ITEM * > m_items

References m_items.

◆ RemoveInvalidItems()

void CN_LIST::RemoveInvalidItems ( std::vector< CN_ITEM * > &  aGarbage)

Definition at line 293 of file connectivity_items.cpp.

294 {
295  if( !m_hasInvalid )
296  return;
297 
298  auto lastItem = std::remove_if(m_items.begin(), m_items.end(), [&aGarbage] ( CN_ITEM* item )
299  {
300  if( !item->Valid() )
301  {
302  aGarbage.push_back ( item );
303  return true;
304  }
305 
306  return false;
307  } );
308 
309  m_items.resize( lastItem - m_items.begin() );
310 
311  for( auto item : m_items )
312  item->RemoveInvalidRefs();
313 
314  for( auto item : aGarbage )
315  m_index.Remove( item );
316 
317  m_hasInvalid = false;
318 }
std::vector< CN_ITEM * > m_items
void Remove(T aItem)
Function Remove() Removes an item from the tree.
CN_RTREE< CN_ITEM * > m_index

References m_hasInvalid, m_index, m_items, and CN_RTREE< T >::Remove().

Referenced by CN_CONNECTIVITY_ALGO::searchConnections().

◆ SetDirty()

void CN_LIST::SetDirty ( bool  aDirty = true)
inline

Definition at line 464 of file connectivity_items.h.

465  {
466  m_dirty = aDirty;
467  }

References m_dirty.

Referenced by Add(), ClearDirtyFlags(), MarkAllAsDirty(), and CN_CONNECTIVITY_ALGO::Remove().

◆ SetHasInvalid()

void CN_LIST::SetHasInvalid ( bool  aInvalid = true)
inline

Definition at line 459 of file connectivity_items.h.

460  {
461  m_hasInvalid = aInvalid;
462  }

References m_hasInvalid.

Referenced by CN_CONNECTIVITY_ALGO::Remove().

◆ Size()

int CN_LIST::Size ( ) const
inline

Definition at line 492 of file connectivity_items.h.

493  {
494  return m_items.size();
495  }
std::vector< CN_ITEM * > m_items

References m_items.

Member Data Documentation

◆ m_dirty

bool CN_LIST::m_dirty
private

Definition at line 406 of file connectivity_items.h.

Referenced by CN_LIST(), IsDirty(), and SetDirty().

◆ m_hasInvalid

bool CN_LIST::m_hasInvalid
private

Definition at line 407 of file connectivity_items.h.

Referenced by CN_LIST(), RemoveInvalidItems(), and SetHasInvalid().

◆ m_index

CN_RTREE<CN_ITEM*> CN_LIST::m_index
private

Definition at line 409 of file connectivity_items.h.

Referenced by addItemtoTree(), Clear(), FindNearby(), and RemoveInvalidItems().

◆ m_items

std::vector<CN_ITEM*> CN_LIST::m_items
protected

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