KiCad PCB EDA Suite
panel_sym_lib_table.cpp File Reference
#include <set>
#include <wx/regex.h>
#include <fctsys.h>
#include <project.h>
#include <panel_sym_lib_table.h>
#include <lib_id.h>
#include <symbol_lib_table.h>
#include <lib_table_lexer.h>
#include <grid_tricks.h>
#include <widgets/wx_grid.h>
#include <confirm.h>
#include <bitmaps.h>
#include <lib_table_grid.h>
#include <wildcards_and_files_ext.h>
#include <env_paths.h>
#include <lib_edit_frame.h>
#include <viewlib_frame.h>
#include <kiway.h>
#include <widgets/grid_readonly_text_helpers.h>
#include <widgets/grid_text_button_helpers.h>

Go to the source code of this file.

Classes

class  SYMBOL_LIB_TABLE_GRID
 Build a wxGridTableBase by wrapping an SYMBOL_LIB_TABLE object. More...
 
class  SYMBOL_GRID_TRICKS
 

Functions

void InvokeSchEditSymbolLibTable (KIWAY *aKiway, wxWindow *aParent)
 

Function Documentation

◆ InvokeSchEditSymbolLibTable()

void InvokeSchEditSymbolLibTable ( KIWAY aKiway,
wxWindow *  aParent 
)

Definition at line 698 of file panel_sym_lib_table.cpp.

699 {
701  wxString globalTablePath = SYMBOL_LIB_TABLE::GetGlobalTableFileName();
702  SYMBOL_LIB_TABLE* projectTable = aKiway->Prj().SchSymbolLibTable();
703  wxString projectPath = aKiway->Prj().GetProjectPath();
704  wxFileName projectTableFn( projectPath, SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
705  wxString msg;
706 
707  DIALOG_EDIT_LIBRARY_TABLES dlg( aParent, _( "Symbol Libraries" ) );
708 
709  dlg.InstallPanel( new PANEL_SYM_LIB_TABLE( &dlg, globalTable, globalTablePath,
710  projectTable, projectTableFn.GetFullPath(),
711  aKiway->Prj().GetProjectPath() ) );
712 
713  if( dlg.ShowModal() == wxID_CANCEL )
714  return;
715 
716  if( dlg.m_GlobalTableChanged )
717  {
718  try
719  {
720  globalTable->Save( globalTablePath );
721  }
722  catch( const IO_ERROR& ioe )
723  {
724  msg.Printf( _( "Error saving global library table:\n\n%s" ), ioe.What() );
725  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
726  }
727  }
728 
729  if( dlg.m_ProjectTableChanged )
730  {
731 
732  try
733  {
734  projectTable->Save( projectTableFn.GetFullPath() );
735  }
736  catch( const IO_ERROR& ioe )
737  {
738  msg.Printf( _( "Error saving project-specific library table:\n\n%s" ), ioe.What() );
739  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
740  }
741  }
742 
743  auto editor = (LIB_EDIT_FRAME*) aKiway->Player( FRAME_SCH_LIB_EDITOR, false );
744 
745  if( editor )
746  editor->SyncLibraries( true );
747 
748  LIB_VIEW_FRAME* viewer = (LIB_VIEW_FRAME*) aKiway->Player( FRAME_SCH_VIEWER, false );
749 
750  if( viewer )
751  viewer->ReCreateListLib();
752 }
static const wxString & GetSymbolLibTableFileName()
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
VTBL_ENTRY PROJECT & Prj() const
Function Prj returns the PROJECT associated with this KIWAY.
Definition: kiway.cpp:142
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
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
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Dialog to show and edit symbol library tables.
The symbol library editor main window.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
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.

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, 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().