Commit c047d7f4 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: regression fix when using the new netlist format:

* when a footprint has  many pads having the same pad name, only the first pad was connected to the net
parent 909c2a60
...@@ -363,15 +363,18 @@ public: ...@@ -363,15 +363,18 @@ public:
void RemoveExtraFootprints( ); void RemoveExtraFootprints( );
/** /**
* Function SetPadNetName * Function SetPadsNetName
* Update a pad netname * Update pads netnames for a given module.
* Because a pad name can be found more than once in this module,
* all pads matching the pad name are updated
* @param aModule = module reference * @param aModule = module reference
* @param aPadname = pad name (pad num) * @param aPadname = pad name (pad num)
* @param aNetname = new net name of the pad * @param aNetname = new net name of the pad
* @return a pointer to the pad or NULL if the pad is not found * @param aPadList = a std::vector<D_PAD*>& buffer where the updated pads can be stored
* @return the pad count
*/ */
D_PAD* SetPadNetName( const wxString & aModule, const wxString & aPadname, int SetPadsNetName( const wxString & aModule, const wxString & aPadname,
const wxString & aNetname ); const wxString & aNetname, std::vector<D_PAD*> & aPadList );
private: private:
......
...@@ -278,27 +278,43 @@ void NETLIST_READER::TestFootprintsMatchingAndExchange() ...@@ -278,27 +278,43 @@ void NETLIST_READER::TestFootprintsMatchingAndExchange()
} }
/** /**
* Function SetPadNetName * Function SetPadsNetName
* Update a pad netname * Update pads netnames for a given module.
* Because a pad name can be found more than once in this module,
* all pads matching the pad name are updated
* @param aModule = module reference * @param aModule = module reference
* @param aPadname = pad name (pad num) * @param aPadname = pad name (pad num)
* @param aNetname = new net name of the pad * @param aNetname = new net name of the pad
* @return a pointer to the pad or NULL if the pad is not found * @param aPadList = a std::vector<D_PAD*>& buffer where the updated pads can be stored
* @return the pad count
*/ */
D_PAD* NETLIST_READER::SetPadNetName( const wxString & aModule, const wxString & aPadname, int NETLIST_READER::SetPadsNetName( const wxString & aModule, const wxString & aPadname,
const wxString & aNetname ) const wxString & aNetname, std::vector<D_PAD*> & aPadList )
{ {
if( m_pcbframe == NULL ) if( m_pcbframe == NULL )
return NULL; return 0;
int padcount = 0;
MODULE* module = m_pcbframe->GetBoard()->FindModuleByReference( aModule ); MODULE* module = m_pcbframe->GetBoard()->FindModuleByReference( aModule );
if( module ) if( module )
{ {
D_PAD * pad = module->FindPadByName( aPadname ); D_PAD * pad = module->FindPadByName( aPadname );
if( pad ) if( pad )
{ {
padcount++;
aPadList.push_back( pad );
pad->SetNetname( aNetname ); pad->SetNetname( aNetname );
return pad; // Search for other pads having the same pad name/num
for( D_PAD* curr_pad = pad->Next(); curr_pad; curr_pad = curr_pad->Next() )
{
if( pad->PadNameEqual( curr_pad ) )
{
padcount++;
aPadList.push_back( curr_pad );
curr_pad->SetNetname( aNetname );
}
}
return padcount;
} }
if( m_messageWindow ) if( m_messageWindow )
{ {
...@@ -309,7 +325,7 @@ D_PAD* NETLIST_READER::SetPadNetName( const wxString & aModule, const wxString & ...@@ -309,7 +325,7 @@ D_PAD* NETLIST_READER::SetPadNetName( const wxString & aModule, const wxString &
} }
} }
return NULL; return 0;
} }
......
...@@ -245,8 +245,9 @@ void NETLIST_READER_KICAD_PARSER::ParseNet( BOARD * aBrd ) ...@@ -245,8 +245,9 @@ void NETLIST_READER_KICAD_PARSER::ParseNet( BOARD * aBrd )
wxString name; wxString name;
wxString cmpref; wxString cmpref;
wxString pin; wxString pin;
D_PAD * pad = NULL;
int nodecount = 0; int nodecount = 0;
std::vector<D_PAD*> padList;
// The token net was read, so the next data is (code <number>) // The token net was read, so the next data is (code <number>)
while( (token = NextTok()) != T_RIGHT ) while( (token = NextTok()) != T_RIGHT )
{ {
...@@ -292,7 +293,7 @@ void NETLIST_READER_KICAD_PARSER::ParseNet( BOARD * aBrd ) ...@@ -292,7 +293,7 @@ void NETLIST_READER_KICAD_PARSER::ParseNet( BOARD * aBrd )
break; break;
} }
} }
pad = netlist_reader->SetPadNetName( cmpref, pin, name ); netlist_reader->SetPadsNetName( cmpref, pin, name, padList );
nodecount++; nodecount++;
break; break;
...@@ -303,8 +304,11 @@ void NETLIST_READER_KICAD_PARSER::ParseNet( BOARD * aBrd ) ...@@ -303,8 +304,11 @@ void NETLIST_READER_KICAD_PARSER::ParseNet( BOARD * aBrd )
} }
// When there is only one item in net, clear pad netname // When there is only one item in net, clear pad netname
if( nodecount < 2 && pad ) // Remember one can have more than one pad in list, because a footprint
pad->SetNetname( wxEmptyString ); // can have many pads with the same pad name
if( nodecount < 2 )
for( unsigned ii = 0; ii < padList.size(); ii++ )
padList[ii]->SetNetname( wxEmptyString );
} }
......
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