2009-11-14 22:15:22 +00:00
|
|
|
/************************************************************************/
|
|
|
|
/* Functions to create drill data used to create files and report files */
|
|
|
|
/************************************************************************/
|
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 <colors.h>
|
|
|
|
#include <drawtxt.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#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>
|
|
|
|
#include <gendrill.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... */
|
|
|
|
static double diameter_in_inches(double ius)
|
|
|
|
{
|
|
|
|
return ius * 0.001 / IU_PER_MILS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static double diameter_in_mm(double ius)
|
|
|
|
{
|
|
|
|
return ius / IU_PER_MM;
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
|
2011-12-22 21:57:50 +00:00
|
|
|
const PAGE_INFO& aSheet,
|
2008-01-18 15:47:15 +00:00
|
|
|
std::vector<HOLE_INFO> aHoleListBuffer,
|
|
|
|
std::vector<DRILL_TOOL> aToolListBuffer,
|
2009-06-28 16:50:42 +00:00
|
|
|
bool aUnit_Drill_is_Inch, int format,
|
2009-08-29 10:20:48 +00:00
|
|
|
const wxPoint& auxoffset )
|
2008-01-18 15:47:15 +00:00
|
|
|
{
|
2011-12-22 21:57:50 +00:00
|
|
|
double scale = 1.0;
|
|
|
|
wxPoint offset;
|
|
|
|
PLOTTER* plotter = NULL;
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2012-09-21 08:20:38 +00:00
|
|
|
PCB_PLOT_PARAMS plot_opts; // starts plotting with default options
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2012-08-29 12:40:09 +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-08-29 12:40:09 +00:00
|
|
|
EDA_RECT bbbox = aPcb->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
|
2008-01-18 15:47:15 +00:00
|
|
|
switch( format )
|
|
|
|
{
|
2009-06-28 16:50:42 +00:00
|
|
|
case PLOT_FORMAT_GERBER:
|
2009-08-29 10:20:48 +00:00
|
|
|
offset = auxoffset;
|
|
|
|
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
|
|
|
|
2011-12-22 21:57:50 +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
|
|
|
|
|
|
|
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.
|
|
|
|
int margin = (int)(20 * IU_PER_MM );
|
|
|
|
|
|
|
|
// Calculate a scaling factor to print the board on the sheet
|
|
|
|
double Xscale = (double)( pageSizeIU.x - ( 2 * margin ) ) / bbbox.GetWidth();
|
|
|
|
|
|
|
|
// We should print the list of drill sizes, so reserve room for it
|
|
|
|
// 60% height for board 40% height for list
|
|
|
|
int ypagesize_for_board = (int) (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
|
|
|
|
|
|
|
offset.x = (int) ( (double) bbbox.Centre().x - ( pageSizeIU.x / 2.0 ) / scale );
|
|
|
|
offset.y = (int) ( (double) bbbox.Centre().y -
|
|
|
|
( ypagesize_for_board / 2.0 ) / scale );
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
PS_PLOTTER* ps_plotter = new PS_PLOTTER;
|
|
|
|
plotter = ps_plotter;
|
|
|
|
ps_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
|
|
|
default:
|
2009-08-29 10:20:48 +00:00
|
|
|
wxASSERT( false );
|
2008-01-18 15:47:15 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
plotter->SetCreator( wxT( "PCBNEW" ) );
|
|
|
|
plotter->SetFilename( aFullFileName );
|
|
|
|
plotter->SetDefaultLineWidth( 10 * IU_PER_DECIMILS );
|
|
|
|
plotter->StartPlot( aFile );
|
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
|
|
|
|
BRDITEMS_PLOTTER itemplotter( plotter, aPcb, plot_opts );
|
|
|
|
itemplotter.SetLayerMask( EDGE_LAYER );
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2012-08-29 12:40:09 +00:00
|
|
|
for( EDA_ITEM* PtStruct = aPcb->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;
|
|
|
|
int textmarginaftersymbol = (int) (2 * IU_PER_MM);
|
|
|
|
|
|
|
|
// 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
|
2009-08-29 10:20:48 +00:00
|
|
|
Gen_Drill_PcbMap( aPcb, plotter, aHoleListBuffer, aToolListBuffer );
|
2009-03-19 10:54:53 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
// Print a list of symbols used.
|
2012-08-29 12:40:09 +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
|
|
|
|
TextWidth = (int) ( (charSize * charScale) / 10 ); // Set text width (thickness)
|
|
|
|
intervalle = (int) ( charSize * charScale ) + TextWidth;
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
// Trace information.
|
2012-08-29 12:40:09 +00:00
|
|
|
plotX = (int) ( (double) bbbox.GetX() + textmarginaftersymbol * charScale );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +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,
|
2012-08-29 12:40:09 +00:00
|
|
|
wxSize( (int) ( charSize * charScale ),
|
|
|
|
(int) ( 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
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
for( unsigned ii = 0; ii < aToolListBuffer.size(); ii++ )
|
2008-01-18 15:47:15 +00:00
|
|
|
{
|
|
|
|
int plot_diam;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-01-18 15:47:15 +00:00
|
|
|
if( aToolListBuffer[ii].m_TotalCount == 0 )
|
|
|
|
continue;
|
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
plotY += intervalle;
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
plot_diam = (int) aToolListBuffer[ii].m_Diameter;
|
2012-08-29 12:40:09 +00:00
|
|
|
x = (int) ( (double) plotX - textmarginaftersymbol * charScale
|
2012-05-03 18:37:56 +00:00
|
|
|
- (double)plot_diam / 2.0 );
|
2012-08-29 12:40:09 +00:00
|
|
|
y = (int) ( (double) plotY + (double) 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
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
// Trace the legends.
|
2009-08-29 10:20:48 +00:00
|
|
|
|
|
|
|
// List the diameter of each drill in the selected Drill Unit,
|
|
|
|
// and then its diameter in the other Drill Unit.
|
|
|
|
if( aUnit_Drill_is_Inch )
|
|
|
|
sprintf( line, "%2.3f\" / %2.2fmm ",
|
2012-05-03 18:37:56 +00:00
|
|
|
diameter_in_inches( aToolListBuffer[ii].m_Diameter ),
|
|
|
|
diameter_in_mm( aToolListBuffer[ii].m_Diameter ) );
|
2009-08-29 10:20:48 +00:00
|
|
|
else
|
|
|
|
sprintf( line, "%2.2fmm / %2.3f\" ",
|
2012-05-03 18:37:56 +00:00
|
|
|
diameter_in_mm( aToolListBuffer[ii].m_Diameter ),
|
|
|
|
diameter_in_inches( aToolListBuffer[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.
|
|
|
|
if( ( aToolListBuffer[ii].m_TotalCount == 1 )
|
|
|
|
&& ( aToolListBuffer[ii].m_OvalCount == 0 ) )
|
|
|
|
sprintf( line, "(1 hole)" );
|
|
|
|
else if( aToolListBuffer[ii].m_TotalCount == 1 ) // && ( aToolListBuffer[ii]m_OvalCount == 1 )
|
|
|
|
sprintf( line, "(1 slot)" );
|
|
|
|
else if( aToolListBuffer[ii].m_OvalCount == 0 )
|
2011-09-07 19:41:04 +00:00
|
|
|
sprintf( line, "(%d holes)", aToolListBuffer[ii].m_TotalCount );
|
2009-08-29 10:20:48 +00:00
|
|
|
else if( aToolListBuffer[ii].m_OvalCount == 1 )
|
2011-09-07 19:41:04 +00:00
|
|
|
sprintf( line, "(%d holes + 1 slot)", aToolListBuffer[ii].m_TotalCount - 1 );
|
2009-08-29 10:20:48 +00:00
|
|
|
else // if ( aToolListBuffer[ii]m_OvalCount > 1 )
|
|
|
|
sprintf( line, "(%d holes + %d slots)",
|
2012-08-29 12:40:09 +00:00
|
|
|
aToolListBuffer[ii].m_TotalCount - aToolListBuffer[ii].m_OvalCount,
|
2009-08-29 10:20:48 +00:00
|
|
|
aToolListBuffer[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,
|
2012-09-02 12:06:47 +00:00
|
|
|
0, wxSize( (int) ( charSize * charScale ),
|
|
|
|
(int) ( charSize * charScale ) ),
|
2009-08-29 10:20:48 +00:00
|
|
|
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
TextWidth, false, false );
|
|
|
|
|
2012-08-29 12:40:09 +00:00
|
|
|
intervalle = (int) ( charSize * charScale ) + TextWidth;
|
2009-08-29 10:20:48 +00:00
|
|
|
intervalle = (int) ( intervalle * 1.2 );
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2012-08-29 12:40:09 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Creates the drill map aFile in HPGL or POSTSCRIPT format
|
2010-12-28 11:24:42 +00:00
|
|
|
* @param aPcb = the BOARD
|
|
|
|
* @param aPlotter = a PLOTTER instance (HPGL or POSTSCRIPT plotter).
|
2008-01-18 15:47:15 +00:00
|
|
|
* @param aHoleListBuffer = std::vector<HOLE_INFO> list of holes descriptors
|
|
|
|
* @param aToolListBuffer = std::vector<DRILL_TOOL> drill list buffer
|
|
|
|
*/
|
2010-12-28 11:24:42 +00:00
|
|
|
void Gen_Drill_PcbMap( BOARD* aPcb, PLOTTER* aPlotter,
|
2009-11-14 22:15:22 +00:00
|
|
|
std::vector<HOLE_INFO>& aHoleListBuffer,
|
|
|
|
std::vector<DRILL_TOOL>& aToolListBuffer )
|
2008-01-18 15:47:15 +00:00
|
|
|
{
|
|
|
|
wxPoint pos;
|
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
// create the drill list
|
2012-05-03 18:37:56 +00:00
|
|
|
if( aToolListBuffer.size() > PLOTTER::MARKER_COUNT )
|
2008-01-18 15:47:15 +00:00
|
|
|
{
|
2009-04-17 08:51:02 +00:00
|
|
|
DisplayInfoMessage( NULL,
|
2012-05-11 09:02:35 +00:00
|
|
|
_( " Drill map: Too many diameter values to draw one symbol per drill value\n"
|
|
|
|
"Plot will use circle shape for some drill values" ),
|
2009-08-29 10:20:48 +00:00
|
|
|
10 );
|
2008-01-18 15:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Plot the drill map:
|
|
|
|
for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ )
|
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
pos = aHoleListBuffer[ii].m_Hole_Pos;
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
/* Always plot the drill symbol (for slots identifies the needed
|
|
|
|
* cutter!) */
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->Marker( pos, aHoleListBuffer[ii].m_Hole_Diameter,
|
2011-09-07 19:41:04 +00:00
|
|
|
aHoleListBuffer[ii].m_Tool_Reference - 1 );
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
if( aHoleListBuffer[ii].m_Hole_Shape != 0 )
|
2008-01-18 15:47:15 +00:00
|
|
|
{
|
|
|
|
wxSize oblong_size;
|
2011-08-19 13:08:24 +00:00
|
|
|
oblong_size = aHoleListBuffer[ii].m_Hole_Size;
|
2012-05-03 18:37:56 +00:00
|
|
|
aPlotter->FlashPadOval( pos, oblong_size,
|
|
|
|
aHoleListBuffer[ii].m_Hole_Orient, LINE );
|
2009-08-29 10:20:48 +00:00
|
|
|
}
|
2008-01-18 15:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a list of drill values and drill count
|
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
void GenDrillReportFile( FILE* aFile, BOARD* aPcb,
|
|
|
|
const wxString& aBoardFilename,
|
|
|
|
bool aUnit_Drill_is_Inch,
|
|
|
|
std::vector<HOLE_INFO>& aHoleListBuffer,
|
|
|
|
std::vector<DRILL_TOOL>& aToolListBuffer )
|
2008-01-18 15:47:15 +00:00
|
|
|
{
|
|
|
|
unsigned TotalHoleCount;
|
|
|
|
char line[1024];
|
2009-12-07 03:46:13 +00:00
|
|
|
int layer1 = LAYER_N_BACK;
|
|
|
|
int layer2 = LAYER_N_FRONT;
|
2008-01-25 16:47:36 +00:00
|
|
|
bool gen_through_holes = true;
|
2011-08-19 13:08:24 +00:00
|
|
|
bool gen_NPTH_holes = false;
|
2008-01-25 16:47:36 +00:00
|
|
|
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
fprintf( aFile, "Drill report for %s\n", TO_UTF8( aBoardFilename ) );
|
2011-11-08 16:37:25 +00:00
|
|
|
fprintf( aFile, "Created on %s\n", TO_UTF8( DateAndTime() ) );
|
2008-01-18 15:47:15 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// List which Drill Unit option had been selected for the associated
|
|
|
|
// drill aFile.
|
2008-01-18 15:47:15 +00:00
|
|
|
if( aUnit_Drill_is_Inch )
|
2012-05-03 18:37:56 +00:00
|
|
|
fputs( "Selected Drill Unit: Imperial (inches)\n\n", aFile );
|
2008-01-18 15:47:15 +00:00
|
|
|
else
|
|
|
|
fputs( "Selected Drill Unit: Metric (mm)\n\n", aFile );
|
|
|
|
|
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
|
|
|
{
|
2008-01-25 16:47:36 +00:00
|
|
|
Build_Holes_List( aPcb,
|
|
|
|
aHoleListBuffer,
|
|
|
|
aToolListBuffer,
|
|
|
|
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
|
|
|
|
|
|
|
TotalHoleCount = 0;
|
|
|
|
|
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 )
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2012-05-03 18:37:56 +00:00
|
|
|
sprintf( line, "Drill report for plated through holes :\n" );
|
2008-03-22 05:55:06 +00:00
|
|
|
}
|
2008-01-18 15:47:15 +00:00
|
|
|
else
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
if( layer1 == LAYER_N_BACK ) // First partial hole list
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2009-08-29 10:20:48 +00:00
|
|
|
sprintf( line, "Drill report for buried and blind vias :\n\n" );
|
2008-03-22 05:55:06 +00:00
|
|
|
fputs( line, aFile );
|
|
|
|
}
|
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
sprintf( line, "Drill report for holes from layer %s to layer %s :\n",
|
2011-09-07 19:41:04 +00:00
|
|
|
TO_UTF8( aPcb->GetLayerName( layer1 ) ),
|
|
|
|
TO_UTF8( aPcb->GetLayerName( layer2 ) ) );
|
2008-03-22 05:55:06 +00:00
|
|
|
}
|
2008-01-25 16:47:36 +00:00
|
|
|
|
2008-01-18 15:47:15 +00:00
|
|
|
fputs( line, aFile );
|
|
|
|
|
2008-01-25 16:47:36 +00:00
|
|
|
for( unsigned ii = 0; ii < aToolListBuffer.size(); ii++ )
|
|
|
|
{
|
|
|
|
// List the tool number assigned to each drill,
|
|
|
|
// then its diameter in the selected Drill Unit,
|
|
|
|
// and then its diameter in the other Drill Unit.
|
|
|
|
if( aUnit_Drill_is_Inch )
|
2012-05-03 18:37:56 +00:00
|
|
|
{
|
2008-01-25 16:47:36 +00:00
|
|
|
sprintf( line, "T%d %2.3f\" %2.2fmm ",
|
|
|
|
ii + 1,
|
2012-05-03 18:37:56 +00:00
|
|
|
diameter_in_inches( aToolListBuffer[ii].m_Diameter ),
|
|
|
|
diameter_in_mm( aToolListBuffer[ii].m_Diameter ) );
|
|
|
|
}
|
2008-01-25 16:47:36 +00:00
|
|
|
else
|
2012-05-03 18:37:56 +00:00
|
|
|
{
|
2008-01-25 16:47:36 +00:00
|
|
|
sprintf( line, "T%d %2.2fmm %2.3f\" ",
|
|
|
|
ii + 1,
|
2012-05-03 18:37:56 +00:00
|
|
|
diameter_in_mm( aToolListBuffer[ii].m_Diameter ),
|
|
|
|
diameter_in_inches( aToolListBuffer[ii].m_Diameter ) );
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-01-25 16:47:36 +00:00
|
|
|
fputs( line, aFile );
|
|
|
|
|
|
|
|
// Now list how many holes and ovals are associated with each drill.
|
|
|
|
if( ( aToolListBuffer[ii].m_TotalCount == 1 )
|
|
|
|
&& ( aToolListBuffer[ii].m_OvalCount == 0 ) )
|
|
|
|
sprintf( line, "(1 hole)\n" );
|
|
|
|
else if( aToolListBuffer[ii].m_TotalCount == 1 )
|
2012-05-03 18:37:56 +00:00
|
|
|
sprintf( line, "(1 hole) (with 1 slot)\n" );
|
2008-01-25 16:47:36 +00:00
|
|
|
else if( aToolListBuffer[ii].m_OvalCount == 0 )
|
2011-09-07 19:41:04 +00:00
|
|
|
sprintf( line, "(%d holes)\n", aToolListBuffer[ii].m_TotalCount );
|
2008-01-25 16:47:36 +00:00
|
|
|
else if( aToolListBuffer[ii].m_OvalCount == 1 )
|
2012-05-03 18:37:56 +00:00
|
|
|
sprintf( line, "(%d holes) (with 1 slot)\n", aToolListBuffer[ii].m_TotalCount );
|
2008-01-25 16:47:36 +00:00
|
|
|
else // if ( buffer[ii]m_OvalCount > 1 )
|
2012-05-03 18:37:56 +00:00
|
|
|
sprintf( line, "(%d holes) (with %d slots)\n",
|
2008-01-25 16:47:36 +00:00
|
|
|
aToolListBuffer[ii].m_TotalCount,
|
|
|
|
aToolListBuffer[ii].m_OvalCount );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-01-25 16:47:36 +00:00
|
|
|
fputs( line, aFile );
|
|
|
|
|
|
|
|
TotalHoleCount += aToolListBuffer[ii].m_TotalCount;
|
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
if( gen_NPTH_holes )
|
2012-05-03 18:37:56 +00:00
|
|
|
sprintf( line, "\nTotal unplated holes count %d\n\n\n", TotalHoleCount );
|
2011-08-19 13:08:24 +00:00
|
|
|
else
|
2012-05-03 18:37:56 +00:00
|
|
|
sprintf( line, "\nTotal plated holes count %d\n\n\n", TotalHoleCount );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-01-18 15:47:15 +00:00
|
|
|
fputs( line, aFile );
|
|
|
|
|
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
|
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
if( aPcb->GetCopperLayerCount() <= 2 )
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
layer1++; layer2++; // use next layer pair
|
|
|
|
|
|
|
|
if( layer2 == aPcb->GetCopperLayerCount() - 1 )
|
|
|
|
layer2 = LAYER_N_FRONT; // the last layer is always the
|
|
|
|
// component layer
|
|
|
|
}
|
|
|
|
gen_through_holes = false;
|
2008-01-25 16:47:36 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-18 15:47:15 +00:00
|
|
|
|
|
|
|
fclose( aFile );
|
|
|
|
}
|