Complete comment translation of common source.

This commit is contained in:
stambaughw
2009-11-23 15:16:50 +00:00
parent d21bf859ae
commit bc5d9a75f5
33 changed files with 2510 additions and 2645 deletions
+94 -114
View File
@@ -1,6 +1,6 @@
/******************************************/
/***********************************/
/* Kicad: Common plot DXF Routines */
/******************************************/
/***********************************/
#include "fctsys.h"
#include "gr_basic.h"
@@ -11,13 +11,11 @@
#include "macros.h"
#include "kicad_string.h"
/***********************************************************************************/
void DXF_PLOTTER::set_viewport( wxPoint offset,
double aScale, int orient )
/***********************************************************************************/
/* Set the plot offset for the current plotting
*/
void DXF_PLOTTER::set_viewport( wxPoint offset,
double aScale, int orient )
{
wxASSERT( !output_file );
plot_offset = offset;
@@ -29,16 +27,13 @@ void DXF_PLOTTER::set_viewport( wxPoint offset,
}
/*****************************************************************/
void DXF_PLOTTER::start_plot( FILE* fout )
/*****************************************************************/
{
wxASSERT( !output_file );
output_file = fout;
/* DXF HEADER - Boilerplate */
fputs(
"0\nSECTION\n2\nHEADER\n9\n$ANGBASE\n50\n0.0\n9\n$ANGDIR\n70\n0\n0\nENDSEC\n0\nSECTION\n2\nTABLES\n0\nTABLE\n2\nLTYPE\n70\n1\n0\nLTYPE\n2\nCONTINUOUS\n70\n0\n3\nSolid line\n72\n65\n73\n0\n40\n0.0\n0\nENDTAB\n",
output_file );
fputs( "0\nSECTION\n2\nHEADER\n9\n$ANGBASE\n50\n0.0\n9\n$ANGDIR\n70\n0\n0\nENDSEC\n0\nSECTION\n2\nTABLES\n0\nTABLE\n2\nLTYPE\n70\n1\n0\nLTYPE\n2\nCONTINUOUS\n70\n0\n3\nSolid line\n72\n65\n73\n0\n40\n0.0\n0\nENDTAB\n",
output_file );
/* Layer table - one layer per color */
fprintf( output_file, "0\nTABLE\n2\nLAYER\n70\n%d\n", NBCOLOR );
for( int i = 0; i<NBCOLOR; i++ )
@@ -53,9 +48,7 @@ void DXF_PLOTTER::start_plot( FILE* fout )
}
/**********************************/
void DXF_PLOTTER::end_plot()
/**********************************/
{
wxASSERT( output_file );
/* DXF FOOTER */
@@ -65,27 +58,22 @@ void DXF_PLOTTER::end_plot()
}
/******************************/
void DXF_PLOTTER::set_color( int color )
/******************************/
/*
* color = color index in ColorRefs[]
*/
void DXF_PLOTTER::set_color( int color )
{
wxASSERT( output_file );
if( (color >= 0 && color_mode)
|| (color == BLACK)
|| (color == WHITE) )
if( ( color >= 0 && color_mode )
|| ( color == BLACK )
|| ( color == WHITE ) )
{
current_color = color;
}
}
/************************************************************/
void DXF_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
/************************************************************/
{
wxASSERT( output_file );
move_to( p1 );
@@ -96,32 +84,27 @@ void DXF_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
}
/************************************************************/
void DXF_PLOTTER::circle( wxPoint centre, int diameter, FILL_T fill, int width )
/************************************************************/
{
wxASSERT( output_file );
double rayon = user_to_device_size( diameter / 2 );
double radius = user_to_device_size( diameter / 2 );
user_to_device_coordinates( centre );
if( rayon > 0 )
if( radius > 0 )
{
wxString cname = ColorRefs[current_color].m_Name;
fprintf( output_file, "0\nCIRCLE\n8\n%s\n10\n%d.0\n20\n%d.0\n40\n%g\n",
CONV_TO_UTF8( cname ),
centre.x, centre.y, rayon );
centre.x, centre.y, radius );
}
}
/*****************************************************/
void DXF_PLOTTER::poly( int nb, int* coord, FILL_T fill, int width )
/*****************************************************/
/* Trace un polygone (ferme si rempli) en format DXF
* coord = tableau des coord des sommets
* nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau )
* fill : si != 0 polygone rempli
/* Draw a polygon (closed if completed) in DXF format
* coord = coord table tops
* nb = number of coord (coord 1 = 2 elements: X and Y table)
* fill: if != 0 filled polygon
*/
void DXF_PLOTTER::poly( int nb, int* coord, FILL_T fill, int width )
{
wxASSERT( output_file );
if( nb <= 1 )
@@ -131,27 +114,23 @@ void DXF_PLOTTER::poly( int nb, int* coord, FILL_T fill, int width )
for( int ii = 1; ii < nb; ii++ )
line_to( wxPoint( coord[ii * 2], coord[(ii * 2) + 1] ) );
/* Fermeture eventuelle du polygone */
/* Close polygon. */
if( fill )
{
int ii = (nb - 1) * 2;
if( (coord[ii] != coord[0] ) || (coord[ii + 1] != coord[1]) )
if( ( coord[ii] != coord[0] ) || ( coord[ii + 1] != coord[1] ) )
line_to( wxPoint( coord[0], coord[1] ) );
}
pen_finish();
}
/**********************************************/
void DXF_PLOTTER::pen_to( wxPoint pos, char plume )
/**********************************************/
/*
* deplace la plume levee (plume = 'U') ou baissee (plume = 'D')
* en position x,y
* Unites en Unites DESSIN
* Si plume = 'Z' lever de plume sans deplacement
* Move the pen up (pen = 'U') or down (feather = 'D') at position x, y
* Unit to unit DRAWING
* If pen = 'Z' without lifting pen displacement
*/
void DXF_PLOTTER::pen_to( wxPoint pos, char plume )
{
wxASSERT( output_file );
if( plume == 'Z' )
@@ -179,15 +158,14 @@ void DXF_PLOTTER::set_dash( bool dashed )
}
void DXF_PLOTTER::thick_segment( wxPoint start, wxPoint end, int width,
GRTraceMode tracemode )
/** Function Plot a filled segment (track)
* @param start = starting point
* @param end = ending point
* @param aWidth = segment width (thickness)
* @param aPlotMode = FILLED, SKETCH ..
*/
void DXF_PLOTTER::thick_segment( wxPoint start, wxPoint end, int width,
GRTraceMode tracemode )
{
wxASSERT( output_file );
@@ -201,47 +179,44 @@ void DXF_PLOTTER::thick_segment( wxPoint start, wxPoint end, int width,
}
/********************************************************************/
void DXF_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
FILL_T fill, int width )
/********************************************************************/
/* trace d'un arc de cercle:
* centre = coord du centre
* StAngle, EndAngle = angle de debut et fin
* rayon = rayon de l'arc
/* Plot an arc in DXF format.
* center = center coord
* StAngle, EndAngle = angle of beginning and end
* Radius = radius of the arc
*/
void DXF_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int radius,
FILL_T fill, int width )
{
wxASSERT( output_file );
if( rayon <= 0 )
if( radius <= 0 )
return;
user_to_device_coordinates( centre );
rayon = user_to_device_size( rayon );
radius = user_to_device_size( radius );
/* DXF ARC */
wxString cname = ColorRefs[current_color].m_Name;
fprintf( output_file, "0\nARC\n8\n%s\n10\n%d.0\n20\n%d.0\n40\n%d.0\n50\n%d.0\n51\n%d.0\n",
fprintf( output_file,
"0\nARC\n8\n%s\n10\n%d.0\n20\n%d.0\n40\n%d.0\n50\n%d.0\n51\n%d.0\n",
CONV_TO_UTF8( cname ),
centre.x, centre.y, rayon,
centre.x, centre.y, radius,
StAngle / 10, EndAngle / 10 );
}
/***********************************************************************************/
/* Plot oval pad at position. */
void DXF_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
GRTraceMode trace_mode )
/************************************************************************************/
/* Trace 1 pastille PAD_OVAL en position pos_X,Y , de dim size.x, size.y */
{
wxASSERT( output_file );
/* la pastille est ramenee a une pastille ovale avec size.y > size.x
* ( ovale vertical en orientation 0 ) */
/* The chip is reduced to an oval tablet with size.y > size.x
* (Oval vertical orientation 0) */
if( size.x > size.y )
{
EXCHG( size.x, size.y ); orient += 900;
EXCHG( size.x, size.y );
orient += 900;
if( orient >= 3600 )
orient -= 3600;
}
@@ -249,27 +224,20 @@ void DXF_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
}
/*******************************************************************************/
/* Plot round pad or via. */
void DXF_PLOTTER::flash_pad_circle( wxPoint pos, int diametre,
GRTraceMode trace_mode )
/*******************************************************************************/
/* Trace 1 pastille RONDE (via,pad rond) en position pos */
{
wxASSERT( output_file );
circle( pos, diametre, NO_FILL );
}
/**************************************************************************/
/*
* Plot rectangular pad vertical or horizontal (rectangular Pad)
*/
void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize,
int orient, GRTraceMode trace_mode )
/**************************************************************************/
/*
* Trace 1 pad rectangulaire vertical ou horizontal ( Pad rectangulaire )
* donne par son centre et ses dimensions X et Y
* Units are user units
*/
{
wxASSERT( output_file );
wxSize size;
@@ -282,12 +250,14 @@ void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize,
if( size.y < 0 )
size.y = 0;
/* Si une des dimensions est nulle, le trace se reduit a 1 trait */
/* If a dimension is zero, the trace is reduced to 1 line. */
if( size.x == 0 )
{
ox = pos.x; oy = pos.y - size.y;
ox = pos.x;
oy = pos.y - size.y;
RotatePoint( &ox, &oy, pos.x, pos.y, orient );
fx = pos.x; fy = pos.y + size.y;
fx = pos.x;
fy = pos.y + size.y;
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
move_to( wxPoint( ox, oy ) );
finish_to( wxPoint( fx, fy ) );
@@ -295,28 +265,34 @@ void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize,
}
if( size.y == 0 )
{
ox = pos.x - size.x; oy = pos.y;
ox = pos.x - size.x;
oy = pos.y;
RotatePoint( &ox, &oy, pos.x, pos.y, orient );
fx = pos.x + size.x; fy = pos.y;
fx = pos.x + size.x;
fy = pos.y;
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
move_to( wxPoint( ox, oy ) );
finish_to( wxPoint( fx, fy ) );
return;
}
ox = pos.x - size.x; oy = pos.y - size.y;
ox = pos.x - size.x;
oy = pos.y - size.y;
RotatePoint( &ox, &oy, pos.x, pos.y, orient );
move_to( wxPoint( ox, oy ) );
fx = pos.x - size.x; fy = pos.y + size.y;
fx = pos.x - size.x;
fy = pos.y + size.y;
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
line_to( wxPoint( fx, fy ) );
fx = pos.x + size.x; fy = pos.y + size.y;
fx = pos.x + size.x;
fy = pos.y + size.y;
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
line_to( wxPoint( fx, fy ) );
fx = pos.x + size.x; fy = pos.y - size.y;
fx = pos.x + size.x;
fy = pos.y - size.y;
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
line_to( wxPoint( fx, fy ) );
@@ -324,43 +300,47 @@ void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize,
}
/*******************************************************************/
void DXF_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
int orient, GRTraceMode trace_mode )
/*******************************************************************/
/*
* Trace 1 pad trapezoidal donne par :
* son centre pos.x,pos.y
* ses dimensions dimX et dimY
* les variations deltaX et deltaY
* son orientation orient et 0.1 degres
* le mode de trace (FILLED, SKETCH, FILAIRE)
* Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY
* = 0.
* Plot trapezoidal pad.
* pos its center, pos.y
* Dimensions dim X and dimy
* DeltaX and variations deltaY
* Orientation and 0.1 degrees east
* Plot mode (FILLED, SKETCH, WIRED)
* The evidence is that a trapezoid, ie that deltaX or deltaY
* = 0.
*
* les notation des sommets sont ( vis a vis de la table tracante )
* The rating of the vertexes are (vis a vis the plotter)
* 0 ------------- 3
* . .
* . .
* . .
* . .
* . .
* . .
* 1 --- 2
*/
void DXF_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
int orient, GRTraceMode trace_mode )
{
wxASSERT( output_file );
wxPoint polygone[4]; /* coord des sommets / centre du pad */
wxPoint coord[4]; /* coord reelles des sommets du trapeze a tracer */
int moveX, moveY; /* variation de position plume selon axe X et Y , lors
* du remplissage du trapeze */
wxPoint polygone[4]; /* coord of vertex or center of the pad */
wxPoint coord[4]; /* coord actual corners of a trapezoidal trace */
int moveX, moveY; /* change pen position by X and Y axis to
* fill the trapezoid */
moveX = moveY = 0;
size.x /= 2; size.y /= 2;
delta.x /= 2; delta.y /= 2;
size.x /= 2;
size.y /= 2;
delta.x /= 2;
delta.y /= 2;
polygone[0].x = -size.x - delta.y; polygone[0].y = +size.y + delta.x;
polygone[1].x = -size.x + delta.y; polygone[1].y = -size.y - delta.x;
polygone[2].x = +size.x - delta.y; polygone[2].y = -size.y + delta.x;
polygone[3].x = +size.x + delta.y; polygone[3].y = +size.y - delta.x;
polygone[0].x = -size.x - delta.y;
polygone[0].y = +size.y + delta.x;
polygone[1].x = -size.x + delta.y;
polygone[1].y = -size.y - delta.x;
polygone[2].x = +size.x - delta.y;
polygone[2].y = -size.y + delta.x;
polygone[3].x = +size.x + delta.y;
polygone[3].y = +size.y - delta.x;
for( int ii = 0; ii < 4; ii++ )
{