KiCad PCB EDA Suite
readwrite_dlgs.cpp File Reference
#include <confirm.h>
#include <fp_lib_table.h>
#include <dialogs/html_messagebox.h>
#include <kiway.h>
#include <lib_id.h>
#include <macros.h>
#include <cvpcb_mainframe.h>
#include <fp_conflict_assignment_selector.h>

Go to the source code of this file.

Functions

static int guessNickname (FP_LIB_TABLE *aTbl, LIB_ID *aFootprintId)
 Return true if the resultant LIB_ID has a certain nickname. More...
 

Function Documentation

◆ guessNickname()

static int guessNickname ( FP_LIB_TABLE aTbl,
LIB_ID aFootprintId 
)
static

Return true if the resultant LIB_ID has a certain nickname.

The guess is only made if this footprint resides in only one library.

Returns
int - 0 on success, 1 on not found, 2 on ambiguous i.e. multiple matches

Definition at line 40 of file readwrite_dlgs.cpp.

41 {
42  if( aFootprintId->GetLibNickname().size() )
43  return 0;
44 
45  wxString nick;
46  wxString fpname = aFootprintId->GetLibItemName();
47 
48  std::vector<wxString> nicks = aTbl->GetLogicalLibs();
49 
50  // Search each library going through libraries alphabetically.
51  for( unsigned libNdx = 0; libNdx<nicks.size(); ++libNdx )
52  {
53  wxArrayString fpnames;
54 
55  aTbl->FootprintEnumerate( fpnames, nicks[libNdx], true );
56 
57  for( unsigned nameNdx = 0; nameNdx<fpnames.size(); ++nameNdx )
58  {
59  if( fpname == fpnames[nameNdx] )
60  {
61  if( !nick )
62  nick = nicks[libNdx];
63  else
64  return 2; // duplicate, the guess would not be certain
65  }
66  }
67  }
68 
69  if( nick.size() )
70  {
71  aFootprintId->SetLibNickname( nick );
72  return 0;
73  }
74 
75  return 1;
76 }
const UTF8 & GetLibItemName() const
Definition: lib_id.h:106
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aNickname, bool aBestEfforts)
Return a list of footprint names contained within the library given by aNickname.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:92
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:193
std::string::size_type size() const
Definition: utf8.h:110
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.

References FP_LIB_TABLE::FootprintEnumerate(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), LIB_TABLE::GetLogicalLibs(), LIB_ID::SetLibNickname(), and UTF8::size().

Referenced by CVPCB_MAINFRAME::ReadNetListAndFpFiles().