|
KiCad PCB EDA Suite
|
Symbol library management helper that is specific to the symbol library editor frame. More...
#include <lib_symbol_library_manager.h>
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. | |
| bool | CreateNewSymbol (const wxString &aLibrary, const NEW_SYMBOL_PROPERTIES &aProps) |
| wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & | GetAdapter () |
| Return the adapter object that provides the stored data. | |
| 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. | |
| std::list< LIB_SYMBOL * > | EnumerateSymbols (const wxString &aLibrary) const |
| bool | CreateLibrary (const wxString &aFilePath, LIBRARY_TABLE_SCOPE aScope) |
| Create an empty library and adds it to the library table. | |
| bool | AddLibrary (const wxString &aFilePath, LIBRARY_TABLE_SCOPE aScope) |
| 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 &aOldSymbolName, 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 &aSymbolName, const wxString &aLibrary) |
| Remove the symbol from the symbol buffer. | |
| LIB_SYMBOL * | GetSymbol (const wxString &aSymbolName, 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_SYMBOL * | GetBufferedSymbol (const wxString &aSymbolName, const wxString &aLibrary) |
| Return the symbol copy from the buffer. | |
| SCH_SCREEN * | GetScreen (const wxString &aSymbolName, const wxString &aLibrary) |
| Return the screen used to edit a specific symbol. | |
| bool | SymbolExists (const wxString &aSymbolName, const wxString &aLibrary) const |
| Return true if symbol with a specific alias exists in library (either original one or buffered). | |
| bool | SymbolNameInUse (const wxString &aName, const wxString &aLibrary) |
| Return true if the symbol name is already in use in the specified library. | |
| 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 &aSymbolName, const wxString &aLibrary) const |
| Return true if symbol has unsaved modifications. | |
| void | SetSymbolModified (const wxString &aSymbolName, const wxString &aLibrary) |
| bool | ClearLibraryModified (const wxString &aLibrary) const |
| Clear the modified flag for all symbols in a library. | |
| bool | ClearSymbolModified (const wxString &aSymbolName, 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 &aSymbolName, const wxString &aLibrary) |
| Revert unsaved changes for a symbol. | |
| bool | RevertLibrary (const wxString &aLibrary) |
| Revert unsaved changes for a symbol 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) |
| size_t | GetDerivedSymbolNames (const wxString &aSymbolName, const wxString &aLibraryName, wxArrayString &aList) |
| Fetch all of the symbols derived from a aSymbolName into aList. | |
| size_t | GetLibraryCount () const |
Static Public Member Functions | |
| static std::unique_ptr< LIB_SYMBOL > | CreateSymbol (const NEW_SYMBOL_PROPERTIES &aProps, LIB_SYMBOL *aParent) |
Protected Member Functions | |
| void | OnDataChanged () const override |
| bool | addLibrary (const wxString &aFilePath, bool aCreate, LIBRARY_TABLE_SCOPE aScope) |
| Helper function to add either existing or create new library. | |
| std::set< LIB_SYMBOL * > | getOriginalSymbols (const wxString &aLibrary) |
| Return a set of LIB_SYMBOL objects belonging to the original library. | |
| LIB_BUFFER & | getLibraryBuffer (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) |
| Extract library name basing on the file name. | |
Protected Attributes | |
| std::map< wxString, LIB_BUFFER > | m_libs |
| The library buffers. | |
| SCH_BASE_FRAME & | m_frame |
| Parent frame. | |
| LIB_LOGGER * | m_logger |
Private Member Functions | |
| SYMBOL_TREE_SYNCHRONIZING_ADAPTER * | getAdapter () |
Private Attributes | |
| wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > | m_adapter |
| int | m_syncHash |
| Symbol lib table hash value from last synchronization. | |
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 53 of file lib_symbol_library_manager.h.
| LIB_SYMBOL_LIBRARY_MANAGER::LIB_SYMBOL_LIBRARY_MANAGER | ( | SYMBOL_EDIT_FRAME & | aFrame | ) |
Definition at line 31 of file lib_symbol_library_manager.cpp.
References SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create(), m_adapter, m_syncHash, and SYMBOL_LIBRARY_MANAGER::SYMBOL_LIBRARY_MANAGER().
|
inlineinherited |
Add an existing library.
The library is added to the library table as well.
Definition at line 222 of file symbol_library_manager.h.
References addLibrary().
|
protectedinherited |
Helper function to add either existing or create new library.
Definition at line 676 of file symbol_library_manager.cpp.
References LIBRARY_MANAGER_ADAPTER::CreateLibrary(), PGM_BASE::GetLibraryManager(), getLibraryName(), SCH_IO_MGR::GuessPluginTypeFromLibPath(), KICTL_CREATE, LibraryExists(), m_frame, NormalizePath(), OnDataChanged(), Pgm(), LIBRARY_TABLE_ROW::SetNickname(), LIBRARY_TABLE_ROW::SetType(), LIBRARY_TABLE_ROW::SetURI(), SCH_IO_MGR::ShowType(), SYMBOL, PROJECT_SCH::SymbolLibAdapter(), LIBRARY_MANAGER::Table(), and table.
Referenced by AddLibrary(), and CreateLibrary().
|
inherited |
Clear the modified flag for all symbols in a library.
Definition at line 260 of file symbol_library_manager.cpp.
References m_libs, and BASE_SCREEN::SetContentModified().
|
inherited |
Clear the modified flag for a symbol.
Definition at line 279 of file symbol_library_manager.cpp.
References m_libs.
|
inlineinherited |
Create an empty library and adds it to the library table.
The library file is created.
Definition at line 212 of file symbol_library_manager.h.
References addLibrary().
Referenced by SCH_BASE_FRAME::SelectLibrary().
| bool LIB_SYMBOL_LIBRARY_MANAGER::CreateNewSymbol | ( | const wxString & | aLibrary, |
| const NEW_SYMBOL_PROPERTIES & | aProps ) |
Definition at line 152 of file lib_symbol_library_manager.cpp.
References CreateSymbol(), SYMBOL_LIBRARY_MANAGER::GetSymbol(), NEW_SYMBOL_PROPERTIES::parentSymbolName, and SYMBOL_LIBRARY_MANAGER::UpdateSymbol().
|
static |
Definition at line 54 of file lib_symbol_library_manager.cpp.
References NEW_SYMBOL_PROPERTIES::alternateBodyStyle, DATASHEET, FOOTPRINT, LIB_SYMBOL::GetField(), LIB_SYMBOL::GetFields(), NEW_SYMBOL_PROPERTIES::includeInBom, NEW_SYMBOL_PROPERTIES::includeOnBoard, LIB_SYMBOL::IsPower(), NEW_SYMBOL_PROPERTIES::keepContentUserFields, NEW_SYMBOL_PROPERTIES::keepDatasheet, NEW_SYMBOL_PROPERTIES::keepFootprint, MANDATORY_FIELDS, NEW_SYMBOL_PROPERTIES::name, NEW_SYMBOL_PROPERTIES::pinNameInside, NEW_SYMBOL_PROPERTIES::pinTextPosition, NEW_SYMBOL_PROPERTIES::powerSymbol, REFERENCE, NEW_SYMBOL_PROPERTIES::reference, EDA_ITEM::SetParent(), SCH_FIELD::SetText(), NEW_SYMBOL_PROPERTIES::showPinName, NEW_SYMBOL_PROPERTIES::showPinNumber, NEW_SYMBOL_PROPERTIES::transferUserFields, NEW_SYMBOL_PROPERTIES::unitCount, NEW_SYMBOL_PROPERTIES::unitsInterchangeable, USER, and VALUE.
Referenced by BOOST_AUTO_TEST_CASE(), and CreateNewSymbol().
|
inherited |
Definition at line 308 of file symbol_library_manager.cpp.
References SYMBOL_LIBRARY_ADAPTER::GetSymbols(), m_frame, m_libs, and PROJECT_SCH::SymbolLibAdapter().
|
inline |
Return the adapter object that provides the stored data.
Definition at line 72 of file lib_symbol_library_manager.h.
References m_adapter.
Referenced by SYMBOL_EDITOR_CONTROL::FlattenSymbol(), and SYMBOL_EDITOR_CONTROL::RenameSymbol().
|
inlineprivate |
Definition at line 78 of file lib_symbol_library_manager.h.
References m_adapter.
Referenced by Sync().
|
inherited |
Return the symbol copy from the buffer.
In case it does not exist yet, the copy is created. SYMBOL_LIBRARY_MANAGER retains the ownership.
Definition at line 330 of file symbol_library_manager.cpp.
References _, LIB_BUFFER::CreateBuffer(), DisplayErrorMessage(), getLibraryBuffer(), LIB_SYMBOL::GetName(), LIB_SYMBOL::GetParent(), LIB_BUFFER::GetSymbol(), LIB_SYMBOL::IsDerived(), SYMBOL_LIBRARY_ADAPTER::LoadSymbol(), m_frame, PROJECT_SCH::SymbolLibAdapter(), THROW_IO_ERROR, and IO_ERROR::What().
Referenced by SYMBOL_EDITOR_CONTROL::FlattenSymbol(), SYMBOL_EDITOR_CONTROL::RenameSymbol(), and DIALOG_LIB_FIELDS_TABLE::setScope().
|
inherited |
Fetch all of the symbols derived from a aSymbolName into aList.
Definition at line 653 of file symbol_library_manager.cpp.
References LIB_BUFFER::GetDerivedSymbolNames(), and getLibraryBuffer().
Referenced by DIALOG_LIB_FIELDS_TABLE::setScope().
|
inherited |
Definition at line 73 of file symbol_library_manager.cpp.
References SYMBOL_LIBRARY_ADAPTER::GetModifyHash(), m_frame, and PROJECT_SCH::SymbolLibAdapter().
Referenced by RevertAll().
|
protectedinherited |
Return an existing library buffer or creates one to using symbol library table to get the original data.
Definition at line 735 of file symbol_library_manager.cpp.
References LIB_BUFFER::CreateBuffer(), getOriginalSymbols(), LIB_BUFFER::GetSymbol(), and m_libs.
Referenced by GetBufferedSymbol(), GetDerivedSymbolNames(), GetSymbolNames(), RemoveSymbol(), UpdateLibraryBuffer(), UpdateSymbol(), and UpdateSymbolAfterRename().
|
inherited |
Definition at line 662 of file symbol_library_manager.cpp.
References LIBRARY_MANAGER_ADAPTER::GetLibraryNames(), m_frame, and PROJECT_SCH::SymbolLibAdapter().
|
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 80 of file symbol_library_manager.cpp.
References LIBRARY_MANAGER::GetFullURI(), PGM_BASE::GetLibraryManager(), m_libs, Pgm(), and SYMBOL.
|
staticprotectedinherited |
Extract library name basing on the file name.
Definition at line 669 of file symbol_library_manager.cpp.
Referenced by addLibrary().
|
inherited |
Return the array of library names.
Definition at line 96 of file symbol_library_manager.cpp.
References PGM_BASE::GetLibraryManager(), Pgm(), res, LIBRARY_MANAGER::Rows(), SCH_IO_MGR::ShowType(), and SYMBOL.
|
protectedinherited |
Return a set of LIB_SYMBOL objects belonging to the original library.
Definition at line 721 of file symbol_library_manager.cpp.
References SYMBOL_LIBRARY_ADAPTER::GetSymbols(), LibraryExists(), m_frame, and PROJECT_SCH::SymbolLibAdapter().
Referenced by getLibraryBuffer(), and SaveLibrary().
|
inherited |
Return the screen used to edit a specific symbol.
SYMBOL_LIBRARY_MANAGER retains the ownership.
Definition at line 392 of file symbol_library_manager.cpp.
References LIB_BUFFER::GetBuffer(), and m_libs.
|
inherited |
Return either an alias of a working LIB_SYMBOL copy, or alias of the original symbol if there is no working copy.
Definition at line 532 of file symbol_library_manager.cpp.
References _, DisplayErrorMessage(), SYMBOL_LIBRARY_ADAPTER::LoadSymbol(), m_frame, m_libs, PROJECT_SCH::SymbolLibAdapter(), and IO_ERROR::What().
Referenced by CheckSavingIntoOwnInheritance(), LIB_SYMBOL_LIBRARY_MANAGER::CreateNewSymbol(), and SYMBOL_EDITOR_CONTROL::Init().
|
inherited |
Definition at line 644 of file symbol_library_manager.cpp.
References getLibraryBuffer(), and LIB_BUFFER::GetSymbolNames().
Referenced by DIALOG_LIB_FIELDS_TABLE::setScope(), and SymbolNameInUse().
|
inherited |
Return a library name that is not currently in use.
Used for generating names for new libraries.
Definition at line 624 of file symbol_library_manager.cpp.
References LibraryExists(), and name.
|
inherited |
Definition at line 61 of file symbol_library_manager.cpp.
|
inherited |
Return true if the library was successfully loaded.
Definition at line 301 of file symbol_library_manager.cpp.
References LIBRARY_MANAGER_ADAPTER::IsLibraryLoaded(), m_frame, and PROJECT_SCH::SymbolLibAdapter().
|
inherited |
Return true if library has unsaved modifications.
Definition at line 223 of file symbol_library_manager.cpp.
References m_libs.
Referenced by SYMBOL_EDITOR_CONTROL::Init().
|
inherited |
Return true if the library is stored in a read-only file.
Definition at line 294 of file symbol_library_manager.cpp.
References SYMBOL_LIBRARY_ADAPTER::IsSymbolLibWritable(), m_frame, and PROJECT_SCH::SymbolLibAdapter().
Referenced by SYMBOL_EDITOR_CONTROL::AddSymbol(), SYMBOL_EDITOR_CONTROL::CutCopyDelete(), and SYMBOL_EDITOR_CONTROL::DuplicateSymbol().
|
inherited |
Return true if symbol has unsaved modifications.
Definition at line 230 of file symbol_library_manager.cpp.
References LIB_BUFFER::GetBuffer(), and m_libs.
|
inherited |
Return true if library exists.
If aCheckEnabled is set, then the library must also be enabled in the library table.
Definition at line 610 of file symbol_library_manager.cpp.
References LIBRARY_MANAGER_ADAPTER::HasLibrary(), m_frame, m_libs, and PROJECT_SCH::SymbolLibAdapter().
Referenced by addLibrary(), SYMBOL_EDITOR_CONTROL::AddSymbol(), SYMBOL_EDITOR_CONTROL::CutCopyDelete(), SYMBOL_EDITOR_CONTROL::DuplicateSymbol(), getOriginalSymbols(), GetUniqueLibraryName(), and SYMBOL_EDITOR_CONTROL::RenameSymbol().
|
overrideprotectedvirtual |
Reimplemented from SYMBOL_LIBRARY_MANAGER.
Definition at line 169 of file lib_symbol_library_manager.cpp.
References SYMBOL_LIBRARY_MANAGER::m_frame.
|
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 517 of file symbol_library_manager.cpp.
References LIB_BUFFER::DeleteBuffer(), LIB_BUFFER::GetBuffer(), getLibraryBuffer(), and OnDataChanged().
Referenced by SYMBOL_EDITOR_CONTROL::RenameSymbol().
|
inherited |
Revert all pending changes.
Definition at line 491 of file symbol_library_manager.cpp.
References GetHash(), m_libs, and RevertSymbol().
|
inherited |
Revert unsaved changes for a symbol library.
Definition at line 477 of file symbol_library_manager.cpp.
References m_libs, and OnDataChanged().
|
inherited |
Revert unsaved changes for a symbol.
Definition at line 451 of file symbol_library_manager.cpp.
References LIB_SYMBOL::GetName(), m_libs, OnDataChanged(), and UpdateSymbolAfterRename().
Referenced by RevertAll().
|
inherited |
Save library to a file, including unsaved changes.
| aLibrary | is the library name. |
| aFileName | is the target file name. |
Definition at line 115 of file symbol_library_manager.cpp.
References LIB_BUFFER::ClearDeletedBuffer(), FN_NORMALIZE_FLAGS, LIB_BUFFER::GetBuffers(), LIBRARY_MANAGER::GetFullURI(), PGM_BASE::GetLibraryManager(), LIB_SYMBOL::GetName(), getOriginalSymbols(), m_libs, Pgm(), SCH_IO_KICAD_LEGACY::PropBuffering, res, LIB_BUFFER::SaveBuffer(), LIB_SYMBOL::SetParent(), and SYMBOL.
|
inherited |
Definition at line 244 of file symbol_library_manager.cpp.
References LIB_BUFFER::GetBuffer(), and m_libs.
Referenced by SYMBOL_EDITOR_CONTROL::RenameSymbol().
|
inherited |
Return true if symbol with a specific alias exists in library (either original one or buffered).
Definition at line 567 of file symbol_library_manager.cpp.
References SYMBOL_LIBRARY_ADAPTER::LoadSymbol(), m_frame, m_libs, and PROJECT_SCH::SymbolLibAdapter().
Referenced by SYMBOL_EDITOR_CONTROL::RenameSymbol().
|
inherited |
Return true if the symbol name is already in use in the specified library.
Definition at line 591 of file symbol_library_manager.cpp.
References GetSymbolNames(), and UnescapeString().
Referenced by CheckForParentalChainConflicts(), CheckSavingIntoOwnInheritance(), and SYMBOL_EDITOR_CONTROL::RenameSymbol().
| void LIB_SYMBOL_LIBRARY_MANAGER::Sync | ( | const wxString & | aForceRefresh, |
| std::function< void(int, int, const wxString &)> | aProgressCallback ) |
Updates the SYMBOL_LIBRARY_MANAGER data to synchronize with Symbol Library Table.
Definition at line 40 of file lib_symbol_library_manager.cpp.
References getAdapter(), SYMBOL_LIBRARY_ADAPTER::GetModifyHash(), SYMBOL_LIBRARY_MANAGER::m_frame, SYMBOL_LIBRARY_MANAGER::m_logger, m_syncHash, PROJECT_SCH::SymbolLibAdapter(), and SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync().
|
inherited |
Update the library buffer with a new version of the library.
Definition at line 778 of file symbol_library_manager.cpp.
References _, getLibraryBuffer(), and m_libs.
|
inherited |
Update the symbol buffer with a new version of the symbol.
The library buffer creates a copy of the symbol.
It is required to save the library to use the updated symbol in the schematic editor.
Definition at line 404 of file symbol_library_manager.cpp.
References LIB_BUFFER::CreateBuffer(), LIB_BUFFER::GetBuffer(), LIB_SYMBOL::GetLibId(), LIB_ID::GetLibItemName(), getLibraryBuffer(), LIB_SYMBOL::GetName(), BASE_SCREEN::SetContentModified(), and LIB_SYMBOL::SetLibId().
Referenced by LIB_SYMBOL_LIBRARY_MANAGER::CreateNewSymbol(), and SYMBOL_EDITOR_CONTROL::FlattenSymbol().
|
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 436 of file symbol_library_manager.cpp.
References LIB_BUFFER::GetBuffer(), getLibraryBuffer(), OnDataChanged(), and LIB_BUFFER::UpdateBuffer().
Referenced by SYMBOL_EDITOR_CONTROL::RenameSymbol(), and RevertSymbol().
|
private |
Definition at line 83 of file lib_symbol_library_manager.h.
Referenced by GetAdapter(), getAdapter(), and LIB_SYMBOL_LIBRARY_MANAGER().
|
protectedinherited |
Parent frame.
Definition at line 399 of file symbol_library_manager.h.
Referenced by addLibrary(), EnumerateSymbols(), GetBufferedSymbol(), GetHash(), GetLibraryCount(), getOriginalSymbols(), GetSymbol(), IsLibraryLoaded(), IsLibraryReadOnly(), LibraryExists(), LIB_SYMBOL_LIBRARY_MANAGER::OnDataChanged(), SYMBOL_LIBRARY_MANAGER(), SymbolExists(), and LIB_SYMBOL_LIBRARY_MANAGER::Sync().
|
protectedinherited |
The library buffers.
Definition at line 398 of file symbol_library_manager.h.
Referenced by ClearLibraryModified(), ClearSymbolModified(), EnumerateSymbols(), getLibraryBuffer(), GetLibraryHash(), GetScreen(), GetSymbol(), HasModifications(), IsLibraryModified(), IsSymbolModified(), LibraryExists(), RevertAll(), RevertLibrary(), RevertSymbol(), SaveLibrary(), SetSymbolModified(), SymbolExists(), and UpdateLibraryBuffer().
|
protectedinherited |
Definition at line 400 of file symbol_library_manager.h.
Referenced by SYMBOL_LIBRARY_MANAGER(), LIB_SYMBOL_LIBRARY_MANAGER::Sync(), and ~SYMBOL_LIBRARY_MANAGER().
|
private |
Symbol lib table hash value from last synchronization.
Definition at line 85 of file lib_symbol_library_manager.h.
Referenced by LIB_SYMBOL_LIBRARY_MANAGER(), and Sync().