KiCad PCB EDA Suite
readwrite_dlgs.cpp File Reference
#include <confirm.h>
#include <fp_lib_table.h>
#include <dialogs/html_message_box.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 44 of file readwrite_dlgs.cpp.

45 {
46  if( aFootprintId->GetLibNickname().size() )
47  return 0;
48 
49  wxString nick;
50  wxString fpname = aFootprintId->GetLibItemName();
51 
52  std::vector<wxString> nicks = aTbl->GetLogicalLibs();
53 
54  // Search each library going through libraries alphabetically.
55  for( unsigned libNdx = 0; libNdx<nicks.size(); ++libNdx )
56  {
57  wxArrayString fpnames;
58 
59  aTbl->FootprintEnumerate( fpnames, nicks[libNdx], true );
60 
61  for( unsigned nameNdx = 0; nameNdx<fpnames.size(); ++nameNdx )
62  {
63  if( fpname == fpnames[nameNdx] )
64  {
65  if( !nick )
66  nick = nicks[libNdx];
67  else
68  return 2; // duplicate, the guess would not be certain
69  }
70  }
71  }
72 
73  if( nick.size() )
74  {
75  aFootprintId->SetLibNickname( nick );
76  return 0;
77  }
78 
79  return 1;
80 }
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
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:90
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:97
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().