From b77ba486eccb1ab64006daa0549d484d2f78bbf7 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 18 Oct 2017 10:33:51 +0200 Subject: [PATCH] Eeschema Eagle Import: fixed name and reference fields placement --- eeschema/sch_eagle_plugin.cpp | 45 ++++++++++++++++++----------------- eeschema/sch_eagle_plugin.h | 2 ++ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 6fc3ca8159..12672bfcf0 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -1368,28 +1368,17 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, { std::unique_ptr libtext( loadSymbolText( aPart, currentNode, aGateNumber ) ); - LIB_FIELD* field; - - if( libtext->GetText().Upper() ==">NAME" || libtext->GetText().Upper() == ">VALUE" ) + if( libtext->GetText().Upper() ==">NAME" ) { - if( libtext->GetText().Upper() ==">NAME" ) - { - field = aPart->GetField( REFERENCE ); - foundName = true; - } - else - { - field = aPart->GetField( REFERENCE ); - foundValue = true; - } - - field->SetTextPos( libtext->GetPosition() ); - field->SetTextSize( libtext->GetTextSize() ); - field->SetTextAngle( libtext->GetTextAngle() ); - field->SetBold( libtext->IsBold() ); - field->SetVertJustify( libtext->GetVertJustify() ); - field->SetHorizJustify( libtext->GetHorizJustify() ); - field->SetVisible( true ); + LIB_FIELD* field = aPart->GetField( REFERENCE ); + loadFieldAttributes( field, libtext.get() ); + foundName = true; + } + else if( libtext->GetText().Upper() ==">VALUE" ) + { + LIB_FIELD* field = aPart->GetField( VALUE ); + loadFieldAttributes( field, libtext.get() ); + foundValue = true; } else { @@ -1630,7 +1619,7 @@ LIB_PIN* SCH_EAGLE_PLUGIN::loadPin( std::unique_ptr& aPart, } } - // emaulate the visibility of pin elements + // emulate the visibility of pin elements if( aEPin->visible ) { wxString visible = aEPin->visible.Get(); @@ -1730,6 +1719,18 @@ void SCH_EAGLE_PLUGIN::loadTextAttributes( EDA_TEXT* aText, const ETEXT& aAttrib } +void SCH_EAGLE_PLUGIN::loadFieldAttributes( LIB_FIELD* aField, const LIB_TEXT* aText ) const +{ + aField->SetTextPos( aText->GetPosition() ); + aField->SetTextSize( aText->GetTextSize() ); + aField->SetTextAngle( aText->GetTextAngle() ); + aField->SetBold( aText->IsBold() ); + aField->SetVertJustify( aText->GetVertJustify() ); + aField->SetHorizJustify( aText->GetHorizJustify() ); + aField->SetVisible( true ); +} + + bool SCH_EAGLE_PLUGIN::CheckHeader( const wxString& aFileName ) { // Open file and check first line diff --git a/eeschema/sch_eagle_plugin.h b/eeschema/sch_eagle_plugin.h index 2610ef26b3..50c57f7c31 100644 --- a/eeschema/sch_eagle_plugin.h +++ b/eeschema/sch_eagle_plugin.h @@ -53,6 +53,7 @@ class LIB_PART; class PART_LIB; class LIB_ALIAS; class LIB_CIRCLE; +class LIB_FIELD; class LIB_RECTANGLE; class LIB_POLYLINE; class LIB_PIN; @@ -169,6 +170,7 @@ private: LIB_TEXT* loadSymbolText( std::unique_ptr& aPart, wxXmlNode* aLibText, int aGateNumber ); void loadTextAttributes( EDA_TEXT* aText, const ETEXT& aAttribs ) const; + void loadFieldAttributes( LIB_FIELD* aField, const LIB_TEXT* aText ) const; KIWAY* m_kiway; ///< For creating sub sheets. SCH_SHEET* m_rootSheet; ///< The root sheet of the schematic being loaded..