25#include <wx/filedlg.h>
118 [
this]( wxCommandEvent& )
132 wxGridCellAttr* includeAttr =
new wxGridCellAttr;
133 includeAttr->SetRenderer(
new wxGridCellBoolRenderer );
134 includeAttr->SetEditor(
new wxGridCellBoolEditor );
135 includeAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
136 m_layers->SetColAttr( COL_INCLUDE, includeAttr );
138 for(
int col : { COL_LAYER, COL_CONTEXT, COL_SPAN } )
140 wxGridCellAttr* readOnlyAttr =
new wxGridCellAttr;
141 readOnlyAttr->SetReadOnly();
142 m_layers->SetColAttr( col, readOnlyAttr );
188 wxFileName brdFile(
m_parent->GetBoard()->GetFileName() );
189 wxFileName odbFile( brdFile.GetPath(), wxString::Format( wxS(
"%s-odb" ), brdFile.GetName() ),
198 SetTitle(
m_job->GetSettingsDialogTitle() );
250 return row.m_editable && aCandidate.m_layer == row.m_boardLayer;
254 wxString
name =
override && !
override->m_odbName.IsEmpty() ?
override->m_odbName : row.m_matrix.m_name;
255 wxString type =
override && !
override->m_odbType.IsEmpty() ?
override->m_odbType : row.m_matrix.m_type;
256 wxString span = row.m_matrix.m_startName;
258 if( !row.m_matrix.m_endName.IsEmpty() )
259 span += wxS(
" – " ) + row.m_matrix.m_endName;
262 bool keepsRef = type == wxS(
"SOLDER_MASK" ) || type == wxS(
"SOLDER_PASTE" ) || type == wxS(
"SILK_SCREEN" );
264 if( !row.m_matrix.m_ref.IsEmpty() && keepsRef )
269 bool include = !
override ||
override->m_include;
270 m_layers->SetCellValue( gridRow, COL_INCLUDE, include ? wxString( wxS(
"1" ) ) : wxString() );
271 m_layers->SetCellValue( gridRow, COL_LAYER, row.m_displayLayer );
274 m_layers->SetCellValue( gridRow, COL_CONTEXT, row.m_matrix.m_context );
275 m_layers->SetCellValue( gridRow, COL_SPAN, span );
280 new wxGridCellChoiceEditor( overridableTypeNames( row.m_boardLayer ) ) );
285 m_layers->SetReadOnly( gridRow, col );
295 m_layers->CommitPendingChanges(
true );
305 int gridRow =
static_cast<int>(
index );
310 if( overridableTypeNames( row.
m_boardLayer ).Index( type ) == wxNOT_FOUND )
315 override.m_include = !
m_layers->GetCellValue( gridRow, COL_INCLUDE ).IsEmpty();
317 override.m_odbType = type == row.
m_matrix.
m_type ? wxString() : type;
325 if( !
override.m_include || !
override.m_odbName.IsEmpty() || !
override.m_odbType.IsEmpty() )
339 if( !
path.IsEmpty() )
347 wxString
filter =
_(
"zip files" )
356 wxFileName brdFile(
m_parent->GetBoard()->GetFileName() );
358 wxString fileDialogName( wxString::Format( wxS(
"%s-odb" ), brdFile.GetName() ) );
360 wxFileDialog dlg(
this,
_(
"Export ODB++ File" ), fn.GetPath(), fileDialogName,
filter, wxFD_SAVE );
364 if( dlg.ShowModal() == wxID_CANCEL )
367 wxString
path = dlg.GetPath();
369 fn = wxFileName(
path );
371 if( fn.GetExt().Lower() ==
"zip" )
375 else if( fn.GetExt().Lower() ==
"tgz" )
379 else if(
path.EndsWith(
"/" ) ||
path.EndsWith(
"\\" ) )
385 DisplayErrorMessage(
this,
_(
"The selected output file name is not a supported archive format." ) );
403 wxFileName fileName( fn );
407 int sepIdx = std::max( fn.Find(
'/',
true ), fn.Find(
'\\',
true ) );
408 int dotIdx = fn.Find(
'.',
true );
410 if( fileName.IsDir() )
411 fn = fn.Mid( 0, sepIdx );
412 else if( sepIdx < dotIdx )
413 fn = fn.Mid( 0, dotIdx );
415 switch( compressionMode )
424 fn = wxFileName( fn,
"" ).GetFullPath();
449 wxFileName fileName( fn );
450 bool isDirectory = fileName.IsDir();
451 wxString extension = fileName.GetExt();
457 DisplayErrorMessage(
this,
_(
"The output file name conflicts with the selected compression format." ) );
480 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...
wxString ResolveProjectPath(const wxString &aPath, const PROJECT *aProject, const std::function< bool(wxString *)> *aTextResolver)
Expand a user-entered file path as ExpandPathVariables() does, then anchor a relative result at the p...
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.