Made support for multiple equ. matches in CVPCB:
- first, matches are now filtered with component filters (as set in eeschema lib editor); - second, if two or more matches exist, first one will be accepted in accordance to alias file order set in project prefs, and then to order of lines in file. For example you may have such configuration .equ: '100' 'CAP100' '100' 'RES300' C component have filter 'CAP*' R component have filter 'RES*' So R with value 100 (IEEE/ESKD short for 100 Ohm) will get 'RES300' footprint, and C with value 100 (IEEE/ESKD short for 100 pF) will get 'CAP100'. Also equ read routine is rewritten so it is now gracefully accept UTF-8 and spaces.
This commit is contained in:
parent
95388c6ec4
commit
6751777885
|
@ -35,27 +35,15 @@ typedef boost::ptr_vector< FOOTPRINT_ALIAS > FOOTPRINT_ALIAS_LIST;
|
||||||
* 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)
|
||||||
*/
|
*/
|
||||||
char * ReadQuotedText(wxString & aTarget, char * aText)
|
wxString GetQuotedText( wxString & text )
|
||||||
{
|
{
|
||||||
// search the first quote:
|
int i = text.Find( QUOTE );
|
||||||
for( ; *aText != 0; aText++ )
|
if( wxNOT_FOUND == i ) return wxT( "" );
|
||||||
{
|
wxString shrt = text.Mid( i + 1 );
|
||||||
if( *aText == QUOTE )
|
i = shrt.Find( QUOTE );
|
||||||
break;
|
if( wxNOT_FOUND == i ) return wxT( "" );
|
||||||
}
|
text = shrt.Mid( i + 1 );
|
||||||
|
return shrt.Mid( 0, i );
|
||||||
if ( *aText == 0 )
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
aText++;
|
|
||||||
for(; *aText != 0; aText++ )
|
|
||||||
{
|
|
||||||
if( *aText == QUOTE )
|
|
||||||
break;
|
|
||||||
aTarget.Append(*aText);
|
|
||||||
}
|
|
||||||
|
|
||||||
return aText;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,24 +96,24 @@ found in the default search paths." ),
|
||||||
while( GetLine( file, Line, NULL, sizeof(Line) ) != NULL )
|
while( GetLine( file, Line, NULL, sizeof(Line) ) != NULL )
|
||||||
{
|
{
|
||||||
char* text = Line;
|
char* text = Line;
|
||||||
wxString value, footprint;
|
wxString value, footprint, wtext = FROM_UTF8( Line );
|
||||||
|
|
||||||
text = ReadQuotedText( value, text );
|
value = GetQuotedText( wtext );
|
||||||
|
|
||||||
if( text == NULL || ( *text == 0 ) || value.IsEmpty() )
|
if( text == NULL || ( *text == 0 ) || value.IsEmpty() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
text++;
|
footprint = GetQuotedText( wtext );
|
||||||
text = ReadQuotedText( footprint, text );
|
|
||||||
|
|
||||||
if( footprint.IsEmpty() )
|
if( footprint.IsEmpty() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
value.Replace( wxT( " " ), wxT( "_" ) );
|
||||||
|
|
||||||
alias = new FOOTPRINT_ALIAS();
|
alias = new FOOTPRINT_ALIAS();
|
||||||
alias->m_Name = value;
|
alias->m_Name = value;
|
||||||
alias->m_FootprintName = footprint;
|
alias->m_FootprintName = footprint;
|
||||||
aliases.push_back( alias );
|
aliases.push_back( alias );
|
||||||
text++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose( file );
|
fclose( file );
|
||||||
|
@ -146,13 +134,24 @@ found in the default search paths." ),
|
||||||
|
|
||||||
BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases )
|
BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases )
|
||||||
{
|
{
|
||||||
|
bool found = false;
|
||||||
if( alias.m_Name.CmpNoCase( component.m_Value ) != 0 )
|
if( alias.m_Name.CmpNoCase( component.m_Value ) != 0 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( m_footprints.GetModuleInfo( alias.m_FootprintName ) )
|
/* filter alias so one can use multiple aliases (for polar and nonpolar caps for example) */
|
||||||
SetNewPkg( alias.m_FootprintName );
|
FOOTPRINT_INFO *module = m_footprints.GetModuleInfo( alias.m_FootprintName );
|
||||||
|
|
||||||
if( component.m_Module.IsEmpty() )
|
if( module )
|
||||||
|
{
|
||||||
|
size_t filtercount = component.m_FootprintFilter.GetCount();
|
||||||
|
found = ( 0 == filtercount ); // if no entries, do not filter
|
||||||
|
|
||||||
|
for( int jj = 0; jj < filtercount && !found; jj++ )
|
||||||
|
{
|
||||||
|
found = module->m_Module.Matches( component.m_FootprintFilter[jj] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Component %s: footprint %s not found in \
|
msg.Printf( _( "Component %s: footprint %s not found in \
|
||||||
any of the project footprint libraries." ),
|
any of the project footprint libraries." ),
|
||||||
|
@ -161,6 +160,12 @@ any of the project footprint libraries." ),
|
||||||
wxMessageBox( msg, _( "CVPcb Error" ), wxOK | wxICON_ERROR,
|
wxMessageBox( msg, _( "CVPcb Error" ), wxOK | wxICON_ERROR,
|
||||||
this );
|
this );
|
||||||
}
|
}
|
||||||
|
if( found )
|
||||||
|
{
|
||||||
|
SetNewPkg( alias.m_FootprintName );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue