26#include <wx/filedlg.h>
57 { wxID_CANCEL,
_(
"Close" ) } } );
80 SetTitle(
m_job->GetSettingsDialogTitle() );
97 wxFileName fn(
Prj().AbsolutePath(
path ) );
98 wxString ipc_files =
_(
"IPC-2581 Files (*.xml)|*.xml" );
99 wxString compressed_files =
_(
"IPC-2581 Compressed Files (*.zip)|*.zip" );
101 wxFileDialog dlg(
this,
_(
"Export IPC-2581 File" ), fn.GetPath(), fn.GetFullName(),
102 m_cbCompress->IsChecked() ? compressed_files : ipc_files,
103 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
107 if( dlg.ShowModal() == wxID_CANCEL )
135 if( event.GetSelection() == 0 )
149 if( it =
m_choiceMfg->FindString( wxT(
"manufacturer" ) ); it != wxNOT_FOUND )
151 else if( it =
m_choiceMfg->FindString(
_(
"manufacturer" ) ); it != wxNOT_FOUND )
153 else if( it =
m_choiceMfg->FindString( wxT(
"mfg" ) ); it != wxNOT_FOUND )
155 else if( it =
m_choiceMfg->FindString(
_(
"mfg" ) ); it != wxNOT_FOUND )
163 if( event.GetSelection() == 0 )
181 if( dist.Contains( wxT(
"DIGIKEY" ) ) )
185 else if( dist.Contains( wxT(
"DIGI-KEY" ) ) )
189 else if( dist.Contains( wxT(
"MOUSER" ) ) )
193 else if( dist.Contains( wxT(
"NEWARK" ) ) )
197 else if( dist.Contains( wxT(
"RS COMPONENTS" ) ) )
201 else if( dist.Contains( wxT(
"FARNELL" ) ) )
205 else if( dist.Contains( wxT(
"ARROW" ) ) )
209 else if( dist.Contains( wxT(
"AVNET" ) ) )
213 else if( dist.Contains( wxT(
"TME" ) ) )
217 else if( dist.Contains( wxT(
"LCSC" ) ) )
245 if( pcbFileName.GetName().empty() )
247 reporter.
Report(
_(
"The board must be saved before generating IPC-2581 file." ),
252 if( !
m_parent->IsWritable( pcbFileName ) )
254 reporter.
Report( wxString::Format(
_(
"Insufficient permissions to write file '%s'." ),
255 pcbFileName.GetFullPath() ),
260 wxString tempFile = wxFileName::CreateTempFileName( wxS(
"pcbnew_ipc" ) );
264 std::map<std::string, UTF8> props;
277 if( !bomRev.IsEmpty() )
278 props[
"bomrev" ] =
TO_UTF8( bomRev );
283 pi->SetProgressReporter( &progress );
284 pi->SetReporter( &reporter );
285 pi->SaveBoard( tempFile,
m_parent->GetBoard(), &props );
289 reporter.
Report( wxString::Format(
_(
"Error generating IPC-2581 file '%s'.\n%s" ),
290 pcbFileName.GetFullPath(), ioe.
What() ),
293 wxRemoveFile( tempFile );
297 if( wxFileExists( pcbFileName.GetFullPath() ) )
298 wxRemoveFile( pcbFileName.GetFullPath() );
300 if( !wxRenameFile( tempFile, pcbFileName.GetFullPath() ) )
302 reporter.
Report( wxString::Format(
_(
"Failed to create file '%s'." ), pcbFileName.GetFullPath() ),
304 wxRemoveFile( tempFile );
316 std::set<wxString> options;
320 for(
PCB_FIELD* field : fp->GetFields() )
322 wxCHECK2( field,
continue );
324 options.insert( field->GetName() );
328 std::vector<wxString> items( options.begin(), options.end() );
344 wxFileName brdFile(
m_parent->GetBoard()->GetFileName() );
345 brdFile.SetExt( wxT(
"xml" ) );
346 path = brdFile.GetFullPath();
359 wxCommandEvent
dummy;
364 wxString internalIdCol;
379 if( bomRev.IsEmpty() )
386 internalIdCol =
m_job->m_colInternalId;
387 mpnCol =
m_job->m_colMfgPn;
388 distPnCol =
m_job->m_colDistPn;
389 mfgCol =
m_job->m_colMfg;
390 distCol =
m_job->m_colDist;
394 if( !
m_choiceMPN->SetStringSelection( internalIdCol ) )
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
wxTextCtrl * m_outputFileName
wxTextCtrl * m_textBomRev
wxChoice * m_versionChoice
DIALOG_EXPORT_2581_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Export IPC-2581"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
WX_HTML_REPORT_PANEL * m_messagesPanel
wxTextCtrl * m_textDistributor
STD_BITMAP_BUTTON * m_browseButton
wxChoice * m_choiceDistPN
wxCheckBox * m_cbCompress
void onMfgPNChange(wxCommandEvent &event) override
wxString GetPrecision() const
bool TransferDataToWindow() override
void onCompressCheck(wxCommandEvent &event) override
void onOKClick(wxCommandEvent &event) override
void onDistPNChange(wxCommandEvent &event) override
bool TransferDataFromWindow() override
wxString GetDistPN() const
DIALOG_EXPORT_2581(PCB_EDIT_FRAME *aParent)
PCB_EDIT_FRAME * m_parent
void onBrowseClicked(wxCommandEvent &event) override
wxString GetUnitsString() const
JOB_EXPORT_PCB_IPC2581 * m_job
wxString GetOutputPath() const
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
The main frame for Pcbnew.
static PCB_IO * FindPlugin(PCB_FILE_T aFileType)
Return a #PLUGIN which the caller can use to import, export, save, or load design documents.
The backing store for a PROJECT, in JSON format.
struct IP2581_BOM m_IP2581Bom
Layer pair list for the board.
virtual PROJECT_FILE & GetProjectFile() const
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
static void ResolvePossibleSymlinks(wxFileName &aFilename)
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
std::vector< FAB_LAYER_COLOR > dummy
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
wxString mfg
Manufacturer name column.
wxString bomRev
Explicit BOM revision override set by user.
wxString schRevision
Auto-propagated schematic title block revision.
wxString MPN
Manufacturer part number column.
wxString id
Internal ID column.
wxString dist
Distributor name column.
wxString distPN
Distributor part number column.