From 0421987b3223e2c02dd4cf3e5a26bd3fee6d3a21 Mon Sep 17 00:00:00 2001 From: g_harland Date: Mon, 20 Aug 2007 13:28:34 +0000 Subject: [PATCH] Comments within postscript files now fully comply with Adobe's Document Structuring Convention, and beautification --- change_log.txt | 7 + common/common_plotPS_functions.cpp | 274 ++++++---- eeschema/plotps.cpp | 8 +- include/plot_common.h | 20 +- pcbnew/gendrill.cpp | 7 +- pcbnew/plotps.cpp | 808 ++++++++++++++++------------- 6 files changed, 643 insertions(+), 481 deletions(-) diff --git a/change_log.txt b/change_log.txt index fec70b98bb..e27458e9f6 100644 --- a/change_log.txt +++ b/change_log.txt @@ -4,6 +4,13 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2007-Aug-20 UPDATE Geoff Harland +================================================================================ ++ eeschema & pcbnew + The comments provided within postscript files now fully comply with Adobe's + Document Structuring Convention. + + 2007-aug-20 UPDATE Jean-Pierre Charras ================================================================================ + eeschema & pcbnew diff --git a/common/common_plotPS_functions.cpp b/common/common_plotPS_functions.cpp index a0547d7b83..be42d429b6 100644 --- a/common/common_plotPS_functions.cpp +++ b/common/common_plotPS_functions.cpp @@ -11,6 +11,8 @@ #include "plot_common.h" #include "macros.h" +#include "wx/defs.h" + // Variables partagees avec Common plot Postscript Routines extern wxPoint LastPenPosition; extern wxPoint PlotOffset; @@ -22,14 +24,16 @@ extern int PlotOrientOptions, etat_plume; // Locales static Ki_PageDescr * SheetPS; + /*************************************************************************************/ void InitPlotParametresPS(wxPoint offset, Ki_PageDescr * sheet, double xscale, double yscale, int orient) /*************************************************************************************/ + /* Set the plot offset for the current plotting - xscale,yscale = coordinate scale (scale coefficient for coordinates) - device_xscale,device_yscale = device coordinate scale (i.e scale used by plot device) -*/ + * xscale,yscale = coordinate scale (scale coefficient for coordinates) + * device_xscale,device_yscale = device coordinate scale (i.e scale used by plot device) + */ { PlotOrientOptions = orient; PlotOffset = offset; @@ -39,55 +43,66 @@ void InitPlotParametresPS(wxPoint offset, Ki_PageDescr * sheet, g_CurrentPenWidth = -1; } + /*************************************************************************************/ -void SetDefaultLineWidthPS( int width) +void SetDefaultLineWidthPS(int width) /*************************************************************************************/ + /* Set the default line width (in 1/1000 inch) for the current plotting -*/ + */ { - g_DefaultPenWidth = width; /* epaisseur du trait standard en 1/1000 pouce */ + g_DefaultPenWidth = width; // epaisseur du trait standard en 1/1000 pouce g_CurrentPenWidth = -1; } + /***************************************/ -void SetCurrentLineWidthPS( int width) +void SetCurrentLineWidthPS(int width) /***************************************/ + /* Set the Current line width (in 1/1000 inch) for the next plot -*/ + */ { int pen_width; - if ( width > 0 ) pen_width = width; - else pen_width = g_DefaultPenWidth; - if ( pen_width != g_CurrentPenWidth ) - fprintf(PlotOutputFile,"%d setlinewidth\n", (int)(XScale * pen_width)); + if( width > 0 ) + pen_width = width; + else + pen_width = g_DefaultPenWidth; + + if( pen_width != g_CurrentPenWidth ) + fprintf(PlotOutputFile, "%d setlinewidth\n", (int)(XScale * pen_width) ); + g_CurrentPenWidth = pen_width; } + /******************************/ void SetColorMapPS(int color) /******************************/ -/* Print the postscript set color command: - r g b setrgbcolor, - r, g, b = color values (= 0 .. 1.0 ) - color = color index in ColorRefs[] -*/ +/* Print the postscript set color command: + * r g b setrgbcolor, + * r, g, b = color values (= 0 .. 1.0 ) + * + * color = color index in ColorRefs[] + */ { char Line[1024]; - sprintf( Line,"%.3f %.3f %.3f setrgbcolor\n", - (float)ColorRefs[color].m_Red/255, - (float)ColorRefs[color].m_Green/255, - (float)ColorRefs[color].m_Blue/255 - ); + sprintf( Line, "%.3f %.3f %.3f setrgbcolor\n", + (float)ColorRefs[color].m_Red / 255, + (float)ColorRefs[color].m_Green / 255, + (float)ColorRefs[color].m_Blue / 255 ); 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 */ { @@ -109,104 +124,129 @@ char Line[256]; UserToDeviceCoordinate(pos); rayon = (int)(XScale * diametre / 2); - if(rayon < 0 ) rayon = 0 ; + if( rayon < 0 ) + rayon = 0; SetCurrentLineWidthPS(width); - sprintf(Line,"newpath %d %d %d 0 360 arc stroke\n", pos.x, pos.y, rayon); - fputs(Line,PlotOutputFile) ; + sprintf(Line, "newpath %d %d %d 0 360 arc stroke\n", pos.x, pos.y, rayon); + fputs(Line, PlotOutputFile); } - /**************************************************************************************/ void PlotArcPS(wxPoint centre, int StAngle, int EndAngle, int rayon, int width) /**************************************************************************************/ + /* 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]; - if(rayon <= 0 ) return ; + if( rayon <= 0 ) + return; SetCurrentLineWidthPS(width); - /* Calcul des coord du point de depart : */ + // Calcul des coord du point de depart : UserToDeviceCoordinate(centre); - if( PlotOrientOptions == PLOT_MIROIR) - sprintf(Line, "newpath %d %d %d %f %f arc stroke\n", centre.x, centre.y, - (int)(rayon * XScale), (float)StAngle/10, (float)EndAngle/10 ) ; + if( PlotOrientOptions == PLOT_MIROIR ) + sprintf( Line, "newpath %d %d %d %f %f arc stroke\n", centre.x, centre.y, + (int)(rayon * XScale), (float)StAngle / 10, (float)EndAngle / 10 ); else - sprintf(Line, "newpath %d %d %d %f %f arc stroke\n", centre.x, centre.y, - (int)(rayon * XScale), -(float)EndAngle/10, -(float)StAngle/10 ) ; + sprintf( Line, "newpath %d %d %d %f %f arc stroke\n", centre.x, centre.y, + (int)(rayon * XScale), -(float)EndAngle / 10, -(float)StAngle / 10 ); // Undo internationalization printf (float x.y printed x,y) 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) +/*****************************************************************/ + /* Trace un polygone ( ferme si rempli ) en format POSTSCRIPT - coord = tableau des coord des sommets - nb_segm = nombre de coord ( 1 coord = 2 elements: X et Y du tableau ) - fill : si != 0 polygone rempli -*/ + * coord = tableau des coord des sommets + * nb_segm = nombre de coord ( 1 coord = 2 elements: X et Y du tableau ) + * fill : si != 0 polygone rempli + */ { int ii; wxPoint pos; - if( nb_segm <= 1 ) return; + if( nb_segm <= 1 ) + return; SetCurrentLineWidthPS(width); - pos.x = coord[0]; pos.y = coord[1]; + pos.x = coord[0]; + pos.y = coord[1]; UserToDeviceCoordinate(pos); fprintf(PlotOutputFile, "newpath %d %d moveto\n", pos.x, pos.y); for( ii = 1; ii < nb_segm; ii ++ ) - { - pos.x = coord[ii*2]; pos.y = coord[(ii*2)+1]; + { + pos.x = coord[2 * ii]; + pos.y = coord[2 * ii + 1]; UserToDeviceCoordinate(pos); fprintf(PlotOutputFile, "%d %d lineto\n", pos.x, pos.y); - } + } - /* Fermeture du polygone */ - if( fill ) fprintf(PlotOutputFile, "closepath "); - if( fill == 1 ) fprintf(PlotOutputFile, "fill "); + // Fermeture du polygone + if( fill ) + fprintf(PlotOutputFile, "closepath "); + if( fill == 1 ) + fprintf(PlotOutputFile, "fill "); fprintf(PlotOutputFile, "stroke\n"); } -/*************************************/ -/* Routine to draw to a new position */ /*************************************/ void LineTo_PS(wxPoint pos, int plume) +/*************************************/ + +/* Routine to draw to a new position + */ { - if ( plume == 'Z') return; + if( plume == 'Z' ) + return; UserToDeviceCoordinate(pos); - if ( plume == 'D') + if( plume == 'D' ) { - char Line[256]; - sprintf(Line,"%d %d %d %d line\n", - LastPenPosition.x, LastPenPosition.y, pos.x, pos.y); - fputs(Line,PlotOutputFile); + char Line[256]; + sprintf(Line, "%d %d %d %d line\n", + LastPenPosition.x, LastPenPosition.y, pos.x, pos.y); + fputs(Line, PlotOutputFile); } LastPenPosition = pos; } -/**********************************************************/ -void PrintHeaderPS(FILE * file, const wxString & Creator, - const wxString & FileName, int BBox[4]) /***********************************************************/ -/* BBox is the boundary box (position and size of the "client rectangle" -for drawings (page - margins) in mils (0.001 inch) -*/ +void PrintHeaderPS(FILE * file, const wxString & Creator, + const wxString & FileName, int PageCount, + int BBox[4], int PaperOrientation) +/***********************************************************/ + +/* The code within this function (and the CloseFilePS function) + * creates postscript files whose contents comply with Adobe's + * Document Structuring Convention, as documented by assorted + * details described within the following URLs: + * + * http://en.wikipedia.org/wiki/Document_Structuring_Conventions + * http://partners.adobe.com/public/developer/en/ps/5001.DSC_Spec.pdf + * + * + * The PageCount and PaperOrientation parameters have been provided to + * respectively cater for the production of multiple-page postscript + * files, and postscript files having either a portrait orientation + * or a landscape orientation. + * + * BBox is the boundary box (position and size of the "client rectangle" + * for drawings (page - margins) in mils (0.001 inch) + */ { wxString msg; char Line[1024]; @@ -218,61 +258,112 @@ const char *PSMacro[] = { " stroke\n", "} def\n", "gsave\n", -"72 72 scale\t\t\t%% Talk inches\n", +"72 72 scale\t\t\t% Talk inches\n", "1 setlinecap\n", "1 setlinejoin\n", "1 setlinewidth\n", NULL }; -#define MIL_TO_INCH 0.001 +const double MIL_TO_INCH = 0.001; int ii; time_t time1970 = time(NULL); PlotOutputFile = file; - fputs("%!PS-Adobe-3.0\n",PlotOutputFile); // Print header + fputs("%!PS-Adobe-3.0\n", PlotOutputFile); // Print header - /* Print boundary box en 1/72 pouce, box is in mils */ - #define CONV_SCALE (MIL_TO_INCH * 72) - sprintf( Line, "%%%%BoundingBox: %d %d %d %d\n", - (int)(BBox[1]*CONV_SCALE), (int)(BBox[0]*CONV_SCALE), - (int)(BBox[3]*CONV_SCALE), (int)(BBox[2]*CONV_SCALE)); + sprintf( Line, "%%%%Creator: %s\n", CONV_TO_UTF8(Creator) ); + fputs(Line, PlotOutputFile); + + // A "newline" character ("\n") is not included in the following string, + // because it is provided by the ctime() function. + sprintf( Line, "%%%%CreationDate: %s", ctime(&time1970) ); fputs(Line, PlotOutputFile); sprintf( Line, "%%%%Title: %s\n", CONV_TO_UTF8(FileName) ); fputs(Line, PlotOutputFile); - sprintf( Line, "%%%%Creator: %s_n", CONV_TO_UTF8(Creator) ); + sprintf( Line, "%%%%Pages: %d\n", PageCount ); fputs(Line, PlotOutputFile); - sprintf( Line, "%%%%CreationDate: %s\n", ctime(&time1970) ); + sprintf( Line, "%%%%PageOrder: Ascend\n" ); fputs(Line, PlotOutputFile); - sprintf( Line, "%%%%DocumentPaperSizes: %s\n", CONV_TO_UTF8(SheetPS->m_Name) ); + // Print boundary box en 1/72 pouce, box is in mils + const double CONV_SCALE = MIL_TO_INCH * 72; + // The coordinates of the lower left corner of the boundary + // box need to be "rounded down", but the coordinates of its + // upper right corner need to be "rounded up" instead. + sprintf( Line, "%%%%BoundingBox: %d %d %d %d\n", + (int)floor((BBox[1] * CONV_SCALE)), (int)floor((BBox[0] * CONV_SCALE)), + (int)ceil((BBox[3] * CONV_SCALE)), (int)ceil((BBox[2] * CONV_SCALE)) ); fputs(Line, PlotOutputFile); - sprintf( Line, "%%%%Orientation: Landscape\n%%%%EndComments\n"); + // 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, + // identify the sheet size as "Custom" (rather than as "User"), but + // otherwise use the name assigned by KiCad for each sheet size.) + // + // (The Document Structuring Convention also supports sheet weight, + // sheet colour, and sheet type properties being specified within a + // %%DocumentMedia comment, but they are not being specified here; + // a zero and two null strings are subsequently provided instead.) + // + // (NOTE: m_Size.y is *supposed* to be listed before m_Size.x; + // the order in which they are specified is not wrong!) + if( SheetPS->m_Name.Cmp( wxT("User") ) == 0 ) + sprintf( Line, "%%%%DocumentMedia: Custom %d %d 0 () ()\n", + (int)round( SheetPS->m_Size.y * CONV_SCALE ), + (int)round( SheetPS->m_Size.x * CONV_SCALE ) ); + else // ( if SheetPS->m_Name does not equal "User" ) + sprintf( Line, "%%%%DocumentMedia: %s %d %d 0 () ()\n", + CONV_TO_UTF8( SheetPS->m_Name ), + (int)round( SheetPS->m_Size.y * CONV_SCALE ), + (int)round( SheetPS->m_Size.x * CONV_SCALE ) ); fputs(Line, PlotOutputFile); - for (ii = 0; PSMacro[ii] != NULL; ii++) + if( PaperOrientation == wxPORTRAIT ) + sprintf( Line, "%%%%Orientation: Portrait\n" ); + else + sprintf( Line, "%%%%Orientation: Landscape\n" ); + fputs(Line, PlotOutputFile); + + sprintf( Line, "%%%%EndComments\n" ); + fputs(Line, PlotOutputFile); + + // Now specify various other details. + + // The following string has been specified here (rather than within + // PSMacro[]) to highlight that it has been provided to ensure that the + // contents of the postscript file comply with the details specified + // within the Document Structuring Convention. + sprintf( Line, "%%%%Page: 1 1\n" ); + fputs(Line, PlotOutputFile); + + for ( ii = 0; PSMacro[ii] != NULL; ii++ ) { - fputs(PSMacro[ii],PlotOutputFile); + fputs(PSMacro[ii], PlotOutputFile); } - sprintf(Line, "%f %f translate 90 rotate\n", - (float) BBox[3] * MIL_TO_INCH, (float)BBox[0] * MIL_TO_INCH ); + if( PaperOrientation == wxLANDSCAPE ) + sprintf(Line, "%f %f translate 90 rotate\n", + (float)BBox[3] * MIL_TO_INCH, (float)BBox[0] * MIL_TO_INCH); + // (If support for creating postscript files with a portrait orientation + // is ever provided, determine whether it would be necessary to provide + // an "else" command and then an appropriate "sprintf" command here.) + // compensation internationalisation printf (float x.y généré x,y) 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); to_point(Line); - fputs(Line,PlotOutputFile); + fputs(Line, PlotOutputFile); - // Set default line width: - fprintf(PlotOutputFile,"%d setlinewidth\n", g_DefaultPenWidth ); //g_DefaultPenWidth in user units + // Set default line width ( g_DefaultPenWidth is in user units ) + fprintf(PlotOutputFile, "%d setlinewidth\n", g_DefaultPenWidth); } @@ -280,8 +371,9 @@ time_t time1970 = time(NULL); bool CloseFilePS(FILE * plot_file) /******************************************/ { - fputs("showpage\n",plot_file); - fputs("grestore\n",plot_file); + fputs("showpage\n", plot_file); + fputs("grestore\n", plot_file); + fputs("%%EOF\n", plot_file); fclose(plot_file); diff --git a/eeschema/plotps.cpp b/eeschema/plotps.cpp index 0020b973e3..4626df2bd9 100644 --- a/eeschema/plotps.cpp +++ b/eeschema/plotps.cpp @@ -36,9 +36,10 @@ #include "plot_common.h" #include "protos.h" +#include "wx/defs.h" -/* coeff de conversion dim en 1 mil -> dim en unite PS: */ -#define SCALE_PS 0.001 +// coeff de conversion dim en 1 mil -> dim en unite PS: +const double SCALE_PS = 0.001; extern void Move_Plume( wxPoint pos, int plume ); extern void Plume( int plume ); @@ -399,7 +400,7 @@ wxPoint StartPos, EndPos; SetDefaultLineWidthPS( g_PlotPSMinimunLineWidth); /* Init : */ - PrintHeaderPS(PlotOutput, wxT("EESchema-PS"), FileName, BBox); + PrintHeaderPS( PlotOutput, wxT("EESchema-PS"), FileName, 1, BBox, wxLANDSCAPE ); InitPlotParametresPS(plot_offset, sheet, 1.0, 1.0); if ( m_Plot_Sheet_Ref->GetValue() ) @@ -513,4 +514,3 @@ wxPoint StartPos, EndPos; m_MsgBox->AppendText( wxT("Ok\n")); } - diff --git a/include/plot_common.h b/include/plot_common.h index cba7cee854..eb01c5edac 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -19,23 +19,23 @@ typedef enum { PLOT_FORMAT_POST_A4 } PlotFormat; -#define PLOT_MIROIR 1 +const int PLOT_MIROIR = 1; /*******************************/ /* common_plot_functions.cpp */ /*******************************/ -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 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 InitPlotParametresGERBER(wxPoint offset, double xscale, double yscale); void PlotWorkSheet(int format_plot, BASE_SCREEN * screen); void UserToDeviceCoordinate(wxPoint & pos ); - /* modifie les coord pos.x et pos.y pour le trace selon l'orientation, l'echelle, les offsets de trace */ + // 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 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 void ForcePenReinit(void); - /* 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 /*******************************/ @@ -46,16 +46,15 @@ void InitPlotParametresPS( wxPoint offset, Ki_PageDescr * sheet, double xscale, void SetDefaultLineWidthPS( int width); void PlotCircle_PS(wxPoint pos, int diametre, int width = -1); void PlotArcPS(wxPoint centre, int StAngle, int EndAngle, int rayon, int width = -1); - /* Plot an arc: StAngle, EndAngle = start and end arc in 0.1 degree */ + // Plot an arc: StAngle, EndAngle = start and end arc in 0.1 degree 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 BBox[4]); +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 */ /*********************************/ @@ -70,4 +69,3 @@ void Plume_HPGL( int plume ); #endif // PLOT_COMMON_H - diff --git a/pcbnew/gendrill.cpp b/pcbnew/gendrill.cpp index 6bdc81e533..cd4e18dc21 100644 --- a/pcbnew/gendrill.cpp +++ b/pcbnew/gendrill.cpp @@ -15,6 +15,7 @@ #include "protos.h" +#include "wx/defs.h" /* Generation du fichier de percage en format EXCELLON @@ -89,8 +90,8 @@ enum id_drill { ID_SEL_DRILL_UNITS, ID_SEL_DRILL_SHEET, ID_SEL_DRILL_REPORT, - ID_SEL_ZEROS_FMT, - ID_SEL_PRECISION + ID_SEL_ZEROS_FMT, + ID_SEL_PRECISION }; class WinEDA_DrillFrame: public wxDialog @@ -958,7 +959,7 @@ wxString msg; InitPlotParametresPS(g_PlotOffset, SheetPS, (double) 1.0 / PCB_INTERNAL_UNIT, (double) 1.0 / PCB_INTERNAL_UNIT); SetDefaultLineWidthPS(10); // Set line with to 10/1000 inch - PrintHeaderPS(dest, wxT("PCBNEW-PS"), FullFileName, BBox); + PrintHeaderPS(dest, wxT("PCBNEW-PS"), FullFileName, 1, BBox, wxLANDSCAPE); InitPlotParametresPS(g_PlotOffset, SheetPS, scale_x, scale_y); } break; diff --git a/pcbnew/plotps.cpp b/pcbnew/plotps.cpp index f4e4a5c5d1..7163ef5281 100644 --- a/pcbnew/plotps.cpp +++ b/pcbnew/plotps.cpp @@ -13,20 +13,23 @@ #include "protos.h" -/* Routines Locales */ +#include "wx/defs.h" + +// Routines Locales static void PrintDrillMark(BOARD * Pcb); static Ki_PageDescr * SheetPS; -/* variables locales: */ +// variables locales: +const int DRILL_MARK = 1; -#define DRILL_MARK 1 /****************************************************************************/ void WinEDA_BasePcbFrame::Genere_PS(const wxString & FullFileName, int Layer) /****************************************************************************/ + /* Genere un fichier POSTSCRIPT (*.ps) de trace du circuit, couche layer - if layer < 0: all layers -*/ + * if layer < 0: all layers + */ { int modetrace, tracevia; wxSize PcbSheetSize; @@ -41,26 +44,30 @@ int PlotMarge_in_mils = 0; MsgPanel->EraseMsgBox(); - dest = wxFopen(FullFileName, wxT("wt") ); - if (dest == NULL) + dest = wxFopen( FullFileName, wxT("wt") ); + if( dest == NULL ) { wxString msg = _("Unable to create file ") + FullFileName; - DisplayError(this, msg); return ; + DisplayError(this, msg); + return; } setlocale(LC_NUMERIC, "C"); - Affiche_1_Parametre(this, 0,_("File"),FullFileName,CYAN) ; + Affiche_1_Parametre(this, 0, _("File"), FullFileName, CYAN); - if( g_PlotScaleOpt != 1 ) Center = TRUE; // Echelle != 1 donc trace centree du PCB + if( g_PlotScaleOpt != 1 ) + Center = TRUE; // Echelle != 1 donc trace centree du PCB modetrace = Plot_Mode; scale_format = 1.0; - /* Set default line width */ - if( g_PlotLine_Width < 1 ) g_PlotLine_Width = 1; + // Set default line width + if( g_PlotLine_Width < 1 ) + g_PlotLine_Width = 1; + // calcul en unites internes des dimensions des feuilles ( connues en 1/1000 pouce ) PcbSheetSize.x = currentsheet->m_Size.x * U_PCB; PcbSheetSize.y = currentsheet->m_Size.y * U_PCB; - if ( g_ForcePlotPS_On_A4 ) + if( g_ForcePlotPS_On_A4 ) { SheetPS = &g_Sheet_A4; PaperSize.x = g_Sheet_A4.m_Size.x * U_PCB; @@ -74,68 +81,72 @@ int PlotMarge_in_mils = 0; } // calcul de l'offset de trace: - // calcul du cadrage horizontal du mode paysage( val algebr. plus grande = decalage a gauche ) - g_PlotOffset.x = PlotMarge_in_mils * 10; - // cadrage vertical du mode paysage( val algebr. plus grande = decalage vers le haut ) - g_PlotOffset.y = PaperSize.y - (PlotMarge_in_mils*10); + // calcul du cadrage horizontal du mode paysage ( val algebr. plus grande = decalage a gauche ) + g_PlotOffset.x = PlotMarge_in_mils * U_PCB; + // cadrage vertical du mode paysage ( val algebr. plus grande = decalage vers le haut ) + g_PlotOffset.y = PaperSize.y - PlotMarge_in_mils * U_PCB; int BBox[4]; BBox[0] = BBox[1] = PlotMarge_in_mils; BBox[2] = SheetPS->m_Size.x - PlotMarge_in_mils; BBox[3] = SheetPS->m_Size.y - PlotMarge_in_mils; scale_x = scale_y = 1.0; - InitPlotParametresPS( g_PlotOffset, SheetPS, 1.0/m_InternalUnits, 1.0/m_InternalUnits); + InitPlotParametresPS( g_PlotOffset, SheetPS, 1.0 / m_InternalUnits, 1.0 / m_InternalUnits ); SetDefaultLineWidthPS(g_PlotLine_Width); - PrintHeaderPS(dest, wxT("PCBNEW-PS"), FullFileName, BBox); + PrintHeaderPS(dest, wxT("PCBNEW-PS"), FullFileName, 1, BBox, wxLANDSCAPE); - if ( Plot_Sheet_Ref ) + if( Plot_Sheet_Ref ) { - int tmp = g_PlotOrient; g_PlotOrient = 0; - SetPlotScale( 1.0, 1.0); - PlotWorkSheet( PLOT_FORMAT_POST, m_CurrentScreen); + int tmp = g_PlotOrient; + g_PlotOrient = 0; + SetPlotScale( 1.0, 1.0 ); + PlotWorkSheet( PLOT_FORMAT_POST, m_CurrentScreen ); g_PlotOrient = tmp; } - /* calcul des dimensions et centre du PCB */ + // calcul des dimensions et centre du PCB m_Pcb->ComputeBoundaryBox(); BoardSize = m_Pcb->m_BoundaryBox.GetSize(); BoardCenter = m_Pcb->m_BoundaryBox.Centre(); - scale_x = Scale_X; scale_y = Scale_Y; + scale_x = Scale_X; + scale_y = Scale_Y; if( g_PlotScaleOpt == 0 ) // Optimum scale - { + { float Xscale, Yscale; int noprint_size = 2 * PlotMarge_in_mils * U_PCB; - if ( Plot_Sheet_Ref ) noprint_size += 500 * U_PCB; - Xscale = (float) (PaperSize.x - noprint_size ) / BoardSize.x; - Yscale = (float) (PaperSize.y - noprint_size ) / BoardSize.y; - scale_x = scale_y = min( Xscale, Yscale); - } - - BoardCenter.x = (int) (BoardCenter.x * scale_x); - BoardCenter.y = (int) (BoardCenter.y * scale_y); - - /* Calcul du cadrage (echelle != 1 donc recadrage du trace) */ - if ( Center ) - { - g_PlotOffset.x -= PaperSize.x/2 - BoardCenter.x + (PlotMarge_in_mils*10); - g_PlotOffset.y = PaperSize.y/2 + BoardCenter.y; // cadrage horizontal du mode paysage + if( Plot_Sheet_Ref ) + noprint_size += 500 * U_PCB; + Xscale = (float) ( PaperSize.x - noprint_size ) / BoardSize.x; + Yscale = (float) ( PaperSize.y - noprint_size ) / BoardSize.y; + scale_x = scale_y = min( Xscale, Yscale ); } - if ( g_PlotOrient == PLOT_MIROIR ) + BoardCenter.x = (int)(BoardCenter.x * scale_x); + BoardCenter.y = (int)(BoardCenter.y * scale_y); + + // Calcul du cadrage (echelle != 1 donc recadrage du trace) + if( Center ) { - if ( Center ) g_PlotOffset.y = - PaperSize.y/2 + BoardCenter.y; - else g_PlotOffset.y = - PaperSize.y + - (m_Pcb->m_BoundaryBox.GetBottom() + m_Pcb->m_BoundaryBox.GetY()) - + (PlotMarge_in_mils*10) ; + g_PlotOffset.x -= PaperSize.x / 2 - BoardCenter.x + PlotMarge_in_mils * U_PCB; + g_PlotOffset.y = PaperSize.y / 2 + BoardCenter.y; // cadrage horizontal du mode paysage } - InitPlotParametresPS( g_PlotOffset, SheetPS, scale_x, scale_y, g_PlotOrient); + if( g_PlotOrient == PLOT_MIROIR ) + { + if( Center ) + g_PlotOffset.y = - PaperSize.y / 2 + BoardCenter.y; + else + g_PlotOffset.y = - PaperSize.y + m_Pcb->m_BoundaryBox.GetBottom() + + m_Pcb->m_BoundaryBox.GetY() + PlotMarge_in_mils * U_PCB; + } + + InitPlotParametresPS( g_PlotOffset, SheetPS, scale_x, scale_y, g_PlotOrient ); // If plot a negative board: - // Draw a black rectangle (background for plot board in white ) + // Draw a black rectangle (background for plot board in white) // and switch the current color to WHITE - if( g_Plot_PS_Negative) + if( g_Plot_PS_Negative ) { int Rectangle[10]; // Put here the board corners int margin = 500; // Add a 0.1 inch margin around the board @@ -150,59 +161,61 @@ int PlotMarge_in_mils = 0; Rectangle[8] = Rectangle[0]; Rectangle[9] = Rectangle[1]; SetColorMapPS(BLACK); - PlotPolyPS( 5, Rectangle, TRUE); + PlotPolyPS( 5, Rectangle, TRUE ); SetColorMapPS(WHITE); } switch(Layer) - { - case -1: - Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], 0, 1, modetrace); - break; + { + case -1: + Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], 0, 1, modetrace); + break; - case CUIVRE_N : - case LAYER_N_2 : - case LAYER_N_3 : - case LAYER_N_4 : - case LAYER_N_5 : - case LAYER_N_6 : - case LAYER_N_7 : - case LAYER_N_8 : - case LAYER_N_9 : - case LAYER_N_10 : - case LAYER_N_11: - case LAYER_N_12: - case LAYER_N_13 : - case LAYER_N_14 : - case LAYER_N_15 : - case CMP_N : - Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], 0, 1, modetrace); - break; + case CUIVRE_N : + case LAYER_N_2 : + case LAYER_N_3 : + case LAYER_N_4 : + case LAYER_N_5 : + case LAYER_N_6 : + case LAYER_N_7 : + case LAYER_N_8 : + case LAYER_N_9 : + case LAYER_N_10 : + case LAYER_N_11: + case LAYER_N_12: + case LAYER_N_13 : + case LAYER_N_14 : + case LAYER_N_15 : + case CMP_N : + Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], 0, 1, modetrace); + break; - case SILKSCREEN_N_CU : - case SILKSCREEN_N_CMP : - Plot_Serigraphie(PLOT_FORMAT_POST, dest, g_TabOneLayerMask[Layer]); - break; + case SILKSCREEN_N_CU : + case SILKSCREEN_N_CMP : + Plot_Serigraphie(PLOT_FORMAT_POST, dest, g_TabOneLayerMask[Layer]); + break; - case SOLDERMASK_N_CU : - case SOLDERMASK_N_CMP : /* Trace du vernis epargne */ - if (g_DrawViaOnMaskLayer) tracevia = 1; - else tracevia = 0; - Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], g_DesignSettings.m_MaskMargin, - tracevia, modetrace); - break; + case SOLDERMASK_N_CU : + case SOLDERMASK_N_CMP : // Trace du vernis epargne + if( g_DrawViaOnMaskLayer ) + tracevia = 1; + else + tracevia = 0; + Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], g_DesignSettings.m_MaskMargin, + tracevia, modetrace); + break; - case SOLDERPASTE_N_CU : - case SOLDERPASTE_N_CMP : /* Trace du masque de pate de soudure */ - Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], 0, 0, modetrace); - break; + case SOLDERPASTE_N_CU : + case SOLDERPASTE_N_CMP : // Trace du masque de pate de soudure + Plot_Layer_PS(dest, g_TabOneLayerMask[Layer], 0, 0, modetrace); + break; - default: - Plot_Serigraphie(PLOT_FORMAT_POST,dest, g_TabOneLayerMask[Layer]); - break; + default: + Plot_Serigraphie(PLOT_FORMAT_POST, dest, g_TabOneLayerMask[Layer]); + break; } - /* fin */ - CloseFilePS(dest) ; + // fin + CloseFilePS(dest); setlocale(LC_NUMERIC, ""); } @@ -211,7 +224,9 @@ int PlotMarge_in_mils = 0; void WinEDA_BasePcbFrame::Plot_Layer_PS(FILE * File,int masque_layer, int garde, int tracevia, int modetrace) /********************************************************************/ -/* Trace en format POSTSCRIPT d'une couche cuivre ou masque */ + +/* Trace en format POSTSCRIPT d'une couche cuivre ou masque + */ { wxPoint pos, end; wxSize size; @@ -221,225 +236,239 @@ TRACK * pts ; EDA_BaseStruct * PtStruct; wxString msg; - 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 - /* trace des elements type Drawings Pcb : */ + // trace des elements type Drawings Pcb : PtStruct = m_Pcb->m_Drawings; for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { + { switch( PtStruct->m_StructType ) + { + case TYPEDRAWSEGMENT: + PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_POST, + masque_layer); + break; + + case TYPETEXTE: + PlotTextePcb((TEXTE_PCB*) PtStruct,PLOT_FORMAT_POST, + masque_layer); + break; + + case TYPECOTATION: + PlotCotation((COTATION*) PtStruct, PLOT_FORMAT_POST, + masque_layer); + break; + + case TYPEMIRE: + PlotMirePcb((MIREPCB*) PtStruct, PLOT_FORMAT_POST, + masque_layer); + break; + + case TYPEMARQUEUR: + break; + + default: + DisplayError(this, wxT("WinEDA_BasePcbFrame::Plot_Layer_PS() : Unexpected Draw Type")); + break; + } + } + + // Trace des Elements des modules autres que pads + nb_items = 0; + Affiche_1_Parametre(this, 48, wxT("DrawMod"), wxEmptyString, GREEN); + Module = m_Pcb->m_Modules; + for( ; Module != NULL; Module = (MODULE *)Module->Pnext ) + { + PtStruct = Module->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) + { + switch( PtStruct->m_StructType ) { - case TYPEDRAWSEGMENT: - PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_POST, - masque_layer); - break; - - case TYPETEXTE: - PlotTextePcb((TEXTE_PCB*) PtStruct,PLOT_FORMAT_POST, - masque_layer); - break; - - case TYPECOTATION: - PlotCotation((COTATION*) PtStruct, PLOT_FORMAT_POST, - masque_layer); - break; - - case TYPEMIRE: - PlotMirePcb((MIREPCB*) PtStruct, PLOT_FORMAT_POST, - masque_layer); - break; - - case TYPEMARQUEUR: + case TYPEEDGEMODULE: + if( masque_layer & g_TabOneLayerMask[((EDGE_MODULE*)PtStruct)->m_Layer] ) + Plot_1_EdgeModule(PLOT_FORMAT_POST, (EDGE_MODULE*) PtStruct); break; default: - DisplayError(this, wxT("WinEDA_BasePcbFrame::Plot_Layer_PS() : Unexpected Draw Type")); break; } } + } - /* Trace des Elements des modules autres que pads */ - nb_items = 0 ; - Affiche_1_Parametre(this, 48,wxT("DrawMod"),wxEmptyString,GREEN) ; + // Trace des Elements des modules : Pastilles + nb_items = 0; + Affiche_1_Parametre(this, 48, wxT("Pads "), wxEmptyString, GREEN); Module = m_Pcb->m_Modules; - for( ; Module != NULL ;Module = (MODULE *)Module->Pnext ) - { - PtStruct = Module->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) - { - switch( PtStruct->m_StructType ) - { - case TYPEEDGEMODULE: - if( masque_layer & - g_TabOneLayerMask[((EDGE_MODULE*)PtStruct)->m_Layer] ) - Plot_1_EdgeModule(PLOT_FORMAT_POST, (EDGE_MODULE*) PtStruct); - break; - - default: break; - } - } - } - - /* Trace des Elements des modules : Pastilles */ - nb_items = 0 ; - Affiche_1_Parametre(this,48,wxT("Pads "),wxEmptyString,GREEN) ; - 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; - for ( ; PtPad != NULL ; PtPad = (D_PAD*)PtPad->Pnext ) - { - if( (PtPad->m_Masque_Layer & masque_layer) == 0) - continue ; - wxPoint shape_pos = PtPad->ReturnShapePos(); + for( ; PtPad != NULL; PtPad = (D_PAD*)PtPad->Pnext ) + { + if( (PtPad->m_Masque_Layer & masque_layer) == 0 ) + continue; + wxPoint shape_pos = PtPad->ReturnShapePos(); pos = shape_pos; - size.x = PtPad->m_Size.x + (garde * 2) ; - size.y = PtPad->m_Size.y + (garde * 2) ; + size.x = PtPad->m_Size.x + garde * 2; + size.y = PtPad->m_Size.y + garde * 2; - nb_items++ ; + nb_items++; switch (PtPad->m_PadShape) + { + case CIRCLE : + trace_1_pastille_RONDE_POST(pos, size.x, modetrace); + break; + + case OVALE : + trace_1_pastille_OVALE_POST(pos, size, PtPad->m_Orient, modetrace); + break; + + case TRAPEZE : { - case CIRCLE : - trace_1_pastille_RONDE_POST(pos,size.x, modetrace) ; - break ; - - case OVALE : - { - trace_1_pastille_OVALE_POST(pos,size, PtPad->m_Orient, modetrace); - break ; - } - - case TRAPEZE : - { - wxSize delta; - delta = PtPad->m_DeltaSize; - trace_1_pad_TRAPEZE_POST(pos,size,delta, - PtPad->m_Orient, modetrace) ; - break ; - } - - case RECT: - default: - trace_1_pad_rectangulaire_POST(pos,size, PtPad->m_Orient, modetrace) ; - break ; + wxSize delta; + delta = PtPad->m_DeltaSize; + trace_1_pad_TRAPEZE_POST(pos, size, delta, + PtPad->m_Orient, modetrace); + break; } - msg.Printf( wxT("%d"),nb_items) ; - Affiche_1_Parametre(this, 48, wxT("Pads"),msg,GREEN) ; + + case RECT: + default: + trace_1_pad_rectangulaire_POST(pos, size, PtPad->m_Orient, modetrace); + break; } + msg.Printf( wxT("%d"), nb_items ); + Affiche_1_Parametre(this, 48, wxT("Pads"), msg, GREEN); } - /* trace des VIAS : */ - if(tracevia) + } + // trace des VIAS : + if( tracevia ) { - nb_items = 0 ; - Affiche_1_Parametre(this, 56,_("Vias"),wxEmptyString,RED) ; - for( pts = m_Pcb->m_Track;pts != NULL; pts = pts->Next()) + nb_items = 0; + Affiche_1_Parametre(this, 56,_("Vias"), wxEmptyString, RED); + for( pts = m_Pcb->m_Track; pts != NULL; pts = pts->Next() ) { - if( pts->m_StructType != TYPEVIA ) continue; + if( pts->m_StructType != TYPEVIA ) + continue; SEGVIA * Via = (SEGVIA *) pts; - /* vias not plotted if not on selected layer, but if layer - == SOLDERMASK_LAYER_CU or SOLDERMASK_LAYER_CMP, vias are drawn , - if they are on a external copper layer - */ + // vias not plotted if not on selected layer, but if layer + // == SOLDERMASK_LAYER_CU or SOLDERMASK_LAYER_CMP, vias are drawn, + // if they are on a external copper layer int via_mask_layer = Via->ReturnMaskLayer(); - if ( (via_mask_layer & CUIVRE_LAYER ) ) via_mask_layer |= SOLDERMASK_LAYER_CU; - if ( (via_mask_layer & CMP_LAYER ) ) via_mask_layer |= SOLDERMASK_LAYER_CMP; - if( (via_mask_layer & masque_layer) == 0 ) continue; + if( via_mask_layer & CUIVRE_LAYER ) + via_mask_layer |= SOLDERMASK_LAYER_CU; + if ( via_mask_layer & CMP_LAYER ) + via_mask_layer |= SOLDERMASK_LAYER_CMP; + if( (via_mask_layer & masque_layer) == 0 ) + continue; pos = Via->m_Start; - size.x = size.y = Via->m_Width + (garde*2); - trace_1_pastille_RONDE_POST(pos,size.x, modetrace) ; - nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; - Affiche_1_Parametre(this, 56,wxEmptyString,msg,RED) ; + size.x = size.y = Via->m_Width + garde * 2; + trace_1_pastille_RONDE_POST(pos, size.x, modetrace); + nb_items++; + msg.Printf( wxT("%d"), nb_items ); + Affiche_1_Parametre(this, 56, wxEmptyString, msg, RED); } } - /* trace des pistes et zones: */ - nb_items = 0 ; - Affiche_1_Parametre(this, 64,_("Tracks"),wxEmptyString,YELLOW) ; + // trace des pistes et zones: + nb_items = 0; + Affiche_1_Parametre(this, 64, _("Tracks"), wxEmptyString, YELLOW); - for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext) + for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext ) { - if ( pts->m_StructType == TYPEVIA ) continue ; + if( pts->m_StructType == TYPEVIA ) + continue; - if( (g_TabOneLayerMask[pts->m_Layer] & masque_layer) == 0 ) continue; + if( (g_TabOneLayerMask[pts->m_Layer] & masque_layer) == 0 ) + continue; size.x = size.y = pts->m_Width; - pos = pts->m_Start; end = pts->m_End; + pos = pts->m_Start; + end = pts->m_End; - PlotFilledSegmentPS(pos,end, size.x); + PlotFilledSegmentPS(pos, end, size.x); - nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; - Affiche_1_Parametre(this, 64,wxEmptyString,msg,YELLOW) ; + nb_items++; + msg.Printf( wxT("%d"), nb_items ); + Affiche_1_Parametre(this, 64, wxEmptyString, msg, YELLOW); } - nb_items = 0 ; - Affiche_1_Parametre(this, 64, wxT("Zones "),wxEmptyString,YELLOW) ; + nb_items = 0; + Affiche_1_Parametre(this, 64, wxT("Zones "), wxEmptyString, YELLOW); - for( pts = m_Pcb->m_Zone; pts != NULL; pts = (TRACK*) pts->Pnext) + for( pts = m_Pcb->m_Zone; pts != NULL; pts = (TRACK*) pts->Pnext ) { - if( (g_TabOneLayerMask[pts->m_Layer] & masque_layer) == 0 ) continue; + if( (g_TabOneLayerMask[pts->m_Layer] & masque_layer) == 0 ) + continue; size.x = size.y = pts->m_Width; - pos = pts->m_Start; end = pts->m_End; - PlotFilledSegmentPS(pos,end, size.x); - nb_items++ ; msg.Printf( wxT("%d"),nb_items) ; - Affiche_1_Parametre(this, 64,wxEmptyString,msg,YELLOW) ; + pos = pts->m_Start; + end = pts->m_End; + PlotFilledSegmentPS(pos, end, size.x); + nb_items++; + msg.Printf( wxT("%d"), nb_items ); + Affiche_1_Parametre(this, 64, wxEmptyString, msg, YELLOW); } - /* Trace des trous de percage */ + // Trace des trous de percage if( modetrace == FILLED ) - { PrintDrillMark(m_Pcb); - } } /*************************************/ static void PrintDrillMark(BOARD * Pcb) /*************************************/ + /* Draw a drill mark for pads and vias. - Must be called after all drawings, because it redraw the drill mark - on a pad or via -*/ + * Must be called after all drawings, because it + * redraw the drill mark on a pad or via + */ { -#define SMALL_DRILL 150 +const int SMALL_DRILL = 150; wxPoint pos; wxSize diam; MODULE * Module; D_PAD * PtPad; TRACK * pts ; - if (g_DrillShapeOpt == 0 ) return; + if( g_DrillShapeOpt == 0 ) + return; - if ( g_Plot_PS_Negative ) fprintf(dest," 0 setgray\n"); - else fprintf(dest," 1 setgray\n"); + if( g_Plot_PS_Negative ) + fprintf(dest, " 0 setgray\n"); + else + fprintf(dest, " 1 setgray\n"); diam.x = diam.y = (g_DrillShapeOpt == DRILL_MARK) ? SMALL_DRILL : g_DesignSettings.m_ViaDrill; - for( pts = Pcb->m_Track;pts != NULL; pts = (TRACK*)pts->Pnext) + for( pts = Pcb->m_Track; pts != NULL; pts = (TRACK*)pts->Pnext ) { - if( pts->m_StructType != TYPEVIA ) continue; + if( pts->m_StructType != TYPEVIA ) + continue; pos = pts->m_Start; - if (g_DrillShapeOpt == DRILL_MARK) diam.x = diam.y = SMALL_DRILL; + if( g_DrillShapeOpt == DRILL_MARK ) + diam.x = diam.y = SMALL_DRILL; else { - if (pts->m_Drill < 0) + if( pts->m_Drill < 0 ) diam.x = diam.y = g_DesignSettings.m_ViaDrill; else diam.x = diam.y = pts->m_Drill; } - trace_1_pastille_RONDE_POST(pos,diam.x, FILLED); + trace_1_pastille_RONDE_POST(pos, diam.x, FILLED); } Module = Pcb->m_Modules; for( ; Module != NULL; Module = (MODULE *)Module->Pnext ) { PtPad = (D_PAD*) Module->m_Pads; - for ( ; PtPad != NULL ; PtPad = (D_PAD*)PtPad->Pnext ) + for ( ; PtPad != NULL; PtPad = (D_PAD*)PtPad->Pnext ) { - if( PtPad->m_Drill.x == 0 ) continue; + if( PtPad->m_Drill.x == 0 ) + continue; - /* calcul de la position des trous, selon echelle */ + // calcul de la position des trous, selon echelle pos = PtPad->m_Pos; diam.x = diam.y = (g_DrillShapeOpt == DRILL_MARK) ? SMALL_DRILL : PtPad->m_Drill.x; @@ -447,33 +476,39 @@ TRACK * pts ; } } - fprintf(dest," 0 setgray\n"); + fprintf(dest, " 0 setgray\n"); } + /***********************************************************************************/ void trace_1_pastille_OVALE_POST(wxPoint pos, wxSize size, int orient, int modetrace) /************************************************************************************/ + /* Trace 1 pastille OVALE en position pos_X,Y: - dimensions dx,dy, - orientation orient - La forme est tracee comme un segment -*/ + * dimensions dx,dy, + * orientation orient + * La forme est tracee comme un segment + */ { int x0, y0, x1, y1, delta; int w, rayon; - /* la pastille est ramenee a une pastille ovale avec dy > dx */ - if(size.x > size.y ) - { - EXCHG(size.x,size.y); orient += 900; - if ( orient >= 3600 ) orient -= 3600; - } + // la pastille est ramenee a une pastille ovale avec dy > dx + if( size.x > size.y ) + { + EXCHG(size.x, size.y); + orient += 900; + if( orient >= 3600 ) + orient -= 3600; + } delta = size.y - size.x; - x0 = 0; y0 = -delta / 2; - x1 = 0; y1 = delta / 2; - RotatePoint(&x0,&y0, orient); - RotatePoint(&x1,&y1, orient); + x0 = 0; + y0 = -delta / 2; + x1 = 0; + y1 = delta / 2; + RotatePoint(&x0, &y0, orient); + RotatePoint(&x1, &y1, orient); if( modetrace == FILLED ) { @@ -484,24 +519,30 @@ int w, rayon; { w = g_PlotLine_Width; rayon = (size.x - w) / 2; - if(rayon < 1 ) rayon = 1 ; - if ( rayon < w ) w = rayon; - PlotArcPS( wxPoint(pos.x + x1,pos.y + y1), -orient, -orient + 1800, rayon, w); - PlotArcPS( wxPoint(pos.x + x0,pos.y + y0), -orient + 1800, -orient ,rayon, w); + if( rayon < 1 ) + rayon = 1; + if( rayon < w ) + w = rayon; + PlotArcPS( wxPoint(pos.x + x1, pos.y + y1), -orient, -orient + 1800, rayon, w ); + PlotArcPS( wxPoint(pos.x + x0, pos.y + y0), -orient + 1800, -orient, rayon, w ); - x0 = -rayon; y0 = -delta / 2; - x1 = -rayon; y1 = delta / 2; + x0 = -rayon; + y0 = -delta / 2; + x1 = -rayon; + y1 = delta / 2; RotatePoint(&x0, &y0, orient); RotatePoint(&x1, &y1, orient); - PlotFilledSegmentPS( wxPoint(pos.x+x0, pos.y+y0) , - wxPoint(pos.x+x1, pos.y+y1), w); + PlotFilledSegmentPS( wxPoint(pos.x + x0, pos.y + y0), + wxPoint(pos.x + x1, pos.y + y1), w ); - x0 = rayon; y0 = -delta / 2; - x1 = rayon; y1 = delta / 2; + x0 = rayon; + y0 = -delta / 2; + x1 = rayon; + y1 = delta / 2; RotatePoint(&x0, &y0, orient); RotatePoint(&x1, &y1, orient); - PlotFilledSegmentPS( wxPoint(pos.x+x0, pos.y+y0), - wxPoint(pos.x+x1, pos.y+y1), w); + PlotFilledSegmentPS( wxPoint(pos.x + x0, pos.y + y0), + wxPoint(pos.x + x1, pos.y + y1), w ); } } @@ -509,7 +550,9 @@ int w, rayon; /*******************************************************************************/ void trace_1_pastille_RONDE_POST(wxPoint centre, int diametre, int modetrace) /*******************************************************************************/ -/* Trace 1 pastille RONDE (via,pad rond) en position pos_X,Y */ + +/* Trace 1 pastille RONDE (via,pad rond) en position pos_X,Y + */ { int rayon, w; wxSize diam(diametre, diametre); @@ -518,60 +561,70 @@ wxSize diam(diametre, diametre); UserToDeviceSize(diam); if( modetrace == FILLED ) - { - fprintf(dest,"%d setlinewidth\n", g_PlotLine_Width); - rayon = (diam.x) / 2; - if(rayon < 1 ) rayon = 1 ; - fprintf(dest,"newpath %d %d %d 0 360 arc fill stroke\n", + { + fprintf(dest, "%d setlinewidth\n", g_PlotLine_Width); + rayon = diam.x / 2; + if( rayon < 1 ) + rayon = 1; + fprintf(dest, "newpath %d %d %d 0 360 arc fill stroke\n", centre.x, centre.y, rayon); - } - + } else - { + { w = g_PlotLine_Width; rayon = (diam.x - w) / 2; - if(rayon < 1 ) rayon = 1 ; - if ( rayon < w ) w = rayon; - fprintf(dest,"%d setlinewidth\n", w); - fprintf(dest,"newpath %d %d %d 0 360 arc stroke\n", + if( rayon < 1 ) + rayon = 1; + if( rayon < w ) + w = rayon; + fprintf(dest, "%d setlinewidth\n", w); + fprintf(dest, "newpath %d %d %d 0 360 arc stroke\n", centre.x, centre.y, rayon); - } + } } + /**************************************************************************/ void trace_1_pad_rectangulaire_POST(wxPoint centre, wxSize size, int orient, int modetrace) /**************************************************************************/ + /* - Trace 1 pad rectangulaire d'orientation quelconque - donne par son centre, ses dimensions, - et son orientation orient -*/ + * Trace 1 pad rectangulaire d'orientation quelconque + * donne par son centre, ses dimensions, + * et son orientation orient + */ { int x0, y0, x1, y1, w; if( modetrace == FILLED ) - { - x0 = centre.x - size.x/2; x1 = centre.x + size.x/2; - y0 = y1 = centre.y; w = size.y; + { + x0 = centre.x - size.x / 2; + x1 = centre.x + size.x / 2; + y0 = y1 = centre.y; + w = size.y; - RotatePoint(&x0,&y0, centre.x, centre.y, orient); - RotatePoint(&x1,&y1, centre.x, centre.y, orient); + RotatePoint(&x0, &y0, centre.x, centre.y, orient); + RotatePoint(&x1, &y1, centre.x, centre.y, orient); - fprintf(dest,"0 setlinewidth 0 setlinecap 0 setlinejoin\n"); - ForcePenReinit(); // Force init line width for PlotFilledSegmentPS + fprintf(dest, "0 setlinewidth 0 setlinecap 0 setlinejoin\n"); + ForcePenReinit(); // Force init line width for PlotFilledSegmentPS PlotFilledSegmentPS(wxPoint(x0, y0), wxPoint(x1, y1), w); - ForcePenReinit(); + ForcePenReinit(); SetCurrentLineWidthPS(0); // Force init line width to default - fprintf(dest,"1 setlinecap 1 setlinejoin\n"); - } - - else { + fprintf(dest, "1 setlinecap 1 setlinejoin\n"); + } + else + { w = g_PlotLine_Width; - size.x -= w; if ( size.x < 1 ) size.x = 1; - size.y -= w; if ( size.y < 1 ) size.y = 1; + size.x -= w; + if( size.x < 1 ) + size.x = 1; + size.y -= w; + if( size.y < 1 ) + size.y = 1; trace_1_contour_POST(centre, size, wxSize(0, 0), w, orient); - } + } } @@ -579,14 +632,15 @@ int x0, y0, x1, y1, w; void trace_1_contour_POST(wxPoint centre, wxSize size, wxSize delta, int dim_trait, int orient) /**************************************************************/ + /* - Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque - donne par son centre centre, - ses dimensions size, - ses variations delta - epaisseur de trait dim_trait - et son orientation orient (en 0.1 degres) -*/ + * Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque + * donne par son centre centre, + * ses dimensions size, + * ses variations delta + * epaisseur de trait dim_trait + * et son orientation orient (en 0.1 degres) + */ { int ii; int dx, dy, lpen; @@ -595,8 +649,10 @@ wxPoint coord[4]; lpen = dim_trait; - dx = size.x / 2; dy = size.y / 2 ; - ddx = delta.x >> 1; ddy = delta.y >> 1 ; /* demi dim dx et dy */ + dx = size.x / 2; + dy = size.y / 2; + ddx = delta.x >> 1; + ddy = delta.y >> 1; // demi dim dx et dy coord[0].x = centre.x - dx - ddy; coord[0].y = centre.y + dy + ddx; @@ -610,16 +666,15 @@ wxPoint coord[4]; coord[3].x = centre.x + dx + ddy; coord[3].y = centre.y + dy - ddx; - for (ii = 0; ii < 4; ii++) - { + for( ii = 0; ii < 4; ii++ ) + { RotatePoint(&coord[ii], centre, orient); - } + } - - PlotFilledSegmentPS( coord[0], coord[1], lpen); - PlotFilledSegmentPS( coord[1], coord[2], lpen); - PlotFilledSegmentPS( coord[2], coord[3], lpen); - PlotFilledSegmentPS( coord[3], coord[0], lpen); + PlotFilledSegmentPS( coord[0], coord[1], lpen ); + PlotFilledSegmentPS( coord[1], coord[2], lpen ); + PlotFilledSegmentPS( coord[2], coord[3], lpen ); + PlotFilledSegmentPS( coord[3], coord[0], lpen ); } @@ -627,90 +682,99 @@ wxPoint coord[4]; void trace_1_pad_TRAPEZE_POST(wxPoint centre, wxSize size, wxSize delta, int orient,int modetrace) /*******************************************************************/ + /* - Trace 1 pad trapezoidal donne par : - son centre centre - ses dimensions size - les variations delta ( 1 des deux au moins doit etre nulle) - son orientation orient en 0.1 degres - le mode de trace (FILLED, SKETCH, FILAIRE) - - Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY - = 0. - - les notation des sommets sont ( vis a vis de la table tracante ) - -" 0 ------------- 3 " -" . . " -" . O . " -" . . " -" 1 ---- 2 " - - - exemple de Disposition pour deltaY > 0, deltaX = 0 -" 1 ---- 2 " -" . . " -" . O . " -" . . " -" 0 ------------- 3 " - - - exemple de Disposition pour deltaY = 0, deltaX > 0 -" 0 " -" . . " -" . . " -" . 3 " -" . . " -" . O . " -" . . " -" . 2 " -" . . " -" . . " -" 1 " -*/ + * Trace 1 pad trapezoidal donne par : + * son centre centre + * ses dimensions size + * les variations delta ( 1 des deux au moins doit etre nulle) + * son orientation orient en 0.1 degres + * le mode de trace (FILLED, SKETCH, FILAIRE) + * + * Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY + * = 0. + * + * les notation des sommets sont ( vis a vis de la table tracante ) + * + * " 0 ------------- 3 " + * " . . " + * " . O . " + * " . . " + * " 1 ---- 2 " + * + * + * exemple de Disposition pour deltaY > 0, deltaX = 0 + * " 1 ---- 2 " + * " . . " + * " . O . " + * " . . " + * " 0 ------------- 3 " + * + * + * exemple de Disposition pour deltaY = 0, deltaX > 0 + * " 0 " + * " . . " + * " . . " + * " . 3 " + * " . . " + * " . O . " + * " . . " + * " . 2 " + * " . . " + * " . . " + * " 1 " + */ { int ii; -int dx,dy; -wxPoint polygone[4]; /* coord des sommets / centre du pad */ -int ddx, ddy ; -int l_pen; /* diam spot (plume) */ +int dx, dy; +wxPoint polygone[4]; // coord des sommets / centre du pad +int ddx, ddy; +int l_pen; // diam spot (plume) l_pen = 1; - if( (modetrace == FILAIRE) || ( Plot_Mode == FILAIRE ) ) + if( modetrace == FILAIRE || Plot_Mode == FILAIRE ) { - wxSize lsize(g_PlotLine_Width,g_PlotLine_Width); + wxSize lsize(g_PlotLine_Width, g_PlotLine_Width); UserToDeviceSize(lsize); l_pen = lsize.x; } - dx = size.x / 2; dy = size.y / 2 ; - ddx = delta.x / 2; ddy = delta.y / 2 ; + dx = size.x / 2; + dy = size.y / 2; + ddx = delta.x / 2; + ddy = delta.y / 2; - polygone[0].x = - dx - ddy; polygone[0].y = + dy + ddx; - polygone[1].x = - dx + ddy; polygone[1].y = - dy - ddx; - polygone[2].x = + dx - ddy; polygone[2].y = - dy + ddx; - polygone[3].x = + dx + ddy; polygone[3].y = + dy - ddx; + polygone[0].x = - dx - ddy; + polygone[0].y = + dy + ddx; + polygone[1].x = - dx + ddy; + polygone[1].y = - dy - ddx; + polygone[2].x = + dx - ddy; + polygone[2].y = - dy + ddx; + polygone[3].x = + dx + ddy; + polygone[3].y = + dy - ddx; - for (ii = 0; ii < 4; ii++) - { + for( ii = 0; ii < 4; ii++ ) + { RotatePoint(&polygone[ii].x, &polygone[ii].y, orient); - polygone[ii].x += centre.x; polygone[ii].y += centre.y; - } + polygone[ii].x += centre.x; + polygone[ii].y += centre.y; + } - SetCurrentLineWidthPS( l_pen); + SetCurrentLineWidthPS( l_pen ); UserToDeviceCoordinate(polygone[0]); - fprintf(dest,"newpath %d %d moveto\n", polygone[0].x, polygone[0].y); + fprintf(dest, "newpath %d %d moveto\n", polygone[0].x, polygone[0].y); - for (ii = 1; ii < 4; ii++) - { + for( ii = 1; ii < 4; ii++ ) + { UserToDeviceCoordinate(polygone[ii]); - fprintf(dest,"%d %d lineto\n", polygone[ii].x, polygone[ii].y); - } + fprintf(dest, "%d %d lineto\n", polygone[ii].x, polygone[ii].y); + } - fprintf(dest,"%d %d lineto ", polygone[0].x, polygone[0].y); + fprintf(dest, "%d %d lineto ", polygone[0].x, polygone[0].y); - if(modetrace == FILLED ) fprintf(dest, "fill ");; - fprintf(dest, "stroke\n");; + if( modetrace == FILLED ) + fprintf(dest, "fill "); + fprintf(dest, "stroke\n"); }