53 if( wxNOT_FOUND == i )
56 wxString shrt =
text.Mid( i + 1 );
57 i = shrt.Find(
QUOTE );
59 if( wxNOT_FOUND == i )
62 text = shrt.Mid( i + 1 );
63 return shrt.Mid( 0, i );
76 wxString* aErrorMessages )
82 wxString tmp, error_msg;
89 for(
const wxString& equfile :
project.m_EquivalenceFiles )
91 fn = wxExpandEnvVars( equfile );
93 if( fn.IsAbsolute() || fn.FileExists() )
94 tmp = fn.GetFullPath();
96 tmp = search.FindValidPath( fn.GetFullPath() );
104 error_msg.Printf(
_(
"Equivalence file '%s' could not be found." ),
107 if( ! aErrorMessages->IsEmpty() )
108 *aErrorMessages << wxT(
"\n\n" );
110 *aErrorMessages += error_msg;
116 file = wxFopen( tmp, wxT(
"rt" ) );
118 if( file ==
nullptr )
124 error_msg.Printf(
_(
"Error opening equivalence file '%s'." ), tmp );
126 if( ! aErrorMessages->IsEmpty() )
127 *aErrorMessages << wxT(
"\n\n" );
129 *aErrorMessages += error_msg;
135 while(
GetLine( file, line,
nullptr,
sizeof( line ) ) !=
nullptr )
143 if( value.IsEmpty() )
148 if( footprint.IsEmpty() )
151 value.Replace( wxT(
" " ), wxT(
"_" ) );
156 aList.push_back( equivItem );
176 wxMessageBox( error_msg,
_(
"Equivalence File Load Error" ), wxOK | wxICON_WARNING,
this );
183 msg.Printf(
_(
"%lu footprint/symbol equivalences found." ), (
unsigned long)equivList.size() );
190 bool firstAssoc =
true;
192 for(
int kk = 0; kk < (int)
m_netlist.GetCount(); kk++ )
205 wxString fpid_candidate;
207 for(
int idx = 0; idx < (int) equivList.size(); idx++ )
216 bool equ_is_unique =
true;
218 int previous = idx-1;
221 equ_is_unique =
false;
223 if( previous >= 0 && equivItem.
m_ComponentValue == equivList[previous].m_ComponentValue )
224 equ_is_unique =
false;
227 if( fp && equ_is_unique )
237 if( fp && fpid_candidate.IsEmpty() )
246 found = ( filtercount == 0 );
248 for(
size_t jj = 0; jj < filtercount && !found; jj++ )
253 msg.Printf(
_(
"Component %s: footprint %s not found in any of the project footprint libraries." ),
257 if( !error_msg.IsEmpty() )
258 error_msg << wxT(
"\n\n");
275 else if( !fpid_candidate.IsEmpty() )
295 if( !error_msg.IsEmpty() )
296 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 component 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.
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.