|
KiCad PCB EDA Suite
|
#include <cstdint>#include <memory>#include <vector>#include <lib_id.h>#include <wx/filename.h>#include <wx/string.h>Go to the source code of this file.
Functions | |
| wxString | SanitizeRemoteFileComponent (const wxString &aValue, const wxString &aDefault, bool aLower=false) |
| Replace non-alphanumeric characters (other than _ - .) with underscores. | |
| wxString | RemoteLibraryPrefix () |
| Return the configured (or default) library prefix for remote downloads, sanitized for use as a filename component. | |
| bool | WriteRemoteBinaryFile (const wxFileName &aOutput, const std::vector< uint8_t > &aPayload, wxString &aError) |
| Write binary data to a file, creating parent directories as needed. | |
| bool | EnsureRemoteDestinationRoot (wxFileName &aOutDir, wxString &aError) |
| Resolve and create the configured destination root directory for remote symbol downloads. | |
| bool | EnsureRemoteLibraryEntry (LIBRARY_TABLE_TYPE aTableType, const wxFileName &aLibraryPath, const wxString &aNickname, bool aGlobalTable, bool aStrict, wxString &aError) |
| Add or update a library table entry for a remote download library. | |
| bool | SaveRemoteSymbolToLibrary (SYMBOL_LIBRARY_ADAPTER &aAdapter, const wxFileName &aLibraryFile, const wxString &aNickname, bool aGlobalTable, std::unique_ptr< LIB_SYMBOL > aSymbol, wxString &aError) |
| Save a downloaded symbol into the remote symbol library aNickname backed by aLibraryFile. | |
| bool | PlaceRemoteDownloadedSymbol (SCH_EDIT_FRAME *aFrame, const wxString &aNickname, const wxString &aLibItemName, wxString &aError) |
| Place a symbol from a remote download into the schematic editor. | |
| std::unique_ptr< LIB_SYMBOL > | LoadRemoteSymbolFromPayload (const std::vector< uint8_t > &aPayload, const wxString &aLibItemName, wxString &aError) |
| Deserialize a remote-downloaded symbol payload into a LIB_SYMBOL. | |
| LIB_ID | BuildRemoteLibId (const wxString &aResolvedLibrary, const wxString &aResolvedItemName) |
| Build the local LIB_ID for a remote-downloaded library item. | |
| void | ApplyFootprintLinks (LIB_SYMBOL &aSymbol, const std::vector< LIB_ID > &aLinks) |
| Apply a list of footprint LIB_IDs to a symbol about to be saved. | |
| void ApplyFootprintLinks | ( | LIB_SYMBOL & | aSymbol, |
| const std::vector< LIB_ID > & | aLinks ) |
Apply a list of footprint LIB_IDs to a symbol about to be saved.
The first LIB_ID is written to the symbol's Footprint field as a fully-qualified <nickname>:<itemName> string (overwriting any previous value). Remaining LIB_IDs are appended to the symbol's footprint filter list as bare item names (filters are globs over footprint name only and would not match colon-qualified strings).
If aLinks is empty, the symbol is left untouched.
Definition at line 368 of file remote_symbol_import_utils.cpp.
References LIB_SYMBOL::GetFPFilters(), LIB_SYMBOL::SetFootprintProp(), and LIB_SYMBOL::SetFPFilters().
Referenced by REMOTE_SYMBOL_IMPORT_JOB::Import(), and PANEL_REMOTE_SYMBOL::receiveSymbol().
| LIB_ID BuildRemoteLibId | ( | const wxString & | aResolvedLibrary, |
| const wxString & | aResolvedItemName ) |
Build the local LIB_ID for a remote-downloaded library item.
The caller is responsible for resolving any fallbacks before calling. The library nickname is constructed as <RemoteLibraryPrefix()>_<sanitized aResolvedLibrary>; the item name is the sanitized aResolvedItemName.
Definition at line 353 of file remote_symbol_import_utils.cpp.
References RemoteLibraryPrefix(), SanitizeRemoteFileComponent(), and LIB_ID::SetLibNickname().
Referenced by REMOTE_SYMBOL_IMPORT_JOB::Import(), and PANEL_REMOTE_SYMBOL::receiveFootprint().
| bool EnsureRemoteDestinationRoot | ( | wxFileName & | aOutDir, |
| wxString & | aError ) |
Resolve and create the configured destination root directory for remote symbol downloads.
Definition at line 112 of file remote_symbol_import_utils.cpp.
References _, REMOTE_PROVIDER_SETTINGS::DefaultDestinationDir(), REMOTE_PROVIDER_SETTINGS::destination_dir, ExpandEnvVarSubstitutions(), FN_NORMALIZE_FLAGS, GetAppSettings(), EESCHEMA_SETTINGS::m_RemoteSymbol, Pgm(), and Prj().
Referenced by REMOTE_SYMBOL_IMPORT_JOB::Import(), PANEL_REMOTE_SYMBOL::receive3DModel(), PANEL_REMOTE_SYMBOL::receiveFootprint(), PANEL_REMOTE_SYMBOL::receiveSPICEModel(), and PANEL_REMOTE_SYMBOL::receiveSymbol().
| bool EnsureRemoteLibraryEntry | ( | LIBRARY_TABLE_TYPE | aTableType, |
| const wxFileName & | aLibraryPath, | ||
| const wxString & | aNickname, | ||
| bool | aGlobalTable, | ||
| bool | aStrict, | ||
| wxString & | aError ) |
Add or update a library table entry for a remote download library.
When aStrict is false, a missing library table is not treated as an error.
Definition at line 150 of file remote_symbol_import_utils.cpp.
References _, PGM_BASE::GetLibraryManager(), GLOBAL, Pgm(), PROJECT, LIBRARY_TABLE_ROW::SetDescription(), LIBRARY_TABLE_ROW::SetNickname(), LIBRARY_TABLE_ROW::SetOk(), LIBRARY_TABLE_ROW::SetOptions(), LIBRARY_TABLE_ROW::SetType(), LIBRARY_TABLE_ROW::SetURI(), LIBRARY_MANAGER::Table(), table, and LIBRARY_TABLE_ROW::URI().
Referenced by REMOTE_SYMBOL_IMPORT_JOB::Import(), PANEL_REMOTE_SYMBOL::receiveFootprint(), and SaveRemoteSymbolToLibrary().
| std::unique_ptr< LIB_SYMBOL > LoadRemoteSymbolFromPayload | ( | const std::vector< uint8_t > & | aPayload, |
| const wxString & | aLibItemName, | ||
| wxString & | aError ) |
Deserialize a remote-downloaded symbol payload into a LIB_SYMBOL.
The payload is expected to be a complete kicad_symbol_lib s-expression. The named symbol is extracted via the SCH_KICAD plugin and returned as an owned copy.
Definition at line 285 of file remote_symbol_import_utils.cpp.
References _, and IO_ERROR::What().
Referenced by BOOST_AUTO_TEST_CASE(), REMOTE_SYMBOL_IMPORT_JOB::Import(), and PANEL_REMOTE_SYMBOL::receiveSymbol().
| bool PlaceRemoteDownloadedSymbol | ( | SCH_EDIT_FRAME * | aFrame, |
| const wxString & | aNickname, | ||
| const wxString & | aLibItemName, | ||
| wxString & | aError ) |
Place a symbol from a remote download into the schematic editor.
Definition at line 242 of file remote_symbol_import_utils.cpp.
References _, AUTOPLACE_AUTO, SCH_SYMBOL::AutoplaceFields(), SCH_BASE_FRAME::eeconfig(), EESCHEMA_SETTINGS::AUTOPLACE_FIELDS::enable, SCH_EDIT_FRAME::GetCurrentSheet(), SCH_BASE_FRAME::GetLibSymbol(), SCH_EDIT_FRAME::GetScreen(), TOOLS_HOLDER::GetToolManager(), SCH_SYMBOL::IsMultiUnit(), EESCHEMA_SETTINGS::m_AutoplaceFields, SCH_ACTIONS::placeSymbol, TOOL_MANAGER::PostAction(), LIB_ID::SetLibItemName(), LIB_ID::SetLibNickname(), and EDA_ITEM::SetParent().
Referenced by REMOTE_SYMBOL_IMPORT_JOB::Import(), and PANEL_REMOTE_SYMBOL::receiveSymbol().
| wxString RemoteLibraryPrefix | ( | ) |
Return the configured (or default) library prefix for remote downloads, sanitized for use as a filename component.
Definition at line 63 of file remote_symbol_import_utils.cpp.
References REMOTE_PROVIDER_SETTINGS::DefaultLibraryPrefix(), GetAppSettings(), REMOTE_PROVIDER_SETTINGS::library_prefix, EESCHEMA_SETTINGS::m_RemoteSymbol, and SanitizeRemoteFileComponent().
Referenced by BuildRemoteLibId(), REMOTE_SYMBOL_IMPORT_JOB::Import(), PANEL_REMOTE_SYMBOL::receive3DModel(), PANEL_REMOTE_SYMBOL::receiveSPICEModel(), and PANEL_REMOTE_SYMBOL::receiveSymbol().
| wxString SanitizeRemoteFileComponent | ( | const wxString & | aValue, |
| const wxString & | aDefault, | ||
| bool | aLower = false ) |
Replace non-alphanumeric characters (other than _ - .) with underscores.
Returns aDefault when aValue is empty after trimming.
Definition at line 43 of file remote_symbol_import_utils.cpp.
References result.
Referenced by BuildRemoteLibId(), PANEL_REMOTE_SYMBOL::cookieFilePath(), REMOTE_SYMBOL_IMPORT_JOB::Import(), PANEL_REMOTE_SYMBOL::receive3DModel(), PANEL_REMOTE_SYMBOL::receiveSPICEModel(), PANEL_REMOTE_SYMBOL::receiveSymbol(), and RemoteLibraryPrefix().
| bool SaveRemoteSymbolToLibrary | ( | SYMBOL_LIBRARY_ADAPTER & | aAdapter, |
| const wxFileName & | aLibraryFile, | ||
| const wxString & | aNickname, | ||
| bool | aGlobalTable, | ||
| std::unique_ptr< LIB_SYMBOL > | aSymbol, | ||
| wxString & | aError ) |
Save a downloaded symbol into the remote symbol library aNickname backed by aLibraryFile.
Registers the library table row and creates the library file when it does not exist yet, then reloads the library so the symbol can be placed. On success the library cache owns aSymbol.
Definition at line 209 of file remote_symbol_import_utils.cpp.
References _, LIBRARY_MANAGER_ADAPTER::CreateLibrary(), EnsureRemoteLibraryEntry(), PGM_BASE::GetLibraryManager(), GLOBAL, SYMBOL_LIBRARY_ADAPTER::LoadOne(), Pgm(), PROJECT, LIBRARY_MANAGER::ReloadLibraryEntry(), SYMBOL_LIBRARY_ADAPTER::SAVE_OK, SYMBOL_LIBRARY_ADAPTER::SaveSymbol(), and SYMBOL.
Referenced by BOOST_AUTO_TEST_CASE(), REMOTE_SYMBOL_IMPORT_JOB::Import(), and PANEL_REMOTE_SYMBOL::receiveSymbol().
| bool WriteRemoteBinaryFile | ( | const wxFileName & | aOutput, |
| const std::vector< uint8_t > & | aPayload, | ||
| wxString & | aError ) |
Write binary data to a file, creating parent directories as needed.
Definition at line 75 of file remote_symbol_import_utils.cpp.
References _.
Referenced by REMOTE_SYMBOL_IMPORT_JOB::Import(), PANEL_REMOTE_SYMBOL::receive3DModel(), PANEL_REMOTE_SYMBOL::receiveFootprint(), and PANEL_REMOTE_SYMBOL::receiveSPICEModel().