Commit 2da432b2 authored by dickelbeck's avatar dickelbeck

plot fix, beautification

parent 11d8f51b
/******************************************/ /******************************************/
/* Kicad: Common plot HPGL Routines */ /* Kicad: Common plot HPGL Routines */
/******************************************/ /******************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
// Variables partagees avec Common plot Postscript Routines // Variables partagees avec Common plot Postscript Routines
extern wxPoint LastPenPosition; extern wxPoint LastPenPosition;
extern wxPoint PlotOffset; extern wxPoint PlotOffset;
extern FILE * PlotOutputFile; extern FILE* PlotOutputFile;
extern double XScale, YScale; extern double XScale, YScale;
extern int g_DefaultPenWidth, g_CurrentPenWidth; extern int g_DefaultPenWidth, g_CurrentPenWidth;
extern int PlotOrientOptions, etat_plume; extern int PlotOrientOptions, etat_plume;
...@@ -28,12 +28,13 @@ void Plume_HPGL( int plume ); ...@@ -28,12 +28,13 @@ void Plume_HPGL( int plume );
/***********************************************************************************/ /***********************************************************************************/
void InitPlotParametresHPGL(wxPoint offset, double xscale, double yscale, int orient) void InitPlotParametresHPGL( wxPoint offset, double xscale, double yscale, int orient )
/***********************************************************************************/ /***********************************************************************************/
/* Set the plot offset for the current plotting /* Set the plot offset for the current plotting
xscale,yscale = coordinate scale (scale coefficient for coordinates) * xscale,yscale = coordinate scale (scale coefficient for coordinates)
device_xscale,device_yscale = device coordinate scale (i.e scale used by plot device) * device_xscale,device_yscale = device coordinate scale (i.e scale used by plot device)
*/ */
{ {
PlotOffset = offset; PlotOffset = offset;
XScale = xscale; XScale = xscale;
...@@ -44,164 +45,171 @@ void InitPlotParametresHPGL(wxPoint offset, double xscale, double yscale, int or ...@@ -44,164 +45,171 @@ void InitPlotParametresHPGL(wxPoint offset, double xscale, double yscale, int or
} }
/*****************************************************************/ /*****************************************************************/
bool PrintHeaderHPGL(FILE * plot_file, int pen_speed, int pen_num) bool PrintHeaderHPGL( FILE* plot_file, int pen_speed, int pen_num )
/*****************************************************************/ /*****************************************************************/
{ {
char Line[256]; char Line[256];
PlotOutputFile = plot_file; PlotOutputFile = plot_file;
etat_plume = 'U'; etat_plume = 'U';
sprintf(Line,"IN;VS%d;PU;PA;SP%d;\n",pen_speed,pen_num); sprintf( Line, "IN;VS%d;PU;PA;SP%d;\n", pen_speed, pen_num );
fputs(Line,plot_file); fputs( Line, plot_file );
return TRUE; return TRUE;
} }
/**********************************/ /**********************************/
bool CloseFileHPGL(FILE * plot_file) bool CloseFileHPGL( FILE* plot_file )
/**********************************/ /**********************************/
{ {
fputs("PU;PA;SP0;\n",plot_file); fputs( "PU;PA;SP0;\n", plot_file );
fclose(plot_file); fclose( plot_file );
return TRUE; return TRUE;
} }
/************************************************************/ /************************************************************/
void PlotCircle_HPGL(wxPoint centre, int diameter, int width) void PlotCircle_HPGL( wxPoint centre, int diameter, int width )
/************************************************************/ /************************************************************/
{ {
int rayon; int rayon;
char Line[256]; char Line[256];
UserToDeviceCoordinate(centre); UserToDeviceCoordinate( centre );
rayon = (int)(diameter / 2 * XScale); rayon = (int) (diameter / 2 * XScale);
if(rayon < 0 ) rayon = 0 ; if( rayon < 0 )
rayon = 0;
Plume_HPGL('U'); Plume_HPGL( 'U' );
sprintf(Line,"PA %d,%d;CI %d,%d;\n", centre.x, centre.y, rayon , CHORD_ANGLE); sprintf( Line, "PA %d,%d;CI %d,%d;\n", centre.x, centre.y, rayon, CHORD_ANGLE );
fputs(Line,PlotOutputFile) ; fputs( Line, PlotOutputFile );
Plume_HPGL('U'); return ; Plume_HPGL( 'U' ); return;
} }
/********************************************************************/ /********************************************************************/
void PlotArcHPGL(wxPoint centre, int StAngle, int EndAngle, int rayon, int width) void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, int width )
/********************************************************************/ /********************************************************************/
/* trace d'un arc de cercle: /* trace d'un arc de cercle:
centre = coord du centre * centre = coord du centre
StAngle, EndAngle = angle de debut et fin * StAngle, EndAngle = angle de debut et fin
rayon = rayon de l'arc * rayon = rayon de l'arc
commande * commande
PU;PA x,y;PD;AA start_arc_X, start_arc_Y, angle, NbSegm; PU; * PU;PA x,y;PD;AA start_arc_X, start_arc_Y, angle, NbSegm; PU;
ou PU;PA x,y;PD;AA start_arc_X, start_arc_Y, angle; PU; * ou PU;PA x,y;PD;AA start_arc_X, start_arc_Y, angle; PU;
*/ */
{ {
char Line[256]; char Line[256];
wxPoint cmap; /* point de depart */ wxPoint cmap; /* point de depart */
wxPoint cpos; /* centre */ wxPoint cpos; /* centre */
float angle; /* angle de l'arc*/ float angle; /* angle de l'arc*/
if(rayon <= 0 ) return ; if( rayon <= 0 )
return;
cpos = centre; UserToDeviceCoordinate(cpos); cpos = centre; UserToDeviceCoordinate( cpos );
if( PlotOrientOptions == PLOT_MIROIR) if( PlotOrientOptions == PLOT_MIROIR )
{ {
EndAngle = - EndAngle; EndAngle = -EndAngle;
StAngle = - StAngle; StAngle = -StAngle;
EXCHG (StAngle, EndAngle); EXCHG( StAngle, EndAngle );
} }
angle = (EndAngle - StAngle) /10.0; angle = (EndAngle - StAngle) / 10.0;
/* Calcul des coord du point de depart : */ /* Calcul des coord du point de depart : */
cmap.x = (int)( centre.x + ( rayon * cos(StAngle * M_PI / 1800 ) ) ); cmap.x = (int) ( centre.x + ( rayon * cos( StAngle * M_PI / 1800 ) ) );
cmap.y = (int)(centre.y + ( rayon * sin(StAngle * M_PI / 1800 ) ) ); cmap.y = (int) ( centre.y + ( rayon * sin( StAngle * M_PI / 1800 ) ) );
UserToDeviceCoordinate(cmap); UserToDeviceCoordinate( cmap );
Plume_HPGL('U'); Plume_HPGL( 'U' );
sprintf(Line,"PU;PA %d,%d;PD;AA %d,%d, ", cmap.x, cmap.y, cpos.x, cpos.y); sprintf( Line, "PU;PA %d,%d;PD;AA %d,%d, ", cmap.x, cmap.y, cpos.x, cpos.y );
fputs(Line,PlotOutputFile) ; fputs( Line, PlotOutputFile );
sprintf(Line,"%f", - angle); to_point(Line); // Transforme , et . du separateur sprintf( Line, "%f", -angle ); to_point( Line ); // Transforme , et . du separateur
fputs(Line,PlotOutputFile) ; fputs( Line, PlotOutputFile );
sprintf(Line,", %d", CHORD_ANGLE); fputs(Line,PlotOutputFile) ; sprintf( Line, ", %d", CHORD_ANGLE ); fputs( Line, PlotOutputFile );
sprintf(Line,";PU;\n"); fputs(Line,PlotOutputFile) ; sprintf( Line, ";PU;\n" ); fputs( Line, PlotOutputFile );
Plume_HPGL('U'); Plume_HPGL( 'U' );
} }
/*****************************************************/ /*****************************************************/
void PlotPolyHPGL( int nb, int * coord, int fill, int width) void PlotPolyHPGL( int nb, int* coord, int fill, int width )
/*****************************************************/ /*****************************************************/
/* Trace un polygone (ferme si rempli) en format HPGL /* Trace un polygone (ferme si rempli) en format HPGL
coord = tableau des coord des sommets * coord = tableau des coord des sommets
nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau ) * nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau )
fill : si != 0 polygone rempli * fill : si != 0 polygone rempli
*/ */
{ {
int ii; int ii;
if( nb <= 1 ) return;
Move_Plume_HPGL( wxPoint(coord[0],coord[1]), 'U'); if( nb <= 1 )
for( ii = 1; ii < nb ; ii ++ ) return;
Move_Plume_HPGL( wxPoint( coord[0], coord[1] ), 'U' );
for( ii = 1; ii < nb; ii++ )
{ {
Move_Plume_HPGL( wxPoint(coord[ii * 2],coord[(ii*2) +1]), 'D'); Move_Plume_HPGL( wxPoint( coord[ii * 2], coord[(ii * 2) + 1] ), 'D' );
} }
/* Fermeture eventuelle du polygone */ /* Fermeture eventuelle du polygone */
if ( fill ) if( fill )
{ {
ii = (nb - 1) * 2; ii = (nb - 1) * 2;
if( (coord[ii] != coord[0] ) || (coord[ii+1] != coord[0]) ) if( (coord[ii] != coord[0] ) || (coord[ii + 1] != coord[0]) )
Move_Plume_HPGL( wxPoint(coord[0],coord[1]), 'D'); Move_Plume_HPGL( wxPoint( coord[0], coord[1] ), 'D' );
} }
Plume_HPGL('U'); Plume_HPGL( 'U' );
} }
/**********************************************/ /**********************************************/
void Move_Plume_HPGL( wxPoint pos, int plume ) void Move_Plume_HPGL( wxPoint pos, int plume )
/**********************************************/ /**********************************************/
/* /*
deplace la plume levee (plume = 'U') ou baissee (plume = 'D') * deplace la plume levee (plume = 'U') ou baissee (plume = 'D')
en position x,y * en position x,y
Unites en Unites DESSIN * Unites en Unites DESSIN
Si plume = 'Z' lever de plume sans deplacement * Si plume = 'Z' lever de plume sans deplacement
*/ */
{ {
char Line[256]; char Line[256];
if ( plume == 'Z') if( plume == 'Z' )
{ {
Plume_HPGL('U'); Plume_HPGL( 'U' );
return; return;
} }
Plume_HPGL(plume); Plume_HPGL( plume );
UserToDeviceCoordinate(pos); UserToDeviceCoordinate( pos );
sprintf(Line,"PA %d,%d;\n",pos.x,pos.y) ; fputs(Line,PlotOutputFile) ; sprintf( Line, "PA %d,%d;\n", pos.x, pos.y ); fputs( Line, PlotOutputFile );
} }
/***************************/ /***************************/
void Plume_HPGL( int plume ) void Plume_HPGL( int plume )
/***************************/ /***************************/
/* leve (plume = 'U') ou baisse (plume = 'D') la plume /* leve (plume = 'U') ou baisse (plume = 'D') la plume
*/ */
{ {
if ( plume == 'U') if( plume == 'U' )
{ {
if(etat_plume != 'U' ) fputs("PU;",PlotOutputFile) ; if( etat_plume != 'U' )
fputs( "PU;", PlotOutputFile );
etat_plume = 'U'; etat_plume = 'U';
} }
else else
{ {
if(etat_plume != 'D' )fputs("PD;",PlotOutputFile) ; if( etat_plume != 'D' )
fputs( "PD;", PlotOutputFile );
etat_plume = 'D'; etat_plume = 'D';
} }
} }
/******************************************/ /******************************************/
/* Kicad: Common plot Postscript Routines */ /* Kicad: Common plot Postscript Routines */
/******************************************/ /******************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -16,18 +16,18 @@ ...@@ -16,18 +16,18 @@
// Variables partagees avec Common plot Postscript Routines // Variables partagees avec Common plot Postscript Routines
extern wxPoint LastPenPosition; extern wxPoint LastPenPosition;
extern wxPoint PlotOffset; extern wxPoint PlotOffset;
extern FILE * PlotOutputFile; extern FILE* PlotOutputFile;
extern double XScale, YScale; extern double XScale, YScale;
extern int g_DefaultPenWidth, g_CurrentPenWidth; extern int g_DefaultPenWidth, g_CurrentPenWidth;
extern int PlotOrientOptions, etat_plume; extern int PlotOrientOptions, etat_plume;
// Locales // Locales
static Ki_PageDescr * SheetPS; static Ki_PageDescr* SheetPS;
/*************************************************************************************/ /*************************************************************************************/
void InitPlotParametresPS(wxPoint offset, Ki_PageDescr * sheet, void InitPlotParametresPS( wxPoint offset, Ki_PageDescr* sheet,
double xscale, double yscale, int orient) double xscale, double yscale, int orient )
/*************************************************************************************/ /*************************************************************************************/
/* Set the plot offset for the current plotting /* Set the plot offset for the current plotting
...@@ -45,7 +45,7 @@ void InitPlotParametresPS(wxPoint offset, Ki_PageDescr * sheet, ...@@ -45,7 +45,7 @@ void InitPlotParametresPS(wxPoint offset, Ki_PageDescr * sheet,
/*************************************************************************************/ /*************************************************************************************/
void SetDefaultLineWidthPS(int width) void SetDefaultLineWidthPS( int width )
/*************************************************************************************/ /*************************************************************************************/
/* Set the default line width (in 1/1000 inch) for the current plotting /* Set the default line width (in 1/1000 inch) for the current plotting
...@@ -57,13 +57,15 @@ void SetDefaultLineWidthPS(int width) ...@@ -57,13 +57,15 @@ void SetDefaultLineWidthPS(int width)
/***************************************/ /***************************************/
void SetCurrentLineWidthPS(int width) void SetCurrentLineWidthPS( int width )
/***************************************/ /***************************************/
/* Set the Current line width (in 1/1000 inch) for the next plot /* Set the Current line width (in 1/1000 inch) for the next plot
*/ */
{ {
int pen_width; D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)
int pen_width;
if( width > 0 ) if( width > 0 )
pen_width = width; pen_width = width;
...@@ -71,14 +73,14 @@ int pen_width; ...@@ -71,14 +73,14 @@ int pen_width;
pen_width = g_DefaultPenWidth; pen_width = g_DefaultPenWidth;
if( pen_width != g_CurrentPenWidth ) if( pen_width != g_CurrentPenWidth )
fprintf(PlotOutputFile, "%d setlinewidth\n", (int)(XScale * pen_width) ); fprintf( PlotOutputFile, "%d setlinewidth\n", (int) (XScale * pen_width) );
g_CurrentPenWidth = pen_width; g_CurrentPenWidth = pen_width;
} }
/******************************/ /******************************/
void SetColorMapPS(int color) void SetColorMapPS( int color )
/******************************/ /******************************/
/* Print the postscript set color command: /* Print the postscript set color command:
...@@ -88,82 +90,92 @@ void SetColorMapPS(int color) ...@@ -88,82 +90,92 @@ void SetColorMapPS(int color)
* color = color index in ColorRefs[] * color = color index in ColorRefs[]
*/ */
{ {
char Line[1024]; D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)
char Line[1024];
sprintf( Line, "%.3f %.3f %.3f setrgbcolor\n", sprintf( Line, "%.3f %.3f %.3f setrgbcolor\n",
(float)ColorRefs[color].m_Red / 255, (float) ColorRefs[color].m_Red / 255,
(float)ColorRefs[color].m_Green / 255, (float) ColorRefs[color].m_Green / 255,
(float)ColorRefs[color].m_Blue / 255 ); (float) ColorRefs[color].m_Blue / 255 );
to_point(Line); to_point( Line );
fputs( Line, PlotOutputFile ); fputs( Line, PlotOutputFile );
} }
/***************************************************************/ /***************************************************************/
void PlotFilledSegmentPS(wxPoint start, wxPoint end, int width) void PlotFilledSegmentPS( wxPoint start, wxPoint end, int width )
/***************************************************************/ /***************************************************************/
/* Plot 1 segment like a track segment /* Plot 1 segment like a track segment
*/ */
{ {
UserToDeviceCoordinate(start); D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)
UserToDeviceCoordinate(end);
UserToDeviceCoordinate( start );
UserToDeviceCoordinate( end );
SetCurrentLineWidthPS(width); SetCurrentLineWidthPS( width );
fprintf(PlotOutputFile,"%d %d %d %d line\n", start.x, start.y, end.x, end.y); fprintf( PlotOutputFile, "%d %d %d %d line\n", start.x, start.y, end.x, end.y );
} }
/******************************************************/ /******************************************************/
void PlotCircle_PS(wxPoint pos, int diametre, int width) void PlotCircle_PS( wxPoint pos, int diametre, int width )
/******************************************************/ /******************************************************/
{ {
int rayon; D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)
char Line[256];
UserToDeviceCoordinate(pos); int rayon;
rayon = (int)(XScale * diametre / 2); char Line[256];
UserToDeviceCoordinate( pos );
rayon = (int) (XScale * diametre / 2);
if( rayon < 0 ) if( rayon < 0 )
rayon = 0; rayon = 0;
SetCurrentLineWidthPS(width); SetCurrentLineWidthPS( width );
sprintf(Line, "newpath %d %d %d 0 360 arc stroke\n", pos.x, pos.y, rayon); sprintf( Line, "newpath %d %d %d 0 360 arc stroke\n", pos.x, pos.y, rayon );
fputs(Line, PlotOutputFile); fputs( Line, PlotOutputFile );
} }
/**************************************************************************************/ /**************************************************************************************/
void PlotArcPS(wxPoint centre, int StAngle, int EndAngle, int rayon, int width) void PlotArcPS( wxPoint centre, int StAngle, int EndAngle, int rayon, int width )
/**************************************************************************************/ /**************************************************************************************/
/* Plot an arc: /* Plot an arc:
* StAngle, EndAngle = start and end arc in 0.1 degree * StAngle, EndAngle = start and end arc in 0.1 degree
*/ */
{ {
char Line[256]; D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)
char Line[256];
if( rayon <= 0 ) if( rayon <= 0 )
return; return;
SetCurrentLineWidthPS(width); SetCurrentLineWidthPS( width );
// Calcul des coord du point de depart : // Calcul des coord du point de depart :
UserToDeviceCoordinate(centre); UserToDeviceCoordinate( centre );
if( PlotOrientOptions == PLOT_MIROIR ) if( PlotOrientOptions == PLOT_MIROIR )
sprintf( Line, "newpath %d %d %d %f %f arc stroke\n", centre.x, centre.y, sprintf( Line, "newpath %d %d %d %f %f arc stroke\n", centre.x, centre.y,
(int)(rayon * XScale), (float)StAngle / 10, (float)EndAngle / 10 ); (int) (rayon * XScale), (float) StAngle / 10, (float) EndAngle / 10 );
else else
sprintf( Line, "newpath %d %d %d %f %f arc stroke\n", centre.x, centre.y, sprintf( Line, "newpath %d %d %d %f %f arc stroke\n", centre.x, centre.y,
(int)(rayon * XScale), -(float)EndAngle / 10, -(float)StAngle / 10 ); (int) (rayon * XScale), -(float) EndAngle / 10, -(float) StAngle / 10 );
// Undo internationalization printf (float x.y printed x,y) // Undo internationalization printf (float x.y printed x,y)
to_point(Line); to_point( Line );
fputs(Line, PlotOutputFile); fputs( Line, PlotOutputFile );
} }
/*****************************************************************/ /*****************************************************************/
void PlotPolyPS(int nb_segm, int * coord, int fill, int width) void PlotPolyPS( int nb_segm, int* coord, int fill, int width )
/*****************************************************************/ /*****************************************************************/
/* Draw a polygon ( a filled polygon if fill == 1 ) in POSTSCRIPT format /* Draw a polygon ( a filled polygon if fill == 1 ) in POSTSCRIPT format
...@@ -173,62 +185,66 @@ void PlotPolyPS(int nb_segm, int * coord, int fill, int width) ...@@ -173,62 +185,66 @@ void PlotPolyPS(int nb_segm, int * coord, int fill, int width)
* @param width = line width * @param width = line width
*/ */
{ {
int ii; D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)
wxPoint pos;
int ii;
wxPoint pos;
if( nb_segm <= 1 ) if( nb_segm <= 1 )
return; return;
SetCurrentLineWidthPS(width); SetCurrentLineWidthPS( width );
pos.x = coord[0]; pos.x = coord[0];
pos.y = coord[1]; pos.y = coord[1];
UserToDeviceCoordinate(pos); UserToDeviceCoordinate( pos );
fprintf(PlotOutputFile, "newpath %d %d moveto\n", pos.x, pos.y); fprintf( PlotOutputFile, "newpath %d %d moveto\n", pos.x, pos.y );
for( ii = 1; ii < nb_segm; ii ++ ) for( ii = 1; ii < nb_segm; ii++ )
{ {
pos.x = coord[2 * ii]; pos.x = coord[2 * ii];
pos.y = coord[2 * ii + 1]; pos.y = coord[2 * ii + 1];
UserToDeviceCoordinate(pos); UserToDeviceCoordinate( pos );
fprintf(PlotOutputFile, "%d %d lineto\n", pos.x, pos.y); fprintf( PlotOutputFile, "%d %d lineto\n", pos.x, pos.y );
} }
// Fermeture du polygone // Fermeture du polygone
if( fill ) if( fill )
fprintf(PlotOutputFile, "closepath "); fprintf( PlotOutputFile, "closepath " );
if( fill == 1 ) if( fill == 1 )
fprintf(PlotOutputFile, "fill "); fprintf( PlotOutputFile, "fill " );
fprintf(PlotOutputFile, "stroke\n"); fprintf( PlotOutputFile, "stroke\n" );
} }
/*************************************/ /*************************************/
void LineTo_PS(wxPoint pos, int plume) void LineTo_PS( wxPoint pos, int plume )
/*************************************/ /*************************************/
/* Routine to draw to a new position /* Routine to draw to a new position
*/ */
{ {
D(printf( "PlotOutputFile = %p\n", PlotOutputFile );)
if( plume == 'Z' ) if( plume == 'Z' )
return; return;
UserToDeviceCoordinate(pos); UserToDeviceCoordinate( pos );
if( plume == 'D' ) if( plume == 'D' )
{ {
char Line[256]; char Line[256];
sprintf(Line, "%d %d %d %d line\n", sprintf( Line, "%d %d %d %d line\n",
LastPenPosition.x, LastPenPosition.y, pos.x, pos.y); LastPenPosition.x, LastPenPosition.y, pos.x, pos.y );
fputs(Line, PlotOutputFile); fputs( Line, PlotOutputFile );
} }
LastPenPosition = pos; LastPenPosition = pos;
} }
/***********************************************************/ /***********************************************************/
void PrintHeaderPS(FILE * file, const wxString & Creator, void PrintHeaderPS( FILE* file, const wxString& Creator,
const wxString & FileName, int PageCount, const wxString& FileName, int PageCount,
int BBox[4], int PaperOrientation) int BBox[4], int PaperOrientation )
/***********************************************************/ /***********************************************************/
/* The code within this function (and the CloseFilePS function) /* The code within this function (and the CloseFilePS function)
...@@ -249,56 +265,63 @@ void PrintHeaderPS(FILE * file, const wxString & Creator, ...@@ -249,56 +265,63 @@ void PrintHeaderPS(FILE * file, const wxString & Creator,
* for drawings (page - margins) in mils (0.001 inch) * for drawings (page - margins) in mils (0.001 inch)
*/ */
{ {
wxString msg; wxString msg;
char Line[1024]; char Line[1024];
const char *PSMacro[] = {
"/line {\n", static const char* PSMacro[] = {
" newpath\n", "/line {\n",
" moveto\n", " newpath\n",
" lineto\n", " moveto\n",
" stroke\n", " lineto\n",
"} def\n", " stroke\n",
"gsave\n", "} def\n",
"72 72 scale\t\t\t% Talk inches\n", "gsave\n",
"1 setlinecap\n", "72 72 scale\t\t\t% Talk inches\n",
"1 setlinejoin\n", "1 setlinecap\n",
"1 setlinewidth\n", "1 setlinejoin\n",
"1 setlinewidth\n",
NULL NULL
}; };
const double MIL_TO_INCH = 0.001;
int ii; const double MIL_TO_INCH = 0.001;
time_t time1970 = time(NULL); int ii;
time_t time1970 = time( NULL );
PlotOutputFile = file; PlotOutputFile = file;
fputs("%!PS-Adobe-3.0\n", PlotOutputFile); // Print header D(printf( "PrintHeaderPS PlotOutputFile = %p\n", PlotOutputFile );)
fputs( "%!PS-Adobe-3.0\n", PlotOutputFile ); // Print header
sprintf( Line, "%%%%Creator: %s\n", CONV_TO_UTF8(Creator) ); sprintf( Line, "%%%%Creator: %s\n", CONV_TO_UTF8( Creator ) );
fputs(Line, PlotOutputFile); fputs( Line, PlotOutputFile );
// A "newline" character ("\n") is not included in the following string, // A "newline" character ("\n") is not included in the following string,
// because it is provided by the ctime() function. // because it is provided by the ctime() function.
sprintf( Line, "%%%%CreationDate: %s", ctime(&time1970) ); sprintf( Line, "%%%%CreationDate: %s", ctime( &time1970 ) );
fputs(Line, PlotOutputFile); fputs( Line, PlotOutputFile );
sprintf( Line, "%%%%Title: %s\n", CONV_TO_UTF8(FileName) ); sprintf( Line, "%%%%Title: %s\n", CONV_TO_UTF8( FileName ) );
fputs(Line, PlotOutputFile); fputs( Line, PlotOutputFile );
sprintf( Line, "%%%%Pages: %d\n", PageCount ); sprintf( Line, "%%%%Pages: %d\n", PageCount );
fputs(Line, PlotOutputFile); fputs( Line, PlotOutputFile );
sprintf( Line, "%%%%PageOrder: Ascend\n" ); sprintf( Line, "%%%%PageOrder: Ascend\n" );
fputs(Line, PlotOutputFile); fputs( Line, PlotOutputFile );
// Print boundary box en 1/72 pouce, box is in mils // Print boundary box en 1/72 pouce, box is in mils
const double CONV_SCALE = MIL_TO_INCH * 72; const double CONV_SCALE = MIL_TO_INCH * 72;
// The coordinates of the lower left corner of the boundary // The coordinates of the lower left corner of the boundary
// box need to be "rounded down", but the coordinates of its // box need to be "rounded down", but the coordinates of its
// upper right corner need to be "rounded up" instead. // upper right corner need to be "rounded up" instead.
sprintf( Line, "%%%%BoundingBox: %d %d %d %d\n", sprintf( Line, "%%%%BoundingBox: %d %d %d %d\n",
(int)floor((BBox[1] * CONV_SCALE)), (int)floor((BBox[0] * CONV_SCALE)), (int) floor( (BBox[1] * CONV_SCALE) ), (int) floor( (BBox[0] * CONV_SCALE) ),
(int)ceil((BBox[3] * CONV_SCALE)), (int)ceil((BBox[2] * CONV_SCALE)) ); (int) ceil( (BBox[3] * CONV_SCALE) ), (int) ceil( (BBox[2] * CONV_SCALE) ) );
fputs(Line, PlotOutputFile);
fputs( Line, PlotOutputFile );
// Specify the size of the sheet and the name associated with that size. // Specify the size of the sheet and the name associated with that size.
// (If the "User size" option has been selected for the sheet size, // (If the "User size" option has been selected for the sheet size,
...@@ -312,25 +335,27 @@ time_t time1970 = time(NULL); ...@@ -312,25 +335,27 @@ time_t time1970 = time(NULL);
// //
// (NOTE: m_Size.y is *supposed* to be listed before m_Size.x; // (NOTE: m_Size.y is *supposed* to be listed before m_Size.x;
// the order in which they are specified is not wrong!) // the order in which they are specified is not wrong!)
if( SheetPS->m_Name.Cmp( wxT("User") ) == 0 ) if( SheetPS->m_Name.Cmp( wxT( "User" ) ) == 0 )
sprintf( Line, "%%%%DocumentMedia: Custom %d %d 0 () ()\n", sprintf( Line, "%%%%DocumentMedia: Custom %d %d 0 () ()\n",
(int)round( SheetPS->m_Size.y * CONV_SCALE ), (int) round( SheetPS->m_Size.y * CONV_SCALE ),
(int)round( SheetPS->m_Size.x * CONV_SCALE ) ); (int) round( SheetPS->m_Size.x * CONV_SCALE ) );
else // ( if SheetPS->m_Name does not equal "User" ) else // ( if SheetPS->m_Name does not equal "User" )
sprintf( Line, "%%%%DocumentMedia: %s %d %d 0 () ()\n", sprintf( Line, "%%%%DocumentMedia: %s %d %d 0 () ()\n",
CONV_TO_UTF8( SheetPS->m_Name ), CONV_TO_UTF8( SheetPS->m_Name ),
(int)round( SheetPS->m_Size.y * CONV_SCALE ), (int) round( SheetPS->m_Size.y * CONV_SCALE ),
(int)round( SheetPS->m_Size.x * CONV_SCALE ) ); (int) round( SheetPS->m_Size.x * CONV_SCALE ) );
fputs(Line, PlotOutputFile); fputs( Line, PlotOutputFile );
if( PaperOrientation == wxPORTRAIT ) if( PaperOrientation == wxPORTRAIT )
sprintf( Line, "%%%%Orientation: Portrait\n" ); sprintf( Line, "%%%%Orientation: Portrait\n" );
else else
sprintf( Line, "%%%%Orientation: Landscape\n" ); sprintf( Line, "%%%%Orientation: Landscape\n" );
fputs(Line, PlotOutputFile);
fputs( Line, PlotOutputFile );
sprintf( Line, "%%%%EndComments\n" ); sprintf( Line, "%%%%EndComments\n" );
fputs(Line, PlotOutputFile); fputs( Line, PlotOutputFile );
// Now specify various other details. // Now specify various other details.
...@@ -339,45 +364,47 @@ time_t time1970 = time(NULL); ...@@ -339,45 +364,47 @@ time_t time1970 = time(NULL);
// contents of the postscript file comply with the details specified // contents of the postscript file comply with the details specified
// within the Document Structuring Convention. // within the Document Structuring Convention.
sprintf( Line, "%%%%Page: 1 1\n" ); sprintf( Line, "%%%%Page: 1 1\n" );
fputs(Line, PlotOutputFile); fputs( Line, PlotOutputFile );
for ( ii = 0; PSMacro[ii] != NULL; ii++ ) for( ii = 0; PSMacro[ii] != NULL; ii++ )
{ {
fputs(PSMacro[ii], PlotOutputFile); fputs( PSMacro[ii], PlotOutputFile );
} }
if( PaperOrientation == wxLANDSCAPE ) if( PaperOrientation == wxLANDSCAPE )
sprintf(Line, "%f %f translate 90 rotate\n", sprintf( Line, "%f %f translate 90 rotate\n",
(float)BBox[3] * MIL_TO_INCH, (float)BBox[0] * MIL_TO_INCH); (float) BBox[3] * MIL_TO_INCH, (float) BBox[0] * MIL_TO_INCH );
// (If support for creating postscript files with a portrait orientation // (If support for creating postscript files with a portrait orientation
// is ever provided, determine whether it would be necessary to provide // is ever provided, determine whether it would be necessary to provide
// an "else" command and then an appropriate "sprintf" command here.) // an "else" command and then an appropriate "sprintf" command here.)
// compensation internationalisation printf (float x.y gnr x,y) // compensation internationalisation printf (float x.y gnr x,y)
to_point(Line); to_point( Line );
fputs(Line, PlotOutputFile); fputs( Line, PlotOutputFile );
sprintf(Line, "%f %f scale\t\t%% Move to User coordinates\n", sprintf( Line, "%f %f scale\t\t%% Move to User coordinates\n",
XScale, YScale); XScale, YScale );
to_point(Line); to_point( Line );
fputs(Line, PlotOutputFile); fputs( Line, PlotOutputFile );
// Set default line width ( g_DefaultPenWidth is in user units ) // Set default line width ( g_DefaultPenWidth is in user units )
fprintf(PlotOutputFile, "%d setlinewidth\n", g_DefaultPenWidth); fprintf( PlotOutputFile, "%d setlinewidth\n", g_DefaultPenWidth );
} }
/******************************************/ /******************************************/
bool CloseFilePS(FILE * plot_file) bool CloseFilePS( FILE* plot_file )
/******************************************/ /******************************************/
{ {
fputs("showpage\n", plot_file); D(printf( "CloseFilePS\n" );)
fputs("grestore\n", plot_file);
fputs("%%EOF\n", plot_file);
fclose(plot_file); fputs( "showpage\n", plot_file );
fputs( "grestore\n", plot_file );
fputs( "%%EOF\n", plot_file );
fclose( plot_file );
return TRUE; return TRUE;
} }
/******************************************/ /******************************************/
/* Kicad: Common plot Postscript Routines */ /* Kicad: Common plot Postscript Routines */
/******************************************/ /******************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
// Variables partagees avec Common plot Postscript et HPLG Routines // Variables partagees avec Common plot Postscript et HPLG Routines
wxPoint LastPenPosition; wxPoint LastPenPosition;
wxPoint PlotOffset; wxPoint PlotOffset;
FILE * PlotOutputFile; FILE* PlotOutputFile;
double XScale, YScale; double XScale, YScale;
int g_DefaultPenWidth; int g_DefaultPenWidth;
int g_CurrentPenWidth = -1; int g_CurrentPenWidth = -1;
...@@ -24,43 +24,50 @@ int PlotOrientOptions, etat_plume; ...@@ -24,43 +24,50 @@ int PlotOrientOptions, etat_plume;
// Locales // Locales
static Ki_PageDescr * SheetPS; static Ki_PageDescr* SheetPS;
/*************************/ /*************************/
void ForcePenReinit() void ForcePenReinit()
/*************************/ /*************************/
/* set the flag g_CurrentPenWidth to -1 in order to force a pen width redefinition /* set the flag g_CurrentPenWidth to -1 in order to force a pen width redefinition
for the next draw command * for the next draw command
*/ */
{ {
g_CurrentPenWidth = -1; g_CurrentPenWidth = -1;
} }
/**********************************************/ /**********************************************/
void SetPlotScale(double xscale, double yscale) void SetPlotScale( double xscale, double yscale )
/**********************************************/ /**********************************************/
/* Set the plot scale for the current plotting) /* Set the plot scale for the current plotting)
*/ */
{ {
XScale = xscale; XScale = xscale;
YScale = yscale; YScale = yscale;
} }
/*********************************/ /*********************************/
void SetPlotOffset(wxPoint offset) void SetPlotOffset( wxPoint offset )
/*********************************/ /*********************************/
/* Set the plot offset for the current plotting) /* Set the plot offset for the current plotting)
*/ */
{ {
PlotOffset = offset; PlotOffset = offset;
} }
/***************************************************************************/ /***************************************************************************/
void InitPlotParametresGERBER(wxPoint offset, double xscale, double yscale) void InitPlotParametresGERBER( wxPoint offset, double xscale, double yscale )
/***************************************************************************/ /***************************************************************************/
/* Set the plot offset for the current plotting /* Set the plot offset for the current plotting
xscale,yscale = coordinate scale (scale coefficient for coordinates) * xscale,yscale = coordinate scale (scale coefficient for coordinates)
*/ */
{ {
PlotOrientOptions = 0; PlotOrientOptions = 0;
PlotOffset = offset; PlotOffset = offset;
...@@ -73,27 +80,28 @@ void InitPlotParametresGERBER(wxPoint offset, double xscale, double yscale) ...@@ -73,27 +80,28 @@ void InitPlotParametresGERBER(wxPoint offset, double xscale, double yscale)
/*******************************************************/ /*******************************************************/
void PlotWorkSheet(int format_plot, BASE_SCREEN * screen) void PlotWorkSheet( int format_plot, BASE_SCREEN* screen )
/*******************************************************/ /*******************************************************/
/* Plot sheet references /* Plot sheet references
margin is in mils (1/1000 inch) * margin is in mils (1/1000 inch)
*/ */
{ {
#define WSTEXTSIZE 50 // Text size in mils #define WSTEXTSIZE 50 // Text size in mils
Ki_PageDescr * Sheet = screen->m_CurrentSheetDesc; Ki_PageDescr* Sheet = screen->m_CurrentSheetDesc;
int ii, jj, xg , yg, ipas, gxpas, gypas; int ii, jj, xg, yg, ipas, gxpas, gypas;
wxSize PageSize; wxSize PageSize;
wxPoint pos, ref; wxPoint pos, ref;
int color; int color;
Ki_WorkSheetData * WsItem; Ki_WorkSheetData* WsItem;
int conv_unit = screen->GetInternalUnits()/1000; /* Scale to convert dimension in 1/1000 in into internal units int conv_unit = screen->GetInternalUnits() / 1000; /* Scale to convert dimension in 1/1000 in into internal units
(1/1000 inc for EESchema, 1/10000 for pcbnew */ * (1/1000 inc for EESchema, 1/10000 for pcbnew */
wxString msg; wxString msg;
wxSize text_size; wxSize text_size;
void (*FctPlume)(wxPoint pos, int state); void (*FctPlume)( wxPoint pos, int state );
int UpperLimit = VARIABLE_BLOCK_START_POSITION; int UpperLimit = VARIABLE_BLOCK_START_POSITION;
switch ( format_plot) switch( format_plot )
{ {
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
FctPlume = LineTo_PS; FctPlume = LineTo_PS;
...@@ -119,16 +127,16 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION; ...@@ -119,16 +127,16 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION;
xg = (PageSize.x - Sheet->m_RightMargin) * conv_unit; xg = (PageSize.x - Sheet->m_RightMargin) * conv_unit;
yg = (PageSize.y - Sheet->m_BottomMargin) * conv_unit; /* lower right corner */ yg = (PageSize.y - Sheet->m_BottomMargin) * conv_unit; /* lower right corner */
for ( ii = 0; ii < 2 ; ii++ ) for( ii = 0; ii < 2; ii++ )
{ {
FctPlume(ref,'U'); FctPlume( ref, 'U' );
pos.x = xg; pos.y = ref.y; pos.x = xg; pos.y = ref.y;
FctPlume(pos,'D'); FctPlume( pos, 'D' );
pos.x = xg; pos.y = yg; pos.x = xg; pos.y = yg;
FctPlume(pos,'D'); FctPlume( pos, 'D' );
pos.x = ref.x; pos.y = yg; pos.x = ref.x; pos.y = yg;
FctPlume( pos,'D' ); FctPlume( pos, 'D' );
FctPlume(ref,'D'); FctPlume( ref, 'D' );
ref.x += GRID_REF_W * conv_unit; ref.y += GRID_REF_W * conv_unit; ref.x += GRID_REF_W * conv_unit; ref.y += GRID_REF_W * conv_unit;
xg -= GRID_REF_W * conv_unit; yg -= GRID_REF_W * conv_unit; xg -= GRID_REF_W * conv_unit; yg -= GRID_REF_W * conv_unit;
} }
...@@ -145,66 +153,66 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION; ...@@ -145,66 +153,66 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION;
/* Trace des reperes selon l'axe X */ /* Trace des reperes selon l'axe X */
ipas = (xg - ref.x) / PAS_REF; ipas = (xg - ref.x) / PAS_REF;
gxpas = ( xg - ref.x) / ipas; gxpas = ( xg - ref.x) / ipas;
for ( ii = ref.x + gxpas, jj = 1; ipas > 0 ; ii += gxpas , jj++, ipas--) for( ii = ref.x + gxpas, jj = 1; ipas > 0; ii += gxpas, jj++, ipas-- )
{ {
msg.Empty(); msg << jj; msg.Empty(); msg << jj;
if( ii < xg - PAS_REF/2 ) if( ii < xg - PAS_REF / 2 )
{ {
pos.x = ii * conv_unit; pos.y = ref.y * conv_unit; pos.x = ii * conv_unit; pos.y = ref.y * conv_unit;
FctPlume(pos, 'U'); FctPlume( pos, 'U' );
pos.x = ii * conv_unit; pos.y = (ref.y + GRID_REF_W) * conv_unit; pos.x = ii * conv_unit; pos.y = (ref.y + GRID_REF_W) * conv_unit;
FctPlume(pos,'D'); FctPlume( pos, 'D' );
} }
pos.x = (ii - gxpas/2) * conv_unit; pos.x = (ii - gxpas / 2) * conv_unit;
pos.y = (ref.y + GRID_REF_W/2) * conv_unit; pos.y = (ref.y + GRID_REF_W / 2) * conv_unit;
PlotGraphicText(format_plot, pos, color, PlotGraphicText( format_plot, pos, color,
msg, TEXT_ORIENT_HORIZ,text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER );
if( ii < xg - PAS_REF/2 ) if( ii < xg - PAS_REF / 2 )
{ {
pos.x = ii * conv_unit; pos.y = yg * conv_unit; pos.x = ii * conv_unit; pos.y = yg * conv_unit;
FctPlume(pos,'U'); FctPlume( pos, 'U' );
pos.x = ii * conv_unit; pos.y = (yg - GRID_REF_W) * conv_unit; pos.x = ii * conv_unit; pos.y = (yg - GRID_REF_W) * conv_unit;
FctPlume(pos,'D'); FctPlume( pos, 'D' );
} }
pos.x = (ii - gxpas/2) * conv_unit; pos.x = (ii - gxpas / 2) * conv_unit;
pos.y = (yg - GRID_REF_W/2) * conv_unit; pos.y = (yg - GRID_REF_W / 2) * conv_unit;
PlotGraphicText(format_plot, pos, color, PlotGraphicText( format_plot, pos, color,
msg, TEXT_ORIENT_HORIZ,text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER );
} }
/* Trace des reperes selon l'axe Y */ /* Trace des reperes selon l'axe Y */
ipas = (yg - ref.y) / PAS_REF; ipas = (yg - ref.y) / PAS_REF;
gypas = ( yg - ref.y) / ipas; gypas = ( yg - ref.y) / ipas;
for ( ii = ref.y + gypas, jj = 0; ipas > 0 ; ii += gypas , jj++, ipas--) for( ii = ref.y + gypas, jj = 0; ipas > 0; ii += gypas, jj++, ipas-- )
{ {
msg.Empty(); msg << jj; msg.Empty(); msg << jj;
if( ii < yg - PAS_REF/2 ) if( ii < yg - PAS_REF / 2 )
{ {
pos.x = ref.x * conv_unit; pos.y = ii * conv_unit; pos.x = ref.x * conv_unit; pos.y = ii * conv_unit;
FctPlume(pos,'U'); FctPlume( pos, 'U' );
pos.x = (ref.x + GRID_REF_W) * conv_unit; pos.y = ii * conv_unit; pos.x = (ref.x + GRID_REF_W) * conv_unit; pos.y = ii * conv_unit;
FctPlume(pos, 'D'); FctPlume( pos, 'D' );
} }
pos.x = (ref.x + GRID_REF_W/2) * conv_unit; pos.x = (ref.x + GRID_REF_W / 2) * conv_unit;
pos.y = (ii - gypas/2) * conv_unit; pos.y = (ii - gypas / 2) * conv_unit;
PlotGraphicText(format_plot, pos, color, PlotGraphicText( format_plot, pos, color,
msg, TEXT_ORIENT_HORIZ,text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER );
if( ii < yg - PAS_REF/2 ) if( ii < yg - PAS_REF / 2 )
{ {
pos.x = xg * conv_unit; pos.y = ii * conv_unit; pos.x = xg * conv_unit; pos.y = ii * conv_unit;
FctPlume(pos,'U'); FctPlume( pos, 'U' );
pos.x = (xg - GRID_REF_W) * conv_unit; pos.y = ii * conv_unit; pos.x = (xg - GRID_REF_W) * conv_unit; pos.y = ii * conv_unit;
FctPlume(pos,'D'); FctPlume( pos, 'D' );
} }
pos.x = (xg - GRID_REF_W/2) * conv_unit; pos.x = (xg - GRID_REF_W / 2) * conv_unit;
pos.y = (ii - gypas/2) * conv_unit; pos.y = (ii - gypas / 2) * conv_unit;
PlotGraphicText(format_plot, pos, color, msg, TEXT_ORIENT_HORIZ,text_size, PlotGraphicText( format_plot, pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER );
} }
/* Trace du cartouche */ /* Trace du cartouche */
...@@ -217,8 +225,11 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION; ...@@ -217,8 +225,11 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION;
{ {
pos.x = (ref.x - WsItem->m_Posx) * conv_unit; pos.x = (ref.x - WsItem->m_Posx) * conv_unit;
pos.y = (ref.y - WsItem->m_Posy) * conv_unit; pos.y = (ref.y - WsItem->m_Posy) * conv_unit;
if(WsItem->m_Legende) msg = WsItem->m_Legende; if( WsItem->m_Legende )
else msg.Empty(); msg = WsItem->m_Legende;
else
msg.Empty();
switch( WsItem->m_Type ) switch( WsItem->m_Type )
{ {
case WS_DATE: case WS_DATE:
...@@ -238,25 +249,26 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION; ...@@ -238,25 +249,26 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION;
break; break;
case WS_IDENTSHEET: case WS_IDENTSHEET:
msg << screen->m_ScreenNumber << wxT("/") << screen->m_NumberOfScreen; msg << screen->m_ScreenNumber << wxT( "/" ) << screen->m_NumberOfScreen;
break; break;
case WS_FILENAME: case WS_FILENAME:
{ {
wxString fname, fext; wxString fname, fext;
wxFileName::SplitPath(screen->m_FileName, (wxString*)NULL, &fname, &fext); wxFileName::SplitPath( screen->m_FileName, (wxString*) NULL, &fname, &fext );
msg << fname << wxT(".") << fext; msg << fname << wxT( "." ) << fext;
} }
break; break;
case WS_FULLSHEETNAME: case WS_FULLSHEETNAME:
// msg += GetScreenDesc(); // msg += GetScreenDesc();
break; break;
case WS_COMPANY_NAME: case WS_COMPANY_NAME:
msg += screen->m_Company; msg += screen->m_Company;
if ( ! msg.IsEmpty() ) if( !msg.IsEmpty() )
UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
break; break;
case WS_TITLE: case WS_TITLE:
...@@ -265,59 +277,63 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION; ...@@ -265,59 +277,63 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION;
case WS_COMMENT1: case WS_COMMENT1:
msg += screen->m_Commentaire1; msg += screen->m_Commentaire1;
if ( ! msg.IsEmpty() ) if( !msg.IsEmpty() )
UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
break; break;
case WS_COMMENT2: case WS_COMMENT2:
msg += screen->m_Commentaire2; msg += screen->m_Commentaire2;
if ( ! msg.IsEmpty() ) if( !msg.IsEmpty() )
UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
break; break;
case WS_COMMENT3: case WS_COMMENT3:
msg += screen->m_Commentaire3; msg += screen->m_Commentaire3;
if ( ! msg.IsEmpty() ) if( !msg.IsEmpty() )
UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
break; break;
case WS_COMMENT4: case WS_COMMENT4:
msg += screen->m_Commentaire4; msg += screen->m_Commentaire4;
if ( ! msg.IsEmpty() ) if( !msg.IsEmpty() )
UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
break; break;
case WS_UPPER_SEGMENT: case WS_UPPER_SEGMENT:
if (UpperLimit == 0 ) break; if( UpperLimit == 0 )
break;
case WS_LEFT_SEGMENT: case WS_LEFT_SEGMENT:
WS_MostUpperLine.m_Posy = WS_MostUpperLine.m_Posy =
WS_MostUpperLine.m_Endy = WS_MostUpperLine.m_Endy =
WS_MostLeftLine.m_Posy = UpperLimit; WS_MostLeftLine.m_Posy = UpperLimit;
pos.y = (ref.y - WsItem->m_Posy) * conv_unit; pos.y = (ref.y - WsItem->m_Posy) * conv_unit;
case WS_SEGMENT: case WS_SEGMENT:
{ {
wxPoint auxpos; wxPoint auxpos;
auxpos.x = (ref.x - WsItem->m_Endx) * conv_unit;; auxpos.x = (ref.x - WsItem->m_Endx) * conv_unit;;
auxpos.y = (ref.y - WsItem->m_Endy) * conv_unit;; auxpos.y = (ref.y - WsItem->m_Endy) * conv_unit;;
FctPlume(pos, 'U'); FctPlume( pos, 'U' );
FctPlume(auxpos, 'D'); FctPlume( auxpos, 'D' );
} }
break; break;
} }
if ( ! msg.IsEmpty() )
if( !msg.IsEmpty() )
{ {
PlotGraphicText(format_plot, pos, color, PlotGraphicText( format_plot, pos, color,
msg.GetData(), TEXT_ORIENT_HORIZ,text_size, msg.GetData(), TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER );
} }
} }
switch ( format_plot ) switch( format_plot )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
Plume_HPGL('U'); Plume_HPGL( 'U' );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
break; break;
} }
...@@ -325,34 +341,33 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION; ...@@ -325,34 +341,33 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION;
/******************************************/ /******************************************/
void UserToDeviceCoordinate(wxPoint & pos ) void UserToDeviceCoordinate( wxPoint& pos )
/******************************************/ /******************************************/
/* modifie les coord pos.x et pos.y pour le trace selon l'orientation, /* modifie les coord pos.x et pos.y pour le trace selon l'orientation,
l'echelle, les offsets de trace */ * l'echelle, les offsets de trace */
{ {
pos.x = (int) (pos.x * XScale); pos.x = (int) (pos.x * XScale);
pos.y = (int) (pos.y * YScale); pos.y = (int) (pos.y * YScale);
switch ( PlotOrientOptions) /* Calcul du cadrage */ switch( PlotOrientOptions ) /* Calcul du cadrage */
{ {
default : default:
pos.x -= PlotOffset.x ; pos.y = PlotOffset.y - pos.y; pos.x -= PlotOffset.x; pos.y = PlotOffset.y - pos.y;
break ; break;
case PLOT_MIROIR :
pos.x -= PlotOffset.x ; pos.y = - PlotOffset.y + pos.y;
break ;
case PLOT_MIROIR:
pos.x -= PlotOffset.x; pos.y = -PlotOffset.y + pos.y;
break;
} }
} }
/************************************/ /************************************/
void UserToDeviceSize(wxSize & size ) void UserToDeviceSize( wxSize& size )
/************************************/ /************************************/
/* modifie les dimension size.x et size.y pour le trace selon l'echelle */ /* modifie les dimension size.x et size.y pour le trace selon l'echelle */
{ {
size.x = (int) (size.x * XScale); size.x = (int) (size.x * XScale);
size.y = (int) (size.y * YScale); size.y = (int) (size.y * YScale);
} }
...@@ -326,7 +326,7 @@ void PlotGraphicText( int format_plot, const wxPoint& Pos, int gcolor, ...@@ -326,7 +326,7 @@ void PlotGraphicText( int format_plot, const wxPoint& Pos, int gcolor,
return; return;
} }
if( (gcolor >= 0) && (format_plot == PLOT_FORMAT_POST) ) if( gcolor >= 0 && IsPostScript( format_plot ) )
SetColorMapPS( gcolor ); SetColorMapPS( gcolor );
size_h = Size.x; size_h = Size.x;
......
/**************************************/ /**************************************/
/* Module to handle screen printing. */ /* Module to handle screen printing. */
/**************************************/ /**************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -17,63 +17,73 @@ extern void Move_Plume( wxPoint pos, int plume ); // see plot.cpp ...@@ -17,63 +17,73 @@ extern void Move_Plume( wxPoint pos, int plume ); // see plot.cpp
/***************************************************************************** /*****************************************************************************
Put out pin number and pin text info, given the pin line coordinates. * Put out pin number and pin text info, given the pin line coordinates.
The line must be vertical or horizontal. * The line must be vertical or horizontal.
If PinText == NULL nothing is printed. If PinNum = 0 no number is printed. * If PinText == NULL nothing is printed. If PinNum = 0 no number is printed.
Current Zoom factor is taken into account. * Current Zoom factor is taken into account.
If TextInside then the text is been put inside,otherwise all is drawn outside. * If TextInside then the text is been put inside,otherwise all is drawn outside.
Pin Name: substring beteween '~' is negated * Pin Name: substring beteween '~' is negated
*****************************************************************************/ *****************************************************************************/
void LibDrawPin::DrawPinTexts(WinEDA_DrawPanel * panel, wxDC * DC, void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
wxPoint & pin_pos, int orient, wxPoint& pin_pos, int orient,
int TextInside, bool DrawPinNum, bool DrawPinName, int TextInside, bool DrawPinNum, bool DrawPinName,
int Color, int DrawMode) int Color, int DrawMode )
/* DrawMode = GR_OR, XOR ... */ /* DrawMode = GR_OR, XOR ... */
{ {
int ii, x, y, x1, y1, dx, dy, len; int ii, x, y, x1, y1, dx, dy, len;
wxString StringPinNum; wxString StringPinNum;
wxString PinText; wxString PinText;
int PinTextBarPos[256]; int PinTextBarPos[256];
int PinTextBarCount; int PinTextBarCount;
int NameColor, NumColor; int NameColor, NumColor;
int PinTxtLen; int PinTxtLen;
wxSize PinNameSize(m_PinNameSize,m_PinNameSize);
wxSize PinNumSize(m_PinNumSize,m_PinNumSize); wxSize PinNameSize( m_PinNameSize, m_PinNameSize );
int LineWidth = g_DrawMinimunLineWidth; wxSize PinNumSize( m_PinNumSize, m_PinNumSize );
GRSetDrawMode(DC, DrawMode); int LineWidth = g_DrawMinimunLineWidth;
GRSetDrawMode( DC, DrawMode );
/* Get the num and name colors */ /* Get the num and name colors */
NameColor = Color == - 1 ? ReturnLayerColor(LAYER_PINNAM) : Color; NameColor = Color == -1 ? ReturnLayerColor( LAYER_PINNAM ) : Color;
NumColor = Color == - 1 ? ReturnLayerColor(LAYER_PINNUM) : Color; NumColor = Color == -1 ? ReturnLayerColor( LAYER_PINNUM ) : Color;
/* Create the pin num string */ /* Create the pin num string */
ReturnPinStringNum(StringPinNum); ReturnPinStringNum( StringPinNum );
x1 = pin_pos.x; y1 = pin_pos.y; x1 = pin_pos.x; y1 = pin_pos.y;
switch(orient)
switch( orient )
{ {
case PIN_UP: y1 -= m_PinLen; break; case PIN_UP:
case PIN_DOWN: y1 += m_PinLen; break; y1 -= m_PinLen; break;
case PIN_LEFT: x1 -= m_PinLen; break;
case PIN_RIGHT: x1 += m_PinLen; break; case PIN_DOWN:
y1 += m_PinLen; break;
case PIN_LEFT:
x1 -= m_PinLen; break;
case PIN_RIGHT:
x1 += m_PinLen; break;
} }
const wxChar * textsrc = m_PinName.GetData(); const wxChar* textsrc = m_PinName.GetData();
float fPinTextPitch = PinNameSize.x * 1.1; float fPinTextPitch = PinNameSize.x * 1.1;
/* Do we need to invert the string? Is this string has only "~"? */ /* Do we need to invert the string? Is this string has only "~"? */
PinTextBarCount = 0; PinTxtLen = 0; PinTextBarCount = 0; PinTxtLen = 0;
ii = 0; ii = 0;
while ( * textsrc ) while( *textsrc )
{ {
if ( * textsrc == '~' ) if( *textsrc == '~' )
{ {
PinTextBarPos[PinTextBarCount++] = (int)(PinTxtLen * fPinTextPitch); PinTextBarPos[PinTextBarCount++] = (int) (PinTxtLen * fPinTextPitch);
} }
else else
{ {
PinText.Append(* textsrc); PinText.Append( *textsrc );
PinTxtLen ++; PinTxtLen++;
} }
textsrc++; textsrc++;
...@@ -82,183 +92,184 @@ int LineWidth = g_DrawMinimunLineWidth; ...@@ -82,183 +92,184 @@ int LineWidth = g_DrawMinimunLineWidth;
PinTxtLen = (int) (fPinTextPitch * PinTxtLen); PinTxtLen = (int) (fPinTextPitch * PinTxtLen);
PinTextBarPos[PinTextBarCount] = PinTxtLen; // Needed if no end '~' PinTextBarPos[PinTextBarCount] = PinTxtLen; // Needed if no end '~'
if (PinText[0] == 0) DrawPinName = FALSE; if( PinText[0] == 0 )
DrawPinName = FALSE;
if( TextInside ) /* Draw the text inside, but the pin numbers outside. */ if( TextInside ) /* Draw the text inside, but the pin numbers outside. */
{ {
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
// It is an horizontal line // It is an horizontal line
{ {
if (PinText && DrawPinName) if( PinText && DrawPinName )
{ {
if( orient == PIN_RIGHT) if( orient == PIN_RIGHT )
{ {
x = x1 + TextInside; x = x1 + TextInside;
DrawGraphicText(panel, DC, wxPoint(x, y1), NameColor, PinText, DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor, PinText,
TEXT_ORIENT_HORIZ, TEXT_ORIENT_HORIZ,
PinNameSize, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, LineWidth); GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
for ( ii = 0; ii < PinTextBarCount; ) for( ii = 0; ii < PinTextBarCount; )
{ {
GRMoveTo(x, y1 - TXTMARGE); GRMoveTo( x, y1 - TXTMARGE );
dy = -PinNameSize.y / 2; dy = -PinNameSize.y / 2;
GRMoveRel(0, dy); GRMoveRel( 0, dy );
dx = PinTextBarPos[ii++]; // Get the line pos dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel(dx, 0); GRMoveRel( dx, 0 );
len = PinTextBarPos[ii++] - dx; // Get the line length len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel(&panel->m_ClipBox, DC, len, 0, LineWidth, NameColor); GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor );
} }
} }
else // Orient == PIN_LEFT else // Orient == PIN_LEFT
{ {
x = x1 - TextInside; x = x1 - TextInside;
DrawGraphicText(panel, DC, wxPoint(x, y1) , NameColor, PinText, DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor, PinText,
TEXT_ORIENT_HORIZ, TEXT_ORIENT_HORIZ,
PinNameSize, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth); GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
for ( ii = 0; ii < PinTextBarCount; ) for( ii = 0; ii < PinTextBarCount; )
{ {
GRMoveTo(x, y1 - TXTMARGE); GRMoveTo( x, y1 - TXTMARGE );
dy = -PinNameSize.y / 2; dy = -PinNameSize.y / 2;
GRMoveRel(0, dy); GRMoveRel( 0, dy );
dx = PinTextBarPos[ii++]; // Get the line pos dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel(dx - PinTxtLen, 0); GRMoveRel( dx - PinTxtLen, 0 );
len = PinTextBarPos[ii++] - dx; // Get the line length len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel(&panel->m_ClipBox, DC, len, 0, LineWidth, NameColor); GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor );
} }
} }
} }
if ( DrawPinNum) if( DrawPinNum )
{ {
DrawGraphicText(panel, DC, DrawGraphicText( panel, DC,
wxPoint((x1 + pin_pos.x) / 2, y1 - TXTMARGE), NumColor, StringPinNum, wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ), NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize, TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
} }
} }
else /* Its a vertical line. */ else /* Its a vertical line. */
{ // Text is drawn from bottom to top (i.e. to negative value for Y axis)
if (PinText && DrawPinName)
{ {
if ( orient == PIN_DOWN ) // Text is drawn from bottom to top (i.e. to negative value for Y axis)
if( PinText && DrawPinName )
{
if( orient == PIN_DOWN )
{ {
y = y1 + TextInside; y = y1 + TextInside;
DrawGraphicText(panel, DC, wxPoint(x1, y), NameColor, PinText, DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, LineWidth); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, LineWidth );
for ( ii = 0; ii < PinTextBarCount; ) for( ii = 0; ii < PinTextBarCount; )
{ {
GRMoveTo(x1 - TXTMARGE, y); GRMoveTo( x1 - TXTMARGE, y );
dy = -PinNameSize.y / 2; dy = -PinNameSize.y / 2;
GRMoveRel(dy , 0); GRMoveRel( dy, 0 );
dx = PinTextBarPos[ii++]; // Get the line pos dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel(0, PinTxtLen - dx); GRMoveRel( 0, PinTxtLen - dx );
len = PinTextBarPos[ii++] - dx; // Get the line length len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel(&panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor); GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor );
} }
} }
else /* PIN_UP */ else /* PIN_UP */
{ {
y = y1 - TextInside; y = y1 - TextInside;
DrawGraphicText(panel, DC, wxPoint(x1, y), NameColor, PinText, DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
for ( ii = 0; ii < PinTextBarCount; ) for( ii = 0; ii < PinTextBarCount; )
{ {
GRMoveTo(x1 - TXTMARGE, y); GRMoveTo( x1 - TXTMARGE, y );
dy = -PinNameSize.y / 2; dy = -PinNameSize.y / 2;
GRMoveRel(dy, 0); GRMoveRel( dy, 0 );
dx = PinTextBarPos[ii++]; // Get the line pos dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel(0, - dx); GRMoveRel( 0, -dx );
len = PinTextBarPos[ii++] - dx; // Get the line length len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel(&panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor); GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor );
} }
} }
} }
if(DrawPinNum) if( DrawPinNum )
{ {
DrawGraphicText(panel, DC, DrawGraphicText( panel, DC,
wxPoint(x1 - TXTMARGE, (y1 + pin_pos.y) / 2) , NumColor, StringPinNum, wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ), NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth); GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
} }
} }
} }
else /**** Draw num & text pin outside ****/ else /**** Draw num & text pin outside ****/
{ {
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
/* Its an horizontal line. */ /* Its an horizontal line. */
{ {
if (PinText && DrawPinName) if( PinText && DrawPinName )
{ {
x = (x1 + pin_pos.x) / 2; x = (x1 + pin_pos.x) / 2;
DrawGraphicText(panel, DC, wxPoint(x , y1 - TXTMARGE), DrawGraphicText( panel, DC, wxPoint( x, y1 - TXTMARGE ),
NameColor, PinText, NameColor, PinText,
TEXT_ORIENT_HORIZ, PinNameSize, TEXT_ORIENT_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
for ( ii = 0; ii < PinTextBarCount; ) for( ii = 0; ii < PinTextBarCount; )
{ {
GRMoveTo(x, y1 - TXTMARGE*2); GRMoveTo( x, y1 - TXTMARGE * 2 );
GRMoveRel(-PinTxtLen / 2, -PinNameSize.y ); GRMoveRel( -PinTxtLen / 2, -PinNameSize.y );
dx = PinTextBarPos[ii++]; // Get the line pos dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel(dx, 0); GRMoveRel( dx, 0 );
len = PinTextBarPos[ii++] - dx; // Get the line length len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel(&panel->m_ClipBox, DC, len, 0, LineWidth, NameColor); GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor );
} }
} }
if(DrawPinNum) if( DrawPinNum )
{ {
x = (x1 + pin_pos.x) / 2; x = (x1 + pin_pos.x) / 2;
DrawGraphicText(panel, DC, wxPoint(x, y1 + TXTMARGE), DrawGraphicText( panel, DC, wxPoint( x, y1 + TXTMARGE ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize, TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, LineWidth); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, LineWidth );
} }
} }
else /* Its a vertical line. */ else /* Its a vertical line. */
{ {
if (PinText && DrawPinName) if( PinText && DrawPinName )
{ {
y = (y1 + pin_pos.y) / 2; y = (y1 + pin_pos.y) / 2;
DrawGraphicText(panel, DC, wxPoint(x1 - TXTMARGE , y ), DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE, y ),
NameColor, PinText, NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth); GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
for ( ii = 0; ii < PinTextBarCount; ) for( ii = 0; ii < PinTextBarCount; )
{ {
GRMoveTo(x1 - (TXTMARGE * 2), y); GRMoveTo( x1 - (TXTMARGE * 2), y );
GRMoveRel(-PinNameSize.y, -PinTxtLen / 2); GRMoveRel( -PinNameSize.y, -PinTxtLen / 2 );
dx = PinTextBarPos[ii++]; // Get the line pos dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel(0, PinTxtLen - dx); GRMoveRel( 0, PinTxtLen - dx );
len = PinTextBarPos[ii++] - dx; // Get the line length len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel(&panel->m_ClipBox, DC, 0, - len, LineWidth, NameColor); GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor );
} }
} }
if(DrawPinNum) if( DrawPinNum )
{ {
DrawGraphicText(panel, DC, wxPoint(x1 + TXTMARGE , (y1 + pin_pos.y) / 2), DrawGraphicText( panel, DC, wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, LineWidth); GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
} }
} }
} }
} }
/***************************************************************************** /*****************************************************************************
* Plot pin number and pin text info, given the pin line coordinates. * * Plot pin number and pin text info, given the pin line coordinates. *
* Same as DrawPinTexts((), but output is the plotter * Same as DrawPinTexts((), but output is the plotter
...@@ -268,51 +279,59 @@ int LineWidth = g_DrawMinimunLineWidth; ...@@ -268,51 +279,59 @@ int LineWidth = g_DrawMinimunLineWidth;
* If TextInside then the text is been put inside (moving from x1, y1 in * * If TextInside then the text is been put inside (moving from x1, y1 in *
* the opposite direction to x2,y2), otherwise all is drawn outside. * * the opposite direction to x2,y2), otherwise all is drawn outside. *
*****************************************************************************/ *****************************************************************************/
void LibDrawPin::PlotPinTexts(wxPoint & pin_pos, int orient, void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
int TextInside, bool DrawPinNum, bool DrawPinName) int TextInside, bool DrawPinNum, bool DrawPinName )
{ {
int dx, len, start; int dx, len, start;
int ii , x, y, x1, y1, cte; int ii, x, y, x1, y1, cte;
wxString StringPinNum; wxString StringPinNum;
wxString PinText; wxString PinText;
int PinTextBarPos[256]; int PinTextBarPos[256];
int PinTextBarCount; int PinTextBarCount;
int NameColor, NumColor; int NameColor, NumColor;
int PinTxtLen = 0; int PinTxtLen = 0;
wxSize PinNameSize = wxSize(m_PinNameSize,m_PinNameSize); wxSize PinNameSize = wxSize( m_PinNameSize, m_PinNameSize );
wxSize PinNumSize = wxSize(m_PinNumSize,m_PinNumSize); wxSize PinNumSize = wxSize( m_PinNumSize, m_PinNumSize );
bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt; bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt;
/* Get the num and name colors */ /* Get the num and name colors */
NameColor = plot_color ? ReturnLayerColor(LAYER_PINNAM) : -1; NameColor = plot_color ? ReturnLayerColor( LAYER_PINNAM ) : -1;
NumColor = plot_color ? ReturnLayerColor(LAYER_PINNUM) : -1; NumColor = plot_color ? ReturnLayerColor( LAYER_PINNUM ) : -1;
/* Create the pin num string */ /* Create the pin num string */
ReturnPinStringNum(StringPinNum); ReturnPinStringNum( StringPinNum );
x1 = pin_pos.x; y1 = pin_pos.y; x1 = pin_pos.x; y1 = pin_pos.y;
switch(orient)
switch( orient )
{ {
case PIN_UP: y1 -= m_PinLen; break; case PIN_UP:
case PIN_DOWN: y1 += m_PinLen; break; y1 -= m_PinLen; break;
case PIN_LEFT: x1 -= m_PinLen; break;
case PIN_RIGHT: x1 += m_PinLen; break; case PIN_DOWN:
y1 += m_PinLen; break;
case PIN_LEFT:
x1 -= m_PinLen; break;
case PIN_RIGHT:
x1 += m_PinLen; break;
} }
const wxChar * textsrc = m_PinName.GetData(); const wxChar* textsrc = m_PinName.GetData();
float fPinTextPitch = PinNameSize.x * 1.1; float fPinTextPitch = PinNameSize.x * 1.1;
/* Do we need to invert the string? Is this string has only "~"? */ /* Do we need to invert the string? Is this string has only "~"? */
PinTextBarCount = 0; PinTxtLen = 0; PinTextBarCount = 0; PinTxtLen = 0;
ii = 0; ii = 0;
while ( * textsrc ) while( *textsrc )
{ {
if ( * textsrc == '~' ) if( *textsrc == '~' )
{ {
PinTextBarPos[PinTextBarCount++] = (int) (fPinTextPitch * PinTxtLen); PinTextBarPos[PinTextBarCount++] = (int) (fPinTextPitch * PinTxtLen);
} }
else else
{ {
PinText.Append(* textsrc); PinText.Append( *textsrc );
PinTxtLen ++; PinTxtLen++;
} }
textsrc++; textsrc++;
...@@ -321,171 +340,168 @@ bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt; ...@@ -321,171 +340,168 @@ bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt;
PinTxtLen = (int) (fPinTextPitch * PinTxtLen); PinTxtLen = (int) (fPinTextPitch * PinTxtLen);
PinTextBarPos[PinTextBarCount] = PinTxtLen; // Needed if no end '~' PinTextBarPos[PinTextBarCount] = PinTxtLen; // Needed if no end '~'
if (PinText[0] == 0) DrawPinName = FALSE; if( PinText[0] == 0 )
DrawPinName = FALSE;
if (TextInside) /* Draw the text inside, but the pin numbers outside. */ if( TextInside ) /* Draw the text inside, but the pin numbers outside. */
{ {
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
{ /* Its an horizontal line. */ { /* Its an horizontal line. */
if (PinText && DrawPinName) if( PinText && DrawPinName )
{ {
if( orient == PIN_RIGHT) if( orient == PIN_RIGHT )
{ {
x = x1 + TextInside; x = x1 + TextInside;
PlotGraphicText(g_PlotFormat, wxPoint(x, y1), NameColor, PinText, PlotGraphicText( g_PlotFormat, wxPoint( x, y1 ), NameColor, PinText,
TEXT_ORIENT_HORIZ, TEXT_ORIENT_HORIZ,
PinNameSize, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER );
for ( ii = 0; ii < PinTextBarCount; ) for( ii = 0; ii < PinTextBarCount; )
{ {
cte = y1 - PinNameSize.y/2 - TXTMARGE; cte = y1 - PinNameSize.y / 2 - TXTMARGE;
dx = PinTextBarPos[ii++]; // Get the line pos dx = PinTextBarPos[ii++]; // Get the line pos
Move_Plume( wxPoint(x+dx, cte), 'U'); Move_Plume( wxPoint( x + dx, cte ), 'U' );
len = PinTextBarPos[ii++]; // Get the line end len = PinTextBarPos[ii++]; // Get the line end
Move_Plume( wxPoint(x + len, cte), 'D'); Move_Plume( wxPoint( x + len, cte ), 'D' );
} }
} }
else // orient == PIN_LEFT else // orient == PIN_LEFT
{ {
x = x1 - TextInside; x = x1 - TextInside;
PlotGraphicText(g_PlotFormat, wxPoint(x, y1), PlotGraphicText( g_PlotFormat, wxPoint( x, y1 ),
NameColor, PinText, TEXT_ORIENT_HORIZ, NameColor, PinText, TEXT_ORIENT_HORIZ,
PinNameSize, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER); GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER );
for ( ii = 0; ii < PinTextBarCount; ) for( ii = 0; ii < PinTextBarCount; )
{ {
cte = y1 - PinNameSize.y/2 - TXTMARGE; cte = y1 - PinNameSize.y / 2 - TXTMARGE;
dx = PinTextBarPos[ii++]; // Get the line pos dx = PinTextBarPos[ii++]; // Get the line pos
Move_Plume( wxPoint(x+dx - PinTxtLen, cte), 'U'); Move_Plume( wxPoint( x + dx - PinTxtLen, cte ), 'U' );
len = PinTextBarPos[ii++]; // Get the line end len = PinTextBarPos[ii++]; // Get the line end
Move_Plume(wxPoint(x + len - PinTxtLen, cte), 'D'); Move_Plume( wxPoint( x + len - PinTxtLen, cte ), 'D' );
} }
} }
} }
if (DrawPinNum) if( DrawPinNum )
{ {
PlotGraphicText( g_PlotFormat, wxPoint((x1 + pin_pos.x) / 2, y1 - TXTMARGE), PlotGraphicText( g_PlotFormat, wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize, TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM );
} }
} }
else /* Its a vertical line. */ else /* Its a vertical line. */
{ {
if (PinText && DrawPinName) if( PinText && DrawPinName )
{ {
if ( orient == PIN_DOWN ) if( orient == PIN_DOWN )
{ {
y = y1 + TextInside; y = y1 + TextInside;
PlotGraphicText( g_PlotFormat, wxPoint(x1, y), NameColor, PinText, PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP );
for ( ii = 0; ii < PinTextBarCount; ) for( ii = 0; ii < PinTextBarCount; )
{ {
cte = x1 - PinNameSize.y/2 - TXTMARGE; cte = x1 - PinNameSize.y / 2 - TXTMARGE;
dx = PinTextBarPos[ii++]; // Get the line pos dx = PinTextBarPos[ii++]; // Get the line pos
Move_Plume( wxPoint(cte, y + PinTxtLen - dx), 'U'); Move_Plume( wxPoint( cte, y + PinTxtLen - dx ), 'U' );
len = PinTextBarPos[ii++]; // Get the line end len = PinTextBarPos[ii++]; // Get the line end
Move_Plume( wxPoint(cte , y + PinTxtLen - len), 'D'); Move_Plume( wxPoint( cte, y + PinTxtLen - len ), 'D' );
} }
} }
else /* PIN_UP */ else /* PIN_UP */
{ {
y = y1 - TextInside; y = y1 - TextInside;
PlotGraphicText( g_PlotFormat, wxPoint(x1, y), NameColor, PinText, PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM );
for ( ii = 0; ii < PinTextBarCount; ) for( ii = 0; ii < PinTextBarCount; )
{ {
cte = x1 - PinNameSize.y/2 - TXTMARGE; cte = x1 - PinNameSize.y / 2 - TXTMARGE;
dx = PinTextBarPos[ii++]; // Get the line pos dx = PinTextBarPos[ii++]; // Get the line pos
Move_Plume( wxPoint(cte, y -dx), 'U'); Move_Plume( wxPoint( cte, y - dx ), 'U' );
len = PinTextBarPos[ii++]; // Get the line end len = PinTextBarPos[ii++]; // Get the line end
Move_Plume(wxPoint(cte, y - len), 'D'); Move_Plume( wxPoint( cte, y - len ), 'D' );
} }
} }
} }
if (DrawPinNum) if( DrawPinNum )
{ {
PlotGraphicText( g_PlotFormat, wxPoint(x1 - TXTMARGE, (y1 + pin_pos.y) / 2), PlotGraphicText( g_PlotFormat, wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER); GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER );
} }
} }
} }
else /* Draw num & text pin outside */ else /* Draw num & text pin outside */
{ {
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
/* Its an horizontal line. */ /* Its an horizontal line. */
{ {
if (PinText && DrawPinName) if( PinText && DrawPinName )
{ {
x = (x1 + pin_pos.x) / 2; x = (x1 + pin_pos.x) / 2;
PlotGraphicText( g_PlotFormat, wxPoint(x, y1 - TXTMARGE), PlotGraphicText( g_PlotFormat, wxPoint( x, y1 - TXTMARGE ),
NameColor, PinText, NameColor, PinText,
TEXT_ORIENT_HORIZ, PinNameSize, TEXT_ORIENT_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM );
for ( ii = 0; ii < PinTextBarCount; ) for( ii = 0; ii < PinTextBarCount; )
{ {
cte = y1 - PinNameSize.y - TXTMARGE*2; cte = y1 - PinNameSize.y - TXTMARGE * 2;
start = x - (PinTxtLen / 2); start = x - (PinTxtLen / 2);
dx = PinTextBarPos[ii++]; // Get the line pos dx = PinTextBarPos[ii++]; // Get the line pos
Move_Plume( wxPoint(start + dx, cte), 'U'); Move_Plume( wxPoint( start + dx, cte ), 'U' );
len = PinTextBarPos[ii++]; // Get the line end len = PinTextBarPos[ii++]; // Get the line end
Move_Plume(wxPoint(start + len, cte), 'D'); Move_Plume( wxPoint( start + len, cte ), 'D' );
} }
} }
if (DrawPinNum) if( DrawPinNum )
{ {
x = (x1 + pin_pos.x) / 2; x = (x1 + pin_pos.x) / 2;
PlotGraphicText(g_PlotFormat, wxPoint(x, y1 + TXTMARGE), PlotGraphicText( g_PlotFormat, wxPoint( x, y1 + TXTMARGE ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize, TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP );
} }
} }
else /* Its a vertical line. */ else /* Its a vertical line. */
{ {
if (PinText && DrawPinName) if( PinText && DrawPinName )
{ {
y = (y1 + pin_pos.y) / 2; y = (y1 + pin_pos.y) / 2;
PlotGraphicText( g_PlotFormat, wxPoint(x1 - TXTMARGE,y), PlotGraphicText( g_PlotFormat, wxPoint( x1 - TXTMARGE, y ),
NameColor, PinText, NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize, TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER); GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER );
for ( ii = 0; ii < PinTextBarCount; ) for( ii = 0; ii < PinTextBarCount; )
{ {
cte = x1 - PinNameSize.y - TXTMARGE*2; cte = x1 - PinNameSize.y - TXTMARGE * 2;
start = y + (PinTxtLen / 2); start = y + (PinTxtLen / 2);
dx = PinTextBarPos[ii++]; // Get the line pos dx = PinTextBarPos[ii++]; // Get the line pos
Move_Plume( wxPoint(cte, start - dx), 'U'); Move_Plume( wxPoint( cte, start - dx ), 'U' );
len = PinTextBarPos[ii++]; // Get the line end len = PinTextBarPos[ii++]; // Get the line end
Move_Plume( wxPoint(cte, start - len), 'D'); Move_Plume( wxPoint( cte, start - len ), 'D' );
} }
} }
if (DrawPinNum) if( DrawPinNum )
{ {
PlotGraphicText( g_PlotFormat, wxPoint(x1 + TXTMARGE, (y1 + pin_pos.y) / 2), PlotGraphicText( g_PlotFormat, wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum, NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize, TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER );
} }
} }
} }
} }
...@@ -54,7 +54,6 @@ void Move_Plume( wxPoint pos, int plume ) ...@@ -54,7 +54,6 @@ void Move_Plume( wxPoint pos, int plume )
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
case PLOT_FORMAT_POST_A4:
LineTo_PS( pos, plume ); LineTo_PS( pos, plume );
break; break;
} }
...@@ -69,7 +68,6 @@ void SetCurrentLineWidth( int width ) ...@@ -69,7 +68,6 @@ void SetCurrentLineWidth( int width )
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
case PLOT_FORMAT_POST_A4:
SetCurrentLineWidthPS( width ); SetCurrentLineWidthPS( width );
break; break;
} }
......
/********************/ /********************/
/* plot_common.h */ /* plot_common.h */
/********************/ /********************/
#ifndef PLOT_COMMON_H #ifndef PLOT_COMMON_H
#define PLOT_COMMON_H #define PLOT_COMMON_H
...@@ -12,12 +12,22 @@ ...@@ -12,12 +12,22 @@
#endif #endif
typedef enum { /**
* Enum PlotFormat
* must be kept in order of the radio buttons in the plot panel/window.
*/
enum PlotFormat {
PLOT_FORMAT_HPGL, PLOT_FORMAT_HPGL,
PLOT_FORMAT_POST,
PLOT_FORMAT_GERBER, PLOT_FORMAT_GERBER,
PLOT_FORMAT_POST_A4 PLOT_FORMAT_POST,
} PlotFormat; };
static inline bool IsPostScript( int aFormat )
{
return aFormat==PLOT_FORMAT_POST;
}
const int PLOT_MIROIR = 1; const int PLOT_MIROIR = 1;
...@@ -25,47 +35,59 @@ const int PLOT_MIROIR = 1; ...@@ -25,47 +35,59 @@ const int PLOT_MIROIR = 1;
/*******************************/ /*******************************/
/* common_plot_functions.cpp */ /* common_plot_functions.cpp */
/*******************************/ /*******************************/
void SetPlotScale(double xscale, double yscale); // Set the plot scale for the current plotting) void SetPlotScale( double xscale, double yscale ); // Set the plot scale for the current plotting)
void SetPlotOffset(wxPoint offset); // Set the plot offset for the current plotting) void SetPlotOffset( wxPoint offset ); // Set the plot offset for the current plotting)
void InitPlotParametresGERBER(wxPoint offset, double xscale, double yscale); void InitPlotParametresGERBER( wxPoint offset, double xscale, double yscale );
void PlotWorkSheet(int format_plot, BASE_SCREEN * screen); void PlotWorkSheet( int format_plot, BASE_SCREEN* screen );
void UserToDeviceCoordinate(wxPoint & pos ); void UserToDeviceCoordinate( wxPoint& pos );
// modifie les coord pos.x et pos.y pour le trace selon l'orientation, l'echelle, les offsets de trace
void UserToDeviceSize(wxSize & size ); // modifie les coord pos.x et pos.y pour le trace selon l'orientation, l'echelle, les offsets de trace
// modifie les dimension size.x et size.y pour le trace selon l'echelle void UserToDeviceSize( wxSize& size );
// modifie les dimension size.x et size.y pour le trace selon l'echelle
void ForcePenReinit(); void ForcePenReinit();
// set the flag g_CurrentPenWidth to -1 in order
// to force a pen width redefinition for the next draw command // set the flag g_CurrentPenWidth to -1 in order
// to force a pen width redefinition for the next draw command
/*******************************/ /*******************************/
/* common_plotPS_functions.cpp */ /* common_plotPS_functions.cpp */
/*******************************/ /*******************************/
void SetCurrentLineWidthPS( int width); void SetCurrentLineWidthPS( int width );
void InitPlotParametresPS( wxPoint offset, Ki_PageDescr * sheet, double xscale, double yscale, int orient = 0); void InitPlotParametresPS( wxPoint offset,
void SetDefaultLineWidthPS( int width); Ki_PageDescr* sheet,
void PlotCircle_PS(wxPoint pos, int diametre, int width = -1); double xscale,
void PlotArcPS(wxPoint centre, int StAngle, int EndAngle, int rayon, int width = -1); double yscale,
// Plot an arc: StAngle, EndAngle = start and end arc in 0.1 degree int orient = 0 );
void PlotPolyPS( int nb_segm, int * coord, int fill, int width = -1); void SetDefaultLineWidthPS( int width );
void PlotFilledSegmentPS(wxPoint start , wxPoint end, int width); void PlotCircle_PS( wxPoint pos, int diametre, int width = -1 );
void LineTo_PS(wxPoint pos, int plume); void PlotArcPS( wxPoint centre, int StAngle, int EndAngle, int rayon, int width = -1 );
void PrintHeaderPS(FILE * file, const wxString & Creator, const wxString & FileName, int PageCount, int BBox[4], int PaperOrientation);
bool CloseFilePS(FILE * plot_file); // Plot an arc: StAngle, EndAngle = start and end arc in 0.1 degree
void SetColorMapPS(int color); void PlotPolyPS( int nb_segm, int* coord, int fill, int width = -1 );
void PlotFilledSegmentPS( wxPoint start, wxPoint end, int width );
void LineTo_PS( wxPoint pos, int plume );
void PrintHeaderPS( FILE* file,
const wxString& Creator,
const wxString& FileName,
int PageCount,
int BBox[4],
int PaperOrientation );
bool CloseFilePS( FILE* plot_file );
void SetColorMapPS( int color );
/*********************************/ /*********************************/
/* common_plotHPGL_functions.cpp */ /* common_plotHPGL_functions.cpp */
/*********************************/ /*********************************/
void InitPlotParametresHPGL(wxPoint offset, double xscale, double yscale, int orient = 0); void InitPlotParametresHPGL( wxPoint offset, double xscale, double yscale, int orient = 0 );
bool PrintHeaderHPGL(FILE * plot_file, int pen_speed, int pen_num); bool PrintHeaderHPGL( FILE* plot_file, int pen_speed, int pen_num );
bool CloseFileHPGL(FILE * plot_file); bool CloseFileHPGL( FILE* plot_file );
void PlotCircle_HPGL(wxPoint centre, int diameter, int width = -1); void PlotCircle_HPGL( wxPoint centre, int diameter, int width = -1 );
void PlotArcHPGL(wxPoint centre, int StAngle, int EndAngle, int rayon, int width = -1); void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, int width = -1 );
void PlotPolyHPGL( int nb, int * coord, int fill, int width = -1); void PlotPolyHPGL( int nb, int* coord, int fill, int width = -1 );
void Move_Plume_HPGL( wxPoint pos, int plume ); void Move_Plume_HPGL( wxPoint pos, int plume );
void Plume_HPGL( int plume ); void Plume_HPGL( int plume );
#endif // PLOT_COMMON_H #endif // PLOT_COMMON_H
...@@ -258,7 +258,7 @@ public: ...@@ -258,7 +258,7 @@ public:
void Genere_GERBER( const wxString& FullFileName, int Layer, void Genere_GERBER( const wxString& FullFileName, int Layer,
bool PlotOriginIsAuxAxis ); bool PlotOriginIsAuxAxis );
void Genere_HPGL( const wxString& FullFileName, int Layer ); void Genere_HPGL( const wxString& FullFileName, int Layer );
void Genere_PS( const wxString& FullFileName, int Layer ); void Genere_PS( const wxString& FullFileName, int Layer, bool useA4 );
void Plot_Layer_HPGL( FILE* File, int masque_layer, void Plot_Layer_HPGL( FILE* File, int masque_layer,
int garde, int tracevia, int modetrace ); int garde, int tracevia, int modetrace );
void Plot_Layer_GERBER( FILE* File, int masque_layer, void Plot_Layer_GERBER( FILE* File, int masque_layer,
......
...@@ -158,7 +158,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, w ...@@ -158,7 +158,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, w
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( IsPostScript( format ) )
{ {
sprintf( line, "%d setlinewidth\n", TextWidth ); sprintf( line, "%d setlinewidth\n", TextWidth );
fputs( line, aFile ); fputs( line, aFile );
...@@ -429,7 +429,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f ...@@ -429,7 +429,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f
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( IsPostScript( format ) )
FctPlume = LineTo_PS; FctPlume = LineTo_PS;
switch( aShapeId ) switch( aShapeId )
...@@ -444,7 +444,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f ...@@ -444,7 +444,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f
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( IsPostScript( format ) )
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
...@@ -462,7 +462,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f ...@@ -462,7 +462,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f
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( IsPostScript( format ) )
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
...@@ -471,7 +471,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f ...@@ -471,7 +471,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f
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( IsPostScript( format ) )
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
...@@ -480,7 +480,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f ...@@ -480,7 +480,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f
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( IsPostScript( format ) )
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
...@@ -489,7 +489,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f ...@@ -489,7 +489,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f
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( IsPostScript( format ) )
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 );
...@@ -500,7 +500,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f ...@@ -500,7 +500,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f
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( IsPostScript( format ) )
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 );
...@@ -515,7 +515,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f ...@@ -515,7 +515,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f
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( IsPostScript( format ) )
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 );
...@@ -530,7 +530,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f ...@@ -530,7 +530,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f
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( IsPostScript( format ) )
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 );
...@@ -543,7 +543,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f ...@@ -543,7 +543,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f
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( IsPostScript( format ) )
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 );
...@@ -556,7 +556,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f ...@@ -556,7 +556,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f
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( IsPostScript( format ) )
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 );
...@@ -569,7 +569,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f ...@@ -569,7 +569,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f
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( IsPostScript( format ) )
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 );
...@@ -578,7 +578,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f ...@@ -578,7 +578,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int aShapeId, int f
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( IsPostScript( format ) )
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE ); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
} }
......
...@@ -90,7 +90,29 @@ public: ...@@ -90,7 +90,29 @@ public:
WinEDA_ValueCtrl* m_HPGLPenOverlayOpt; WinEDA_ValueCtrl* m_HPGLPenOverlayOpt;
WinEDA_DFloatValueCtrl* m_FineAdjustXscaleOpt, * m_FineAdjustYscaleOpt; WinEDA_DFloatValueCtrl* m_FineAdjustXscaleOpt, * m_FineAdjustYscaleOpt;
double m_XScaleAdjust, m_YScaleAdjust; double m_XScaleAdjust, m_YScaleAdjust;
int m_PlotFormat;
bool useA4()
{
return m_PlotFormatOpt->GetSelection() == 3;
}
/**
* Function getFormat
* returns one of the values from the PlotFormat enum. If the 4th
* radio button is selected, map this back to postscript.
*/
PlotFormat getFormat()
{
int radioNdx = m_PlotFormatOpt->GetSelection();
// change the A4 to the simple postscript, according to the PlotFormat enum
if( radioNdx == 3 )
radioNdx = 2;
return PlotFormat( radioNdx );
}
public: public:
WinEDA_PlotFrame( WinEDA_BasePcbFrame * parent ); WinEDA_PlotFrame( WinEDA_BasePcbFrame * parent );
...@@ -137,7 +159,6 @@ WinEDA_PlotFrame::WinEDA_PlotFrame( WinEDA_BasePcbFrame* parent ) : ...@@ -137,7 +159,6 @@ WinEDA_PlotFrame::WinEDA_PlotFrame( WinEDA_BasePcbFrame* parent ) :
SetFont( *g_DialogFont ); SetFont( *g_DialogFont );
Centre(); Centre();
m_PlotFormat = format_plot;
m_Plot_Sheet_Ref = NULL; m_Plot_Sheet_Ref = NULL;
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
...@@ -169,32 +190,15 @@ WinEDA_PlotFrame::WinEDA_PlotFrame( WinEDA_BasePcbFrame* parent ) : ...@@ -169,32 +190,15 @@ WinEDA_PlotFrame::WinEDA_PlotFrame( WinEDA_BasePcbFrame* parent ) :
4, fmtmsg, 1, wxRA_SPECIFY_COLS ); 4, fmtmsg, 1, wxRA_SPECIFY_COLS );
MidRightBoxSizer->Add( m_PlotFormatOpt, 0, wxGROW | wxALL, 5 ); MidRightBoxSizer->Add( m_PlotFormatOpt, 0, wxGROW | wxALL, 5 );
if( config && config->Read( OPTKEY_OUTPUT_FORMAT, &m_PlotFormat ) ) int myFormatIndex = format_plot;
m_PlotFormatOpt->SetSelection( m_PlotFormat );
else if( config )
{
switch( m_PlotFormat )
{ {
case PLOT_FORMAT_HPGL: config->Read( OPTKEY_OUTPUT_FORMAT, &myFormatIndex );
m_PlotFormatOpt->SetSelection( 0 ); }
break;
case PLOT_FORMAT_GERBER: m_PlotFormatOpt->SetSelection( myFormatIndex );
m_PlotFormatOpt->SetSelection( 1 );
break;
default: // ( PLOT_FORMAT_POST or PLOT_FORMAT_POST_A4 )
// As m_PlotFormat is never set to a value of PLOT_FORMAT_POST_A4,
// use the value of g_ForcePlotPS_On_A4 to determine whether the
// "Postscript" or "Postscipt A4" radiobutton had been selected
// previously (and thus which button should be reselected now).
if( g_ForcePlotPS_On_A4 )
m_PlotFormatOpt->SetSelection( 3 );
else
m_PlotFormatOpt->SetSelection( 2 );
break;
}
}
// Creation des menus d'option du format GERBER // Creation des menus d'option du format GERBER
m_GerbSpotSizeMinOpt = new WinEDA_ValueCtrl( this, _( "Spot min" ), m_GerbSpotSizeMinOpt = new WinEDA_ValueCtrl( this, _( "Spot min" ),
...@@ -490,18 +494,10 @@ void WinEDA_PlotFrame::SetCommands( wxCommandEvent& event ) ...@@ -490,18 +494,10 @@ void WinEDA_PlotFrame::SetCommands( wxCommandEvent& event )
/* active ou dsactive les diffrents menus d'option selon le standard choisi /* active ou dsactive les diffrents menus d'option selon le standard choisi
*/ */
{ {
int format; int format = getFormat();
static const int format_list[] = {
PLOT_FORMAT_HPGL, PLOT_FORMAT_GERBER,
PLOT_FORMAT_POST, PLOT_FORMAT_POST_A4
};
format = format_list[m_PlotFormatOpt->GetSelection()];
switch( format ) switch( format )
{ {
case PLOT_FORMAT_POST_A4:
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
default: default:
m_Drill_Shape_Opt->Enable( true ); m_Drill_Shape_Opt->Enable( true );
...@@ -519,8 +515,6 @@ void WinEDA_PlotFrame::SetCommands( wxCommandEvent& event ) ...@@ -519,8 +515,6 @@ void WinEDA_PlotFrame::SetCommands( wxCommandEvent& event )
m_Scale_Opt->Enable( true ); m_Scale_Opt->Enable( true );
m_FineAdjustXscaleOpt->Enable( true ); m_FineAdjustXscaleOpt->Enable( true );
m_FineAdjustYscaleOpt->Enable( true ); m_FineAdjustYscaleOpt->Enable( true );
m_PlotFormat = PLOT_FORMAT_POST;
g_ForcePlotPS_On_A4 = (format == PLOT_FORMAT_POST_A4);
m_Plot_PS_Negative->Enable( true ); m_Plot_PS_Negative->Enable( true );
break; break;
...@@ -540,7 +534,6 @@ void WinEDA_PlotFrame::SetCommands( wxCommandEvent& event ) ...@@ -540,7 +534,6 @@ void WinEDA_PlotFrame::SetCommands( wxCommandEvent& event )
m_Scale_Opt->Enable( false ); m_Scale_Opt->Enable( false );
m_FineAdjustXscaleOpt->Enable( false ); m_FineAdjustXscaleOpt->Enable( false );
m_FineAdjustYscaleOpt->Enable( false ); m_FineAdjustYscaleOpt->Enable( false );
m_PlotFormat = PLOT_FORMAT_GERBER;
m_Plot_PS_Negative->Enable( false ); m_Plot_PS_Negative->Enable( false );
break; break;
...@@ -560,12 +553,11 @@ void WinEDA_PlotFrame::SetCommands( wxCommandEvent& event ) ...@@ -560,12 +553,11 @@ void WinEDA_PlotFrame::SetCommands( wxCommandEvent& event )
m_Scale_Opt->Enable( true ); m_Scale_Opt->Enable( true );
m_FineAdjustXscaleOpt->Enable( false ); m_FineAdjustXscaleOpt->Enable( false );
m_FineAdjustYscaleOpt->Enable( false ); m_FineAdjustYscaleOpt->Enable( false );
m_PlotFormat = PLOT_FORMAT_HPGL;
m_Plot_PS_Negative->Enable( false ); m_Plot_PS_Negative->Enable( false );
break; break;
} }
format_plot = m_PlotFormat; format_plot = format;
} }
...@@ -616,8 +608,8 @@ void WinEDA_PlotFrame::SaveOptPlot( wxCommandEvent& event ) ...@@ -616,8 +608,8 @@ void WinEDA_PlotFrame::SaveOptPlot( wxCommandEvent& event )
config->Write( OPTKEY_PADS_ON_SILKSCREEN, PlotPadsOnSilkLayer ); config->Write( OPTKEY_PADS_ON_SILKSCREEN, PlotPadsOnSilkLayer );
config->Write( OPTKEY_ALWAYS_PRINT_PADS, Plot_Pads_All_Layers ); config->Write( OPTKEY_ALWAYS_PRINT_PADS, Plot_Pads_All_Layers );
m_PlotFormat = m_PlotFormatOpt->GetSelection(); int formatNdx = m_PlotFormatOpt->GetSelection();
config->Write( OPTKEY_OUTPUT_FORMAT, m_PlotFormat ); config->Write( OPTKEY_OUTPUT_FORMAT, formatNdx );
wxString layerKey; wxString layerKey;
for( int layer=0; layer<NB_LAYERS; ++layer ) for( int layer=0; layer<NB_LAYERS; ++layer )
...@@ -668,12 +660,15 @@ void WinEDA_PlotFrame::Plot( wxCommandEvent& event ) ...@@ -668,12 +660,15 @@ void WinEDA_PlotFrame::Plot( wxCommandEvent& event )
BaseFileName = m_Parent->GetScreen()->m_FileName; BaseFileName = m_Parent->GetScreen()->m_FileName;
ChangeFileNameExt( BaseFileName, wxT( "-" ) ); ChangeFileNameExt( BaseFileName, wxT( "-" ) );
switch( m_PlotFormat ) int format = getFormat();
switch( format )
{ {
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
ext = wxT( ".ps" ); ext = wxT( ".ps" );
break; break;
default:
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
ext = wxT( ".pho" ); ext = wxT( ".pho" );
break; break;
...@@ -695,12 +690,13 @@ void WinEDA_PlotFrame::Plot( wxCommandEvent& event ) ...@@ -695,12 +690,13 @@ void WinEDA_PlotFrame::Plot( wxCommandEvent& event )
// Calcul du nom du fichier // Calcul du nom du fichier
FullFileName = BaseFileName + board->GetLayerName( layer_to_plot ) + ext; FullFileName = BaseFileName + board->GetLayerName( layer_to_plot ) + ext;
switch( m_PlotFormat ) switch( format )
{ {
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
m_Parent->Genere_PS( FullFileName, layer_to_plot ); m_Parent->Genere_PS( FullFileName, layer_to_plot, useA4() );
break; break;
default:
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
m_Parent->Genere_GERBER( FullFileName, layer_to_plot, s_PlotOriginIsAuxAxis ); m_Parent->Genere_GERBER( FullFileName, layer_to_plot, s_PlotOriginIsAuxAxis );
break; break;
......
...@@ -102,7 +102,6 @@ eda_global int g_PlotScaleOpt // 0 = automatique, >=1 echelle specifiee ...@@ -102,7 +102,6 @@ eda_global int g_PlotScaleOpt // 0 = automatique, >=1 echelle specifiee
= 1 = 1
#endif #endif
; ;
eda_global bool g_ForcePlotPS_On_A4; // Force la selection de la feuille A4 pour le plot POSTSCRIPT
eda_global int g_DrillShapeOpt eda_global int g_DrillShapeOpt
#ifdef MAIN #ifdef MAIN
......
...@@ -33,7 +33,6 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -33,7 +33,6 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
wxPoint pos, shape_pos; wxPoint pos, shape_pos;
wxSize size; wxSize size;
bool trace_val, trace_ref; bool trace_val, trace_ref;
MODULE* Module;
D_PAD* pt_pad; D_PAD* pt_pad;
TEXTE_MODULE* pt_texte; TEXTE_MODULE* pt_texte;
EDA_BaseStruct* PtStruct; EDA_BaseStruct* PtStruct;
...@@ -87,8 +86,8 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -87,8 +86,8 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
{ {
nb_items = 0; nb_items = 0;
Affiche_1_Parametre( this, 56, wxT( "Pads" ), wxEmptyString, GREEN ); Affiche_1_Parametre( this, 56, wxT( "Pads" ), wxEmptyString, GREEN );
Module = m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) for( MODULE* Module = m_Pcb->m_Modules; Module; Module = Module->Next() )
{ {
pt_pad = (D_PAD*) Module->m_Pads; pt_pad = (D_PAD*) Module->m_Pads;
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
...@@ -121,7 +120,6 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -121,7 +120,6 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
trace_1_pastille_RONDE_POST( pos, size.x, FILAIRE ); trace_1_pastille_RONDE_POST( pos, size.x, FILAIRE );
break; break;
} }
break; break;
case PAD_OVAL: case PAD_OVAL:
...@@ -144,7 +142,6 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -144,7 +142,6 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
pt_pad->m_Orient, FILAIRE ); pt_pad->m_Orient, FILAIRE );
break; break;
} }
break; break;
case PAD_TRAPEZOID: case PAD_TRAPEZOID:
...@@ -172,7 +169,6 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -172,7 +169,6 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
FILAIRE ); FILAIRE );
break; break;
} }
break; break;
} }
...@@ -196,7 +192,6 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -196,7 +192,6 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
(int) pt_pad->m_Orient, FILAIRE ); (int) pt_pad->m_Orient, FILAIRE );
break; break;
} }
break; break;
} }
...@@ -209,8 +204,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, ...@@ -209,8 +204,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot,
/* Trace Textes MODULES */ /* Trace Textes MODULES */
nb_items = 0; Affiche_1_Parametre( this, 64, wxT( "TxtMod" ), wxEmptyString, LIGHTBLUE ); nb_items = 0; Affiche_1_Parametre( this, 64, wxT( "TxtMod" ), wxEmptyString, LIGHTBLUE );
Module = m_Pcb->m_Modules; for( MODULE* Module = m_Pcb->m_Modules; Module; Module = Module->Next() )
for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
/* Analyse des autorisations de trace pour les textes VALEUR et REF */ /* Analyse des autorisations de trace pour les textes VALEUR et REF */
trace_val = Sel_Texte_Valeur; trace_val = Sel_Texte_Valeur;
...@@ -831,7 +825,7 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle, ...@@ -831,7 +825,7 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle,
if( Plot_Mode == FILAIRE ) if( Plot_Mode == FILAIRE )
epaisseur = g_PlotLine_Width; epaisseur = g_PlotLine_Width;
if( format_plot == PLOT_FORMAT_POST ) if( IsPostScript( format_plot ) )
{ {
PlotArcPS( centre, start_angle, end_angle, rayon, epaisseur ); PlotArcPS( centre, start_angle, end_angle, rayon, epaisseur );
return; return;
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
static int s_Last_D_code; static int s_Last_D_code;
static float Gerb_scale_plot; // Coeff de conversion d'unites des traces static float Gerb_scale_plot; // Coeff de conversion d'unites des traces
static int scale_spot_mini; // Ouverture mini (pour remplissages) static int scale_spot_mini; // Ouverture mini (pour remplissages)
static D_CODE * s_DCodeList; // Pointeur sur la zone de stockage des D_CODES static D_CODE* s_DCodeList; // Pointeur sur la zone de stockage des D_CODES
wxString GerberFullFileName; wxString GerberFullFileName;
static double scale_x, scale_y; // echelles de convertion en X et Y (compte tenu static double scale_x, scale_y; // echelles de convertion en X et Y (compte tenu
// des unites relatives du PCB et des traceurs // des unites relatives du PCB et des traceurs
...@@ -26,28 +26,28 @@ static bool ShowDcodeError = TRUE; ...@@ -26,28 +26,28 @@ static bool ShowDcodeError = TRUE;
/* Routines Locales */ /* Routines Locales */
static void Init_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile); static void Init_Trace_GERBER( WinEDA_BasePcbFrame* frame, FILE* gerbfile );
static void Init_ApertureList(); static void Init_ApertureList();
static void Fin_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile); static void Fin_Trace_GERBER( WinEDA_BasePcbFrame* frame, FILE* gerbfile );
static void Plot_1_CIRCLE_pad_GERBER(wxPoint pos, int diametre); static void Plot_1_CIRCLE_pad_GERBER( wxPoint pos, int diametre );
static void trace_1_pastille_OVALE_GERBER(wxPoint pos, wxSize size, int orient); static void trace_1_pastille_OVALE_GERBER( wxPoint pos, wxSize size, int orient );
static void PlotRectangularPad_GERBER(wxPoint pos, wxSize size, int orient); static void PlotRectangularPad_GERBER( wxPoint pos, wxSize size, int orient );
static D_CODE * get_D_code(int dx, int dy, int type, int drill); static D_CODE* get_D_code( int dx, int dy, int type, int drill );
static void trace_1_pad_TRAPEZE_GERBER(wxPoint pos, wxSize size, wxSize delta, static void trace_1_pad_TRAPEZE_GERBER( wxPoint pos, wxSize size, wxSize delta,
int orient, int modetrace); int orient, int modetrace );
/********************************************************************************/ /********************************************************************************/
void WinEDA_BasePcbFrame::Genere_GERBER(const wxString & FullFileName, int Layer, void WinEDA_BasePcbFrame::Genere_GERBER( const wxString& FullFileName, int Layer,
bool PlotOriginIsAuxAxis) bool PlotOriginIsAuxAxis )
/********************************************************************************/ /********************************************************************************/
/* Genere les divers fichiers de trace: /* Genere les divers fichiers de trace:
* Pour chaque couche 1 fichier xxxc.PHO au format RS274X * Pour chaque couche 1 fichier xxxc.PHO au format RS274X
*/ */
{ {
int tracevia = 1; int tracevia = 1;
EraseMsgBox(); EraseMsgBox();
GerberFullFileName = FullFileName; GerberFullFileName = FullFileName;
...@@ -58,7 +58,7 @@ int tracevia = 1; ...@@ -58,7 +58,7 @@ int tracevia = 1;
/* Calcul des echelles de conversion */ /* Calcul des echelles de conversion */
Gerb_scale_plot = 1.0; /* pour unites gerber en 0,1 Mils, format 3.4 */ Gerb_scale_plot = 1.0; /* pour unites gerber en 0,1 Mils, format 3.4 */
scale_spot_mini = (int)(10 * spot_mini * Gerb_scale_plot); scale_spot_mini = (int) (10 * spot_mini * Gerb_scale_plot);
scale_x = Scale_X * Gerb_scale_plot; scale_x = Scale_X * Gerb_scale_plot;
scale_y = Scale_Y * Gerb_scale_plot; scale_y = Scale_Y * Gerb_scale_plot;
g_PlotOffset.x = 0; g_PlotOffset.x = 0;
...@@ -66,31 +66,32 @@ int tracevia = 1; ...@@ -66,31 +66,32 @@ int tracevia = 1;
if( PlotOriginIsAuxAxis ) if( PlotOriginIsAuxAxis )
g_PlotOffset = m_Auxiliary_Axis_Position; g_PlotOffset = m_Auxiliary_Axis_Position;
dest = wxFopen( FullFileName, wxT("wt") ); dest = wxFopen( FullFileName, wxT( "wt" ) );
if( dest == NULL ) if( dest == NULL )
{ {
wxString msg = _("unable to create file ") + FullFileName; wxString msg = _( "unable to create file " ) + FullFileName;
DisplayError(this, msg); DisplayError( this, msg );
return; return;
} }
setlocale(LC_NUMERIC, "C"); setlocale( LC_NUMERIC, "C" );
InitPlotParametresGERBER(g_PlotOffset, scale_x, scale_y); InitPlotParametresGERBER( g_PlotOffset, scale_x, scale_y );
/* Clear the memory used for handle the D_CODE (aperture) list */ /* Clear the memory used for handle the D_CODE (aperture) list */
Init_ApertureList(); Init_ApertureList();
Affiche_1_Parametre(this, 0, _("File"), FullFileName, CYAN); Affiche_1_Parametre( this, 0, _( "File" ), FullFileName, CYAN );
Init_Trace_GERBER(this, dest); Init_Trace_GERBER( this, dest );
nb_plot_erreur = 0; nb_plot_erreur = 0;
int layer_mask = g_TabOneLayerMask[Layer]; int layer_mask = g_TabOneLayerMask[Layer];
// Specify that the contents of the "Edges Pcb" layer are also to be // Specify that the contents of the "Edges Pcb" layer are also to be
// plotted, unless the option of excluding that layer has been selected. // plotted, unless the option of excluding that layer has been selected.
if( ! g_Exclude_Edges_Pcb ) if( !g_Exclude_Edges_Pcb )
layer_mask |= EDGE_LAYER; layer_mask |= EDGE_LAYER;
switch( Layer ) switch( Layer )
...@@ -111,7 +112,7 @@ int tracevia = 1; ...@@ -111,7 +112,7 @@ int tracevia = 1;
case LAYER_N_14: case LAYER_N_14:
case LAYER_N_15: case LAYER_N_15:
case LAST_COPPER_LAYER: case LAST_COPPER_LAYER:
Plot_Layer_GERBER(dest, layer_mask, 0, 1); Plot_Layer_GERBER( dest, layer_mask, 0, 1 );
break; break;
case SOLDERMASK_N_CU: case SOLDERMASK_N_CU:
...@@ -120,16 +121,16 @@ int tracevia = 1; ...@@ -120,16 +121,16 @@ int tracevia = 1;
tracevia = 1; tracevia = 1;
else else
tracevia = 0; tracevia = 0;
Plot_Layer_GERBER(dest, layer_mask, g_DesignSettings.m_MaskMargin, tracevia); Plot_Layer_GERBER( dest, layer_mask, g_DesignSettings.m_MaskMargin, tracevia );
break; break;
case SOLDERPASTE_N_CU: case SOLDERPASTE_N_CU:
case SOLDERPASTE_N_CMP: /* Trace du masque de pate de soudure */ case SOLDERPASTE_N_CMP: /* Trace du masque de pate de soudure */
Plot_Layer_GERBER(dest, layer_mask, 0, 0); Plot_Layer_GERBER( dest, layer_mask, 0, 0 );
break; break;
default: default:
Plot_Serigraphie(PLOT_FORMAT_GERBER, dest, layer_mask); Plot_Serigraphie( PLOT_FORMAT_GERBER, dest, layer_mask );
break; break;
} }
...@@ -139,20 +140,20 @@ int tracevia = 1; ...@@ -139,20 +140,20 @@ int tracevia = 1;
/***********************************************************************/ /***********************************************************************/
void WinEDA_BasePcbFrame::Plot_Layer_GERBER(FILE * File,int masque_layer, void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer,
int garde, int tracevia) int garde, int tracevia )
/***********************************************************************/ /***********************************************************************/
/* Trace en format GERBER. d'une couche cuivre ou masque /* Trace en format GERBER. d'une couche cuivre ou masque
*/ */
{ {
wxPoint pos; wxPoint pos;
wxSize size; wxSize size;
MODULE * Module; MODULE* Module;
D_PAD * PtPad; D_PAD* PtPad;
TRACK * track ; TRACK* track;
EDA_BaseStruct * PtStruct; EDA_BaseStruct* PtStruct;
wxString msg; wxString msg;
// (Following command has been superceded by new command on lines 93 and 94.) // (Following command has been superceded by new command on lines 93 and 94.)
// masque_layer |= EDGE_LAYER; /* Les elements de la couche EDGE sont tj traces */ // masque_layer |= EDGE_LAYER; /* Les elements de la couche EDGE sont tj traces */
...@@ -187,16 +188,16 @@ wxString msg; ...@@ -187,16 +188,16 @@ wxString msg;
break; break;
default: default:
DisplayError( this, wxT("Type Draw non gere") ); DisplayError( this, wxT( "Type Draw non gere" ) );
break; break;
} }
} }
/* Trace des Elements des modules autres que pads */ /* Trace des Elements des modules autres que pads */
nb_items = 0; nb_items = 0;
Affiche_1_Parametre(this, 38, wxT("DrawMod"), wxEmptyString, GREEN); Affiche_1_Parametre( this, 38, wxT( "DrawMod" ), wxEmptyString, GREEN );
Module = m_Pcb->m_Modules; Module = m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE *)Module->Pnext ) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
PtStruct = Module->m_Drawings; PtStruct = Module->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
...@@ -204,8 +205,8 @@ wxString msg; ...@@ -204,8 +205,8 @@ wxString msg;
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEEDGEMODULE: case TYPEEDGEMODULE:
if( masque_layer & g_TabOneLayerMask[((EDGE_MODULE*)PtStruct)->GetLayer()] ) if( masque_layer & g_TabOneLayerMask[( (EDGE_MODULE*) PtStruct )->GetLayer()] )
Plot_1_EdgeModule(PLOT_FORMAT_GERBER, (EDGE_MODULE*) PtStruct); Plot_1_EdgeModule( PLOT_FORMAT_GERBER, (EDGE_MODULE*) PtStruct );
break; break;
default: default:
...@@ -216,12 +217,12 @@ wxString msg; ...@@ -216,12 +217,12 @@ wxString msg;
/* Trace des Elements des modules : Pastilles */ /* Trace des Elements des modules : Pastilles */
nb_items = 0; nb_items = 0;
Affiche_1_Parametre(this, 48, wxT("Pads"), wxEmptyString, GREEN); Affiche_1_Parametre( this, 48, wxT( "Pads" ), wxEmptyString, GREEN );
Module = m_Pcb->m_Modules; Module = m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE *)Module->Pnext ) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
PtPad = (D_PAD*) Module->m_Pads; PtPad = (D_PAD*) Module->m_Pads;
for( ; PtPad != NULL; PtPad = (D_PAD*)PtPad->Pnext ) for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext )
{ {
wxPoint shape_pos; wxPoint shape_pos;
if( (PtPad->m_Masque_Layer & masque_layer) == 0 ) if( (PtPad->m_Masque_Layer & masque_layer) == 0 )
...@@ -241,44 +242,48 @@ wxString msg; ...@@ -241,44 +242,48 @@ wxString msg;
switch( PtPad->m_PadShape ) switch( PtPad->m_PadShape )
{ {
case PAD_CIRCLE: case PAD_CIRCLE:
Plot_1_CIRCLE_pad_GERBER(pos, size.x); Plot_1_CIRCLE_pad_GERBER( pos, size.x );
break; break;
case PAD_OVAL: case PAD_OVAL:
// Check whether the pad really has a circular shape instead // Check whether the pad really has a circular shape instead
if( size.x == size.y ) if( size.x == size.y )
Plot_1_CIRCLE_pad_GERBER(pos, size.x); Plot_1_CIRCLE_pad_GERBER( pos, size.x );
else else
trace_1_pastille_OVALE_GERBER(pos, size, PtPad->m_Orient); trace_1_pastille_OVALE_GERBER( pos, size, PtPad->m_Orient );
break; break;
case PAD_TRAPEZOID: case PAD_TRAPEZOID:
{ {
wxSize delta = PtPad->m_DeltaSize; wxSize delta = PtPad->m_DeltaSize;
trace_1_pad_TRAPEZE_GERBER(pos, size, trace_1_pad_TRAPEZE_GERBER( pos, size,
delta, PtPad->m_Orient, FILLED); delta, PtPad->m_Orient, FILLED );
} }
break; break;
case PAD_RECT: case PAD_RECT:
default: default:
PlotRectangularPad_GERBER(pos, size, PtPad->m_Orient); PlotRectangularPad_GERBER( pos, size, PtPad->m_Orient );
break; break;
} }
msg.Printf( wxT("%d"), nb_items );
Affiche_1_Parametre(this, 48, wxEmptyString, msg, GREEN); msg.Printf( wxT( "%d" ), nb_items );
Affiche_1_Parametre( this, 48, wxEmptyString, msg, GREEN );
} }
} }
/* trace des VIAS : */ /* trace des VIAS : */
if( tracevia ) if( tracevia )
{ {
nb_items = 0; nb_items = 0;
Affiche_1_Parametre(this, 56, wxT("Vias"), wxEmptyString, RED); Affiche_1_Parametre( this, 56, wxT( "Vias" ), wxEmptyString, RED );
for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext )
{ {
if( track->Type() != TYPEVIA ) if( track->Type() != TYPEVIA )
continue; continue;
SEGVIA * Via = (SEGVIA *) track; SEGVIA* Via = (SEGVIA*) track;
// vias not plotted if not on selected layer, but if layer // vias not plotted if not on selected layer, but if layer
// == SOLDERMASK_LAYER_CU or SOLDERMASK_LAYER_CMP, vias are drawn, // == SOLDERMASK_LAYER_CU or SOLDERMASK_LAYER_CMP, vias are drawn,
// if they are on a external copper layer // if they are on a external copper layer
...@@ -295,15 +300,15 @@ wxString msg; ...@@ -295,15 +300,15 @@ wxString msg;
/* Don't draw a null size item : */ /* Don't draw a null size item : */
if( size.x <= 0 ) if( size.x <= 0 )
continue; continue;
Plot_1_CIRCLE_pad_GERBER(pos, size.x); Plot_1_CIRCLE_pad_GERBER( pos, size.x );
nb_items++; nb_items++;
msg.Printf( wxT("%d"), nb_items ); msg.Printf( wxT( "%d" ), nb_items );
Affiche_1_Parametre(this, 56, wxEmptyString, msg, RED); Affiche_1_Parametre( this, 56, wxEmptyString, msg, RED );
} }
} }
/* trace des pistes : */ /* trace des pistes : */
nb_items = 0; nb_items = 0;
Affiche_1_Parametre(this, 64, wxT("Tracks"), wxEmptyString, YELLOW); Affiche_1_Parametre( this, 64, wxT( "Tracks" ), wxEmptyString, YELLOW );
for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext ) for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext )
{ {
...@@ -318,17 +323,17 @@ wxString msg; ...@@ -318,17 +323,17 @@ wxString msg;
pos = track->m_Start; pos = track->m_Start;
end = track->m_End; end = track->m_End;
PlotGERBERLine(pos, end, size.x); PlotGERBERLine( pos, end, size.x );
nb_items++; nb_items++;
msg.Printf( wxT("%d"), nb_items ); msg.Printf( wxT( "%d" ), nb_items );
Affiche_1_Parametre(this, 64, wxEmptyString, msg, YELLOW); Affiche_1_Parametre( this, 64, wxEmptyString, msg, YELLOW );
} }
/* trace des zones: */ /* trace des zones: */
nb_items = 0; nb_items = 0;
if( m_Pcb->m_Zone ) if( m_Pcb->m_Zone )
Affiche_1_Parametre(this, 72, wxT("Zones "), wxEmptyString, YELLOW); Affiche_1_Parametre( this, 72, wxT( "Zones " ), wxEmptyString, YELLOW );
for( track = m_Pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext ) for( track = m_Pcb->m_Zone; track != NULL; track = (TRACK*) track->Pnext )
{ {
...@@ -341,17 +346,17 @@ wxString msg; ...@@ -341,17 +346,17 @@ wxString msg;
pos = track->m_Start; pos = track->m_Start;
end = track->m_End; end = track->m_End;
PlotGERBERLine(pos, end, size.x); PlotGERBERLine( pos, end, size.x );
nb_items++; nb_items++;
msg.Printf( wxT("%d"), nb_items ); msg.Printf( wxT( "%d" ), nb_items );
Affiche_1_Parametre(this, 72, wxEmptyString, msg, YELLOW); Affiche_1_Parametre( this, 72, wxEmptyString, msg, YELLOW );
} }
} }
/**********************************************************************/ /**********************************************************************/
void trace_1_pastille_OVALE_GERBER(wxPoint pos, wxSize size, int orient) void trace_1_pastille_OVALE_GERBER( wxPoint pos, wxSize size, int orient )
/**********************************************************************/ /**********************************************************************/
/* Trace 1 pastille PAD_OVAL en position pos_X,Y: /* Trace 1 pastille PAD_OVAL en position pos_X,Y:
...@@ -361,34 +366,33 @@ void trace_1_pastille_OVALE_GERBER(wxPoint pos, wxSize size, int orient) ...@@ -361,34 +366,33 @@ void trace_1_pastille_OVALE_GERBER(wxPoint pos, wxSize size, int orient)
* Pour une orientation quelconque la forme est tracee comme un segment * Pour une orientation quelconque la forme est tracee comme un segment
*/ */
{ {
D_CODE * dcode_ptr; D_CODE* dcode_ptr;
int x0, y0, x1, y1, delta; int x0, y0, x1, y1, delta;
if( orient == 900 || orient == 2700 ) /* orient tournee de 90 deg */ if( orient == 900 || orient == 2700 ) /* orient tournee de 90 deg */
EXCHG(size.x, size.y); EXCHG( size.x, size.y );
/* Trace de la forme flashee */ /* Trace de la forme flashee */
if( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 ) if( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 )
{ {
UserToDeviceCoordinate(pos); UserToDeviceCoordinate( pos );
UserToDeviceSize(size); UserToDeviceSize( size );
dcode_ptr = get_D_code(size.x, size.y, GERB_OVALE, 0); dcode_ptr = get_D_code( size.x, size.y, GERB_OVALE, 0 );
if( dcode_ptr->m_NumDcode != s_Last_D_code ) if( dcode_ptr->m_NumDcode != s_Last_D_code )
{ {
sprintf(cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode); sprintf( cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode );
fputs(cbuf, dest); fputs( cbuf, dest );
s_Last_D_code = dcode_ptr->m_NumDcode; s_Last_D_code = dcode_ptr->m_NumDcode;
} }
sprintf(cbuf, "X%5.5dY%5.5dD03*\n", pos.x, pos.y); sprintf( cbuf, "X%5.5dY%5.5dD03*\n", pos.x, pos.y );
fputs(cbuf, dest); fputs( cbuf, dest );
} }
else /* Forme tracee comme un segment */ else /* Forme tracee comme un segment */
{ {
if( size.x > size.y ) if( size.x > size.y )
{ {
EXCHG(size.x, size.y); EXCHG( size.x, size.y );
if( orient < 2700 ) if( orient < 2700 )
orient += 900; orient += 900;
else else
...@@ -400,42 +404,43 @@ int x0, y0, x1, y1, delta; ...@@ -400,42 +404,43 @@ int x0, y0, x1, y1, delta;
y0 = -delta / 2; y0 = -delta / 2;
x1 = 0; x1 = 0;
y1 = delta / 2; y1 = delta / 2;
RotatePoint(&x0, &y0, orient); RotatePoint( &x0, &y0, orient );
RotatePoint(&x1, &y1, orient); RotatePoint( &x1, &y1, orient );
PlotGERBERLine( wxPoint(pos.x + x0, pos.y + y0), PlotGERBERLine( wxPoint( pos.x + x0, pos.y + y0 ),
wxPoint(pos.x + x1, pos.y + y1), size.x ); wxPoint( pos.x + x1, pos.y + y1 ), size.x );
} }
} }
/******************************************************************/ /******************************************************************/
void Plot_1_CIRCLE_pad_GERBER(wxPoint pos,int diametre) void Plot_1_CIRCLE_pad_GERBER( wxPoint pos, int diametre )
/******************************************************************/ /******************************************************************/
/* Plot a circular pad or via at the user position pos /* Plot a circular pad or via at the user position pos
*/ */
{ {
D_CODE * dcode_ptr; D_CODE* dcode_ptr;
wxSize size(diametre, diametre);
wxSize size( diametre, diametre );
UserToDeviceCoordinate(pos); UserToDeviceCoordinate( pos );
UserToDeviceSize(size); UserToDeviceSize( size );
dcode_ptr = get_D_code(size.x, size.x, GERB_CIRCLE, 0); dcode_ptr = get_D_code( size.x, size.x, GERB_CIRCLE, 0 );
if( dcode_ptr->m_NumDcode != s_Last_D_code ) if( dcode_ptr->m_NumDcode != s_Last_D_code )
{ {
sprintf(cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode); sprintf( cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode );
fputs(cbuf, dest); fputs( cbuf, dest );
s_Last_D_code = dcode_ptr->m_NumDcode; s_Last_D_code = dcode_ptr->m_NumDcode;
} }
sprintf(cbuf, "X%5.5dY%5.5dD03*\n", pos.x, pos.y); sprintf( cbuf, "X%5.5dY%5.5dD03*\n", pos.x, pos.y );
fputs(cbuf, dest); fputs( cbuf, dest );
} }
/**************************************************************************/ /**************************************************************************/
void PlotRectangularPad_GERBER(wxPoint pos, wxSize size, int orient) void PlotRectangularPad_GERBER( wxPoint pos, wxSize size, int orient )
/**************************************************************************/ /**************************************************************************/
/* Trace 1 pad rectangulaire d'orientation quelconque /* Trace 1 pad rectangulaire d'orientation quelconque
...@@ -445,42 +450,43 @@ void PlotRectangularPad_GERBER(wxPoint pos, wxSize size, int orient) ...@@ -445,42 +450,43 @@ void PlotRectangularPad_GERBER(wxPoint pos, wxSize size, int orient)
* de largeur 1/2 largeur pad * de largeur 1/2 largeur pad
*/ */
{ {
D_CODE * dcode_ptr; D_CODE* dcode_ptr;
/* Trace de la forme flashee */ /* Trace de la forme flashee */
switch( orient ) switch( orient )
{ {
case 900: case 900:
case 2700: /* la rotation de 90 ou 270 degres revient a permutter des dimensions */ case 2700: /* la rotation de 90 ou 270 degres revient a permutter des dimensions */
EXCHG(size.x, size.y); EXCHG( size.x, size.y );
// Pass through // Pass through
case 0: case 0:
case 1800: case 1800:
UserToDeviceCoordinate(pos); UserToDeviceCoordinate( pos );
UserToDeviceSize(size); UserToDeviceSize( size );
dcode_ptr = get_D_code(size.x, size.y, GERB_RECT, 0); dcode_ptr = get_D_code( size.x, size.y, GERB_RECT, 0 );
if( dcode_ptr->m_NumDcode != s_Last_D_code ) if( dcode_ptr->m_NumDcode != s_Last_D_code )
{ {
sprintf(cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode); sprintf( cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode );
fputs(cbuf, dest); fputs( cbuf, dest );
s_Last_D_code = dcode_ptr->m_NumDcode; s_Last_D_code = dcode_ptr->m_NumDcode;
} }
sprintf(cbuf, "X%5.5dY%5.5dD03*\n", pos.x, pos.y); sprintf( cbuf, "X%5.5dY%5.5dD03*\n", pos.x, pos.y );
fputs(cbuf, dest); fputs( cbuf, dest );
break; break;
default: /* Forme tracee par remplissage */ default: /* Forme tracee par remplissage */
trace_1_pad_TRAPEZE_GERBER(pos, size, wxSize(0, 0), orient, FILLED); trace_1_pad_TRAPEZE_GERBER( pos, size, wxSize( 0, 0 ), orient, FILLED );
break; break;
} }
} }
/*****************************************************************/ /*****************************************************************/
void trace_1_contour_GERBER(wxPoint pos, wxSize size, wxSize delta, void trace_1_contour_GERBER( wxPoint pos, wxSize size, wxSize delta,
int penwidth, int orient) int penwidth, int orient )
/*****************************************************************/ /*****************************************************************/
/* Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque /* Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque
...@@ -491,8 +497,8 @@ void trace_1_contour_GERBER(wxPoint pos, wxSize size, wxSize delta, ...@@ -491,8 +497,8 @@ void trace_1_contour_GERBER(wxPoint pos, wxSize size, wxSize delta,
* et son orientation orient * et son orientation orient
*/ */
{ {
int ii; int ii;
wxPoint coord[4]; wxPoint coord[4];
size.x /= 2; size.x /= 2;
size.y /= 2; size.y /= 2;
...@@ -513,7 +519,7 @@ wxPoint coord[4]; ...@@ -513,7 +519,7 @@ wxPoint coord[4];
for( ii = 0; ii < 4; ii++ ) for( ii = 0; ii < 4; ii++ )
{ {
RotatePoint(&coord[ii].x, &coord[ii].y, pos.x, pos.y, orient); RotatePoint( &coord[ii].x, &coord[ii].y, pos.x, pos.y, orient );
} }
PlotGERBERLine( coord[0], coord[1], penwidth ); PlotGERBERLine( coord[0], coord[1], penwidth );
...@@ -524,8 +530,8 @@ wxPoint coord[4]; ...@@ -524,8 +530,8 @@ wxPoint coord[4];
/*******************************************************************/ /*******************************************************************/
void trace_1_pad_TRAPEZE_GERBER(wxPoint pos, wxSize size,wxSize delta, void trace_1_pad_TRAPEZE_GERBER( wxPoint pos, wxSize size, wxSize delta,
int orient,int modetrace) int orient, int modetrace )
/*******************************************************************/ /*******************************************************************/
/* Trace 1 pad trapezoidal donne par : /* Trace 1 pad trapezoidal donne par :
...@@ -569,35 +575,35 @@ void trace_1_pad_TRAPEZE_GERBER(wxPoint pos, wxSize size,wxSize delta, ...@@ -569,35 +575,35 @@ void trace_1_pad_TRAPEZE_GERBER(wxPoint pos, wxSize size,wxSize delta,
* " 1 " * " 1 "
*/ */
{ {
int ii, jj; int ii, jj;
int dx, dy; int dx, dy;
wxPoint polygone[4]; /* coord sommets */ wxPoint polygone[4]; /* coord sommets */
int coord[8]; int coord[8];
int ddx, ddy; int ddx, ddy;
/* calcul des dimensions optimales du spot choisi = 1/4 plus petite dim */ /* calcul des dimensions optimales du spot choisi = 1/4 plus petite dim */
dx = size.x - abs(delta.y); dx = size.x - abs( delta.y );
dy = size.y - abs(delta.x); dy = size.y - abs( delta.x );
dx = size.x / 2; dx = size.x / 2;
dy = size.y / 2; dy = size.y / 2;
ddx = delta.x / 2; ddx = delta.x / 2;
ddy = delta.y / 2; ddy = delta.y / 2;
polygone[0].x = - dx - ddy; polygone[0].x = -dx - ddy;
polygone[0].y = + dy + ddx; polygone[0].y = +dy + ddx;
polygone[1].x = - dx + ddy; polygone[1].x = -dx + ddy;
polygone[1].y = - dy - ddx; polygone[1].y = -dy - ddx;
polygone[2].x = + dx - ddy; polygone[2].x = +dx - ddy;
polygone[2].y = - dy + ddx; polygone[2].y = -dy + ddx;
polygone[3].x = + dx + ddy; polygone[3].x = +dx + ddy;
polygone[3].y = + dy - ddx; polygone[3].y = +dy - ddx;
/* Dessin du polygone et Remplissage eventuel de l'interieur */ /* Dessin du polygone et Remplissage eventuel de l'interieur */
for( ii = 0, jj = 0; ii < 4; ii++ ) for( ii = 0, jj = 0; ii < 4; ii++ )
{ {
RotatePoint(&polygone[ii].x, &polygone[ii].y, orient); RotatePoint( &polygone[ii].x, &polygone[ii].y, orient );
coord[jj] = polygone[ii].x += pos.x; coord[jj] = polygone[ii].x += pos.x;
jj++; jj++;
coord[jj] = polygone[ii].y += pos.y; coord[jj] = polygone[ii].y += pos.y;
...@@ -611,35 +617,34 @@ int ddx, ddy; ...@@ -611,35 +617,34 @@ int ddx, ddy;
PlotGERBERLine( polygone[2], polygone[3], scale_spot_mini ); PlotGERBERLine( polygone[2], polygone[3], scale_spot_mini );
PlotGERBERLine( polygone[3], polygone[0], scale_spot_mini ); PlotGERBERLine( polygone[3], polygone[0], scale_spot_mini );
} }
else else
PlotPolygon_GERBER(4, coord, TRUE); PlotPolygon_GERBER( 4, coord, TRUE );
} }
/**********************************************************/ /**********************************************************/
void PlotGERBERLine(wxPoint start, wxPoint end, int large) void PlotGERBERLine( wxPoint start, wxPoint end, int large )
/**********************************************************/ /**********************************************************/
/* Trace 1 segment de piste : /* Trace 1 segment de piste :
*/ */
{ {
D_CODE * dcode_ptr; D_CODE* dcode_ptr;
UserToDeviceCoordinate(start); UserToDeviceCoordinate( start );
UserToDeviceCoordinate(end); UserToDeviceCoordinate( end );
dcode_ptr = get_D_code(large, large, GERB_LINE, 0); dcode_ptr = get_D_code( large, large, GERB_LINE, 0 );
if(dcode_ptr->m_NumDcode != s_Last_D_code ) if( dcode_ptr->m_NumDcode != s_Last_D_code )
{ {
sprintf(cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode); sprintf( cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode );
fputs(cbuf, dest); fputs( cbuf, dest );
s_Last_D_code = dcode_ptr->m_NumDcode; s_Last_D_code = dcode_ptr->m_NumDcode;
} }
sprintf(cbuf, "X%5.5dY%5.5dD02*\n", start.x, start.y); sprintf( cbuf, "X%5.5dY%5.5dD02*\n", start.x, start.y );
fputs(cbuf, dest); fputs( cbuf, dest );
sprintf(cbuf, "X%5.5dY%5.5dD01*\n", end.x, end.y); sprintf( cbuf, "X%5.5dY%5.5dD01*\n", end.x, end.y );
fputs(cbuf, dest); fputs( cbuf, dest );
} }
...@@ -650,9 +655,9 @@ void PlotCircle_GERBER( wxPoint centre, int rayon, int epaisseur ) ...@@ -650,9 +655,9 @@ void PlotCircle_GERBER( wxPoint centre, int rayon, int epaisseur )
/* routine de trace de 1 cercle de centre centre par approximation de segments /* routine de trace de 1 cercle de centre centre par approximation de segments
*/ */
{ {
int ii; int ii;
int ox, oy, fx, fy; int ox, oy, fx, fy;
int delta; /* increment (en 0.1 degres) angulaire pour trace de cercles */ int delta; /* increment (en 0.1 degres) angulaire pour trace de cercles */
delta = 120; /* un cercle sera trace en 3600/delta segments */ delta = 120; /* un cercle sera trace en 3600/delta segments */
/* Correction pour petits cercles par rapport a l'epaisseur du trait */ /* Correction pour petits cercles par rapport a l'epaisseur du trait */
...@@ -667,32 +672,32 @@ int delta; /* increment (en 0.1 degres) angulaire pour trace de cercles */ ...@@ -667,32 +672,32 @@ int delta; /* increment (en 0.1 degres) angulaire pour trace de cercles */
oy = centre.y; oy = centre.y;
for( ii = delta; ii < 3600; ii += delta ) for( ii = delta; ii < 3600; ii += delta )
{ {
fx = centre.x + (int)(rayon * fcosinus[ii]); fx = centre.x + (int) (rayon * fcosinus[ii]);
fy = centre.y + (int)(rayon * fsinus[ii]); fy = centre.y + (int) (rayon * fsinus[ii]);
PlotGERBERLine(wxPoint(ox, oy), wxPoint(fx, fy), epaisseur); PlotGERBERLine( wxPoint( ox, oy ), wxPoint( fx, fy ), epaisseur );
ox = fx; ox = fx;
oy = fy; oy = fy;
} }
fx = centre.x + rayon; fx = centre.x + rayon;
fy = centre.y; fy = centre.y;
PlotGERBERLine(wxPoint(ox ,oy), wxPoint(fx, fy), epaisseur); PlotGERBERLine( wxPoint( ox, oy ), wxPoint( fx, fy ), epaisseur );
} }
/***************************************************************/ /***************************************************************/
void PlotPolygon_GERBER(int nb_segm, int * coord, bool fill) void PlotPolygon_GERBER( int nb_segm, int* coord, bool fill )
/***************************************************************/ /***************************************************************/
{ {
int ii; int ii;
wxPoint pos; wxPoint pos;
fputs("G36*\n", dest); fputs( "G36*\n", dest );
pos.x = *coord; pos.x = *coord;
coord++; coord++;
pos.y = *coord; pos.y = *coord;
coord++; coord++;
UserToDeviceCoordinate(pos); UserToDeviceCoordinate( pos );
fprintf( dest, "X%5.5dY%5.5dD02*\n", pos.x, pos.y ); fprintf( dest, "X%5.5dY%5.5dD02*\n", pos.x, pos.y );
for( ii = 1; ii < nb_segm; ii++ ) for( ii = 1; ii < nb_segm; ii++ )
{ {
...@@ -700,34 +705,34 @@ wxPoint pos; ...@@ -700,34 +705,34 @@ wxPoint pos;
coord++; coord++;
pos.y = *coord; pos.y = *coord;
coord++; coord++;
UserToDeviceCoordinate(pos); UserToDeviceCoordinate( pos );
fprintf( dest, "X%5.5dY%5.5dD01*\n", pos.x, pos.y ); fprintf( dest, "X%5.5dY%5.5dD01*\n", pos.x, pos.y );
} }
fputs("G37*\n", dest); fputs( "G37*\n", dest );
} }
/*******************************************************/ /*******************************************************/
D_CODE * get_D_code( int dx, int dy, int type, int drill ) D_CODE* get_D_code( int dx, int dy, int type, int drill )
/*******************************************************/ /*******************************************************/
/* Fonction Recherchant et Creant eventuellement la description /* Fonction Recherchant et Creant eventuellement la description
* du D_CODE du type et dimensions demandees * du D_CODE du type et dimensions demandees
*/ */
{ {
D_CODE * ptr_tool, * last_dcode_ptr; D_CODE* ptr_tool, * last_dcode_ptr;
int num_new_D_code = FIRST_DCODE_VALUE; int num_new_D_code = FIRST_DCODE_VALUE;
ptr_tool = last_dcode_ptr = s_DCodeList; ptr_tool = last_dcode_ptr = s_DCodeList;
while( ptr_tool && ptr_tool->m_Type >= 0 ) while( ptr_tool && ptr_tool->m_Type >= 0 )
{ {
if( ( ptr_tool->m_Size.x == dx ) && if( ( ptr_tool->m_Size.x == dx )
( ptr_tool->m_Size.y == dy ) && && ( ptr_tool->m_Size.y == dy )
( ptr_tool->m_Type == type ) ) && ( ptr_tool->m_Type == type ) )
return(ptr_tool); /* D_code deja existant */ return ptr_tool; /* D_code deja existant */
last_dcode_ptr = ptr_tool; last_dcode_ptr = ptr_tool;
ptr_tool = ptr_tool->m_Pnext; ptr_tool = ptr_tool->m_Pnext;
num_new_D_code++; num_new_D_code++;
...@@ -737,6 +742,7 @@ int num_new_D_code = FIRST_DCODE_VALUE; ...@@ -737,6 +742,7 @@ int num_new_D_code = FIRST_DCODE_VALUE;
if( ptr_tool == NULL ) /* We must create a new data */ if( ptr_tool == NULL ) /* We must create a new data */
{ {
ptr_tool = new D_CODE(); ptr_tool = new D_CODE();
ptr_tool->m_NumDcode = num_new_D_code; ptr_tool->m_NumDcode = num_new_D_code;
if( last_dcode_ptr ) if( last_dcode_ptr )
{ {
...@@ -749,32 +755,32 @@ int num_new_D_code = FIRST_DCODE_VALUE; ...@@ -749,32 +755,32 @@ int num_new_D_code = FIRST_DCODE_VALUE;
ptr_tool->m_Size.x = dx; ptr_tool->m_Size.x = dx;
ptr_tool->m_Size.y = dy; ptr_tool->m_Size.y = dy;
ptr_tool->m_Type = type; ptr_tool->m_Type = type;
return(ptr_tool); return ptr_tool;
} }
/******************************************************************/ /******************************************************************/
void Init_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile) void Init_Trace_GERBER( WinEDA_BasePcbFrame* frame, FILE* gerbfile )
/******************************************************************/ /******************************************************************/
{ {
char Line[1024]; char Line[1024];
s_Last_D_code = 0; s_Last_D_code = 0;
DateAndTime(Line); DateAndTime( Line );
wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
fprintf(gerbfile, "G04 (Genere par %s) le %s*\n", CONV_TO_UTF8(Title), Line); fprintf( gerbfile, "G04 (Genere par %s) le %s*\n", CONV_TO_UTF8( Title ), Line );
// Specify linear interpol (G01), unit = INCH (G70), abs format (G90): // Specify linear interpol (G01), unit = INCH (G70), abs format (G90):
fputs("G01*\nG70*\nG90*\n", gerbfile); fputs( "G01*\nG70*\nG90*\n", gerbfile );
fputs("%MOIN*%\n", gerbfile); // set unites = INCHES fputs( "%MOIN*%\n", gerbfile ); // set unites = INCHES
/* Set gerber format to 3.4 */ /* Set gerber format to 3.4 */
strcpy(Line, "G04 Gerber Fmt 3.4, Leading zero omitted, Abs format*\n%FSLAX34Y34*%\n"); strcpy( Line, "G04 Gerber Fmt 3.4, Leading zero omitted, Abs format*\n%FSLAX34Y34*%\n" );
fputs(Line, gerbfile); fputs( Line, gerbfile );
fputs("G04 APERTURE LIST*\n", gerbfile); fputs( "G04 APERTURE LIST*\n", gerbfile );
} }
...@@ -787,7 +793,7 @@ static void Init_ApertureList() ...@@ -787,7 +793,7 @@ static void Init_ApertureList()
* .m_Type < 0 is the first free aperture descr * .m_Type < 0 is the first free aperture descr
*/ */
{ {
D_CODE * ptr_tool; D_CODE* ptr_tool;
ptr_tool = s_DCodeList; ptr_tool = s_DCodeList;
while( ptr_tool ) while( ptr_tool )
...@@ -795,61 +801,62 @@ D_CODE * ptr_tool; ...@@ -795,61 +801,62 @@ D_CODE * ptr_tool;
s_DCodeList->m_Type = -1; s_DCodeList->m_Type = -1;
ptr_tool = ptr_tool->m_Pnext; ptr_tool = ptr_tool->m_Pnext;
} }
ShowDcodeError = TRUE; ShowDcodeError = TRUE;
} }
/*****************************************************************/ /*****************************************************************/
void Fin_Trace_GERBER(WinEDA_BasePcbFrame * frame, FILE * gerbfile) void Fin_Trace_GERBER( WinEDA_BasePcbFrame* frame, FILE* gerbfile )
/*****************************************************************/ /*****************************************************************/
{ {
char line[1024]; char line[1024];
wxString TmpFileName, msg; wxString TmpFileName, msg;
FILE * outfile; FILE* outfile;
fputs("M02*\n", gerbfile); fputs( "M02*\n", gerbfile );
fclose(gerbfile); fclose( gerbfile );
// Reouverture gerbfile pour ajout des Apertures // Reouverture gerbfile pour ajout des Apertures
gerbfile = wxFopen( GerberFullFileName, wxT("rt") ); gerbfile = wxFopen( GerberFullFileName, wxT( "rt" ) );
if( gerbfile == NULL ) if( gerbfile == NULL )
{ {
msg.Printf( _("unable to reopen file <%s>"), GerberFullFileName.GetData() ); msg.Printf( _( "unable to reopen file <%s>" ), GerberFullFileName.GetData() );
DisplayError(frame, msg); DisplayError( frame, msg );
return; return;
} }
// Ouverture tmpfile // Ouverture tmpfile
TmpFileName = GerberFullFileName + wxT(".$$$"); TmpFileName = GerberFullFileName + wxT( ".$$$" );
outfile = wxFopen( TmpFileName, wxT("wt") ); outfile = wxFopen( TmpFileName, wxT( "wt" ) );
if( outfile == NULL ) if( outfile == NULL )
{ {
fclose(gerbfile); fclose( gerbfile );
DisplayError(frame, wxT("Fin_Trace_GERBER(): Can't Open tmp file")); DisplayError( frame, wxT( "Fin_Trace_GERBER(): Can't Open tmp file" ) );
return; return;
} }
// Placement des Apertures en RS274X // Placement des Apertures en RS274X
rewind(gerbfile); rewind( gerbfile );
while( fgets(line, 1024, gerbfile) ) while( fgets( line, 1024, gerbfile ) )
{ {
fputs(line, outfile); fputs( line, outfile );
if( strcmp(strtok(line, "\n\r"), "G04 APERTURE LIST*") == 0 ) if( strcmp( strtok( line, "\n\r" ), "G04 APERTURE LIST*" ) == 0 )
{ {
frame->Gen_D_CODE_File(outfile); frame->Gen_D_CODE_File( outfile );
fputs("G04 APERTURE END LIST*\n", outfile); fputs( "G04 APERTURE END LIST*\n", outfile );
} }
} }
fclose(outfile); fclose( outfile );
fclose(gerbfile); fclose( gerbfile );
wxRemoveFile(GerberFullFileName); wxRemoveFile( GerberFullFileName );
wxRenameFile(TmpFileName, GerberFullFileName); wxRenameFile( TmpFileName, GerberFullFileName );
} }
/******************************************************/ /******************************************************/
int WinEDA_BasePcbFrame::Gen_D_CODE_File(FILE * penfile) int WinEDA_BasePcbFrame::Gen_D_CODE_File( FILE* penfile )
/******************************************************/ /******************************************************/
/* Genere la liste courante des D_CODES /* Genere la liste courante des D_CODES
...@@ -857,8 +864,8 @@ int WinEDA_BasePcbFrame::Gen_D_CODE_File(FILE * penfile) ...@@ -857,8 +864,8 @@ int WinEDA_BasePcbFrame::Gen_D_CODE_File(FILE * penfile)
* Genere une sequence RS274X * Genere une sequence RS274X
*/ */
{ {
D_CODE * ptr_tool; D_CODE* ptr_tool;
int nb_dcodes = 0 ; int nb_dcodes = 0;
/* Init : */ /* Init : */
ptr_tool = s_DCodeList; ptr_tool = s_DCodeList;
...@@ -866,40 +873,42 @@ int nb_dcodes = 0 ; ...@@ -866,40 +873,42 @@ int nb_dcodes = 0 ;
while( ptr_tool && ( ptr_tool->m_Type >= 0 ) ) while( ptr_tool && ( ptr_tool->m_Type >= 0 ) )
{ {
float fscale = 0.0001; // For 3.4 format float fscale = 0.0001; // For 3.4 format
char * text; char* text;
sprintf(cbuf, "%%ADD%d", ptr_tool->m_NumDcode); sprintf( cbuf, "%%ADD%d", ptr_tool->m_NumDcode );
text = cbuf + strlen(cbuf); text = cbuf + strlen( cbuf );
switch( ptr_tool->m_Type ) switch( ptr_tool->m_Type )
{ {
case 1: // Circle (flash ) case 1: // Circle (flash )
sprintf(text, "C,%f*%%\n", ptr_tool->m_Size.x * fscale); sprintf( text, "C,%f*%%\n", ptr_tool->m_Size.x * fscale );
break; break;
case 2: // PAD_RECT case 2: // PAD_RECT
sprintf(text, "R,%fX%f*%%\n", ptr_tool->m_Size.x * fscale, sprintf( text, "R,%fX%f*%%\n", ptr_tool->m_Size.x * fscale,
ptr_tool->m_Size.y * fscale); ptr_tool->m_Size.y * fscale );
break; break;
case 3: // Circle ( lines ) case 3: // Circle ( lines )
sprintf(text, "C,%f*%%\n", ptr_tool->m_Size.x * fscale); sprintf( text, "C,%f*%%\n", ptr_tool->m_Size.x * fscale );
break; break;
case 4: // PAD_OVAL case 4: // PAD_OVAL
sprintf(text, "O,%fX%f*%%\n", ptr_tool->m_Size.x * fscale, sprintf( text, "O,%fX%f*%%\n", ptr_tool->m_Size.x * fscale,
ptr_tool->m_Size.y * fscale); ptr_tool->m_Size.y * fscale );
break; break;
default: default:
DisplayError( this, wxT("Gen_D_CODE_File(): Dcode Type err") ); DisplayError( this, wxT( "Gen_D_CODE_File(): Dcode Type err" ) );
break; break;
} }
// compensation localisation printf (float x.y gnr x,y) // compensation localisation printf (float x.y gnr x,y)
to_point( text + 2 ); to_point( text + 2 );
fputs(cbuf, penfile); fputs( cbuf, penfile );
ptr_tool = ptr_tool->m_Pnext; ptr_tool = ptr_tool->m_Pnext;
nb_dcodes++; nb_dcodes++;
} }
return( nb_dcodes ); return nb_dcodes;
} }
...@@ -25,7 +25,7 @@ const int DRILL_MARK = 1; ...@@ -25,7 +25,7 @@ const int DRILL_MARK = 1;
/****************************************************************************/ /****************************************************************************/
void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer ) void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer, bool useA4 )
/****************************************************************************/ /****************************************************************************/
/* Genere un fichier POSTSCRIPT (*.ps) de trace du circuit, couche layer /* Genere un fichier POSTSCRIPT (*.ps) de trace du circuit, couche layer
...@@ -59,6 +59,7 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer ) ...@@ -59,6 +59,7 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer )
if( g_PlotScaleOpt != 1 ) if( g_PlotScaleOpt != 1 )
Center = TRUE; // Echelle != 1 donc trace centree du PCB Center = TRUE; // Echelle != 1 donc trace centree du PCB
modetrace = Plot_Mode; modetrace = Plot_Mode;
scale_format = 1.0; scale_format = 1.0;
...@@ -69,7 +70,8 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer ) ...@@ -69,7 +70,8 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer )
// calcul en unites internes des dimensions des feuilles ( connues en 1/1000 pouce ) // calcul en unites internes des dimensions des feuilles ( connues en 1/1000 pouce )
PcbSheetSize.x = currentsheet->m_Size.x * U_PCB; PcbSheetSize.x = currentsheet->m_Size.x * U_PCB;
PcbSheetSize.y = currentsheet->m_Size.y * U_PCB; PcbSheetSize.y = currentsheet->m_Size.y * U_PCB;
if( g_ForcePlotPS_On_A4 )
if( useA4 )
{ {
SheetPS = &g_Sheet_A4; SheetPS = &g_Sheet_A4;
PaperSize.x = g_Sheet_A4.m_Size.x * U_PCB; PaperSize.x = g_Sheet_A4.m_Size.x * U_PCB;
......
...@@ -2707,6 +2707,10 @@ public: ...@@ -2707,6 +2707,10 @@ public:
}; };
/**
* Class CLASS
* corresponds to the &lt;class_descriptor&gt; in the specctra spec.
*/
class CLASS : public ELEM class CLASS : public ELEM
{ {
friend class SPECCTRA_DB; friend class SPECCTRA_DB;
......
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