2010-11-24 19:54:59 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2010-11-24 19:54:59 +00:00
|
|
|
*
|
2018-09-22 12:00:22 +00:00
|
|
|
* Copyright (C) 2018 Jean_Pierre Charras <jp.charras at wanadoo.fr>
|
2015-12-14 08:00:49 +00:00
|
|
|
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2021-03-07 16:47:37 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2010-11-24 19:54:59 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2017-04-28 10:53:30 +00:00
|
|
|
/**
|
|
|
|
* @file gendrill_Excellon_writer.cpp
|
|
|
|
* @brief Functions to create EXCELLON drill files and report files.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
/**
|
2010-12-14 15:56:30 +00:00
|
|
|
* @see for EXCELLON format, see:
|
2010-11-29 15:05:01 +00:00
|
|
|
* http://www.excellon.com/manuals/program.htm
|
2010-11-24 15:10:33 +00:00
|
|
|
* and the CNC-7 manual.
|
|
|
|
*/
|
|
|
|
|
2021-08-18 20:38:14 +00:00
|
|
|
#include <plotters/plotter.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2020-10-24 01:38:50 +00:00
|
|
|
#include <locale_io.h>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <macros.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <build_version.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <math/util.h> // for KiROUND
|
2020-10-14 03:37:48 +00:00
|
|
|
#include <trigo.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbplot.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2012-10-05 12:25:12 +00:00
|
|
|
#include <gendrill_Excellon_writer.h>
|
2012-02-16 20:03:33 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2015-04-29 15:37:37 +00:00
|
|
|
#include <reporter.h>
|
2018-11-21 14:33:17 +00:00
|
|
|
#include <gbr_metadata.h>
|
2015-10-23 14:30:22 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2018-09-22 12:00:22 +00:00
|
|
|
// Oblong holes can be drilled by a "canned slot" command (G85) or a routing command
|
|
|
|
// a linear routing command (G01) is perhaps more usual for drill files
|
2019-02-09 13:56:02 +00:00
|
|
|
//
|
|
|
|
// set m_useRouteModeForOval to false to use a canned slot hole (old way)
|
2021-06-09 19:32:58 +00:00
|
|
|
// set m_useRouteModeForOval to true (preferred mode) to use a linear routed hole (new way)
|
2015-04-29 15:37:37 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2015-04-29 15:37:37 +00:00
|
|
|
EXCELLON_WRITER::EXCELLON_WRITER( BOARD* aPcb )
|
2017-04-28 10:53:30 +00:00
|
|
|
: GENDRILL_WRITER_BASE( aPcb )
|
2015-04-29 15:37:37 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
m_file = nullptr;
|
2015-04-29 15:37:37 +00:00
|
|
|
m_zeroFormat = DECIMAL_FORMAT;
|
|
|
|
m_conversionUnits = 0.0001;
|
|
|
|
m_mirror = false;
|
2015-11-16 18:42:58 +00:00
|
|
|
m_merge_PTH_NPTH = false;
|
2015-04-29 15:37:37 +00:00
|
|
|
m_minimalHeader = false;
|
2017-04-28 10:53:30 +00:00
|
|
|
m_drillFileExtension = DrillFileExtension;
|
2019-02-09 13:56:02 +00:00
|
|
|
m_useRouteModeForOval = true;
|
2015-04-29 15:37:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-27 16:39:09 +00:00
|
|
|
void EXCELLON_WRITER::CreateDrillandMapFilesSet( const wxString& aPlotDirectory, bool aGenDrill,
|
|
|
|
bool aGenMap, REPORTER * aReporter )
|
2015-04-29 15:37:37 +00:00
|
|
|
{
|
2015-10-23 14:30:22 +00:00
|
|
|
wxFileName fn;
|
|
|
|
wxString msg;
|
2015-04-29 15:37:37 +00:00
|
|
|
|
2017-01-10 19:12:50 +00:00
|
|
|
std::vector<DRILL_LAYER_PAIR> hole_sets = getUniqueLayerPairs();
|
2015-04-29 15:37:37 +00:00
|
|
|
|
2015-11-16 18:42:58 +00:00
|
|
|
// append a pair representing the NPTH set of holes, for separate drill files.
|
|
|
|
if( !m_merge_PTH_NPTH )
|
2019-12-05 15:41:21 +00:00
|
|
|
hole_sets.emplace_back( F_Cu, B_Cu );
|
2015-04-29 15:37:37 +00:00
|
|
|
|
2017-01-10 19:12:50 +00:00
|
|
|
for( std::vector<DRILL_LAYER_PAIR>::const_iterator it = hole_sets.begin();
|
2016-10-07 14:57:45 +00:00
|
|
|
it != hole_sets.end(); ++it )
|
2015-04-29 15:37:37 +00:00
|
|
|
{
|
2017-01-10 19:12:50 +00:00
|
|
|
DRILL_LAYER_PAIR pair = *it;
|
2016-10-07 14:57:45 +00:00
|
|
|
// For separate drill files, the last layer pair is the NPTH drill file.
|
2015-11-16 18:42:58 +00:00
|
|
|
bool doing_npth = m_merge_PTH_NPTH ? false : ( it == hole_sets.end() - 1 );
|
2015-04-29 15:37:37 +00:00
|
|
|
|
2017-01-15 15:35:47 +00:00
|
|
|
buildHolesList( pair, doing_npth );
|
2015-04-29 15:37:37 +00:00
|
|
|
|
2021-06-27 16:39:09 +00:00
|
|
|
// The file is created if it has holes, or if it is the non plated drill file to be
|
|
|
|
// sure the NPTH file is up to date in separate files mode.
|
|
|
|
// Also a PTH drill/map file is always created, to be sure at least one plated hole
|
|
|
|
// drill file is created (do not create any PTH drill file can be seen as not working
|
|
|
|
// drill generator).
|
2020-09-10 14:42:04 +00:00
|
|
|
if( getHolesCount() > 0 || doing_npth || pair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
|
2015-04-29 15:37:37 +00:00
|
|
|
{
|
2017-04-28 10:53:30 +00:00
|
|
|
fn = getDrillFileName( pair, doing_npth, m_merge_PTH_NPTH );
|
2015-04-29 15:37:37 +00:00
|
|
|
fn.SetPath( aPlotDirectory );
|
|
|
|
|
|
|
|
if( aGenDrill )
|
|
|
|
{
|
|
|
|
wxString fullFilename = fn.GetFullPath();
|
|
|
|
|
|
|
|
FILE* file = wxFopen( fullFilename, wxT( "w" ) );
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( file == nullptr )
|
2015-04-29 15:37:37 +00:00
|
|
|
{
|
|
|
|
if( aReporter )
|
|
|
|
{
|
2021-07-05 12:40:38 +00:00
|
|
|
msg.Printf( _( "Failed to create file '%s'." ), fullFilename );
|
|
|
|
aReporter->Report( msg, RPT_SEVERITY_ERROR );
|
2015-04-29 15:37:37 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2015-04-29 15:37:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( aReporter )
|
|
|
|
{
|
2021-06-28 23:44:07 +00:00
|
|
|
msg.Printf( _( "Created file '%s'" ), fullFilename );
|
2021-09-19 18:25:41 +00:00
|
|
|
aReporter->Report( msg, RPT_SEVERITY_ACTION );
|
2015-04-29 15:37:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-14 11:38:03 +00:00
|
|
|
TYPE_FILE file_type = TYPE_FILE::PTH_FILE;
|
|
|
|
|
|
|
|
// Only external layer pair can have non plated hole
|
|
|
|
// internal layers have only plated via holes
|
|
|
|
if( pair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
|
|
|
|
{
|
|
|
|
if( m_merge_PTH_NPTH )
|
|
|
|
file_type = TYPE_FILE::MIXED_FILE;
|
|
|
|
else if( doing_npth )
|
|
|
|
file_type = TYPE_FILE::NPTH_FILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
createDrillFile( file, pair, file_type );
|
2015-04-29 15:37:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-28 10:53:30 +00:00
|
|
|
|
|
|
|
if( aGenMap )
|
|
|
|
CreateMapFilesSet( aPlotDirectory, aReporter );
|
2021-09-19 18:25:41 +00:00
|
|
|
|
2021-09-20 07:13:51 +00:00
|
|
|
if( aReporter )
|
|
|
|
aReporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
|
2015-04-29 15:37:37 +00:00
|
|
|
}
|
2010-04-30 18:39:10 +00:00
|
|
|
|
2010-01-05 08:48:49 +00:00
|
|
|
|
2021-03-26 08:46:32 +00:00
|
|
|
void EXCELLON_WRITER::writeHoleAttribute( HOLE_ATTRIBUTE aAttribute )
|
2021-03-07 16:47:37 +00:00
|
|
|
{
|
|
|
|
// Hole attributes are comments (lines starting by ';') in the drill files
|
|
|
|
// For tools (file header), they are similar to X2 apertures attributes.
|
|
|
|
// for attributes added in coordinate list, they are just comments.
|
|
|
|
if( !m_minimalHeader )
|
|
|
|
{
|
|
|
|
switch( aAttribute )
|
|
|
|
{
|
2021-03-31 12:00:25 +00:00
|
|
|
case HOLE_ATTRIBUTE::HOLE_VIA_THROUGH:
|
|
|
|
fprintf( m_file, "; #@! TA.AperFunction,Plated,PTH,ViaDrill\n" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HOLE_ATTRIBUTE::HOLE_VIA_BURIED:
|
|
|
|
fprintf( m_file, "; #@! TA.AperFunction,Plated,Buried,ViaDrill\n" );
|
2021-03-07 16:47:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HOLE_ATTRIBUTE::HOLE_PAD:
|
2021-03-31 12:00:25 +00:00
|
|
|
fprintf( m_file, "; #@! TA.AperFunction,Plated,PTH,ComponentDrill\n" );
|
2021-03-07 16:47:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HOLE_ATTRIBUTE::HOLE_MECHANICAL:
|
2021-03-31 12:00:25 +00:00
|
|
|
fprintf( m_file, "; #@! TA.AperFunction,NonPlated,NPTH,ComponentDrill\n" );
|
2021-03-07 16:47:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HOLE_ATTRIBUTE::HOLE_UNKNOWN:
|
2021-03-26 08:46:32 +00:00
|
|
|
fprintf( m_file, "; #@! TD\n" );
|
2021-03-07 16:47:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-21 14:33:17 +00:00
|
|
|
int EXCELLON_WRITER::createDrillFile( FILE* aFile, DRILL_LAYER_PAIR aLayerPair,
|
2021-03-14 11:38:03 +00:00
|
|
|
TYPE_FILE aHolesType )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-10-05 12:25:12 +00:00
|
|
|
m_file = aFile;
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
int diam, holes_count;
|
|
|
|
int x0, y0, xf, yf, xc, yc;
|
2010-11-24 15:10:33 +00:00
|
|
|
double xt, yt;
|
2011-08-19 13:08:24 +00:00
|
|
|
char line[1024];
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2015-04-29 15:37:37 +00:00
|
|
|
LOCALE_IO dummy; // Use the standard notation for double numbers
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2021-03-14 11:38:03 +00:00
|
|
|
writeEXCELLONHeader( aLayerPair, aHolesType );
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
holes_count = 0;
|
2010-11-24 19:54:59 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
/* Write the tool list */
|
2012-10-05 12:25:12 +00:00
|
|
|
for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2012-10-05 12:25:12 +00:00
|
|
|
DRILL_TOOL& tool_descr = m_toolListBuffer[ii];
|
2015-11-16 18:42:58 +00:00
|
|
|
|
2021-03-07 16:47:37 +00:00
|
|
|
#if USE_ATTRIB_FOR_HOLES
|
2021-03-26 08:46:32 +00:00
|
|
|
writeHoleAttribute( tool_descr.m_HoleAttribute );
|
2015-11-16 18:42:58 +00:00
|
|
|
#endif
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-03-07 16:47:37 +00:00
|
|
|
// if units are mm, the resolution is 0.001 mm (3 digits in mantissa)
|
|
|
|
// if units are inches, the resolution is 0.1 mil (4 digits in mantissa)
|
|
|
|
if( m_unitsMetric )
|
2017-12-20 16:48:53 +00:00
|
|
|
fprintf( m_file, "T%dC%.3f\n", ii + 1, tool_descr.m_Diameter * m_conversionUnits );
|
2021-03-07 16:47:37 +00:00
|
|
|
else
|
2017-12-20 16:48:53 +00:00
|
|
|
fprintf( m_file, "T%dC%.4f\n", ii + 1, tool_descr.m_Diameter * m_conversionUnits );
|
2008-01-18 08:54:15 +00:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
fputs( "%\n", m_file ); // End of header info
|
|
|
|
fputs( "G90\n", m_file ); // Absolute mode
|
|
|
|
fputs( "G05\n", m_file ); // Drill mode
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2021-03-07 16:47:37 +00:00
|
|
|
/* Read the hole list and generate data for normal holes (oblong
|
2009-11-14 22:15:22 +00:00
|
|
|
* holes will be created later) */
|
2010-11-24 15:10:33 +00:00
|
|
|
int tool_reference = -2;
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
|
2008-01-18 08:54:15 +00:00
|
|
|
{
|
2012-10-05 12:25:12 +00:00
|
|
|
HOLE_INFO& hole_descr = m_holeListBuffer[ii];
|
2010-11-24 19:54:59 +00:00
|
|
|
|
|
|
|
if( hole_descr.m_Hole_Shape )
|
2010-11-24 15:10:33 +00:00
|
|
|
continue; // oblong holes will be created later
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
if( tool_reference != hole_descr.m_Tool_Reference )
|
2008-01-18 08:54:15 +00:00
|
|
|
{
|
2010-11-24 19:54:59 +00:00
|
|
|
tool_reference = hole_descr.m_Tool_Reference;
|
|
|
|
fprintf( m_file, "T%d\n", tool_reference );
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
x0 = hole_descr.m_Hole_Pos.x - m_offset.x;
|
|
|
|
y0 = hole_descr.m_Hole_Pos.y - m_offset.y;
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
if( !m_mirror )
|
2008-01-18 08:54:15 +00:00
|
|
|
y0 *= -1;
|
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
xt = x0 * m_conversionUnits;
|
|
|
|
yt = y0 * m_conversionUnits;
|
2017-01-15 15:35:47 +00:00
|
|
|
writeCoordinates( line, xt, yt );
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( line, m_file );
|
2008-01-18 08:54:15 +00:00
|
|
|
holes_count++;
|
|
|
|
}
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2021-03-07 16:47:37 +00:00
|
|
|
/* Read the hole list and generate data for oblong holes
|
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
tool_reference = -2; // set to a value not used for
|
2012-10-05 12:25:12 +00:00
|
|
|
// m_holeListBuffer[ii].m_Tool_Reference
|
2021-03-07 16:47:37 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
|
2008-01-18 08:54:15 +00:00
|
|
|
{
|
2012-10-05 12:25:12 +00:00
|
|
|
HOLE_INFO& hole_descr = m_holeListBuffer[ii];
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
if( hole_descr.m_Hole_Shape == 0 )
|
2010-11-24 15:10:33 +00:00
|
|
|
continue; // wait for oblong holes
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
if( tool_reference != hole_descr.m_Tool_Reference )
|
2008-01-18 08:54:15 +00:00
|
|
|
{
|
2010-11-24 19:54:59 +00:00
|
|
|
tool_reference = hole_descr.m_Tool_Reference;
|
|
|
|
fprintf( m_file, "T%d\n", tool_reference );
|
2008-01-16 20:37:50 +00:00
|
|
|
}
|
|
|
|
|
2014-03-06 18:38:39 +00:00
|
|
|
diam = std::min( hole_descr.m_Hole_Size.x, hole_descr.m_Hole_Size.y );
|
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
if( diam == 0 )
|
|
|
|
continue;
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
/* Compute the hole coordinates: */
|
2011-08-19 13:08:24 +00:00
|
|
|
xc = x0 = xf = hole_descr.m_Hole_Pos.x - m_offset.x;
|
|
|
|
yc = y0 = yf = hole_descr.m_Hole_Pos.y - m_offset.y;
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2008-01-18 08:54:15 +00:00
|
|
|
/* Compute the start and end coordinates for the shape */
|
2011-08-19 13:08:24 +00:00
|
|
|
if( hole_descr.m_Hole_Size.x < hole_descr.m_Hole_Size.y )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
int delta = ( hole_descr.m_Hole_Size.y - hole_descr.m_Hole_Size.x ) / 2;
|
2014-03-06 18:38:39 +00:00
|
|
|
y0 -= delta;
|
|
|
|
yf += delta;
|
2008-01-18 08:54:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
int delta = ( hole_descr.m_Hole_Size.x - hole_descr.m_Hole_Size.y ) / 2;
|
2014-03-06 18:38:39 +00:00
|
|
|
x0 -= delta;
|
|
|
|
xf += delta;
|
2008-01-18 08:54:15 +00:00
|
|
|
}
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
RotatePoint( &x0, &y0, xc, yc, hole_descr.m_Hole_Orient );
|
|
|
|
RotatePoint( &xf, &yf, xc, yc, hole_descr.m_Hole_Orient );
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
if( !m_mirror )
|
2008-01-18 08:54:15 +00:00
|
|
|
{
|
2014-03-06 18:38:39 +00:00
|
|
|
y0 *= -1;
|
|
|
|
yf *= -1;
|
2008-01-18 08:54:15 +00:00
|
|
|
}
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
xt = x0 * m_conversionUnits;
|
|
|
|
yt = y0 * m_conversionUnits;
|
2019-02-09 13:56:02 +00:00
|
|
|
|
|
|
|
if( m_useRouteModeForOval )
|
|
|
|
fputs( "G00", m_file ); // Select the routing mode
|
|
|
|
|
2017-01-15 15:35:47 +00:00
|
|
|
writeCoordinates( line, xt, yt );
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2019-02-09 13:56:02 +00:00
|
|
|
if( !m_useRouteModeForOval )
|
2014-03-06 18:38:39 +00:00
|
|
|
{
|
2019-02-09 13:56:02 +00:00
|
|
|
/* remove the '\n' from end of line, because we must add the "G85"
|
|
|
|
* command to the line: */
|
|
|
|
for( int kk = 0; line[kk] != 0; kk++ )
|
|
|
|
{
|
|
|
|
if( line[kk] < ' ' )
|
|
|
|
line[kk] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs( line, m_file );
|
|
|
|
fputs( "G85", m_file ); // add the "G85" command
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fputs( line, m_file );
|
|
|
|
fputs( "M15\nG01", m_file ); // tool down and linear routing from last coordinates
|
2014-03-06 18:38:39 +00:00
|
|
|
}
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
xt = xf * m_conversionUnits;
|
|
|
|
yt = yf * m_conversionUnits;
|
2017-01-15 15:35:47 +00:00
|
|
|
writeCoordinates( line, xt, yt );
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( line, m_file );
|
2019-02-09 13:56:02 +00:00
|
|
|
|
|
|
|
if( m_useRouteModeForOval )
|
|
|
|
fputs( "M16\n", m_file ); // Tool up (end routing)
|
|
|
|
|
|
|
|
fputs( "G05\n", m_file ); // Select drill mode
|
2008-01-18 08:54:15 +00:00
|
|
|
holes_count++;
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2017-01-15 15:35:47 +00:00
|
|
|
writeEXCELLONEndOfFile();
|
2008-01-18 08:54:15 +00:00
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
return holes_count;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void EXCELLON_WRITER::SetFormat( bool aMetric, ZEROS_FMT aZerosFmt, int aLeftDigits,
|
|
|
|
int aRightDigits )
|
2010-11-24 19:54:59 +00:00
|
|
|
{
|
2017-12-20 16:48:53 +00:00
|
|
|
m_unitsMetric = aMetric;
|
2011-08-19 13:08:24 +00:00
|
|
|
m_zeroFormat = aZerosFmt;
|
2010-11-24 19:54:59 +00:00
|
|
|
|
|
|
|
/* Set conversion scale depending on drill file units */
|
2017-12-20 16:48:53 +00:00
|
|
|
if( m_unitsMetric )
|
2015-04-29 15:37:37 +00:00
|
|
|
m_conversionUnits = 1.0 / IU_PER_MM; // EXCELLON units = mm
|
2010-11-24 19:54:59 +00:00
|
|
|
else
|
2015-04-29 15:37:37 +00:00
|
|
|
m_conversionUnits = 0.001 / IU_PER_MILS; // EXCELLON units = INCHES
|
|
|
|
|
|
|
|
// Set the zero counts. if aZerosFmt == DECIMAL_FORMAT, these values
|
|
|
|
// will be set, but not used.
|
|
|
|
if( aLeftDigits <= 0 )
|
2017-12-20 16:48:53 +00:00
|
|
|
aLeftDigits = m_unitsMetric ? 3 : 2;
|
2015-04-29 15:37:37 +00:00
|
|
|
|
|
|
|
if( aRightDigits <= 0 )
|
2017-12-20 16:48:53 +00:00
|
|
|
aRightDigits = m_unitsMetric ? 3 : 4;
|
2010-11-24 19:54:59 +00:00
|
|
|
|
2020-11-16 00:04:55 +00:00
|
|
|
m_precision.m_Lhs = aLeftDigits;
|
|
|
|
m_precision.m_Rhs = aRightDigits;
|
2010-11-24 19:54:59 +00:00
|
|
|
}
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2017-01-15 15:35:47 +00:00
|
|
|
void EXCELLON_WRITER::writeCoordinates( char* aLine, double aCoordX, double aCoordY )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-29 13:31:10 +00:00
|
|
|
wxString xs, ys;
|
2020-11-16 00:04:55 +00:00
|
|
|
int xpad = m_precision.m_Lhs + m_precision.m_Rhs;
|
2007-09-29 13:31:10 +00:00
|
|
|
int ypad = xpad;
|
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
switch( m_zeroFormat )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case DECIMAL_FORMAT:
|
2012-07-03 13:46:58 +00:00
|
|
|
/* In Excellon files, resolution is 1/1000 mm or 1/10000 inch (0.1 mil)
|
|
|
|
* Although in decimal format, Excellon specifications do not specify
|
|
|
|
* clearly the resolution. However it seems to be 1/1000mm or 0.1 mil
|
|
|
|
* like in non decimal formats, so we trunk coordinates to 3 or 4 digits in mantissa
|
|
|
|
* Decimal format just prohibit useless leading 0:
|
|
|
|
* 0.45 or .45 is right, but 00.54 is incorrect.
|
|
|
|
*/
|
2017-12-20 16:48:53 +00:00
|
|
|
if( m_unitsMetric )
|
2012-07-03 13:46:58 +00:00
|
|
|
{
|
|
|
|
// resolution is 1/1000 mm
|
|
|
|
xs.Printf( wxT( "%.3f" ), aCoordX );
|
|
|
|
ys.Printf( wxT( "%.3f" ), aCoordY );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// resolution is 1/10000 inch
|
|
|
|
xs.Printf( wxT( "%.4f" ), aCoordX );
|
|
|
|
ys.Printf( wxT( "%.4f" ), aCoordY );
|
|
|
|
}
|
|
|
|
|
|
|
|
//Remove useless trailing 0
|
|
|
|
while( xs.Last() == '0' )
|
|
|
|
xs.RemoveLast();
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2018-09-24 11:49:46 +00:00
|
|
|
if( xs.Last() == '.' ) // however keep a trailing 0 after the floating point separator
|
|
|
|
xs << '0';
|
|
|
|
|
2012-07-03 13:46:58 +00:00
|
|
|
while( ys.Last() == '0' )
|
|
|
|
ys.RemoveLast();
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2018-09-24 11:49:46 +00:00
|
|
|
if( ys.Last() == '.' )
|
|
|
|
ys << '0';
|
|
|
|
|
2012-07-03 13:46:58 +00:00
|
|
|
sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
|
2012-07-03 13:46:58 +00:00
|
|
|
case SUPPRESS_LEADING:
|
2020-11-16 00:04:55 +00:00
|
|
|
for( int i = 0; i< m_precision.m_Rhs; i++ )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2010-11-24 15:10:33 +00:00
|
|
|
aCoordX *= 10; aCoordY *= 10;
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
sprintf( aLine, "X%dY%d\n", KiROUND( aCoordX ), KiROUND( aCoordY ) );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SUPPRESS_TRAILING:
|
|
|
|
{
|
2020-11-16 00:04:55 +00:00
|
|
|
for( int i = 0; i < m_precision.m_Rhs; i++ )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2010-11-24 15:10:33 +00:00
|
|
|
aCoordX *= 10;
|
|
|
|
aCoordY *= 10;
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aCoordX < 0 )
|
2007-09-29 13:31:10 +00:00
|
|
|
xpad++;
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aCoordY < 0 )
|
2007-09-29 13:31:10 +00:00
|
|
|
ypad++;
|
|
|
|
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
xs.Printf( wxT( "%0*d" ), xpad, KiROUND( aCoordX ) );
|
|
|
|
ys.Printf( wxT( "%0*d" ), ypad, KiROUND( aCoordY ) );
|
2007-09-29 13:31:10 +00:00
|
|
|
|
|
|
|
size_t j = xs.Len() - 1;
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2007-09-29 13:31:10 +00:00
|
|
|
while( xs[j] == '0' && j )
|
|
|
|
xs.Truncate( j-- );
|
|
|
|
|
|
|
|
j = ys.Len() - 1;
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2007-09-29 13:31:10 +00:00
|
|
|
while( ys[j] == '0' && j )
|
|
|
|
ys.Truncate( j-- );
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case KEEP_ZEROS:
|
2020-11-16 00:04:55 +00:00
|
|
|
for( int i = 0; i< m_precision.m_Rhs; i++ )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2010-11-24 15:10:33 +00:00
|
|
|
aCoordX *= 10; aCoordY *= 10;
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aCoordX < 0 )
|
2007-09-29 13:31:10 +00:00
|
|
|
xpad++;
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
if( aCoordY < 0 )
|
2007-09-29 13:31:10 +00:00
|
|
|
ypad++;
|
2014-03-06 18:38:39 +00:00
|
|
|
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
xs.Printf( wxT( "%0*d" ), xpad, KiROUND( aCoordX ) );
|
|
|
|
ys.Printf( wxT( "%0*d" ), ypad, KiROUND( aCoordY ) );
|
2011-02-28 18:36:19 +00:00
|
|
|
sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void EXCELLON_WRITER::writeEXCELLONHeader( DRILL_LAYER_PAIR aLayerPair, TYPE_FILE aHolesType )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( "M48\n", m_file ); // The beginning of a header
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
if( !m_minimalHeader )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
2018-11-21 14:33:17 +00:00
|
|
|
// The next lines in EXCELLON files are comments:
|
2015-04-29 15:37:37 +00:00
|
|
|
wxString msg;
|
2022-02-05 02:06:25 +00:00
|
|
|
msg << wxT( "KiCad " ) << GetBuildVersion();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
2018-11-21 14:33:17 +00:00
|
|
|
fprintf( m_file, "; DRILL file {%s} date %s\n", TO_UTF8( msg ), TO_UTF8( DateAndTime() ) );
|
2022-02-05 02:06:25 +00:00
|
|
|
msg = wxT( "; FORMAT={" );
|
2009-10-21 19:16:25 +00:00
|
|
|
|
2008-08-26 06:00:27 +00:00
|
|
|
// Print precision:
|
2018-09-24 11:49:46 +00:00
|
|
|
// Note in decimal format the precision is not used.
|
|
|
|
// the floating point notation has higher priority than the precision.
|
2010-11-24 19:54:59 +00:00
|
|
|
if( m_zeroFormat != DECIMAL_FORMAT )
|
|
|
|
msg << m_precision.GetPrecisionString();
|
2008-08-26 06:00:27 +00:00
|
|
|
else
|
2022-02-05 02:06:25 +00:00
|
|
|
msg << wxT( "-:-" ); // in decimal format the precision is irrelevant
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2022-02-05 02:06:25 +00:00
|
|
|
msg << wxT( "/ absolute / " );
|
|
|
|
msg << ( m_unitsMetric ? wxT( "metric" ) : wxT( "inch" ) );
|
2008-08-26 06:00:27 +00:00
|
|
|
|
|
|
|
/* Adding numbers notation format.
|
|
|
|
* this is same as m_Choice_Zeros_Format strings, but NOT translated
|
2014-03-06 18:38:39 +00:00
|
|
|
* because some EXCELLON parsers do not like non ASCII values
|
|
|
|
* so we use ONLY English (ASCII) strings.
|
2009-11-14 22:15:22 +00:00
|
|
|
* if new options are added in m_Choice_Zeros_Format, they must also
|
|
|
|
* be added here
|
2008-08-26 06:00:27 +00:00
|
|
|
*/
|
|
|
|
msg << wxT( " / " );
|
2011-11-08 16:37:25 +00:00
|
|
|
|
2010-11-24 15:10:33 +00:00
|
|
|
const wxString zero_fmt[4] =
|
2008-08-26 06:00:27 +00:00
|
|
|
{
|
2022-02-05 02:06:25 +00:00
|
|
|
wxT( "decimal" ),
|
|
|
|
wxT( "suppress leading zeros" ),
|
|
|
|
wxT( "suppress trailing zeros" ),
|
|
|
|
wxT( "keep zeros" )
|
2008-08-26 06:00:27 +00:00
|
|
|
};
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2022-02-05 02:06:25 +00:00
|
|
|
msg << zero_fmt[m_zeroFormat] << wxT( "}\n" );
|
2011-02-28 18:36:19 +00:00
|
|
|
fputs( TO_UTF8( msg ), m_file );
|
2018-11-21 14:33:17 +00:00
|
|
|
|
|
|
|
// add the structured comment TF.CreationDate:
|
|
|
|
// The attribute value must conform to the full version of the ISO 8601
|
2022-02-05 02:06:25 +00:00
|
|
|
msg = GbrMakeCreationDateAttributeString( GBR_NC_STRING_FORMAT_NCDRILL ) + wxT( "\n" );
|
2018-11-21 14:33:17 +00:00
|
|
|
fputs( TO_UTF8( msg ), m_file );
|
|
|
|
|
|
|
|
// Add the application name that created the drill file
|
2022-02-05 02:06:25 +00:00
|
|
|
msg = wxT( "; #@! TF.GenerationSoftware,Kicad,Pcbnew," );
|
|
|
|
msg << GetBuildVersion() << wxT( "\n" );
|
2018-11-21 14:33:17 +00:00
|
|
|
fputs( TO_UTF8( msg ), m_file );
|
|
|
|
|
2021-03-14 11:38:03 +00:00
|
|
|
// Add the standard X2 FileFunction for drill files
|
|
|
|
// TF.FileFunction,Plated[NonPlated],layer1num,layer2num,PTH[NPTH]
|
2022-02-05 02:06:25 +00:00
|
|
|
msg = BuildFileFunctionAttributeString( aLayerPair, aHolesType , true ) + wxT( "\n" );
|
2021-03-14 11:38:03 +00:00
|
|
|
fputs( TO_UTF8( msg ), m_file );
|
2018-11-21 14:33:17 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( "FMAT,2\n", m_file ); // Use Format 2 commands (version used since 1979)
|
2007-09-29 13:31:10 +00:00
|
|
|
}
|
|
|
|
|
2017-12-20 16:48:53 +00:00
|
|
|
fputs( m_unitsMetric ? "METRIC" : "INCH", m_file );
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
switch( m_zeroFormat )
|
2007-09-29 13:31:10 +00:00
|
|
|
{
|
|
|
|
case DECIMAL_FORMAT:
|
2018-09-24 11:49:46 +00:00
|
|
|
fputs( "\n", m_file );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SUPPRESS_LEADING:
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( ",TZ\n", m_file );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SUPPRESS_TRAILING:
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( ",LZ\n", m_file );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KEEP_ZEROS:
|
2018-09-24 11:49:46 +00:00
|
|
|
// write nothing, but TZ is acceptable when all zeros are kept
|
|
|
|
fputs( "\n", m_file );
|
2007-09-29 13:31:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-29 13:31:10 +00:00
|
|
|
|
2017-01-15 15:35:47 +00:00
|
|
|
void EXCELLON_WRITER::writeEXCELLONEndOfFile()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
// add if minimal here
|
2010-11-24 19:54:59 +00:00
|
|
|
fputs( "T0\nM30\n", m_file );
|
|
|
|
fclose( m_file );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|