Keep track of which nets are currently in use.

Fixes: lp:1798006
* https://bugs.launchpad.net/kicad/+bug/1798006
This commit is contained in:
Jeff Young 2018-10-18 10:35:59 +01:00
parent 8a54b1b3b7
commit ff992f4a64
6 changed files with 48 additions and 32 deletions

View File

@ -236,14 +236,15 @@ protected:
for( NETINFO_ITEM* netinfo : *m_netinfoList )
{
if( netinfo->GetNet() == 0 )
continue; // we'll insert NO_NET after sorting
if( filter.IsEmpty() || wxString( netinfo->GetNetname() ).MakeLower().Matches( filter ) )
netNames.push_back( netinfo->GetNetname() );
if( netinfo->GetNet() > 0 && netinfo->IsCurrent() )
{
if( filter.IsEmpty() || wxString( netinfo->GetNetname() ).MakeLower().Matches( filter ) )
netNames.push_back( netinfo->GetNetname() );
}
}
std::sort( netNames.begin(), netNames.end() );
// Special handling for <no net>
if( filter.IsEmpty() || wxString( NO_NET ).MakeLower().Matches( filter ) )
netNames.insert( netNames.begin(), NO_NET );

View File

@ -306,10 +306,14 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE* aPcbComponent
}
else // New footprint pad has a net.
{
if( net.GetNetName() != pad->GetNetname() )
const wxString& netName = net.GetNetName();
NETINFO_ITEM* netinfo = m_board->FindNet( netName );
if( netinfo && !m_isDryRun )
netinfo->SetIsCurrent( true );
if( pad->GetNetname() != netName )
{
const wxString& netName = net.GetNetName();
NETINFO_ITEM* netinfo = m_board->FindNet( netName );
if( netinfo == nullptr )
{
@ -326,9 +330,9 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE* aPcbComponent
changed = true;
netinfo = new NETINFO_ITEM( m_board, netName );
m_commit.Add( netinfo );
m_addedNets[netName] = netinfo;
}
m_addedNets[netName] = netinfo;
msg.Printf( _( "Add net %s." ), netName );
m_reporter->Report( msg, REPORTER::RPT_ACTION );
}
@ -626,6 +630,11 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
if( !m_isDryRun )
{
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++ )

View File

@ -2484,19 +2484,23 @@ void BOARD::updateComponentPadConnections( NETLIST& aNetlist, MODULE* footprint,
}
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." ),
footprint->GetReference(),
pad->GetName(),
pad->GetNetname(),
net.GetNetName() );
netName );
aReporter.Report( msg, REPORTER::RPT_ACTION );
if( !aNetlist.IsDryRun() )
{
NETINFO_ITEM* netinfo = FindNet( net.GetNetName() );
if( netinfo == NULL )
{
// 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;
// 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++ )
{
COMPONENT* component = aNetlist.GetComponent( i );

View File

@ -146,30 +146,16 @@ bool PANEL_SETUP_NETCLASSES::TransferDataToWindow()
for( NETCLASSES::iterator i = netclasses.begin(); i != netclasses.end(); ++i, ++row )
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();
if( m_membershipGrid->GetNumberRows() )
m_membershipGrid->DeleteRows( 0, m_membershipGrid->GetNumberRows() );
// Initialize list of nets for Default Net Class
for( NETCLASS::iterator name = netclass->begin(); name != netclass->end(); ++name )
for( NETINFO_ITEM* net : m_Pcb->GetNetInfo() )
{
if( name->IsEmpty() )
// @TODO go fix m_Pcb->SynchronizeNetsAndNetClasses() so that the netcode==0
// 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() );
if( net->GetNet() > 0 && net->IsCurrent() )
addNet( net->GetNetname(), net->GetNetClass()->GetName() );
}
return true;

View File

@ -74,6 +74,10 @@ private:
int m_NetCode; ///< A number equivalent to the net name.
///< 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_ShortNetname; ///< short net name, like vout from /mysheet/mysubsheet/vout
@ -240,6 +244,10 @@ public:
*/
const wxString& GetShortNetname() const { return m_ShortNetname; }
bool IsCurrent() const { return m_isCurrent; }
void SetIsCurrent( bool isCurrent ) { m_isCurrent = isCurrent; }
/**
* Function GetMsgPanelInfo
* returns the information about the #NETINFO_ITEM in \a aList to display in the

View File

@ -50,7 +50,10 @@
NETINFO_ITEM::NETINFO_ITEM( BOARD* aParent, const wxString& aNetName, int aNetCode ) :
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;