KiCad PCB EDA Suite
Loading...
Searching...
No Matches
LIB_SYMBOL_LIBRARY_MANAGER Class Reference

Symbol library management helper that is specific to the symbol library editor frame. More...

#include <lib_symbol_library_manager.h>

Inheritance diagram for LIB_SYMBOL_LIBRARY_MANAGER:
SYMBOL_LIBRARY_MANAGER

Public Member Functions

 LIB_SYMBOL_LIBRARY_MANAGER (SYMBOL_EDIT_FRAME &aFrame)
 
void Sync (const wxString &aForceRefresh, std::function< void(int, int, const wxString &)> aProgressCallback)
 Updates the SYMBOL_LIBRARY_MANAGER data to synchronize with Symbol Library Table.
 
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetAdapter ()
 Return the adapter object that provides the stored data.
 
void Preload (PROGRESS_REPORTER &aReporter)
 Preloads all symbol libraries in the symbol library table using SYMBOL_ASYNC_LOADER.
 
int GetHash () const
 
bool HasModifications () const
 
int GetLibraryHash (const wxString &aLibrary) const
 Return a library hash value to determine if it has changed.
 
wxArrayString GetLibraryNames () const
 Return the array of library names.
 
SYMBOL_LIB_TABLE_ROWGetLibrary (const wxString &aLibrary) const
 Find a single library within the (aggregate) library table.
 
std::list< LIB_SYMBOL * > GetAliases (const wxString &aLibrary) const
 
bool CreateLibrary (const wxString &aFilePath, SYMBOL_LIB_TABLE &aTable)
 Create an empty library and adds it to the library table.
 
bool AddLibrary (const wxString &aFilePath, SYMBOL_LIB_TABLE &aTable)
 Add an existing library.
 
bool UpdateSymbol (LIB_SYMBOL *aSymbol, const wxString &aLibrary)
 Update the symbol buffer with a new version of the symbol.
 
bool UpdateSymbolAfterRename (LIB_SYMBOL *aSymbol, const wxString &oldAlias, const wxString &aLibrary)
 Update the symbol buffer with a new version of the symbol when the name has changed.
 
bool UpdateLibraryBuffer (const wxString &aLibrary)
 Update the library buffer with a new version of the library.
 
bool RemoveSymbol (const wxString &aName, const wxString &aLibrary)
 Remove the symbol from the symbol buffer.
 
LIB_SYMBOLGetAlias (const wxString &aAlias, const wxString &aLibrary) const
 Return either an alias of a working LIB_SYMBOL copy, or alias of the original symbol if there is no working copy.
 
LIB_SYMBOLGetBufferedSymbol (const wxString &aAlias, const wxString &aLibrary)
 Return the symbol copy from the buffer.
 
SCH_SCREENGetScreen (const wxString &aAlias, const wxString &aLibrary)
 Return the screen used to edit a specific symbol.
 
bool SymbolExists (const wxString &aAlias, const wxString &aLibrary) const
 Return true if symbol with a specific alias exists in library (either original one or buffered).
 
bool LibraryExists (const wxString &aLibrary, bool aCheckEnabled=false) const
 Return true if library exists.
 
bool IsLibraryLoaded (const wxString &aLibrary) const
 Return true if the library was successfully loaded.
 
bool IsLibraryModified (const wxString &aLibrary) const
 Return true if library has unsaved modifications.
 
bool IsSymbolModified (const wxString &aAlias, const wxString &aLibrary) const
 Return true if symbol has unsaved modifications.
 
void SetSymbolModified (const wxString &aAlias, const wxString &aLibrary)
 
bool ClearLibraryModified (const wxString &aLibrary) const
 Clear the modified flag for all symbols in a library.
 
bool ClearSymbolModified (const wxString &aAlias, const wxString &aLibrary) const
 Clear the modified flag for a symbol.
 
bool IsLibraryReadOnly (const wxString &aLibrary) const
 Return true if the library is stored in a read-only file.
 
bool SaveLibrary (const wxString &aLibrary, const wxString &aFileName, SCH_IO_MGR::SCH_FILE_T aFileType=SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY)
 Save library to a file, including unsaved changes.
 
LIB_ID RevertSymbol (const wxString &aAlias, const wxString &aLibrary)
 Revert unsaved changes for a symbolicular symbol.
 
bool RevertLibrary (const wxString &aLibrary)
 Revert unsaved changes for a symbolicular library.
 
bool RevertAll ()
 Revert all pending changes.
 
wxString GetUniqueLibraryName () const
 Return a library name that is not currently in use.
 
void GetSymbolNames (const wxString &aLibName, wxArrayString &aSymbolNames, SYMBOL_NAME_FILTER aFilter=SYMBOL_NAME_FILTER::ALL)
 
bool HasDerivedSymbols (const wxString &aSymbolName, const wxString &aLibraryName)
 Check if symbol aSymbolName in library aLibraryName is a root symbol that has derived symbols.
 
size_t GetLibraryCount () const
 

Protected Member Functions

void OnDataChanged () const override
 Extract library name basing on the file name.
 
bool addLibrary (const wxString &aFilePath, bool aCreate, SYMBOL_LIB_TABLE &aTable)
 Return the current Symbol Library Table.
 
SYMBOL_LIB_TABLEsymTable () const
 Class to store a working copy of a LIB_SYMBOL object and editor context.
 
std::set< LIB_SYMBOL * > getOriginalSymbols (const wxString &aLibrary)
 Return a set of LIB_SYMBOL objects belonging to the original library.
 
LIB_BUFFERgetLibraryBuffer (const wxString &aLibrary)
 Return an existing library buffer or creates one to using Symbol Library Table to get the original data.
 

Static Protected Member Functions

static wxString getLibraryName (const wxString &aFilePath)
 Helper function to add either existing or create new library.
 

Protected Attributes

std::map< wxString, LIB_BUFFERm_libs
 The library buffers.
 
SCH_BASE_FRAMEm_frame
 Parent frame.
 
LIB_LOGGERm_logger
 

Private Member Functions

SYMBOL_TREE_SYNCHRONIZING_ADAPTERgetAdapter ()
 

Private Attributes

wxObjectDataPtr< LIB_TREE_MODEL_ADAPTERm_adapter
 
int m_syncHash
 Symbol lib table hash value from last synchronization.
 

Detailed Description

Symbol library management helper that is specific to the symbol library editor frame.

The base class handles library manipulation; this one also handles synchronizing the LIB_TREE.

Definition at line 32 of file lib_symbol_library_manager.h.

Constructor & Destructor Documentation

◆ LIB_SYMBOL_LIBRARY_MANAGER()

LIB_SYMBOL_LIBRARY_MANAGER::LIB_SYMBOL_LIBRARY_MANAGER ( SYMBOL_EDIT_FRAME aFrame)

Member Function Documentation

◆ addLibrary()

◆ AddLibrary()

bool SYMBOL_LIBRARY_MANAGER::AddLibrary ( const wxString &  aFilePath,
SYMBOL_LIB_TABLE aTable 
)
inlineinherited

Add an existing library.

The library is added to the library table as well.

Definition at line 230 of file symbol_library_manager.h.

References SYMBOL_LIBRARY_MANAGER::addLibrary().

Referenced by SYMBOL_EDIT_FRAME::AddLibraryFile(), and SYMBOL_EDIT_FRAME::DdAddLibrary().

◆ ClearLibraryModified()

bool SYMBOL_LIBRARY_MANAGER::ClearLibraryModified ( const wxString &  aLibrary) const
inherited

Clear the modified flag for all symbols in a library.

Definition at line 317 of file symbol_library_manager.cpp.

References SYMBOL_LIBRARY_MANAGER::m_libs, and BASE_SCREEN::SetContentModified().

Referenced by SYMBOL_EDIT_FRAME::saveLibrary().

◆ ClearSymbolModified()

bool SYMBOL_LIBRARY_MANAGER::ClearSymbolModified ( const wxString &  aAlias,
const wxString &  aLibrary 
) const
inherited

Clear the modified flag for a symbol.

Definition at line 336 of file symbol_library_manager.cpp.

References SYMBOL_LIBRARY_MANAGER::m_libs.

Referenced by SYMBOL_EDIT_FRAME::Revert().

◆ CreateLibrary()

bool SYMBOL_LIBRARY_MANAGER::CreateLibrary ( const wxString &  aFilePath,
SYMBOL_LIB_TABLE aTable 
)
inlineinherited

Create an empty library and adds it to the library table.

The library file is created.

Definition at line 222 of file symbol_library_manager.h.

References SYMBOL_LIBRARY_MANAGER::addLibrary().

Referenced by SYMBOL_EDIT_FRAME::AddLibraryFile(), and SCH_EDITOR_CONTROL::ExportSymbolsToLibrary().

◆ GetAdapter()

wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & LIB_SYMBOL_LIBRARY_MANAGER::GetAdapter ( )
inline

◆ getAdapter()

SYMBOL_TREE_SYNCHRONIZING_ADAPTER * LIB_SYMBOL_LIBRARY_MANAGER::getAdapter ( )
inlineprivate

Definition at line 52 of file lib_symbol_library_manager.h.

References m_adapter.

Referenced by Sync().

◆ GetAlias()

LIB_SYMBOL * SYMBOL_LIBRARY_MANAGER::GetAlias ( const wxString &  aAlias,
const wxString &  aLibrary 
) const
inherited

◆ GetAliases()

std::list< LIB_SYMBOL * > SYMBOL_LIBRARY_MANAGER::GetAliases ( const wxString &  aLibrary) const
inherited

◆ GetBufferedSymbol()

◆ GetHash()

◆ GetLibrary()

◆ getLibraryBuffer()

◆ GetLibraryCount()

size_t SYMBOL_LIBRARY_MANAGER::GetLibraryCount ( ) const
inherited

◆ GetLibraryHash()

int SYMBOL_LIBRARY_MANAGER::GetLibraryHash ( const wxString &  aLibrary) const
inherited

Return a library hash value to determine if it has changed.

For buffered libraries, it returns a number corresponding to the number of modifications. For original libraries, hash is computed basing on the library URI. Returns -1 when the requested library does not exist.

Definition at line 118 of file symbol_library_manager.cpp.

References LIB_TABLE_ROW::GetFullURI(), SYMBOL_LIBRARY_MANAGER::GetLibrary(), and SYMBOL_LIBRARY_MANAGER::m_libs.

Referenced by SYMBOL_TREE_SYNCHRONIZING_ADAPTER::updateLibrary().

◆ getLibraryName()

wxString SYMBOL_LIBRARY_MANAGER::getLibraryName ( const wxString &  aFilePath)
staticprotectedinherited

Helper function to add either existing or create new library.

Definition at line 726 of file symbol_library_manager.cpp.

Referenced by SYMBOL_LIBRARY_MANAGER::addLibrary().

◆ GetLibraryNames()

wxArrayString SYMBOL_LIBRARY_MANAGER::GetLibraryNames ( ) const
inherited

◆ getOriginalSymbols()

std::set< LIB_SYMBOL * > SYMBOL_LIBRARY_MANAGER::getOriginalSymbols ( const wxString &  aLibrary)
protectedinherited

◆ GetScreen()

SCH_SCREEN * SYMBOL_LIBRARY_MANAGER::GetScreen ( const wxString &  aAlias,
const wxString &  aLibrary 
)
inherited

Return the screen used to edit a specific symbol.

SYMBOL_LIBRARY_MANAGER retains the ownership.

Definition at line 466 of file symbol_library_manager.cpp.

References LIB_BUFFER::GetBuffer(), SYMBOL_LIBRARY_MANAGER::LibraryExists(), and SYMBOL_LIBRARY_MANAGER::m_libs.

Referenced by SYMBOL_EDIT_FRAME::KiwayMailIn(), and SYMBOL_EDIT_FRAME::LoadOneLibrarySymbolAux().

◆ GetSymbolNames()

void SYMBOL_LIBRARY_MANAGER::GetSymbolNames ( const wxString &  aLibName,
wxArrayString &  aSymbolNames,
SYMBOL_NAME_FILTER  aFilter = SYMBOL_NAME_FILTER::ALL 
)
inherited

◆ GetUniqueLibraryName()

wxString SYMBOL_LIBRARY_MANAGER::GetUniqueLibraryName ( ) const
inherited

Return a library name that is not currently in use.

Used for generating names for new libraries.

Definition at line 681 of file symbol_library_manager.cpp.

References SYMBOL_LIBRARY_MANAGER::LibraryExists(), and name.

Referenced by SYMBOL_EDIT_FRAME::AddLibraryFile().

◆ HasDerivedSymbols()

bool SYMBOL_LIBRARY_MANAGER::HasDerivedSymbols ( const wxString &  aSymbolName,
const wxString &  aLibraryName 
)
inherited

Check if symbol aSymbolName in library aLibraryName is a root symbol that has derived symbols.

Returns
true if \aSymbolName in aLibraryName has derived symbols.

Definition at line 711 of file symbol_library_manager.cpp.

References SYMBOL_LIBRARY_MANAGER::getLibraryBuffer(), and LIB_BUFFER::HasDerivedSymbols().

Referenced by SYMBOL_EDIT_FRAME::DeleteSymbolFromLibrary().

◆ HasModifications()

bool SYMBOL_LIBRARY_MANAGER::HasModifications ( ) const
inherited

◆ IsLibraryLoaded()

bool SYMBOL_LIBRARY_MANAGER::IsLibraryLoaded ( const wxString &  aLibrary) const
inherited

◆ IsLibraryModified()

bool SYMBOL_LIBRARY_MANAGER::IsLibraryModified ( const wxString &  aLibrary) const
inherited

◆ IsLibraryReadOnly()

◆ IsSymbolModified()

bool SYMBOL_LIBRARY_MANAGER::IsSymbolModified ( const wxString &  aAlias,
const wxString &  aLibrary 
) const
inherited

◆ LibraryExists()

◆ OnDataChanged()

void LIB_SYMBOL_LIBRARY_MANAGER::OnDataChanged ( ) const
overrideprotectedvirtual

Extract library name basing on the file name.

Reimplemented from SYMBOL_LIBRARY_MANAGER.

Definition at line 48 of file lib_symbol_library_manager.cpp.

References SYMBOL_LIBRARY_MANAGER::m_frame.

◆ Preload()

void SYMBOL_LIBRARY_MANAGER::Preload ( PROGRESS_REPORTER aReporter)
inherited

Preloads all symbol libraries in the symbol library table using SYMBOL_ASYNC_LOADER.

Call before the first call to Sync() to get better performance.

Parameters
aReporteris used to report progress of the load

Definition at line 61 of file symbol_library_manager.cpp.

References _, HTML_MESSAGE_BOX::AddHTML_Text(), SYMBOL_ASYNC_LOADER::Done(), SYMBOL_ASYNC_LOADER::GetErrors(), SYMBOL_ASYNC_LOADER::Join(), PROGRESS_REPORTER::KeepRefreshing(), SYMBOL_LIBRARY_MANAGER::m_frame, HTML_MESSAGE_BOX::MessageSet(), DIALOG_SHIM::ShowModal(), SYMBOL_ASYNC_LOADER::Start(), and SYMBOL_LIBRARY_MANAGER::symTable().

◆ RemoveSymbol()

bool SYMBOL_LIBRARY_MANAGER::RemoveSymbol ( const wxString &  aName,
const wxString &  aLibrary 
)
inherited

Remove the symbol from the symbol buffer.

It is required to save the library to have the symbol removed in the schematic editor.

Definition at line 600 of file symbol_library_manager.cpp.

References LIB_BUFFER::DeleteBuffer(), LIB_BUFFER::GetBuffer(), SYMBOL_LIBRARY_MANAGER::getLibraryBuffer(), and SYMBOL_LIBRARY_MANAGER::OnDataChanged().

Referenced by SYMBOL_EDIT_FRAME::DeleteSymbolFromLibrary().

◆ RevertAll()

bool SYMBOL_LIBRARY_MANAGER::RevertAll ( )
inherited

Revert all pending changes.

Returns
True if all changes successfully reverted.

Definition at line 574 of file symbol_library_manager.cpp.

References SYMBOL_LIBRARY_MANAGER::GetHash(), SYMBOL_LIBRARY_MANAGER::m_libs, and SYMBOL_LIBRARY_MANAGER::RevertSymbol().

Referenced by SYMBOL_EDIT_FRAME::RevertAll().

◆ RevertLibrary()

bool SYMBOL_LIBRARY_MANAGER::RevertLibrary ( const wxString &  aLibrary)
inherited

Revert unsaved changes for a symbolicular library.

Returns
True on success, false otherwise.

Definition at line 560 of file symbol_library_manager.cpp.

References SYMBOL_LIBRARY_MANAGER::m_libs, and SYMBOL_LIBRARY_MANAGER::OnDataChanged().

Referenced by SYMBOL_EDIT_FRAME::Revert().

◆ RevertSymbol()

LIB_ID SYMBOL_LIBRARY_MANAGER::RevertSymbol ( const wxString &  aAlias,
const wxString &  aLibrary 
)
inherited

Revert unsaved changes for a symbolicular symbol.

Returns
The LIB_ID of the reverted symbol (which may be different in the case of a rename)

Definition at line 534 of file symbol_library_manager.cpp.

References LIB_SYMBOL::GetName(), SYMBOL_LIBRARY_MANAGER::m_libs, SYMBOL_LIBRARY_MANAGER::OnDataChanged(), and SYMBOL_LIBRARY_MANAGER::UpdateSymbolAfterRename().

Referenced by SYMBOL_EDIT_FRAME::Revert(), and SYMBOL_LIBRARY_MANAGER::RevertAll().

◆ SaveLibrary()

bool SYMBOL_LIBRARY_MANAGER::SaveLibrary ( const wxString &  aLibrary,
const wxString &  aFileName,
SCH_IO_MGR::SCH_FILE_T  aFileType = SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY 
)
inherited

◆ SetSymbolModified()

void SYMBOL_LIBRARY_MANAGER::SetSymbolModified ( const wxString &  aAlias,
const wxString &  aLibrary 
)
inherited

◆ SymbolExists()

◆ symTable()

◆ Sync()

void LIB_SYMBOL_LIBRARY_MANAGER::Sync ( const wxString &  aForceRefresh,
std::function< void(int, int, const wxString &)>  aProgressCallback 
)

◆ UpdateLibraryBuffer()

bool SYMBOL_LIBRARY_MANAGER::UpdateLibraryBuffer ( const wxString &  aLibrary)
inherited

Update the library buffer with a new version of the library.

Definition at line 851 of file symbol_library_manager.cpp.

References _, SYMBOL_LIBRARY_MANAGER::getLibraryBuffer(), and SYMBOL_LIBRARY_MANAGER::m_libs.

Referenced by SYMBOL_EDIT_FRAME::KiwayMailIn().

◆ UpdateSymbol()

bool SYMBOL_LIBRARY_MANAGER::UpdateSymbol ( LIB_SYMBOL aSymbol,
const wxString &  aLibrary 
)
inherited

◆ UpdateSymbolAfterRename()

bool SYMBOL_LIBRARY_MANAGER::UpdateSymbolAfterRename ( LIB_SYMBOL aSymbol,
const wxString &  oldAlias,
const wxString &  aLibrary 
)
inherited

Update the symbol buffer with a new version of the symbol when the name has changed.

The old library buffer will be deleted and a new one created with the new name.

Definition at line 519 of file symbol_library_manager.cpp.

References LIB_BUFFER::GetBuffer(), SYMBOL_LIBRARY_MANAGER::getLibraryBuffer(), SYMBOL_LIBRARY_MANAGER::OnDataChanged(), and LIB_BUFFER::UpdateBuffer().

Referenced by SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), SYMBOL_EDITOR_CONTROL::RenameSymbol(), SYMBOL_LIBRARY_MANAGER::RevertSymbol(), and SYMBOL_EDIT_FRAME::UpdateAfterSymbolProperties().

Member Data Documentation

◆ m_adapter

wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> LIB_SYMBOL_LIBRARY_MANAGER::m_adapter
private

Definition at line 57 of file lib_symbol_library_manager.h.

Referenced by GetAdapter(), getAdapter(), and LIB_SYMBOL_LIBRARY_MANAGER().

◆ m_frame

◆ m_libs

◆ m_logger

LIB_LOGGER* SYMBOL_LIBRARY_MANAGER::m_logger
protectedinherited

◆ m_syncHash

int LIB_SYMBOL_LIBRARY_MANAGER::m_syncHash
private

Symbol lib table hash value from last synchronization.

Definition at line 59 of file lib_symbol_library_manager.h.

Referenced by Sync().


The documentation for this class was generated from the following files: