2012-10-05 12:25:12 +00:00
|
|
|
/**
|
|
|
|
* @file gen_drill_report_files.cpp
|
|
|
|
* @brief Functions to create report and map files for EXCELLON drill files.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992-2012 Jean_Pierre Charras <jp.charras at wanadoo.fr>
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <plot_common.h>
|
|
|
|
#include <base_struct.h>
|
|
|
|
#include <drawtxt.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <kicad_string.h>
|
2013-05-02 18:06:58 +00:00
|
|
|
#include <macros.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbplot.h>
|
2012-10-05 12:25:12 +00:00
|
|
|
#include <gendrill_Excellon_writer.h>
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
/* Conversion utilities - these will be used often in there... */
|
2012-10-05 12:25:12 +00:00
|
|
|
inline double diameter_in_inches( double ius )
|
2012-05-03 18:37:56 +00:00
|
|
|
{
|
|
|
|
return ius * 0.001 / IU_PER_MILS;
|
|
|
|
}
|
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
|
|
|
|
inline double diameter_in_mm( double ius )
|
2012-05-03 18:37:56 +00:00
|
|
|
{
|
|
|
|
return ius / IU_PER_MM;
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
/* Creates a hole map of the board in HPGL, POSTSCRIPT or other supported formats
|
|
|
|
* Each hole size has a the drill mark symbol (circle, cross X, cross + ...) up to
|
|
|
|
* PLOTTER::MARKER_COUNT different values.
|
|
|
|
* If more than PLOTTER::MARKER_COUNT different values,
|
|
|
|
* these other vaules share the same mark
|
|
|
|
*/
|
|
|
|
bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
|
|
|
|
const PAGE_INFO& aSheet,
|
|
|
|
PlotFormat aFormat )
|
2008-01-18 15:47:15 +00:00
|
|
|
{
|
2012-10-05 12:25:12 +00:00
|
|
|
double scale = 1.0;
|
|
|
|
wxPoint offset;
|
|
|
|
PLOTTER* plotter = NULL;
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
PCB_PLOT_PARAMS plot_opts; // starts plotting with default options
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
LOCALE_IO toggle; // use standard C notation for float numbers
|
2011-02-25 16:23:24 +00:00
|
|
|
|
|
|
|
// Calculate dimensions and center of PCB
|
2012-10-05 12:25:12 +00:00
|
|
|
EDA_RECT bbbox = m_pcb->ComputeBoundingBox( true );
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Calculate the scale for the format type, scale 1 in HPGL, drawing on
|
|
|
|
// an A4 sheet in PS, + text description of symbols
|
2012-10-05 12:25:12 +00:00
|
|
|
switch( aFormat )
|
2008-01-18 15:47:15 +00:00
|
|
|
{
|
2009-06-28 16:50:42 +00:00
|
|
|
case PLOT_FORMAT_GERBER:
|
2012-10-05 12:25:12 +00:00
|
|
|
offset = GetOffset();
|
2009-08-29 10:20:48 +00:00
|
|
|
plotter = new GERBER_PLOTTER();
|
2012-08-29 16:59:50 +00:00
|
|
|
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
|
2009-08-29 10:20:48 +00:00
|
|
|
break;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
case PLOT_FORMAT_HPGL: // Scale for HPGL format.
|
2012-04-05 18:27:56 +00:00
|
|
|
{
|
|
|
|
HPGL_PLOTTER* hpgl_plotter = new HPGL_PLOTTER;
|
|
|
|
plotter = hpgl_plotter;
|
2012-08-29 16:59:50 +00:00
|
|
|
hpgl_plotter->SetPenNumber( plot_opts.GetHPGLPenNum() );
|
|
|
|
hpgl_plotter->SetPenSpeed( plot_opts.GetHPGLPenSpeed() );
|
2012-05-03 18:37:56 +00:00
|
|
|
hpgl_plotter->SetPenOverlap( 0 );
|
2012-04-05 18:27:56 +00:00
|
|
|
plotter->SetPageSettings( aSheet );
|
2012-08-29 16:59:50 +00:00
|
|
|
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
|
2012-04-05 18:27:56 +00:00
|
|
|
}
|
|
|
|
break;
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2012-10-13 18:54:33 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
wxASSERT( false );
|
|
|
|
// fall through
|
|
|
|
case PLOT_FORMAT_PDF:
|
2008-01-18 15:47:15 +00:00
|
|
|
case PLOT_FORMAT_POST:
|
2012-04-05 18:27:56 +00:00
|
|
|
{
|
|
|
|
PAGE_INFO pageA4( wxT( "A4" ) );
|
|
|
|
wxSize pageSizeIU = pageA4.GetSizeIU();
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-08-29 12:40:09 +00:00
|
|
|
// Reserve a margin around the page.
|
2013-05-04 11:57:09 +00:00
|
|
|
int margin = KiROUND( 20 * IU_PER_MM );
|
2012-08-29 12:40:09 +00:00
|
|
|
|
|
|
|
// Calculate a scaling factor to print the board on the sheet
|
2013-05-04 11:57:09 +00:00
|
|
|
double Xscale = double( pageSizeIU.x - ( 2 * margin ) ) / bbbox.GetWidth();
|
2012-08-29 12:40:09 +00:00
|
|
|
|
|
|
|
// We should print the list of drill sizes, so reserve room for it
|
|
|
|
// 60% height for board 40% height for list
|
2013-05-04 11:57:09 +00:00
|
|
|
int ypagesize_for_board = KiROUND( pageSizeIU.y * 0.6 );
|
|
|
|
double Yscale = double( ypagesize_for_board - margin ) / bbbox.GetHeight();
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-09-20 13:22:33 +00:00
|
|
|
scale = std::min( Xscale, Yscale );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-08-29 12:40:09 +00:00
|
|
|
// Experience shows the scale should not to large, because texts
|
|
|
|
// create problem (can be to big or too small).
|
|
|
|
// So the scale is clipped at 3.0;
|
2012-09-20 13:22:33 +00:00
|
|
|
scale = std::min( scale, 3.0 );
|
2012-08-29 12:40:09 +00:00
|
|
|
|
2013-05-04 11:57:09 +00:00
|
|
|
offset.x = KiROUND( double( bbbox.Centre().x ) -
|
|
|
|
( pageSizeIU.x / 2.0 ) / scale );
|
|
|
|
offset.y = KiROUND( double( bbbox.Centre().y ) -
|
2012-10-05 12:25:12 +00:00
|
|
|
( ypagesize_for_board / 2.0 ) / scale );
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-10-13 18:54:33 +00:00
|
|
|
if( aFormat == PLOT_FORMAT_PDF )
|
|
|
|
plotter = new PDF_PLOTTER;
|
|
|
|
else
|
|
|
|
plotter = new PS_PLOTTER;
|
|
|
|
|
|
|
|
plotter->SetPageSettings( pageA4 );
|
2012-08-29 16:59:50 +00:00
|
|
|
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
|
2012-04-05 18:27:56 +00:00
|
|
|
}
|
2008-01-18 15:47:15 +00:00
|
|
|
break;
|
2009-08-29 10:20:48 +00:00
|
|
|
|
2009-06-30 10:43:20 +00:00
|
|
|
case PLOT_FORMAT_DXF:
|
2012-04-05 18:27:56 +00:00
|
|
|
{
|
|
|
|
DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER;
|
|
|
|
plotter = dxf_plotter;
|
|
|
|
plotter->SetPageSettings( aSheet );
|
2012-08-29 16:59:50 +00:00
|
|
|
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
|
2012-04-05 18:27:56 +00:00
|
|
|
}
|
2009-08-29 10:20:48 +00:00
|
|
|
break;
|
2009-06-30 10:43:20 +00:00
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
case PLOT_FORMAT_SVG:
|
|
|
|
{
|
|
|
|
SVG_PLOTTER* svg_plotter = new SVG_PLOTTER;
|
|
|
|
plotter = svg_plotter;
|
|
|
|
plotter->SetPageSettings( aSheet );
|
|
|
|
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
|
|
|
|
}
|
|
|
|
break;
|
2008-01-18 15:47:15 +00:00
|
|
|
}
|
|
|
|
|
2012-10-13 18:54:33 +00:00
|
|
|
plotter->SetCreator( wxT( "PCBNEW" ) );
|
|
|
|
plotter->SetDefaultLineWidth( 5 * IU_PER_MILS );
|
|
|
|
plotter->SetColorMode( false );
|
2012-10-05 12:25:12 +00:00
|
|
|
|
2012-10-13 18:54:33 +00:00
|
|
|
if( ! plotter->OpenFile( aFullFileName ) )
|
2012-10-05 12:25:12 +00:00
|
|
|
{
|
|
|
|
delete plotter;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-10-13 18:54:33 +00:00
|
|
|
plotter->StartPlot();
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2012-09-21 08:20:38 +00:00
|
|
|
// Draw items on edge layer (not all, only items useful for drill map
|
2012-10-05 12:25:12 +00:00
|
|
|
BRDITEMS_PLOTTER itemplotter( plotter, m_pcb, plot_opts );
|
2012-09-21 08:20:38 +00:00
|
|
|
itemplotter.SetLayerMask( EDGE_LAYER );
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
for( EDA_ITEM* PtStruct = m_pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
|
2008-01-18 15:47:15 +00:00
|
|
|
{
|
|
|
|
switch( PtStruct->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
2012-09-21 08:20:38 +00:00
|
|
|
itemplotter.PlotDrawSegment( (DRAWSEGMENT*) PtStruct );
|
2008-01-18 15:47:15 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2012-09-21 08:20:38 +00:00
|
|
|
itemplotter.PlotTextePcb( (TEXTE_PCB*) PtStruct );
|
2008-01-18 15:47:15 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_DIMENSION_T:
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MARKER_T: // do not draw
|
2008-01-18 15:47:15 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-29 12:40:09 +00:00
|
|
|
int x, y;
|
|
|
|
int plotX, plotY, TextWidth;
|
|
|
|
int intervalle = 0;
|
|
|
|
char line[1024];
|
|
|
|
wxString msg;
|
2013-05-04 11:57:09 +00:00
|
|
|
int textmarginaftersymbol = KiROUND( 2 * IU_PER_MM );
|
2012-08-29 12:40:09 +00:00
|
|
|
|
|
|
|
// Set Drill Symbols width
|
|
|
|
plotter->SetDefaultLineWidth( 0.2 * IU_PER_MM / scale );
|
2012-05-03 18:37:56 +00:00
|
|
|
plotter->SetCurrentLineWidth( -1 );
|
2009-08-29 10:20:48 +00:00
|
|
|
|
2009-03-19 10:54:53 +00:00
|
|
|
// Plot board outlines and drill map
|
2012-10-05 12:25:12 +00:00
|
|
|
PlotDrillMarks( plotter );
|
2009-03-19 10:54:53 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
// Print a list of symbols used.
|
2012-10-05 12:25:12 +00:00
|
|
|
int charSize = 3 * IU_PER_MM; // text size in IUs
|
|
|
|
double charScale = 1.0 / scale; // real scale will be 1/scale,
|
|
|
|
// because the global plot scale is scale
|
2013-05-04 11:57:09 +00:00
|
|
|
TextWidth = KiROUND( (charSize * charScale) / 10.0 ); // Set text width (thickness)
|
|
|
|
intervalle = KiROUND( charSize * charScale ) + TextWidth;
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
// Trace information.
|
2013-05-04 11:57:09 +00:00
|
|
|
plotX = KiROUND( bbbox.GetX() + textmarginaftersymbol * charScale );
|
2012-10-05 12:25:12 +00:00
|
|
|
plotY = bbbox.GetBottom() + intervalle;
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
// Plot title "Info"
|
2009-06-28 16:50:42 +00:00
|
|
|
wxString Text = wxT( "Drill Map:" );
|
2012-09-02 12:06:47 +00:00
|
|
|
plotter->Text( wxPoint( plotX, plotY ), UNSPECIFIED_COLOR, Text, 0,
|
2013-05-04 11:57:09 +00:00
|
|
|
wxSize( KiROUND( charSize * charScale ),
|
|
|
|
KiROUND( charSize * charScale ) ),
|
2009-08-29 10:20:48 +00:00
|
|
|
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
TextWidth, false, false );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
|
2008-01-18 15:47:15 +00:00
|
|
|
{
|
|
|
|
int plot_diam;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
if( m_toolListBuffer[ii].m_TotalCount == 0 )
|
2008-01-18 15:47:15 +00:00
|
|
|
continue;
|
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
plotY += intervalle;
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2013-05-04 11:57:09 +00:00
|
|
|
plot_diam = KiROUND( m_toolListBuffer[ii].m_Diameter );
|
|
|
|
x = KiROUND( plotX - textmarginaftersymbol * charScale
|
|
|
|
- plot_diam / 2.0 );
|
|
|
|
y = KiROUND( plotY + charSize * charScale );
|
2012-05-03 18:37:56 +00:00
|
|
|
plotter->Marker( wxPoint( x, y ), plot_diam, ii );
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
// List the diameter of each drill in mm and inches.
|
|
|
|
sprintf( line, "%2.2fmm / %2.3f\" ",
|
|
|
|
diameter_in_mm( m_toolListBuffer[ii].m_Diameter ),
|
|
|
|
diameter_in_inches( m_toolListBuffer[ii].m_Diameter ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
msg = FROM_UTF8( line );
|
2009-08-29 10:20:48 +00:00
|
|
|
|
|
|
|
// Now list how many holes and ovals are associated with each drill.
|
2012-10-05 12:25:12 +00:00
|
|
|
if( ( m_toolListBuffer[ii].m_TotalCount == 1 )
|
|
|
|
&& ( m_toolListBuffer[ii].m_OvalCount == 0 ) )
|
2009-08-29 10:20:48 +00:00
|
|
|
sprintf( line, "(1 hole)" );
|
2012-10-05 12:25:12 +00:00
|
|
|
else if( m_toolListBuffer[ii].m_TotalCount == 1 ) // && ( m_toolListBuffer[ii]m_OvalCount == 1 )
|
2009-08-29 10:20:48 +00:00
|
|
|
sprintf( line, "(1 slot)" );
|
2012-10-05 12:25:12 +00:00
|
|
|
else if( m_toolListBuffer[ii].m_OvalCount == 0 )
|
|
|
|
sprintf( line, "(%d holes)", m_toolListBuffer[ii].m_TotalCount );
|
|
|
|
else if( m_toolListBuffer[ii].m_OvalCount == 1 )
|
|
|
|
sprintf( line, "(%d holes + 1 slot)", m_toolListBuffer[ii].m_TotalCount - 1 );
|
|
|
|
else // if ( m_toolListBuffer[ii]m_OvalCount > 1 )
|
2009-08-29 10:20:48 +00:00
|
|
|
sprintf( line, "(%d holes + %d slots)",
|
2012-10-05 12:25:12 +00:00
|
|
|
m_toolListBuffer[ii].m_TotalCount - m_toolListBuffer[ii].m_OvalCount,
|
|
|
|
m_toolListBuffer[ii].m_OvalCount );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
msg += FROM_UTF8( line );
|
2012-09-02 12:06:47 +00:00
|
|
|
plotter->Text( wxPoint( plotX, y ), UNSPECIFIED_COLOR,
|
2009-08-29 10:20:48 +00:00
|
|
|
msg,
|
2013-05-04 11:57:09 +00:00
|
|
|
0, wxSize( KiROUND( charSize * charScale ),
|
|
|
|
KiROUND( charSize * charScale ) ),
|
2009-08-29 10:20:48 +00:00
|
|
|
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
TextWidth, false, false );
|
|
|
|
|
2013-05-04 11:57:09 +00:00
|
|
|
intervalle = KiROUND( (( charSize * charScale ) + TextWidth) * 1.2);
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
if( intervalle < (plot_diam + (1 * IU_PER_MM / scale) + TextWidth) )
|
|
|
|
intervalle = plot_diam + (1 * IU_PER_MM / scale) + TextWidth;
|
2008-01-18 15:47:15 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
plotter->EndPlot();
|
2009-06-28 16:50:42 +00:00
|
|
|
delete plotter;
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
return true;
|
2008-01-18 15:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-10-05 12:25:12 +00:00
|
|
|
* Create a plain text report file giving a list of drill values and drill count
|
|
|
|
* for through holes, oblong holes, and for buried vias,
|
|
|
|
* drill values and drill count per layer pair
|
|
|
|
*/
|
|
|
|
/* Here is a sample created by this function:
|
|
|
|
* Drill report for F:/tmp/interf_u/interf_u.brd
|
|
|
|
* Created on 04/10/2012 20:48:38
|
|
|
|
* Selected Drill Unit: Imperial (inches)
|
|
|
|
*
|
|
|
|
* Drill report for plated through holes :
|
|
|
|
* T1 0,025" 0,64mm (88 holes)
|
|
|
|
* T2 0,031" 0,79mm (120 holes)
|
|
|
|
* T3 0,032" 0,81mm (151 holes) (with 1 slot)
|
|
|
|
* T4 0,040" 1,02mm (43 holes)
|
|
|
|
* T5 0,079" 2,00mm (1 hole) (with 1 slot)
|
|
|
|
* T6 0,120" 3,05mm (1 hole) (with 1 slot)
|
|
|
|
*
|
|
|
|
* Total plated holes count 404
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Drill report for buried and blind vias :
|
|
|
|
*
|
|
|
|
* Drill report for holes from layer Soudure to layer Interne1 :
|
|
|
|
*
|
|
|
|
* Total plated holes count 0
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Drill report for holes from layer Interne1 to layer Interne2 :
|
|
|
|
* T1 0,025" 0,64mm (3 holes)
|
|
|
|
*
|
|
|
|
* Total plated holes count 3
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Drill report for holes from layer Interne2 to layer Composant :
|
|
|
|
* T1 0,025" 0,64mm (1 hole)
|
|
|
|
*
|
|
|
|
* Total plated holes count 1
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Drill report for unplated through holes :
|
|
|
|
* T1 0,120" 3,05mm (1 hole) (with 1 slot)
|
|
|
|
*
|
|
|
|
* Total unplated holes count 1
|
|
|
|
*
|
2008-01-18 15:47:15 +00:00
|
|
|
*/
|
2012-10-05 12:25:12 +00:00
|
|
|
bool EXCELLON_WRITER::GenDrillReportFile( const wxString& aFullFileName )
|
2008-01-18 15:47:15 +00:00
|
|
|
{
|
2012-10-05 12:25:12 +00:00
|
|
|
unsigned totalHoleCount;
|
|
|
|
char line[1024];
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM layer1 = LAYER_N_BACK;
|
|
|
|
LAYER_NUM layer2 = LAYER_N_FRONT;
|
2012-10-05 12:25:12 +00:00
|
|
|
bool gen_through_holes = true;
|
|
|
|
bool gen_NPTH_holes = false;
|
2008-01-25 16:47:36 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
m_file = wxFopen( aFullFileName, wxT( "w" ) );
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
if( m_file == NULL )
|
|
|
|
return false;
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
wxString brdFilename = m_pcb->GetFileName();
|
|
|
|
fprintf( m_file, "Drill report for %s\n", TO_UTF8( brdFilename ) );
|
|
|
|
fprintf( m_file, "Created on %s\n", TO_UTF8( DateAndTime() ) );
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2008-01-25 16:47:36 +00:00
|
|
|
/* build hole lists:
|
|
|
|
* 1 - through holes
|
|
|
|
* 2 - for partial holes only: by layer pair
|
2011-08-19 13:08:24 +00:00
|
|
|
* 3 - Not Plated through holes
|
2008-01-25 16:47:36 +00:00
|
|
|
*/
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2008-01-25 16:47:36 +00:00
|
|
|
for( ; ; )
|
2008-01-18 15:47:15 +00:00
|
|
|
{
|
2012-10-05 12:25:12 +00:00
|
|
|
BuildHolesList( layer1, layer2,
|
2011-08-19 13:08:24 +00:00
|
|
|
gen_through_holes ? false : true, gen_NPTH_holes );
|
2008-01-25 16:47:36 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
totalHoleCount = 0;
|
2008-01-25 16:47:36 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
if( gen_NPTH_holes )
|
2012-05-03 18:37:56 +00:00
|
|
|
sprintf( line, "Drill report for unplated through holes :\n" );
|
2011-08-19 13:08:24 +00:00
|
|
|
else if( gen_through_holes )
|
2012-05-03 18:37:56 +00:00
|
|
|
sprintf( line, "Drill report for plated through holes :\n" );
|
2008-01-18 15:47:15 +00:00
|
|
|
else
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2012-10-05 12:25:12 +00:00
|
|
|
// If this is the first partial hole list: print a title
|
|
|
|
if( layer1 == LAYER_N_BACK )
|
|
|
|
fputs( "Drill report for buried and blind vias :\n\n", m_file );
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
sprintf( line, "Drill report for holes from layer %s to layer %s :\n",
|
2012-10-05 12:25:12 +00:00
|
|
|
TO_UTF8( m_pcb->GetLayerName( layer1 ) ),
|
|
|
|
TO_UTF8( m_pcb->GetLayerName( layer2 ) ) );
|
2008-03-22 05:55:06 +00:00
|
|
|
}
|
2008-01-25 16:47:36 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
fputs( line, m_file );
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
for( unsigned ii = 0; ii < m_toolListBuffer.size(); ii++ )
|
2008-01-25 16:47:36 +00:00
|
|
|
{
|
|
|
|
// List the tool number assigned to each drill,
|
2012-10-05 12:25:12 +00:00
|
|
|
// in mm then in inches.
|
|
|
|
sprintf( line, "T%d %2.2fmm %2.3f\" ",
|
|
|
|
ii + 1,
|
|
|
|
diameter_in_mm( m_toolListBuffer[ii].m_Diameter ),
|
|
|
|
diameter_in_inches( m_toolListBuffer[ii].m_Diameter ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
fputs( line, m_file );
|
2008-01-25 16:47:36 +00:00
|
|
|
|
|
|
|
// Now list how many holes and ovals are associated with each drill.
|
2012-10-05 12:25:12 +00:00
|
|
|
if( ( m_toolListBuffer[ii].m_TotalCount == 1 )
|
|
|
|
&& ( m_toolListBuffer[ii].m_OvalCount == 0 ) )
|
2008-01-25 16:47:36 +00:00
|
|
|
sprintf( line, "(1 hole)\n" );
|
2012-10-05 12:25:12 +00:00
|
|
|
else if( m_toolListBuffer[ii].m_TotalCount == 1 )
|
2012-05-03 18:37:56 +00:00
|
|
|
sprintf( line, "(1 hole) (with 1 slot)\n" );
|
2012-10-05 12:25:12 +00:00
|
|
|
else if( m_toolListBuffer[ii].m_OvalCount == 0 )
|
|
|
|
sprintf( line, "(%d holes)\n", m_toolListBuffer[ii].m_TotalCount );
|
|
|
|
else if( m_toolListBuffer[ii].m_OvalCount == 1 )
|
|
|
|
sprintf( line, "(%d holes) (with 1 slot)\n",
|
|
|
|
m_toolListBuffer[ii].m_TotalCount );
|
|
|
|
else // if ( buffer[ii]m_OvalCount > 1 )
|
2012-05-03 18:37:56 +00:00
|
|
|
sprintf( line, "(%d holes) (with %d slots)\n",
|
2012-10-05 12:25:12 +00:00
|
|
|
m_toolListBuffer[ii].m_TotalCount,
|
|
|
|
m_toolListBuffer[ii].m_OvalCount );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
fputs( line, m_file );
|
2008-01-25 16:47:36 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
totalHoleCount += m_toolListBuffer[ii].m_TotalCount;
|
2008-01-25 16:47:36 +00:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
if( gen_NPTH_holes )
|
2012-10-05 12:25:12 +00:00
|
|
|
sprintf( line, "\nTotal unplated holes count %d\n\n\n", totalHoleCount );
|
2011-08-19 13:08:24 +00:00
|
|
|
else
|
2012-10-05 12:25:12 +00:00
|
|
|
sprintf( line, "\nTotal plated holes count %d\n\n\n", totalHoleCount );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
fputs( line, m_file );
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
if( gen_NPTH_holes )
|
|
|
|
{
|
2008-01-25 16:47:36 +00:00
|
|
|
break;
|
2011-08-19 13:08:24 +00:00
|
|
|
}
|
2008-01-25 16:47:36 +00:00
|
|
|
else
|
|
|
|
{
|
2012-10-05 12:25:12 +00:00
|
|
|
if( m_pcb->GetCopperLayerCount() <= 2 )
|
2011-08-19 13:08:24 +00:00
|
|
|
{
|
|
|
|
gen_NPTH_holes = true;
|
|
|
|
continue;
|
|
|
|
}
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
if( gen_through_holes )
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
layer2 = layer1 + 1;
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2011-08-19 13:08:24 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if( layer2 >= LAYER_N_FRONT ) // no more layer pair to consider
|
|
|
|
{
|
|
|
|
gen_NPTH_holes = true;
|
|
|
|
continue;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
++layer1; ++layer2; // use next layer pair
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
if( layer2 == m_pcb->GetCopperLayerCount() - 1 )
|
|
|
|
layer2 = LAYER_N_FRONT; // the last layer is always the
|
|
|
|
|
|
|
|
// component layer
|
2011-08-19 13:08:24 +00:00
|
|
|
}
|
2012-10-05 12:25:12 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
gen_through_holes = false;
|
2008-01-25 16:47:36 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2012-10-05 12:25:12 +00:00
|
|
|
fclose( m_file );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Helper function to plot drill marks:
|
|
|
|
bool EXCELLON_WRITER::PlotDrillMarks( PLOTTER* aPlotter )
|
|
|
|
{
|
|
|
|
// Plot the drill map:
|
|
|
|
wxPoint pos;
|
|
|
|
for( unsigned ii = 0; ii < m_holeListBuffer.size(); ii++ )
|
|
|
|
{
|
|
|
|
pos = m_holeListBuffer[ii].m_Hole_Pos;
|
|
|
|
|
|
|
|
/* Always plot the drill symbol (for slots identifies the needed
|
|
|
|
* cutter!) */
|
|
|
|
aPlotter->Marker( pos, m_holeListBuffer[ii].m_Hole_Diameter,
|
|
|
|
m_holeListBuffer[ii].m_Tool_Reference - 1 );
|
|
|
|
|
|
|
|
if( m_holeListBuffer[ii].m_Hole_Shape != 0 )
|
|
|
|
{
|
|
|
|
wxSize oblong_size;
|
|
|
|
oblong_size = m_holeListBuffer[ii].m_Hole_Size;
|
|
|
|
aPlotter->FlashPadOval( pos, oblong_size,
|
|
|
|
m_holeListBuffer[ii].m_Hole_Orient, LINE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2008-01-18 15:47:15 +00:00
|
|
|
}
|