KiCad PCB EDA Suite
sch_base_frame.h File Reference
#include <lib_id.h>
#include <draw_frame.h>
#include <class_sch_screen.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...
 
struct  SCH_BASE_FRAME::COMPONENT_SELECTION
 

Functions

LIB_ALIASSchGetLibAlias (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...
 
LIB_PARTSchGetLibPart (const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, PART_LIB *aCacheLib=NULL, wxWindow *aParent=NULL, bool aShowErrorMsg=false)
 

Function Documentation

LIB_ALIAS* SchGetLibAlias ( 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 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." );
45 
46  LIB_ALIAS* alias = NULL;
47 
48  try
49  {
50  alias = aLibTable->LoadSymbol( aLibId );
51 
52  if( !alias && aCacheLib )
53  alias = aCacheLib->FindAlias( aLibId.GetLibItemName() );
54  }
55  catch( const IO_ERROR& ioe )
56  {
57  if( aShowErrorMsg )
58  {
59  wxString msg;
60 
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  }
66 
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.
wxString wx_str() const
Definition: utf8.cpp:48
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:87
const UTF8 & GetLibItemName() const
Definition: lib_id.h:115
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:98
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,
SYMBOL_LIB_TABLE aLibTable,
PART_LIB aCacheLib = NULL,
wxWindow *  aParent = NULL,
bool  aShowErrorMsg = false 
)

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 );
75 
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
Function GetPart gets the shared LIB_PART.