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>
|
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see change_log.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;
|
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
/**
|
|
|
|
* EXCELLON_WRITER is a class mainly used to create Excellon drill files
|
|
|
|
* However, this class is also used to create drill maps and drill report
|
|
|
|
*/
|
2017-04-28 10:53:30 +00:00
|
|
|
class EXCELLON_WRITER: public GENDRILL_WRITER_BASE
|
2010-11-24 19:54:59 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
FILE* m_file; // The output file
|
2014-03-06 18:38:39 +00:00
|
|
|
bool m_minimalHeader; // True to use minimal header
|
2010-11-24 19:54:59 +00:00
|
|
|
bool m_mirror;
|
2008-01-18 15:47:15 +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
|
|
|
/**
|
|
|
|
* Return the plot offset (usually the position
|
2014-03-06 18:38:39 +00:00
|
|
|
* of the auxiliary axis
|
2012-10-05 12:25:12 +00:00
|
|
|
*/
|
|
|
|
const wxPoint GetOffset() { return m_offset; }
|
2010-11-24 19:54:59 +00:00
|
|
|
|
|
|
|
/**
|
2010-12-28 11:24:42 +00:00
|
|
|
* Function SetFormat
|
2010-11-24 19:54:59 +00:00
|
|
|
* Initialize internal parameters to match the given format
|
|
|
|
* @param aMetric = true for metric coordinates, false for imperial units
|
|
|
|
* @param aZerosFmt = DECIMAL_FORMAT, SUPPRESS_LEADING, SUPPRESS_TRAILING, KEEP_ZEROS
|
|
|
|
* @param aLeftDigits = number of digits for integer part of coordinates
|
2015-04-29 15:37:37 +00:00
|
|
|
* if <= 0 (default), a suitable value will be used, depending on units
|
2010-11-24 19:54:59 +00:00
|
|
|
* @param aRightDigits = number of digits for mantissa part of coordinates
|
2015-04-29 15:37:37 +00:00
|
|
|
* 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
|
|
|
|
|
|
|
/**
|
2010-12-28 11:24:42 +00:00
|
|
|
* Function SetOptions
|
2010-11-24 19:54:59 +00:00
|
|
|
* Initialize internal parameters to match drill options
|
2010-12-28 11:24:42 +00:00
|
|
|
* @param aMirror = true to create mirrored coordinates (Y coordinates negated)
|
|
|
|
* @param aMinimalHeader = true to use a minimal header (no comments, no info)
|
|
|
|
* @param aOffset = drill coordinates offset
|
2017-06-17 08:40:38 +00:00
|
|
|
* @param aMerge_PTH_NPTH = 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
|
|
|
*/
|
2015-11-16 18:42:58 +00:00
|
|
|
void SetOptions( bool aMirror, bool aMinimalHeader, wxPoint aOffset, 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
|
|
|
/**
|
|
|
|
* Function CreateDrillandMapFilesSet
|
|
|
|
* Creates the full set of Excellon drill file for the board
|
|
|
|
* filenames are computed from the board name, and layers id
|
|
|
|
* @param aPlotDirectory = the output folder
|
|
|
|
* @param aGenDrill = true to generate the EXCELLON drill file
|
|
|
|
* @param aGenMap = true to generate a drill map file
|
|
|
|
* @param aReporter = a REPORTER to return activity or any message (can be NULL)
|
|
|
|
*/
|
|
|
|
void CreateDrillandMapFilesSet( const wxString& aPlotDirectory,
|
|
|
|
bool aGenDrill, bool aGenMap,
|
|
|
|
REPORTER * aReporter = NULL );
|
|
|
|
|
|
|
|
|
2010-11-24 19:54:59 +00:00
|
|
|
private:
|
2017-01-15 15:35:47 +00:00
|
|
|
/**
|
|
|
|
* Function CreateDrillFile
|
|
|
|
* Creates an Excellon drill file
|
|
|
|
* @param aFile = an opened file to write to will be closed by CreateDrillFile
|
|
|
|
* @return hole count
|
|
|
|
*/
|
2018-11-21 14:33:17 +00:00
|
|
|
int createDrillFile( FILE * aFile, DRILL_LAYER_PAIR aLayerPair,
|
|
|
|
bool aGenerateNPTH_list );
|
2017-01-15 15:35:47 +00:00
|
|
|
|
|
|
|
|
2018-11-21 14:33:17 +00:00
|
|
|
/* Print the DRILL file header. The full header is somethink 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
|
|
|
|
*/
|
2018-11-21 14:33:17 +00:00
|
|
|
void writeEXCELLONHeader( DRILL_LAYER_PAIR aLayerPair,
|
|
|
|
bool aGenerateNPTH_list);
|
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
|
|
|
|
|
|
|
/* Created a line like:
|
|
|
|
* X48000Y19500
|
|
|
|
* According to the selected format
|
|
|
|
*/
|
2017-01-15 15:35:47 +00:00
|
|
|
void writeCoordinates( char* aLine, double aCoordX, double aCoordY );
|
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_
|