23#include <wx/filedlg.h>
116 [
this]( wxCommandEvent& )
130 wxGridCellAttr* includeAttr =
new wxGridCellAttr;
131 includeAttr->SetRenderer(
new wxGridCellBoolRenderer );
132 includeAttr->SetEditor(
new wxGridCellBoolEditor );
133 includeAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
134 m_layers->SetColAttr( COL_INCLUDE, includeAttr );
136 for(
int col : { COL_LAYER, COL_CONTEXT, COL_SPAN } )
138 wxGridCellAttr* readOnlyAttr =
new wxGridCellAttr;
139 readOnlyAttr->SetReadOnly();
140 m_layers->SetColAttr( col, readOnlyAttr );
186 wxFileName brdFile(
m_parent->GetBoard()->GetFileName() );
187 wxFileName odbFile( brdFile.GetPath(), wxString::Format( wxS(
"%s-odb" ), brdFile.GetName() ),
196 SetTitle(
m_job->GetSettingsDialogTitle() );
248 return row.m_editable && aCandidate.m_layer == row.m_boardLayer;
252 wxString
name =
override && !
override->m_odbName.IsEmpty() ?
override->m_odbName : row.m_matrix.m_name;
253 wxString type =
override && !
override->m_odbType.IsEmpty() ?
override->m_odbType : row.m_matrix.m_type;
254 wxString span = row.m_matrix.m_startName;
256 if( !row.m_matrix.m_endName.IsEmpty() )
257 span += wxS(
" – " ) + row.m_matrix.m_endName;
260 bool keepsRef = type == wxS(
"SOLDER_MASK" ) || type == wxS(
"SOLDER_PASTE" ) || type == wxS(
"SILK_SCREEN" );
262 if( !row.m_matrix.m_ref.IsEmpty() && keepsRef )
267 bool include = !
override ||
override->m_include;
268 m_layers->SetCellValue( gridRow, COL_INCLUDE, include ? wxString( wxS(
"1" ) ) : wxString() );
269 m_layers->SetCellValue( gridRow, COL_LAYER, row.m_displayLayer );
272 m_layers->SetCellValue( gridRow, COL_CONTEXT, row.m_matrix.m_context );
273 m_layers->SetCellValue( gridRow, COL_SPAN, span );
278 new wxGridCellChoiceEditor( overridableTypeNames( row.m_boardLayer ) ) );
283 m_layers->SetReadOnly( gridRow, col );
293 m_layers->CommitPendingChanges(
true );
303 int gridRow =
static_cast<int>(
index );
308 if( overridableTypeNames( row.
m_boardLayer ).Index( type ) == wxNOT_FOUND )
313 override.m_include = !
m_layers->GetCellValue( gridRow, COL_INCLUDE ).IsEmpty();
315 override.m_odbType = type == row.
m_matrix.
m_type ? wxString() : type;
323 if( !
override.m_include || !
override.m_odbName.IsEmpty() || !
override.m_odbType.IsEmpty() )
337 if( !
path.IsEmpty() )
345 wxString
filter =
_(
"zip files" )
353 wxFileName fn(
Prj().AbsolutePath(
path ) );
355 wxFileName brdFile(
m_parent->GetBoard()->GetFileName() );
357 wxString fileDialogName( wxString::Format( wxS(
"%s-odb" ), brdFile.GetName() ) );
359 wxFileDialog dlg(
this,
_(
"Export ODB++ File" ), fn.GetPath(), fileDialogName,
filter, wxFD_SAVE );
363 if( dlg.ShowModal() == wxID_CANCEL )
366 path = dlg.GetPath();
368 fn = wxFileName(
path );
370 if( fn.GetExt().Lower() ==
"zip" )
374 else if( fn.GetExt().Lower() ==
"tgz" )
378 else if(
path.EndsWith(
"/" ) ||
path.EndsWith(
"\\" ) )
384 DisplayErrorMessage(
this,
_(
"The selected output file name is not a supported archive format." ) );
402 wxFileName fileName( fn );
406 int sepIdx = std::max( fn.Find(
'/',
true ), fn.Find(
'\\',
true ) );
407 int dotIdx = fn.Find(
'.',
true );
409 if( fileName.IsDir() )
410 fn = fn.Mid( 0, sepIdx );
411 else if( sepIdx < dotIdx )
412 fn = fn.Mid( 0, dotIdx );
414 switch( compressionMode )
423 fn = wxFileName( fn,
"" ).GetFullPath();
448 wxFileName fileName( fn );
449 bool isDirectory = fileName.IsDir();
450 wxString extension = fileName.GetExt();
456 DisplayErrorMessage(
this,
_(
"The output file name conflicts with the selected compression format." ) );
479 for(
const wxString& output :
result.m_outputs )
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
wxTextCtrl * m_outputFileName
wxChoice * m_choiceCompress
wxTextCtrl * m_productName
STD_BITMAP_BUTTON * m_browseButton
wxCheckBox * m_refillZones
PANEL_FAB_EXPORT_CONTENT * m_contentPanel
wxChoice * m_choiceOrigin
WX_HTML_REPORT_PANEL * m_messagesPanel
DIALOG_EXPORT_ODBPP_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Export ODB++"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
bool TransferDataFromWindow() override
void OnFmtChoiceOptionChanged()
std::vector< ODB_MATRIX_PREVIEW_ROW > m_previewRows
void onFormatChoice(wxCommandEvent &event) override
std::vector< ODB_LAYER_OVERRIDE > m_layerOverrides
bool TransferDataToWindow() override
void populateJob(JOB_EXPORT_PCB_ODB &aJob) const
void onBrowseClicked(wxCommandEvent &event) override
JOB_EXPORT_PCB_ODB * m_job
DIALOG_EXPORT_ODBPP(PCB_EDIT_FRAME *aParent)
~DIALOG_EXPORT_ODBPP() override
void updateVariantFilename()
PCB_EDIT_FRAME * m_parent
void updatePrecisionRange()
void harvestLayerOverrides()
Fold the grid's edits for the rows on screen into the layer overrides.
void onOKClick(wxCommandEvent &event) override
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...
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
std::optional< wxString > m_sections
Section key that replaces the optional sections of the data set Unset lets the data set select them a...
std::vector< wxString > m_variantNames
bool m_checkZonesBeforeExport
VARIANT_PACKAGING m_variantPackaging
ODB_COMPRESSION m_compressionMode
std::vector< ODB_LAYER_OVERRIDE > m_layerOverrides
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
The main frame for Pcbnew.
static int MinPrecision(bool aInches)
Lowest sigfig that still resolves a 0.1 mil grid: 3 decimal places in mm, 4 in inches.
static int MaxPrecision()
Highest sigfig accepted by the exporter, matching the export dialog's spin control.
A pure virtual class used to derive REPORTER objects from.
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.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
static const std::string ArchiveFileExtension
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
PCB_LAYER_ID
A quick note on layer IDs:
std::string Enum2String(T value)
std::vector< ODB_TYPE > OverridableLayerTypes(PCB_LAYER_ID aLayer)
Matrix types a layer override may assign to aLayer.
wxString OdbPreviewReferenceName(const wxString &aReference, const std::vector< ODB_MATRIX_PREVIEW_ROW > &aRows)
Matrix name of the row whose ID is aReference.
wxString UpdateOdbVariantOutputPath(const wxString &aPath, bool aDirectory, bool aSeparate, bool aRemoveAutomaticSuffix)
Add or remove the automatic variant suffix on the file stem or final directory.
std::vector< ODB_MATRIX_PREVIEW_ROW > PreviewOdbMatrix(BOARD *aBoard, const JOB_EXPORT_PCB_ODB &aJob)
Build export matrix rows without layer overrides or writing files.
ODB_EXPORT_RESULT GenerateODBPPFiles(const JOB_EXPORT_PCB_ODB &aJob, BOARD *aBoard, PCB_EDIT_FRAME *aParentFrame, PROGRESS_REPORTER *aProgressReporter, REPORTER *aReporter)
Generate the ODB++ tree or archive and return the write status and the paths written.
Fields that supply the IPC-2581 BOM section.
One matrix row with its KiCad layer for the dialog's layer grid.
PCB_LAYER_ID m_boardLayer
IbisParser parser & reporter
wxString result
Test unit parsing edge cases and error handling.
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.