Cvpcb: auto-selection of footprints: better algo to find a candidate.
This commit is contained in:
parent
ee5565ae33
commit
1f1438947f
|
@ -53,7 +53,7 @@
|
||||||
* put text in aTarget
|
* put text in aTarget
|
||||||
* return a pointer to the last read char (the second quote if OK)
|
* return a pointer to the last read char (the second quote if OK)
|
||||||
*/
|
*/
|
||||||
wxString GetQuotedText( wxString & text )
|
wxString GetQuotedText( wxString& text )
|
||||||
{
|
{
|
||||||
int i = text.Find( QUOTE );
|
int i = text.Find( QUOTE );
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ bool sortListbyCmpValue( const FOOTPRINT_EQUIVALENCE& ref, const FOOTPRINT_EQUIV
|
||||||
// read the .equ files and populate the list of equivalents
|
// read the .equ files and populate the list of equivalents
|
||||||
int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wxString * aErrorMessages )
|
int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wxString * aErrorMessages )
|
||||||
{
|
{
|
||||||
char Line[1024];
|
char line[1024];
|
||||||
int error_count = 0;
|
int error_count = 0;
|
||||||
FILE* file;
|
FILE* file;
|
||||||
wxFileName fn;
|
wxFileName fn;
|
||||||
|
@ -136,17 +136,18 @@ int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wx
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
while( GetLine( file, Line, NULL, sizeof(Line) ) != NULL )
|
while( GetLine( file, line, NULL, sizeof( line ) ) != NULL )
|
||||||
{
|
{
|
||||||
char* text = Line;
|
if( *line == 0 )
|
||||||
wxString value, footprint, wtext = FROM_UTF8( Line );
|
|
||||||
|
|
||||||
value = GetQuotedText( wtext );
|
|
||||||
|
|
||||||
if( text == NULL || ( *text == 0 ) || value.IsEmpty() )
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
footprint = GetQuotedText( wtext );
|
wxString wtext = FROM_UTF8( line );
|
||||||
|
wxString value = GetQuotedText( wtext );
|
||||||
|
|
||||||
|
if( value.IsEmpty() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
wxString footprint = GetQuotedText( wtext );
|
||||||
|
|
||||||
if( footprint.IsEmpty() )
|
if( footprint.IsEmpty() )
|
||||||
continue;
|
continue;
|
||||||
|
@ -204,6 +205,8 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching( wxCommandEvent& event )
|
||||||
// When happens, using the footprint filter of components can remove the ambiguity by
|
// When happens, using the footprint filter of components can remove the ambiguity by
|
||||||
// filtering equivItem so one can use multiple equiv_List (for polar and
|
// filtering equivItem so one can use multiple equiv_List (for polar and
|
||||||
// non-polar caps for example)
|
// non-polar caps for example)
|
||||||
|
wxString fpid_candidate;
|
||||||
|
|
||||||
for( unsigned idx = 0; idx < equiv_List.size(); idx++ )
|
for( unsigned idx = 0; idx < equiv_List.size(); idx++ )
|
||||||
{
|
{
|
||||||
FOOTPRINT_EQUIVALENCE& equivItem = equiv_List[idx];
|
FOOTPRINT_EQUIVALENCE& equivItem = equiv_List[idx];
|
||||||
|
@ -233,8 +236,14 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching( wxCommandEvent& event )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store the first candidate found in list, when equivalence is not unique
|
||||||
|
// We use it later.
|
||||||
|
if( module && fpid_candidate.IsEmpty() )
|
||||||
|
fpid_candidate = equivItem.m_FootprintFPID;
|
||||||
|
|
||||||
// The equivalence is not unique: use the footprint filter to try to remove
|
// The equivalence is not unique: use the footprint filter to try to remove
|
||||||
// ambiguity
|
// ambiguity
|
||||||
|
// if the footprint filter does not remove ambiguity, we will use fpid_candidate
|
||||||
if( module )
|
if( module )
|
||||||
{
|
{
|
||||||
size_t filtercount = component->GetFootprintFilters().GetCount();
|
size_t filtercount = component->GetFootprintFilters().GetCount();
|
||||||
|
@ -267,6 +276,11 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching( wxCommandEvent& event )
|
||||||
|
|
||||||
if( found )
|
if( found )
|
||||||
continue;
|
continue;
|
||||||
|
else if( !fpid_candidate.IsEmpty() )
|
||||||
|
{
|
||||||
|
SetNewPkg( fpid_candidate, kk );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// obviously the last chance: there's only one filter matching one footprint
|
// obviously the last chance: there's only one filter matching one footprint
|
||||||
if( 1 == component->GetFootprintFilters().GetCount() )
|
if( 1 == component->GetFootprintFilters().GetCount() )
|
||||||
|
|
Loading…
Reference in New Issue