KiCad PCB EDA Suite
Loading...
Searching...
No Matches
CONNECTIVITY_DATA Class Reference

#include <connectivity_data.h>

Public Member Functions

 CONNECTIVITY_DATA ()
 
 ~CONNECTIVITY_DATA ()
 
 CONNECTIVITY_DATA (std::shared_ptr< CONNECTIVITY_DATA > aGlobalConnectivity, const std::vector< BOARD_ITEM * > &aLocalItems, bool aSkipRatsnestUpdate=false)
 
bool Build (BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
 Function Build() Builds the connectivity database for the board aBoard. More...
 
void Build (std::shared_ptr< CONNECTIVITY_DATA > &aGlobalConnectivity, const std::vector< BOARD_ITEM * > &aLocalItems)
 Function Build() Builds the connectivity database for a set of items aItems. More...
 
bool Add (BOARD_ITEM *aItem)
 Function Add() Adds an item to the connectivity data. More...
 
bool Remove (BOARD_ITEM *aItem)
 Function Remove() Removes an item from the connectivity data. More...
 
bool Update (BOARD_ITEM *aItem)
 Function Update() Updates the connectivity data for an item. More...
 
void Move (const VECTOR2I &aDelta)
 Moves the connectivity list anchors. More...
 
void ClearRatsnest ()
 Function Clear() Erases the connectivity database. More...
 
int GetNetCount () const
 Function GetNetCount() Returns the total number of nets in the connectivity database. More...
 
RN_NETGetRatsnestForNet (int aNet)
 Function GetRatsnestForNet() Returns the ratsnest, expressed as a set of graph edges for a given net. More...
 
void PropagateNets (BOARD_COMMIT *aCommit=nullptr)
 Propagates the net codes from the source pads to the tracks/vias. More...
 
void FillIsolatedIslandsMap (std::map< ZONE *, std::map< PCB_LAYER_ID, ISOLATED_ISLANDS > > &aMap, bool aConnectivityAlreadyRebuilt=false)
 Fill the isolate islands list for each layer of each zone. More...
 
void RecalculateRatsnest (BOARD_COMMIT *aCommit=nullptr)
 Function RecalculateRatsnest() Updates the ratsnest for the board. More...
 
unsigned int GetUnconnectedCount (bool aVisibileOnly) const
 
bool IsConnectedOnLayer (const BOARD_CONNECTED_ITEM *aItem, int aLayer, const std::initializer_list< KICAD_T > &aTypes={}) const
 
unsigned int GetNodeCount (int aNet=-1) const
 
unsigned int GetPadCount (int aNet=-1) const
 
const std::vector< PCB_TRACK * > GetConnectedTracks (const BOARD_CONNECTED_ITEM *aItem) const
 
const std::vector< PAD * > GetConnectedPads (const BOARD_CONNECTED_ITEM *aItem) const
 
void GetConnectedPads (const BOARD_CONNECTED_ITEM *aItem, std::set< PAD * > *pads) const
 
void GetConnectedPadsAndVias (const BOARD_CONNECTED_ITEM *aItem, std::vector< PAD * > *pads, std::vector< PCB_VIA * > *vias)
 
const std::vector< BOARD_CONNECTED_ITEM * > GetConnectedItemsAtAnchor (const BOARD_CONNECTED_ITEM *aItem, const VECTOR2I &aAnchor, const std::initializer_list< KICAD_T > &aTypes, const int &aMaxError=0) const
 Function GetConnectedItemsAtAnchor() Returns a list of items connected to a source item aItem at position aAnchor with an optional maximum distance from the defined anchor. More...
 
void RunOnUnconnectedEdges (std::function< bool(CN_EDGE &)> aFunc)
 
bool TestTrackEndpointDangling (PCB_TRACK *aTrack, bool aIgnoreTracksInPads, VECTOR2I *aPos=nullptr) const
 
void ClearLocalRatsnest ()
 Function ClearLocalRatsnest() Erases the temporary, selection-based ratsnest (i.e. More...
 
void HideLocalRatsnest ()
 Hides the temporary, selection-based ratsnest lines. More...
 
void ComputeLocalRatsnest (const std::vector< BOARD_ITEM * > &aItems, const CONNECTIVITY_DATA *aDynamicData, VECTOR2I aInternalOffset={ 0, 0 })
 Function ComputeLocalRatsnest() Calculates the temporary (usually selection-based) ratsnest for the set of aItems. More...
 
const std::vector< RN_DYNAMIC_LINE > & GetLocalRatsnest () const
 
const std::vector< BOARD_CONNECTED_ITEM * > GetConnectedItems (const BOARD_CONNECTED_ITEM *aItem, const std::initializer_list< KICAD_T > &aTypes, bool aIgnoreNetcodes=false) const
 Function GetConnectedItems() Returns a list of items connected to a source item aItem. More...
 
const std::vector< BOARD_CONNECTED_ITEM * > GetNetItems (int aNetCode, const std::initializer_list< KICAD_T > &aTypes) const
 Function GetNetItems() Returns the list of items that belong to a certain net. More...
 
void BlockRatsnestItems (const std::vector< BOARD_ITEM * > &aItems)
 
std::shared_ptr< CN_CONNECTIVITY_ALGOGetConnectivityAlgo () const
 
KISPINLOCKGetLock ()
 
void MarkItemNetAsDirty (BOARD_ITEM *aItem)
 
void RemoveInvalidRefs ()
 
void SetProgressReporter (PROGRESS_REPORTER *aReporter)
 
const std::map< int, wxString > & GetNetclassMap () const
 
const std::vector< CN_EDGEGetRatsnestForItems (const std::vector< BOARD_ITEM * > &aItems)
 
const std::vector< CN_EDGEGetRatsnestForPad (const PAD *aPad)
 
const std::vector< CN_EDGEGetRatsnestForComponent (FOOTPRINT *aComponent, bool aSkipInternalConnections=false)
 
std::shared_ptr< FROM_TO_CACHEGetFromToCache ()
 

Private Member Functions

void internalRecalculateRatsnest (BOARD_COMMIT *aCommit=nullptr)
 Updates the ratsnest for the board without locking the connectivity mutex. More...
 
void updateRatsnest ()
 
void addRatsnestCluster (const std::shared_ptr< CN_CLUSTER > &aCluster)
 

Private Attributes

std::shared_ptr< CN_CONNECTIVITY_ALGOm_connAlgo
 
std::shared_ptr< FROM_TO_CACHEm_fromToCache
 
std::vector< RN_DYNAMIC_LINEm_dynamicRatsnest
 
std::vector< RN_NET * > m_nets
 
bool m_skipRatsnestUpdate
 Used to suppress ratsnest calculations on dynamic ratsnests. More...
 
KISPINLOCK m_lock
 
std::map< int, wxString > m_netclassMap
 Map of netcode -> netclass the net is a member of; used for ratsnest painting. More...
 
PROGRESS_REPORTERm_progressReporter
 

Detailed Description

Definition at line 86 of file connectivity_data.h.

Constructor & Destructor Documentation

◆ CONNECTIVITY_DATA() [1/2]

CONNECTIVITY_DATA::CONNECTIVITY_DATA ( )

Definition at line 47 of file connectivity_data.cpp.

References m_connAlgo, m_fromToCache, and m_progressReporter.

◆ ~CONNECTIVITY_DATA()

CONNECTIVITY_DATA::~CONNECTIVITY_DATA ( )

Definition at line 67 of file connectivity_data.cpp.

References m_nets.

◆ CONNECTIVITY_DATA() [2/2]

CONNECTIVITY_DATA::CONNECTIVITY_DATA ( std::shared_ptr< CONNECTIVITY_DATA aGlobalConnectivity,
const std::vector< BOARD_ITEM * > &  aLocalItems,
bool  aSkipRatsnestUpdate = false 
)

Definition at line 56 of file connectivity_data.cpp.

References Build(), m_fromToCache, and m_progressReporter.

Member Function Documentation

◆ Add()

bool CONNECTIVITY_DATA::Add ( BOARD_ITEM aItem)

Function Add() Adds an item to the connectivity data.

Parameters
aItemis an item to be added.
Returns
True if operation succeeded.

Definition at line 76 of file connectivity_data.cpp.

References m_connAlgo.

◆ addRatsnestCluster()

void CONNECTIVITY_DATA::addRatsnestCluster ( const std::shared_ptr< CN_CLUSTER > &  aCluster)
private

Definition at line 210 of file connectivity_data.cpp.

References RN_NET::AddCluster(), and m_nets.

Referenced by internalRecalculateRatsnest().

◆ BlockRatsnestItems()

void CONNECTIVITY_DATA::BlockRatsnestItems ( const std::vector< BOARD_ITEM * > &  aItems)

◆ Build() [1/2]

◆ Build() [2/2]

void CONNECTIVITY_DATA::Build ( std::shared_ptr< CONNECTIVITY_DATA > &  aGlobalConnectivity,
const std::vector< BOARD_ITEM * > &  aLocalItems 
)

Function Build() Builds the connectivity database for a set of items aItems.

Definition at line 146 of file connectivity_data.cpp.

References internalRecalculateRatsnest(), m_connAlgo, and m_lock.

◆ ClearLocalRatsnest()

void CONNECTIVITY_DATA::ClearLocalRatsnest ( )

Function ClearLocalRatsnest() Erases the temporary, selection-based ratsnest (i.e.

the ratsnest lines that pcbnew displays when moving an item/set of items).

Definition at line 403 of file connectivity_data.cpp.

References anchor, HideLocalRatsnest(), and m_connAlgo.

◆ ClearRatsnest()

void CONNECTIVITY_DATA::ClearRatsnest ( )

Function Clear() Erases the connectivity database.

Definition at line 528 of file connectivity_data.cpp.

References m_nets.

◆ ComputeLocalRatsnest()

void CONNECTIVITY_DATA::ComputeLocalRatsnest ( const std::vector< BOARD_ITEM * > &  aItems,
const CONNECTIVITY_DATA aDynamicData,
VECTOR2I  aInternalOffset = { 0, 0 } 
)

Function ComputeLocalRatsnest() Calculates the temporary (usually selection-based) ratsnest for the set of aItems.

We don't need to compute the dynamic ratsnest in two cases: 1) We are not moving any net elements 2) We are moving all net elements

Definition at line 331 of file connectivity_data.cpp.

References RN_DYNAMIC_LINE::a, RN_DYNAMIC_LINE::b, GetKiCadThreadPool(), RN_NET::GetNodeCount(), GetRatsnestForItems(), m_dynamicRatsnest, m_nets, RN_NET::NearestBicoloredPair(), RN_DYNAMIC_LINE::netCode, and tp.

◆ FillIsolatedIslandsMap()

void CONNECTIVITY_DATA::FillIsolatedIslandsMap ( std::map< ZONE *, std::map< PCB_LAYER_ID, ISOLATED_ISLANDS > > &  aMap,
bool  aConnectivityAlreadyRebuilt = false 
)

Fill the isolate islands list for each layer of each zone.

Isolated islands are individual polygons in a zone fill that don't connect to a net.

Definition at line 324 of file connectivity_data.cpp.

References m_connAlgo.

◆ GetConnectedItems()

const std::vector< BOARD_CONNECTED_ITEM * > CONNECTIVITY_DATA::GetConnectedItems ( const BOARD_CONNECTED_ITEM aItem,
const std::initializer_list< KICAD_T > &  aTypes,
bool  aIgnoreNetcodes = false 
) const

Function GetConnectedItems() Returns a list of items connected to a source item aItem.

Parameters
aItemis the reference item to find other connected items.
aTypesallows one to filter by item types.

Definition at line 536 of file connectivity_data.cpp.

References CN_CONNECTIVITY_ALGO::CSM_CONNECTIVITY_CHECK, CN_CONNECTIVITY_ALGO::CSM_PROPAGATE, BOARD_CONNECTED_ITEM::GetNetCode(), and m_connAlgo.

◆ GetConnectedItemsAtAnchor()

const std::vector< BOARD_CONNECTED_ITEM * > CONNECTIVITY_DATA::GetConnectedItemsAtAnchor ( const BOARD_CONNECTED_ITEM aItem,
const VECTOR2I aAnchor,
const std::initializer_list< KICAD_T > &  aTypes,
const int &  aMaxError = 0 
) const

Function GetConnectedItemsAtAnchor() Returns a list of items connected to a source item aItem at position aAnchor with an optional maximum distance from the defined anchor.

Parameters
aItemis the reference item to find other connected items.
aAnchoris the position to find connected items on.
aTypesallows one to filter by item types.
aMaxErrorMaximum distance of the found items' anchors to aAnchor in IU
Returns

Definition at line 881 of file connectivity_data.cpp.

References anchor, CN_ITEM::ConnectedItems(), CN_CONNECTIVITY_ALGO::ITEM_MAP_ENTRY::GetItems(), and m_connAlgo.

◆ GetConnectedPads() [1/2]

const std::vector< PAD * > CONNECTIVITY_DATA::GetConnectedPads ( const BOARD_CONNECTED_ITEM aItem) const

Definition at line 635 of file connectivity_data.cpp.

References GetConnectedPads().

Referenced by GetConnectedPads().

◆ GetConnectedPads() [2/2]

void CONNECTIVITY_DATA::GetConnectedPads ( const BOARD_CONNECTED_ITEM aItem,
std::set< PAD * > *  pads 
) const

Definition at line 621 of file connectivity_data.cpp.

References CN_ITEM::ConnectedItems(), m_connAlgo, and PCB_PAD_T.

◆ GetConnectedPadsAndVias()

void CONNECTIVITY_DATA::GetConnectedPadsAndVias ( const BOARD_CONNECTED_ITEM aItem,
std::vector< PAD * > *  pads,
std::vector< PCB_VIA * > *  vias 
)

◆ GetConnectedTracks()

const std::vector< PCB_TRACK * > CONNECTIVITY_DATA::GetConnectedTracks ( const BOARD_CONNECTED_ITEM aItem) const

◆ GetConnectivityAlgo()

std::shared_ptr< CN_CONNECTIVITY_ALGO > CONNECTIVITY_DATA::GetConnectivityAlgo ( ) const
inline

Definition at line 266 of file connectivity_data.h.

References m_connAlgo.

Referenced by TestTrackEndpointDangling().

◆ GetFromToCache()

std::shared_ptr< FROM_TO_CACHE > CONNECTIVITY_DATA::GetFromToCache ( )
inline

Definition at line 286 of file connectivity_data.h.

References m_fromToCache.

◆ GetLocalRatsnest()

const std::vector< RN_DYNAMIC_LINE > & CONNECTIVITY_DATA::GetLocalRatsnest ( ) const
inline

Definition at line 242 of file connectivity_data.h.

References m_dynamicRatsnest.

◆ GetLock()

KISPINLOCK & CONNECTIVITY_DATA::GetLock ( )
inline

Definition at line 268 of file connectivity_data.h.

References m_lock.

◆ GetNetclassMap()

const std::map< int, wxString > & CONNECTIVITY_DATA::GetNetclassMap ( ) const
inline

Definition at line 275 of file connectivity_data.h.

References m_netclassMap.

◆ GetNetCount()

int CONNECTIVITY_DATA::GetNetCount ( ) const

Function GetNetCount() Returns the total number of nets in the connectivity database.

Definition at line 318 of file connectivity_data.cpp.

References m_connAlgo.

◆ GetNetItems()

const std::vector< BOARD_CONNECTED_ITEM * > CONNECTIVITY_DATA::GetNetItems ( int  aNetCode,
const std::initializer_list< KICAD_T > &  aTypes 
) const

Function GetNetItems() Returns the list of items that belong to a certain net.

Parameters
aNetCodeis the net code.
aTypesallows one to filter by item types.

Definition at line 568 of file connectivity_data.cpp.

References m_connAlgo, MAX_STRUCT_TYPE_ID, CN_ITEM::Net(), CN_ITEM::Parent(), EDA_ITEM::Type(), and CN_ITEM::Valid().

◆ GetNodeCount()

unsigned int CONNECTIVITY_DATA::GetNodeCount ( int  aNet = -1) const

Definition at line 670 of file connectivity_data.cpp.

References m_nets.

◆ GetPadCount()

unsigned int CONNECTIVITY_DATA::GetPadCount ( int  aNet = -1) const

Definition at line 688 of file connectivity_data.cpp.

References m_connAlgo, pad, and PCB_PAD_T.

◆ GetRatsnestForComponent()

const std::vector< CN_EDGE > CONNECTIVITY_DATA::GetRatsnestForComponent ( FOOTPRINT aComponent,
bool  aSkipInternalConnections = false 
)

◆ GetRatsnestForItems()

const std::vector< CN_EDGE > CONNECTIVITY_DATA::GetRatsnestForItems ( const std::vector< BOARD_ITEM * > &  aItems)

◆ GetRatsnestForNet()

RN_NET * CONNECTIVITY_DATA::GetRatsnestForNet ( int  aNet)

Function GetRatsnestForNet() Returns the ratsnest, expressed as a set of graph edges for a given net.

Definition at line 917 of file connectivity_data.cpp.

References m_nets.

Referenced by GetRatsnestForComponent(), GetRatsnestForItems(), and GetRatsnestForPad().

◆ GetRatsnestForPad()

const std::vector< CN_EDGE > CONNECTIVITY_DATA::GetRatsnestForPad ( const PAD aPad)

◆ GetUnconnectedCount()

unsigned int CONNECTIVITY_DATA::GetUnconnectedCount ( bool  aVisibileOnly) const
Parameters
aVisibleOnlyinclude only visbile edges in the count
Returns
the number of remaining edges in the ratsnest

Definition at line 508 of file connectivity_data.cpp.

References m_nets.

◆ HideLocalRatsnest()

void CONNECTIVITY_DATA::HideLocalRatsnest ( )

Hides the temporary, selection-based ratsnest lines.

Definition at line 413 of file connectivity_data.cpp.

References m_dynamicRatsnest.

Referenced by ClearLocalRatsnest().

◆ internalRecalculateRatsnest()

void CONNECTIVITY_DATA::internalRecalculateRatsnest ( BOARD_COMMIT aCommit = nullptr)
private

Updates the ratsnest for the board without locking the connectivity mutex.

Parameters
aCommitis used to save the undo state of items modified by this call

Definition at line 229 of file connectivity_data.cpp.

References addRatsnestCluster(), m_connAlgo, m_nets, m_skipRatsnestUpdate, and updateRatsnest().

Referenced by Build(), and RecalculateRatsnest().

◆ IsConnectedOnLayer()

◆ MarkItemNetAsDirty()

void CONNECTIVITY_DATA::MarkItemNetAsDirty ( BOARD_ITEM aItem)

◆ Move()

void CONNECTIVITY_DATA::Move ( const VECTOR2I aDelta)

Moves the connectivity list anchors.

N.B., this does not move the bounding boxes for the RTree, so the use of this function will invalidate the connectivity data for uses other than the dynamic ratsnest

Parameters
aDeltavector for movement of the tree

Definition at line 161 of file connectivity_data.cpp.

References anchor, and m_connAlgo.

Referenced by BOARD_INSPECTION_TOOL::calculateSelectionRatsnest().

◆ PropagateNets()

void CONNECTIVITY_DATA::PropagateNets ( BOARD_COMMIT aCommit = nullptr)

Propagates the net codes from the source pads to the tracks/vias.

Parameters
aCommitis used to save the undo state of items modified by this call
aModecontrols how conflicts between pads are resolved

Definition at line 419 of file connectivity_data.cpp.

References m_connAlgo.

◆ RecalculateRatsnest()

void CONNECTIVITY_DATA::RecalculateRatsnest ( BOARD_COMMIT aCommit = nullptr)

Function RecalculateRatsnest() Updates the ratsnest for the board.

Parameters
aCommitis used to save the undo state of items modified by this call

Definition at line 218 of file connectivity_data.cpp.

References internalRecalculateRatsnest(), and m_lock.

◆ Remove()

bool CONNECTIVITY_DATA::Remove ( BOARD_ITEM aItem)

Function Remove() Removes an item from the connectivity data.

Parameters
aItemis an item to be updated.
Returns
True if operation succeeded.

Definition at line 83 of file connectivity_data.cpp.

References m_connAlgo.

◆ RemoveInvalidRefs()

void CONNECTIVITY_DATA::RemoveInvalidRefs ( )

Definition at line 939 of file connectivity_data.cpp.

References m_connAlgo, and m_nets.

Referenced by CN_CONNECTIVITY_ALGO::searchConnections().

◆ RunOnUnconnectedEdges()

void CONNECTIVITY_DATA::RunOnUnconnectedEdges ( std::function< bool(CN_EDGE &)>  aFunc)

Definition at line 707 of file connectivity_data.cpp.

References m_nets.

◆ SetProgressReporter()

void CONNECTIVITY_DATA::SetProgressReporter ( PROGRESS_REPORTER aReporter)

Definition at line 948 of file connectivity_data.cpp.

References m_connAlgo, and m_progressReporter.

◆ TestTrackEndpointDangling()

◆ Update()

bool CONNECTIVITY_DATA::Update ( BOARD_ITEM aItem)

Function Update() Updates the connectivity data for an item.

Parameters
aItemis an item to be updated.
Returns
True if operation succeeded.

Definition at line 90 of file connectivity_data.cpp.

References m_connAlgo.

◆ updateRatsnest()

void CONNECTIVITY_DATA::updateRatsnest ( )
private

Definition at line 170 of file connectivity_data.cpp.

References GetKiCadThreadPool(), m_nets, PROF_TIMER::Show(), and tp.

Referenced by internalRecalculateRatsnest().

Member Data Documentation

◆ m_connAlgo

◆ m_dynamicRatsnest

std::vector<RN_DYNAMIC_LINE> CONNECTIVITY_DATA::m_dynamicRatsnest
private

Definition at line 303 of file connectivity_data.h.

Referenced by ComputeLocalRatsnest(), GetLocalRatsnest(), and HideLocalRatsnest().

◆ m_fromToCache

std::shared_ptr<FROM_TO_CACHE> CONNECTIVITY_DATA::m_fromToCache
private

Definition at line 302 of file connectivity_data.h.

Referenced by CONNECTIVITY_DATA(), and GetFromToCache().

◆ m_lock

KISPINLOCK CONNECTIVITY_DATA::m_lock
private

Definition at line 309 of file connectivity_data.h.

Referenced by Build(), GetLock(), and RecalculateRatsnest().

◆ m_netclassMap

std::map<int, wxString> CONNECTIVITY_DATA::m_netclassMap
private

Map of netcode -> netclass the net is a member of; used for ratsnest painting.

Definition at line 312 of file connectivity_data.h.

Referenced by Build(), and GetNetclassMap().

◆ m_nets

◆ m_progressReporter

PROGRESS_REPORTER* CONNECTIVITY_DATA::m_progressReporter
private

Definition at line 314 of file connectivity_data.h.

Referenced by CONNECTIVITY_DATA(), and SetProgressReporter().

◆ m_skipRatsnestUpdate

bool CONNECTIVITY_DATA::m_skipRatsnestUpdate
private

Used to suppress ratsnest calculations on dynamic ratsnests.

Definition at line 307 of file connectivity_data.h.

Referenced by internalRecalculateRatsnest().


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