/* Initialize state of check boxes and texts */ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg() { m_AliasLocation = -1; LIB_PART* component = m_Parent->GetCurPart(); if( component == NULL ) { SetTitle( _( "Library Component Properties" ) ); return; } wxString title; bool isRoot = m_Parent->GetAliasName().CmpNoCase( component->GetName() ) == 0; if( !isRoot ) { title.Printf( _( "Properties for %s (alias of %s)" ), GetChars( m_Parent->GetAliasName() ), GetChars( component->GetName() ) ); } else title.Printf( _( "Properties for %s" ), GetChars( component->GetName() ) ); SetTitle( title ); InitPanelDoc(); InitBasicPanel(); if( isRoot && component->GetAliasCount() == 1 ) m_ButtonDeleteAllAlias->Enable( false ); /* Place list of alias names in listbox */ m_PartAliasListCtrl->Append( component->GetAliasNames( false ) ); if( component->GetAliasCount() <= 1 ) { m_ButtonDeleteAllAlias->Enable( false ); m_ButtonDeleteOneAlias->Enable( false ); } /* Read the Footprint Filter list */ m_FootprintFilterListBox->Append( component->GetFootPrints() ); if( component->GetFootPrints().GetCount() == 0 ) { m_ButtonDeleteAllFootprintFilter->Enable( false ); m_ButtonDeleteOneFootprintFilter->Enable( false ); m_buttonEditOneFootprintFilter->Enable( false ); } m_NoteBook->SetSelection( m_lastOpenedPage ); m_stdSizerButtonOK->SetDefault(); }
void LIB_EDIT_FRAME::UpdateAliasSelectList() { if( m_aliasSelectBox == NULL ) return; m_aliasSelectBox->Clear(); LIB_PART* part = GetCurPart(); if( !part ) return; m_aliasSelectBox->Append( part->GetAliasNames() ); m_aliasSelectBox->SetSelection( 0 ); int index = m_aliasSelectBox->FindString( m_aliasName ); if( index != wxNOT_FOUND ) m_aliasSelectBox->SetSelection( index ); }
void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField ) { wxString newFieldValue; wxString title; wxString caption; wxString oldName; if( aField == NULL ) return; LIB_PART* parent = aField->GetParent(); wxASSERT( parent ); // Editing the component value field is equivalent to creating a new component based // on the current component. Set the dialog message to inform the user. if( aField->GetId() == VALUE ) { caption = _( "Component Name" ); title = _( "Enter a name to create a new component based on this one." ); } else { caption.Printf( _( "Edit Field %s" ), GetChars( aField->GetName() ) ); title.Printf( _( "Enter a new value for the %s field." ), GetChars( aField->GetName().Lower() ) ); } DIALOG_LIB_EDIT_ONE_FIELD dlg( this, caption, aField ); // The dialog may invoke a kiway player for footprint fields // so we must use a quasimodal dialog. if( dlg.ShowQuasiModal() != wxID_OK ) return; newFieldValue = dlg.GetText(); wxString fieldText = aField->GetFullText( m_unit ); /* If the value field is changed, this is equivalent to creating a new component from * the old one. Rename the component and remove any conflicting aliases to prevent name * errors when updating the library. */ if( aField->GetId() == VALUE && newFieldValue != aField->GetText() ) { wxString msg; PART_LIB* lib = GetCurLib(); // Test the current library for name conflicts. if( lib && lib->FindAlias( newFieldValue ) ) { msg.Printf( _( "The name '%s' conflicts with an existing entry in the component library '%s'.\n\n" "Do you wish to replace the current component in the library with this one?" ), GetChars( newFieldValue ), GetChars( lib->GetName() ) ); int rsp = wxMessageBox( msg, _( "Confirm" ), wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT, this ); if( rsp == wxNO ) return; } // Test the current component for name conflicts. if( parent->HasAlias( newFieldValue ) ) { msg.Printf( _( "The current component already has an alias named '%s'.\n\n" "Do you wish to remove this alias from the component?" ), GetChars( newFieldValue ) ); int rsp = wxMessageBox( msg, _( "Confirm" ), wxYES_NO | wxICON_QUESTION, this ); if( rsp == wxNO ) return; parent->RemoveAlias( newFieldValue ); } parent->SetName( newFieldValue ); // Test the library for any conflicts with the any aliases in the current component. if( parent->GetAliasCount() > 1 && lib && lib->Conflicts( parent ) ) { msg.Printf( _( "The new component contains alias names that conflict with entries in the " "component library '%s'.\n\n" "Do you wish to remove all of the conflicting aliases from this component?" ), GetChars( lib->GetName() ) ); int rsp = wxMessageBox( msg, _( "Confirm" ), wxYES_NO | wxICON_QUESTION, this ); if( rsp == wxNO ) { parent->SetName( fieldText ); return; } wxArrayString aliases = parent->GetAliasNames( false ); for( size_t i = 0; i < aliases.GetCount(); i++ ) { if( lib->FindAlias( aliases[ i ] ) != NULL ) parent->RemoveAlias( aliases[ i ] ); } } if( !parent->HasAlias( m_aliasName ) ) m_aliasName = newFieldValue; } dlg.UpdateField( aField ); if( !aField->InEditMode() ) SaveCopyInUndoList( parent ); m_canvas->Refresh(); OnModify(); UpdateAliasSelectList(); }
XNODE* NETLIST_EXPORTER_GENERIC::makeLibParts() { XNODE* xlibparts = node( wxT( "libparts" ) ); // auto_ptr wxString sLibpart = wxT( "libpart" ); wxString sLib = wxT( "lib" ); wxString sPart = wxT( "part" ); wxString sAliases = wxT( "aliases" ); wxString sAlias = wxT( "alias" ); wxString sPins = wxT( "pins" ); // key for library component pins list wxString sPin = wxT( "pin" ); // key for one library component pin descr wxString sPinNum = wxT( "num" ); // key for one library component pin num wxString sPinName = wxT( "name" ); // key for one library component pin name wxString sPinType = wxT( "type" ); // key for one library component pin electrical type wxString sName = wxT( "name" ); wxString sField = wxT( "field" ); wxString sFields = wxT( "fields" ); wxString sDescr = wxT( "description" ); wxString sDocs = wxT( "docs" ); wxString sFprints = wxT( "footprints" ); wxString sFp = wxT( "fp" ); LIB_PINS pinList; LIB_FIELDS fieldList; m_Libraries.clear(); for( std::set<LIB_PART*>::iterator it = m_LibParts.begin(); it!=m_LibParts.end(); ++it ) { LIB_PART* lcomp = *it; PART_LIB* library = lcomp->GetLib(); m_Libraries.insert( library ); // inserts component's library if unique XNODE* xlibpart; xlibparts->AddChild( xlibpart = node( sLibpart ) ); xlibpart->AddAttribute( sLib, library->GetLogicalName() ); xlibpart->AddAttribute( sPart, lcomp->GetName() ); if( lcomp->GetAliasCount() ) { wxArrayString aliases = lcomp->GetAliasNames( false ); if( aliases.GetCount() ) { XNODE* xaliases = node( sAliases ); xlibpart->AddChild( xaliases ); for( unsigned i=0; i<aliases.GetCount(); ++i ) { xaliases->AddChild( node( sAlias, aliases[i] ) ); } } } //----- show the important properties ------------------------- if( !lcomp->GetAlias( 0 )->GetDescription().IsEmpty() ) xlibpart->AddChild( node( sDescr, lcomp->GetAlias( 0 )->GetDescription() ) ); if( !lcomp->GetAlias( 0 )->GetDocFileName().IsEmpty() ) xlibpart->AddChild( node( sDocs, lcomp->GetAlias( 0 )->GetDocFileName() ) ); // Write the footprint list if( lcomp->GetFootPrints().GetCount() ) { XNODE* xfootprints; xlibpart->AddChild( xfootprints = node( sFprints ) ); for( unsigned i=0; i<lcomp->GetFootPrints().GetCount(); ++i ) { xfootprints->AddChild( node( sFp, lcomp->GetFootPrints()[i] ) ); } } //----- show the fields here ---------------------------------- fieldList.clear(); lcomp->GetFields( fieldList ); XNODE* xfields; xlibpart->AddChild( xfields = node( sFields ) ); for( unsigned i=0; i<fieldList.size(); ++i ) { if( !fieldList[i].GetText().IsEmpty() ) { XNODE* xfield; xfields->AddChild( xfield = node( sField, fieldList[i].GetText() ) ); xfield->AddAttribute( sName, fieldList[i].GetName(false) ); } } //----- show the pins here ------------------------------------ pinList.clear(); lcomp->GetPins( pinList, 0, 0 ); /* we must erase redundant Pins references in pinList * These redundant pins exist because some pins * are found more than one time when a component has * multiple parts per package or has 2 representations (DeMorgan conversion) * For instance, a 74ls00 has DeMorgan conversion, with different pin shapes, * and therefore each pin appears 2 times in the list. * Common pins (VCC, GND) can also be found more than once. */ sort( pinList.begin(), pinList.end(), sortPinsByNumber ); for( int ii = 0; ii < (int)pinList.size()-1; ii++ ) { if( pinList[ii]->GetNumber() == pinList[ii+1]->GetNumber() ) { // 2 pins have the same number, remove the redundant pin at index i+1 pinList.erase(pinList.begin() + ii + 1); ii--; } } if( pinList.size() ) { XNODE* pins; xlibpart->AddChild( pins = node( sPins ) ); for( unsigned i=0; i<pinList.size(); ++i ) { XNODE* pin; pins->AddChild( pin = node( sPin ) ); pin->AddAttribute( sPinNum, pinList[i]->GetNumberString() ); pin->AddAttribute( sPinName, pinList[i]->GetName() ); pin->AddAttribute( sPinType, pinList[i]->GetCanonicalElectricalTypeName() ); // caution: construction work site here, drive slowly } } } return xlibparts; }