Loading CHANGELOG.txt +8 −1 Original line number Diff line number Diff line Loading @@ -5,11 +5,18 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. 2008-Dec-22 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> ================================================================================ ++All Cleaning code to draw/plot texts: Now only one function is used to draw and plot texts in pcbnew in all formats Italics texts are allowed in pcbnew (work in progress) 2008-Dec-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> ================================================================================ ++All Cleaning code to draw/plot texts (work in progress): Now only one function is used to draw and plot texts Now only one function is used to draw and plot texts (not for pcbnew) (easier to maintain and ensure texts have the same size in ploting and drawing) In eeschema, italic and bold texts allowed (in pcbenew, texts thickness is already adjustable) Loading common/CMakeLists.txt +2 −1 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ set(COMMON_SRCS common_plot_functions.cpp common_plotHPGL_functions.cpp common_plotPS_functions.cpp common_plotGERBER_functions.cpp confirm.cpp copy_to_clipboard.cpp dcsvg.cpp Loading common/common_plotHPGL_functions.cpp +26 −33 Original line number Diff line number Diff line Loading @@ -14,13 +14,6 @@ /* parametre HPGL pour trace de cercle: */ #define CHORD_ANGLE 10 // Variables partagees avec Common plot Postscript Routines extern wxPoint LastPenPosition; extern wxPoint PlotOffset; extern FILE* PlotOutputFile; extern double XScale, YScale; extern int g_DefaultPenWidth, g_CurrentPenWidth; extern int PlotOrientOptions, etat_plume; //Variables locales void Move_Plume_HPGL( wxPoint pos, int plume ); Loading @@ -28,20 +21,20 @@ void Plume_HPGL( int plume ); /***********************************************************************************/ void InitPlotParametresHPGL( wxPoint offset, double xscale, double yscale, int orient ) void InitPlotParametresHPGL( wxPoint offset, double aXScale, double aYScale, 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) * g_Plot_XScale,g_Plot_YScale = coordinate scale (scale coefficient for coordinates) * device_g_Plot_XScale,device_g_Plot_YScale = device coordinate scale (i.e scale used by plot device) */ { PlotOffset = offset; XScale = xscale; YScale = yscale; g_DefaultPenWidth = 6; /* epaisseur du trait standard en 1/1000 pouce */ PlotOrientOptions = orient; g_CurrentPenWidth = -1; g_Plot_PlotOffset = offset; g_Plot_XScale = aXScale; g_Plot_YScale = aYScale; g_Plot_DefaultPenWidth = 6; /* epaisseur du trait standard en 1/1000 pouce */ g_Plot_PlotOrientOptions = orient; g_Plot_CurrentPenWidth = -1; } Loading @@ -51,8 +44,8 @@ bool PrintHeaderHPGL( FILE* plot_file, int pen_speed, int pen_num ) { char Line[256]; PlotOutputFile = plot_file; etat_plume = 'U'; g_Plot_PlotOutputFile = plot_file; g_Plot_PenState = 'U'; sprintf( Line, "IN;VS%d;PU;PA;SP%d;\n", pen_speed, pen_num ); fputs( Line, plot_file ); return TRUE; Loading @@ -79,7 +72,7 @@ void PlotRectHPGL( wxPoint p1, wxPoint p2, bool fill, int width ) Plume_HPGL( 'U' ); sprintf( Line, "PA %d,%d;EA %d,%d;\n", p1.x, p1.y, p2.x, p2.y ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); Plume_HPGL( 'U' ); return; } Loading @@ -93,14 +86,14 @@ void PlotCircleHPGL( wxPoint centre, int diameter, bool fill, int width ) char Line[256]; UserToDeviceCoordinate( centre ); rayon = (int) (diameter / 2 * XScale); rayon = (int) (diameter / 2 * g_Plot_XScale); if( rayon < 0 ) rayon = 0; Plume_HPGL( 'U' ); sprintf( Line, "PA %d,%d;CI %d,%d;\n", centre.x, centre.y, rayon, CHORD_ANGLE ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); Plume_HPGL( 'U' ); return; } Loading Loading @@ -129,7 +122,7 @@ void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, bool fil cpos = centre; UserToDeviceCoordinate( cpos ); if( PlotOrientOptions == PLOT_MIROIR ) if( g_Plot_PlotOrientOptions == PLOT_MIROIR ) { EndAngle = -EndAngle; StAngle = -StAngle; Loading @@ -143,11 +136,11 @@ void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, bool fil Plume_HPGL( 'U' ); sprintf( Line, "PU;PA %d,%d;PD;AA %d,%d, ", cmap.x, cmap.y, cpos.x, cpos.y ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, "%f", -angle ); to_point( Line ); // Transforme , et . du separateur fputs( Line, PlotOutputFile ); sprintf( Line, ", %d", CHORD_ANGLE ); fputs( Line, PlotOutputFile ); sprintf( Line, ";PU;\n" ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, ", %d", CHORD_ANGLE ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, ";PU;\n" ); fputs( Line, g_Plot_PlotOutputFile ); Plume_HPGL( 'U' ); } Loading Loading @@ -205,7 +198,7 @@ void Move_Plume_HPGL( wxPoint pos, int plume ) Plume_HPGL( plume ); 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, g_Plot_PlotOutputFile ); } Loading @@ -218,14 +211,14 @@ void Plume_HPGL( int plume ) { if( plume == 'U' ) { if( etat_plume != 'U' ) fputs( "PU;", PlotOutputFile ); etat_plume = 'U'; if( g_Plot_PenState != 'U' ) fputs( "PU;", g_Plot_PlotOutputFile ); g_Plot_PenState = 'U'; } else { if( etat_plume != 'D' ) fputs( "PD;", PlotOutputFile ); etat_plume = 'D'; if( g_Plot_PenState != 'D' ) fputs( "PD;", g_Plot_PlotOutputFile ); g_Plot_PenState = 'D'; } } common/common_plotPS_functions.cpp +47 −58 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ /******************************************/ #include "fctsys.h" #include "gr_basic.h" #include "trigo.h" #include "wxstruct.h" #include "base_struct.h" Loading @@ -11,36 +10,26 @@ #include "plot_common.h" #include "macros.h" #include "wx/defs.h" // Variables partagees avec Common plot Postscript Routines extern wxPoint LastPenPosition; extern wxPoint PlotOffset; extern FILE* PlotOutputFile; extern double XScale, YScale; extern int g_DefaultPenWidth, g_CurrentPenWidth; extern int PlotOrientOptions, etat_plume; // Locales static Ki_PageDescr* SheetPS; /*************************************************************************************/ void InitPlotParametresPS( wxPoint offset, Ki_PageDescr* sheet, double xscale, double yscale, int orient ) double aXScale, double aYScale, 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) * g_Plot_XScale,g_Plot_YScale = coordinate scale (scale coefficient for coordinates) * device_g_Plot_XScale,device_g_Plot_YScale = device coordinate scale (i.e scale used by plot device) */ { PlotOrientOptions = orient; PlotOffset = offset; g_Plot_PlotOrientOptions = orient; g_Plot_PlotOffset = offset; SheetPS = sheet; XScale = xscale; YScale = yscale; g_CurrentPenWidth = -1; g_Plot_XScale = aXScale; g_Plot_YScale = aYScale; g_Plot_CurrentPenWidth = -1; } Loading @@ -51,8 +40,8 @@ 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_CurrentPenWidth = -1; g_Plot_DefaultPenWidth = width; // epaisseur du trait standard en 1/1000 pouce g_Plot_CurrentPenWidth = -1; } Loading @@ -68,12 +57,12 @@ void SetCurrentLineWidthPS( int width ) if( width > 0 ) pen_width = width; else pen_width = g_DefaultPenWidth; pen_width = g_Plot_DefaultPenWidth; if( pen_width != g_CurrentPenWidth ) fprintf( PlotOutputFile, "%d setlinewidth\n", (int) (XScale * pen_width) ); if( pen_width != g_Plot_CurrentPenWidth ) fprintf( g_Plot_PlotOutputFile, "%d setlinewidth\n", (int) (g_Plot_XScale * pen_width) ); g_CurrentPenWidth = pen_width; g_Plot_CurrentPenWidth = pen_width; } Loading @@ -95,7 +84,7 @@ void SetColorMapPS( int color ) (float) ColorRefs[color].m_Green / 255, (float) ColorRefs[color].m_Blue / 255 ); to_point( Line ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); } Loading @@ -110,7 +99,7 @@ void PlotFilledSegmentPS( wxPoint start, wxPoint end, int width ) UserToDeviceCoordinate( end ); SetCurrentLineWidthPS( width ); fprintf( PlotOutputFile, "%d %d %d %d line\n", start.x, start.y, end.x, end.y ); fprintf( g_Plot_PlotOutputFile, "%d %d %d %d line\n", start.x, start.y, end.x, end.y ); } /***************************************************************/ Loading @@ -121,7 +110,7 @@ void PlotRectPS( wxPoint p1, wxPoint p2, bool fill, int width ) UserToDeviceCoordinate( p2 ); SetCurrentLineWidthPS( width ); fprintf( PlotOutputFile, "%d %d %d %d rect%d\n", p1.x, p1.y, fprintf( g_Plot_PlotOutputFile, "%d %d %d %d rect%d\n", p1.x, p1.y, p2.x-p1.x, p2.y-p1.y, fill ); } Loading @@ -133,14 +122,14 @@ void PlotCirclePS( wxPoint pos, int diametre, bool fill, int width ) char Line[256]; UserToDeviceCoordinate( pos ); rayon = (int) (XScale * diametre / 2); rayon = (int) (g_Plot_XScale * diametre / 2); if( rayon < 0 ) rayon = 0; SetCurrentLineWidthPS( width ); sprintf(Line, "%d %d %d cir%d\n", pos.x, pos.y, rayon, fill); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); } Loading @@ -162,18 +151,18 @@ void PlotArcPS( wxPoint centre, int StAngle, int EndAngle, int rayon, bool fill, // Calcul des coord du point de depart : UserToDeviceCoordinate( centre ); if( PlotOrientOptions == PLOT_MIROIR ) if( g_Plot_PlotOrientOptions == PLOT_MIROIR ) sprintf( Line, "%d %d %d %f %f arc%d\n", centre.x, centre.y, (int) (rayon * XScale), (float) StAngle / 10, (float) EndAngle / 10, (int) (rayon * g_Plot_XScale), (float) StAngle / 10, (float) EndAngle / 10, fill); else sprintf( Line, "%d %d %d %f %f arc%d\n", centre.x, centre.y, (int) (rayon * XScale), -(float) EndAngle / 10, -(float) StAngle / 10, (int) (rayon * g_Plot_XScale), -(float) EndAngle / 10, -(float) StAngle / 10, fill); // Undo internationalization printf (float x.y printed x,y) to_point( Line ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); } Loading @@ -199,18 +188,18 @@ void PlotPolyPS( int nb_segm, int* coord, bool fill, int width ) pos.x = coord[0]; pos.y = coord[1]; UserToDeviceCoordinate( pos ); fprintf( PlotOutputFile, "newpath %d %d moveto\n", pos.x, pos.y ); fprintf( g_Plot_PlotOutputFile, "newpath %d %d moveto\n", pos.x, pos.y ); for( ii = 1; ii < nb_segm; ii++ ) { pos.x = coord[2 * ii]; pos.y = coord[2 * ii + 1]; UserToDeviceCoordinate( pos ); fprintf( PlotOutputFile, "%d %d lineto\n", pos.x, pos.y ); fprintf( g_Plot_PlotOutputFile, "%d %d lineto\n", pos.x, pos.y ); } // Fermeture du polygone fprintf(PlotOutputFile, "poly%d\n", fill); fprintf(g_Plot_PlotOutputFile, "poly%d\n", fill); } Loading @@ -229,10 +218,10 @@ void LineTo_PS( wxPoint pos, int plume ) { char Line[256]; sprintf( Line, "%d %d %d %d line\n", LastPenPosition.x, LastPenPosition.y, pos.x, pos.y ); fputs( Line, PlotOutputFile ); g_Plot_LastPenPosition.x, g_Plot_LastPenPosition.y, pos.x, pos.y ); fputs( Line, g_Plot_PlotOutputFile ); } LastPenPosition = pos; g_Plot_LastPenPosition = pos; } Loading Loading @@ -294,26 +283,26 @@ void PrintHeaderPS( FILE* file, const wxString& Creator, int ii; time_t time1970 = time( NULL ); PlotOutputFile = file; g_Plot_PlotOutputFile = file; fputs( "%!PS-Adobe-3.0\n", PlotOutputFile ); // Print header fputs( "%!PS-Adobe-3.0\n", g_Plot_PlotOutputFile ); // Print header sprintf( Line, "%%%%Creator: %s\n", CONV_TO_UTF8( Creator ) ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_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 ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, "%%%%Title: %s\n", CONV_TO_UTF8( FileName ) ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, "%%%%Pages: %d\n", PageCount ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, "%%%%PageOrder: Ascend\n" ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); // Print boundary box en 1/72 pouce, box is in mils const double CONV_SCALE = MIL_TO_INCH * 72; Loading @@ -325,7 +314,7 @@ void PrintHeaderPS( FILE* file, const wxString& Creator, (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 ); fputs( Line, g_Plot_PlotOutputFile ); // 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, Loading @@ -349,17 +338,17 @@ void PrintHeaderPS( FILE* file, const wxString& Creator, 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 ); fputs( Line, g_Plot_PlotOutputFile ); if( PaperOrientation == wxPORTRAIT ) sprintf( Line, "%%%%Orientation: Portrait\n" ); else sprintf( Line, "%%%%Orientation: Landscape\n" ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, "%%%%EndComments\n" ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); // Now specify various other details. Loading @@ -368,11 +357,11 @@ void PrintHeaderPS( FILE* file, const wxString& Creator, // contents of the postscript file comply with the details specified // within the Document Structuring Convention. sprintf( Line, "%%%%Page: 1 1\n" ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); for( ii = 0; PSMacro[ii] != NULL; ii++ ) { fputs( PSMacro[ii], PlotOutputFile ); fputs( PSMacro[ii], g_Plot_PlotOutputFile ); } if( PaperOrientation == wxLANDSCAPE ) Loading @@ -386,15 +375,15 @@ void PrintHeaderPS( FILE* file, const wxString& Creator, // compensation internationalisation printf (float x.y gnr x,y) to_point( Line ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, "%f %f scale\t\t%% Move to User coordinates\n", XScale, YScale ); g_Plot_XScale, g_Plot_YScale ); to_point( Line ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); // Set default line width ( g_DefaultPenWidth is in user units ) fprintf( PlotOutputFile, "%d setlinewidth\n", g_DefaultPenWidth ); // Set default line width ( g_Plot_DefaultPenWidth is in user units ) fprintf( g_Plot_PlotOutputFile, "%d setlinewidth\n", g_Plot_DefaultPenWidth ); } Loading common/common_plot_functions.cpp +24 −43 Original line number Diff line number Diff line Loading @@ -14,68 +14,46 @@ // Variables partagees avec Common plot Postscript et HPLG Routines wxPoint LastPenPosition; wxPoint PlotOffset; FILE* PlotOutputFile; double XScale, YScale; int g_DefaultPenWidth; int g_CurrentPenWidth = -1; int PlotOrientOptions, etat_plume; // Locales static Ki_PageDescr* SheetPS; wxPoint g_Plot_LastPenPosition; wxPoint g_Plot_PlotOffset; FILE* g_Plot_PlotOutputFile; double g_Plot_XScale, g_Plot_YScale; int g_Plot_DefaultPenWidth; int g_Plot_CurrentPenWidth = -1; int g_Plot_PlotOrientOptions, g_Plot_PenState; /*************************/ void ForcePenReinit() /*************************/ /* set the flag g_CurrentPenWidth to -1 in order to force a pen width redefinition /* set the flag g_Plot_CurrentPenWidth to -1 in order to force a pen width redefinition * for the next draw command */ { g_CurrentPenWidth = -1; g_Plot_CurrentPenWidth = -1; } /**********************************************/ void SetPlotScale( double xscale, double yscale ) void SetPlotScale( double aXScale, double aYScale ) /**********************************************/ /* Set the plot scale for the current plotting) */ { XScale = xscale; YScale = yscale; g_Plot_XScale = aXScale; g_Plot_YScale = aYScale; } /*********************************/ void SetPlotOffset( wxPoint offset ) void Setg_Plot_PlotOffset( wxPoint offset ) /*********************************/ /* Set the plot offset for the current plotting) */ { PlotOffset = offset; } /***************************************************************************/ void InitPlotParametresGERBER( wxPoint offset, double xscale, double yscale ) /***************************************************************************/ /* Set the plot offset for the current plotting * xscale,yscale = coordinate scale (scale coefficient for coordinates) */ { PlotOrientOptions = 0; PlotOffset = offset; SheetPS = NULL; XScale = xscale; YScale = yscale; g_DefaultPenWidth = 120; /* epaisseur du trait standard en 1/1000 pouce */ g_CurrentPenWidth = -1; g_Plot_PlotOffset = offset; } Loading Loading @@ -114,6 +92,9 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ) break; case PLOT_FORMAT_GERBER: FctPlume = LineTo_GERBER; break; default: return; } Loading Loading @@ -507,17 +488,17 @@ void UserToDeviceCoordinate( wxPoint& pos ) /* modifie les coord pos.x et pos.y pour le trace selon l'orientation, * l'echelle, les offsets de trace */ { pos.x = (int) (pos.x * XScale); pos.y = (int) (pos.y * YScale); pos.x = (int) (pos.x * g_Plot_XScale); pos.y = (int) (pos.y * g_Plot_YScale); switch( PlotOrientOptions ) /* Calcul du cadrage */ switch( g_Plot_PlotOrientOptions ) /* Calcul du cadrage */ { default: pos.x -= PlotOffset.x; pos.y = PlotOffset.y - pos.y; pos.x -= g_Plot_PlotOffset.x; pos.y = g_Plot_PlotOffset.y - pos.y; break; case PLOT_MIROIR: pos.x -= PlotOffset.x; pos.y = -PlotOffset.y + pos.y; pos.x -= g_Plot_PlotOffset.x; pos.y = -g_Plot_PlotOffset.y + pos.y; break; } } Loading @@ -528,6 +509,6 @@ void UserToDeviceSize( wxSize& size ) /************************************/ /* modifie les dimension size.x et size.y pour le trace selon l'echelle */ { size.x = (int) (size.x * XScale); size.y = (int) (size.y * YScale); size.x = (int) (size.x * g_Plot_XScale); size.y = (int) (size.y * g_Plot_YScale); } Loading
CHANGELOG.txt +8 −1 Original line number Diff line number Diff line Loading @@ -5,11 +5,18 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. 2008-Dec-22 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> ================================================================================ ++All Cleaning code to draw/plot texts: Now only one function is used to draw and plot texts in pcbnew in all formats Italics texts are allowed in pcbnew (work in progress) 2008-Dec-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> ================================================================================ ++All Cleaning code to draw/plot texts (work in progress): Now only one function is used to draw and plot texts Now only one function is used to draw and plot texts (not for pcbnew) (easier to maintain and ensure texts have the same size in ploting and drawing) In eeschema, italic and bold texts allowed (in pcbenew, texts thickness is already adjustable) Loading
common/CMakeLists.txt +2 −1 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ set(COMMON_SRCS common_plot_functions.cpp common_plotHPGL_functions.cpp common_plotPS_functions.cpp common_plotGERBER_functions.cpp confirm.cpp copy_to_clipboard.cpp dcsvg.cpp Loading
common/common_plotHPGL_functions.cpp +26 −33 Original line number Diff line number Diff line Loading @@ -14,13 +14,6 @@ /* parametre HPGL pour trace de cercle: */ #define CHORD_ANGLE 10 // Variables partagees avec Common plot Postscript Routines extern wxPoint LastPenPosition; extern wxPoint PlotOffset; extern FILE* PlotOutputFile; extern double XScale, YScale; extern int g_DefaultPenWidth, g_CurrentPenWidth; extern int PlotOrientOptions, etat_plume; //Variables locales void Move_Plume_HPGL( wxPoint pos, int plume ); Loading @@ -28,20 +21,20 @@ void Plume_HPGL( int plume ); /***********************************************************************************/ void InitPlotParametresHPGL( wxPoint offset, double xscale, double yscale, int orient ) void InitPlotParametresHPGL( wxPoint offset, double aXScale, double aYScale, 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) * g_Plot_XScale,g_Plot_YScale = coordinate scale (scale coefficient for coordinates) * device_g_Plot_XScale,device_g_Plot_YScale = device coordinate scale (i.e scale used by plot device) */ { PlotOffset = offset; XScale = xscale; YScale = yscale; g_DefaultPenWidth = 6; /* epaisseur du trait standard en 1/1000 pouce */ PlotOrientOptions = orient; g_CurrentPenWidth = -1; g_Plot_PlotOffset = offset; g_Plot_XScale = aXScale; g_Plot_YScale = aYScale; g_Plot_DefaultPenWidth = 6; /* epaisseur du trait standard en 1/1000 pouce */ g_Plot_PlotOrientOptions = orient; g_Plot_CurrentPenWidth = -1; } Loading @@ -51,8 +44,8 @@ bool PrintHeaderHPGL( FILE* plot_file, int pen_speed, int pen_num ) { char Line[256]; PlotOutputFile = plot_file; etat_plume = 'U'; g_Plot_PlotOutputFile = plot_file; g_Plot_PenState = 'U'; sprintf( Line, "IN;VS%d;PU;PA;SP%d;\n", pen_speed, pen_num ); fputs( Line, plot_file ); return TRUE; Loading @@ -79,7 +72,7 @@ void PlotRectHPGL( wxPoint p1, wxPoint p2, bool fill, int width ) Plume_HPGL( 'U' ); sprintf( Line, "PA %d,%d;EA %d,%d;\n", p1.x, p1.y, p2.x, p2.y ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); Plume_HPGL( 'U' ); return; } Loading @@ -93,14 +86,14 @@ void PlotCircleHPGL( wxPoint centre, int diameter, bool fill, int width ) char Line[256]; UserToDeviceCoordinate( centre ); rayon = (int) (diameter / 2 * XScale); rayon = (int) (diameter / 2 * g_Plot_XScale); if( rayon < 0 ) rayon = 0; Plume_HPGL( 'U' ); sprintf( Line, "PA %d,%d;CI %d,%d;\n", centre.x, centre.y, rayon, CHORD_ANGLE ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); Plume_HPGL( 'U' ); return; } Loading Loading @@ -129,7 +122,7 @@ void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, bool fil cpos = centre; UserToDeviceCoordinate( cpos ); if( PlotOrientOptions == PLOT_MIROIR ) if( g_Plot_PlotOrientOptions == PLOT_MIROIR ) { EndAngle = -EndAngle; StAngle = -StAngle; Loading @@ -143,11 +136,11 @@ void PlotArcHPGL( wxPoint centre, int StAngle, int EndAngle, int rayon, bool fil Plume_HPGL( 'U' ); sprintf( Line, "PU;PA %d,%d;PD;AA %d,%d, ", cmap.x, cmap.y, cpos.x, cpos.y ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, "%f", -angle ); to_point( Line ); // Transforme , et . du separateur fputs( Line, PlotOutputFile ); sprintf( Line, ", %d", CHORD_ANGLE ); fputs( Line, PlotOutputFile ); sprintf( Line, ";PU;\n" ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, ", %d", CHORD_ANGLE ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, ";PU;\n" ); fputs( Line, g_Plot_PlotOutputFile ); Plume_HPGL( 'U' ); } Loading Loading @@ -205,7 +198,7 @@ void Move_Plume_HPGL( wxPoint pos, int plume ) Plume_HPGL( plume ); 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, g_Plot_PlotOutputFile ); } Loading @@ -218,14 +211,14 @@ void Plume_HPGL( int plume ) { if( plume == 'U' ) { if( etat_plume != 'U' ) fputs( "PU;", PlotOutputFile ); etat_plume = 'U'; if( g_Plot_PenState != 'U' ) fputs( "PU;", g_Plot_PlotOutputFile ); g_Plot_PenState = 'U'; } else { if( etat_plume != 'D' ) fputs( "PD;", PlotOutputFile ); etat_plume = 'D'; if( g_Plot_PenState != 'D' ) fputs( "PD;", g_Plot_PlotOutputFile ); g_Plot_PenState = 'D'; } }
common/common_plotPS_functions.cpp +47 −58 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ /******************************************/ #include "fctsys.h" #include "gr_basic.h" #include "trigo.h" #include "wxstruct.h" #include "base_struct.h" Loading @@ -11,36 +10,26 @@ #include "plot_common.h" #include "macros.h" #include "wx/defs.h" // Variables partagees avec Common plot Postscript Routines extern wxPoint LastPenPosition; extern wxPoint PlotOffset; extern FILE* PlotOutputFile; extern double XScale, YScale; extern int g_DefaultPenWidth, g_CurrentPenWidth; extern int PlotOrientOptions, etat_plume; // Locales static Ki_PageDescr* SheetPS; /*************************************************************************************/ void InitPlotParametresPS( wxPoint offset, Ki_PageDescr* sheet, double xscale, double yscale, int orient ) double aXScale, double aYScale, 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) * g_Plot_XScale,g_Plot_YScale = coordinate scale (scale coefficient for coordinates) * device_g_Plot_XScale,device_g_Plot_YScale = device coordinate scale (i.e scale used by plot device) */ { PlotOrientOptions = orient; PlotOffset = offset; g_Plot_PlotOrientOptions = orient; g_Plot_PlotOffset = offset; SheetPS = sheet; XScale = xscale; YScale = yscale; g_CurrentPenWidth = -1; g_Plot_XScale = aXScale; g_Plot_YScale = aYScale; g_Plot_CurrentPenWidth = -1; } Loading @@ -51,8 +40,8 @@ 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_CurrentPenWidth = -1; g_Plot_DefaultPenWidth = width; // epaisseur du trait standard en 1/1000 pouce g_Plot_CurrentPenWidth = -1; } Loading @@ -68,12 +57,12 @@ void SetCurrentLineWidthPS( int width ) if( width > 0 ) pen_width = width; else pen_width = g_DefaultPenWidth; pen_width = g_Plot_DefaultPenWidth; if( pen_width != g_CurrentPenWidth ) fprintf( PlotOutputFile, "%d setlinewidth\n", (int) (XScale * pen_width) ); if( pen_width != g_Plot_CurrentPenWidth ) fprintf( g_Plot_PlotOutputFile, "%d setlinewidth\n", (int) (g_Plot_XScale * pen_width) ); g_CurrentPenWidth = pen_width; g_Plot_CurrentPenWidth = pen_width; } Loading @@ -95,7 +84,7 @@ void SetColorMapPS( int color ) (float) ColorRefs[color].m_Green / 255, (float) ColorRefs[color].m_Blue / 255 ); to_point( Line ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); } Loading @@ -110,7 +99,7 @@ void PlotFilledSegmentPS( wxPoint start, wxPoint end, int width ) UserToDeviceCoordinate( end ); SetCurrentLineWidthPS( width ); fprintf( PlotOutputFile, "%d %d %d %d line\n", start.x, start.y, end.x, end.y ); fprintf( g_Plot_PlotOutputFile, "%d %d %d %d line\n", start.x, start.y, end.x, end.y ); } /***************************************************************/ Loading @@ -121,7 +110,7 @@ void PlotRectPS( wxPoint p1, wxPoint p2, bool fill, int width ) UserToDeviceCoordinate( p2 ); SetCurrentLineWidthPS( width ); fprintf( PlotOutputFile, "%d %d %d %d rect%d\n", p1.x, p1.y, fprintf( g_Plot_PlotOutputFile, "%d %d %d %d rect%d\n", p1.x, p1.y, p2.x-p1.x, p2.y-p1.y, fill ); } Loading @@ -133,14 +122,14 @@ void PlotCirclePS( wxPoint pos, int diametre, bool fill, int width ) char Line[256]; UserToDeviceCoordinate( pos ); rayon = (int) (XScale * diametre / 2); rayon = (int) (g_Plot_XScale * diametre / 2); if( rayon < 0 ) rayon = 0; SetCurrentLineWidthPS( width ); sprintf(Line, "%d %d %d cir%d\n", pos.x, pos.y, rayon, fill); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); } Loading @@ -162,18 +151,18 @@ void PlotArcPS( wxPoint centre, int StAngle, int EndAngle, int rayon, bool fill, // Calcul des coord du point de depart : UserToDeviceCoordinate( centre ); if( PlotOrientOptions == PLOT_MIROIR ) if( g_Plot_PlotOrientOptions == PLOT_MIROIR ) sprintf( Line, "%d %d %d %f %f arc%d\n", centre.x, centre.y, (int) (rayon * XScale), (float) StAngle / 10, (float) EndAngle / 10, (int) (rayon * g_Plot_XScale), (float) StAngle / 10, (float) EndAngle / 10, fill); else sprintf( Line, "%d %d %d %f %f arc%d\n", centre.x, centre.y, (int) (rayon * XScale), -(float) EndAngle / 10, -(float) StAngle / 10, (int) (rayon * g_Plot_XScale), -(float) EndAngle / 10, -(float) StAngle / 10, fill); // Undo internationalization printf (float x.y printed x,y) to_point( Line ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); } Loading @@ -199,18 +188,18 @@ void PlotPolyPS( int nb_segm, int* coord, bool fill, int width ) pos.x = coord[0]; pos.y = coord[1]; UserToDeviceCoordinate( pos ); fprintf( PlotOutputFile, "newpath %d %d moveto\n", pos.x, pos.y ); fprintf( g_Plot_PlotOutputFile, "newpath %d %d moveto\n", pos.x, pos.y ); for( ii = 1; ii < nb_segm; ii++ ) { pos.x = coord[2 * ii]; pos.y = coord[2 * ii + 1]; UserToDeviceCoordinate( pos ); fprintf( PlotOutputFile, "%d %d lineto\n", pos.x, pos.y ); fprintf( g_Plot_PlotOutputFile, "%d %d lineto\n", pos.x, pos.y ); } // Fermeture du polygone fprintf(PlotOutputFile, "poly%d\n", fill); fprintf(g_Plot_PlotOutputFile, "poly%d\n", fill); } Loading @@ -229,10 +218,10 @@ void LineTo_PS( wxPoint pos, int plume ) { char Line[256]; sprintf( Line, "%d %d %d %d line\n", LastPenPosition.x, LastPenPosition.y, pos.x, pos.y ); fputs( Line, PlotOutputFile ); g_Plot_LastPenPosition.x, g_Plot_LastPenPosition.y, pos.x, pos.y ); fputs( Line, g_Plot_PlotOutputFile ); } LastPenPosition = pos; g_Plot_LastPenPosition = pos; } Loading Loading @@ -294,26 +283,26 @@ void PrintHeaderPS( FILE* file, const wxString& Creator, int ii; time_t time1970 = time( NULL ); PlotOutputFile = file; g_Plot_PlotOutputFile = file; fputs( "%!PS-Adobe-3.0\n", PlotOutputFile ); // Print header fputs( "%!PS-Adobe-3.0\n", g_Plot_PlotOutputFile ); // Print header sprintf( Line, "%%%%Creator: %s\n", CONV_TO_UTF8( Creator ) ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_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 ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, "%%%%Title: %s\n", CONV_TO_UTF8( FileName ) ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, "%%%%Pages: %d\n", PageCount ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, "%%%%PageOrder: Ascend\n" ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); // Print boundary box en 1/72 pouce, box is in mils const double CONV_SCALE = MIL_TO_INCH * 72; Loading @@ -325,7 +314,7 @@ void PrintHeaderPS( FILE* file, const wxString& Creator, (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 ); fputs( Line, g_Plot_PlotOutputFile ); // 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, Loading @@ -349,17 +338,17 @@ void PrintHeaderPS( FILE* file, const wxString& Creator, 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 ); fputs( Line, g_Plot_PlotOutputFile ); if( PaperOrientation == wxPORTRAIT ) sprintf( Line, "%%%%Orientation: Portrait\n" ); else sprintf( Line, "%%%%Orientation: Landscape\n" ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, "%%%%EndComments\n" ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); // Now specify various other details. Loading @@ -368,11 +357,11 @@ void PrintHeaderPS( FILE* file, const wxString& Creator, // contents of the postscript file comply with the details specified // within the Document Structuring Convention. sprintf( Line, "%%%%Page: 1 1\n" ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); for( ii = 0; PSMacro[ii] != NULL; ii++ ) { fputs( PSMacro[ii], PlotOutputFile ); fputs( PSMacro[ii], g_Plot_PlotOutputFile ); } if( PaperOrientation == wxLANDSCAPE ) Loading @@ -386,15 +375,15 @@ void PrintHeaderPS( FILE* file, const wxString& Creator, // compensation internationalisation printf (float x.y gnr x,y) to_point( Line ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); sprintf( Line, "%f %f scale\t\t%% Move to User coordinates\n", XScale, YScale ); g_Plot_XScale, g_Plot_YScale ); to_point( Line ); fputs( Line, PlotOutputFile ); fputs( Line, g_Plot_PlotOutputFile ); // Set default line width ( g_DefaultPenWidth is in user units ) fprintf( PlotOutputFile, "%d setlinewidth\n", g_DefaultPenWidth ); // Set default line width ( g_Plot_DefaultPenWidth is in user units ) fprintf( g_Plot_PlotOutputFile, "%d setlinewidth\n", g_Plot_DefaultPenWidth ); } Loading
common/common_plot_functions.cpp +24 −43 Original line number Diff line number Diff line Loading @@ -14,68 +14,46 @@ // Variables partagees avec Common plot Postscript et HPLG Routines wxPoint LastPenPosition; wxPoint PlotOffset; FILE* PlotOutputFile; double XScale, YScale; int g_DefaultPenWidth; int g_CurrentPenWidth = -1; int PlotOrientOptions, etat_plume; // Locales static Ki_PageDescr* SheetPS; wxPoint g_Plot_LastPenPosition; wxPoint g_Plot_PlotOffset; FILE* g_Plot_PlotOutputFile; double g_Plot_XScale, g_Plot_YScale; int g_Plot_DefaultPenWidth; int g_Plot_CurrentPenWidth = -1; int g_Plot_PlotOrientOptions, g_Plot_PenState; /*************************/ void ForcePenReinit() /*************************/ /* set the flag g_CurrentPenWidth to -1 in order to force a pen width redefinition /* set the flag g_Plot_CurrentPenWidth to -1 in order to force a pen width redefinition * for the next draw command */ { g_CurrentPenWidth = -1; g_Plot_CurrentPenWidth = -1; } /**********************************************/ void SetPlotScale( double xscale, double yscale ) void SetPlotScale( double aXScale, double aYScale ) /**********************************************/ /* Set the plot scale for the current plotting) */ { XScale = xscale; YScale = yscale; g_Plot_XScale = aXScale; g_Plot_YScale = aYScale; } /*********************************/ void SetPlotOffset( wxPoint offset ) void Setg_Plot_PlotOffset( wxPoint offset ) /*********************************/ /* Set the plot offset for the current plotting) */ { PlotOffset = offset; } /***************************************************************************/ void InitPlotParametresGERBER( wxPoint offset, double xscale, double yscale ) /***************************************************************************/ /* Set the plot offset for the current plotting * xscale,yscale = coordinate scale (scale coefficient for coordinates) */ { PlotOrientOptions = 0; PlotOffset = offset; SheetPS = NULL; XScale = xscale; YScale = yscale; g_DefaultPenWidth = 120; /* epaisseur du trait standard en 1/1000 pouce */ g_CurrentPenWidth = -1; g_Plot_PlotOffset = offset; } Loading Loading @@ -114,6 +92,9 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ) break; case PLOT_FORMAT_GERBER: FctPlume = LineTo_GERBER; break; default: return; } Loading Loading @@ -507,17 +488,17 @@ void UserToDeviceCoordinate( wxPoint& pos ) /* modifie les coord pos.x et pos.y pour le trace selon l'orientation, * l'echelle, les offsets de trace */ { pos.x = (int) (pos.x * XScale); pos.y = (int) (pos.y * YScale); pos.x = (int) (pos.x * g_Plot_XScale); pos.y = (int) (pos.y * g_Plot_YScale); switch( PlotOrientOptions ) /* Calcul du cadrage */ switch( g_Plot_PlotOrientOptions ) /* Calcul du cadrage */ { default: pos.x -= PlotOffset.x; pos.y = PlotOffset.y - pos.y; pos.x -= g_Plot_PlotOffset.x; pos.y = g_Plot_PlotOffset.y - pos.y; break; case PLOT_MIROIR: pos.x -= PlotOffset.x; pos.y = -PlotOffset.y + pos.y; pos.x -= g_Plot_PlotOffset.x; pos.y = -g_Plot_PlotOffset.y + pos.y; break; } } Loading @@ -528,6 +509,6 @@ void UserToDeviceSize( wxSize& size ) /************************************/ /* modifie les dimension size.x et size.y pour le trace selon l'echelle */ { size.x = (int) (size.x * XScale); size.y = (int) (size.y * YScale); size.x = (int) (size.x * g_Plot_XScale); size.y = (int) (size.y * g_Plot_YScale); }