54 NETNAMES_MAP::iterator it, itEnd;
67 NETCODES_MAP::const_iterator result =
m_netCodes.find( aNetCode );
70 return (*result).second;
78 NETNAMES_MAP::const_iterator result =
m_netNames.find( aNetName );
81 return (*result).second;
93 if ( i->second == aNet )
103 if ( i->second == aNet )
105 wxASSERT_MSG( removed, wxT(
"NETINFO_LIST::RemoveNet: target net found in m_netNames "
106 "but not m_netCodes!" ) );
123 std::vector<NETINFO_ITEM*> unusedNets;
128 for(
const auto& [ netCode, netInfo ] : existingNets )
130 if( netInfo->IsCurrent() )
132 m_netNames.insert( std::make_pair( netInfo->GetNetname(), netInfo ) );
133 m_netCodes.insert( std::make_pair( netCode, netInfo ) );
151 if( sameName !=
nullptr )
189 std::map<wxString, std::vector<wxString>> shortNameMap;
202 wxArrayString parts = wxSplit( net->
m_netname,
'/' );
203 std::vector<wxArrayString> aggregateParts;
204 std::optional<size_t> firstNonCommon;
206 for(
const wxString& longName : shortNameMap[net->
m_shortNetname] )
207 aggregateParts.push_back( wxSplit( longName,
'/' ) );
209 for(
size_t ii = 0; ii < parts.size() && !firstNonCommon; ++ii )
211 for(
const wxArrayString& otherParts : aggregateParts )
213 if( ii < otherParts.size() && otherParts[ii] == parts[ii] )
221 if( firstNonCommon.value_or( 0 ) > 0 && firstNonCommon.value() < parts.size() )
223 wxString disambiguatedName;
225 for(
size_t ii = firstNonCommon.value(); ii < parts.size(); ++ii )
227 if( !disambiguatedName.IsEmpty() )
228 disambiguatedName += wxS(
"/" );
230 disambiguatedName += parts[ii];
247void NETINFO_LIST::Show()
const
250 NETNAMES_MAP::const_iterator it, itEnd;
254 wxLogDebug( wxT(
"[%d]: netcode:%d netname:<%s>\n" ),
256 it->second->GetNetCode(),
257 TO_UTF8( it->second->GetNetname() ) );
277 std::map<int, int>::const_iterator value =
m_netMapping.find( aNetCode );
280 return value->second;
297 nets.insert( zone->GetNetCode() );
301 nets.insert( track->GetNetCode() );
317 for(
PAD*
pad : footprint->Pads() )
318 nets.insert(
pad->GetNetCode() );
328 for(
auto net : nets )
341 return m_mapping->m_board->FindNet( m_iterator->first );
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
const ZONES & Zones() const
int SetAreasNetCodesFromNetNames()
Set the .m_NetCode member of all copper areas, according to the area Net Name The SetNetCodesFromNetN...
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
const DRAWINGS & Drawings() const
COMMIT & Removed(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Modify a given item in the model.
Handle the data for a net.
wxString m_shortNetname
Short net name, like vout from /sheet/subsheet/vout.
wxString m_displayNetname
Unescaped netname for display.
const wxString & GetNetname() const
void Clear()
Set all fields to their default values.
int m_netCode
A number equivalent to the net name.
wxString m_netname
Full net name like /sheet/subsheet/vout used by Eeschema.
int getFreeNetCode()
Return the first available net code that is not used by any other net.
void RemoveUnusedNets(BOARD_COMMIT *aCommit)
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
NETCODES_MAP m_netCodes
map of <int, NETINFO_ITEM*> is NOT owner
static const int ORPHANED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
int m_newNetCode
possible value for new net code assignment
void RemoveNet(NETINFO_ITEM *aNet)
Remove a net from the net list.
NETINFO_ITEM * GetNetItem(int aNetCode) const
NETINFO_LIST(BOARD *aParent)
void clear()
Delete the list of nets (and free memory).
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
void AppendNet(NETINFO_ITEM *aNewElement)
Add aNewElement to the end of the net list.
bool m_DisplayNetnamesDirty
void RebuildDisplayNetnames() const
void buildListOfNets()
Rebuild the list of NETINFO_ITEMs.
NETINFO_ITEM * operator->() const
const NETINFO_MAPPING * m_mapping
std::map< int, int >::const_iterator m_iterator
NETINFO_ITEM * operator*() const
int Translate(int aNetCode) const
Translate net number according to the map prepared by Update() function.
void Update()
Prepare a mapping for net codes so they can be saved as consecutive numbers.
const BOARD * m_board
Board for which mapping is prepared.
std::map< int, int > m_netMapping
Map that allows saving net codes with consecutive numbers (for compatibility reasons)
Handle a list of polygons defining a copper zone.
This file contains miscellaneous commonly used macros and functions.
wxString UnescapeString(const wxString &aSource)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers