35 #include <wx/listimpl.cpp> 67 WX_DEFINE_LIST( BOM_ENTRY_LIST )
78 ShowInfoBarError(
_(
"Cannot export BOM: there are no footprints on the PCB." ) );
86 wxString pro_dir = wxPathOnly(
Prj().GetProjectFullName() );
88 wxFileDialog dlg(
this,
_(
"Save Bill of Materials" ), pro_dir, fn.GetFullName(),
91 if( dlg.ShowModal() == wxID_CANCEL )
96 fp_bom = wxFopen( fn.GetFullPath(), wxT(
"wt" ) );
100 msg.Printf(
_(
"Unable to create file \"%s\"" ), fn.GetFullPath() );
107 msg <<
_(
"Id" ) << wxT(
"\";\"" );
108 msg <<
_(
"Designator" ) << wxT(
"\";\"" );
109 msg <<
_(
"Package" ) << wxT(
"\";\"" );
110 msg <<
_(
"Quantity" ) << wxT(
"\";\"" );
111 msg <<
_(
"Designation" ) << wxT(
"\";\"" );
112 msg <<
_(
"Supplier and ref" ) << wxT(
"\";\n" );
113 fprintf( fp_bom,
"%s",
TO_UTF8( msg ) );
121 bool valExist =
false;
124 for(
auto iter = list.begin(); iter != list.end(); ++iter )
128 if( curEntry->
m_Val == footprint->GetValue()
129 && curEntry->
m_FPID == footprint->GetFPID() )
131 curEntry->
m_Ref.Append( wxT(
", " ), 1 );
132 curEntry->
m_Ref.Append( footprint->Reference().GetShownText() );
141 if( valExist ==
false )
144 newEntry->
m_Id = i++;
145 newEntry->
m_Val = footprint->Value().GetShownText();
146 newEntry->
m_Ref = footprint->Reference().GetShownText();
147 newEntry->
m_FPID = footprint->GetFPID();
149 list.Append( newEntry );
154 for(
size_t ii = list.GetCount(); ii > 0; ii-- )
161 msg << curEntry->
m_Id << wxT(
";\"" );
162 msg << curEntry->
m_Ref << wxT(
"\";\"" );
164 msg << curEntry->
m_Count << wxT(
";\"" );
165 msg << curEntry->
m_Val << wxT(
"\";;;\n" );
166 fprintf( fp_bom,
"%s",
TO_UTF8( msg ) );
169 list.DeleteObject( curEntry );
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
const UTF8 & GetLibItemName() const
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
This file is part of the common library.
wxString CsvFileWildcard()
A logical library item identifier and consists of various portions much like a URI.
const wxString CsvFileExtension(wxT("csv"))
const wxString & GetFileName() const
This file contains miscellaneous commonly used macros and functions.
const char * c_str() const
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition of file extensions used in Kicad.
The main frame for Pcbnew.
static bool empty(const wxTextEntryBase *aCtrl)
WX_DECLARE_LIST(BOM_ENTRY, BOM_ENTRY_LIST)