eagle: Interpret overline in texts

CHANGED: Overline in Eagle boards are correctly imported
This commit is contained in:
Jan Mrázek 2020-08-04 16:25:08 +02:00
parent aa8fb38445
commit 1c9cae0b06
No known key found for this signature in database
GPG Key ID: A3E71126F180EB6F
1 changed files with 56 additions and 1 deletions

View File

@ -114,6 +114,60 @@ static wxString makeKey( const wxString& aFirst, const wxString& aSecond )
return key; return key;
} }
/// interpret special characters in Eagle text and converts them to KiCAD notation
static wxString interpret_text( const wxString& aText )
{
wxString text;
bool sectionOpen = false;
for ( wxString::size_type i = 0; i < aText.size(); i++ ) {
// Interpret escaped characters
if ( aText[ i ] == '\\' ) {
if ( i + 1 != aText.size() )
text.Append( aText[ i + 1 ] );
i++;
continue;
}
// Escape ~ for KiCAD
if( aText[i] == '~' )
{
text.Append( '~' );
text.Append( '~' );
continue;
}
if ( aText[ i ] == '!' ) {
if ( sectionOpen ) {
text.Append( '~' );
sectionOpen = false;
continue;
}
static wxString escapeChars( " )]}'\"" );
if( i + 1 != aText.size() && escapeChars.Find( aText[i + 1] ) == wxNOT_FOUND )
{
sectionOpen = true;
text.Append( '~' );
}
else
{
text.Append( aText[ i ] );
}
continue;
}
if( aText[i] == ',' && sectionOpen )
{
text.Append( '~' );
sectionOpen = false;
}
text.Append( aText[ i ] );
}
return text;
}
static void setKeepoutSettingsToZone( ZONE_CONTAINER* aZone, LAYER_NUM aLayer ) static void setKeepoutSettingsToZone( ZONE_CONTAINER* aZone, LAYER_NUM aLayer )
{ {
@ -575,7 +629,8 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
m_board->Add( pcbtxt, ADD_MODE::APPEND ); m_board->Add( pcbtxt, ADD_MODE::APPEND );
pcbtxt->SetLayer( layer ); pcbtxt->SetLayer( layer );
pcbtxt->SetText( FROM_UTF8( t.text.c_str() ) ); wxString kicadText = interpret_text( t.text );
pcbtxt->SetText( FROM_UTF8( kicadText.c_str() ) );
pcbtxt->SetTextPos( wxPoint( kicad_x( t.x ), kicad_y( t.y ) ) ); pcbtxt->SetTextPos( wxPoint( kicad_x( t.x ), kicad_y( t.y ) ) );
double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default