Commit c425aeb3 authored by dickelbeck's avatar dickelbeck

svn ps svn:eol-style native

parent a3ea4268
/*************************************************************************/ /*************************************************************************/
/* Functions to create drill data used to create aFiles and report aFiles */ /* Functions to create drill data used to create aFiles and report aFiles */
/*************************************************************************/ /*************************************************************************/
#include "fctsys.h" #include "fctsys.h"
using namespace std; using namespace std;
#include <vector> #include <vector>
#include "common.h" #include "common.h"
#include "plot_common.h" #include "plot_common.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "pcbplot.h" #include "pcbplot.h"
#include "macros.h" #include "macros.h"
#include "gendrill.h" #include "gendrill.h"
static void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int format ); static void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int format );
static void PlotOvalDrillSymbol( const wxPoint& position, static void PlotOvalDrillSymbol( const wxPoint& position,
const wxSize& size, const wxSize& size,
int orient, int orient,
int format ); int format );
/**********************************************************************************/ /**********************************************************************************/
void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, wxSize aSheetSize, void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, wxSize aSheetSize,
std::vector<HOLE_INFO> aHoleListBuffer, std::vector<HOLE_INFO> aHoleListBuffer,
std::vector<DRILL_TOOL> aToolListBuffer, std::vector<DRILL_TOOL> aToolListBuffer,
bool aUnit_Drill_is_Inch, int format ) bool aUnit_Drill_is_Inch, int format )
/**********************************************************************************/ /**********************************************************************************/
/* Genere le plan de percage (Drill map) format HPGL ou POSTSCRIPT /* Genere le plan de percage (Drill map) format HPGL ou POSTSCRIPT
*/ */
{ {
unsigned ii; unsigned ii;
int x, y; int x, y;
int plotX, plotY, TextWidth; int plotX, plotY, TextWidth;
int intervalle = 0, CharSize = 0; int intervalle = 0, CharSize = 0;
EDA_BaseStruct* PtStruct; EDA_BaseStruct* PtStruct;
int old_g_PlotOrient = g_PlotOrient; int old_g_PlotOrient = g_PlotOrient;
char line[1024]; char line[1024];
int dX, dY; int dX, dY;
wxPoint BoardCentre; wxPoint BoardCentre;
int PlotMarge_in_mils = 400; // Margin in 1/1000 inch int PlotMarge_in_mils = 400; // Margin in 1/1000 inch
int marge = PlotMarge_in_mils * U_PCB; int marge = PlotMarge_in_mils * U_PCB;
wxSize SheetSize; wxSize SheetSize;
float fTextScale = 1.0; float fTextScale = 1.0;
double scale_x = 1.0, scale_y = 1.0; double scale_x = 1.0, scale_y = 1.0;
Ki_PageDescr* SheetPS = NULL; Ki_PageDescr* SheetPS = NULL;
wxString msg; wxString msg;
setlocale( LC_NUMERIC, "C" ); // Use the standard notation for float numbers setlocale( LC_NUMERIC, "C" ); // Use the standard notation for float numbers
g_PlotOrient = 0; g_PlotOrient = 0;
/* calcul des dimensions et centre du PCB */ /* calcul des dimensions et centre du PCB */
aPcb->ComputeBoundaryBox(); aPcb->ComputeBoundaryBox();
dX = aPcb->m_BoundaryBox.GetWidth(); dX = aPcb->m_BoundaryBox.GetWidth();
dY = aPcb->m_BoundaryBox.GetHeight(); dY = aPcb->m_BoundaryBox.GetHeight();
BoardCentre = aPcb->m_BoundaryBox.Centre(); BoardCentre = aPcb->m_BoundaryBox.Centre();
// Calcul de l'echelle du dessin du PCB, // Calcul de l'echelle du dessin du PCB,
// Echelle 1 en HPGL, dessin sur feuille A4 en PS, + texte description des symboles // Echelle 1 en HPGL, dessin sur feuille A4 en PS, + texte description des symboles
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: /* Calcul des echelles de conversion format HPGL */ case PLOT_FORMAT_HPGL: /* Calcul des echelles de conversion format HPGL */
Scale_X = Scale_Y = 1.0; Scale_X = Scale_Y = 1.0;
scale_x = Scale_X * SCALE_HPGL; scale_x = Scale_X * SCALE_HPGL;
scale_y = Scale_Y * SCALE_HPGL; scale_y = Scale_Y * SCALE_HPGL;
fTextScale = SCALE_HPGL; fTextScale = SCALE_HPGL;
SheetSize = aSheetSize; SheetSize = aSheetSize;
SheetSize.x *= U_PCB; SheetSize.x *= U_PCB;
SheetSize.y *= U_PCB; SheetSize.y *= U_PCB;
g_PlotOffset.x = 0; g_PlotOffset.x = 0;
g_PlotOffset.y = (int) (SheetSize.y * scale_y); g_PlotOffset.y = (int) (SheetSize.y * scale_y);
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
{ {
// calcul en unites internes des dimensions de la feuille ( connues en 1/1000 pouce ) // calcul en unites internes des dimensions de la feuille ( connues en 1/1000 pouce )
SheetPS = &g_Sheet_A4; SheetPS = &g_Sheet_A4;
SheetSize.x = SheetPS->m_Size.x * U_PCB; SheetSize.x = SheetPS->m_Size.x * U_PCB;
SheetSize.y = SheetPS->m_Size.y * U_PCB; SheetSize.y = SheetPS->m_Size.y * U_PCB;
float Xscale = (float) ( SheetSize.x - (marge * 2) ) / dX; float Xscale = (float) ( SheetSize.x - (marge * 2) ) / dX;
float Yscale = (float) ( SheetSize.y * 0.6 - (marge * 2) ) / dY; float Yscale = (float) ( SheetSize.y * 0.6 - (marge * 2) ) / dY;
scale_x = scale_y = MIN( Xscale, Yscale ); scale_x = scale_y = MIN( Xscale, Yscale );
g_PlotOffset.x = -(SheetSize.x / 2) + g_PlotOffset.x = -(SheetSize.x / 2) +
(int) (BoardCentre.x * scale_x) + marge; (int) (BoardCentre.x * scale_x) + marge;
g_PlotOffset.y = SheetSize.y / 2 + g_PlotOffset.y = SheetSize.y / 2 +
(int) (BoardCentre.y * scale_y) - marge; (int) (BoardCentre.y * scale_y) - marge;
g_PlotOffset.y += SheetSize.y / 8; /* decalage pour legende */ g_PlotOffset.y += SheetSize.y / 8; /* decalage pour legende */
break; break;
} }
default: default:
break; break;
} }
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
InitPlotParametresHPGL( g_PlotOffset, scale_x, scale_y ); InitPlotParametresHPGL( g_PlotOffset, scale_x, scale_y );
PrintHeaderHPGL( aFile, g_HPGL_Pen_Speed, g_HPGL_Pen_Num ); PrintHeaderHPGL( aFile, g_HPGL_Pen_Speed, g_HPGL_Pen_Num );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
{ {
int BBox[4]; int BBox[4];
BBox[0] = BBox[1] = PlotMarge_in_mils; BBox[0] = BBox[1] = PlotMarge_in_mils;
BBox[2] = SheetPS->m_Size.x - PlotMarge_in_mils; BBox[2] = SheetPS->m_Size.x - PlotMarge_in_mils;
BBox[3] = SheetPS->m_Size.y - PlotMarge_in_mils; BBox[3] = SheetPS->m_Size.y - PlotMarge_in_mils;
InitPlotParametresPS( g_PlotOffset, InitPlotParametresPS( g_PlotOffset,
SheetPS, SheetPS,
(double) 1.0 / PCB_INTERNAL_UNIT, (double) 1.0 / PCB_INTERNAL_UNIT,
(double) 1.0 / PCB_INTERNAL_UNIT ); (double) 1.0 / PCB_INTERNAL_UNIT );
SetDefaultLineWidthPS( 10 ); // Set line with to 10/1000 inch SetDefaultLineWidthPS( 10 ); // Set line with to 10/1000 inch
PrintHeaderPS( aFile, wxT( "PCBNEW-PS" ), aFullFileName, 1, BBox, wxLANDSCAPE ); PrintHeaderPS( aFile, wxT( "PCBNEW-PS" ), aFullFileName, 1, BBox, wxLANDSCAPE );
InitPlotParametresPS( g_PlotOffset, SheetPS, scale_x, scale_y ); InitPlotParametresPS( g_PlotOffset, SheetPS, scale_x, scale_y );
} }
break; break;
default: default:
break; break;
} }
/* Draw items on edge layer */ /* Draw items on edge layer */
PtStruct = aPcb->m_Drawings; PtStruct = aPcb->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{ {
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPEDRAWSEGMENT:
PlotDrawSegment( (DRAWSEGMENT*) PtStruct, format, EDGE_LAYER ); PlotDrawSegment( (DRAWSEGMENT*) PtStruct, format, EDGE_LAYER );
break; break;
case TYPETEXTE: case TYPETEXTE:
PlotTextePcb( (TEXTE_PCB*) PtStruct, format, EDGE_LAYER ); PlotTextePcb( (TEXTE_PCB*) PtStruct, format, EDGE_LAYER );
break; break;
case TYPECOTATION: case TYPECOTATION:
PlotCotation( (COTATION*) PtStruct, format, EDGE_LAYER ); PlotCotation( (COTATION*) PtStruct, format, EDGE_LAYER );
break; break;
case TYPEMIRE: case TYPEMIRE:
PlotMirePcb( (MIREPCB*) PtStruct, format, EDGE_LAYER ); PlotMirePcb( (MIREPCB*) PtStruct, format, EDGE_LAYER );
break; break;
case TYPEMARKER: // do not draw case TYPEMARKER: // do not draw
break; break;
default: default:
DisplayError( NULL, wxT( "WinEDA_DrillFrame::GenDrillMap() : Unexpected Draw Type" ) ); DisplayError( NULL, wxT( "WinEDA_DrillFrame::GenDrillMap() : Unexpected Draw Type" ) );
break; break;
} }
} }
TextWidth = 50; // Set Drill Symbols width in 1/10000 mils TextWidth = 50; // Set Drill Symbols width in 1/10000 mils
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
{ {
sprintf( line, "%d setlinewidth\n", TextWidth ); sprintf( line, "%d setlinewidth\n", TextWidth );
fputs( line, aFile ); fputs( line, aFile );
} }
Gen_Drill_PcbMap( aPcb, aFile, aHoleListBuffer, aToolListBuffer, format ); Gen_Drill_PcbMap( aPcb, aFile, aHoleListBuffer, aToolListBuffer, format );
/* Impression de la liste des symboles utilises */ /* Impression de la liste des symboles utilises */
CharSize = 800; /* text size in 1/10000 mils */ CharSize = 800; /* text size in 1/10000 mils */
float CharScale = 1.0 / scale_x; /* real scale will be CharScale * scale_x, float CharScale = 1.0 / scale_x; /* real scale will be CharScale * scale_x,
* because the global plot scale is scale_x */ * because the global plot scale is scale_x */
TextWidth = (int) (50 * CharScale); // Set text width TextWidth = (int) (50 * CharScale); // Set text width
intervalle = (int) (CharSize * CharScale) + TextWidth; intervalle = (int) (CharSize * CharScale) + TextWidth;
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
{ {
/* generation des dim: commande SI x,y; x et y = dim en cm */ /* generation des dim: commande SI x,y; x et y = dim en cm */
char csize[256]; char csize[256];
sprintf( csize, "%2.3f", (float) CharSize * CharScale * 0.000254 ); sprintf( csize, "%2.3f", (float) CharSize * CharScale * 0.000254 );
sprintf( line, "SI %s, %s;\n", csize, csize ); sprintf( line, "SI %s, %s;\n", csize, csize );
break; break;
} }
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
/* Reglage de l'epaisseur de traits des textes */ /* Reglage de l'epaisseur de traits des textes */
sprintf( line, "%d setlinewidth\n", TextWidth ); sprintf( line, "%d setlinewidth\n", TextWidth );
break; break;
default: default:
*line = 0; *line = 0;
break; break;
} }
fputs( line, aFile ); fputs( line, aFile );
switch( format ) switch( format )
{ {
default: default:
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
g_PlotOffset.x = 0; g_PlotOffset.x = 0;
g_PlotOffset.y = 0; g_PlotOffset.y = 0;
InitPlotParametresPS( g_PlotOffset, SheetPS, scale_x, scale_x ); InitPlotParametresPS( g_PlotOffset, SheetPS, scale_x, scale_x );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
InitPlotParametresHPGL( g_PlotOffset, scale_x, scale_x ); InitPlotParametresHPGL( g_PlotOffset, scale_x, scale_x );
break; break;
} }
/* Trace des informations */ /* Trace des informations */
/* Trace de "Infos" */ /* Trace de "Infos" */
plotX = marge + 1000; plotX = marge + 1000;
plotY = CharSize + 1000; plotY = CharSize + 1000;
x = plotX; y = plotY; x = plotX; y = plotY;
x = +g_PlotOffset.x + (int) (x * fTextScale); x = +g_PlotOffset.x + (int) (x * fTextScale);
y = g_PlotOffset.y - (int) (y * fTextScale); y = g_PlotOffset.y - (int) (y * fTextScale);
plotY += (int) ( intervalle * 1.2) + 200; plotY += (int) ( intervalle * 1.2) + 200;
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
sprintf( line, "PU %d, %d; LBInfos\03;\n", sprintf( line, "PU %d, %d; LBInfos\03;\n",
x + (int) (intervalle * CharScale * fTextScale), x + (int) (intervalle * CharScale * fTextScale),
y - (int) (CharSize / 2 * CharScale * fTextScale) ); y - (int) (CharSize / 2 * CharScale * fTextScale) );
fputs( line, aFile ); fputs( line, aFile );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
wxString Text = wxT( "Infos" ); wxString Text = wxT( "Infos" );
Plot_1_texte( format, Text, 0, TextWidth, Plot_1_texte( format, Text, 0, TextWidth,
x, y, x, y,
(int) (CharSize * CharScale), (int) (CharSize * CharScale), (int) (CharSize * CharScale), (int) (CharSize * CharScale),
FALSE ); FALSE );
break; break;
} }
for( ii = 0; ii < aToolListBuffer.size(); ii++ ) for( ii = 0; ii < aToolListBuffer.size(); ii++ )
{ {
int plot_diam; int plot_diam;
if( aToolListBuffer[ii].m_TotalCount == 0 ) if( aToolListBuffer[ii].m_TotalCount == 0 )
continue; continue;
plot_diam = (int) (aToolListBuffer[ii].m_Diameter); plot_diam = (int) (aToolListBuffer[ii].m_Diameter);
x = plotX; y = plotY; x = plotX; y = plotY;
x = -g_PlotOffset.x + (int) (x * fTextScale); x = -g_PlotOffset.x + (int) (x * fTextScale);
y = g_PlotOffset.y - (int) (y * fTextScale); y = g_PlotOffset.y - (int) (y * fTextScale);
PlotDrillSymbol( wxPoint( x, y ), plot_diam, ii, format ); PlotDrillSymbol( wxPoint( x, y ), plot_diam, ii, format );
intervalle = (int) (CharSize * CharScale) + TextWidth; intervalle = (int) (CharSize * CharScale) + TextWidth;
intervalle = (int) ( intervalle * 1.2); intervalle = (int) ( intervalle * 1.2);
if( intervalle < (plot_diam + 200 + TextWidth) ) if( intervalle < (plot_diam + 200 + TextWidth) )
intervalle = plot_diam + 200 + TextWidth; intervalle = plot_diam + 200 + TextWidth;
int rayon = plot_diam / 2; int rayon = plot_diam / 2;
x = plotX + rayon + (int) (CharSize * CharScale); y = plotY; x = plotX + rayon + (int) (CharSize * CharScale); y = plotY;
x = -g_PlotOffset.x + (int) (x * fTextScale); x = -g_PlotOffset.x + (int) (x * fTextScale);
y = g_PlotOffset.y - (int) (y * fTextScale); y = g_PlotOffset.y - (int) (y * fTextScale);
/* Trace de la legende associee */ /* Trace de la legende associee */
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
// List the diameter of each drill in the selected Drill Unit, // List the diameter of each drill in the selected Drill Unit,
// and then its diameter in the other Drill Unit. // and then its diameter in the other Drill Unit.
if( aUnit_Drill_is_Inch ) if( aUnit_Drill_is_Inch )
sprintf( line, "PU %d, %d; LB%2.3f\" / %2.2fmm ", sprintf( line, "PU %d, %d; LB%2.3f\" / %2.2fmm ",
x + (int) (intervalle * CharScale * fTextScale), x + (int) (intervalle * CharScale * fTextScale),
y - (int) (CharSize / 2 * CharScale * fTextScale), y - (int) (CharSize / 2 * CharScale * fTextScale),
float (aToolListBuffer[ii].m_Diameter) * 0.0001, float (aToolListBuffer[ii].m_Diameter) * 0.0001,
float (aToolListBuffer[ii].m_Diameter) * 0.00254 ); float (aToolListBuffer[ii].m_Diameter) * 0.00254 );
else else
sprintf( line, "PU %d, %d; LB%2.2fmm / %2.3f\" ", sprintf( line, "PU %d, %d; LB%2.2fmm / %2.3f\" ",
x + (int) (intervalle * CharScale * fTextScale), x + (int) (intervalle * CharScale * fTextScale),
y - (int) (CharSize / 2 * CharScale * fTextScale), y - (int) (CharSize / 2 * CharScale * fTextScale),
float (aToolListBuffer[ii].m_Diameter) * 0.00254, float (aToolListBuffer[ii].m_Diameter) * 0.00254,
float (aToolListBuffer[ii].m_Diameter) * 0.0001 ); float (aToolListBuffer[ii].m_Diameter) * 0.0001 );
fputs( line, aFile ); fputs( line, aFile );
// Now list how many holes and ovals are associated with each drill. // Now list how many holes and ovals are associated with each drill.
if( ( aToolListBuffer[ii].m_TotalCount == 1 ) && if( ( aToolListBuffer[ii].m_TotalCount == 1 ) &&
( aToolListBuffer[ii].m_OvalCount == 0 ) ) ( aToolListBuffer[ii].m_OvalCount == 0 ) )
sprintf( line, "(1 hole)\n" ); sprintf( line, "(1 hole)\n" );
else if( aToolListBuffer[ii].m_TotalCount == 1 ) // && ( buffer[ii]m_OvalCount == 1 ) else if( aToolListBuffer[ii].m_TotalCount == 1 ) // && ( buffer[ii]m_OvalCount == 1 )
sprintf( line, "(1 hole) (with 1 oblong)\n" ); sprintf( line, "(1 hole) (with 1 oblong)\n" );
else if( aToolListBuffer[ii].m_OvalCount == 0 ) else if( aToolListBuffer[ii].m_OvalCount == 0 )
sprintf( line, "(%d holes)\n", sprintf( line, "(%d holes)\n",
aToolListBuffer[ii].m_TotalCount ); aToolListBuffer[ii].m_TotalCount );
else if( aToolListBuffer[ii].m_OvalCount == 1 ) else if( aToolListBuffer[ii].m_OvalCount == 1 )
sprintf( line, "(%d holes) (with 1 oblong)\n", sprintf( line, "(%d holes) (with 1 oblong)\n",
aToolListBuffer[ii].m_TotalCount ); aToolListBuffer[ii].m_TotalCount );
else // if ( aToolListBuffer[ii]m_OvalCount > 1 ) else // if ( aToolListBuffer[ii]m_OvalCount > 1 )
sprintf( line, "(%d holes) (with %d oblongs)\n", sprintf( line, "(%d holes) (with %d oblongs)\n",
aToolListBuffer[ii].m_TotalCount, aToolListBuffer[ii].m_TotalCount,
aToolListBuffer[ii].m_OvalCount ); aToolListBuffer[ii].m_OvalCount );
fputs( line, aFile ); fputs( line, aFile );
fputs( "\03;\n", aFile ); fputs( "\03;\n", aFile );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
// List the diameter of each drill in the selected Drill Unit, // List the diameter of each drill in the selected Drill Unit,
// and then its diameter in the other Drill Unit. // and then its diameter in the other Drill Unit.
if( aUnit_Drill_is_Inch ) if( aUnit_Drill_is_Inch )
sprintf( line, "%2.3f\" / %2.2fmm ", sprintf( line, "%2.3f\" / %2.2fmm ",
float (aToolListBuffer[ii].m_Diameter) * 0.0001, float (aToolListBuffer[ii].m_Diameter) * 0.0001,
float (aToolListBuffer[ii].m_Diameter) * 0.00254 ); float (aToolListBuffer[ii].m_Diameter) * 0.00254 );
else else
sprintf( line, "%2.2fmm / %2.3f\" ", sprintf( line, "%2.2fmm / %2.3f\" ",
float (aToolListBuffer[ii].m_Diameter) * 0.00254, float (aToolListBuffer[ii].m_Diameter) * 0.00254,
float (aToolListBuffer[ii].m_Diameter) * 0.0001 ); float (aToolListBuffer[ii].m_Diameter) * 0.0001 );
msg = CONV_FROM_UTF8( line ); msg = CONV_FROM_UTF8( line );
// Now list how many holes and ovals are associated with each drill. // Now list how many holes and ovals are associated with each drill.
if( ( aToolListBuffer[ii].m_TotalCount == 1 ) && if( ( aToolListBuffer[ii].m_TotalCount == 1 ) &&
( aToolListBuffer[ii].m_OvalCount == 0 ) ) ( aToolListBuffer[ii].m_OvalCount == 0 ) )
sprintf( line, "(1 hole)" ); sprintf( line, "(1 hole)" );
else if( aToolListBuffer[ii].m_TotalCount == 1 ) // && ( aToolListBuffer[ii]m_OvalCount == 1 ) else if( aToolListBuffer[ii].m_TotalCount == 1 ) // && ( aToolListBuffer[ii]m_OvalCount == 1 )
sprintf( line, "(1 hole) (with 1 oblong)" ); sprintf( line, "(1 hole) (with 1 oblong)" );
else if( aToolListBuffer[ii].m_OvalCount == 0 ) else if( aToolListBuffer[ii].m_OvalCount == 0 )
sprintf( line, "(%d holes)", sprintf( line, "(%d holes)",
aToolListBuffer[ii].m_TotalCount ); aToolListBuffer[ii].m_TotalCount );
else if( aToolListBuffer[ii].m_OvalCount == 1 ) else if( aToolListBuffer[ii].m_OvalCount == 1 )
sprintf( line, "(%d holes) (with 1 oblong)", sprintf( line, "(%d holes) (with 1 oblong)",
aToolListBuffer[ii].m_TotalCount ); aToolListBuffer[ii].m_TotalCount );
else // if ( aToolListBuffer[ii]m_OvalCount > 1 ) else // if ( aToolListBuffer[ii]m_OvalCount > 1 )
sprintf( line, "(%d holes) (with %d oblongs)", sprintf( line, "(%d holes) (with %d oblongs)",
aToolListBuffer[ii].m_TotalCount, aToolListBuffer[ii].m_TotalCount,
aToolListBuffer[ii].m_OvalCount ); aToolListBuffer[ii].m_OvalCount );
msg += CONV_FROM_UTF8( line ); msg += CONV_FROM_UTF8( line );
Plot_1_texte( format, msg, 0, TextWidth, Plot_1_texte( format, msg, 0, TextWidth,
x, y, x, y,
(int) (CharSize * CharScale), (int) (CharSize * CharScale),
(int) (CharSize * CharScale), (int) (CharSize * CharScale),
FALSE ); FALSE );
break; break;
} }
plotY += intervalle; plotY += intervalle;
} }
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
CloseFileHPGL( aFile ); CloseFileHPGL( aFile );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
CloseFilePS( aFile ); CloseFilePS( aFile );
break; break;
} }
setlocale( LC_NUMERIC, "" ); // Revert to local notation for float numbers setlocale( LC_NUMERIC, "" ); // Revert to local notation for float numbers
g_PlotOrient = old_g_PlotOrient; g_PlotOrient = old_g_PlotOrient;
} }
/****************************************************************************************/ /****************************************************************************************/
void Gen_Drill_PcbMap( BOARD* aPcb, FILE* aFile, void Gen_Drill_PcbMap( BOARD* aPcb, FILE* aFile,
std::vector<HOLE_INFO>& aHoleListBuffer, std::vector<HOLE_INFO>& aHoleListBuffer,
std::vector<DRILL_TOOL>& aToolListBuffer, std::vector<DRILL_TOOL>& aToolListBuffer,
int format ) int format )
/****************************************************************************************/ /****************************************************************************************/
/** Creates the drill map aFile in HPGL or POSTSCRIPT format /** Creates the drill map aFile in HPGL or POSTSCRIPT format
* @param aPcb BOARD * @param aPcb BOARD
* @param aFile = output aFile * @param aFile = output aFile
* @param aHoleListBuffer = std::vector<HOLE_INFO> list of holes descriptors * @param aHoleListBuffer = std::vector<HOLE_INFO> list of holes descriptors
* @param aToolListBuffer = std::vector<DRILL_TOOL> drill list buffer * @param aToolListBuffer = std::vector<DRILL_TOOL> drill list buffer
* @param format = ouput format (hpgl / ps) * @param format = ouput format (hpgl / ps)
*/ */
{ {
wxPoint pos; wxPoint pos;
/* create the drill list */ /* create the drill list */
if( aToolListBuffer.size() > 13 ) if( aToolListBuffer.size() > 13 )
{ {
DisplayInfo( NULL, DisplayInfo( NULL,
_( _(
" Drill map: Too many diameter values to draw to draw one symbol per drill value (max 13)\nPlot uses circle shape for some drill values" ), " Drill map: Too many diameter values to draw to draw one symbol per drill value (max 13)\nPlot uses circle shape for some drill values" ),
10 ); 10 );
} }
// Plot the drill map: // Plot the drill map:
for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ ) for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ )
{ {
pos.x = aHoleListBuffer[ii].m_Hole_Pos_X; pos.x = aHoleListBuffer[ii].m_Hole_Pos_X;
pos.y = aHoleListBuffer[ii].m_Hole_Pos_Y; pos.y = aHoleListBuffer[ii].m_Hole_Pos_Y;
if( aHoleListBuffer[ii].m_Hole_Shape == 0 ) if( aHoleListBuffer[ii].m_Hole_Shape == 0 )
{ {
PlotDrillSymbol( pos, aHoleListBuffer[ii].m_Hole_Diameter, PlotDrillSymbol( pos, aHoleListBuffer[ii].m_Hole_Diameter,
aHoleListBuffer[ii].m_Tool_Reference - 1, aHoleListBuffer[ii].m_Tool_Reference - 1,
format ); format );
} }
else else
{ {
wxSize oblong_size; wxSize oblong_size;
oblong_size.x = aHoleListBuffer[ii].m_Hole_SizeX; oblong_size.x = aHoleListBuffer[ii].m_Hole_SizeX;
oblong_size.y = aHoleListBuffer[ii].m_Hole_SizeY; oblong_size.y = aHoleListBuffer[ii].m_Hole_SizeY;
PlotOvalDrillSymbol( pos, oblong_size, aHoleListBuffer[ii].m_Hole_Orient, format ); PlotOvalDrillSymbol( pos, oblong_size, aHoleListBuffer[ii].m_Hole_Orient, format );
} }
} }
} }
/************************************************************************************/ /************************************************************************************/
void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int format ) void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int format )
/************************************************************************************/ /************************************************************************************/
/* Trace un motif de numero de forme aShapeId, aux coord x0, y0. /* Trace un motif de numero de forme aShapeId, aux coord x0, y0.
* x0, y0 = coordonnees tables * x0, y0 = coordonnees tables
* diametre = diametre (coord table) du trou * diametre = diametre (coord table) du trou
* aShapeId = index ( permet de generer des formes caract ) * aShapeId = index ( permet de generer des formes caract )
*/ */
{ {
int rayon = diametre / 2; int rayon = diametre / 2;
void (*FctPlume)( wxPoint pos, int state ); void (*FctPlume)( wxPoint pos, int state );
int x0, y0; int x0, y0;
x0 = position.x; y0 = position.y; x0 = position.x; y0 = position.y;
FctPlume = Move_Plume_HPGL; FctPlume = Move_Plume_HPGL;
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
FctPlume = LineTo_PS; FctPlume = LineTo_PS;
switch( aShapeId ) switch( aShapeId )
{ {
case 0: /* vias : forme en X */ case 0: /* vias : forme en X */
FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' ); FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' ); FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' ); FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' ); FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' );
break; break;
case 1: /* Cercle */ case 1: /* Cercle */
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
case 2: /* forme en + */ case 2: /* forme en + */
FctPlume( wxPoint( x0, y0 - rayon ), 'U' ); FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0, y0 + rayon ), 'D' ); FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 ), 'U' ); FctPlume( wxPoint( x0 + rayon, y0 ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 ), 'D' ); FctPlume( wxPoint( x0 - rayon, y0 ), 'D' );
break; break;
case 3: /* forme en X cercle */ case 3: /* forme en X cercle */
FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' ); FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' ); FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' ); FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' ); FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
case 4: /* forme en cercle barre de - */ case 4: /* forme en cercle barre de - */
FctPlume( wxPoint( x0 - rayon, y0 ), 'U' ); FctPlume( wxPoint( x0 - rayon, y0 ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 ), 'D' ); FctPlume( wxPoint( x0 + rayon, y0 ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
case 5: /* forme en cercle barre de | */ case 5: /* forme en cercle barre de | */
FctPlume( wxPoint( x0, y0 - rayon ), 'U' ); FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0, y0 + rayon ), 'D' ); FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
case 6: /* forme en carre */ case 6: /* forme en carre */
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 0, 0 ), 0,
FILAIRE ); FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 0, 0 ), 0,
FILAIRE ); FILAIRE );
break; break;
case 7: /* forme en losange */ case 7: /* forme en losange */
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450, 0 ), 450,
FILAIRE ); FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450, 0 ), 450,
FILAIRE ); FILAIRE );
break; break;
case 8: /* forme en carre barre par un X*/ case 8: /* forme en carre barre par un X*/
FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' ); FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' ); FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' ); FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' ); FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 0, 0 ), 0,
FILAIRE ); FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 0, 0 ), 0,
FILAIRE ); FILAIRE );
break; break;
case 9: /* forme en losange barre par un +*/ case 9: /* forme en losange barre par un +*/
FctPlume( wxPoint( x0, y0 - rayon ), 'U' ); FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0, y0 + rayon ), 'D' ); FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 ), 'U' ); FctPlume( wxPoint( x0 + rayon, y0 ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 ), 'D' ); FctPlume( wxPoint( x0 - rayon, y0 ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450, 0 ), 450,
FILAIRE ); FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450, 0 ), 450,
FILAIRE ); FILAIRE );
break; break;
case 10: /* forme en carre barre par un '/' */ case 10: /* forme en carre barre par un '/' */
FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' ); FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' ); FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 0, 0 ), 0,
FILAIRE ); FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 0, 0 ), 0,
FILAIRE ); FILAIRE );
break; break;
case 11: /* forme en losange barre par un |*/ case 11: /* forme en losange barre par un |*/
FctPlume( wxPoint( x0, y0 - rayon ), 'U' ); FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0, y0 + rayon ), 'D' ); FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450, 0 ), 450,
FILAIRE ); FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450, 0 ), 450,
FILAIRE ); FILAIRE );
break; break;
case 12: /* forme en losange barre par un -*/ case 12: /* forme en losange barre par un -*/
FctPlume( wxPoint( x0 - rayon, y0 ), 'U' ); FctPlume( wxPoint( x0 - rayon, y0 ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 ), 'D' ); FctPlume( wxPoint( x0 + rayon, y0 ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450, 0 ), 450,
FILAIRE ); FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0, trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450, 0 ), 450,
FILAIRE ); FILAIRE );
break; break;
default: default:
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
} }
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
Plume_HPGL( 'U' ); Plume_HPGL( 'U' );
} }
/*********************************************************************************************/ /*********************************************************************************************/
void PlotOvalDrillSymbol( const wxPoint& position, const wxSize& size, int orient, int format ) void PlotOvalDrillSymbol( const wxPoint& position, const wxSize& size, int orient, int format )
/*********************************************************************************************/ /*********************************************************************************************/
/* Draws an oblong hole. /* Draws an oblong hole.
* because functions to draw oblong shapes exist to draw oblong pads, Use they. * because functions to draw oblong shapes exist to draw oblong pads, Use they.
*/ */
{ {
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_pastille_OVALE_HPGL( position, size, orient, FILAIRE ); trace_1_pastille_OVALE_HPGL( position, size, orient, FILAIRE );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
trace_1_pastille_OVALE_POST( position, size, orient, FILAIRE ); trace_1_pastille_OVALE_POST( position, size, orient, FILAIRE );
break; break;
} }
} }
/**************************************************************************************************/ /**************************************************************************************************/
void GenDrillReportFile( FILE* aFile, const wxString& aBoardFilename, void GenDrillReportFile( FILE* aFile, const wxString& aBoardFilename,
std::vector<DRILL_TOOL>& aToolListBuffer, bool aUnit_Drill_is_Inch ) std::vector<DRILL_TOOL>& aToolListBuffer, bool aUnit_Drill_is_Inch )
/*************************************************************************************************/ /*************************************************************************************************/
/* /*
* Create a list of drill values and drill count * Create a list of drill values and drill count
*/ */
{ {
unsigned TotalHoleCount; unsigned TotalHoleCount;
char line[1024]; char line[1024];
fprintf( aFile, "Drill report for %s\n", CONV_TO_UTF8( aBoardFilename ) ); fprintf( aFile, "Drill report for %s\n", CONV_TO_UTF8( aBoardFilename ) );
fprintf( aFile, "Created on %s\n", DateAndTime( line ) ); fprintf( aFile, "Created on %s\n", DateAndTime( line ) );
// List which Drill Unit option had been selected for the associated drill aFile. // List which Drill Unit option had been selected for the associated drill aFile.
if( aUnit_Drill_is_Inch ) if( aUnit_Drill_is_Inch )
fputs( "Selected Drill Unit: Imperial (\")\n\n", aFile ); fputs( "Selected Drill Unit: Imperial (\")\n\n", aFile );
else else
fputs( "Selected Drill Unit: Metric (mm)\n\n", aFile ); fputs( "Selected Drill Unit: Metric (mm)\n\n", aFile );
TotalHoleCount = 0; TotalHoleCount = 0;
for( unsigned ii = 0; ii < aToolListBuffer.size(); ii++ ) for( unsigned ii = 0; ii < aToolListBuffer.size(); ii++ )
{ {
// List the tool number assigned to each drill, // List the tool number assigned to each drill,
// then its diameter in the selected Drill Unit, // then its diameter in the selected Drill Unit,
// and then its diameter in the other Drill Unit. // and then its diameter in the other Drill Unit.
if( aUnit_Drill_is_Inch ) if( aUnit_Drill_is_Inch )
sprintf( line, "T%d %2.3f\" %2.2fmm ", sprintf( line, "T%d %2.3f\" %2.2fmm ",
ii + 1, ii + 1,
float (aToolListBuffer[ii].m_Diameter) * 0.0001, float (aToolListBuffer[ii].m_Diameter) * 0.0001,
float (aToolListBuffer[ii].m_Diameter) * 0.00254 ); float (aToolListBuffer[ii].m_Diameter) * 0.00254 );
else else
sprintf( line, "T%d %2.2fmm %2.3f\" ", sprintf( line, "T%d %2.2fmm %2.3f\" ",
ii + 1, ii + 1,
float (aToolListBuffer[ii].m_Diameter) * 0.00254, float (aToolListBuffer[ii].m_Diameter) * 0.00254,
float (aToolListBuffer[ii].m_Diameter) * 0.0001 ); float (aToolListBuffer[ii].m_Diameter) * 0.0001 );
fputs( line, aFile ); fputs( line, aFile );
// Now list how many holes and ovals are associated with each drill. // Now list how many holes and ovals are associated with each drill.
if( ( aToolListBuffer[ii].m_TotalCount == 1 ) && ( aToolListBuffer[ii].m_OvalCount == 0 ) ) if( ( aToolListBuffer[ii].m_TotalCount == 1 ) && ( aToolListBuffer[ii].m_OvalCount == 0 ) )
sprintf( line, "(1 hole)\n" ); sprintf( line, "(1 hole)\n" );
else if( aToolListBuffer[ii].m_TotalCount == 1 ) else if( aToolListBuffer[ii].m_TotalCount == 1 )
sprintf( line, "(1 hole) (with 1 oblong)\n" ); sprintf( line, "(1 hole) (with 1 oblong)\n" );
else if( aToolListBuffer[ii].m_OvalCount == 0 ) else if( aToolListBuffer[ii].m_OvalCount == 0 )
sprintf( line, "(%d holes)\n", sprintf( line, "(%d holes)\n",
aToolListBuffer[ii].m_TotalCount ); aToolListBuffer[ii].m_TotalCount );
else if( aToolListBuffer[ii].m_OvalCount == 1 ) else if( aToolListBuffer[ii].m_OvalCount == 1 )
sprintf( line, "(%d holes) (with 1 oblong)\n", sprintf( line, "(%d holes) (with 1 oblong)\n",
aToolListBuffer[ii].m_TotalCount ); aToolListBuffer[ii].m_TotalCount );
else // if ( buffer[ii]m_OvalCount > 1 ) else // if ( buffer[ii]m_OvalCount > 1 )
sprintf( line, "(%d holes) (with %d oblongs)\n", sprintf( line, "(%d holes) (with %d oblongs)\n",
aToolListBuffer[ii].m_TotalCount, aToolListBuffer[ii].m_TotalCount,
aToolListBuffer[ii].m_OvalCount ); aToolListBuffer[ii].m_OvalCount );
fputs( line, aFile ); fputs( line, aFile );
TotalHoleCount += aToolListBuffer[ii].m_TotalCount; TotalHoleCount += aToolListBuffer[ii].m_TotalCount;
} }
sprintf( line, "\ntotal holes count %d\n", TotalHoleCount ); sprintf( line, "\ntotal holes count %d\n", TotalHoleCount );
fputs( line, aFile ); fputs( line, aFile );
fclose( aFile ); fclose( aFile );
} }
/*************************************************************************/ /*************************************************************************/
/* Functions to create drill data used to create files and report files */ /* Functions to create drill data used to create files and report files */
/*************************************************************************/ /*************************************************************************/
#include "fctsys.h" #include "fctsys.h"
using namespace std; using namespace std;
#include <vector> #include <vector>
#include "common.h" #include "common.h"
#include "plot_common.h" #include "plot_common.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "pcbplot.h" #include "pcbplot.h"
#include "macros.h" #include "macros.h"
#include "gendrill.h" #include "gendrill.h"
/* Local Functions */ /* Local Functions */
/* Compare function used for sorting holes by increasing diameter value /* Compare function used for sorting holes by increasing diameter value
* and X value * and X value
*/ */
static bool CmpHoleDiameterValue( const HOLE_INFO& a, const HOLE_INFO& b ) static bool CmpHoleDiameterValue( const HOLE_INFO& a, const HOLE_INFO& b )
{ {
if ( a.m_Hole_Diameter != b.m_Hole_Diameter ) if ( a.m_Hole_Diameter != b.m_Hole_Diameter )
return a.m_Hole_Diameter < b.m_Hole_Diameter; return a.m_Hole_Diameter < b.m_Hole_Diameter;
if ( a.m_Hole_Pos_X != b.m_Hole_Pos_X ) if ( a.m_Hole_Pos_X != b.m_Hole_Pos_X )
return a.m_Hole_Pos_X < b.m_Hole_Pos_X; return a.m_Hole_Pos_X < b.m_Hole_Pos_X;
return a.m_Hole_Pos_Y < b.m_Hole_Pos_Y; return a.m_Hole_Pos_Y < b.m_Hole_Pos_Y;
} }
/** /**
* Function BuildHolesList * Function BuildHolesList
* Create the list of holes and tools for a given board * Create the list of holes and tools for a given board
* The list is sorted by incraesin drill values * The list is sorted by incraesin drill values
* Only holes from aFirstLayer to aLastLayer copper layers are listed (for vias, because pad holes are always through holes) * Only holes from aFirstLayer to aLastLayer copper layers are listed (for vias, because pad holes are always through holes)
* @param Pcb : the given board * @param Pcb : the given board
* @param aHoleListBuffer : the std::vector<HOLE_INFO> to fill with pcb holes info * @param aHoleListBuffer : the std::vector<HOLE_INFO> to fill with pcb holes info
* @param aToolListBuffer : the std::vector<DRILL_TOOL> to fill with tools to use * @param aToolListBuffer : the std::vector<DRILL_TOOL> to fill with tools to use
* @param aFirstLayer = first layer to consider * @param aFirstLayer = first layer to consider
* @param aLastLayer = last layer to consider * @param aLastLayer = last layer to consider
*/ */
void Build_Holes_List( BOARD* aPcb, void Build_Holes_List( BOARD* aPcb,
std::vector<HOLE_INFO>& aHoleListBuffer, std::vector<HOLE_INFO>& aHoleListBuffer,
std::vector<DRILL_TOOL>& aToolListBuffer, std::vector<DRILL_TOOL>& aToolListBuffer,
int aFirstLayer, int aLastLayer ) int aFirstLayer, int aLastLayer )
{ {
HOLE_INFO new_hole; HOLE_INFO new_hole;
int hole_value; int hole_value;
aHoleListBuffer.clear(); aHoleListBuffer.clear();
aToolListBuffer.clear(); aToolListBuffer.clear();
if( aFirstLayer > aLastLayer ) if( aFirstLayer > aLastLayer )
EXCHG( aFirstLayer, aLastLayer ); EXCHG( aFirstLayer, aLastLayer );
/* build hole list for vias */ /* build hole list for vias */
TRACK* track = aPcb->m_Track; TRACK* track = aPcb->m_Track;
for( ; track != NULL; track = track->Next() ) for( ; track != NULL; track = track->Next() )
{ {
if( track->Type() != TYPEVIA ) if( track->Type() != TYPEVIA )
continue; continue;
SEGVIA* via = (SEGVIA*) track; SEGVIA* via = (SEGVIA*) track;
hole_value = via->GetDrillValue(); hole_value = via->GetDrillValue();
if( hole_value == 0 ) if( hole_value == 0 )
continue; continue;
new_hole.m_Tool_Reference = -1; // Flag value for Not initialized new_hole.m_Tool_Reference = -1; // Flag value for Not initialized
new_hole.m_Hole_Orient = 0; new_hole.m_Hole_Orient = 0;
new_hole.m_Hole_Diameter = hole_value; new_hole.m_Hole_Diameter = hole_value;
new_hole.m_Hole_SizeX = new_hole.m_Hole_SizeY = new_hole.m_Hole_Diameter; new_hole.m_Hole_SizeX = new_hole.m_Hole_SizeY = new_hole.m_Hole_Diameter;
new_hole.m_Hole_Shape = 0; // hole shape: round new_hole.m_Hole_Shape = 0; // hole shape: round
new_hole.m_Hole_Pos_X = via->m_Start.x; new_hole.m_Hole_Pos_X = via->m_Start.x;
new_hole.m_Hole_Pos_Y = via->m_Start.y; // hole position new_hole.m_Hole_Pos_Y = via->m_Start.y; // hole position
via->ReturnLayerPair( &new_hole.m_Hole_Top_Layer, &new_hole.m_Hole_Bottom_Layer ); via->ReturnLayerPair( &new_hole.m_Hole_Top_Layer, &new_hole.m_Hole_Bottom_Layer );
// ReturnLayerPair return params with m_Hole_Bottom_Layer < m_Hole_Top_Layer // ReturnLayerPair return params with m_Hole_Bottom_Layer < m_Hole_Top_Layer
if( new_hole.m_Hole_Bottom_Layer > aFirstLayer ) if( new_hole.m_Hole_Bottom_Layer > aFirstLayer )
continue; continue;
if( new_hole.m_Hole_Top_Layer < aLastLayer ) if( new_hole.m_Hole_Top_Layer < aLastLayer )
continue; continue;
aHoleListBuffer.push_back( new_hole ); aHoleListBuffer.push_back( new_hole );
} }
/* build hole list for pads */ /* build hole list for pads */
MODULE* Module = aPcb->m_Modules; MODULE* Module = aPcb->m_Modules;
for( ; Module != NULL; Module = Module->Next() ) for( ; Module != NULL; Module = Module->Next() )
{ {
/* Read and analyse pads */ /* Read and analyse pads */
D_PAD* pad = Module->m_Pads; D_PAD* pad = Module->m_Pads;
for( ; pad != NULL; pad = pad->Next() ) for( ; pad != NULL; pad = pad->Next() )
{ {
if( pad->m_Drill.x == 0 ) if( pad->m_Drill.x == 0 )
continue; continue;
new_hole.m_Tool_Reference = -1; // Flag is: Not initialized new_hole.m_Tool_Reference = -1; // Flag is: Not initialized
new_hole.m_Hole_Orient = pad->m_Orient; new_hole.m_Hole_Orient = pad->m_Orient;
new_hole.m_Hole_Shape = 0; // hole shape: round new_hole.m_Hole_Shape = 0; // hole shape: round
new_hole.m_Hole_Diameter = min( pad->m_Drill.x, pad->m_Drill.x ); new_hole.m_Hole_Diameter = min( pad->m_Drill.x, pad->m_Drill.x );
new_hole.m_Hole_SizeX = new_hole.m_Hole_SizeY = new_hole.m_Hole_Diameter; new_hole.m_Hole_SizeX = new_hole.m_Hole_SizeY = new_hole.m_Hole_Diameter;
if( pad->m_DrillShape != PAD_CIRCLE ) if( pad->m_DrillShape != PAD_CIRCLE )
new_hole.m_Hole_Shape = 1; // oval flag set new_hole.m_Hole_Shape = 1; // oval flag set
new_hole.m_Hole_SizeX = pad->m_Drill.x; new_hole.m_Hole_SizeX = pad->m_Drill.x;
new_hole.m_Hole_SizeY = pad->m_Drill.y; new_hole.m_Hole_SizeY = pad->m_Drill.y;
new_hole.m_Hole_Pos_X = pad->m_Pos.x; new_hole.m_Hole_Pos_X = pad->m_Pos.x;
new_hole.m_Hole_Pos_Y = pad->m_Pos.y; // hole position new_hole.m_Hole_Pos_Y = pad->m_Pos.y; // hole position
new_hole.m_Hole_Bottom_Layer = COPPER_LAYER_N; new_hole.m_Hole_Bottom_Layer = COPPER_LAYER_N;
new_hole.m_Hole_Top_Layer = LAYER_CMP_N; // pad holes are through holes new_hole.m_Hole_Top_Layer = LAYER_CMP_N; // pad holes are through holes
aHoleListBuffer.push_back( new_hole ); aHoleListBuffer.push_back( new_hole );
} }
} }
// Sort holes per increasing diameter value // Sort holes per increasing diameter value
sort( aHoleListBuffer.begin(), aHoleListBuffer.end(), CmpHoleDiameterValue ); sort( aHoleListBuffer.begin(), aHoleListBuffer.end(), CmpHoleDiameterValue );
// build the tool list // build the tool list
int LastHole = -1; /* Set to not initialised int LastHole = -1; /* Set to not initialised
* (this is a value not used for aHoleListBuffer[ii].m_Hole_Diameter) */ * (this is a value not used for aHoleListBuffer[ii].m_Hole_Diameter) */
DRILL_TOOL new_tool( 0 ); DRILL_TOOL new_tool( 0 );
unsigned jj; unsigned jj;
for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ ) for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ )
{ {
if( aHoleListBuffer[ii].m_Hole_Diameter != LastHole ) if( aHoleListBuffer[ii].m_Hole_Diameter != LastHole )
{ {
new_tool.m_Diameter = ( aHoleListBuffer[ii].m_Hole_Diameter ); new_tool.m_Diameter = ( aHoleListBuffer[ii].m_Hole_Diameter );
aToolListBuffer.push_back( new_tool ); aToolListBuffer.push_back( new_tool );
LastHole = new_tool.m_Diameter; LastHole = new_tool.m_Diameter;
} }
jj = aToolListBuffer.size(); jj = aToolListBuffer.size();
if( jj == 0 ) if( jj == 0 )
continue; // Should not occurs continue; // Should not occurs
aHoleListBuffer[ii].m_Tool_Reference = jj; // Tool value Initialized (value >= 1) aHoleListBuffer[ii].m_Tool_Reference = jj; // Tool value Initialized (value >= 1)
aToolListBuffer.back().m_TotalCount++; aToolListBuffer.back().m_TotalCount++;
if( aHoleListBuffer[ii].m_Hole_Shape ) if( aHoleListBuffer[ii].m_Hole_Shape )
aToolListBuffer.back().m_OvalCount++; aToolListBuffer.back().m_OvalCount++;
} }
} }
/*******************************************************************************/ /*******************************************************************************/
/* classes and functions declaration unsed in drill file and report generation */ /* classes and functions declaration unsed in drill file and report generation */
/*******************************************************************************/ /*******************************************************************************/
#ifndef GENDRILL_H #ifndef GENDRILL_H
#define GENDRILL_H #define GENDRILL_H
/* the DRILL_TOOL class handle tools used in the excellon drill file */ /* the DRILL_TOOL class handle tools used in the excellon drill file */
class DRILL_TOOL class DRILL_TOOL
{ {
public: public:
int m_Diameter; // the diameter of the used tool (for oblong, the smaller size) int m_Diameter; // the diameter of the used tool (for oblong, the smaller size)
int m_TotalCount; // how many times it is used (round and oblong) int m_TotalCount; // how many times it is used (round and oblong)
int m_OvalCount; // oblong count int m_OvalCount; // oblong count
public: public:
DRILL_TOOL( int diametre ) DRILL_TOOL( int diametre )
{ {
m_TotalCount = 0; m_TotalCount = 0;
m_OvalCount = 0; m_OvalCount = 0;
m_Diameter = diametre; m_Diameter = diametre;
} }
}; };
/* the HOLE_INFO class handle hole which must be drilled (diameter, position and layers) */ /* the HOLE_INFO class handle hole which must be drilled (diameter, position and layers) */
class HOLE_INFO class HOLE_INFO
{ {
public: public:
int m_Hole_Diameter; // hole value, and for oblong min(hole size x, hole size y) int m_Hole_Diameter; // hole value, and for oblong min(hole size x, hole size y)
int m_Tool_Reference; // Tool reference for this hole = 1 ... n (values <=0 must not be used) int m_Tool_Reference; // Tool reference for this hole = 1 ... n (values <=0 must not be used)
int m_Hole_SizeX; // hole size x for oblong holes int m_Hole_SizeX; // hole size x for oblong holes
int m_Hole_SizeY; // hole size y for oblong holes int m_Hole_SizeY; // hole size y for oblong holes
int m_Hole_Orient; // Hole rotation (= pad rotation) for oblong holes int m_Hole_Orient; // Hole rotation (= pad rotation) for oblong holes
int m_Hole_Shape; // hole shape: round (0) or oval (1) int m_Hole_Shape; // hole shape: round (0) or oval (1)
int m_Hole_Pos_X; // hole position X int m_Hole_Pos_X; // hole position X
int m_Hole_Pos_Y; // hole position Y int m_Hole_Pos_Y; // hole position Y
int m_Hole_Bottom_Layer; // hole starting layer (usually copper) int m_Hole_Bottom_Layer; // hole starting layer (usually copper)
int m_Hole_Top_Layer; // hole ending layer (usually component): m_Hole_First_Layer < m_Hole_Last_Layer int m_Hole_Top_Layer; // hole ending layer (usually component): m_Hole_First_Layer < m_Hole_Last_Layer
}; };
/* the DrillPrecision class to handle drill precision format in excellon files*/ /* the DrillPrecision class to handle drill precision format in excellon files*/
class DrillPrecision class DrillPrecision
{ {
public: public:
int m_lhs; int m_lhs;
int m_rhs; int m_rhs;
public: public:
DrillPrecision( int l, int r ) { m_lhs = l; m_rhs = r; } DrillPrecision( int l, int r ) { m_lhs = l; m_rhs = r; }
}; };
/* zeros format */ /* zeros format */
enum zeros_fmt { enum zeros_fmt {
DECIMAL_FORMAT, DECIMAL_FORMAT,
SUPPRESS_LEADING, SUPPRESS_LEADING,
SUPPRESS_TRAILING, SUPPRESS_TRAILING,
KEEP_ZEROS KEEP_ZEROS
}; };
/** /**
* Function BuildHolesList * Function BuildHolesList
* Create the list of holes and tools for a given board * Create the list of holes and tools for a given board
* @param Pcb : the given board * @param Pcb : the given board
* @param aHoleListBuffer : the std::vector<HOLE_INFO> to fill with pcb info * @param aHoleListBuffer : the std::vector<HOLE_INFO> to fill with pcb info
* @param aToolListBuffer : the std::vector<DRILL_TOOL> to fill with tools to use * @param aToolListBuffer : the std::vector<DRILL_TOOL> to fill with tools to use
*/ */
void Build_Holes_List( BOARD* Pcb, std::vector<HOLE_INFO>& aHoleListBuffer, void Build_Holes_List( BOARD* Pcb, std::vector<HOLE_INFO>& aHoleListBuffer,
std::vector<DRILL_TOOL>& aToolListBuffer, std::vector<DRILL_TOOL>& aToolListBuffer,
int aFirstLayer, int aLastLayer ); int aFirstLayer, int aLastLayer );
void GenDrillMapFile( BOARD* aPcb, void GenDrillMapFile( BOARD* aPcb,
FILE* aFile, FILE* aFile,
const wxString& aFullFileName, const wxString& aFullFileName,
wxSize aSheetSize, wxSize aSheetSize,
std::vector<HOLE_INFO> aHoleListBuffer, std::vector<HOLE_INFO> aHoleListBuffer,
std::vector<DRILL_TOOL> aToolListBuffer, std::vector<DRILL_TOOL> aToolListBuffer,
bool aUnit_Drill_is_Inch, bool aUnit_Drill_is_Inch,
int format ); int format );
void Gen_Drill_PcbMap( BOARD* aPcb, FILE* aFile, void Gen_Drill_PcbMap( BOARD* aPcb, FILE* aFile,
std::vector<HOLE_INFO>& aHoleListBuffer, std::vector<HOLE_INFO>& aHoleListBuffer,
std::vector<DRILL_TOOL>& aToolListBuffer, std::vector<DRILL_TOOL>& aToolListBuffer,
int format ); int format );
/* /*
* Create a list of drill values and drill count * Create a list of drill values and drill count
*/ */
void GenDrillReportFile( FILE* aFile, const wxString& aBoardFilename, void GenDrillReportFile( FILE* aFile, const wxString& aBoardFilename,
std::vector<DRILL_TOOL>& aToolListBuffer, bool aUnit_Drill_is_Inch ); std::vector<DRILL_TOOL>& aToolListBuffer, bool aUnit_Drill_is_Inch );
#endif // #ifndef GENDRILL_H #endif // #ifndef GENDRILL_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment