Loading eeschema/dialogs/dialog_edit_component_in_schematic.cpp +13 −13 Original line number Original line Diff line number Diff line Loading @@ -236,14 +236,14 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event // Delete any fields with no name before we copy all of m_FieldsBuf back into the component. // Delete any fields with no name before we copy all of m_FieldsBuf back into the component. for( unsigned i = MANDATORY_FIELDS; i<m_FieldsBuf.size(); ) for( unsigned i = MANDATORY_FIELDS; i<m_FieldsBuf.size(); ) { { if( m_FieldsBuf[i].m_Name.IsEmpty() || m_FieldsBuf[i].m_Text.IsEmpty() ) if( m_FieldsBuf[i].GetName( false ).IsEmpty() || m_FieldsBuf[i].GetText().IsEmpty() ) { { // If a field has no value and is not it the field template list, warn the user // If a field has no value and is not it the field template list, warn the user // that it will be remove from the component. This gives the user a chance to // that it will be remove from the component. This gives the user a chance to // correct the problem before removing the undefined fields. It should also // correct the problem before removing the undefined fields. It should also // resolve most of the bug reports and questions regarding missing fields. // resolve most of the bug reports and questions regarding missing fields. if( !m_FieldsBuf[i].m_Name.IsEmpty() && m_FieldsBuf[i].m_Text.IsEmpty() if( !m_FieldsBuf[i].GetName( false ).IsEmpty() && m_FieldsBuf[i].GetText().IsEmpty() && !m_Parent->GetTemplates().HasFieldName( m_FieldsBuf[i].m_Name ) && !m_Parent->GetTemplates().HasFieldName( m_FieldsBuf[i].GetName( false ) ) && !removeRemainingFields ) && !removeRemainingFields ) { { wxString msg; wxString msg; Loading @@ -251,7 +251,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event msg.Printf( _( "The field name <%s> does not have a value and is not defined in \ msg.Printf( _( "The field name <%s> does not have a value and is not defined in \ the field template list. Empty field values are invalid an will be removed from the component. \ the field template list. Empty field values are invalid an will be removed from the component. \ Do you wish to remove this and all remaining undefined fields?" ), Do you wish to remove this and all remaining undefined fields?" ), GetChars( m_FieldsBuf[i].m_Name ) ); GetChars( m_FieldsBuf[i].GetName( false ) ) ); wxMessageDialog dlg( this, msg, _( "Remove Fields" ), wxYES_NO | wxNO_DEFAULT ); wxMessageDialog dlg( this, msg, _( "Remove Fields" ), wxYES_NO | wxNO_DEFAULT ); Loading Loading @@ -303,7 +303,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent& blank.m_Orient = m_FieldsBuf[REFERENCE].m_Orient; blank.m_Orient = m_FieldsBuf[REFERENCE].m_Orient; m_FieldsBuf.push_back( blank ); m_FieldsBuf.push_back( blank ); m_FieldsBuf[fieldNdx].m_Name = TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ); m_FieldsBuf[fieldNdx].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ) ); m_skipCopyFromPanel = true; m_skipCopyFromPanel = true; setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] ); setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] ); Loading Loading @@ -361,7 +361,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler( wxCommandEvent& ev SCH_FIELD tmp = m_FieldsBuf[fieldNdx - 1]; SCH_FIELD tmp = m_FieldsBuf[fieldNdx - 1]; D( printf( "tmp.m_Text=\"%s\" tmp.m_Name=\"%s\"\n", D( printf( "tmp.m_Text=\"%s\" tmp.m_Name=\"%s\"\n", TO_UTF8( tmp.m_Text ), TO_UTF8( tmp.m_Name ) ); ) TO_UTF8( tmp.m_Text ), TO_UTF8( tmp.GetName( false ) ) ); ) m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx]; m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx]; setRowItem( fieldNdx - 1, m_FieldsBuf[fieldNdx] ); setRowItem( fieldNdx - 1, m_FieldsBuf[fieldNdx] ); Loading Loading @@ -408,7 +408,7 @@ SCH_FIELD* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::findField( const wxString& aField { { for( unsigned i=0; i<m_FieldsBuf.size(); ++i ) for( unsigned i=0; i<m_FieldsBuf.size(); ++i ) { { if( aFieldName == m_FieldsBuf[i].m_Name ) if( aFieldName == m_FieldsBuf[i].GetName( false ) ) return &m_FieldsBuf[i]; return &m_FieldsBuf[i]; } } Loading Loading @@ -499,7 +499,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent for( unsigned i=MANDATORY_FIELDS; i<aComponent->m_Fields.size(); ++i ) for( unsigned i=MANDATORY_FIELDS; i<aComponent->m_Fields.size(); ++i ) { { SCH_FIELD* cmp = &aComponent->m_Fields[i]; SCH_FIELD* cmp = &aComponent->m_Fields[i]; SCH_FIELD* buf = findField( cmp->m_Name ); SCH_FIELD* buf = findField( cmp->GetName( false ) ); if( !buf ) if( !buf ) { { Loading @@ -516,7 +516,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent for( unsigned i = 0; i<m_FieldsBuf.size(); ++i ) for( unsigned i = 0; i<m_FieldsBuf.size(); ++i ) { { printf( "m_FieldsBuf[%d] (x=%-3d, y=%-3d) name:%s\n", i, m_FieldsBuf[i].m_Pos.x, printf( "m_FieldsBuf[%d] (x=%-3d, y=%-3d) name:%s\n", i, m_FieldsBuf[i].m_Pos.x, m_FieldsBuf[i].m_Pos.y, TO_UTF8(m_FieldsBuf[i].m_Name) ); m_FieldsBuf[i].m_Pos.y, TO_UTF8(m_FieldsBuf[i].GetName( false ) ) ); } } #endif #endif Loading Loading @@ -560,8 +560,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const SCH_FI fieldListCtrl->SetItem( ndx, 1, wxEmptyString ); fieldListCtrl->SetItem( ndx, 1, wxEmptyString ); } } fieldListCtrl->SetItem( aFieldNdx, 0, aField.m_Name ); fieldListCtrl->SetItem( aFieldNdx, 0, aField.GetName( false ) ); fieldListCtrl->SetItem( aFieldNdx, 1, aField.m_Text ); fieldListCtrl->SetItem( aFieldNdx, 1, aField.GetText() ); // recompute the column widths here, after setting texts // recompute the column widths here, after setting texts fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE ); fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE ); Loading Loading @@ -608,7 +608,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() m_FieldVJustifyCtrl->SetSelection(1); m_FieldVJustifyCtrl->SetSelection(1); fieldNameTextCtrl->SetValue( field.m_Name ); fieldNameTextCtrl->SetValue( field.GetName( false ) ); // the names of the fixed fields are not editable, others are. // the names of the fixed fields are not editable, others are. fieldNameTextCtrl->Enable( fieldNdx >= MANDATORY_FIELDS ); fieldNameTextCtrl->Enable( fieldNdx >= MANDATORY_FIELDS ); Loading Loading @@ -698,7 +698,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField() field.m_HJustify = hjustify[m_FieldHJustifyCtrl->GetSelection()]; field.m_HJustify = hjustify[m_FieldHJustifyCtrl->GetSelection()]; field.m_VJustify = vjustify[m_FieldVJustifyCtrl->GetSelection()]; field.m_VJustify = vjustify[m_FieldVJustifyCtrl->GetSelection()]; field.m_Name = fieldNameTextCtrl->GetValue(); field.SetName( fieldNameTextCtrl->GetValue() ); /* Void fields texts for REFERENCE and VALUE (value is the name of the /* Void fields texts for REFERENCE and VALUE (value is the name of the * component in lib ! ) are not allowed * component in lib ! ) are not allowed Loading eeschema/edit_component_in_schematic.cpp +3 −3 Original line number Original line Diff line number Diff line Loading @@ -77,7 +77,7 @@ create a new power component with the new value." ), GetChars( entry->GetName() DrawPanel->m_IgnoreMouseEvents = true; DrawPanel->m_IgnoreMouseEvents = true; wxString title; wxString title; title.Printf( _( "Edit %s Field" ), GetChars( aField->m_Name ) ); title.Printf( _( "Edit %s Field" ), GetChars( aField->GetName() ) ); wxTextEntryDialog dlg( this, wxEmptyString , title, newtext ); wxTextEntryDialog dlg( this, wxEmptyString , title, newtext ); int response = dlg.ShowModal(); int response = dlg.ShowModal(); Loading @@ -95,7 +95,7 @@ create a new power component with the new value." ), GetChars( entry->GetName() if( !newtext.IsEmpty() ) if( !newtext.IsEmpty() ) { { if( aField->m_Text.IsEmpty() ) // Means the field was not already in use if( aField->GetText().IsEmpty() ) // Means the field was not already in use { { aField->m_Pos = component->GetPosition(); aField->m_Pos = component->GetPosition(); aField->m_Size.x = aField->m_Size.y = m_TextFieldSize; aField->m_Size.x = aField->m_Size.y = m_TextFieldSize; Loading @@ -107,7 +107,7 @@ create a new power component with the new value." ), GetChars( entry->GetName() if( SCH_COMPONENT::IsReferenceStringValid( newtext ) ) if( SCH_COMPONENT::IsReferenceStringValid( newtext ) ) { { component->SetRef( GetSheet(), newtext ); component->SetRef( GetSheet(), newtext ); aField->m_Text = newtext; aField->SetText( newtext ); } } else else { { Loading eeschema/netform.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -1010,11 +1010,11 @@ XNODE* EXPORT_HELP::makeGenericComponents() SCH_FIELD* f = comp->GetField( fldNdx ); SCH_FIELD* f = comp->GetField( fldNdx ); // only output a field if non empty // only output a field if non empty if( !f->m_Text.IsEmpty() ) if( !f->GetText().IsEmpty() ) { { XNODE* xfield; XNODE* xfield; xfields->AddChild( xfield = node( sField, f->m_Text ) ); xfields->AddChild( xfield = node( sField, f->m_Text ) ); xfield->AddAttribute( sName, f->m_Name ); xfield->AddAttribute( sName, f->GetName() ); } } } } } } Loading eeschema/sch_component.cpp +27 −7 Original line number Original line Diff line number Diff line Loading @@ -424,6 +424,7 @@ const wxString SCH_COMPONENT::GetRef( SCH_SHEET_PATH* sheet ) SetRef( sheet, GetField( REFERENCE )->m_Text ); SetRef( sheet, GetField( REFERENCE )->m_Text ); return GetField( REFERENCE )->m_Text; return GetField( REFERENCE )->m_Text; } } return m_prefix; return m_prefix; } } Loading @@ -440,8 +441,7 @@ bool SCH_COMPONENT::IsReferenceStringValid( const wxString & aReferenceString ) bool ok = true; bool ok = true; // Try to unannotate this reference // Try to unannotate this reference while( !text.IsEmpty() && while( !text.IsEmpty() && ( text.Last() == '?' || isdigit( text.Last() ) ) ) ( text.Last() == '?' || isdigit( text.Last() ) ) ) text.RemoveLast(); text.RemoveLast(); if( text.IsEmpty() ) if( text.IsEmpty() ) Loading Loading @@ -502,13 +502,16 @@ void SCH_COMPONENT::SetRef( SCH_SHEET_PATH* sheet, const wxString& ref ) // Reinit the m_prefix member if needed // Reinit the m_prefix member if needed wxString prefix = ref; wxString prefix = ref; if( IsReferenceStringValid( prefix ) ) if( IsReferenceStringValid( prefix ) ) { { while( prefix.Last() == '?' || isdigit( prefix.Last() ) ) while( prefix.Last() == '?' || isdigit( prefix.Last() ) ) prefix.RemoveLast(); prefix.RemoveLast(); } } else else { prefix = wxT("U"); // Set to default ref prefix prefix = wxT("U"); // Set to default ref prefix } if( m_prefix != prefix ) if( m_prefix != prefix ) m_prefix = prefix; m_prefix = prefix; Loading Loading @@ -582,6 +585,7 @@ void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection h_ref += tokenizer.GetNextToken(); // Add reference h_ref += tokenizer.GetNextToken(); // Add reference h_ref += wxT( " " ); h_ref += wxT( " " ); h_ref << aUnitSelection; // Add part selection h_ref << aUnitSelection; // Add part selection // Ann the part selection // Ann the part selection m_PathsAndReferences[ii] = h_ref; m_PathsAndReferences[ii] = h_ref; notInArray = false; notInArray = false; Loading Loading @@ -622,7 +626,7 @@ SCH_FIELD* SCH_COMPONENT::FindField( const wxString& aFieldName ) { { for( unsigned i = 0; i<m_Fields.size(); ++i ) for( unsigned i = 0; i<m_Fields.size(); ++i ) { { if( aFieldName == m_Fields[i].m_Name ) if( aFieldName == m_Fields[i].GetName( false ) ) return &m_Fields[i]; return &m_Fields[i]; } } Loading Loading @@ -690,6 +694,7 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath ) // Build a reference with no annotation, // Build a reference with no annotation, // i.e. a reference ended by only one '?' // i.e. a reference ended by only one '?' wxString defRef = m_prefix; wxString defRef = m_prefix; if( IsReferenceStringValid( defRef ) ) if( IsReferenceStringValid( defRef ) ) { { while( defRef.Last() == '?' ) while( defRef.Last() == '?' ) Loading Loading @@ -966,8 +971,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const //files backwards-compatible. //files backwards-compatible. if( m_PathsAndReferences.GetCount() > 0 ) if( m_PathsAndReferences.GetCount() > 0 ) { { reference_fields = wxStringTokenize( m_PathsAndReferences[0], reference_fields = wxStringTokenize( m_PathsAndReferences[0], delimiters ); delimiters ); name1 = toUTFTildaText( reference_fields[1] ); name1 = toUTFTildaText( reference_fields[1] ); } } Loading @@ -984,7 +988,9 @@ bool SCH_COMPONENT::Save( FILE* f ) const name2 = toUTFTildaText( m_ChipName ); name2 = toUTFTildaText( m_ChipName ); } } else else { name2 = NULL_STRING; name2 = NULL_STRING; } if( fprintf( f, "$Comp\n" ) == EOF ) if( fprintf( f, "$Comp\n" ) == EOF ) return false; return false; Loading Loading @@ -1031,7 +1037,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const for( unsigned i = 0; i<m_Fields.size(); ++i ) for( unsigned i = 0; i<m_Fields.size(); ++i ) { { SCH_FIELD* fld = GetField( i ); SCH_FIELD* fld = GetField( i ); fld->m_FieldId = i; // we don't need field Ids, please be gone. fld->SetId( i ); // we don't need field Ids, please be gone. } } // Fixed fields: // Fixed fields: Loading Loading @@ -1108,8 +1114,10 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) if( strcmp( name1, NULL_STRING ) != 0 ) if( strcmp( name1, NULL_STRING ) != 0 ) { { for( ii = 0; ii < (int) strlen( name1 ); ii++ ) for( ii = 0; ii < (int) strlen( name1 ); ii++ ) { if( name1[ii] == '~' ) if( name1[ii] == '~' ) name1[ii] = ' '; name1[ii] = ' '; } m_ChipName = FROM_UTF8( name1 ); m_ChipName = FROM_UTF8( name1 ); Loading Loading @@ -1139,6 +1147,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) isDigit = true; isDigit = true; name1[ii] = 0; //null-terminate. name1[ii] = 0; //null-terminate. } } if( !isDigit ) if( !isDigit ) { { name1[ii] = name2[ii]; name1[ii] = name2[ii]; Loading Loading @@ -1226,11 +1235,15 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) // copy the multi, if exists // copy the multi, if exists ii = ReadDelimitedText( name1, ptcar, 255 ); ii = ReadDelimitedText( name1, ptcar, 255 ); if( name1[0] == 0 ) // Nothing read, put a default value if( name1[0] == 0 ) // Nothing read, put a default value sprintf( name1, "%d", m_unit ); sprintf( name1, "%d", m_unit ); int multi = atoi( name1 ); int multi = atoi( name1 ); if( multi < 0 || multi > 25 ) if( multi < 0 || multi > 25 ) multi = 1; multi = 1; AddHierarchicalReference( path, ref, multi ); AddHierarchicalReference( path, ref, multi ); GetField( REFERENCE )->m_Text = ref; GetField( REFERENCE )->m_Text = ref; } } Loading @@ -1255,6 +1268,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) } } ptcar += ReadDelimitedText( &fieldText, ptcar ); ptcar += ReadDelimitedText( &fieldText, ptcar ); if( *ptcar == 0 ) if( *ptcar == 0 ) { { aErrorMsg.Printf( wxT( "Component field F at line %d, aborted" ), aErrorMsg.Printf( wxT( "Component field F at line %d, aborted" ), Loading Loading @@ -1290,11 +1304,12 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) } } else else { { GetField( fieldNdx )->m_Name = fieldName; GetField( fieldNdx )->SetName( fieldName ); } } GetField( fieldNdx )->m_Text = fieldText; GetField( fieldNdx )->m_Text = fieldText; memset( char3, 0, sizeof(char3) ); memset( char3, 0, sizeof(char3) ); if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", char1, if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", char1, &GetField( fieldNdx )->m_Pos.x, &GetField( fieldNdx )->m_Pos.x, &GetField( fieldNdx )->m_Pos.y, &GetField( fieldNdx )->m_Pos.y, Loading Loading @@ -1322,14 +1337,17 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) hjustify = GR_TEXT_HJUSTIFY_LEFT; hjustify = GR_TEXT_HJUSTIFY_LEFT; else if( *char2 == 'R' ) else if( *char2 == 'R' ) hjustify = GR_TEXT_HJUSTIFY_RIGHT; hjustify = GR_TEXT_HJUSTIFY_RIGHT; if( char3[0] == 'B' ) if( char3[0] == 'B' ) vjustify = GR_TEXT_VJUSTIFY_BOTTOM; vjustify = GR_TEXT_VJUSTIFY_BOTTOM; else if( char3[0] == 'T' ) else if( char3[0] == 'T' ) vjustify = GR_TEXT_VJUSTIFY_TOP; vjustify = GR_TEXT_VJUSTIFY_TOP; if( char3[1] == 'I' ) if( char3[1] == 'I' ) GetField( fieldNdx )->m_Italic = true; GetField( fieldNdx )->m_Italic = true; else else GetField( fieldNdx )->m_Italic = false; GetField( fieldNdx )->m_Italic = false; if( char3[2] == 'B' ) if( char3[2] == 'B' ) GetField( fieldNdx )->m_Bold = true; GetField( fieldNdx )->m_Bold = true; else else Loading @@ -1344,8 +1362,10 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) GetField( fieldNdx )->m_Attributs |= TEXT_NO_VISIBLE; GetField( fieldNdx )->m_Attributs |= TEXT_NO_VISIBLE; } } else else { break; break; } } } if( sscanf( line, "%d %d %d", &m_unit, &m_Pos.x, &m_Pos.y ) != 3 ) if( sscanf( line, "%d %d %d", &m_unit, &m_Pos.x, &m_Pos.y ) != 3 ) { { Loading eeschema/sch_field.cpp +25 −32 Original line number Original line Diff line number Diff line Loading @@ -59,9 +59,9 @@ SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, EDA_TEXT() EDA_TEXT() { { m_Pos = aPos; m_Pos = aPos; m_FieldId = aFieldId; m_id = aFieldId; m_Attributs = TEXT_NO_VISIBLE; m_Attributs = TEXT_NO_VISIBLE; m_Name = aName; m_name = aName; SetLayer( LAYER_FIELDS ); SetLayer( LAYER_FIELDS ); } } Loading @@ -71,8 +71,8 @@ SCH_FIELD::SCH_FIELD( const SCH_FIELD& aField ) : SCH_ITEM( aField ), SCH_ITEM( aField ), EDA_TEXT( aField ) EDA_TEXT( aField ) { { m_FieldId = aField.m_FieldId; m_id = aField.m_id; m_Name = aField.m_Name; m_name = aField.m_name; } } Loading @@ -93,7 +93,7 @@ const wxString SCH_FIELD::GetText() const /* For more than one part per package, we must add the part selection /* For more than one part per package, we must add the part selection * A, B, ... or 1, 2, .. to the reference. */ * A, B, ... or 1, 2, .. to the reference. */ if( m_FieldId == REFERENCE ) if( m_id == REFERENCE ) { { SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent; Loading Loading @@ -178,9 +178,9 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, EDA_RECT boundaryBox = GetBoundingBox(); EDA_RECT boundaryBox = GetBoundingBox(); textpos = boundaryBox.Centre(); textpos = boundaryBox.Centre(); if( m_FieldId == REFERENCE ) if( m_id == REFERENCE ) color = ReturnLayerColor( LAYER_REFERENCEPART ); color = ReturnLayerColor( LAYER_REFERENCEPART ); else if( m_FieldId == VALUE ) else if( m_id == VALUE ) color = ReturnLayerColor( LAYER_VALUEPART ); color = ReturnLayerColor( LAYER_VALUEPART ); else else color = ReturnLayerColor( LAYER_FIELDS ); color = ReturnLayerColor( LAYER_FIELDS ); Loading Loading @@ -306,7 +306,7 @@ bool SCH_FIELD::Save( FILE* aFile ) const vjustify = 'T'; vjustify = 'T'; if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c", if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c", m_FieldId, m_id, EscapedUTF8( m_Text ).c_str(), // wraps in quotes too EscapedUTF8( m_Text ).c_str(), // wraps in quotes too m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V', m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V', m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y, Loading @@ -320,9 +320,9 @@ bool SCH_FIELD::Save( FILE* aFile ) const } } // Save field name, if the name is user definable // Save field name, if the name is user definable if( m_FieldId >= FIELD1 ) if( m_id >= FIELD1 ) { { if( fprintf( aFile, " %s", EscapedUTF8( m_Name ).c_str() ) == EOF ) if( fprintf( aFile, " %s", EscapedUTF8( m_name ).c_str() ) == EOF ) { { return false; return false; } } Loading Loading @@ -358,14 +358,14 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint bool match; bool match; wxString text = GetText(); wxString text = GetText(); if( (m_FieldId > VALUE) && !(aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS) ) if( (m_id > VALUE) && !(aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS) ) return false; return false; wxLogTrace( traceFindReplace, wxT( " child item " ) + GetSelectMenuText() ); wxLogTrace( traceFindReplace, wxT( " child item " ) + GetSelectMenuText() ); // Take sheet path into account which effects the reference field and the unit for // Take sheet path into account which effects the reference field and the unit for // components with multiple parts. // components with multiple parts. if( m_FieldId == REFERENCE && aAuxData != NULL ) if( m_id == REFERENCE && aAuxData != NULL ) { { SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent; Loading Loading @@ -407,24 +407,26 @@ wxString SCH_FIELD::GetSelectMenuText() const } } wxString SCH_FIELD::GetName() const wxString SCH_FIELD::GetName( bool aUseDefaultName ) const { { if( !m_Name.IsEmpty() ) if( !m_name.IsEmpty() ) return m_Name; return m_name; else else if( aUseDefaultName ) return TEMPLATE_FIELDNAME::GetDefaultFieldName( m_FieldId ); return TEMPLATE_FIELDNAME::GetDefaultFieldName( m_id ); return wxEmptyString; } } BITMAP_DEF SCH_FIELD::GetMenuImage() const BITMAP_DEF SCH_FIELD::GetMenuImage() const { { if( m_FieldId == REFERENCE ) if( m_id == REFERENCE ) return edit_comp_ref_xpm; return edit_comp_ref_xpm; if( m_FieldId == VALUE ) if( m_id == VALUE ) return edit_comp_value_xpm; return edit_comp_value_xpm; if( m_FieldId == FOOTPRINT ) if( m_id == FOOTPRINT ) return edit_comp_footprint_xpm; return edit_comp_footprint_xpm; return edit_text_xpm; return edit_text_xpm; Loading Loading @@ -462,15 +464,6 @@ bool SCH_FIELD::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy } } /* Plot field text. * Input: * DrawLibItem: pointer to the component * FieldNumber: Number Field * IsMulti: true flag if there are several parts per package. * Only useful for the field to add a reference to this one * The identification from (A, B ...) * DrawMode: trace mode */ void SCH_FIELD::doPlot( PLOTTER* aPlotter ) void SCH_FIELD::doPlot( PLOTTER* aPlotter ) { { SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent(); SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent(); Loading Loading @@ -518,7 +511,7 @@ void SCH_FIELD::doPlot( PLOTTER* aPlotter ) int thickness = GetPenSize(); int thickness = GetPenSize(); if( (parent->GetPartCount() <= 1) || (m_FieldId != REFERENCE) ) if( (parent->GetPartCount() <= 1) || (m_id != REFERENCE) ) { { aPlotter->text( textpos, color, m_Text, orient, m_Size, hjustify, vjustify, aPlotter->text( textpos, color, m_Text, orient, m_Size, hjustify, vjustify, thickness, m_Italic, m_Bold ); thickness, m_Italic, m_Bold ); Loading Loading
eeschema/dialogs/dialog_edit_component_in_schematic.cpp +13 −13 Original line number Original line Diff line number Diff line Loading @@ -236,14 +236,14 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event // Delete any fields with no name before we copy all of m_FieldsBuf back into the component. // Delete any fields with no name before we copy all of m_FieldsBuf back into the component. for( unsigned i = MANDATORY_FIELDS; i<m_FieldsBuf.size(); ) for( unsigned i = MANDATORY_FIELDS; i<m_FieldsBuf.size(); ) { { if( m_FieldsBuf[i].m_Name.IsEmpty() || m_FieldsBuf[i].m_Text.IsEmpty() ) if( m_FieldsBuf[i].GetName( false ).IsEmpty() || m_FieldsBuf[i].GetText().IsEmpty() ) { { // If a field has no value and is not it the field template list, warn the user // If a field has no value and is not it the field template list, warn the user // that it will be remove from the component. This gives the user a chance to // that it will be remove from the component. This gives the user a chance to // correct the problem before removing the undefined fields. It should also // correct the problem before removing the undefined fields. It should also // resolve most of the bug reports and questions regarding missing fields. // resolve most of the bug reports and questions regarding missing fields. if( !m_FieldsBuf[i].m_Name.IsEmpty() && m_FieldsBuf[i].m_Text.IsEmpty() if( !m_FieldsBuf[i].GetName( false ).IsEmpty() && m_FieldsBuf[i].GetText().IsEmpty() && !m_Parent->GetTemplates().HasFieldName( m_FieldsBuf[i].m_Name ) && !m_Parent->GetTemplates().HasFieldName( m_FieldsBuf[i].GetName( false ) ) && !removeRemainingFields ) && !removeRemainingFields ) { { wxString msg; wxString msg; Loading @@ -251,7 +251,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event msg.Printf( _( "The field name <%s> does not have a value and is not defined in \ msg.Printf( _( "The field name <%s> does not have a value and is not defined in \ the field template list. Empty field values are invalid an will be removed from the component. \ the field template list. Empty field values are invalid an will be removed from the component. \ Do you wish to remove this and all remaining undefined fields?" ), Do you wish to remove this and all remaining undefined fields?" ), GetChars( m_FieldsBuf[i].m_Name ) ); GetChars( m_FieldsBuf[i].GetName( false ) ) ); wxMessageDialog dlg( this, msg, _( "Remove Fields" ), wxYES_NO | wxNO_DEFAULT ); wxMessageDialog dlg( this, msg, _( "Remove Fields" ), wxYES_NO | wxNO_DEFAULT ); Loading Loading @@ -303,7 +303,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent& blank.m_Orient = m_FieldsBuf[REFERENCE].m_Orient; blank.m_Orient = m_FieldsBuf[REFERENCE].m_Orient; m_FieldsBuf.push_back( blank ); m_FieldsBuf.push_back( blank ); m_FieldsBuf[fieldNdx].m_Name = TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ); m_FieldsBuf[fieldNdx].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ) ); m_skipCopyFromPanel = true; m_skipCopyFromPanel = true; setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] ); setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] ); Loading Loading @@ -361,7 +361,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler( wxCommandEvent& ev SCH_FIELD tmp = m_FieldsBuf[fieldNdx - 1]; SCH_FIELD tmp = m_FieldsBuf[fieldNdx - 1]; D( printf( "tmp.m_Text=\"%s\" tmp.m_Name=\"%s\"\n", D( printf( "tmp.m_Text=\"%s\" tmp.m_Name=\"%s\"\n", TO_UTF8( tmp.m_Text ), TO_UTF8( tmp.m_Name ) ); ) TO_UTF8( tmp.m_Text ), TO_UTF8( tmp.GetName( false ) ) ); ) m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx]; m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx]; setRowItem( fieldNdx - 1, m_FieldsBuf[fieldNdx] ); setRowItem( fieldNdx - 1, m_FieldsBuf[fieldNdx] ); Loading Loading @@ -408,7 +408,7 @@ SCH_FIELD* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::findField( const wxString& aField { { for( unsigned i=0; i<m_FieldsBuf.size(); ++i ) for( unsigned i=0; i<m_FieldsBuf.size(); ++i ) { { if( aFieldName == m_FieldsBuf[i].m_Name ) if( aFieldName == m_FieldsBuf[i].GetName( false ) ) return &m_FieldsBuf[i]; return &m_FieldsBuf[i]; } } Loading Loading @@ -499,7 +499,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent for( unsigned i=MANDATORY_FIELDS; i<aComponent->m_Fields.size(); ++i ) for( unsigned i=MANDATORY_FIELDS; i<aComponent->m_Fields.size(); ++i ) { { SCH_FIELD* cmp = &aComponent->m_Fields[i]; SCH_FIELD* cmp = &aComponent->m_Fields[i]; SCH_FIELD* buf = findField( cmp->m_Name ); SCH_FIELD* buf = findField( cmp->GetName( false ) ); if( !buf ) if( !buf ) { { Loading @@ -516,7 +516,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent for( unsigned i = 0; i<m_FieldsBuf.size(); ++i ) for( unsigned i = 0; i<m_FieldsBuf.size(); ++i ) { { printf( "m_FieldsBuf[%d] (x=%-3d, y=%-3d) name:%s\n", i, m_FieldsBuf[i].m_Pos.x, printf( "m_FieldsBuf[%d] (x=%-3d, y=%-3d) name:%s\n", i, m_FieldsBuf[i].m_Pos.x, m_FieldsBuf[i].m_Pos.y, TO_UTF8(m_FieldsBuf[i].m_Name) ); m_FieldsBuf[i].m_Pos.y, TO_UTF8(m_FieldsBuf[i].GetName( false ) ) ); } } #endif #endif Loading Loading @@ -560,8 +560,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const SCH_FI fieldListCtrl->SetItem( ndx, 1, wxEmptyString ); fieldListCtrl->SetItem( ndx, 1, wxEmptyString ); } } fieldListCtrl->SetItem( aFieldNdx, 0, aField.m_Name ); fieldListCtrl->SetItem( aFieldNdx, 0, aField.GetName( false ) ); fieldListCtrl->SetItem( aFieldNdx, 1, aField.m_Text ); fieldListCtrl->SetItem( aFieldNdx, 1, aField.GetText() ); // recompute the column widths here, after setting texts // recompute the column widths here, after setting texts fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE ); fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE ); Loading Loading @@ -608,7 +608,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() m_FieldVJustifyCtrl->SetSelection(1); m_FieldVJustifyCtrl->SetSelection(1); fieldNameTextCtrl->SetValue( field.m_Name ); fieldNameTextCtrl->SetValue( field.GetName( false ) ); // the names of the fixed fields are not editable, others are. // the names of the fixed fields are not editable, others are. fieldNameTextCtrl->Enable( fieldNdx >= MANDATORY_FIELDS ); fieldNameTextCtrl->Enable( fieldNdx >= MANDATORY_FIELDS ); Loading Loading @@ -698,7 +698,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField() field.m_HJustify = hjustify[m_FieldHJustifyCtrl->GetSelection()]; field.m_HJustify = hjustify[m_FieldHJustifyCtrl->GetSelection()]; field.m_VJustify = vjustify[m_FieldVJustifyCtrl->GetSelection()]; field.m_VJustify = vjustify[m_FieldVJustifyCtrl->GetSelection()]; field.m_Name = fieldNameTextCtrl->GetValue(); field.SetName( fieldNameTextCtrl->GetValue() ); /* Void fields texts for REFERENCE and VALUE (value is the name of the /* Void fields texts for REFERENCE and VALUE (value is the name of the * component in lib ! ) are not allowed * component in lib ! ) are not allowed Loading
eeschema/edit_component_in_schematic.cpp +3 −3 Original line number Original line Diff line number Diff line Loading @@ -77,7 +77,7 @@ create a new power component with the new value." ), GetChars( entry->GetName() DrawPanel->m_IgnoreMouseEvents = true; DrawPanel->m_IgnoreMouseEvents = true; wxString title; wxString title; title.Printf( _( "Edit %s Field" ), GetChars( aField->m_Name ) ); title.Printf( _( "Edit %s Field" ), GetChars( aField->GetName() ) ); wxTextEntryDialog dlg( this, wxEmptyString , title, newtext ); wxTextEntryDialog dlg( this, wxEmptyString , title, newtext ); int response = dlg.ShowModal(); int response = dlg.ShowModal(); Loading @@ -95,7 +95,7 @@ create a new power component with the new value." ), GetChars( entry->GetName() if( !newtext.IsEmpty() ) if( !newtext.IsEmpty() ) { { if( aField->m_Text.IsEmpty() ) // Means the field was not already in use if( aField->GetText().IsEmpty() ) // Means the field was not already in use { { aField->m_Pos = component->GetPosition(); aField->m_Pos = component->GetPosition(); aField->m_Size.x = aField->m_Size.y = m_TextFieldSize; aField->m_Size.x = aField->m_Size.y = m_TextFieldSize; Loading @@ -107,7 +107,7 @@ create a new power component with the new value." ), GetChars( entry->GetName() if( SCH_COMPONENT::IsReferenceStringValid( newtext ) ) if( SCH_COMPONENT::IsReferenceStringValid( newtext ) ) { { component->SetRef( GetSheet(), newtext ); component->SetRef( GetSheet(), newtext ); aField->m_Text = newtext; aField->SetText( newtext ); } } else else { { Loading
eeschema/netform.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -1010,11 +1010,11 @@ XNODE* EXPORT_HELP::makeGenericComponents() SCH_FIELD* f = comp->GetField( fldNdx ); SCH_FIELD* f = comp->GetField( fldNdx ); // only output a field if non empty // only output a field if non empty if( !f->m_Text.IsEmpty() ) if( !f->GetText().IsEmpty() ) { { XNODE* xfield; XNODE* xfield; xfields->AddChild( xfield = node( sField, f->m_Text ) ); xfields->AddChild( xfield = node( sField, f->m_Text ) ); xfield->AddAttribute( sName, f->m_Name ); xfield->AddAttribute( sName, f->GetName() ); } } } } } } Loading
eeschema/sch_component.cpp +27 −7 Original line number Original line Diff line number Diff line Loading @@ -424,6 +424,7 @@ const wxString SCH_COMPONENT::GetRef( SCH_SHEET_PATH* sheet ) SetRef( sheet, GetField( REFERENCE )->m_Text ); SetRef( sheet, GetField( REFERENCE )->m_Text ); return GetField( REFERENCE )->m_Text; return GetField( REFERENCE )->m_Text; } } return m_prefix; return m_prefix; } } Loading @@ -440,8 +441,7 @@ bool SCH_COMPONENT::IsReferenceStringValid( const wxString & aReferenceString ) bool ok = true; bool ok = true; // Try to unannotate this reference // Try to unannotate this reference while( !text.IsEmpty() && while( !text.IsEmpty() && ( text.Last() == '?' || isdigit( text.Last() ) ) ) ( text.Last() == '?' || isdigit( text.Last() ) ) ) text.RemoveLast(); text.RemoveLast(); if( text.IsEmpty() ) if( text.IsEmpty() ) Loading Loading @@ -502,13 +502,16 @@ void SCH_COMPONENT::SetRef( SCH_SHEET_PATH* sheet, const wxString& ref ) // Reinit the m_prefix member if needed // Reinit the m_prefix member if needed wxString prefix = ref; wxString prefix = ref; if( IsReferenceStringValid( prefix ) ) if( IsReferenceStringValid( prefix ) ) { { while( prefix.Last() == '?' || isdigit( prefix.Last() ) ) while( prefix.Last() == '?' || isdigit( prefix.Last() ) ) prefix.RemoveLast(); prefix.RemoveLast(); } } else else { prefix = wxT("U"); // Set to default ref prefix prefix = wxT("U"); // Set to default ref prefix } if( m_prefix != prefix ) if( m_prefix != prefix ) m_prefix = prefix; m_prefix = prefix; Loading Loading @@ -582,6 +585,7 @@ void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection h_ref += tokenizer.GetNextToken(); // Add reference h_ref += tokenizer.GetNextToken(); // Add reference h_ref += wxT( " " ); h_ref += wxT( " " ); h_ref << aUnitSelection; // Add part selection h_ref << aUnitSelection; // Add part selection // Ann the part selection // Ann the part selection m_PathsAndReferences[ii] = h_ref; m_PathsAndReferences[ii] = h_ref; notInArray = false; notInArray = false; Loading Loading @@ -622,7 +626,7 @@ SCH_FIELD* SCH_COMPONENT::FindField( const wxString& aFieldName ) { { for( unsigned i = 0; i<m_Fields.size(); ++i ) for( unsigned i = 0; i<m_Fields.size(); ++i ) { { if( aFieldName == m_Fields[i].m_Name ) if( aFieldName == m_Fields[i].GetName( false ) ) return &m_Fields[i]; return &m_Fields[i]; } } Loading Loading @@ -690,6 +694,7 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath ) // Build a reference with no annotation, // Build a reference with no annotation, // i.e. a reference ended by only one '?' // i.e. a reference ended by only one '?' wxString defRef = m_prefix; wxString defRef = m_prefix; if( IsReferenceStringValid( defRef ) ) if( IsReferenceStringValid( defRef ) ) { { while( defRef.Last() == '?' ) while( defRef.Last() == '?' ) Loading Loading @@ -966,8 +971,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const //files backwards-compatible. //files backwards-compatible. if( m_PathsAndReferences.GetCount() > 0 ) if( m_PathsAndReferences.GetCount() > 0 ) { { reference_fields = wxStringTokenize( m_PathsAndReferences[0], reference_fields = wxStringTokenize( m_PathsAndReferences[0], delimiters ); delimiters ); name1 = toUTFTildaText( reference_fields[1] ); name1 = toUTFTildaText( reference_fields[1] ); } } Loading @@ -984,7 +988,9 @@ bool SCH_COMPONENT::Save( FILE* f ) const name2 = toUTFTildaText( m_ChipName ); name2 = toUTFTildaText( m_ChipName ); } } else else { name2 = NULL_STRING; name2 = NULL_STRING; } if( fprintf( f, "$Comp\n" ) == EOF ) if( fprintf( f, "$Comp\n" ) == EOF ) return false; return false; Loading Loading @@ -1031,7 +1037,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const for( unsigned i = 0; i<m_Fields.size(); ++i ) for( unsigned i = 0; i<m_Fields.size(); ++i ) { { SCH_FIELD* fld = GetField( i ); SCH_FIELD* fld = GetField( i ); fld->m_FieldId = i; // we don't need field Ids, please be gone. fld->SetId( i ); // we don't need field Ids, please be gone. } } // Fixed fields: // Fixed fields: Loading Loading @@ -1108,8 +1114,10 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) if( strcmp( name1, NULL_STRING ) != 0 ) if( strcmp( name1, NULL_STRING ) != 0 ) { { for( ii = 0; ii < (int) strlen( name1 ); ii++ ) for( ii = 0; ii < (int) strlen( name1 ); ii++ ) { if( name1[ii] == '~' ) if( name1[ii] == '~' ) name1[ii] = ' '; name1[ii] = ' '; } m_ChipName = FROM_UTF8( name1 ); m_ChipName = FROM_UTF8( name1 ); Loading Loading @@ -1139,6 +1147,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) isDigit = true; isDigit = true; name1[ii] = 0; //null-terminate. name1[ii] = 0; //null-terminate. } } if( !isDigit ) if( !isDigit ) { { name1[ii] = name2[ii]; name1[ii] = name2[ii]; Loading Loading @@ -1226,11 +1235,15 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) // copy the multi, if exists // copy the multi, if exists ii = ReadDelimitedText( name1, ptcar, 255 ); ii = ReadDelimitedText( name1, ptcar, 255 ); if( name1[0] == 0 ) // Nothing read, put a default value if( name1[0] == 0 ) // Nothing read, put a default value sprintf( name1, "%d", m_unit ); sprintf( name1, "%d", m_unit ); int multi = atoi( name1 ); int multi = atoi( name1 ); if( multi < 0 || multi > 25 ) if( multi < 0 || multi > 25 ) multi = 1; multi = 1; AddHierarchicalReference( path, ref, multi ); AddHierarchicalReference( path, ref, multi ); GetField( REFERENCE )->m_Text = ref; GetField( REFERENCE )->m_Text = ref; } } Loading @@ -1255,6 +1268,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) } } ptcar += ReadDelimitedText( &fieldText, ptcar ); ptcar += ReadDelimitedText( &fieldText, ptcar ); if( *ptcar == 0 ) if( *ptcar == 0 ) { { aErrorMsg.Printf( wxT( "Component field F at line %d, aborted" ), aErrorMsg.Printf( wxT( "Component field F at line %d, aborted" ), Loading Loading @@ -1290,11 +1304,12 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) } } else else { { GetField( fieldNdx )->m_Name = fieldName; GetField( fieldNdx )->SetName( fieldName ); } } GetField( fieldNdx )->m_Text = fieldText; GetField( fieldNdx )->m_Text = fieldText; memset( char3, 0, sizeof(char3) ); memset( char3, 0, sizeof(char3) ); if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", char1, if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", char1, &GetField( fieldNdx )->m_Pos.x, &GetField( fieldNdx )->m_Pos.x, &GetField( fieldNdx )->m_Pos.y, &GetField( fieldNdx )->m_Pos.y, Loading Loading @@ -1322,14 +1337,17 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) hjustify = GR_TEXT_HJUSTIFY_LEFT; hjustify = GR_TEXT_HJUSTIFY_LEFT; else if( *char2 == 'R' ) else if( *char2 == 'R' ) hjustify = GR_TEXT_HJUSTIFY_RIGHT; hjustify = GR_TEXT_HJUSTIFY_RIGHT; if( char3[0] == 'B' ) if( char3[0] == 'B' ) vjustify = GR_TEXT_VJUSTIFY_BOTTOM; vjustify = GR_TEXT_VJUSTIFY_BOTTOM; else if( char3[0] == 'T' ) else if( char3[0] == 'T' ) vjustify = GR_TEXT_VJUSTIFY_TOP; vjustify = GR_TEXT_VJUSTIFY_TOP; if( char3[1] == 'I' ) if( char3[1] == 'I' ) GetField( fieldNdx )->m_Italic = true; GetField( fieldNdx )->m_Italic = true; else else GetField( fieldNdx )->m_Italic = false; GetField( fieldNdx )->m_Italic = false; if( char3[2] == 'B' ) if( char3[2] == 'B' ) GetField( fieldNdx )->m_Bold = true; GetField( fieldNdx )->m_Bold = true; else else Loading @@ -1344,8 +1362,10 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) GetField( fieldNdx )->m_Attributs |= TEXT_NO_VISIBLE; GetField( fieldNdx )->m_Attributs |= TEXT_NO_VISIBLE; } } else else { break; break; } } } if( sscanf( line, "%d %d %d", &m_unit, &m_Pos.x, &m_Pos.y ) != 3 ) if( sscanf( line, "%d %d %d", &m_unit, &m_Pos.x, &m_Pos.y ) != 3 ) { { Loading
eeschema/sch_field.cpp +25 −32 Original line number Original line Diff line number Diff line Loading @@ -59,9 +59,9 @@ SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, EDA_TEXT() EDA_TEXT() { { m_Pos = aPos; m_Pos = aPos; m_FieldId = aFieldId; m_id = aFieldId; m_Attributs = TEXT_NO_VISIBLE; m_Attributs = TEXT_NO_VISIBLE; m_Name = aName; m_name = aName; SetLayer( LAYER_FIELDS ); SetLayer( LAYER_FIELDS ); } } Loading @@ -71,8 +71,8 @@ SCH_FIELD::SCH_FIELD( const SCH_FIELD& aField ) : SCH_ITEM( aField ), SCH_ITEM( aField ), EDA_TEXT( aField ) EDA_TEXT( aField ) { { m_FieldId = aField.m_FieldId; m_id = aField.m_id; m_Name = aField.m_Name; m_name = aField.m_name; } } Loading @@ -93,7 +93,7 @@ const wxString SCH_FIELD::GetText() const /* For more than one part per package, we must add the part selection /* For more than one part per package, we must add the part selection * A, B, ... or 1, 2, .. to the reference. */ * A, B, ... or 1, 2, .. to the reference. */ if( m_FieldId == REFERENCE ) if( m_id == REFERENCE ) { { SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent; Loading Loading @@ -178,9 +178,9 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, EDA_RECT boundaryBox = GetBoundingBox(); EDA_RECT boundaryBox = GetBoundingBox(); textpos = boundaryBox.Centre(); textpos = boundaryBox.Centre(); if( m_FieldId == REFERENCE ) if( m_id == REFERENCE ) color = ReturnLayerColor( LAYER_REFERENCEPART ); color = ReturnLayerColor( LAYER_REFERENCEPART ); else if( m_FieldId == VALUE ) else if( m_id == VALUE ) color = ReturnLayerColor( LAYER_VALUEPART ); color = ReturnLayerColor( LAYER_VALUEPART ); else else color = ReturnLayerColor( LAYER_FIELDS ); color = ReturnLayerColor( LAYER_FIELDS ); Loading Loading @@ -306,7 +306,7 @@ bool SCH_FIELD::Save( FILE* aFile ) const vjustify = 'T'; vjustify = 'T'; if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c", if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c", m_FieldId, m_id, EscapedUTF8( m_Text ).c_str(), // wraps in quotes too EscapedUTF8( m_Text ).c_str(), // wraps in quotes too m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V', m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V', m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y, Loading @@ -320,9 +320,9 @@ bool SCH_FIELD::Save( FILE* aFile ) const } } // Save field name, if the name is user definable // Save field name, if the name is user definable if( m_FieldId >= FIELD1 ) if( m_id >= FIELD1 ) { { if( fprintf( aFile, " %s", EscapedUTF8( m_Name ).c_str() ) == EOF ) if( fprintf( aFile, " %s", EscapedUTF8( m_name ).c_str() ) == EOF ) { { return false; return false; } } Loading Loading @@ -358,14 +358,14 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint bool match; bool match; wxString text = GetText(); wxString text = GetText(); if( (m_FieldId > VALUE) && !(aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS) ) if( (m_id > VALUE) && !(aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS) ) return false; return false; wxLogTrace( traceFindReplace, wxT( " child item " ) + GetSelectMenuText() ); wxLogTrace( traceFindReplace, wxT( " child item " ) + GetSelectMenuText() ); // Take sheet path into account which effects the reference field and the unit for // Take sheet path into account which effects the reference field and the unit for // components with multiple parts. // components with multiple parts. if( m_FieldId == REFERENCE && aAuxData != NULL ) if( m_id == REFERENCE && aAuxData != NULL ) { { SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent; Loading Loading @@ -407,24 +407,26 @@ wxString SCH_FIELD::GetSelectMenuText() const } } wxString SCH_FIELD::GetName() const wxString SCH_FIELD::GetName( bool aUseDefaultName ) const { { if( !m_Name.IsEmpty() ) if( !m_name.IsEmpty() ) return m_Name; return m_name; else else if( aUseDefaultName ) return TEMPLATE_FIELDNAME::GetDefaultFieldName( m_FieldId ); return TEMPLATE_FIELDNAME::GetDefaultFieldName( m_id ); return wxEmptyString; } } BITMAP_DEF SCH_FIELD::GetMenuImage() const BITMAP_DEF SCH_FIELD::GetMenuImage() const { { if( m_FieldId == REFERENCE ) if( m_id == REFERENCE ) return edit_comp_ref_xpm; return edit_comp_ref_xpm; if( m_FieldId == VALUE ) if( m_id == VALUE ) return edit_comp_value_xpm; return edit_comp_value_xpm; if( m_FieldId == FOOTPRINT ) if( m_id == FOOTPRINT ) return edit_comp_footprint_xpm; return edit_comp_footprint_xpm; return edit_text_xpm; return edit_text_xpm; Loading Loading @@ -462,15 +464,6 @@ bool SCH_FIELD::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy } } /* Plot field text. * Input: * DrawLibItem: pointer to the component * FieldNumber: Number Field * IsMulti: true flag if there are several parts per package. * Only useful for the field to add a reference to this one * The identification from (A, B ...) * DrawMode: trace mode */ void SCH_FIELD::doPlot( PLOTTER* aPlotter ) void SCH_FIELD::doPlot( PLOTTER* aPlotter ) { { SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent(); SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent(); Loading Loading @@ -518,7 +511,7 @@ void SCH_FIELD::doPlot( PLOTTER* aPlotter ) int thickness = GetPenSize(); int thickness = GetPenSize(); if( (parent->GetPartCount() <= 1) || (m_FieldId != REFERENCE) ) if( (parent->GetPartCount() <= 1) || (m_id != REFERENCE) ) { { aPlotter->text( textpos, color, m_Text, orient, m_Size, hjustify, vjustify, aPlotter->text( textpos, color, m_Text, orient, m_Size, hjustify, vjustify, thickness, m_Italic, m_Bold ); thickness, m_Italic, m_Bold ); Loading