Removed NETINFO_ITEM::SetNet() and NETINFO_ITEM::SetNetname() methods.
NETINFO_ITEM::m_Net and NETINFO_ITEM::m_Netname are const. Changes to be verified: - pcbnew/minimun_spanning_tree.cpp: It segfaults is m_Size == 0 - pcbnew/exporters/export_gencad.cpp: I removed the SetNetname() call, as it changes only the unconnected net and in the next line it returns if the net is unconnected. Still, I wonder if name for the unconnected net matters. What about tests that check if a net name is empty to decide if it is unconnected net or not.
This commit is contained in:
parent
d3f0151ad4
commit
487b609e76
|
@ -228,14 +228,14 @@ private:
|
||||||
class NETINFO_ITEM
|
class NETINFO_ITEM
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int m_NetCode; ///< A number equivalent to the net name.
|
const 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.
|
||||||
|
|
||||||
wxString m_Netname; ///< Full net name like /mysheet/mysubsheet/vout
|
const wxString m_Netname; ///< Full net name like /mysheet/mysubsheet/vout
|
||||||
///< used by Eeschema
|
///< used by Eeschema
|
||||||
|
|
||||||
wxString m_ShortNetname; // short net name, like vout from
|
const wxString m_ShortNetname; // short net name, like vout from
|
||||||
// /mysheet/mysubsheet/vout
|
// /mysheet/mysubsheet/vout
|
||||||
|
|
||||||
wxString m_NetClassName; // Net Class name. if void this is equivalent
|
wxString m_NetClassName; // Net Class name. if void this is equivalent
|
||||||
// to "default" (the first
|
// to "default" (the first
|
||||||
|
@ -386,8 +386,10 @@ public:
|
||||||
*/
|
*/
|
||||||
int GetNet() const { return m_NetCode; }
|
int GetNet() const { return m_NetCode; }
|
||||||
|
|
||||||
void SetNet( int aNetCode ) { m_NetCode = aNetCode; }
|
/**
|
||||||
|
* Function GetNodesCount
|
||||||
|
* @return int - number of nodes in the net
|
||||||
|
*/
|
||||||
int GetNodesCount() const { return m_PadInNetList.size(); }
|
int GetNodesCount() const { return m_PadInNetList.size(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -402,12 +404,6 @@ public:
|
||||||
*/
|
*/
|
||||||
wxString GetShortNetname() const { return m_ShortNetname; }
|
wxString GetShortNetname() const { return m_ShortNetname; }
|
||||||
|
|
||||||
/**
|
|
||||||
* Function SetNetname
|
|
||||||
* @param aNetname : the new netname
|
|
||||||
*/
|
|
||||||
void SetNetname( const wxString& aNetname );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
@ -416,6 +412,25 @@ public:
|
||||||
* @param aList is the list in which to place the status information.
|
* @param aList is the list in which to place the status information.
|
||||||
*/
|
*/
|
||||||
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
|
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function Clear
|
||||||
|
* sets all fields to their defaults values.
|
||||||
|
*/
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
m_PadInNetList.clear();
|
||||||
|
|
||||||
|
m_NbNodes = 0;
|
||||||
|
m_NbLink = 0;
|
||||||
|
m_NbNoconn = 0;
|
||||||
|
m_Flag = 0;
|
||||||
|
m_RatsnestStartIdx = 0; // Starting point of ratsnests of this net in a
|
||||||
|
// general buffer of ratsnest
|
||||||
|
m_RatsnestEndIdx = 0; // Ending point of ratsnests of this net
|
||||||
|
|
||||||
|
SetClass( NULL );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,13 +49,9 @@
|
||||||
/* class NETINFO_ITEM: handle data relative to a given net */
|
/* class NETINFO_ITEM: handle data relative to a given net */
|
||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
|
|
||||||
NETINFO_ITEM::NETINFO_ITEM( BOARD_ITEM* aParent, const wxString& aNetName, int aNetCode )
|
NETINFO_ITEM::NETINFO_ITEM( BOARD_ITEM* aParent, const wxString& aNetName, int aNetCode ) :
|
||||||
|
m_NetCode( aNetCode ), m_Netname( aNetName ), m_ShortNetname( m_Netname.AfterLast( '/' ) )
|
||||||
{
|
{
|
||||||
SetNet( aNetCode );
|
|
||||||
|
|
||||||
if( aNetName.size() )
|
|
||||||
SetNetname( aNetName );
|
|
||||||
|
|
||||||
m_parent = aParent;
|
m_parent = aParent;
|
||||||
m_NbNodes = 0;
|
m_NbNodes = 0;
|
||||||
m_NbLink = 0;
|
m_NbLink = 0;
|
||||||
|
@ -77,17 +73,6 @@ NETINFO_ITEM::~NETINFO_ITEM()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function SetNetname
|
|
||||||
* @param aNetname : the new netname
|
|
||||||
*/
|
|
||||||
void NETINFO_ITEM::SetNetname( const wxString& aNetname )
|
|
||||||
{
|
|
||||||
m_Netname = aNetname;
|
|
||||||
m_ShortNetname = m_Netname.AfterLast( '/' );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Draw (TODO)
|
* Function Draw (TODO)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -37,10 +37,6 @@ void NETINFO_LIST::clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function Append
|
|
||||||
* adds \a aNewElement to the end of the list.
|
|
||||||
*/
|
|
||||||
void NETINFO_LIST::AppendNet( NETINFO_ITEM* aNewElement )
|
void NETINFO_LIST::AppendNet( NETINFO_ITEM* aNewElement )
|
||||||
{
|
{
|
||||||
m_NetBuffer.push_back( aNewElement );
|
m_NetBuffer.push_back( aNewElement );
|
||||||
|
@ -80,46 +76,29 @@ void NETINFO_LIST::buildListOfNets()
|
||||||
int nodes_count = 0;
|
int nodes_count = 0;
|
||||||
NETINFO_ITEM* net_item;
|
NETINFO_ITEM* net_item;
|
||||||
|
|
||||||
clear(); // Remove all nets info and free memory
|
|
||||||
|
|
||||||
// Create and add the "unconnected net", always existing,
|
|
||||||
// used to handle pads and tracks that are not member of a "real" net
|
|
||||||
net_item = new NETINFO_ITEM( m_Parent );
|
|
||||||
AppendNet( net_item );
|
|
||||||
|
|
||||||
// Build the PAD list, sorted by net
|
// Build the PAD list, sorted by net
|
||||||
buildPadsFullList();
|
buildPadsFullList();
|
||||||
|
|
||||||
// Build netnames list, and create a netcode for each netname
|
// Restore the initial state of NETINFO_ITEMs
|
||||||
D_PAD* last_pad = NULL;
|
for( unsigned i = 0; i < GetNetCount(); ++i )
|
||||||
int netcode = 0;
|
{
|
||||||
|
GetNetItem( i )->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << m_PadsFullList.size() << std::endl;
|
||||||
|
|
||||||
|
// Assign pads to appropriate NETINFO_ITEMs
|
||||||
for( unsigned ii = 0; ii < m_PadsFullList.size(); ii++ )
|
for( unsigned ii = 0; ii < m_PadsFullList.size(); ii++ )
|
||||||
{
|
{
|
||||||
pad = m_PadsFullList[ii];
|
pad = m_PadsFullList[ii];
|
||||||
|
|
||||||
if( pad->GetNetname().IsEmpty() ) // pad not connected
|
if( pad->GetNet() == 0 ) // pad not connected
|
||||||
{
|
|
||||||
pad->SetNet( 0 );
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
/* if the current netname was already found: add pad to the current net_item ,
|
net_item = GetNetItem( pad->GetNet() );
|
||||||
* else create a new net_code and a new net_item
|
|
||||||
*/
|
|
||||||
if( last_pad == NULL || ( pad->GetNetname() != last_pad->GetNetname() ) )
|
|
||||||
{
|
|
||||||
netcode++;
|
|
||||||
net_item = new NETINFO_ITEM( m_Parent, pad->GetNetname(), netcode );
|
|
||||||
AppendNet( net_item );
|
|
||||||
}
|
|
||||||
|
|
||||||
pad->SetNet( netcode );
|
|
||||||
net_item->m_PadInNetList.push_back( pad );
|
net_item->m_PadInNetList.push_back( pad );
|
||||||
|
|
||||||
nodes_count++;
|
++nodes_count;
|
||||||
|
|
||||||
last_pad = pad;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Parent->SetNodeCount( nodes_count );
|
m_Parent->SetNodeCount( nodes_count );
|
||||||
|
@ -129,8 +108,6 @@ void NETINFO_LIST::buildListOfNets()
|
||||||
m_Parent->m_Status_Pcb |= NET_CODES_OK;
|
m_Parent->m_Status_Pcb |= NET_CODES_OK;
|
||||||
|
|
||||||
m_Parent->SetAreasNetCodesFromNetNames();
|
m_Parent->SetAreasNetCodesFromNetNames();
|
||||||
|
|
||||||
// D( Show(); )
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
|
|
|
@ -647,7 +647,6 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb )
|
||||||
if( net->GetNetname() == wxEmptyString ) // dummy netlist (no connection)
|
if( net->GetNetname() == wxEmptyString ) // dummy netlist (no connection)
|
||||||
{
|
{
|
||||||
wxString msg; msg << wxT( "NoConnection" ) << NbNoConn++;
|
wxString msg; msg << wxT( "NoConnection" ) << NbNoConn++;
|
||||||
net->SetNetname( msg );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( net->GetNet() <= 0 ) // dummy netlist (no connection)
|
if( net->GetNet() <= 0 ) // dummy netlist (no connection)
|
||||||
|
|
|
@ -1811,7 +1811,7 @@ void LEGACY_PLUGIN::loadNETINFO_ITEM()
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
NETINFO_ITEM* net = new NETINFO_ITEM( m_board );
|
NETINFO_ITEM* net;
|
||||||
char* line;
|
char* line;
|
||||||
|
|
||||||
while( ( line = READLINE( m_reader ) ) != NULL )
|
while( ( line = READLINE( m_reader ) ) != NULL )
|
||||||
|
@ -1822,11 +1822,10 @@ void LEGACY_PLUGIN::loadNETINFO_ITEM()
|
||||||
{
|
{
|
||||||
// e.g. "Na 58 "/cpu.sch/PAD7"\r\n"
|
// e.g. "Na 58 "/cpu.sch/PAD7"\r\n"
|
||||||
|
|
||||||
int tmp = intParse( line + SZ( "Na" ), &data );
|
int netCode = intParse( line + SZ( "Na" ), &data );
|
||||||
net->SetNet( tmp );
|
|
||||||
|
|
||||||
ReadDelimitedText( buf, data, sizeof(buf) );
|
ReadDelimitedText( buf, data, sizeof(buf) );
|
||||||
net->SetNetname( FROM_UTF8( buf ) );
|
net = new NETINFO_ITEM( m_board, FROM_UTF8( buf ), netCode );
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( TESTLINE( "$EndEQUIPOT" ) )
|
else if( TESTLINE( "$EndEQUIPOT" ) )
|
||||||
|
|
|
@ -69,7 +69,7 @@ MIN_SPAN_TREE::MIN_SPAN_TREE()
|
||||||
|
|
||||||
void MIN_SPAN_TREE::MSP_Init( int aNodesCount )
|
void MIN_SPAN_TREE::MSP_Init( int aNodesCount )
|
||||||
{
|
{
|
||||||
m_Size = aNodesCount;
|
m_Size = std::max( aNodesCount, 1 );
|
||||||
inTree.clear();
|
inTree.clear();
|
||||||
linkedTo.clear();
|
linkedTo.clear();
|
||||||
distTo.clear();
|
distTo.clear();
|
||||||
|
|
|
@ -1066,9 +1066,7 @@ void PCB_PARSER::parseNETINFO_ITEM() throw( IO_ERROR, PARSE_ERROR )
|
||||||
// (TODO: a better test.)
|
// (TODO: a better test.)
|
||||||
if( number > 0 || m_board->FindNet( 0 ) == NULL )
|
if( number > 0 || m_board->FindNet( 0 ) == NULL )
|
||||||
{
|
{
|
||||||
NETINFO_ITEM* net = new NETINFO_ITEM( m_board );
|
NETINFO_ITEM* net = new NETINFO_ITEM( m_board, name, number );
|
||||||
net->SetNet( number );
|
|
||||||
net->SetNetname( name );
|
|
||||||
m_board->AppendNet( net );
|
m_board->AppendNet( net );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue