46 #include <wx/dirdlg.h> 73 GetSizer()->SetSizeHints(
this);
80 void OnGenerate( wxCommandEvent& event )
override;
200 GetSizer()->SetSizeHints(
this );
209 wxDirDialog dirDialog(
this,
_(
"Select Output Directory" ),
path );
211 if( dirDialog.ShowModal() == wxID_CANCEL )
214 wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
216 wxMessageDialog dialog(
this,
_(
"Use a relative path?"),
217 _(
"Plot Output Directory" ),
218 wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
220 if( dialog.ShowModal() == wxID_YES )
224 if( !dirName.MakeRelativeTo( boardFilePath ) )
225 wxMessageBox(
_(
"Cannot make path relative (target volume different from board " 227 _(
"Plot Output Directory" ), wxOK | wxICON_ERROR );
246 cfg->m_PlaceFile.file_options =
m_fileOpt;
255 dirStr.Replace( wxT(
"\\" ), wxT(
"/" ) );
277 std::function<bool( wxString* )> textResolver =
278 [&]( wxString* token ) ->
bool 288 wxFileName outputDir = wxFileName::DirName(
path );
295 msg.Printf(
_(
"Could not write plot files to folder '%s'." ),
296 outputDir.GetPath() );
302 fn.SetPath( outputDir.GetPath() );
313 msg.Printf(
_(
"Failed to create file '%s'." ), fn.GetFullPath() );
319 msg.Printf(
_(
"Front (top side) placement file: '%s'." ), filename );
322 msg.Printf(
_(
"Component count: %d." ), fpcount );
334 msg.Printf(
_(
"Failed to create file '%s'." ), filename );
341 msg.Printf(
_(
"Back (bottom side) placement file: '%s'." ), filename );
344 msg.Printf(
_(
"Component count: %d." ), fpcount );
347 fullcount += fpcount;
348 msg.Printf(
_(
"Full component count: %d." ), fullcount );
367 int bottomSide =
true;
372 bottomSide, useCSVfmt, useAuxOrigin );
377 wxMessageBox(
_(
"No footprint for automated placement." ) );
385 std::function<bool( wxString* )> textResolver =
386 [&]( wxString* token ) ->
bool 396 wxFileName outputDir = wxFileName::DirName(
path );
403 msg.Printf(
_(
"Could not write plot files to folder '%s'." ), outputDir.GetPath() );
409 fn.SetPath( outputDir.GetPath() );
418 fn.SetName( fn.GetName() + wxT(
"-" ) + wxT(
"all" ) );
429 fn.SetExt( wxT(
"csv" ) );
438 useCSVfmt, useAuxOrigin );
441 msg.Printf(
_(
"Failed to create file '%s'." ), fn.GetFullPath() );
448 msg.Printf(
_(
"Placement file: '%s'." ), fn.GetFullPath() );
450 msg.Printf(
_(
"Front (top side) placement file: '%s'." ), fn.GetFullPath() );
454 msg.Printf(
_(
"Component count: %d." ), fpcount );
468 fn.SetPath( outputDir.GetPath() );
474 fn.SetExt( wxT(
"csv" ) );
487 msg.Printf(
_(
"Failed to create file '%s'." ), fn.GetFullPath() );
496 msg.Printf(
_(
"Back (bottom side) placement file: '%s'." ), fn.GetFullPath() );
499 msg.Printf(
_(
"Component count: %d." ), fpcount );
505 fullcount += fpcount;
506 msg.Printf(
_(
"Full component count: %d." ), fullcount );
527 bool aOnlySMD,
bool aNoTHItems,
bool aTopSide,
528 bool aBottomSide,
bool aFormatCSV,
531 FILE * file =
nullptr;
533 if( !aFullFileName.IsEmpty() )
535 file = wxFopen( aFullFileName, wxT(
"wt" ) );
537 if( file ==
nullptr )
543 aFormatCSV, aUseAuxOrigin );
554 fputs( data.c_str(), file );
567 wxDirDialog dirDialog(
this,
_(
"Select Output Directory" ), boardFilePath );
569 if( dirDialog.ShowModal() == wxID_CANCEL )
573 fn.SetPath( dirDialog.GetPath() );
574 fn.SetExt( wxT(
"rpt" ) );
583 msg.Printf(
_(
"Footprint report file created:\n'%s'." ), fn.GetFullPath() );
584 wxMessageBox( msg,
_(
"Footprint Report" ), wxICON_INFORMATION );
589 msg.Printf(
_(
"Failed to create file '%s'." ), fn.GetFullPath() );
597 FILE* rptfile = wxFopen( aFullFilename, wxT(
"wt" ) );
599 if( rptfile ==
nullptr )
606 fputs( data.c_str(), rptfile );
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
std::string GenPositionData()
build a string filled with the position data
Classes used in place file generation.
int CreatePlaceFile(wxString &aFullFilename, PCB_LAYER_ID aLayer, bool aIncludeBrdEdges)
Create an pnp gerber file.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
This file is part of the common library.
int DoGenFootprintsPositionFile(const wxString &aFullFileName, bool aUnitsMM, bool aOnlySMD, bool aNoTHItems, bool aTopSide, bool aBottomSide, bool aFormatCSV, bool aUseAuxOrigin)
Create an ASCII footprint position file.
void SetOutputDirectory(const wxString &aDir)
int GeneratePosFile(const TOOL_EVENT &aEvent)
const wxString ExpandEnvVarSubstitutions(const wxString &aString, PROJECT *aProject)
Replace any environment variable & text variable references with their values.
A pure virtual class used to derive REPORTER objects from.
const wxString & GetFileName() const
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
bool DoGenFootprintsReport(const wxString &aFullFilename, bool aUnitsMM)
Create an ASCII footprint report file giving some infos on footprints and board outlines.
void GenFootprintsReport(wxCommandEvent &event)
Call DoGenFootprintsReport to create a footprint report file.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
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.
Definition of file extensions used in Kicad.
virtual void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings)
The ASCII format of the kicad place file is:
std::string GenReportData()
build a string filled with the pad report data This report does not used options aForceSmdItems,...
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Parameters and options when plotting/printing a board.
wxString GetOutputDirectory() const
DIALOG_PLACE_FILE m_PlaceFile
const wxString GetPlaceFileName(const wxString &aFullBaseFilename, PCB_LAYER_ID aLayer) const
Information pertinent to a Pcbnew printed circuit board.
The main frame for Pcbnew.
PCBNEW_SETTINGS * GetPcbNewSettings() const
void MsgPanelSetMinSize(const wxSize &aMinSize)
returns the reporter object that reports to this panel
const std::string FootprintPlaceFileExtension
void SetFileName(const wxString &aReportFileName)
bool ResolveTextVar(wxString *token, int aDepth) const
Used to create Gerber drill files.
static std::string GetBackSideName()
static std::string GetFrontSideName()
EDA_UNITS GetUserUnits() const
Return the user units currently in use.