From a86385bf905c31bce5d4367e785c2ea430ee8aaf Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 8 Feb 2011 13:01:14 +0100 Subject: [PATCH] Eeschema: fix bug 714835. Add electrical pin type in intermediate netlist file. Use non translated fields names in intermediate netlist file because they are keyword in this file. Change intermediate netlist file extension from .tmp to .xml --- eeschema/lib_field.cpp | 27 ++++++++++++++++++++++----- eeschema/lib_field.h | 5 ++++- eeschema/lib_pin.h | 14 +++++++++++++- eeschema/netform.cpp | 18 ++++++++++++------ eeschema/netlist_control.cpp | 6 +++++- 5 files changed, 56 insertions(+), 14 deletions(-) diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 92dae94045..00ba5e5cd0 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -569,31 +569,48 @@ void LIB_FIELD::Rotate() } -wxString LIB_FIELD::GetName() const +wxString LIB_FIELD::GetName(bool aTranslate) const { wxString name; switch( m_id ) { case REFERENCE: - name = _( "Reference" ); + if( aTranslate ) + name = _( "Reference" ); + else + name = wxT( "Reference" ); break; case VALUE: - name = _( "Value" ); + if( aTranslate ) + name = _( "Value" ); + else + name = wxT( "Value" ); break; case FOOTPRINT: - name = _( "Footprint" ); + if( aTranslate ) + name = _( "Footprint" ); + else + name = wxT( "Footprint" ); break; case DATASHEET: - name = _( "Datasheet" ); + if( aTranslate ) + name = _( "Datasheet" ); + else + name = wxT( "Datasheet" ); break; default: if( m_name.IsEmpty() ) + { + if( aTranslate ) name.Printf( _( "Field%d" ), m_id ); + else + name.Printf( wxT( "Field%d" ), m_id ); + } else name = m_name; } diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index e438dd4f17..74f072f2bd 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -61,9 +61,12 @@ public: * names. The user definable fields will return FieldN where N is the ID of the field * when the m_name member is empty. * + * @param aTranslate = true to return translated field name (default) + * false to return the english name + * (usefull when the name is used as keyword in netlists ...) * @return Name of the field. */ - wxString GetName() const; + wxString GetName(bool aTranslate = true) const; /** * Function SetName diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index 236655dfcb..be775ea419 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -254,15 +254,27 @@ public: */ void SetShape( int aShape ); + /** + * Get the electrical type of the pin. + * + * @return The electrical type of the pin (see enun ElectricPinType for values). + */ int GetType() const { return m_type; } + /** + * return a string giving the electrical type of the pin. + * + * @return The electrical name of the pin (see enun MsgPinElectricType for names). + */ + wxString GetTypeString() const { return MsgPinElectricType[m_type]; } + /** * Set the electrical type of the pin. * * This will also update the electrical type of the pins marked by * EnableEditMode(). * - * @param aType - The electrical type of the pin. + * @param aType - The electrical type of the pin(see enun ElectricPinType for values). */ void SetType( int aType ); diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 3b14d4896a..5a19713ceb 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -31,7 +31,6 @@ #include "fctsys.h" -#include "gr_basic.h" #include "common.h" #include "confirm.h" #include "kicad_string.h" @@ -55,6 +54,8 @@ #include "build_version.h" +#define INTERMEDIATE_NETLIST_EXT wxT("xml") + #include /** @@ -406,7 +407,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam default: { wxFileName tmpFile = aFullFileName; - tmpFile.SetExt( wxT( "tmp" ) ); + tmpFile.SetExt( INTERMEDIATE_NETLIST_EXT ); D(printf("tmpFile:'%s'\n", CONV_TO_UTF8( tmpFile.GetFullPath() ) );) @@ -611,6 +612,9 @@ SCH_COMPONENT* EXPORT_HELP::findNextComponentAndCreatPinList( EDA_ITEM* aI // Remove duplicate Pins in m_SortedComponentPinList eraseDuplicatePins( m_SortedComponentPinList ); + // record the usage of this library component entry. + m_LibParts.insert( entry ); // rejects non-unique pointers + return comp; } @@ -705,9 +709,10 @@ XNODE* EXPORT_HELP::makeGenericLibParts() wxString sLibpart = wxT( "libpart" ); wxString sLib = wxT( "lib" ); wxString sPart = wxT( "part" ); - wxString sPins = wxT( "pins" ); - wxString sPin = wxT( "pin" ); - wxString sNum = wxT( "num" ); + wxString sPins = wxT( "pins" ); // key for library component pins list + wxString sPin = wxT( "pin" ); // key for one library component pin descr + wxString sNum = wxT( "num" ); // key for one library component pin num + wxString sPinType = wxT( "type" ); // key for one library component pin electrical type wxString sName = wxT( "name" ); wxString sField = wxT( "field" ); wxString sFields = wxT( "fields" ); @@ -765,7 +770,7 @@ XNODE* EXPORT_HELP::makeGenericLibParts() { XNODE* xfield; xfields->AddChild( xfield = node( sField, fieldList[i].m_Text ) ); - xfield->AddAttribute( sName, fieldList[i].GetName() ); + xfield->AddAttribute( sName, fieldList[i].GetName(false) ); } } @@ -786,6 +791,7 @@ XNODE* EXPORT_HELP::makeGenericLibParts() pins->AddChild( pin = node( sPin ) ); pin->AddAttribute( sNum, pinList[i]->GetNumberString() ); + pin->AddAttribute( sPinType, pinList[i]->GetTypeString() ); // caution: construction work site here, drive slowly } diff --git a/eeschema/netlist_control.cpp b/eeschema/netlist_control.cpp index bba903507a..362d32f344 100644 --- a/eeschema/netlist_control.cpp +++ b/eeschema/netlist_control.cpp @@ -372,7 +372,11 @@ void WinEDA_NetlistFrame::SetupPluginData( wxCommandEvent& event ) if( CurrPage == NULL ) return; - CurrPage->m_CommandStringCtrl->SetValue( FullFileName ); + // Creates a default command line, suitable for external tool xslproc: + // TODO: build better default command lines depending on plugin extension + wxString cmdLine; + cmdLine.Printf(wxT("xsltproc -o %%O %s %%I"), GetChars(FullFileName) ); + CurrPage->m_CommandStringCtrl->SetValue( cmdLine ); /* Get a title for this page */ wxString title = CurrPage->m_TitleStringCtrl->GetValue();