2010-11-26 11:55:34 +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-26 11:55:34 +00:00
|
|
|
*
|
2017-01-15 15:35:47 +00:00
|
|
|
* Copyright (C) 1992-2017 Jean_Pierre Charras <jp.charras at wanadoo.fr>
|
2021-03-07 16:47:37 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHOR.txt for contributors.
|
2010-11-26 11:55:34 +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
|
|
|
|
*/
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2017-04-28 10:53:30 +00:00
|
|
|
/**
|
|
|
|
* @file gendrill_Excellon_writer.h
|
|
|
|
* @brief Classes used in drill files, map files and report files generation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
#ifndef _GENDRILL_EXCELLON_WRITER_
|
|
|
|
#define _GENDRILL_EXCELLON_WRITER_
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2017-04-28 10:53:30 +00:00
|
|
|
#include <gendrill_file_writer_base.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
|
|
|
class BOARD;
|
|
|
|
class PLOTTER;
|
2015-10-23 14:30:22 +00:00
|
|
|
class OUTPUTFORMATTER;
|
|
|
|
|
2021-03-07 16:47:37 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
/**
|
2021-06-04 17:44:22 +00:00
|
|
|
* Create Excellon drill, drill map, and drill report files.
|
2012-10-05 12:25:12 +00:00
|
|
|
*/
|
2017-04-28 10:53:30 +00:00
|
|
|
class EXCELLON_WRITER: public GENDRILL_WRITER_BASE
|
2010-11-24 19:54:59 +00:00
|
|
|
{
|
2015-04-29 15:37:37 +00:00
|
|
|
public:
|
|
|
|
EXCELLON_WRITER( BOARD* aPcb );
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2017-05-01 12:19:38 +00:00
|
|
|
virtual ~EXCELLON_WRITER()
|
2010-11-24 19:54:59 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
/**
|
2021-06-04 17:44:22 +00:00
|
|
|
* Return the plot offset (usually the position of the auxiliary axis.
|
2012-10-05 12:25:12 +00:00
|
|
|
*/
|
2021-12-29 21:30:11 +00:00
|
|
|
VECTOR2I GetOffset() { return m_offset; }
|
2010-11-24 19:54:59 +00:00
|
|
|
|
2019-02-09 13:56:02 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void SetRouteModeForOvalHoles( bool aUseRouteModeForOvalHoles )
|
|
|
|
{
|
|
|
|
m_useRouteModeForOval = aUseRouteModeForOvalHoles;
|
|
|
|
}
|
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
/**
|
2021-06-04 17:44:22 +00:00
|
|
|
* Initialize internal parameters to match the given format.
|
|
|
|
*
|
|
|
|
* @param aMetric set to true for metric coordinates, false for imperial units.
|
|
|
|
* @param aZerosFmt is the zero format DECIMAL_FORMAT, SUPPRESS_LEADING, SUPPRESS_TRAILING,
|
|
|
|
* or KEEP_ZEROS.
|
|
|
|
* @param aLeftDigits is the number of digits for integer part of coordinates
|
|
|
|
* if <= 0 (default), a suitable value will be used, depending on units.
|
|
|
|
* @param aRightDigits is number of digits for mantissa part of coordinates
|
|
|
|
* if <= 0 (default), a suitable value will be used, depending on units.
|
2010-11-24 19:54:59 +00:00
|
|
|
*/
|
2015-04-29 15:37:37 +00:00
|
|
|
void SetFormat( bool aMetric, ZEROS_FMT aZerosFmt = DECIMAL_FORMAT,
|
|
|
|
int aLeftDigits = 0, int aRightDigits = 0 );
|
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
/**
|
2021-06-04 17:44:22 +00:00
|
|
|
* Initialize internal parameters to match drill options.
|
|
|
|
*
|
|
|
|
* @param aMirror set to true to create mirrored coordinates (Y coordinates negated).
|
|
|
|
* @param aMinimalHeader set to true to use a minimal header (no comments, no info).
|
|
|
|
* @param aOffset is the drill coordinates offset.
|
|
|
|
* @param aMerge_PTH_NPTH set to true to create only one file containing PTH and NPTH
|
|
|
|
* false to create 2 separate files : one for PTH and one for NPTH.
|
2010-11-24 19:54:59 +00:00
|
|
|
*/
|
2021-12-29 21:30:11 +00:00
|
|
|
void SetOptions( bool aMirror, bool aMinimalHeader, const VECTOR2I& aOffset,
|
2021-07-26 19:35:12 +00:00
|
|
|
bool aMerge_PTH_NPTH )
|
2010-11-24 19:54:59 +00:00
|
|
|
{
|
|
|
|
m_mirror = aMirror;
|
|
|
|
m_offset = aOffset;
|
|
|
|
m_minimalHeader = aMinimalHeader;
|
2015-11-16 18:42:58 +00:00
|
|
|
m_merge_PTH_NPTH = aMerge_PTH_NPTH;
|
2010-11-24 19:54:59 +00:00
|
|
|
}
|
|
|
|
|
2015-04-29 15:37:37 +00:00
|
|
|
/**
|
2021-06-04 17:44:22 +00:00
|
|
|
* Create the full set of Excellon drill file for the board.
|
|
|
|
*
|
|
|
|
* File names are computed from the board name and layer ID.
|
|
|
|
*
|
|
|
|
* @param aPlotDirectory is the output folder.
|
|
|
|
* @param aGenDrill set to true to generate the EXCELLON drill file.
|
|
|
|
* @param aGenMap set to true to generate a drill map file.
|
|
|
|
* @param aReporter is a #REPORTER to return activity or any message (can be NULL)
|
2015-04-29 15:37:37 +00:00
|
|
|
*/
|
2023-04-21 03:28:32 +00:00
|
|
|
bool CreateDrillandMapFilesSet( const wxString& aPlotDirectory, bool aGenDrill, bool aGenMap,
|
2021-06-04 17:44:22 +00:00
|
|
|
REPORTER* aReporter = nullptr );
|
2015-04-29 15:37:37 +00:00
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
private:
|
2017-01-15 15:35:47 +00:00
|
|
|
/**
|
2021-06-04 17:44:22 +00:00
|
|
|
* Create an Excellon drill file.
|
|
|
|
*
|
|
|
|
* @param aFile is an opened file to write to will be closed by CreateDrillFile.
|
|
|
|
* @param aLayerPair is the layer pair for the current holes.
|
|
|
|
* @param aHolesType is the holes type (PTH, NPTH, mixed).
|
|
|
|
* @return the hole count.
|
2017-01-15 15:35:47 +00:00
|
|
|
*/
|
2021-06-04 17:44:22 +00:00
|
|
|
int createDrillFile( FILE* aFile, DRILL_LAYER_PAIR aLayerPair, TYPE_FILE aHolesType );
|
2017-01-15 15:35:47 +00:00
|
|
|
|
|
|
|
|
2021-06-04 17:44:22 +00:00
|
|
|
/**
|
|
|
|
* Print the DRILL file header.
|
|
|
|
*
|
|
|
|
* The full header is something like:
|
2014-03-06 18:38:39 +00:00
|
|
|
* M48
|
|
|
|
* ;DRILL file {PCBNEW (2007-11-29-b)} date 17/1/2008-21:02:35
|
|
|
|
* ;FORMAT={ <precision> / absolute / <units> / <numbers format>}
|
2018-11-21 14:33:17 +00:00
|
|
|
* ; #@! TF.FileFunction,Plated,1,4,PTH
|
|
|
|
* ; #@! TF.CreationDate,2018-11-23T15:59:51+01:00
|
|
|
|
* ; #@! TF.GenerationSoftware,Kicad,Pcbnew,2017.04
|
2014-03-06 18:38:39 +00:00
|
|
|
* FMAT,2
|
|
|
|
* INCH,TZ
|
2021-06-04 17:44:22 +00:00
|
|
|
*
|
|
|
|
* @param aLayerPair is the layer pair for the current holes.
|
|
|
|
* @param aHolesType is the holes type in file (PTH, NPTH, mixed).
|
2014-03-06 18:38:39 +00:00
|
|
|
*/
|
2021-03-14 11:38:03 +00:00
|
|
|
void writeEXCELLONHeader( DRILL_LAYER_PAIR aLayerPair, TYPE_FILE aHolesType );
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2017-01-15 15:35:47 +00:00
|
|
|
void writeEXCELLONEndOfFile();
|
2014-03-06 18:38:39 +00:00
|
|
|
|
2021-06-04 17:44:22 +00:00
|
|
|
/**
|
|
|
|
* Create a line like according to the selected format.
|
2014-03-06 18:38:39 +00:00
|
|
|
*/
|
2017-01-15 15:35:47 +00:00
|
|
|
void writeCoordinates( char* aLine, double aCoordX, double aCoordY );
|
2021-03-07 16:47:37 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 17:44:22 +00:00
|
|
|
* Write a comment string giving the hole attribute.
|
|
|
|
*
|
|
|
|
* @param aAttribute is the hole attribute.
|
2021-03-07 16:47:37 +00:00
|
|
|
*/
|
2021-03-26 08:46:32 +00:00
|
|
|
void writeHoleAttribute( HOLE_ATTRIBUTE aAttribute );
|
2021-06-04 17:44:22 +00:00
|
|
|
|
|
|
|
FILE* m_file; // The output file
|
|
|
|
bool m_minimalHeader; // True to use minimal header
|
|
|
|
bool m_mirror;
|
|
|
|
bool m_useRouteModeForOval; // True to use a route command for oval holes
|
|
|
|
// False to use a G85 canned mode for oval holes
|
2015-10-23 14:30:22 +00:00
|
|
|
};
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
#endif // #ifndef _GENDRILL_EXCELLON_WRITER_
|