36#include <wx/listimpl.cpp>
37#include <wx/filedlg.h>
69WX_DEFINE_LIST( BOM_ENTRY_LIST )
80 ShowInfoBarError(
_(
"Cannot export BOM: there are no footprints on the PCB." ) );
88 wxString pro_dir = wxPathOnly(
Prj().GetProjectFullName() );
90 wxFileDialog dlg(
this,
_(
"Save Bill of Materials" ), pro_dir, fn.GetFullName(),
93 if( dlg.ShowModal() == wxID_CANCEL )
98 fp_bom = wxFopen( fn.GetFullPath(), wxT(
"wt" ) );
100 if( fp_bom ==
nullptr )
102 msg.Printf(
_(
"Failed to create file '%s'." ), fn.GetFullPath() );
109 msg <<
_(
"Id" ) << wxT(
"\";\"" );
110 msg <<
_(
"Designator" ) << wxT(
"\";\"" );
111 msg <<
_(
"Footprint" ) << wxT(
"\";\"" );
112 msg <<
_(
"Quantity" ) << wxT(
"\";\"" );
113 msg <<
_(
"Designation" ) << wxT(
"\";\"" );
114 msg <<
_(
"Supplier and ref" ) << wxT(
"\";\n" );
115 fprintf( fp_bom,
"%s",
TO_UTF8( msg ) );
126 bool valExist =
false;
129 for(
auto iter = list.begin(); iter != list.end(); ++iter )
133 if( curEntry->
m_Val == footprint->GetValue()
134 && curEntry->
m_FPID == footprint->GetFPID() )
136 curEntry->
m_Ref.Append( wxT(
", " ), 1 );
137 curEntry->
m_Ref.Append( footprint->Reference().GetShownText(
false ) );
146 if( valExist ==
false )
149 newEntry->
m_Id = i++;
150 newEntry->
m_Val = footprint->Value().GetShownText(
false );
151 newEntry->
m_Ref = footprint->Reference().GetShownText(
false );
152 newEntry->
m_FPID = footprint->GetFPID();
154 list.Append( newEntry );
159 for(
size_t ii = list.GetCount(); ii > 0; ii-- )
166 msg << curEntry->
m_Id << wxT(
";\"" );
167 msg << curEntry->
m_Ref << wxT(
"\";\"" );
169 msg << curEntry->
m_Count << wxT(
";\"" );
170 msg << curEntry->
m_Val << wxT(
"\";;;\n" );
171 fprintf( fp_bom,
"%s",
TO_UTF8( msg ) );
174 list.DeleteObject( curEntry );
WX_DECLARE_LIST(BOM_ENTRY, BOM_ENTRY_LIST)
const wxString & GetFileName() const
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibItemName() const
The main frame for Pcbnew.
const char * c_str() const
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
This file is part of the common library.
static bool empty(const wxTextEntryBase *aCtrl)
static const std::string CsvFileExtension
static wxString CsvFileWildcard()
This file contains miscellaneous commonly used macros and functions.
wxString From_UTF8(const char *cstring)
#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.