KiCad PCB EDA Suite
FOOTPRINT_LIST Class Referenceabstract

Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thrown acquiring the FOOTPRINT_INFOs. More...

#include <footprint_info.h>

Inheritance diagram for FOOTPRINT_LIST:
FOOTPRINT_LIST_IMPL

Public Types

typedef std::vector< std::unique_ptr< FOOTPRINT_INFO > > FPILIST
 
typedef SYNC_QUEUE< std::unique_ptr< IO_ERROR > > ERRLIST
 

Public Member Functions

 FOOTPRINT_LIST ()
 
virtual ~FOOTPRINT_LIST ()
 
virtual void WriteCacheToFile (const wxString &aFilePath)
 
virtual void ReadCacheFromFile (const wxString &aFilePath)
 
unsigned GetCount () const
 
const FPILISTGetList () const
 Was forced to add this by modview_frame.cpp. More...
 
void Clear ()
 
FOOTPRINT_INFOGetFootprintInfo (const wxString &aFootprintName)
 Get info for a footprint by id. More...
 
FOOTPRINT_INFOGetFootprintInfo (const wxString &aLibNickname, const wxString &aFootprintName)
 Get info for a footprint by libNickname/footprintName. More...
 
FOOTPRINT_INFOGetItem (unsigned aIdx) const
 Get info for a footprint by index. More...
 
unsigned GetErrorCount () const
 
std::unique_ptr< IO_ERRORPopError ()
 
virtual bool ReadFootprintFiles (FP_LIB_TABLE *aTable, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)=0
 Read all the footprints provided by the combination of aTable and aNickname. More...
 
void DisplayErrors (wxTopLevelWindow *aCaller=nullptr)
 
FP_LIB_TABLEGetTable () const
 

Static Public Member Functions

static FOOTPRINT_LISTGetInstance (KIWAY &aKiway)
 Factory function to return a FOOTPRINT_LIST via Kiway. More...
 

Protected Attributes

FP_LIB_TABLEm_lib_table
 no ownership More...
 
FPILIST m_list
 
ERRLIST m_errors
 some can be PARSE_ERRORs also More...
 

Detailed Description

Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thrown acquiring the FOOTPRINT_INFOs.

This is a virtual class; its implementation lives in pcbnew/footprint_info_impl.cpp. To get instances of these classes, see FOOTPRINT_LIST::GetInstance().

Definition at line 165 of file footprint_info.h.

Member Typedef Documentation

◆ ERRLIST

typedef SYNC_QUEUE<std::unique_ptr<IO_ERROR> > FOOTPRINT_LIST::ERRLIST

Definition at line 169 of file footprint_info.h.

◆ FPILIST

typedef std::vector<std::unique_ptr<FOOTPRINT_INFO> > FOOTPRINT_LIST::FPILIST

Definition at line 168 of file footprint_info.h.

Constructor & Destructor Documentation

◆ FOOTPRINT_LIST()

FOOTPRINT_LIST::FOOTPRINT_LIST ( )
inline

Definition at line 171 of file footprint_info.h.

171 : m_lib_table( nullptr )
172 {
173 }
FP_LIB_TABLE * m_lib_table
no ownership

◆ ~FOOTPRINT_LIST()

virtual FOOTPRINT_LIST::~FOOTPRINT_LIST ( )
inlinevirtual

Definition at line 175 of file footprint_info.h.

176 {
177 }

Member Function Documentation

◆ Clear()

void FOOTPRINT_LIST::Clear ( )
inline
Returns
Clears the footprint info cache

Definition at line 199 of file footprint_info.h.

200 {
201 m_list.clear();
202 }

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ DisplayErrors()

void FOOTPRINT_LIST::DisplayErrors ( wxTopLevelWindow *  aCaller = nullptr)

Definition at line 93 of file footprint_info.cpp.

94{
95 // @todo: go to a more HTML !<table>! ? centric output, possibly with recommendations
96 // for remedy of errors. Add numeric error codes to PARSE_ERROR, and switch on them for
97 // remedies, etc. Full access is provided to everything in every exception!
98
99 HTML_MESSAGE_BOX dlg( aWindow, _( "Load Error" ) );
100
101 dlg.MessageSet( _( "Errors were encountered loading footprints:" ) );
102
103 wxString msg;
104
105 while( std::unique_ptr<IO_ERROR> error = PopError() )
106 {
107 wxString tmp = error->Problem();
108
109 // Preserve new lines in error messages so queued errors don't run together.
110 tmp.Replace( "\n", "<BR>" );
111 msg += wxT( "<p>" ) + tmp + wxT( "</p>" );
112 }
113
114 dlg.AddHTML_Text( msg );
115
116 dlg.ShowModal();
117}
std::unique_ptr< IO_ERROR > PopError()
#define _(s)

References _, HTML_MESSAGE_BOX::AddHTML_Text(), HTML_MESSAGE_BOX::MessageSet(), and PopError().

Referenced by FOOTPRINT_EDIT_FRAME::initLibraryTree(), CVPCB_MAINFRAME::LoadFootprintFiles(), and PCB_BASE_FRAME::SelectFootprintFromLibTree().

◆ GetCount()

unsigned FOOTPRINT_LIST::GetCount ( ) const
inline

◆ GetErrorCount()

unsigned FOOTPRINT_LIST::GetErrorCount ( ) const
inline

Definition at line 226 of file footprint_info.h.

227 {
228 return m_errors.size();
229 }
ERRLIST m_errors
some can be PARSE_ERRORs also
size_t size() const
Return the size of the queue.
Definition: sync_queue.h:91

Referenced by FOOTPRINT_EDIT_FRAME::initLibraryTree(), CVPCB_MAINFRAME::LoadFootprintFiles(), and PCB_BASE_FRAME::SelectFootprintFromLibTree().

◆ GetFootprintInfo() [1/2]

FOOTPRINT_INFO * FOOTPRINT_LIST::GetFootprintInfo ( const wxString &  aFootprintName)

Get info for a footprint by id.

Definition at line 58 of file footprint_info.cpp.

59{
60 if( aFootprintName.IsEmpty() )
61 return nullptr;
62
63 LIB_ID fpid;
64
65 wxCHECK_MSG( fpid.Parse( aFootprintName ) < 0, nullptr,
66 wxString::Format( wxT( "'%s' is not a valid LIB_ID." ), aFootprintName ) );
67
68 return GetFootprintInfo( fpid.GetLibNickname(), fpid.GetLibItemName() );
69}
FOOTPRINT_INFO * GetFootprintInfo(const wxString &aFootprintName)
Get info for a footprint by id.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:50
const UTF8 & GetLibItemName() const
Definition: lib_id.h:101
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
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 Format(), GetFootprintInfo(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), and LIB_ID::Parse().

Referenced by CVPCB_MAINFRAME::AssociateFootprint(), CVPCB_MAINFRAME::AutomaticFootprintMatching(), CVPCB_MAINFRAME::BuildSymbolsListBox(), CVPCB_MAINFRAME::DisplayStatus(), GetFootprintInfo(), DISPLAY_FOOTPRINTS_FRAME::InitDisplay(), CVPCB_MAINFRAME::readNetListAndFpFiles(), and PCB_BASE_FRAME::SelectFootprintFromLibTree().

◆ GetFootprintInfo() [2/2]

FOOTPRINT_INFO * FOOTPRINT_LIST::GetFootprintInfo ( const wxString &  aLibNickname,
const wxString &  aFootprintName 
)

Get info for a footprint by libNickname/footprintName.

Definition at line 42 of file footprint_info.cpp.

44{
45 if( aFootprintName.IsEmpty() )
46 return nullptr;
47
48 for( std::unique_ptr<FOOTPRINT_INFO>& fp : m_list )
49 {
50 if( aLibNickname == fp->GetLibNickname() && aFootprintName == fp->GetFootprintName() )
51 return fp.get();
52 }
53
54 return nullptr;
55}

References m_list.

◆ GetInstance()

FOOTPRINT_LIST * FOOTPRINT_LIST::GetInstance ( KIWAY aKiway)
static

Factory function to return a FOOTPRINT_LIST via Kiway.

This is not guaranteed to succeed and will return null if the kiface is not available.

Parameters
aKiwayactive kiway instance.

Definition at line 143 of file footprint_info.cpp.

144{
146
147 if( !footprintInfo )
148 return nullptr;
149
150 if( !footprintInfo->GetCount() )
151 footprintInfo->ReadCacheFromFile( aKiway.Prj().GetProjectPath() + "fp-info-cache" );
152
153 return footprintInfo;
154}
Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thro...
virtual void ReadCacheFromFile(const wxString &aFilePath)
unsigned GetCount() const
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:192
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:126
static FOOTPRINT_LIST * get_instance_from_id(KIWAY &aKiway, int aId)
@ KIFACE_FOOTPRINT_LIST
Return a pointer to the global instance of FOOTPRINT_LIST from pcbnew.
Definition: kiface_ids.h:39

References get_instance_from_id(), GetCount(), PROJECT::GetProjectPath(), KIFACE_FOOTPRINT_LIST, KIWAY::Prj(), and ReadCacheFromFile().

Referenced by DIALOG_CHOOSE_SYMBOL::ConstructRightPanel(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), FOOTPRINT_SELECT_WIDGET::Load(), and FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList().

◆ GetItem()

FOOTPRINT_INFO & FOOTPRINT_LIST::GetItem ( unsigned  aIdx) const
inline

Get info for a footprint by index.

Parameters
aIdxindex of the given item.
Returns
the aIdx item in list.

Definition at line 221 of file footprint_info.h.

222 {
223 return *m_list[aIdx];
224 }

Referenced by FOOTPRINT_FILTER::ITERATOR::increment().

◆ GetList()

const FPILIST & FOOTPRINT_LIST::GetList ( ) const
inline

Was forced to add this by modview_frame.cpp.

Definition at line 191 of file footprint_info.h.

192 {
193 return m_list;
194 }

Referenced by FP_TREE_MODEL_ADAPTER::getFootprints().

◆ GetTable()

FP_LIB_TABLE * FOOTPRINT_LIST::GetTable ( ) const
inline

Definition at line 256 of file footprint_info.h.

257 {
258 return m_lib_table;
259 }

Referenced by FOOTPRINT_INFO_IMPL::load().

◆ PopError()

std::unique_ptr< IO_ERROR > FOOTPRINT_LIST::PopError ( )
inline

Definition at line 231 of file footprint_info.h.

232 {
233 std::unique_ptr<IO_ERROR> error;
234
235 m_errors.pop( error );
236 return error;
237 }
bool pop(T &aReceiver)
Pop a value if the queue into the provided variable.
Definition: sync_queue.h:63

Referenced by DisplayErrors().

◆ ReadCacheFromFile()

virtual void FOOTPRINT_LIST::ReadCacheFromFile ( const wxString &  aFilePath)
inlinevirtual

Reimplemented in FOOTPRINT_LIST_IMPL.

Definition at line 180 of file footprint_info.h.

180{};

Referenced by GetInstance().

◆ ReadFootprintFiles()

virtual bool FOOTPRINT_LIST::ReadFootprintFiles ( FP_LIB_TABLE aTable,
const wxString *  aNickname = nullptr,
PROGRESS_REPORTER aProgressReporter = nullptr 
)
pure virtual

Read all the footprints provided by the combination of aTable and aNickname.

Parameters
aTabledefines all the libraries.
aNicknameis the library to read from, or if NULL means read all footprints from all known libraries in aTable.
aProgressReporteris an optional progress reporter. ReadFootprintFiles() will use 2 phases within the reporter.
Returns
true if it ran to completion, else false if it aborted after some number of errors. If true, it does not mean there were no errors, check GetErrorCount() for that, should be zero to indicate success.

Implemented in FOOTPRINT_LIST_IMPL.

Referenced by CVPCB_MAINFRAME::LoadFootprintFiles().

◆ WriteCacheToFile()

virtual void FOOTPRINT_LIST::WriteCacheToFile ( const wxString &  aFilePath)
inlinevirtual

Reimplemented in FOOTPRINT_LIST_IMPL.

Definition at line 179 of file footprint_info.h.

179{};

Member Data Documentation

◆ m_errors

ERRLIST FOOTPRINT_LIST::m_errors
protected

some can be PARSE_ERRORs also

Definition at line 274 of file footprint_info.h.

Referenced by FOOTPRINT_LIST_IMPL::CatchErrors(), and FOOTPRINT_LIST_IMPL::ReadFootprintFiles().

◆ m_lib_table

FP_LIB_TABLE* FOOTPRINT_LIST::m_lib_table
protected

◆ m_list


The documentation for this class was generated from the following files: