← Back to team overview

kicad-developers team mailing list archive

Drill plot

 

A slight bug was introduced during the hershey migration... drill symbols aren't being plotted correctly in ps because the path isn't close with a pen'Z' operation. Also (as a cleanup) the 'float' in the printf should be really 'double' (check the C/C++ specs on varargs... you simply have no way topass a float, it will always be promoted to a double). The last 'addition'it to have plotted the drill symbol even for slot holes (you call them 'oblongs', slots is their official name :D). This is of course useful to checkslot tooling...

Also I'm planning to start a refactoring of the plotting routines... too many globals and all that IsPostscript/type == HPGL is sick even in COBOL, let alone in C++ :D:D

The idea is to have a virtual 'Plotter' class encapsulating the output fileand the file operations, then instead of the global file descriptor have an instance of the right subclass.

Anyway, here's the patch for the drill report problem:

Index: gen_drill_report_files.cpp
===================================================================
--- gen_drill_report_files.cpp (revision 1819)
+++ gen_drill_report_files.cpp (working copy)
@@ -49,7 +49,7 @@
int PlotMarge_in_mils = 400; // Margin in 1/1000 inch
int marge = PlotMarge_in_mils * U_PCB;
wxSize SheetSize;
- float fTextScale = 1.0;
+ double fTextScale = 1.0;
double scale_x = 1.0, scale_y = 1.0;
Ki_PageDescr* SheetPS = NULL;
wxString msg;
@@ -72,7 +72,7 @@
Scale_X = Scale_Y = 1.0;
scale_x = Scale_X * SCALE_HPGL;
scale_y = Scale_Y * SCALE_HPGL;
- fTextScale = (float)SCALE_HPGL;
+ fTextScale = (double)SCALE_HPGL;
SheetSize = aSheetSize;
SheetSize.x *= U_PCB;
SheetSize.y *= U_PCB;
@@ -86,8 +86,8 @@
SheetPS = &g_Sheet_A4;
SheetSize.x = SheetPS->m_Size.x * U_PCB;
SheetSize.y = SheetPS->m_Size.y * U_PCB;
- float Xscale = (float) ( SheetSize.x - (marge * 2) ) / dX;
- float Yscale = (float) ( SheetSize.y * 0.6 - (marge * 2) ) / dY;
+ double Xscale = (double) ( SheetSize.x - (marge * 2) ) / dX;
+ double Yscale = (double) ( SheetSize.y * 0.6 - (marge * 2) ) / dY;

scale_x = scale_y = MIN( Xscale, Yscale );

@@ -176,7 +176,7 @@

/* Impression de la liste des symboles utilises */
CharSize = 800; /* text size in 1/10000 mils */
- float CharScale = 1.0 / scale_x; /* real scale will be CharScale * scale_x,
+ double CharScale = 1.0 / scale_x; /* real scale will be CharScale * scale_x,
* because the global plot scale is scale_x */
TextWidth = (int) ((CharSize * CharScale) / 10); // Set textwidth (thickness)
intervalle = (int) (CharSize * CharScale) + TextWidth;
@@ -198,7 +198,7 @@
InitPlotParametresHPGL( g_PlotOffset, scale_x, scale_x );
/* generation des dim: commande SI x,y; x et y = dim en cm */
char csize[256];
- sprintf( csize, "%2.3f", (float) CharSize * CharScale * 0.000254 );
+ sprintf( csize, "%2.3f", (double) CharSize * CharScale * 0.000254 );
sprintf( line, "SI %s, %s;\n", csize, csize );
fputs( line, aFile );
break;
@@ -248,14 +248,14 @@
sprintf( line, "PU %d, %d; LB%2.3f\" / %2.2fmm ",
x + (int) (intervalle * CharScale * fTextScale),
y - (int) (CharSize / 2 * CharScale * fTextScale),
- float (aToolListBuffer[ii].m_Diameter) * 0.0001,
- float (aToolListBuffer[ii].m_Diameter) * 0.00254 );
+ double (aToolListBuffer[ii].m_Diameter) * 0.0001,
+ double (aToolListBuffer[ii].m_Diameter) * 0.00254);
else
sprintf( line, "PU %d, %d; LB%2.2fmm / %2.3f\" ",
x + (int) (intervalle * CharScale * fTextScale),
y - (int) (CharSize / 2 * CharScale * fTextScale),
- float (aToolListBuffer[ii].m_Diameter) * 0.00254,
- float (aToolListBuffer[ii].m_Diameter) * 0.0001 );
+ double (aToolListBuffer[ii].m_Diameter) * 0.00254,
+ double (aToolListBuffer[ii].m_Diameter) * 0.0001 );
fputs( line, aFile );

// Now list how many holes and ovals are associated with each drill.
@@ -284,12 +284,12 @@
// and then its diameter in the other Drill Unit.
if( aUnit_Drill_is_Inch )
sprintf( line, "%2.3f\" / %2.2fmm ",
- float (aToolListBuffer[ii].m_Diameter) * 0.0001,
- float (aToolListBuffer[ii].m_Diameter) * 0.00254 );
+ double (aToolListBuffer[ii].m_Diameter) * 0.0001,
+ double (aToolListBuffer[ii].m_Diameter) * 0.00254);
else
sprintf( line, "%2.2fmm / %2.3f\" ",
- float (aToolListBuffer[ii].m_Diameter) * 0.00254,
- float (aToolListBuffer[ii].m_Diameter) * 0.0001 );
+ double (aToolListBuffer[ii].m_Diameter) * 0.00254,
+ double (aToolListBuffer[ii].m_Diameter) * 0.0001 );
msg = CONV_FROM_UTF8( line );

// Now list how many holes and ovals are associated with each drill.
@@ -399,18 +399,18 @@
pos.x = aHoleListBuffer[ii].m_Hole_Pos_X;
pos.y = aHoleListBuffer[ii].m_Hole_Pos_Y;

- if( aHoleListBuffer[ii].m_Hole_Shape == 0 )
+ /* Always plot the drill symbol (for slots identifies the needed
+ * cutter!) */
+ PlotDrillSymbol( pos, aHoleListBuffer[ii].m_Hole_Diameter,
+ aHoleListBuffer[ii].m_Tool_Reference - 1,
+ format );
+ if( aHoleListBuffer[ii].m_Hole_Shape != 0 )
{
- PlotDrillSymbol( pos, aHoleListBuffer[ii].m_Hole_Diameter,
- aHoleListBuffer[ii].m_Tool_Reference - 1,
- format );
- }
- else
- {
wxSize oblong_size;
oblong_size.x = aHoleListBuffer[ii].m_Hole_SizeX;
oblong_size.y = aHoleListBuffer[ii].m_Hole_SizeY;
PlotOvalDrillSymbol( pos, oblong_size, aHoleListBuffer[ii].m_Hole_Orient, form$
+ /* Plot the drill symbol too, to identify the needed cutter! */
}
}                  
}                  
@@ -443,6 +443,7 @@
FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' );
+ FctPlume( wxPoint( x0, y0 ), 'Z' );
break;

case 1: /* Cercle */
@@ -457,6 +458,7 @@
FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 ), 'D' );
+ FctPlume( wxPoint( x0, y0 ), 'Z' );
break;

case 3: /* forme en X cercle */
@@ -464,6 +466,7 @@
FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' );
+ FctPlume( wxPoint( x0, y0 ), 'Z' );
if( format == PLOT_FORMAT_HPGL )
trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE );
if( IsPostScript( format ) )
@@ -473,6 +476,7 @@
case 4: /* forme en cercle barre de - */
FctPlume( wxPoint( x0 - rayon, y0 ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 ), 'D' );
+ FctPlume( wxPoint( x0, y0 ), 'Z' );
if( format == PLOT_FORMAT_HPGL )
trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE );
if( IsPostScript( format ) )
@@ -482,6 +486,7 @@
case 5: /* forme en cercle barre de | */
FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
+ FctPlume( wxPoint( x0, y0 ), 'Z' );
if( format == PLOT_FORMAT_HPGL )
trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE );
if( IsPostScript( format ) )
@@ -515,6 +520,7 @@
FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' );
+ FctPlume( wxPoint( x0, y0 ), 'Z' );
if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0$
@@ -530,6 +536,7 @@
FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 ), 'D' );
+ FctPlume( wxPoint( x0, y0 ), 'Z' );
if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0$
@@ -543,6 +550,7 @@
case 10: /* forme en carre barre par un '/' */
FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
+ FctPlume( wxPoint( x0, y0 ), 'Z' );
if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0$
@@ -556,6 +564,7 @@
case 11: /* forme en losange barre par un |*/
FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
+ FctPlume( wxPoint( x0, y0 ), 'Z' );
if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0$
@@ -569,6 +578,7 @@
case 12: /* forme en losange barre par un -*/
FctPlume( wxPoint( x0 - rayon, y0 ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 ), 'D' );
+ FctPlume( wxPoint( x0, y0 ), 'Z' );
if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0$
@@ -684,13 +694,13 @@
if( aUnit_Drill_is_Inch )
sprintf( line, "T%d %2.3f\" %2.2fmm ",
ii + 1,
- float (aToolListBuffer[ii].m_Diameter) * 0.0001,
- float (aToolListBuffer[ii].m_Diameter) * 0.00254 );
+ double (aToolListBuffer[ii].m_Diameter) * 0.0001,
+ double (aToolListBuffer[ii].m_Diameter) * 0.00254);
else
sprintf( line, "T%d %2.2fmm %2.3f\" ",
ii + 1,
- float (aToolListBuffer[ii].m_Diameter) * 0.00254,
- float (aToolListBuffer[ii].m_Diameter) * 0.0001 );
+ double (aToolListBuffer[ii].m_Diameter) * 0.00254,
+ double (aToolListBuffer[ii].m_Diameter) * 0.0001 );
fputs( line, aFile );

// Now list how many holes and ovals are associated with each drill.