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.
 
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.
 
bool Add (BOARD_ITEM *aItem)
 Function Add() Adds an item to the connectivity data.
 
bool Remove (BOARD_ITEM *aItem)
 Function Remove() Removes an item from the connectivity data.
 
bool Update (BOARD_ITEM *aItem)
 Function Update() Updates the connectivity data for an item.
 
void Move (const VECTOR2I &aDelta)
 Moves the connectivity list anchors.
 
void ClearRatsnest ()
 Function Clear() Erases the connectivity database.
 
int GetNetCount () const
 Function GetNetCount() Returns the total number of nets in the connectivity database.
 
RN_NETGetRatsnestForNet (int aNet)
 Function GetRatsnestForNet() Returns the ratsnest, expressed as a set of graph edges for a given net.
 
void PropagateNets (BOARD_COMMIT *aCommit=nullptr)
 Propagates the net codes from the source pads to the tracks/vias.
 
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.
 
void RecalculateRatsnest (BOARD_COMMIT *aCommit=nullptr)
 Function RecalculateRatsnest() Updates the ratsnest for the board.
 
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::vector< 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.
 
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.
 
void HideLocalRatsnest ()
 Hides the temporary, selection-based ratsnest lines.
 
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.
 
const std::vector< RN_DYNAMIC_LINE > & GetLocalRatsnest () const
 
const std::vector< BOARD_CONNECTED_ITEM * > GetConnectedItems (const BOARD_CONNECTED_ITEM *aItem, const std::vector< KICAD_T > &aTypes, bool aIgnoreNetcodes=false) const
 Function GetConnectedItems() Returns a list of items connected to a source item aItem.
 
const std::vector< BOARD_CONNECTED_ITEM * > GetNetItems (int aNetCode, const std::vector< KICAD_T > &aTypes) const
 Function GetNetItems() Returns the list of items that belong to a certain net.
 
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 NET_SETTINGSGetNetSettings () const
 
bool HasNetNameForNetCode (int nc) const
 
const wxString & GetNetNameForNetCode (int nc) const
 
void RefreshNetcodeMap (BOARD *aBoard)
 Refresh the map of netcodes to net names.
 
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.
 
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.
 
KISPINLOCK m_lock
 
PROGRESS_REPORTERm_progressReporter
 
std::weak_ptr< NET_SETTINGSm_netSettings
 Used to get netclass data when drawing ratsnests.
 
std::map< int, wxString > m_netcodeMap
 Used to map netcode to net name.
 

Detailed Description

Definition at line 87 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 217 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 153 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 407 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 542 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 335 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 328 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::vector< 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 550 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::vector< 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 895 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 649 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 635 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 265 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 291 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 267 of file connectivity_data.h.

References m_lock.

◆ GetNetCount()

int CONNECTIVITY_DATA::GetNetCount ( ) const

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

Definition at line 322 of file connectivity_data.cpp.

References m_connAlgo.

◆ GetNetItems()

const std::vector< BOARD_CONNECTED_ITEM * > CONNECTIVITY_DATA::GetNetItems ( int  aNetCode,
const std::vector< 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 582 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().

◆ GetNetNameForNetCode()

const wxString & CONNECTIVITY_DATA::GetNetNameForNetCode ( int  nc) const
inline

Definition at line 277 of file connectivity_data.h.

References m_netcodeMap.

◆ GetNetSettings()

const NET_SETTINGS * CONNECTIVITY_DATA::GetNetSettings ( ) const

Definition at line 1096 of file connectivity_data.cpp.

References m_netSettings.

◆ GetNodeCount()

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

Definition at line 684 of file connectivity_data.cpp.

References m_nets.

◆ GetPadCount()

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

Definition at line 702 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 931 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 522 of file connectivity_data.cpp.

References m_nets.

◆ HasNetNameForNetCode()

bool CONNECTIVITY_DATA::HasNetNameForNetCode ( int  nc) const
inline

Definition at line 276 of file connectivity_data.h.

References m_netcodeMap.

◆ HideLocalRatsnest()

void CONNECTIVITY_DATA::HideLocalRatsnest ( )

Hides the temporary, selection-based ratsnest lines.

Definition at line 417 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 236 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 168 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 423 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 225 of file connectivity_data.cpp.

References internalRecalculateRatsnest(), and m_lock.

◆ RefreshNetcodeMap()

void CONNECTIVITY_DATA::RefreshNetcodeMap ( BOARD aBoard)

Refresh the map of netcodes to net names.

Definition at line 144 of file connectivity_data.cpp.

References BOARD::GetNetInfo(), and m_netcodeMap.

Referenced by Build().

◆ 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 953 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 721 of file connectivity_data.cpp.

References m_nets.

◆ SetProgressReporter()

void CONNECTIVITY_DATA::SetProgressReporter ( PROGRESS_REPORTER aReporter)

Definition at line 962 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 177 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 308 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 307 of file connectivity_data.h.

Referenced by CONNECTIVITY_DATA(), and GetFromToCache().

◆ m_lock

KISPINLOCK CONNECTIVITY_DATA::m_lock
private

Definition at line 314 of file connectivity_data.h.

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

◆ m_netcodeMap

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

Used to map netcode to net name.

Definition at line 322 of file connectivity_data.h.

Referenced by GetNetNameForNetCode(), HasNetNameForNetCode(), and RefreshNetcodeMap().

◆ m_nets

◆ m_netSettings

std::weak_ptr<NET_SETTINGS> CONNECTIVITY_DATA::m_netSettings
private

Used to get netclass data when drawing ratsnests.

Definition at line 319 of file connectivity_data.h.

Referenced by Build(), and GetNetSettings().

◆ m_progressReporter

PROGRESS_REPORTER* CONNECTIVITY_DATA::m_progressReporter
private

Definition at line 316 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 312 of file connectivity_data.h.

Referenced by internalRecalculateRatsnest().


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