KiCad PCB EDA Suite
sch_base_frame.cpp File Reference
#include <base_units.h>
#include <kiway.h>
#include <sch_draw_panel.h>
#include <sch_view.h>
#include <sch_painter.h>
#include <gal/graphics_abstraction_layer.h>
#include <confirm.h>
#include <preview_items/selection_area.h>
#include <class_library.h>
#include <eeschema_id.h>
#include <lib_edit_frame.h>
#include <viewlib_frame.h>
#include <sch_base_frame.h>
#include <symbol_lib_table.h>
#include <tool/action_toolbar.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tools/ee_actions.h>
#include <tools/ee_selection_tool.h>

Go to the source code of this file.


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

Function Documentation

◆ SchGetLibAlias()

LIB_ALIAS* SchGetLibAlias ( const LIB_ID aLibId,
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.

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.
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." );
51  LIB_ALIAS* alias = NULL;
53  try
54  {
55  alias = aLibTable->LoadSymbol( aLibId );
57  if( !alias && aCacheLib )
58  alias = aCacheLib->FindAlias( 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  }
71  return alias;
72 }
LIB_ALIAS * LoadSymbol(const wxString &aNickname, const wxString &aAliasName)
Load a LIB_ALIAS having aAliasName from the library given by aNickname.
Part library alias object definition.
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
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
LIB_ALIAS * FindAlias(const wxString &aName) const
Find LIB_ALIAS by aName.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
#define _(s)
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
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::FindAlias(), Format(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), SYMBOL_LIB_TABLE::LoadSymbol(), IO_ERROR::What(), and UTF8::wx_str().

Referenced by SCH_BASE_FRAME::GetLibAlias(), and SchGetLibPart().

◆ SchGetLibPart()

LIB_PART* SchGetLibPart ( const LIB_ID aLibId,
PART_LIB aCacheLib,
wxWindow *  aParent,
bool  aShowErrorMsg 

Definition at line 75 of file sch_base_frame.cpp.

77 {
78  LIB_ALIAS* alias = SchGetLibAlias( aLibId, aLibTable, aCacheLib, aParent, aShowErrorMsg );
80  return ( alias ) ? alias->GetPart() : NULL;
81 }
Part library alias object definition.
LIB_ALIAS * SchGetLibAlias(const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, PART_LIB *aCacheLib, wxWindow *aParent, bool aShowErrorMsg)
Load symbol from symbol library table.
LIB_PART * GetPart() const
Get the shared LIB_PART.

References LIB_ALIAS::GetPart(), and SchGetLibAlias().

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