void LIB_VIEW_FRAME::SelectCurrentLibrary() { CMP_LIBRARY* Lib; Lib = SelectLibraryFromList( this ); if( Lib ) { m_entryName.Empty(); m_libraryName = Lib->GetName(); DisplayLibInfos(); if( m_LibList ) { ReCreateListCmp(); m_canvas->Refresh(); DisplayLibInfos(); ReCreateHToolbar(); int id = m_LibList->FindString( m_libraryName.GetData() ); if( id >= 0 ) m_LibList->SetSelection( id ); } } }
void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event ) { wxString msg; m_lastDrawItem = NULL; wxString libName = getTargetLib(); if( !m_libMgr->LibraryExists( libName ) ) { libName = SelectLibraryFromList(); if( !m_libMgr->LibraryExists( libName ) ) return; } wxFileDialog dlg( this, _( "Import Symbol" ), m_mruPath, wxEmptyString, SchematicLibraryFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) return; wxFileName fn = dlg.GetPath(); m_mruPath = fn.GetPath(); wxArrayString symbols; SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) ); // TODO dialog to select the part to be imported if there is more than one try { pi->EnumerateSymbolLib( symbols, fn.GetFullPath() ); } catch( const IO_ERROR& ioe ) { msg.Printf( _( "Cannot import symbol library \"%s\"." ), fn.GetFullPath() ); DisplayErrorMessage( this, msg, ioe.What() ); return; } if( symbols.empty() ) { msg.Printf( _( "Symbol library file \"%s\" is empty." ), fn.GetFullPath() ); DisplayError( this, msg ); return; } wxString symbolName = symbols[0]; LIB_ALIAS* entry = pi->LoadSymbol( fn.GetFullPath(), symbolName ); if( m_libMgr->PartExists( symbols[0], libName ) ) { msg.Printf( _( "Symbol \"%s\" already exists in library \"%s\"." ), symbolName, libName ); DisplayError( this, msg ); return; } m_libMgr->UpdatePart( entry->GetPart(), libName ); SyncLibraries( false ); loadPart( symbolName, libName, 1 ); }
void LIB_EDIT_FRAME::SelectActiveLibrary( PART_LIB* aLibrary ) { if( !aLibrary ) aLibrary = SelectLibraryFromList(); if( aLibrary ) { SetCurLib( aLibrary ); } DisplayLibInfos(); }
void LIB_EDIT_FRAME::SelectActiveLibrary( const wxString& aLibrary ) { wxString selectedLib = aLibrary; if( selectedLib.empty() ) selectedLib = SelectLibraryFromList(); if( !selectedLib.empty() ) SetCurLib( selectedLib ); updateTitle(); }
void WinEDA_ViewlibFrame::SelectCurrentLibrary(void) { LibraryStruct * Lib; Lib = SelectLibraryFromList(this); if ( Lib ) { g_CurrentViewComponentName.Empty(); g_CurrentViewLibraryName = Lib->m_Name; DisplayLibInfos(); if ( m_LibList ) { ReCreateListCmp(); ReDrawPanel(); DisplayLibInfos(); ReCreateHToolbar(); int id = m_LibList->FindString(g_CurrentViewLibraryName.GetData()); if ( id >= 0 ) m_LibList->SetSelection(id); } } }
bool SCH_BASE_FRAME::DisplayListComponentsInLib( PART_LIB* aLibrary, wxString& aBuffer, wxString& aPreviousChoice ) { wxArrayString nameList; if( aLibrary == NULL ) aLibrary = SelectLibraryFromList(); if( aLibrary == NULL ) return false; aLibrary->GetAliasNames( nameList ); wxArrayString headers; headers.Add( wxT("Component") ); headers.Add( wxT("Library") ); std::vector<wxArrayString> itemsToDisplay; // Conversion from wxArrayString to vector of ArrayString for( unsigned i = 0; i < nameList.GetCount(); i++ ) { wxArrayString item; item.Add( nameList[i] ); item.Add( aLibrary->GetLogicalName() ); itemsToDisplay.push_back( item ); } EDA_LIST_DIALOG dlg( this, _( "Select Component" ), headers, itemsToDisplay, aPreviousChoice, DisplayCmpDocAndKeywords, Prj().SchLibs() ); if( dlg.ShowModal() != wxID_OK ) return false; aBuffer = dlg.GetTextSelection(); return true; }
void LIB_EDIT_FRAME::OnCreateNewPart( wxCommandEvent& event ) { m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); SetDrawItem( NULL ); wxString lib = getTargetLib(); if( !m_libMgr->LibraryExists( lib ) ) { lib = SelectLibraryFromList(); if( !m_libMgr->LibraryExists( lib ) ) return; } DIALOG_LIB_NEW_COMPONENT dlg( this ); dlg.SetMinSize( dlg.GetSize() ); if( dlg.ShowModal() == wxID_CANCEL ) return; if( dlg.GetName().IsEmpty() ) { wxMessageBox( _( "This new symbol has no name and cannot be created." ) ); return; } wxString name = dlg.GetName(); // Currently, symbol names cannot include a space, that breaks libraries: name.Replace( " ", "_" ); // Test if there is a component with this name already. if( !lib.empty() && m_libMgr->PartExists( name, lib ) ) { wxString msg = wxString::Format( _( "Symbol \"%s\" already exists in library \"%s\"" ), name, lib ); DisplayError( this, msg ); return; } LIB_PART new_part( name ); // do not create part on the heap, it will be buffered soon new_part.GetReferenceField().SetText( dlg.GetReference() ); new_part.SetUnitCount( dlg.GetUnitCount() ); // Initialize new_part.m_TextInside member: // if 0, pin text is outside the body (on the pin) // if > 0, pin text is inside the body if( dlg.GetPinNameInside() ) { new_part.SetPinNameOffset( dlg.GetPinTextPosition() ); if( new_part.GetPinNameOffset() == 0 ) new_part.SetPinNameOffset( 1 ); } else { new_part.SetPinNameOffset( 0 ); } ( dlg.GetPowerSymbol() ) ? new_part.SetPower() : new_part.SetNormal(); new_part.SetShowPinNumbers( dlg.GetShowPinNumber() ); new_part.SetShowPinNames( dlg.GetShowPinName() ); new_part.LockUnits( dlg.GetLockItems() ); if( dlg.GetUnitCount() < 2 ) new_part.LockUnits( false ); m_libMgr->UpdatePart( &new_part, lib ); SyncLibraries( false ); loadPart( name, lib, 1 ); new_part.SetConversion( dlg.GetAlternateBodyStyle() ); // must be called after loadPart, that calls SetShowDeMorgan, but // because the symbol is empty,it looks like it has no alternate body SetShowDeMorgan( dlg.GetAlternateBodyStyle() ); }