37#include <wx/listimpl.cpp>
38#include <wx/filedlg.h>
70WX_DEFINE_LIST( BOM_ENTRY_LIST )
81 m_frame->ShowInfoBarError(
_(
"Cannot export BOM: there are no footprints on the PCB." ) );
89 wxString pro_dir = wxPathOnly( m_frame->Prj().GetProjectFullName() );
91 wxFileDialog dlg( m_frame,
_(
"Save Bill of Materials" ), pro_dir, fn.GetFullName(),
94 if( dlg.ShowModal() == wxID_CANCEL )
99 fp_bom = wxFopen( fn.GetFullPath(), wxT(
"wt" ) );
101 if( fp_bom ==
nullptr )
103 DisplayError( m_frame, wxString::Format(
_(
"Failed to create file '%s'." ), fn.GetFullPath() ) );
108 wxString msg = wxT(
"\"" );
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() && curEntry->
m_FPID == footprint->GetFPID() )
135 curEntry->
m_Ref.Append( wxT(
", " ), 1 );
136 curEntry->
m_Ref.Append( footprint->Reference().GetShownText(
false ) );
145 if( valExist ==
false )
148 newEntry->
m_Id = i++;
149 newEntry->
m_Val = footprint->Value().GetShownText(
false );
150 newEntry->
m_Ref = footprint->Reference().GetShownText(
false );
151 newEntry->
m_FPID = footprint->GetFPID();
153 list.Append( newEntry );
158 for(
size_t ii = list.GetCount(); ii > 0; ii-- )
164 msg << curEntry->
m_Id << wxT(
";\"" );
165 msg << curEntry->
m_Ref << wxT(
"\";\"" );
167 msg << curEntry->
m_Count << wxT(
";\"" );
168 msg << curEntry->
m_Val << wxT(
"\";;;\n" );
169 fprintf( fp_bom,
"%s",
TO_UTF8( msg ) );
172 list.DeleteObject( curEntry );
WX_DECLARE_LIST(BOM_ENTRY, BOM_ENTRY_LIST)
Handle actions specific to the board editor in PcbNew.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Information pertinent to a Pcbnew printed circuit board.
const FOOTPRINTS & Footprints() const
const wxString & GetFileName() const
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibItemName() const
const char * c_str() const
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
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.