KiCad PCB EDA Suite
panel_sym_lib_table.h File Reference

Go to the source code of this file.

Classes

class  PANEL_SYM_LIB_TABLE
 Dialog to show and edit symbol library tables. More...
 

Functions

void InvokeSchEditSymbolLibTable (KIWAY *aKiway, wxWindow *aParent)
 

Function Documentation

void InvokeSchEditSymbolLibTable ( KIWAY aKiway,
wxWindow *  aParent 
)

Definition at line 697 of file panel_sym_lib_table.cpp.

References FRAME_SCH_LIB_EDITOR, FRAME_SCH_VIEWER, SYMBOL_LIB_TABLE::GetGlobalLibTable(), SYMBOL_LIB_TABLE::GetGlobalTableFileName(), PROJECT::GetProjectPath(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName(), DIALOG_EDIT_LIBRARY_TABLES::InstallPanel(), DIALOG_EDIT_LIBRARY_TABLES::m_GlobalTableChanged, DIALOG_EDIT_LIBRARY_TABLES::m_ProjectTableChanged, PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE(), KIWAY::Player(), KIWAY::Prj(), LIB_VIEW_FRAME::ReCreateListLib(), LIB_TABLE::Save(), and IO_ERROR::What().

Referenced by SCH::IFACE::CreateWindow(), and SCH_BASE_FRAME::OnEditSymbolLibTable().

698 {
700  wxString globalTablePath = SYMBOL_LIB_TABLE::GetGlobalTableFileName();
701  SYMBOL_LIB_TABLE* projectTable = aKiway->Prj().SchSymbolLibTable();
702  wxString projectPath = aKiway->Prj().GetProjectPath();
703  wxFileName projectTableFn( projectPath, SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
704  wxString msg;
705 
706  DIALOG_EDIT_LIBRARY_TABLES dlg( aParent, _( "Symbol Libraries" ) );
707 
708  dlg.InstallPanel( new PANEL_SYM_LIB_TABLE( &dlg, globalTable, globalTablePath,
709  projectTable, projectTableFn.GetFullPath(),
710  aKiway->Prj().GetProjectPath() ) );
711 
712  if( dlg.ShowModal() == wxID_CANCEL )
713  return;
714 
715  if( dlg.m_GlobalTableChanged )
716  {
717  try
718  {
719  globalTable->Save( globalTablePath );
720  }
721  catch( const IO_ERROR& ioe )
722  {
723  msg.Printf( _( "Error saving global library table:\n\n%s" ), ioe.What() );
724  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
725  }
726  }
727 
728  if( dlg.m_ProjectTableChanged )
729  {
730 
731  try
732  {
733  projectTable->Save( projectTableFn.GetFullPath() );
734  }
735  catch( const IO_ERROR& ioe )
736  {
737  msg.Printf( _( "Error saving project-specific library table:\n\n%s" ), ioe.What() );
738  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
739  }
740  }
741 
742  auto editor = (LIB_EDIT_FRAME*) aKiway->Player( FRAME_SCH_LIB_EDITOR, false );
743 
744  if( editor )
745  editor->SyncLibraries( true );
746 
747  LIB_VIEW_FRAME* viewer = (LIB_VIEW_FRAME*) aKiway->Player( FRAME_SCH_VIEWER, false );
748 
749  if( viewer )
750  viewer->ReCreateListLib();
751 }
static const wxString & GetSymbolLibTableFileName()
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
Symbol library viewer main window.
Definition: viewlib_frame.h:44
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
VTBL_ENTRY PROJECT & Prj() const
Function Prj returns the PROJECT associated with this KIWAY.
Definition: kiway.cpp:142
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
Dialog to show and edit symbol library tables.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
The symbol library editor main window.
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
bool ReCreateListLib()
Creates or recreates a sorted list of currently loaded libraries.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
static wxString GetGlobalTableFileName()
Fetch the global symbol library table file name.