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

A collection of SYMBOL_LIB objects. More...

#include <symbol_library.h>

Inheritance diagram for SYMBOL_LIBS:
PROJECT::_ELEM

Public Member Functions

PROJECT::ELEM ProjectElementType () override
 
 SYMBOL_LIBS ()
 
SYMBOL_LIBAddLibrary (const wxString &aFileName)
 Allocate and adds a symbol library to the library list.
 
SYMBOL_LIBAddLibrary (const wxString &aFileName, SYMBOL_LIBS::iterator &aIterator)
 Insert a symbol library into the library list.
 
bool ReloadLibrary (const wxString &aFileName)
 Refreshes the library from the (possibly updated) contents on disk.
 
void LoadAllLibraries (PROJECT *aProject, bool aShowProgress=true)
 Load all of the project's libraries into this container, which should be cleared before calling it.
 
SYMBOL_LIBFindLibrary (const wxString &aName)
 Find a symbol library by aName.
 
SYMBOL_LIBFindLibraryByFullFileName (const wxString &aFullFileName)
 
SYMBOL_LIBGetCacheLibrary ()
 
wxArrayString GetLibraryNames (bool aSorted=true)
 Return the list of symbol library file names without path and extension.
 
LIB_SYMBOLFindLibSymbol (const LIB_ID &aLibId, const wxString &aLibraryName=wxEmptyString)
 Search all libraries in the list for a symbol.
 
void FindLibraryNearEntries (std::vector< LIB_SYMBOL * > &aCandidates, const wxString &aEntryName, const wxString &aLibraryName=wxEmptyString)
 Search all libraries in the list for a LIB_SYMBOL using a case insensitive comparison.
 
int GetLibraryCount ()
 

Static Public Member Functions

static void GetLibNamesAndPaths (PROJECT *aProject, wxString *aPaths, wxArrayString *aNames=nullptr)
 
static void SetLibNamesAndPaths (PROJECT *aProject, const wxString &aPaths, const wxArrayString &aNames)
 
static const wxString CacheName (const wxString &aFullProjectFilename)
 Return the name of the cache library after potentially fixing it from an older naming scheme.
 

Detailed Description

A collection of SYMBOL_LIB objects.

It extends from PROJECT::_ELEM so it can be hung in the PROJECT. It does not use any UI calls, but rather simply throws an IO_ERROR when there is a problem.

Definition at line 61 of file symbol_library.h.

Constructor & Destructor Documentation

◆ SYMBOL_LIBS()

SYMBOL_LIBS::SYMBOL_LIBS ( )
inline

Definition at line 66 of file symbol_library.h.

Member Function Documentation

◆ AddLibrary() [1/2]

SYMBOL_LIB * SYMBOL_LIBS::AddLibrary ( const wxString &  aFileName)

Allocate and adds a symbol library to the library list.

Parameters
aFileNameis the file name object of symbol library.
Exceptions
IO_ERRORif there's any problem loading.

Definition at line 260 of file symbol_library.cpp.

References FindLibrary(), and SYMBOL_LIB::LoadSymbolLibrary().

Referenced by LoadAllLibraries().

◆ AddLibrary() [2/2]

SYMBOL_LIB * SYMBOL_LIBS::AddLibrary ( const wxString &  aFileName,
SYMBOL_LIBS::iterator &  aIterator 
)

Insert a symbol library into the library list.

Parameters
aFileNameis the file name object of symbol library.
aIteratoris an iterator to insert library in front of.
Returns
the new SYMBOL_LIB, which remains owned by this SYMBOL_LIBS container.
Exceptions
IO_ERRORif there's any problem loading.

Definition at line 285 of file symbol_library.cpp.

References FindLibrary(), and SYMBOL_LIB::LoadSymbolLibrary().

◆ CacheName()

const wxString SYMBOL_LIBS::CacheName ( const wxString &  aFullProjectFilename)
static

Return the name of the cache library after potentially fixing it from an older naming scheme.

That is, the old file is renamed if needed.

Parameters
aFullProjectFilenameis the *.pro filename with absolute path.

Definition at line 485 of file symbol_library.cpp.

References FILEEXT::LegacySymbolLibFileExtension, and name.

Referenced by LoadAllLibraries().

◆ FindLibrary()

SYMBOL_LIB * SYMBOL_LIBS::FindLibrary ( const wxString &  aName)

Find a symbol library by aName.

Parameters
aNameis the library file name without path or extension to find.
Returns
the symbol library if found, otherwise NULL.

Definition at line 355 of file symbol_library.cpp.

Referenced by AddLibrary(), LEGACY_RESCUER::OpenRescueLibrary(), and ReloadLibrary().

◆ FindLibraryByFullFileName()

SYMBOL_LIB * SYMBOL_LIBS::FindLibraryByFullFileName ( const wxString &  aFullFileName)

Definition at line 379 of file symbol_library.cpp.

◆ FindLibraryNearEntries()

void SYMBOL_LIBS::FindLibraryNearEntries ( std::vector< LIB_SYMBOL * > &  aCandidates,
const wxString &  aEntryName,
const wxString &  aLibraryName = wxEmptyString 
)

Search all libraries in the list for a LIB_SYMBOL using a case insensitive comparison.

Helper function used in dialog to find all candidates. During a long time, eeschema was using a case insensitive search. Therefore, for old schematics (<= 2013), or libs, for some symbols, the chip name (name of alias in lib) can be broken. This function can be used to display a list of candidates, in symbol properties dialog.

Parameters
aEntryNameis the name of entries to search for (case insensitive).
aLibraryNameis the name of the library to search.
aCandidatesis a std::vector to store candidates.

Definition at line 434 of file symbol_library.cpp.

References SYMBOL_LIB::FindSymbol(), SYMBOL_LIB::GetName(), and SYMBOL_LIB::GetSymbolNames().

Referenced by RESCUE_CASE_CANDIDATE::FindRescues().

◆ FindLibSymbol()

LIB_SYMBOL * SYMBOL_LIBS::FindLibSymbol ( const LIB_ID aLibId,
const wxString &  aLibraryName = wxEmptyString 
)

Search all libraries in the list for a symbol.

A symbol object will always be returned. If the entry found is an alias. The root symbol will be found and returned.

Parameters
aLibIdis the LIB_ID of the symbol to search for.
aLibraryNameis the name of the library to search for symbol.
Returns
the symbol object if found, otherwise NULL.

Definition at line 415 of file symbol_library.cpp.

References SYMBOL_LIB::FindSymbol(), LIB_ID::GetLibItemName(), SYMBOL_LIB::GetName(), and UTF8::wx_str().

Referenced by RESCUE_CASE_CANDIDATE::FindRescues().

◆ GetCacheLibrary()

SYMBOL_LIB * SYMBOL_LIBS::GetCacheLibrary ( )

Definition at line 367 of file symbol_library.cpp.

Referenced by SCH_DRAWING_TOOLS::PlaceSymbol().

◆ GetLibNamesAndPaths()

void SYMBOL_LIBS::GetLibNamesAndPaths ( PROJECT aProject,
wxString *  aPaths,
wxArrayString *  aNames = nullptr 
)
static

◆ GetLibraryCount()

int SYMBOL_LIBS::GetLibraryCount ( )
inline

◆ GetLibraryNames()

wxArrayString SYMBOL_LIBS::GetLibraryNames ( bool  aSorted = true)

Return the list of symbol library file names without path and extension.

Parameters
aSortedsort the list of name if true. Otherwise use the library load order.
Returns
the list of library names.

Definition at line 391 of file symbol_library.cpp.

References SYMBOL_LIB::GetName(), and SYMBOL_LIB::IsCache().

◆ LoadAllLibraries()

void SYMBOL_LIBS::LoadAllLibraries ( PROJECT aProject,
bool  aShowProgress = true 
)

Load all of the project's libraries into this container, which should be cleared before calling it.

Note
This method is only to be used when loading legacy projects. All further symbol library access should be done via the symbol library table.

Definition at line 499 of file symbol_library.cpp.

References _, AddLibrary(), CacheName(), GetLibNamesAndPaths(), PROJECT::GetProjectFullName(), PROJECT::IsNullProject(), FILEEXT::LegacySymbolLibFileExtension, PROJECT_SCH::SchSearchS(), SYMBOL_LIB::SetCache(), THROW_IO_ERROR, THROW_PARSE_ERROR, TO_UTF8, APP_PROGRESS_DIALOG::Update(), and IO_ERROR::What().

Referenced by PROJECT_SCH::SchLibs(), and LEGACY_RESCUER::WriteRescueLibrary().

◆ ProjectElementType()

PROJECT::ELEM SYMBOL_LIBS::ProjectElementType ( )
inlineoverridevirtual

Implements PROJECT::_ELEM.

Definition at line 64 of file symbol_library.h.

References PROJECT::SCH_SYMBOL_LIBS.

Referenced by PROJECT_SCH::SchLibs().

◆ ReloadLibrary()

bool SYMBOL_LIBS::ReloadLibrary ( const wxString &  aFileName)

Refreshes the library from the (possibly updated) contents on disk.

Parameters
aFileNameis the file name of the symbol library
Returns
true if successfully updated

Definition at line 312 of file symbol_library.cpp.

References FindLibrary(), and SYMBOL_LIB::LoadSymbolLibrary().

◆ SetLibNamesAndPaths()

void SYMBOL_LIBS::SetLibNamesAndPaths ( PROJECT aProject,
const wxString &  aPaths,
const wxArrayString &  aNames 
)
static

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