Commit 487b609e authored by Maciej Suminski's avatar Maciej Suminski

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.
parent d3f0151a
......@@ -228,13 +228,13 @@ private:
class NETINFO_ITEM
{
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.
wxString m_Netname; ///< Full net name like /mysheet/mysubsheet/vout
const wxString m_Netname; ///< Full net name like /mysheet/mysubsheet/vout
///< 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
wxString m_NetClassName; // Net Class name. if void this is equivalent
......@@ -386,8 +386,10 @@ public:
*/
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(); }
/**
......@@ -402,12 +404,6 @@ public:
*/
wxString GetShortNetname() const { return m_ShortNetname; }
/**
* Function SetNetname
* @param aNetname : the new netname
*/
void SetNetname( const wxString& aNetname );
/**
* Function GetMsgPanelInfo
* 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.
*/
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 */
/*********************************************************/
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_NbNodes = 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)
*/
......
......@@ -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 )
{
m_NetBuffer.push_back( aNewElement );
......@@ -80,46 +76,29 @@ void NETINFO_LIST::buildListOfNets()
int nodes_count = 0;
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
buildPadsFullList();
// Build netnames list, and create a netcode for each netname
D_PAD* last_pad = NULL;
int netcode = 0;
// Restore the initial state of NETINFO_ITEMs
for( unsigned i = 0; i < GetNetCount(); ++i )
{
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++ )
{
pad = m_PadsFullList[ii];
if( pad->GetNetname().IsEmpty() ) // pad not connected
{
pad->SetNet( 0 );
if( pad->GetNet() == 0 ) // pad not connected
continue;
}
/* if the current netname was already found: add pad to the current net_item ,
* 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 = GetNetItem( pad->GetNet() );
net_item->m_PadInNetList.push_back( pad );
nodes_count++;
last_pad = pad;
++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->SetAreasNetCodesFromNetNames();
// D( Show(); )
}
#if defined(DEBUG)
......
......@@ -647,7 +647,6 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb )
if( net->GetNetname() == wxEmptyString ) // dummy netlist (no connection)
{
wxString msg; msg << wxT( "NoConnection" ) << NbNoConn++;
net->SetNetname( msg );
}
if( net->GetNet() <= 0 ) // dummy netlist (no connection)
......
......@@ -1811,7 +1811,7 @@ void LEGACY_PLUGIN::loadNETINFO_ITEM()
{
char buf[1024];
NETINFO_ITEM* net = new NETINFO_ITEM( m_board );
NETINFO_ITEM* net;
char* line;
while( ( line = READLINE( m_reader ) ) != NULL )
......@@ -1822,11 +1822,10 @@ void LEGACY_PLUGIN::loadNETINFO_ITEM()
{
// e.g. "Na 58 "/cpu.sch/PAD7"\r\n"
int tmp = intParse( line + SZ( "Na" ), &data );
net->SetNet( tmp );
int netCode = intParse( line + SZ( "Na" ), &data );
ReadDelimitedText( buf, data, sizeof(buf) );
net->SetNetname( FROM_UTF8( buf ) );
net = new NETINFO_ITEM( m_board, FROM_UTF8( buf ), netCode );
}
else if( TESTLINE( "$EndEQUIPOT" ) )
......
......@@ -69,7 +69,7 @@ MIN_SPAN_TREE::MIN_SPAN_TREE()
void MIN_SPAN_TREE::MSP_Init( int aNodesCount )
{
m_Size = aNodesCount;
m_Size = std::max( aNodesCount, 1 );
inTree.clear();
linkedTo.clear();
distTo.clear();
......
......@@ -1066,9 +1066,7 @@ void PCB_PARSER::parseNETINFO_ITEM() throw( IO_ERROR, PARSE_ERROR )
// (TODO: a better test.)
if( number > 0 || m_board->FindNet( 0 ) == NULL )
{
NETINFO_ITEM* net = new NETINFO_ITEM( m_board );
net->SetNet( number );
net->SetNetname( name );
NETINFO_ITEM* net = new NETINFO_ITEM( m_board, name, number );
m_board->AppendNet( net );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment