Loading CHANGELOG.txt +3 −1 Original line number Diff line number Diff line Loading @@ -11,7 +11,9 @@ email address. ++Eeschema: Note: this is a work in progress! Files modification. More about italic andf bold in fileds in libraries More about italic and bold fields in libraries Use DLIST to handle fields in lib entries Bugs and problems solved in fields edition (some are windows only). 2008-Dec-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> Loading eeschema/class_libentry.cpp +47 −12 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ /**********************************************************/ #include "fctsys.h" #include "gr_basic.h" #include "common.h" #include "program.h" Loading Loading @@ -87,8 +86,6 @@ EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar* CmpName ) : m_Options = ENTRY_NORMAL; m_UnitSelectionLocked = FALSE; m_DrawPinNum = m_DrawPinName = 1; Fields = NULL; m_Prefix.m_FieldId = REFERENCE; } Loading @@ -98,15 +95,6 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct() /******************************************************/ { LibEDA_BaseStruct* DrawItem, * NextDrawItem; LibDrawField* TempField, * field; field = Fields; Fields = NULL; while( field ) { TempField = field; field = field->Next(); SAFE_DELETE( TempField ); } /* suppression des elements dependants */ DrawItem = m_Drawings; m_Drawings = NULL; Loading Loading @@ -279,3 +267,50 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) return BoundaryBox; } /** Function SetFields * initialize fields from a vector of fields * @param aFields a std::vector <LibDrawField> to import. */ void EDA_LibComponentStruct::SetFields( const std::vector <LibDrawField> aFields ) { // Init basic fields (Value = name in lib, and reference): aFields[VALUE].Copy( &m_Name ); aFields[REFERENCE].Copy( &m_Prefix ); // Remove others fields: CurrentLibEntry->m_Fields.DeleteAll(); for( unsigned ii = FOOTPRINT; ii < aFields.size(); ii++ ) { bool create = FALSE; if( !aFields[ii].m_Text.IsEmpty() ) create = TRUE; if( !aFields[ii].m_Name.IsEmpty() && ( aFields[ii].m_Name != ReturnDefaultFieldName( ii ) ) ) create = TRUE; if( create ) { LibDrawField*Field = new LibDrawField( ii ); aFields[ii].Copy( Field ); CurrentLibEntry->m_Fields.PushBack( Field ); } } /* for a user field (FieldId >= FIELD1), if a field value is void, * fill it with "~" because for a library component a void field is not a very good idea * (we do not see anything...) and in schematic this text is like a void text * and for non editable names, remove the name (set to the default name) */ for( LibDrawField* Field = CurrentLibEntry->m_Fields; Field; Field = Field->Next() ) { if( Field->m_FieldId >= FIELD1 ) { if( Field->m_Text.IsEmpty() ) Field->m_Text = wxT( "~" ); } else Field->m_Name.Empty(); } } eeschema/class_libentry.h +3 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ #ifndef CLASS_LIBENTRY_H #define CLASS_LIBENTRY_H #include "dlist.h" #include "classes_body_items.h" #include "class_libentry_fields.h" Loading Loading @@ -71,7 +73,7 @@ public: * with a distance of m_TextInside in mils */ bool m_DrawPinNum; bool m_DrawPinName; LibDrawField* Fields; /* Auxiliairy Field list (id = 2 a 11) */ DLIST<LibDrawField> m_Fields; /* Auxiliairy Field list (id >= 2 ) */ LibEDA_BaseStruct* m_Drawings; /* How to draw this part */ long m_LastDate; // Last change Date Loading eeschema/class_libentry_fields.cpp +39 −8 Original line number Diff line number Diff line Loading @@ -27,11 +27,12 @@ */ LibDrawField::LibDrawField( int idfield ) : LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE ) { m_FieldId = idfield; /* 0 a 11, 0 = REFERENCE, 1 = VALUE*/ if( m_FieldId < 0 ) m_FieldId = 0; if( m_FieldId >= NUMBER_OF_FIELDS ) m_FieldId = NUMBER_OF_FIELDS - 1; m_FieldId = idfield; /* 0 = REFERENCE * 1 = VALUE * 3 = FOOTPRINT (default Footprint) * 4 = DOCUMENTATION (user doc link) * others = free fields */ m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; } Loading Loading @@ -108,3 +109,33 @@ bool LibDrawField::Save( FILE* ExportFile ) const return true; } /****************************************************************/ wxString ReturnDefaultFieldName( int aFieldNdx ) /****************************************************************/ /** Function ReturnDefaultFieldName * Return the default field name from its index (REFERENCE, VALUE ..) * FieldDefaultNameList is not static, because we want the text translation for I18n * @param aFieldNdx = Filed number (>= 0) */ { // avoid unnecessarily copying wxStrings at runtime. static const wxString defaults[] = { _( "Reference" ), // Reference of part, i.e. "IC21" _( "Value" ), // Value of part, i.e. "3.3K" and name in lib for lib entries _( "Footprint" ), // Footprint, used by cvpcb or pcbnew, i.e. "16DIP300" _( "Datasheet" ), // A link to an user document, if wanted }; if( (unsigned) aFieldNdx <= DATASHEET ) return defaults[ aFieldNdx ]; else { wxString ret = _( "Field" ); ret << ( aFieldNdx - FIELD1 + 1); return ret; } } eeschema/class_libentry_fields.h +14 −13 Original line number Diff line number Diff line Loading @@ -13,14 +13,15 @@ * Name (74LS00..) used to find the component in libraries, and give the default value in schematic */ class LibDrawField : public LibEDA_BaseStruct , public EDA_TextStruct class LibDrawField : public LibEDA_BaseStruct, public EDA_TextStruct { public: int m_FieldId; /* 0 a 11 * 0 = Reference; 1 = Value * 2 = Default footprint, 3 = subsheet (not used, reserved) * 4 .. 11 other fields int m_FieldId; /* 0 = REFERENCE * 1 = VALUE * 3 = FOOTPRINT (default Footprint) * 4 = DOCUMENTATION (user doc link) * others = free fields */ wxString m_Name; /* Field Name (not the field text itself, that is .m_Text) */ Loading Loading @@ -51,9 +52,9 @@ public: /** Function Copy * copy parameters of this to Target. Pointers are not copied * @param Target = the LibDrawField to set with "this" values * @param aTarget = the LibDrawField to set with "this" values */ void Copy( LibDrawField* Target ) const; void Copy( LibDrawField* aTarget ) const; void SetFields( const std::vector <LibDrawField> aFields ); Loading Loading
CHANGELOG.txt +3 −1 Original line number Diff line number Diff line Loading @@ -11,7 +11,9 @@ email address. ++Eeschema: Note: this is a work in progress! Files modification. More about italic andf bold in fileds in libraries More about italic and bold fields in libraries Use DLIST to handle fields in lib entries Bugs and problems solved in fields edition (some are windows only). 2008-Dec-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> Loading
eeschema/class_libentry.cpp +47 −12 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ /**********************************************************/ #include "fctsys.h" #include "gr_basic.h" #include "common.h" #include "program.h" Loading Loading @@ -87,8 +86,6 @@ EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar* CmpName ) : m_Options = ENTRY_NORMAL; m_UnitSelectionLocked = FALSE; m_DrawPinNum = m_DrawPinName = 1; Fields = NULL; m_Prefix.m_FieldId = REFERENCE; } Loading @@ -98,15 +95,6 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct() /******************************************************/ { LibEDA_BaseStruct* DrawItem, * NextDrawItem; LibDrawField* TempField, * field; field = Fields; Fields = NULL; while( field ) { TempField = field; field = field->Next(); SAFE_DELETE( TempField ); } /* suppression des elements dependants */ DrawItem = m_Drawings; m_Drawings = NULL; Loading Loading @@ -279,3 +267,50 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) return BoundaryBox; } /** Function SetFields * initialize fields from a vector of fields * @param aFields a std::vector <LibDrawField> to import. */ void EDA_LibComponentStruct::SetFields( const std::vector <LibDrawField> aFields ) { // Init basic fields (Value = name in lib, and reference): aFields[VALUE].Copy( &m_Name ); aFields[REFERENCE].Copy( &m_Prefix ); // Remove others fields: CurrentLibEntry->m_Fields.DeleteAll(); for( unsigned ii = FOOTPRINT; ii < aFields.size(); ii++ ) { bool create = FALSE; if( !aFields[ii].m_Text.IsEmpty() ) create = TRUE; if( !aFields[ii].m_Name.IsEmpty() && ( aFields[ii].m_Name != ReturnDefaultFieldName( ii ) ) ) create = TRUE; if( create ) { LibDrawField*Field = new LibDrawField( ii ); aFields[ii].Copy( Field ); CurrentLibEntry->m_Fields.PushBack( Field ); } } /* for a user field (FieldId >= FIELD1), if a field value is void, * fill it with "~" because for a library component a void field is not a very good idea * (we do not see anything...) and in schematic this text is like a void text * and for non editable names, remove the name (set to the default name) */ for( LibDrawField* Field = CurrentLibEntry->m_Fields; Field; Field = Field->Next() ) { if( Field->m_FieldId >= FIELD1 ) { if( Field->m_Text.IsEmpty() ) Field->m_Text = wxT( "~" ); } else Field->m_Name.Empty(); } }
eeschema/class_libentry.h +3 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ #ifndef CLASS_LIBENTRY_H #define CLASS_LIBENTRY_H #include "dlist.h" #include "classes_body_items.h" #include "class_libentry_fields.h" Loading Loading @@ -71,7 +73,7 @@ public: * with a distance of m_TextInside in mils */ bool m_DrawPinNum; bool m_DrawPinName; LibDrawField* Fields; /* Auxiliairy Field list (id = 2 a 11) */ DLIST<LibDrawField> m_Fields; /* Auxiliairy Field list (id >= 2 ) */ LibEDA_BaseStruct* m_Drawings; /* How to draw this part */ long m_LastDate; // Last change Date Loading
eeschema/class_libentry_fields.cpp +39 −8 Original line number Diff line number Diff line Loading @@ -27,11 +27,12 @@ */ LibDrawField::LibDrawField( int idfield ) : LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE ) { m_FieldId = idfield; /* 0 a 11, 0 = REFERENCE, 1 = VALUE*/ if( m_FieldId < 0 ) m_FieldId = 0; if( m_FieldId >= NUMBER_OF_FIELDS ) m_FieldId = NUMBER_OF_FIELDS - 1; m_FieldId = idfield; /* 0 = REFERENCE * 1 = VALUE * 3 = FOOTPRINT (default Footprint) * 4 = DOCUMENTATION (user doc link) * others = free fields */ m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; } Loading Loading @@ -108,3 +109,33 @@ bool LibDrawField::Save( FILE* ExportFile ) const return true; } /****************************************************************/ wxString ReturnDefaultFieldName( int aFieldNdx ) /****************************************************************/ /** Function ReturnDefaultFieldName * Return the default field name from its index (REFERENCE, VALUE ..) * FieldDefaultNameList is not static, because we want the text translation for I18n * @param aFieldNdx = Filed number (>= 0) */ { // avoid unnecessarily copying wxStrings at runtime. static const wxString defaults[] = { _( "Reference" ), // Reference of part, i.e. "IC21" _( "Value" ), // Value of part, i.e. "3.3K" and name in lib for lib entries _( "Footprint" ), // Footprint, used by cvpcb or pcbnew, i.e. "16DIP300" _( "Datasheet" ), // A link to an user document, if wanted }; if( (unsigned) aFieldNdx <= DATASHEET ) return defaults[ aFieldNdx ]; else { wxString ret = _( "Field" ); ret << ( aFieldNdx - FIELD1 + 1); return ret; } }
eeschema/class_libentry_fields.h +14 −13 Original line number Diff line number Diff line Loading @@ -13,14 +13,15 @@ * Name (74LS00..) used to find the component in libraries, and give the default value in schematic */ class LibDrawField : public LibEDA_BaseStruct , public EDA_TextStruct class LibDrawField : public LibEDA_BaseStruct, public EDA_TextStruct { public: int m_FieldId; /* 0 a 11 * 0 = Reference; 1 = Value * 2 = Default footprint, 3 = subsheet (not used, reserved) * 4 .. 11 other fields int m_FieldId; /* 0 = REFERENCE * 1 = VALUE * 3 = FOOTPRINT (default Footprint) * 4 = DOCUMENTATION (user doc link) * others = free fields */ wxString m_Name; /* Field Name (not the field text itself, that is .m_Text) */ Loading Loading @@ -51,9 +52,9 @@ public: /** Function Copy * copy parameters of this to Target. Pointers are not copied * @param Target = the LibDrawField to set with "this" values * @param aTarget = the LibDrawField to set with "this" values */ void Copy( LibDrawField* Target ) const; void Copy( LibDrawField* aTarget ) const; void SetFields( const std::vector <LibDrawField> aFields ); Loading