26#include <wx/filedlg.h>
56 { wxID_CANCEL,
_(
"Close" ) } } );
79 SetTitle(
m_job->GetSettingsDialogTitle() );
96 wxFileName fn(
Prj().AbsolutePath(
path ) );
97 wxString ipc_files =
_(
"IPC-2581 Files (*.xml)|*.xml" );
98 wxString compressed_files =
_(
"IPC-2581 Compressed Files (*.zip)|*.zip" );
100 wxFileDialog dlg(
this,
_(
"Export IPC-2581 File" ), fn.GetPath(), fn.GetFullName(),
101 m_cbCompress->IsChecked() ? compressed_files : ipc_files,
102 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
104 if( dlg.ShowModal() == wxID_CANCEL )
132 if( event.GetSelection() == 0 )
146 if( it =
m_choiceMfg->FindString( wxT(
"manufacturer" ) ); it != wxNOT_FOUND )
148 else if( it =
m_choiceMfg->FindString(
_(
"manufacturer" ) ); it != wxNOT_FOUND )
150 else if( it =
m_choiceMfg->FindString( wxT(
"mfg" ) ); it != wxNOT_FOUND )
152 else if( it =
m_choiceMfg->FindString(
_(
"mfg" ) ); it != wxNOT_FOUND )
160 if( event.GetSelection() == 0 )
178 if( dist.Contains( wxT(
"DIGIKEY" ) ) )
182 else if( dist.Contains( wxT(
"DIGI-KEY" ) ) )
186 else if( dist.Contains( wxT(
"MOUSER" ) ) )
190 else if( dist.Contains( wxT(
"NEWARK" ) ) )
194 else if( dist.Contains( wxT(
"RS COMPONENTS" ) ) )
198 else if( dist.Contains( wxT(
"FARNELL" ) ) )
202 else if( dist.Contains( wxT(
"ARROW" ) ) )
206 else if( dist.Contains( wxT(
"AVNET" ) ) )
210 else if( dist.Contains( wxT(
"TME" ) ) )
214 else if( dist.Contains( wxT(
"LCSC" ) ) )
242 if( pcbFileName.GetName().empty() )
244 reporter.
Report(
_(
"The board must be saved before generating IPC-2581 file." ),
249 if( !
m_parent->IsWritable( pcbFileName ) )
251 reporter.
Report( wxString::Format(
_(
"Insufficient permissions to write file '%s'." ),
252 pcbFileName.GetFullPath() ),
257 wxString tempFile = wxFileName::CreateTempFileName( wxS(
"pcbnew_ipc" ) );
261 std::map<std::string, UTF8> props;
275 pi->SetProgressReporter( &progress );
276 pi->SetReporter( &reporter );
277 pi->SaveBoard( tempFile,
m_parent->GetBoard(), &props );
281 reporter.
Report( wxString::Format(
_(
"Error generating IPC-2581 file '%s'.\n%s" ),
282 pcbFileName.GetFullPath(), ioe.
What() ),
285 wxRemoveFile( tempFile );
289 if( wxFileExists( pcbFileName.GetFullPath() ) )
290 wxRemoveFile( pcbFileName.GetFullPath() );
292 if( !wxRenameFile( tempFile, pcbFileName.GetFullPath() ) )
294 reporter.
Report( wxString::Format(
_(
"Failed to create file '%s'." ), pcbFileName.GetFullPath() ),
296 wxRemoveFile( tempFile );
308 std::set<wxString> options;
312 for(
PCB_FIELD* field : fp->GetFields() )
313 options.insert( field->GetName() );
316 std::vector<wxString> items( options.begin(), options.end() );
332 wxFileName brdFile(
m_parent->GetBoard()->GetFileName() );
333 brdFile.SetExt( wxT(
"xml" ) );
334 path = brdFile.GetFullPath();
347 wxCommandEvent
dummy;
352 wxString internalIdCol;
368 internalIdCol =
m_job->m_colInternalId;
369 mpnCol =
m_job->m_colMfgPn;
370 distPnCol =
m_job->m_colDistPn;
371 mfgCol =
m_job->m_colMfg;
372 distCol =
m_job->m_colDist;
375 if( !
m_choiceMPN->SetStringSelection( internalIdCol ) )
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
wxTextCtrl * m_outputFileName
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 * PluginFind(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 MPN
Manufacturer part number column.
wxString id
Internal ID column.
wxString dist
Distributor name column.
wxString distPN
Distributor part number column.