57 if( wxNOT_FOUND == i )
60 wxString shrt =
text.Mid( i + 1 );
61 i = shrt.Find(
QUOTE );
63 if( wxNOT_FOUND == i )
66 text = shrt.Mid( i + 1 );
67 return shrt.Mid( 0, i );
80 wxString* aErrorMessages )
86 wxString tmp, error_msg;
93 for(
const wxString& equfile :
project.m_EquivalenceFiles )
95 fn = wxExpandEnvVars( equfile );
97 if( fn.IsAbsolute() || fn.FileExists() )
98 tmp = fn.GetFullPath();
100 tmp = search.FindValidPath( fn.GetFullPath() );
108 error_msg.Printf(
_(
"Equivalence file '%s' could not be found." ),
111 if( ! aErrorMessages->IsEmpty() )
112 *aErrorMessages << wxT(
"\n\n");
114 *aErrorMessages += error_msg;
120 file = wxFopen( tmp, wxT(
"rt" ) );
122 if( file ==
nullptr )
128 error_msg.Printf(
_(
"Error opening equivalence file '%s'." ), tmp );
130 if( ! aErrorMessages->IsEmpty() )
131 *aErrorMessages << wxT(
"\n\n");
133 *aErrorMessages += error_msg;
139 while(
GetLine( file, line,
nullptr,
sizeof( line ) ) !=
nullptr )
147 if( value.IsEmpty() )
152 if( footprint.IsEmpty() )
155 value.Replace( wxT(
" " ), wxT(
"_" ) );
160 aList.push_back( equivItem );
180 wxMessageBox( error_msg,
_(
"Equivalence File Load Error" ), wxOK | wxICON_WARNING,
this );
187 msg.Printf(
_(
"%lu footprint/symbol equivalences found." ), (
unsigned long)equivList.size() );
194 bool firstAssoc =
true;
208 wxString fpid_candidate;
210 for(
unsigned idx = 0; idx < equivList.size(); idx++ )
219 bool equ_is_unique =
true;
220 unsigned next = idx+1;
221 int previous = idx-1;
223 if(
next < equivList.size()
226 equ_is_unique =
false;
232 equ_is_unique =
false;
236 if( fp && equ_is_unique )
247 if( fp && fpid_candidate.IsEmpty() )
256 found = ( 0 == filtercount );
258 for(
size_t jj = 0; jj < filtercount && !found; jj++ )
263 msg.Printf(
_(
"Component %s: footprint %s not found in any of the project "
264 "footprint libraries." ),
267 if( ! error_msg.IsEmpty() )
268 error_msg << wxT(
"\n\n");
286 else if( !fpid_candidate.IsEmpty() )
307 if( !error_msg.IsEmpty() )
308 wxMessageBox( error_msg,
_(
"CvPcb Warning" ), wxOK | wxICON_WARNING,
this );
wxString GetQuotedText(wxString &text)
Read the string between quotes.
bool sortListbyCmpValue(const FOOTPRINT_EQUIVALENCE &ref, const FOOTPRINT_EQUIVALENCE &test)
boost::ptr_vector< FOOTPRINT_EQUIVALENCE > FOOTPRINT_EQUIVALENCE_LIST
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Store all of the related footprint information found in a netlist.
const wxString & GetReference() const
const wxString & GetValue() const
const wxArrayString & GetFootprintFilters() const
const LIB_ID & GetFPID() const
A class to define a footprint association to be made in cvpcb.
void SetStatusText(const wxString &aText, int aNumber=0) override
bool m_skipComponentSelect
int buildEquivalenceList(FOOTPRINT_EQUIVALENCE_LIST &aList, wxString *aErrorMessages=nullptr)
Read the .equ files and populate the list of equivalents.
FOOTPRINT_LIST * m_FootprintsList
void AssociateFootprint(const CVPCB_ASSOCIATION &aAssociation, bool aNewEntry=true, bool aAddUndoItem=true)
Associate a footprint with a specific component in the list.
SYMBOLS_LISTBOX * m_symbolsListBox
void AutomaticFootprintMatching()
Called by the automatic association button Read *.equ files to try to find corresponding footprint fo...
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
unsigned GetCount() const
COMPONENT * GetComponent(unsigned aIndex)
Return the COMPONENT at aIndex.
The backing store for a PROJECT, in JSON format.
virtual PROJECT_FILE & GetProjectFile() const
Look for files in a number of paths.
This file contains miscellaneous commonly used macros and functions.
wxString From_UTF8(const char *cstring)
char * GetLine(FILE *File, char *Line, int *LineNum, int SizeLine)
Read one line line from aFile.