KiCad PCB EDA Suite
sch_base_frame.h File Reference
#include <eda_draw_frame.h>
#include <frame_type.h>
#include <lib_id.h>
#include <page_info.h>
#include <sch_draw_panel.h>
#include <sch_screen.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: LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME, and it brings in a common way of handling the provided virtual functions for the derived classes. More...
 

Namespaces

 KIGFX
 Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
 

Functions

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

Function Documentation

◆ SchGetLibPart()

LIB_PART* SchGetLibPart ( const LIB_ID aLibId,
SYMBOL_LIB_TABLE aLibTable,
PART_LIB aCacheLib = NULL,
wxWindow *  aParent = NULL,
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 optiona 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 45 of file sch_base_frame.cpp.

47 {
48  // wxCHECK_MSG( aLibId.IsValid(), NULL, "LIB_ID is not valid." );
49  wxCHECK_MSG( aLibTable, NULL, "Invalid symbol library table." );
50 
51  LIB_PART* symbol = NULL;
52 
53  try
54  {
55  symbol = aLibTable->LoadSymbol( aLibId );
56 
57  if( !symbol && aCacheLib )
58  symbol = aCacheLib->FindPart( aLibId );
59  }
60  catch( const IO_ERROR& ioe )
61  {
62  if( aShowErrorMsg )
63  {
64  wxString msg = wxString::Format( _( "Error loading symbol '%s' from library '%s'." ),
65  aLibId.GetLibItemName().wx_str(),
66  aLibId.GetLibNickname().wx_str() );
67  DisplayErrorMessage( aParent, msg, ioe.What() );
68  }
69  }
70 
71  return symbol;
72 }
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:249
LIB_PART * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_PART having aName from the library given by aNickname.
#define NULL
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Define a library symbol object.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
LIB_PART * FindPart(const wxString &aName) const
Find LIB_PART by aName.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:31
wxString wx_str() const
Definition: utf8.cpp:51
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76

References _, DisplayErrorMessage(), PART_LIB::FindPart(), Format(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), SYMBOL_LIB_TABLE::LoadSymbol(), NULL, IO_ERROR::What(), and UTF8::wx_str().

Referenced by RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(), and SCH_BASE_FRAME::GetLibPart().