26#include <wx/filedlg.h>
69 m_board( aPcbEditFrame->GetBoard() ),
70 m_plotOpts( aPcbEditFrame->GetPlotSettings() ),
76 { wxID_CANCEL,
_(
"Close" ) } } );
102 SetTitle(
m_job->GetSettingsDialogTitle() );
133 m_zeros->SetSelection(
static_cast<int>(
m_job->m_zeroFormat ) );
147 wxCommandEvent
dummy;
188 m_units->Enable( enbl_Excellon );
190 m_zeros->Enable( enbl_Excellon );
215 dirStr.Replace( wxT(
"\\" ), wxT(
"/" ) );
241 if(
m_units->GetSelection() == 1 )
270 wxDirDialog dirDialog(
this,
_(
"Select Output Directory" ),
path );
272 if( dirDialog.ShowModal() == wxID_CANCEL )
275 wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
276 wxFileName fn(
Prj().AbsolutePath(
m_board->GetFileName() ) );
277 wxString defaultPath = fn.GetPathWithSep();
279 if(
IsOK(
this, wxString::Format(
_(
"Do you want to use a path relative to\n'%s'?" ), defaultPath ) ) )
281 if( !dirName.MakeRelativeTo( defaultPath ) )
317 std::function<bool( wxString* )> textResolver =
318 [&]( wxString* token ) ->
bool
321 return m_board->ResolveTextVar( token, 0 );
326 wxFileName outputDir = wxFileName::DirName(
path );
327 wxString boardFilename =
m_board->GetFileName();
331 DisplayError(
this, wxString::Format(
_(
"Could not write drill and/or map files to folder '%s'." ),
332 outputDir.GetPath() ) );
342 drillFileOffset =
m_board->GetDesignSettings().GetAuxOrigin();
344 if(
m_units->GetSelection() == 0 )
382 wxFileName fn =
m_board->GetFileName();
384 fn.SetName( fn.GetName() + wxT(
"-drl" ) );
389 if( defaultPath.IsEmpty() )
392 wxFileDialog dlg(
this,
_(
"Save Drill Report File" ), defaultPath, fn.GetFullName(),
397 if( dlg.ShowModal() == wxID_CANCEL )
418 m_messagesBox->AppendText( wxString::Format(
_(
"Failed to create file '%s'." ), dlg.GetPath() ) );
420 m_messagesBox->AppendText( wxString::Format(
_(
"Report file '%s' created." ), dlg.GetPath() ) );
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
int GenerateDrillFiles(const TOOL_EVENT &aEvent)
wxRadioButton * m_rbExcellon
wxStaticText * m_staticTextPrecision
STD_BITMAP_BUTTON * m_browseButton
wxStaticBoxSizer * bMsgSizer
wxCheckBox * m_altDrillMode
wxStaticText * m_unitsLabel
wxChoice * m_choiceDrillMap
wxRadioButton * m_rbGerberX2
wxCheckBox * m_Check_Mirror
DIALOG_GENDRILL_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Generate Drill Files"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxCheckBox * m_Check_Merge_PTH_NPTH
wxStaticText * m_zerosLabel
wxTextCtrl * m_outputDirectoryName
wxCheckBox * m_cbGenerateMap
wxTextCtrl * m_messagesBox
wxCheckBox * m_generateTentingLayers
wxStaticText * m_precisionLabel
wxButton * m_buttonReport
wxCheckBox * m_Check_Minimal
PCB_PLOT_PARAMS m_plotOpts
void onOutputDirectoryBrowseClicked(wxCommandEvent &event) override
void onFileFormatSelection(wxCommandEvent &event) override
void genDrillAndMapFiles(bool aGenDrill, bool aGenMap, bool aGenTenting)
Call to create EXCELLON drill files and/or drill map files.
bool TransferDataFromWindow() override
PCB_EDIT_FRAME * m_pcbEditFrame
DIALOG_GENDRILL(PCB_EDIT_FRAME *aPcbEditFrame, wxWindow *aParent)
bool TransferDataToWindow() override
void onSelZerosFmtSelected(wxCommandEvent &event) override
void onGenReportFile(wxCommandEvent &event) override
JOB_EXPORT_PCB_DRILL * m_job
void onSelDrillUnitsSelected(wxCommandEvent &event) override
void updatePrecisionOptions()
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...
Helper to handle drill precision format in excellon files.
Create Excellon drill, drill map, and drill report files.
void SetFormat(bool aMetric, ZEROS_FMT aZerosFmt=DECIMAL_FORMAT, int aLeftDigits=0, int aRightDigits=0)
Initialize internal parameters to match the given format.
bool CreateDrillandMapFilesSet(const wxString &aPlotDirectory, bool aGenDrill, bool aGenMap, REPORTER *aReporter=nullptr)
Create the full set of Excellon drill file for the board.
void SetOptions(bool aMirror, bool aMinimalHeader, const VECTOR2I &aOffset, bool aMerge_PTH_NPTH)
Initialize internal parameters to match drill options.
void SetRouteModeForOvalHoles(bool aUseRouteModeForOvalHoles)
void SetMapFileFormat(PLOT_FORMAT aMapFmt)
Initialize the format for the drill map file.
void SetMergeOption(bool aMerge)
Set the option to make separate drill files for PTH and NPTH.
void SetPageInfo(const PAGE_INFO *aPageInfo)
Set the page info used to plot drill maps.
bool GenDrillReportFile(const wxString &aFullFileName, REPORTER *aReporter=nullptr)
Create a plain text report file giving a list of drill values and drill count for through holes,...
Used to create Gerber drill files.
bool CreateDrillandMapFilesSet(const wxString &aPlotDirectory, bool aGenDrill, bool aGenMap, bool aGenTenting, REPORTER *aReporter=nullptr)
Create the full set of Excellon drill file for the board filenames are computed from the board name,...
void SetOptions(const VECTOR2I &aOffset)
Initialize internal parameters to match drill options.
void SetFormat(int aRightDigits=6)
Initialize internal parameters to match the given format.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
The main frame for Pcbnew.
A wrapper for reporting to a wxTextCtrl object.
wxString ExpandPathVariables(const wxString &aPath, const PROJECT *aProject, const std::function< bool(wxString *)> *aTextResolver)
Expand text variables, environment variables and a leading '~' in a user-entered file path.
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...
bool EnsureFileDirectoryExists(wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter)
Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
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 DRILL_PRECISION precisionListForInches(2, 4)
static DRILL_PRECISION precisionListForMetric(3, 3)
Classes used in drill files, map files and report files generation.
Classes used in drill files, map files and report files generation.
static const std::string ReportFileExtension
static wxString ReportFileWildcard()
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
PLOT_FORMAT
The set of supported output plot formats.
std::vector< FAB_LAYER_COLOR > dummy
IbisParser parser & reporter
VECTOR2< int32_t > VECTOR2I
Definition of file extensions used in Kicad.