KiCad PCB EDA Suite
sch_base_frame.cpp File Reference
#include <base_units.h>
#include <kiway.h>
#include <class_drawpanel.h>
#include <confirm.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 "dialogs/dialog_sym_lib_table.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

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 40 of file sch_base_frame.cpp.

References DisplayErrorMessage(), PART_LIB::FindAlias(), 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().

42 {
43  // wxCHECK_MSG( aLibId.IsValid(), NULL, "LIB_ID is not valid." );
44  wxCHECK_MSG( aLibTable, NULL, "Invalid symbol library table." );
46  LIB_ALIAS* alias = NULL;
48  try
49  {
50  alias = aLibTable->LoadSymbol( aLibId );
52  if( !alias && aCacheLib )
53  alias = aCacheLib->FindAlias( aLibId );
54  }
55  catch( const IO_ERROR& ioe )
56  {
57  if( aShowErrorMsg )
58  {
59  wxString msg;
61  msg.Printf( _( "Could not load symbol \"%s\" from library \"%s\"." ),
62  aLibId.GetLibItemName().wx_str(), aLibId.GetLibNickname().wx_str() );
63  DisplayErrorMessage( aParent, msg, ioe.What() );
64  }
65  }
67  return alias;
68 }
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.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:199
wxString wx_str() const
Definition: utf8.cpp:48
const UTF8 & GetLibItemName() const
Definition: lib_id.h:118
LIB_ALIAS * FindAlias(const wxString &aName) const
Find LIB_ALIAS by aName.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:101
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
LIB_PART* SchGetLibPart ( const LIB_ID aLibId,
PART_LIB aCacheLib,
wxWindow *  aParent,
bool  aShowErrorMsg 

Definition at line 71 of file sch_base_frame.cpp.

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

Referenced by SCH_BASE_FRAME::GetLibPart().

73 {
74  LIB_ALIAS* alias = SchGetLibAlias( aLibId, aLibTable, aCacheLib, aParent, aShowErrorMsg );
76  return ( alias ) ? alias->GetPart() : NULL;
77 }
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.