Keep track of which nets are currently in use.
Fixes: lp:1798006 * https://bugs.launchpad.net/kicad/+bug/1798006
This commit is contained in:
parent
8a54b1b3b7
commit
ff992f4a64
|
@ -236,14 +236,15 @@ protected:
|
||||||
|
|
||||||
for( NETINFO_ITEM* netinfo : *m_netinfoList )
|
for( NETINFO_ITEM* netinfo : *m_netinfoList )
|
||||||
{
|
{
|
||||||
if( netinfo->GetNet() == 0 )
|
if( netinfo->GetNet() > 0 && netinfo->IsCurrent() )
|
||||||
continue; // we'll insert NO_NET after sorting
|
{
|
||||||
|
|
||||||
if( filter.IsEmpty() || wxString( netinfo->GetNetname() ).MakeLower().Matches( filter ) )
|
if( filter.IsEmpty() || wxString( netinfo->GetNetname() ).MakeLower().Matches( filter ) )
|
||||||
netNames.push_back( netinfo->GetNetname() );
|
netNames.push_back( netinfo->GetNetname() );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
std::sort( netNames.begin(), netNames.end() );
|
std::sort( netNames.begin(), netNames.end() );
|
||||||
|
|
||||||
|
// Special handling for <no net>
|
||||||
if( filter.IsEmpty() || wxString( NO_NET ).MakeLower().Matches( filter ) )
|
if( filter.IsEmpty() || wxString( NO_NET ).MakeLower().Matches( filter ) )
|
||||||
netNames.insert( netNames.begin(), NO_NET );
|
netNames.insert( netNames.begin(), NO_NET );
|
||||||
|
|
||||||
|
|
|
@ -305,12 +305,16 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE* aPcbComponent
|
||||||
cacheNetname( pad, wxEmptyString );
|
cacheNetname( pad, wxEmptyString );
|
||||||
}
|
}
|
||||||
else // New footprint pad has a net.
|
else // New footprint pad has a net.
|
||||||
{
|
|
||||||
if( net.GetNetName() != pad->GetNetname() )
|
|
||||||
{
|
{
|
||||||
const wxString& netName = net.GetNetName();
|
const wxString& netName = net.GetNetName();
|
||||||
NETINFO_ITEM* netinfo = m_board->FindNet( netName );
|
NETINFO_ITEM* netinfo = m_board->FindNet( netName );
|
||||||
|
|
||||||
|
if( netinfo && !m_isDryRun )
|
||||||
|
netinfo->SetIsCurrent( true );
|
||||||
|
|
||||||
|
if( pad->GetNetname() != netName )
|
||||||
|
{
|
||||||
|
|
||||||
if( netinfo == nullptr )
|
if( netinfo == nullptr )
|
||||||
{
|
{
|
||||||
// It might be a new net that has not been added to the board yet
|
// It might be a new net that has not been added to the board yet
|
||||||
|
@ -326,9 +330,9 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE* aPcbComponent
|
||||||
changed = true;
|
changed = true;
|
||||||
netinfo = new NETINFO_ITEM( m_board, netName );
|
netinfo = new NETINFO_ITEM( m_board, netName );
|
||||||
m_commit.Add( netinfo );
|
m_commit.Add( netinfo );
|
||||||
m_addedNets[netName] = netinfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_addedNets[netName] = netinfo;
|
||||||
msg.Printf( _( "Add net %s." ), netName );
|
msg.Printf( _( "Add net %s." ), netName );
|
||||||
m_reporter->Report( msg, REPORTER::RPT_ACTION );
|
m_reporter->Report( msg, REPORTER::RPT_ACTION );
|
||||||
}
|
}
|
||||||
|
@ -626,6 +630,11 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
|
||||||
if( !m_isDryRun )
|
if( !m_isDryRun )
|
||||||
{
|
{
|
||||||
m_board->SetStatus( 0 );
|
m_board->SetStatus( 0 );
|
||||||
|
|
||||||
|
// Mark all nets (except <no net>) as stale; we'll update those to current that
|
||||||
|
// we find in the netlist
|
||||||
|
for( NETINFO_ITEM* net : m_board->GetNetInfo() )
|
||||||
|
net->SetIsCurrent( net->GetNet() == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( unsigned i = 0; i < aNetlist.GetCount(); i++ )
|
for( unsigned i = 0; i < aNetlist.GetCount(); i++ )
|
||||||
|
|
|
@ -2484,19 +2484,23 @@ void BOARD::updateComponentPadConnections( NETLIST& aNetlist, MODULE* footprint,
|
||||||
}
|
}
|
||||||
else // Footprint pad has a net.
|
else // Footprint pad has a net.
|
||||||
{
|
{
|
||||||
if( net.GetNetName() != pad->GetNetname() )
|
const wxString& netName = net.GetNetName();
|
||||||
|
NETINFO_ITEM* netinfo = FindNet( netName );
|
||||||
|
|
||||||
|
if( netinfo && !aNetlist.IsDryRun() )
|
||||||
|
netinfo->SetIsCurrent( true );
|
||||||
|
|
||||||
|
if( pad->GetNetname() != netName )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Changing footprint %s pad %s net from %s to %s." ),
|
msg.Printf( _( "Changing footprint %s pad %s net from %s to %s." ),
|
||||||
footprint->GetReference(),
|
footprint->GetReference(),
|
||||||
pad->GetName(),
|
pad->GetName(),
|
||||||
pad->GetNetname(),
|
pad->GetNetname(),
|
||||||
net.GetNetName() );
|
netName );
|
||||||
aReporter.Report( msg, REPORTER::RPT_ACTION );
|
aReporter.Report( msg, REPORTER::RPT_ACTION );
|
||||||
|
|
||||||
if( !aNetlist.IsDryRun() )
|
if( !aNetlist.IsDryRun() )
|
||||||
{
|
{
|
||||||
NETINFO_ITEM* netinfo = FindNet( net.GetNetName() );
|
|
||||||
|
|
||||||
if( netinfo == NULL )
|
if( netinfo == NULL )
|
||||||
{
|
{
|
||||||
// It is a new net, we have to add it
|
// It is a new net, we have to add it
|
||||||
|
@ -2556,6 +2560,11 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
|
||||||
|
|
||||||
m_Status_Pcb = 0;
|
m_Status_Pcb = 0;
|
||||||
|
|
||||||
|
// Mark all nets (except <no net>) as stale; we'll update those to current that
|
||||||
|
// we find in the netlist
|
||||||
|
for( NETINFO_ITEM* net : m_NetInfo )
|
||||||
|
net->SetIsCurrent( net->GetNet() == 0 );
|
||||||
|
|
||||||
for( i = 0; i < aNetlist.GetCount(); i++ )
|
for( i = 0; i < aNetlist.GetCount(); i++ )
|
||||||
{
|
{
|
||||||
COMPONENT* component = aNetlist.GetComponent( i );
|
COMPONENT* component = aNetlist.GetComponent( i );
|
||||||
|
|
|
@ -146,30 +146,16 @@ bool PANEL_SETUP_NETCLASSES::TransferDataToWindow()
|
||||||
for( NETCLASSES::iterator i = netclasses.begin(); i != netclasses.end(); ++i, ++row )
|
for( NETCLASSES::iterator i = netclasses.begin(); i != netclasses.end(); ++i, ++row )
|
||||||
netclassToGridRow( m_Frame->GetUserUnits(), m_netclassGrid, row, i->second );
|
netclassToGridRow( m_Frame->GetUserUnits(), m_netclassGrid, row, i->second );
|
||||||
|
|
||||||
// Reassure that all nets have net classes assigned
|
// ensure that all nets have net classes assigned
|
||||||
m_Pcb->BuildListOfNets();
|
m_Pcb->BuildListOfNets();
|
||||||
|
|
||||||
if( m_membershipGrid->GetNumberRows() )
|
if( m_membershipGrid->GetNumberRows() )
|
||||||
m_membershipGrid->DeleteRows( 0, m_membershipGrid->GetNumberRows() );
|
m_membershipGrid->DeleteRows( 0, m_membershipGrid->GetNumberRows() );
|
||||||
|
|
||||||
// Initialize list of nets for Default Net Class
|
for( NETINFO_ITEM* net : m_Pcb->GetNetInfo() )
|
||||||
for( NETCLASS::iterator name = netclass->begin(); name != netclass->end(); ++name )
|
|
||||||
{
|
{
|
||||||
if( name->IsEmpty() )
|
if( net->GetNet() > 0 && net->IsCurrent() )
|
||||||
// @TODO go fix m_Pcb->SynchronizeNetsAndNetClasses() so that the netcode==0
|
addNet( net->GetNetname(), net->GetNetClass()->GetName() );
|
||||||
// is not present in the BOARD::m_NetClasses
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
addNet( *name, netclass->GetName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize list of nets for others (custom) Net Classes
|
|
||||||
for( NETCLASSES::const_iterator nc = netclasses.begin(); nc != netclasses.end(); ++nc )
|
|
||||||
{
|
|
||||||
netclass = nc->second;
|
|
||||||
|
|
||||||
for( NETCLASS::const_iterator name = netclass->begin(); name != netclass->end(); ++name )
|
|
||||||
addNet( *name, netclass->GetName() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -74,6 +74,10 @@ private:
|
||||||
int m_NetCode; ///< A number equivalent to the net name.
|
int m_NetCode; ///< A number equivalent to the net name.
|
||||||
///< Used for fast comparisons in ratsnest and DRC computations.
|
///< Used for fast comparisons in ratsnest and DRC computations.
|
||||||
|
|
||||||
|
bool m_isCurrent; ///< Indicates the net is currently in use. We still store those
|
||||||
|
///< that are not during a session for undo/redo and to keep
|
||||||
|
///< netclass membership information.
|
||||||
|
|
||||||
wxString m_Netname; ///< Full net name like /mysheet/mysubsheet/vout used by Eeschema
|
wxString m_Netname; ///< Full net name like /mysheet/mysubsheet/vout used by Eeschema
|
||||||
|
|
||||||
wxString m_ShortNetname; ///< short net name, like vout from /mysheet/mysubsheet/vout
|
wxString m_ShortNetname; ///< short net name, like vout from /mysheet/mysubsheet/vout
|
||||||
|
@ -240,6 +244,10 @@ public:
|
||||||
*/
|
*/
|
||||||
const wxString& GetShortNetname() const { return m_ShortNetname; }
|
const wxString& GetShortNetname() const { return m_ShortNetname; }
|
||||||
|
|
||||||
|
bool IsCurrent() const { return m_isCurrent; }
|
||||||
|
|
||||||
|
void SetIsCurrent( bool isCurrent ) { m_isCurrent = isCurrent; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetMsgPanelInfo
|
* Function GetMsgPanelInfo
|
||||||
* returns the information about the #NETINFO_ITEM in \a aList to display in the
|
* returns the information about the #NETINFO_ITEM in \a aList to display in the
|
||||||
|
|
|
@ -50,7 +50,10 @@
|
||||||
|
|
||||||
NETINFO_ITEM::NETINFO_ITEM( BOARD* aParent, const wxString& aNetName, int aNetCode ) :
|
NETINFO_ITEM::NETINFO_ITEM( BOARD* aParent, const wxString& aNetName, int aNetCode ) :
|
||||||
BOARD_ITEM( aParent, PCB_NETINFO_T ),
|
BOARD_ITEM( aParent, PCB_NETINFO_T ),
|
||||||
m_NetCode( aNetCode ), m_Netname( aNetName ), m_ShortNetname( m_Netname.AfterLast( '/' ) )
|
m_NetCode( aNetCode ),
|
||||||
|
m_isCurrent( true ),
|
||||||
|
m_Netname( aNetName ),
|
||||||
|
m_ShortNetname( m_Netname.AfterLast( '/' ) )
|
||||||
{
|
{
|
||||||
m_parent = aParent;
|
m_parent = aParent;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue