diff --git a/common/eagle_parser.cpp b/common/eagle_parser.cpp index 60aa526120..3491b5816c 100644 --- a/common/eagle_parser.cpp +++ b/common/eagle_parser.cpp @@ -886,6 +886,41 @@ EPART::EPART( wxXmlNode* aPart ) device = parseRequiredAttribute( aPart, "device" ); technology = parseOptionalAttribute( aPart, "technology" ); value = parseOptionalAttribute( aPart, "value" ); + + for( auto child = aPart->GetChildren(); child; child = child->GetNext() ) + { + + if( child->GetName() == "attribute" ) + { + std::string aname, avalue; + for( auto x = child->GetAttributes(); x; x = x->GetNext() ) + { + + if( x->GetName() == "name" ) + aname = x->GetValue(); + else if( x->GetName() == "value" ) + avalue = x->GetValue(); + } + + if( aname.size() && avalue.size() ) + attribute[aname] = avalue; + } + else if( child->GetName() == "variant" ) + { + std::string aname, avalue; + for( auto x = child->GetAttributes(); x; x = x->GetNext() ) + { + + if( x->GetName() == "name" ) + aname = x->GetValue(); + else if( x->GetName() == "value" ) + avalue = x->GetValue(); + } + + if( aname.size() && avalue.size() ) + variant[aname] = avalue; + } + } } diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 0b36e1f257..c83f75a6aa 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -1142,6 +1142,22 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode ) component->GetField( REFERENCE )->SetVisible( part->GetField( REFERENCE )->IsVisible() ); component->GetField( VALUE )->SetVisible( part->GetField( VALUE )->IsVisible() ); + for( auto a:epart->attribute ) + { + auto field = component->AddField( *component->GetField( VALUE ) ); + field->SetName( a.first ); + field->SetText( a.second ); + field->SetVisible( false ); + } + + for( auto a:epart->variant ) + { + auto field = component->AddField( *component->GetField( VALUE ) ); + field->SetName( "VARIANT_" + a.first ); + field->SetText( a.second ); + field->SetVisible( false ); + } + bool valueAttributeFound = false; bool nameAttributeFound = false; @@ -1154,21 +1170,28 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode ) if( attributeNode->GetName() == "attribute" ) { auto attr = EATTR( attributeNode ); + SCH_FIELD* field = NULL; - SCH_FIELD* field; - - if( attr.name.Lower() == "name" || attr.name.Lower() == "value" ) + if( attr.name.Lower() == "name" ) + { + field = component->GetField( REFERENCE ); + nameAttributeFound = true; + } + else if( attr.name.Lower() == "value" ) + { + field = component->GetField( VALUE ); + valueAttributeFound = true; + } + else + { + field = component->FindField( attr.name ); + + if(field) + field->SetVisible( false ); + } + + if( field ) { - if( attr.name.Lower() == "name" ) - { - field = component->GetField( REFERENCE ); - nameAttributeFound = true; - } - else - { - field = component->GetField( VALUE ); - valueAttributeFound = true; - } field->SetPosition( wxPoint( attr.x->ToSchUnits(), -attr.y->ToSchUnits() ) ); int align = attr.align ? *attr.align : ETEXT::BOTTOM_LEFT; @@ -1191,6 +1214,19 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode ) absdegrees ); } } + else if( attributeNode->GetName() == "variant" ) + { + wxString variant, value; + + if( attributeNode->GetAttribute( "name", &variant ) + && attributeNode->GetAttribute( "value", &value ) ) + { + auto field = component->AddField( *component->GetField( VALUE ) ); + field->SetName( "VARIANT_" + variant ); + field->SetText( value ); + field->SetVisible( false ); + } + } attributeNode = attributeNode->GetNext(); } diff --git a/include/eagle_parser.h b/include/eagle_parser.h index 257aa2e6a5..59f74ccaef 100644 --- a/include/eagle_parser.h +++ b/include/eagle_parser.h @@ -913,6 +913,8 @@ struct EPART wxString device; opt_wxString technology; opt_wxString value; + std::map attribute; + std::map variant; EPART( wxXmlNode* aPart ); };