KiCad PCB EDA Suite
sch_base_frame.h File Reference
#include <eda_draw_frame.h>
#include <frame_type.h>
#include <sch_draw_panel.h>
#include <sch_screen.h>
#include <schematic_settings.h>
#include <stddef.h>
#include <utility>
#include <vector>
#include <wx/event.h>
#include <wx/gdicmn.h>
#include <wx/string.h>
#include <template_fieldnames.h>

Go to the source code of this file.

Classes

class  SCH_BASE_FRAME
 A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME, SYMBOL_VIEWER_FRAME, and SCH_EDIT_FRAME, and it brings in a common way of handling the provided virtual functions for the derived classes. More...
 

Namespaces

namespace  KIGFX
 The Cairo implementation of the graphics abstraction layer.
 

Functions

LIB_SYMBOLSchGetLibSymbol (const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, SYMBOL_LIB *aCacheLib=nullptr, wxWindow *aParent=nullptr, bool aShowErrorMsg=false)
 Load symbol from symbol library table. More...
 

Function Documentation

◆ SchGetLibSymbol()

LIB_SYMBOL * SchGetLibSymbol ( const LIB_ID aLibId,
SYMBOL_LIB_TABLE aLibTable,
SYMBOL_LIB aCacheLib = nullptr,
wxWindow *  aParent = nullptr,
bool  aShowErrorMsg = false 
)

Load symbol from symbol library table.

Check the symbol library table for the part defined by aLibId and optionally check the optional cache library.

Parameters
aLibIdis the symbol library identifier to load.
aLibTableis the #SYMBOL_LIBRARY_TABLE to load the alias from.
aCacheLibis an optional cache library.
aParentis an optional parent window when displaying an error message.
aShowErrorMessageset to true to show any error messages.
Returns
The symbol found in the library or NULL if the symbol was not found.

Definition at line 53 of file sch_base_frame.cpp.

55{
56 wxCHECK_MSG( aLibTable, nullptr, wxS( "Invalid symbol library table." ) );
57
58 LIB_SYMBOL* symbol = nullptr;
59
60 try
61 {
62 symbol = aLibTable->LoadSymbol( aLibId );
63
64 if( !symbol && aCacheLib )
65 {
66 wxCHECK_MSG( aCacheLib->IsCache(), nullptr, wxS( "Invalid cache library." ) );
67
68 wxString cacheName = aLibId.GetLibNickname().wx_str();
69 cacheName += "_" + aLibId.GetLibItemName();
70 symbol = aCacheLib->FindSymbol( cacheName );
71 }
72 }
73 catch( const IO_ERROR& ioe )
74 {
75 if( aShowErrorMsg )
76 {
77 wxString msg = wxString::Format( _( "Error loading symbol %s from library '%s'." ),
78 aLibId.GetLibItemName().wx_str(),
79 aLibId.GetLibNickname().wx_str() );
80 DisplayErrorMessage( aParent, msg, ioe.What() );
81 }
82 }
83
84 return symbol;
85}
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
Define a library symbol object.
Definition: lib_symbol.h:99
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
bool IsCache() const
LIB_SYMBOL * FindSymbol(const wxString &aName) const
Find LIB_SYMBOL by aName.
wxString wx_str() const
Definition: utf8.cpp:46
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:325
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References _, DisplayErrorMessage(), SYMBOL_LIB::FindSymbol(), Format(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), SYMBOL_LIB::IsCache(), SYMBOL_LIB_TABLE::LoadSymbol(), IO_ERROR::What(), and UTF8::wx_str().

Referenced by RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(), SCH_BASE_FRAME::GetLibSymbol(), and ERC_TESTER::TestLibSymbolIssues().