From 3d40bd7e169379f7bf25e63175a39da487360ab2 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 23 Aug 2013 11:22:19 +0200 Subject: [PATCH] Pcbnew: add more test when reading a netlist file: verify if all pads found in netlist are found in corresponding footprints (no missing pads). --- pcbnew/class_board.cpp | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index c6c18742aa..c71c0f3f78 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -2339,7 +2339,6 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter ) wxString msg; D_PAD* pad; MODULE* footprint; - COMPONENT* component; COMPONENT_NET net; if( !IsEmpty() ) @@ -2350,7 +2349,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter ) if( bbbox.GetWidth() || bbbox.GetHeight() ) { bestPosition.x = bbbox.Centre().x; - bestPosition.y = bbbox.GetBottom() + DMils2iu( 5000 ); + bestPosition.y = bbbox.GetBottom() + Millimeter2iu( 10 ); } } else @@ -2366,7 +2365,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter ) for( i = 0; i < aNetlist.GetCount(); i++ ) { - component = aNetlist.GetComponent( i ); + COMPONENT* component = aNetlist.GetComponent( i ); if( aReporter && aReporter->ReportAll() ) { @@ -2574,6 +2573,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter ) if( aNetlist.GetDeleteExtraFootprints() ) { MODULE* nextModule; + const COMPONENT* component; for( MODULE* module = m_Modules; module != NULL; module = nextModule ) { @@ -2602,5 +2602,39 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter ) } } } + + // Last step: verify all pads found in netlist: + // They should exist in footprints, otherwise the footprint is wrong + // note also references or time stamps are updated, so we use only + // the reference to find a footprint + if( aReporter && aReporter->ReportErrors() ) + { + wxString padname; + for( i = 0; i < aNetlist.GetCount(); i++ ) + { + const COMPONENT* component = aNetlist.GetComponent( i ); + MODULE* footprint = FindModuleByReference( component->GetReference() ); + + if( footprint == NULL ) // It can be missing in partial designs + continue; + + // Explore all pins/pads in component + for( unsigned jj = 0; jj < component->GetNetCount(); jj++ ) + { + net = component->GetNet( jj ); + padname = net.GetPinName(); + + if( footprint->FindPadByName( padname ) ) + continue; // OK, pad found + + // not found: bad footprint, report error + msg.Printf( _( "** Error: Component \"%s\" pad <%s> not found in footprint \"%s\" **\n" ), + GetChars( component->GetReference() ), + GetChars( padname ), + GetChars( footprint->GetLibRef() ) ); + aReporter->Report( msg ); + } + } + } }