53#include <fmt/format.h>
89 hole_sets.emplace_back(
F_Cu,
B_Cu );
91 for( std::vector<DRILL_LAYER_PAIR>::const_iterator it = hole_sets.begin();
92 it != hole_sets.end(); ++it )
108 fn.SetPath( aPlotDirectory );
112 wxString fullFilename = fn.GetFullPath();
114 FILE* file = wxFopen( fullFilename, wxT(
"w" ) );
116 if( file ==
nullptr )
120 msg.Printf(
_(
"Failed to create file '%s'." ), fullFilename );
131 msg.Printf(
_(
"Created file '%s'" ), fullFilename );
144 else if( doing_npth )
155 msg.Printf(
_(
"Failed to write file '%s'." ), fullFilename );
183 fmt::print(
m_file,
"{}",
"; #@! TA.AperFunction,Plated,PTH,ViaDrill\n" );
187 fmt::print(
m_file,
"{}",
"; #@! TA.AperFunction,Plated,Buried,ViaDrill\n" );
192 fmt::print(
m_file,
"{}",
"; #@! TA.AperFunction,Plated,PTH,ComponentDrill\n" );
196 fmt::print(
m_file,
"{}",
"; #@! TA.AperFunction,Plated,PTH,CastelletedDrill\n" );
200 fmt::print(
m_file,
"{}",
"; #@! TA.AperFunction,Plated,PTH,ComponentDrill,PressFit\n" );
204 fmt::print(
m_file,
"{}",
"; #@! TA.AperFunction,NonPlated,NPTH,ComponentDrill\n" );
208 fmt::print(
m_file,
"{}",
"; #@! TD\n" );
224 int diam, holes_count;
225 int x0, y0, xf, yf, xc, yc;
238#if USE_ATTRIB_FOR_HOLES
244 fmt::print(
m_file,
"{}",
"%\n" );
245 fmt::print(
m_file,
"{}",
"G90\n" );
246 fmt::print(
m_file,
"{}",
"G05\n" );
250 int tool_reference = -2;
262 fmt::print(
m_file,
"T{}\n", tool_reference );
275 fmt::print(
m_file,
"{}", line );
294 fmt::print(
m_file,
"T{}\n", tool_reference );
333 fmt::print(
m_file,
"{}",
"G00" );
341 for(
int kk = 0; line[kk] != 0; kk++ )
347 fmt::print(
m_file,
"{}", line );
348 fmt::print(
m_file,
"{}",
"G85" );
352 fmt::print(
m_file,
"{}", line );
353 fmt::print(
m_file,
"{}",
"M15\nG01" );
360 fmt::print(
m_file,
"{}",line );
363 fmt::print(
m_file,
"{}",
"M16\n" );
365 fmt::print(
m_file,
"{}",
"G05\n" );
389 if( aLeftDigits <= 0 )
392 if( aRightDigits <= 0 )
426 while( xs.Last() ==
'0' )
429 if( xs.Last() ==
'.' )
432 while( ys.Last() ==
'0' )
435 if( ys.Last() ==
'.' )
438 std::snprintf( aLine, aLineSize,
"X%sY%s\n",
TO_UTF8( xs ),
TO_UTF8( ys ) );
444 aCoordX *= 10; aCoordY *= 10;
447 std::snprintf( aLine, aLineSize,
"X%dY%d\n",
KiROUND( aCoordX ),
KiROUND( aCoordY ) );
464 xs.Printf( wxT(
"%0*d" ), xpad,
KiROUND( aCoordX ) );
465 ys.Printf( wxT(
"%0*d" ), ypad,
KiROUND( aCoordY ) );
467 size_t j = xs.Len() - 1;
469 while( xs[j] ==
'0' && j )
474 while( ys[j] ==
'0' && j )
477 std::snprintf( aLine, aLineSize,
"X%sY%s\n",
TO_UTF8( xs ),
TO_UTF8( ys ) );
484 aCoordX *= 10; aCoordY *= 10;
493 xs.Printf( wxT(
"%0*d" ), xpad,
KiROUND( aCoordX ) );
494 ys.Printf( wxT(
"%0*d" ), ypad,
KiROUND( aCoordY ) );
495 std::snprintf( aLine, aLineSize,
"X%sY%s\n",
TO_UTF8( xs ),
TO_UTF8( ys ) );
503 fmt::print(
m_file,
"{}",
"M48\n" );
511 fmt::print(
m_file,
"; DRILL file {} date {}\n",
513 msg = wxT(
"; FORMAT={" );
523 msg << wxT(
"/ absolute / " );
535 const wxString zero_fmt[4] =
538 wxT(
"suppress leading zeros" ),
539 wxT(
"suppress trailing zeros" ),
552 msg = wxT(
"; #@! TF.GenerationSoftware,Kicad,Pcbnew," );
561 fmt::print(
m_file,
"{}",
"FMAT,2\n" );
569 fmt::print(
m_file,
"{}",
"\n" );
573 fmt::print(
m_file,
"{}",
",TZ\n" );
577 fmt::print(
m_file,
"{}",
",LZ\n" );
582 fmt::print(
m_file,
"{}",
"\n" );
591 fmt::print(
m_file,
"{}",
"M30\n" );
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
wxString GetBuildVersion()
Get the full KiCad version string.
Information pertinent to a Pcbnew printed circuit board.
void SetFormat(bool aMetric, ZEROS_FMT aZerosFmt=DECIMAL_FORMAT, int aLeftDigits=0, int aRightDigits=0)
Initialize internal parameters to match the given format.
bool m_useRouteModeForOval
void writeCoordinates(char *aLine, size_t aLineSize, double aCoordX, double aCoordY)
Create a line like according to the selected format.
void writeEXCELLONHeader(DRILL_LAYER_PAIR aLayerPair, TYPE_FILE aHolesType)
Print the DRILL file header.
void writeHoleAttribute(HOLE_ATTRIBUTE aAttribute)
Write a comment string giving the hole attribute.
bool CreateDrillandMapFilesSet(const wxString &aPlotDirectory, bool aGenDrill, bool aGenMap, REPORTER *aReporter=nullptr)
Create the full set of Excellon drill file for the board.
EXCELLON_WRITER(BOARD *aPcb)
int createDrillFile(FILE *aFile, DRILL_LAYER_PAIR aLayerPair, TYPE_FILE aHolesType)
Create an Excellon drill file.
void writeEXCELLONEndOfFile()
std::vector< DRILL_LAYER_PAIR > getUniqueLayerPairs() const
Get unique layer pairs by examining the micro and blind_buried vias.
virtual const wxString getDrillFileName(DRILL_LAYER_PAIR aPair, bool aNPTH, bool aMerge_PTH_NPTH) const
void buildHolesList(DRILL_LAYER_PAIR aLayerPair, bool aGenerateNPTH_list)
Create the list of holes and tools for a given board.
const wxString BuildFileFunctionAttributeString(DRILL_LAYER_PAIR aLayerPair, TYPE_FILE aHoleType, bool aCompatNCdrill=false) const
wxString m_drillFileExtension
std::vector< HOLE_INFO > m_holeListBuffer
DRILL_PRECISION m_precision
GENDRILL_WRITER_BASE(BOARD *aPcb)
std::vector< DRILL_TOOL > m_toolListBuffer
bool CreateMapFilesSet(const wxString &aPlotDirectory, REPORTER *aReporter=nullptr)
Create the full set of map files for the board, in PS, PDF ... format (use SetMapFileFormat() to sele...
int getHolesCount() const
Handle hole which must be drilled (diameter, position and layers).
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.
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the end of the list, for objects that support report ordering.
Classes used in drill files, map files and report files generation.
std::pair< PCB_LAYER_ID, PCB_LAYER_ID > DRILL_LAYER_PAIR
static const std::string DrillFileExtension
This file contains miscellaneous commonly used macros and functions.
wxString GetISO8601CurrentDateTime()
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition of file extensions used in Kicad.