From daeb9f0e07390f0e0d48fbc1ed1a2df62c8a2082 Mon Sep 17 00:00:00 2001 From: charras Date: Mon, 22 Dec 2008 21:06:44 +0000 Subject: [PATCH] Cleaning code to draw/plot texts; italic allowed for pcbnew --- CHANGELOG.txt | 9 +- common/CMakeLists.txt | 3 +- common/common_plotHPGL_functions.cpp | 59 +- common/common_plotPS_functions.cpp | 105 +- common/common_plot_functions.cpp | 67 +- common/drawtxt.cpp | 6 +- common/edaappl.cpp | 1 - common/makefile.include | 1 + gerbview/protos.h | 12 +- include/plot_common.h | 82 +- include/wxPcbStruct.h | 1 - pcbnew/CMakeLists.txt | 3 +- pcbnew/class_text_mod.cpp | 56 +- pcbnew/class_text_mod.h | 16 +- pcbnew/dialog_edit_mod_text.cpp | 474 ------ pcbnew/dialog_edit_mod_text.pjd | 1488 ----------------- pcbnew/dialog_edit_module_text.cpp | 201 +++ ...t_mod_text.h => dialog_edit_module_text.h} | 0 pcbnew/dialog_edit_module_text_base.cpp | 135 ++ pcbnew/dialog_edit_module_text_base.fbp | 1137 +++++++++++++ pcbnew/dialog_edit_module_text_base.h | 69 + pcbnew/gen_drill_report_files.cpp | 19 +- pcbnew/makefile.include | 9 +- pcbnew/modules.cpp | 18 +- pcbnew/pcbplot.h | 28 +- pcbnew/plot_rtn.cpp | 181 +- pcbnew/plotgerb.cpp | 339 ++-- pcbnew/plotgerb.h | 111 -- pcbnew/plothpgl.cpp | 6 +- pcbnew/protos.h | 6 - 30 files changed, 1951 insertions(+), 2691 deletions(-) delete mode 100644 pcbnew/dialog_edit_mod_text.cpp delete mode 100644 pcbnew/dialog_edit_mod_text.pjd create mode 100644 pcbnew/dialog_edit_module_text.cpp rename pcbnew/{dialog_edit_mod_text.h => dialog_edit_module_text.h} (100%) create mode 100644 pcbnew/dialog_edit_module_text_base.cpp create mode 100644 pcbnew/dialog_edit_module_text_base.fbp create mode 100644 pcbnew/dialog_edit_module_text_base.h delete mode 100644 pcbnew/plotgerb.h diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 81c144c9f3..128d62c078 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 +================================================================================ +++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 ================================================================================ ++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) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index f8db2fb31a..439c66a5ab 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -12,7 +12,8 @@ set(COMMON_SRCS common_plot_functions.cpp common_plotHPGL_functions.cpp common_plotPS_functions.cpp - confirm.cpp + common_plotGERBER_functions.cpp + confirm.cpp copy_to_clipboard.cpp dcsvg.cpp displlst.cpp diff --git a/common/common_plotHPGL_functions.cpp b/common/common_plotHPGL_functions.cpp index 406fa7017b..cc4da80259 100644 --- a/common/common_plotHPGL_functions.cpp +++ b/common/common_plotHPGL_functions.cpp @@ -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 ); @@ -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; } @@ -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; @@ -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; } @@ -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; } @@ -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; @@ -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' ); } @@ -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 ); } @@ -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'; } } diff --git a/common/common_plotPS_functions.cpp b/common/common_plotPS_functions.cpp index bcecb22adf..b19645828f 100644 --- a/common/common_plotPS_functions.cpp +++ b/common/common_plotPS_functions.cpp @@ -3,7 +3,6 @@ /******************************************/ #include "fctsys.h" -#include "gr_basic.h" #include "trigo.h" #include "wxstruct.h" #include "base_struct.h" @@ -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; } @@ -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; } @@ -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; } @@ -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 ); } @@ -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 ); } /***************************************************************/ @@ -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 ); } @@ -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 ); } @@ -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 ); } @@ -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); } @@ -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; } @@ -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; @@ -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, @@ -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. @@ -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 ) @@ -386,15 +375,15 @@ void PrintHeaderPS( FILE* file, const wxString& Creator, // compensation internationalisation printf (float x.y généré 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 ); } diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp index 2d5e22943d..d4124fe831 100644 --- a/common/common_plot_functions.cpp +++ b/common/common_plot_functions.cpp @@ -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; } @@ -114,6 +92,9 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ) break; case PLOT_FORMAT_GERBER: + FctPlume = LineTo_GERBER; + break; + default: return; } @@ -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; } } @@ -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); } diff --git a/common/drawtxt.cpp b/common/drawtxt.cpp index 4e7c5f2df0..5b0afdc5fc 100644 --- a/common/drawtxt.cpp +++ b/common/drawtxt.cpp @@ -348,6 +348,8 @@ static void s_Callback_plot(int x0, int y0, int xf, int yf) PenLastPos = pend; } + + /******************************************************************************************/ void PlotGraphicText( int aFormat_plot, const wxPoint& aPos, enum EDA_Colors aColor, const wxString& aText, @@ -372,7 +374,6 @@ void PlotGraphicText( int aFormat_plot, const wxPoint& aPos, enum EDA_Colors aCo * @param aItalic = true to simulate an italic font */ { - // Initialise the actual function used to plot lines: switch( aFormat_plot ) { @@ -385,6 +386,9 @@ void PlotGraphicText( int aFormat_plot, const wxPoint& aPos, enum EDA_Colors aCo break; case PLOT_FORMAT_GERBER: + MovePenFct = LineTo_GERBER; + break; + default: return; } diff --git a/common/edaappl.cpp b/common/edaappl.cpp index 52681e937d..e8a51aa4c0 100644 --- a/common/edaappl.cpp +++ b/common/edaappl.cpp @@ -24,7 +24,6 @@ #include "hotkeys_basic.h" #include "macros.h" #include "online_help.h" - #include "bitmaps.h" diff --git a/common/makefile.include b/common/makefile.include index 6d9be94ac2..df0f09b461 100644 --- a/common/makefile.include +++ b/common/makefile.include @@ -13,6 +13,7 @@ OBJECTS= \ copy_to_clipboard.o\ class_drawpickedstruct.o\ common_plot_functions.o\ + common_plotGERBER_functions.o\ common_plotPS_functions.o\ common_plotHPGL_functions.o\ dlist.o \ diff --git a/gerbview/protos.h b/gerbview/protos.h index 8ec2267303..d624817579 100644 --- a/gerbview/protos.h +++ b/gerbview/protos.h @@ -25,12 +25,6 @@ void Print_PcbItems(BOARD * Pcb, wxDC *DC, int drawmode, int printmasklayer); /*****************/ void DisplayColorSetupFrame(WinEDA_DrawFrame * parent, const wxPoint & framepos); -/***************/ -/* affiche.cpp */ -/***************/ -void valeur_param(int valeur,char * buf_texte); -void Affiche_Infos_PCB_Texte(WinEDA_BasePcbFrame * frame, TEXTE_PCB* pt_texte); -void Affiche_Infos_Piste(WinEDA_BasePcbFrame * frame, TRACK * pt_piste); /* PLOT_RTN.CC */ void ComputePlotFileName( char * FullFileName, char * Ext ); @@ -38,14 +32,10 @@ void calcule_coord_plot(int * dx, int * dy ) ; void calcule_dim_plot(int * dx, int * dy ) ; void Trace_Un_TextePcb( TEXTE_PCB * pt_texte,int format_plot,int masque_layer); /* Trace 1 Texte type PCB , c.a.d autre que les textes sur modules, - prepare les parametres de trace de Plot_1_texte */ + prepare les parametres de trace de texte */ void trace_1_arc(int format_plot,int cx,int cy,int start,int end, int rayon,int epaisseur); void trace_1_cercle(int format_plot,int epaisseur,int cx, int cy, int rayon); -void Plot_1_texte( int format_plot, - char * ptr,int t_nbcodes, int t_orient, - int epaisseur, int ox,int oy,int size_h,int size_v); - /* Routine de base de trace de 1 chaine de caracteres */ void Trace_Un_DrawSegment( DRAWSEGMENT* PtSegm, int format_plot,int masque_layer ); diff --git a/include/plot_common.h b/include/plot_common.h index 7c011f4520..a17f936e2b 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -31,13 +31,21 @@ static inline bool IsPostScript( int aFormat ) const int PLOT_MIROIR = 1; +// Variables used in Common plot functions +extern wxPoint g_Plot_LastPenPosition; +extern wxPoint g_Plot_PlotOffset; +extern FILE* g_Plot_PlotOutputFile; +extern double g_Plot_XScale, g_Plot_YScale; +extern int g_Plot_DefaultPenWidth, g_Plot_CurrentPenWidth; +extern int g_Plot_PlotOrientOptions, g_Plot_PenState; + /*******************************/ /* 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 InitPlotParametresGERBER( wxPoint offset, double xscale, double yscale ); +void SetPlotScale( double aXScale, double aYScale ); // Set the plot scale for the current plotting) +void Setg_Plot_PlotOffset( wxPoint offset ); // Set the plot offset for the current plotting) +void InitPlotParametresGERBER( wxPoint offset, double aXScale, double aYScale ); void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ); void UserToDeviceCoordinate( wxPoint& pos ); @@ -47,7 +55,7 @@ void UserToDeviceSize( wxSize& size ); // modifie les dimension size.x et size.y pour le trace selon l'echelle void ForcePenReinit(); -// set the flag g_CurrentPenWidth to -1 in order +// set the flag g_Plot_CurrentPenWidth to -1 in order // to force a pen width redefinition for the next draw command @@ -57,8 +65,8 @@ void ForcePenReinit(); void SetCurrentLineWidthPS( int width ); void InitPlotParametresPS( wxPoint offset, Ki_PageDescr* sheet, - double xscale, - double yscale, + double aXScale, + double aYScale, int orient = 0 ); void SetDefaultLineWidthPS( int width ); void PlotRectPS( wxPoint p1, wxPoint p2, bool fill, int width = -1 ); @@ -82,7 +90,7 @@ void SetColorMapPS( int color ); /*********************************/ /* common_plotHPGL_functions.cpp */ /*********************************/ -void InitPlotParametresHPGL( wxPoint offset, double xscale, double yscale, int orient = 0 ); +void InitPlotParametresHPGL( wxPoint offset, double aXScale, double aYScale, int orient = 0 ); bool PrintHeaderHPGL( FILE* plot_file, int pen_speed, int pen_num ); bool CloseFileHPGL( FILE* plot_file ); void PlotCircleHPGL( wxPoint centre, int diameter, bool fill, int width = -1 ); @@ -92,4 +100,64 @@ void PlotPolyHPGL( int nb, int* coord, bool fill, int width = -1 ); void Move_Plume_HPGL( wxPoint pos, int plume ); void Plume_HPGL( int plume ); +/*********************************/ +/* common_plotGERBER_functions.cpp */ +/*********************************/ +/** function InitPlotParametresGERBER + * Set the plot offset for the current plotting + * @param aOffset = plot offset + * @param aXScale,aYScale = coordinate scale (scale coefficient for coordinates) + */ +void InitPlotParametresGERBER( wxPoint aOffset, double aXScale, double aYScale ); + +/** Function Write_Header_GERBER + * Write GERBER header to file + * initialize global variable g_Plot_PlotOutputFile + * @param aTitle: the name of creator (comment) + * @param aFile: an opened file to write to + */ +void Write_Header_GERBER( const wxString aTitle, FILE* aFile ); + +/** Function LineTo_GERBER + * if aCommand = 'U' initialise the starting point of a line + * if aCommand = 'D' draw a line from the starting point, or last point to aPos + * @param aPos = end of the current line. + * @param aCommand = 'U' or 'D' or 'Z' (Pen up , no moving ) + */ +void LineTo_GERBER( wxPoint aPos, int aCommand ); + +/** Function PlotGERBERLine + * Plot a line + * @param aStartPos = starting point of the line + * @param aEndPos = ending point of the line + * @param aThickness = line thickness +*/ +void PlotGERBERLine( wxPoint aStartPos, wxPoint aEndPos, int aThickness ); + +/** Function PlotCircle_GERBER + * writes a non filled circle to output file + * Plot one circle as segments (6 to 16 depending on its radius + * @param aCentre = centre coordintes + * @param aRadius = radius of the circle + * @param aWidth = line width (noc currently used, D_CODEs must be selected before) +*/ +void PlotCircle_GERBER( wxPoint aCentre, int aRadius, int aWidth ); + +/** Function PlotPolygon_GERBER + * writes a closed polyline (not a filled polygon) to output file + * @param aCornersCount = numer of corners + * @param aCoord = buffer of corners coordinates + * @param aWidth = line width (noc currently used, D_CODEs must be selected before) +*/ + + +void PlotPolygon_GERBER( int aCornersCount, int* aCoord, int aWidth ); + +/** Function PlotFilledPolygon_GERBER + * writes a filled polyline to output file + * @param aCornersCount = numer of corners + * @param aCoord = buffer of corners coordinates +*/ +void PlotFilledPolygon_GERBER( int aCornersCount, int* aCoord ); + #endif /* #ifndef PLOT_COMMON_H */ diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 4e29a7f4cb..db4c73a723 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -275,7 +275,6 @@ public: int garde, int tracevia, int modetrace ); void Plot_Layer_GERBER( FILE* File, int masque_layer, int garde, int tracevia ); - int Gen_D_CODE_File( FILE* file ); void Plot_Layer_PS( FILE* File, int masque_layer, int garde, int tracevia, int modetrace ); diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index dfe7a6e412..5e33a0d08d 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -48,7 +48,8 @@ set(PCBNEW_SRCS dialog_copper_zones_base.cpp dialog_display_options_base.cpp # dialog_drc.cpp - dialog_edit_mod_text.cpp + dialog_edit_module_text.cpp + dialog_edit_module_text_base.cpp # dialog_edit_module.cpp dialog_freeroute_exchange.cpp # dialog_gendrill.cpp diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index ef01dd821b..12634c1c26 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -28,19 +28,16 @@ /* Constructeur de TEXTE_MODULE */ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) : - BOARD_ITEM( parent, TYPE_TEXTE_MODULE ) + BOARD_ITEM( parent, TYPE_TEXTE_MODULE ), EDA_TextStruct () { MODULE* Module = (MODULE*) m_Parent; - m_NoShow = 0; /* visible */ m_Type = text_type; /* Reference */ if( (m_Type != TEXT_is_REFERENCE) && (m_Type != TEXT_is_VALUE) ) m_Type = TEXT_is_DIVERS; + m_NoShow = false; m_Size.x = m_Size.y = 400; m_Width = 120; /* dimensions raisonnables par defaut */ - m_Orient = 0; /* en 1/10 degre */ - m_Miroir = 1; // Mode normal (pas de miroir) - m_Unused = 0; SetLayer( SILKSCREEN_N_CMP ); if( Module && (Module->Type() == TYPE_MODULE) ) @@ -60,7 +57,7 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) : || moduleLayer == ADHESIVE_N_CU || moduleLayer == COPPER_LAYER_N ) { - m_Miroir = 0; + m_Mirror = true; } } } @@ -85,17 +82,20 @@ bool TEXTE_MODULE::Save( FILE* aFile ) const MODULE* parent = (MODULE*) GetParent(); int orient = m_Orient; + // Due to the pcbnew history, m_Orient is saved in screen value + // but it is handled as relative to its parent footprint if( parent ) orient += parent->m_Orient; - int ret = fprintf( aFile, "T%d %d %d %d %d %d %d %c %c %d \"%s\"\n", + int ret = fprintf( aFile, "T%d %d %d %d %d %d %d %c %c %d %c\"%s\"\n", m_Type, m_Pos0.x, m_Pos0.y, m_Size.y, m_Size.x, orient, m_Width, - m_Miroir ? 'N' : 'M', m_NoShow ? 'I' : 'V', + m_Mirror ? 'M' : 'N', m_NoShow ? 'I' : 'V', GetLayer(), + m_Italic ? 'I' : 'N', CONV_TO_UTF8( m_Text ) ); return ret > 20; @@ -117,33 +117,40 @@ int TEXTE_MODULE::ReadDescr( char* aLine, FILE* aFile, int* aLineNum ) int success = true; int type; int layer; - char BufCar1[128], BufCar2[128], BufLine[256]; + char BufCar1[128], BufCar2[128], BufCar3[128], BufLine[256]; layer = SILKSCREEN_N_CMP; BufCar1[0] = 0; BufCar2[0] = 0; - if ( sscanf( aLine + 1, "%d %d %d %d %d %d %d %s %s %d", + BufCar3[0] = 0; + if ( sscanf( aLine + 1, "%d %d %d %d %d %d %d %s %s %d %s", &type, &m_Pos0.x, &m_Pos0.y, &m_Size.y, &m_Size.x, &m_Orient, &m_Width, - BufCar1, BufCar2, &layer ) < 10 ) + BufCar1, BufCar2, &layer, BufCar3 ) >= 10 ) success = true; if( (type != TEXT_is_REFERENCE) && (type != TEXT_is_VALUE) ) type = TEXT_is_DIVERS; m_Type = type; - // .m_Orient member must be relative to the parent module + // Due to the pcbnew history, .m_Orient is saved in screen value + // but it is handled as relative to its parent footprint m_Orient -= ((MODULE * )m_Parent)->m_Orient; if( BufCar1[0] == 'M' ) - m_Miroir = 0; + m_Mirror = true; else - m_Miroir = 1; + m_Mirror = false; if( BufCar2[0] == 'I' ) - m_NoShow = 1; + m_NoShow = true; else - m_NoShow = 0; + m_NoShow = false; + + if( BufCar3[0] == 'I' ) + m_Italic = true; + else + m_Italic = false; // Test for a reasonnable layer: if( layer < 0 ) @@ -191,7 +198,7 @@ void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) m_Pos = source->m_Pos; SetLayer( source->GetLayer() ); - m_Miroir = source->m_Miroir; // Show normal / mirror + m_Mirror = source->m_Mirror; // Show normal / mirror m_NoShow = source->m_NoShow; // 0: visible 1: invisible m_Type = source->m_Type; // 0: ref,1: val, others = 2..255 m_Orient = source->m_Orient; // orientation in 1/10 deg @@ -347,7 +354,7 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const */ { int zoom; - int width, color, orient, miroir; + int width, color, orient; wxSize size; wxPoint pos; // Centre du texte PCB_SCREEN* screen; @@ -367,7 +374,6 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const size = m_Size; orient = GetDrawRotation(); - miroir = m_Miroir & 1; // = 0 si vu en miroir width = m_Width; if( (frame->m_DisplayModText == FILAIRE) || ( (width / zoom) < L_MIN_DESSIN ) ) @@ -406,13 +412,13 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const if( (color & ITEM_NOT_SHOW) != 0 ) return; - /* Si le texte doit etre mis en miroir: modif des parametres */ - if( miroir == 0 ) + /* If the text is mirrored : negate size.x (mirror / Y axis) */ + if( m_Mirror ) size.x = -size.x; /* Trace du texte */ DrawGraphicText( panel, DC, pos, (enum EDA_Colors) color, m_Text, - orient, size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width ); + orient, size, m_HJustify, m_VJustify, width, m_Italic ); } @@ -489,9 +495,9 @@ void TEXTE_MODULE::Display_Infos( WinEDA_DrawFrame* frame ) msg.Printf( wxT( "%d" ), ii ); Affiche_1_Parametre( frame, 31, _( "Layer" ), msg, DARKGREEN ); - msg = wxT( " Yes" ); - if( m_Miroir & 1 ) - msg = wxT( " No" ); + msg = _( " No" ); + if( m_Mirror ) + msg = _( " Yes" ); Affiche_1_Parametre( frame, 37, _( "Mirror" ), msg, DARKGREEN ); diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index 6df677a1b5..a5b0cd4d96 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -13,21 +13,16 @@ #define TEXT_is_DIVERS 2 -class TEXTE_MODULE : public BOARD_ITEM +class TEXTE_MODULE : public BOARD_ITEM, public EDA_TextStruct { +/* Note: orientation in 1/10 deg relative to the footprint + * Physical orient is m_Orient + m_Parent->m_Orient +*/ public: - wxPoint m_Pos; // Real (physical)coord - int m_Width; wxPoint m_Pos0; // text coordinates relatives to the footprint ancre, orient 0 // Text coordinate ref point is the text centre - char m_Unused; // unused (reserved for future extensions) - char m_Miroir; // Show normal / mirror - char m_NoShow; // 0: visible 1: invisible (bool) char m_Type; // 0: ref,1: val, others = 2..255 - int m_Orient; // orientation in 1/10 deg relative to the footprint - // Physical orient is m_Orient + m_Parent->m_Orient - wxSize m_Size; // text size - wxString m_Text; + bool m_NoShow; // true = invisible public: TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS ); @@ -52,7 +47,6 @@ public: /* Gestion du texte */ void SetWidth( int new_width ); int GetLength(); /* text length */ - int Pitch(); /* retourne le pas entre 2 caracteres */ int GetDrawRotation(); // Return text rotation for drawings and plotting /** Function GetTextRect diff --git a/pcbnew/dialog_edit_mod_text.cpp b/pcbnew/dialog_edit_mod_text.cpp deleted file mode 100644 index ffda1eb75b..0000000000 --- a/pcbnew/dialog_edit_mod_text.cpp +++ /dev/null @@ -1,474 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// - -// Name: edtxtmod.cpp -// Purpose: -// Author: jean-pierre Charras -// Modified by: -// Created: 09/02/2006 18:17:15 -// RCS-ID: -// Copyright: License GNU -// Licence: -///////////////////////////////////////////////////////////////////////////// - -// Generated by DialogBlocks (unregistered), 09/02/2006 18:17:15 - -#if defined (__GNUG__) && !defined (NO_GCC_PRAGMA) -#pragma implementation "edtxtmod.h" -#endif - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/wx.h" -#endif - -////@begin includes -////@end includes - -#include "fctsys.h" -#include "gr_basic.h" - -#include "common.h" -#include "pcbnew.h" - -#include "dialog_edit_mod_text.h" - -extern wxPoint MoveVector; // Move vector for move edge, imported from edtxtmod.cpp - -////@begin XPM images -////@end XPM images - -/***************************************************************************/ -void WinEDA_BasePcbFrame::InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, - wxDC* DC, const wxPoint& pos ) -/***************************************************************************/ -{ - DrawPanel->m_IgnoreMouseEvents = TRUE; - WinEDA_TextModPropertiesFrame* frame = new WinEDA_TextModPropertiesFrame( this, - TextMod, DC ); - frame->ShowModal(); frame->Destroy(); - DrawPanel->MouseToCursorSchema(); - DrawPanel->m_IgnoreMouseEvents = FALSE; -} - - -/*! - * WinEDA_TextModPropertiesFrame type definition - */ - -IMPLEMENT_DYNAMIC_CLASS( WinEDA_TextModPropertiesFrame, wxDialog ) - -/*! - * WinEDA_TextModPropertiesFrame event table definition - */ - -BEGIN_EVENT_TABLE( WinEDA_TextModPropertiesFrame, wxDialog ) - -////@begin WinEDA_TextModPropertiesFrame event table entries -EVT_BUTTON( wxID_OK, WinEDA_TextModPropertiesFrame::OnOkClick ) - -EVT_BUTTON( wxID_CANCEL, WinEDA_TextModPropertiesFrame::OnCancelClick ) - -////@end WinEDA_TextModPropertiesFrame event table entries - -END_EVENT_TABLE() - -/*! - * WinEDA_TextModPropertiesFrame constructors - */ - -WinEDA_TextModPropertiesFrame::WinEDA_TextModPropertiesFrame() -{ -} - - -WinEDA_TextModPropertiesFrame::WinEDA_TextModPropertiesFrame( WinEDA_BasePcbFrame* parent, - TEXTE_MODULE* TextMod, - wxDC* DC, - wxWindowID id, - const wxString& caption, - const wxPoint& pos, - const wxSize& size, - long style ) -{ - m_Parent = parent; - m_DC = DC; - m_Module = NULL; - m_CurrentTextMod = TextMod; - if( m_CurrentTextMod ) - { - m_Module = (MODULE*) m_CurrentTextMod->GetParent(); - } - - Create( parent, id, caption, pos, size, style ); -} - - -/*! - * WinEDA_TextModPropertiesFrame creator - */ - -bool WinEDA_TextModPropertiesFrame::Create( wxWindow* parent, - wxWindowID id, - const wxString& caption, - const wxPoint& pos, - const wxSize& size, - long style ) -{ -////@begin WinEDA_TextModPropertiesFrame member initialisation - m_ModuleInfoText = NULL; - m_TextDataTitle = NULL; - m_Name = NULL; - m_SizeXTitle = NULL; - m_TxtSizeCtrlX = NULL; - m_SizeYTitle = NULL; - m_TxtSizeCtrlY = NULL; - m_PosXTitle = NULL; - m_TxtPosCtrlX = NULL; - m_PosYTitle = NULL; - m_TxtPosCtrlY = NULL; - m_WidthTitle = NULL; - m_TxtWidthCtlr = NULL; - m_Orient = NULL; - m_Show = NULL; - -////@end WinEDA_TextModPropertiesFrame member initialisation - -////@begin WinEDA_TextModPropertiesFrame creation - SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS ); - wxDialog::Create( parent, id, caption, pos, size, style ); - - CreateControls(); - GetSizer()->Fit( this ); - GetSizer()->SetSizeHints( this ); - Centre(); - -////@end WinEDA_TextModPropertiesFrame creation - return true; -} - - -/*! - * Control creation for WinEDA_TextModPropertiesFrame - */ - -void WinEDA_TextModPropertiesFrame::CreateControls() -{ - SetFont( *g_DialogFont ); - -////@begin WinEDA_TextModPropertiesFrame content construction - // Generated by DialogBlocks, 09/02/2006 19:51:49 (unregistered) - - WinEDA_TextModPropertiesFrame* itemDialog1 = this; - - wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL ); - itemDialog1->SetSizer( itemBoxSizer2 ); - - m_ModuleInfoText = new wxStaticText( itemDialog1, wxID_STATIC, _( - "Module %s (%s) orient %.1f" ), wxDefaultPosition, wxDefaultSize, 0 ); - m_ModuleInfoText->SetForegroundColour( wxColour( 0, 0, 255 ) ); - itemBoxSizer2->Add( m_ModuleInfoText, - 0, - wxALIGN_CENTER_HORIZONTAL | wxALL | wxADJUST_MINSIZE, - 5 ); - - wxStaticLine* itemStaticLine4 = new wxStaticLine( itemDialog1, - wxID_STATIC, - wxDefaultPosition, - wxDefaultSize, - wxLI_HORIZONTAL ); - itemBoxSizer2->Add( itemStaticLine4, 0, wxGROW | wxALL, 5 ); - - m_TextDataTitle = new wxStaticText( itemDialog1, wxID_STATIC, _( - "Reference:" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer2->Add( m_TextDataTitle, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, - 5 ); - - m_Name = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( - "" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer2->Add( m_Name, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - - wxBoxSizer* itemBoxSizer7 = new wxBoxSizer( wxHORIZONTAL ); - itemBoxSizer2->Add( itemBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); - - wxBoxSizer* itemBoxSizer8 = new wxBoxSizer( wxVERTICAL ); - itemBoxSizer7->Add( itemBoxSizer8, 0, wxGROW | wxALL, 5 ); - - m_SizeXTitle = new wxStaticText( itemDialog1, wxID_STATIC, _( - "Size X" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer8->Add( m_SizeXTitle, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, - 5 ); - - m_TxtSizeCtrlX = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T( - "" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer8->Add( m_TxtSizeCtrlX, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - - m_SizeYTitle = new wxStaticText( itemDialog1, wxID_STATIC, _( - "Size Y" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer8->Add( m_SizeYTitle, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, - 5 ); - - m_TxtSizeCtrlY = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T( - "" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer8->Add( m_TxtSizeCtrlY, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - - itemBoxSizer8->Add( 5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); - - m_PosXTitle = new wxStaticText( itemDialog1, wxID_STATIC, _( - "Offset X" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer8->Add( m_PosXTitle, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, - 5 ); - - m_TxtPosCtrlX = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T( - "" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer8->Add( m_TxtPosCtrlX, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - - m_PosYTitle = new wxStaticText( itemDialog1, wxID_STATIC, _( - "Offset Y" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer8->Add( m_PosYTitle, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, - 5 ); - - m_TxtPosCtrlY = new wxTextCtrl( itemDialog1, ID_TEXTCTRL4, _T( - "" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer8->Add( m_TxtPosCtrlY, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - - wxBoxSizer* itemBoxSizer18 = new wxBoxSizer( wxVERTICAL ); - itemBoxSizer7->Add( itemBoxSizer18, 0, wxGROW | wxALL, 5 ); - - m_WidthTitle = new wxStaticText( itemDialog1, wxID_STATIC, _( - "Width" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer18->Add( m_WidthTitle, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, - 5 ); - - m_TxtWidthCtlr = new wxTextCtrl( itemDialog1, ID_TEXTCTRL5, _T( - "" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer18->Add( m_TxtWidthCtlr, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - - wxBoxSizer* itemBoxSizer21 = new wxBoxSizer( wxVERTICAL ); - itemBoxSizer7->Add( itemBoxSizer21, 0, wxGROW | wxALL, 5 ); - - wxButton* itemButton22 = new wxButton( itemDialog1, wxID_OK, _( - "&OK" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton22->SetForegroundColour( wxColour( 198, 0, 0 ) ); - itemBoxSizer21->Add( itemButton22, 0, wxGROW | wxALL, 5 ); - - wxButton* itemButton23 = new wxButton( itemDialog1, wxID_CANCEL, _( - "&Cancel" ), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton23->SetForegroundColour( wxColour( 0, 0, 255 ) ); - itemBoxSizer21->Add( itemButton23, 0, wxGROW | wxALL, 5 ); - - wxString m_OrientStrings[] = { - _( "horiz" ), - _( "vertical" ) - }; - m_Orient = new wxRadioBox( itemDialog1, ID_RADIOBOX, _( - "Orientation" ), wxDefaultPosition, wxDefaultSize, 2, m_OrientStrings, 1, - wxRA_SPECIFY_COLS ); - itemBoxSizer21->Add( m_Orient, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); - - wxString m_ShowStrings[] = { - _( "show" ), - _( "no show" ) - }; - m_Show = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _( - "Display" ), wxDefaultPosition, wxDefaultSize, 2, m_ShowStrings, 1, wxRA_SPECIFY_COLS ); - itemBoxSizer21->Add( m_Show, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); - -////@end WinEDA_TextModPropertiesFrame content construction - - /* Setup titles and datas */ - SetDisplayValue(); -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK - */ - -void WinEDA_TextModPropertiesFrame::OnOkClick( wxCommandEvent& event ) -{ - TextModPropertiesAccept( event ); -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL - */ - -void WinEDA_TextModPropertiesFrame::OnCancelClick( wxCommandEvent& event ) -{ -////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_TextModPropertiesFrame. - // Before editing this code, remove the block markers. - event.Skip(); - -////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_TextModPropertiesFrame. -} - - -/*! - * Should we show tooltips? - */ - -bool WinEDA_TextModPropertiesFrame::ShowToolTips() -{ - return true; -} - - -/*! - * Get bitmap resources - */ - -wxBitmap WinEDA_TextModPropertiesFrame::GetBitmapResource( const wxString& name ) -{ - // Bitmap retrieval -////@begin WinEDA_TextModPropertiesFrame bitmap retrieval - wxUnusedVar( name ); - return wxNullBitmap; - -////@end WinEDA_TextModPropertiesFrame bitmap retrieval -} - - -/*! - * Get icon resources - */ - -wxIcon WinEDA_TextModPropertiesFrame::GetIconResource( const wxString& name ) -{ - // Icon retrieval -////@begin WinEDA_TextModPropertiesFrame icon retrieval - wxUnusedVar( name ); - return wxNullIcon; - -////@end WinEDA_TextModPropertiesFrame icon retrieval -} - - -/********************************************************/ -void WinEDA_TextModPropertiesFrame::SetDisplayValue() -/********************************************************/ -{ - wxString msg; - - if( m_Module ) - { - wxString format = m_ModuleInfoText->GetLabel(); - msg.Printf( format, - m_Module->m_Reference->m_Text.GetData(), - m_Module->m_Value->m_Text.GetData(), - (float) (m_Module->m_Orient / 10) ); - m_ModuleInfoText->SetLabel( msg ); - } - - if( m_CurrentTextMod->m_Type == TEXT_is_VALUE ) - m_TextDataTitle->SetLabel( _( "Value:" ) ); - else if( m_CurrentTextMod->m_Type == TEXT_is_DIVERS ) - m_TextDataTitle->SetLabel( _( "Text:" ) ); - else if( m_CurrentTextMod->m_Type != TEXT_is_REFERENCE ) - m_TextDataTitle->SetLabel( wxT( "???" ) ); - - m_Name->SetValue( m_CurrentTextMod->m_Text ); - - AddUnitSymbol( *m_SizeXTitle ); - PutValueInLocalUnits( *m_TxtSizeCtrlX, m_CurrentTextMod->m_Size.x, - m_Parent->m_InternalUnits ); - - AddUnitSymbol( *m_SizeYTitle ); - PutValueInLocalUnits( *m_TxtSizeCtrlY, m_CurrentTextMod->m_Size.y, - m_Parent->m_InternalUnits ); - - AddUnitSymbol( *m_PosXTitle ); - PutValueInLocalUnits( *m_TxtPosCtrlX, m_CurrentTextMod->m_Pos0.x, - m_Parent->m_InternalUnits ); - - AddUnitSymbol( *m_PosYTitle ); - PutValueInLocalUnits( *m_TxtPosCtrlY, m_CurrentTextMod->m_Pos0.y, - m_Parent->m_InternalUnits ); - - AddUnitSymbol( *m_WidthTitle ); - PutValueInLocalUnits( *m_TxtWidthCtlr, m_CurrentTextMod->m_Width, - m_Parent->m_InternalUnits ); - - if( (m_CurrentTextMod->m_Orient != 0) && (m_CurrentTextMod->m_Orient != 1800) - && (m_CurrentTextMod->m_Orient != -1800) ) - m_Orient->SetSelection( 1 );; - - if( m_CurrentTextMod->m_NoShow ) - m_Show->SetSelection( 1 );; -} - - -/*********************************************************************************/ -void WinEDA_TextModPropertiesFrame::TextModPropertiesAccept( wxCommandEvent& event ) -/*********************************************************************************/ -{ - wxString msg; - - m_Parent->SaveCopyInUndoList( m_Parent->m_Pcb->m_Modules ); - if( m_DC ) // Effacement ancien texte - { - m_CurrentTextMod->Draw( m_Parent->DrawPanel, m_DC, GR_XOR, - (m_CurrentTextMod->m_Flags & IS_MOVED) ? MoveVector : wxPoint( 0, 0 ) ); - } - m_CurrentTextMod->m_Text = m_Name->GetValue(); - - msg = m_TxtPosCtrlX->GetValue(); - m_CurrentTextMod->m_Pos0.x = ReturnValueFromString( g_UnitMetric, msg, - m_Parent->m_InternalUnits ); - msg = m_TxtPosCtrlY->GetValue(); - m_CurrentTextMod->m_Pos0.y = ReturnValueFromString( g_UnitMetric, msg, - m_Parent->m_InternalUnits ); - - msg = m_TxtSizeCtrlX->GetValue(); - m_CurrentTextMod->m_Size.x = ReturnValueFromString( g_UnitMetric, msg, - m_Parent->m_InternalUnits ); - msg = m_TxtSizeCtrlY->GetValue(); - m_CurrentTextMod->m_Size.y = ReturnValueFromString( g_UnitMetric, msg, - m_Parent->m_InternalUnits ); - - // Test for a reasonnable size: - if( m_CurrentTextMod->m_Size.x< TEXTS_MIN_SIZE ) - m_CurrentTextMod->m_Size.x = TEXTS_MIN_SIZE; - if( m_CurrentTextMod->m_Size.y< TEXTS_MIN_SIZE ) - m_CurrentTextMod->m_Size.y = TEXTS_MIN_SIZE; - - msg = m_TxtWidthCtlr->GetValue(); - int width = ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits ); - - // Test for a reasonnable width: - if( width <= 1 ) - width = 1; - if( width > TEXTS_MAX_WIDTH ) - width = TEXTS_MAX_WIDTH; - m_CurrentTextMod->SetWidth( width ); - - m_CurrentTextMod->m_NoShow = (m_Show->GetSelection() == 0) ? 0 : 1; - m_CurrentTextMod->m_Orient = (m_Orient->GetSelection() == 0) ? 0 : 900; - m_CurrentTextMod->SetDrawCoord(); - if( m_DC ) // Display new text - { - m_CurrentTextMod->Draw( m_Parent->DrawPanel, m_DC, GR_XOR, - (m_CurrentTextMod->m_Flags & IS_MOVED) ? MoveVector : wxPoint( 0, 0 ) ); - } - m_Parent->GetScreen()->SetModify(); - ( (MODULE*) m_CurrentTextMod->GetParent() )->m_LastEdit_Time = time( NULL ); - Close( TRUE ); -} diff --git a/pcbnew/dialog_edit_mod_text.pjd b/pcbnew/dialog_edit_mod_text.pjd deleted file mode 100644 index 3149d35a2e..0000000000 --- a/pcbnew/dialog_edit_mod_text.pjd +++ /dev/null @@ -1,1488 +0,0 @@ - - -
- 0 - "" - "" - "" - "" - 32 - "" - 0 - 0 - 0 - 1 - 1 - 0 - "jean-pierre Charras" - "License GNU" - "" - 0 - "<All platforms>" - "<Any>" - "///////////////////////////////////////////////////////////////////////////// -// Name: %HEADER-FILENAME% -// Purpose: -// Author: %AUTHOR% -// Modified by: -// Created: %DATE% -// RCS-ID: -// Copyright: %COPYRIGHT% -// Licence: -///////////////////////////////////////////////////////////////////////////// - -" - "///////////////////////////////////////////////////////////////////////////// -// Name: %SOURCE-FILENAME% -// Purpose: -// Author: %AUTHOR% -// Modified by: -// Created: %DATE% -// RCS-ID: -// Copyright: %COPYRIGHT% -// Licence: -///////////////////////////////////////////////////////////////////////////// - -" - " -/*! - * %BODY% - */ - -" - "///////////////////////////////////////////////////////////////////////////// -// Name: %SYMBOLS-FILENAME% -// Purpose: Symbols file -// Author: %AUTHOR% -// Modified by: -// Created: %DATE% -// RCS-ID: -// Copyright: %COPYRIGHT% -// Licence: -///////////////////////////////////////////////////////////////////////////// - -" - "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma interface "%HEADER-FILENAME%" -#endif - -" - "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "%HEADER-FILENAME%" -#endif - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/wx.h" -#endif - -" - "app_resources.h" - "app_resources.cpp" - "AppResources" - "app.h" - "app.cpp" - "Application" - 0 - "" - "<None>" - "<System>" - "<System>" - "" - 0 - 1 - 1 -
- - - "" - "data-document" - "" - "" - 0 - 1 - 0 - 0 - - "Configurations" - "config-data-document" - "" - "" - 0 - 1 - 0 - 0 - "" - 1 - "" - "Debug" - "ANSI" - "Static" - "Modular" - "GUI" - "wxMSW" - "Dynamic" - "Yes" - "No" - "No" - "%WXVERSION%" - "%EXECUTABLE%" - "" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - - - - - - - "Projects" - "root-document" - "" - "project" - 1 - 1 - 0 - 0 - - "Windows" - "html-document" - "" - "dialogsfolder" - 1 - 1 - 0 - 1 - - "TextMod properties" - "dialog-document" - "" - "dialog" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbDialogProxy" - 10000 - 0 - "" - 0 - "ID_DIALOG" - 10000 - "WinEDA_TextModPropertiesFrame" - "wxDialog" - "wxDialog" - "dialog_edit_mod_text.cpp" - "dialog_edit_mod_text.h" - "" - "TextMod properties" - 1 - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - 0 - 1 - 0 - 0 - 1 - 0 - 0 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - "MAYBE_RESIZE_BORDER" - 0 - 1 - -1 - -1 - 400 - 300 - "" - - "wxBoxSizer V" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "wbBoxSizerProxy" - "Vertical" - "" - 0 - 0 - 0 - "<Any platform>" - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "wxStaticText" - "m_ModuleInfoText" - "Module %s (%s) orient %.1f" - "" - "" - "" - "0000FF" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 1 - 0 - "" - "" - - - "wxStaticLine: wxID_STATIC" - "dialog-control-document" - "" - "staticline" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbStaticLineProxy" - "wxID_STATIC" - 5105 - "wxStaticLine" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "wxStaticText" - "m_TextDataTitle" - "Reference:" - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL" - 10003 - "wxTextCtrl" - "m_Name" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - - - "wxBoxSizer H" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbBoxSizerProxy" - "Horizontal" - "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - "wxBoxSizer V" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbBoxSizerProxy" - "Vertical" - "" - "Centre" - "Expand" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "wxStaticText" - "m_SizeXTitle" - "Size X" - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL1" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL1" - 10004 - "wxTextCtrl" - "m_TxtSizeCtrlX" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "wxStaticText" - "m_SizeYTitle" - "Size Y" - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL2" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL2" - 10005 - "wxTextCtrl" - "m_TxtSizeCtrlY" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - - - "Spacer" - "dialog-control-document" - "" - "spacer" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbSpacerProxy" - 5 - 5 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "wxStaticText" - "m_PosXTitle" - "Offset X" - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL3" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL3" - 10006 - "wxTextCtrl" - "m_TxtPosCtrlX" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "wxStaticText" - "m_PosYTitle" - "Offset Y" - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL4" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL4" - 10007 - "wxTextCtrl" - "m_TxtPosCtrlY" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - - - - "wxBoxSizer V" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbBoxSizerProxy" - "Vertical" - "" - "Centre" - "Expand" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "wxStaticText" - "m_WidthTitle" - "Width" - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL5" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL5" - 10008 - "wxTextCtrl" - "m_TxtWidthCtlr" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - - - - "wxBoxSizer V" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbBoxSizerProxy" - "Vertical" - "" - "Centre" - "Expand" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - "wxButton: wxID_OK" - "dialog-control-document" - "" - "dialogcontrol" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbButtonProxy" - "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" - "wxID_OK" - 5100 - "wxButton" - "" - "&OK" - 0 - "" - "" - "" - "C60000" - "" - 0 - 1 - "<Any platform>" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - - - "wxButton: wxID_CANCEL" - "dialog-control-document" - "" - "dialogcontrol" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbButtonProxy" - "wxEVT_COMMAND_BUTTON_CLICKED|OnCancelClick" - "wxID_CANCEL" - 5101 - "wxButton" - "" - "&Cancel" - 0 - "" - "" - "" - "0000FF" - "" - 0 - 1 - "<Any platform>" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - - - "wxRadioBox: ID_RADIOBOX" - "dialog-control-document" - "" - "radiobox" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbRadioBoxProxy" - "ID_RADIOBOX" - 10001 - "wxRadioBox" - "m_Orient" - "Orientation" - 1 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 1 - "horiz|vertical" - 0 - "" - -1 - -1 - -1 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - - - "wxRadioBox: ID_RADIOBOX1" - "dialog-control-document" - "" - "radiobox" - 0 - 1 - 0 - 0 - "9/5/2006" - "wbRadioBoxProxy" - "ID_RADIOBOX1" - 10002 - "wxRadioBox" - "m_Show" - "Display" - 1 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - 0 - 1 - "show|no show" - 0 - "" - -1 - -1 - -1 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - - - - - - - - "Sources" - "html-document" - "" - "sourcesfolder" - 1 - 1 - 0 - 1 - - "dialog_edit_mod_text.rc" - "source-editor-document" - "dialog_edit_mod_text.rc" - "source-editor" - 0 - 0 - 1 - 0 - "9/5/2006" - "" - - - - "Images" - "html-document" - "" - "bitmapsfolder" - 1 - 1 - 0 - 1 - - - - -
diff --git a/pcbnew/dialog_edit_module_text.cpp b/pcbnew/dialog_edit_module_text.cpp new file mode 100644 index 0000000000..894d4b98dd --- /dev/null +++ b/pcbnew/dialog_edit_module_text.cpp @@ -0,0 +1,201 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_edit_module_text.cpp +// Author: jean-pierre Charras +// Licence: GPL +///////////////////////////////////////////////////////////////////////////// + + +#include "fctsys.h" +#include "macros.h" + +#include "common.h" +#include "pcbnew.h" + +#include "dialog_edit_module_text_base.h" + +extern wxPoint MoveVector; // Move vector for move edge, imported from edtxtmod.cpp + +/*************** **************/ +/* class DialogEditModuleText */ +/*************** **************/ +class DialogEditModuleText : public DialogEditModuleText_base +{ +private: + WinEDA_BasePcbFrame* m_Parent; + wxDC* m_DC; + MODULE* m_Module; + TEXTE_MODULE* m_CurrentTextMod; + +public: + DialogEditModuleText( WinEDA_BasePcbFrame* parent, TEXTE_MODULE* TextMod, wxDC* DC ); + ~DialogEditModuleText() {}; + +private: + void OnInitDialog( wxInitDialogEvent& event ); + void OnOkClick( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); +}; + +/***************************************************************************/ +void WinEDA_BasePcbFrame::InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, + wxDC* DC, const wxPoint& pos ) +/***************************************************************************/ +{ + DrawPanel->m_IgnoreMouseEvents = TRUE; + DialogEditModuleText* frame = new DialogEditModuleText( this, + TextMod, DC ); + frame->ShowModal(); frame->Destroy(); + DrawPanel->MouseToCursorSchema(); + DrawPanel->m_IgnoreMouseEvents = FALSE; +} + + +DialogEditModuleText::DialogEditModuleText( WinEDA_BasePcbFrame* parent, + TEXTE_MODULE* TextMod, + wxDC* DC ) : + DialogEditModuleText_base(parent) + +{ + m_Parent = parent; + m_DC = DC; + m_Module = NULL; + m_CurrentTextMod = TextMod; + if( m_CurrentTextMod ) + { + m_Module = (MODULE*) m_CurrentTextMod->GetParent(); + } +} + + +void DialogEditModuleText::OnCancelClick( wxCommandEvent& event ) +{ + event.Skip(); +} + + +/********************************************************/ +void DialogEditModuleText::OnInitDialog( wxInitDialogEvent& event ) +/********************************************************/ +{ + SetFont( *g_DialogFont ); + SetFocus(); + + wxString msg; + + if( m_Module ) + { + wxString format = m_ModuleInfoText->GetLabel(); + msg.Printf( format, + m_Module->m_Reference->m_Text.GetData(), + m_Module->m_Value->m_Text.GetData(), + (float) (m_Module->m_Orient / 10) ); + m_ModuleInfoText->SetLabel( msg ); + } + + if( m_CurrentTextMod->m_Type == TEXT_is_VALUE ) + m_TextDataTitle->SetLabel( _( "Value:" ) ); + else if( m_CurrentTextMod->m_Type == TEXT_is_DIVERS ) + m_TextDataTitle->SetLabel( _( "Text:" ) ); + else if( m_CurrentTextMod->m_Type != TEXT_is_REFERENCE ) + m_TextDataTitle->SetLabel( wxT( "???" ) ); + + m_Name->SetValue( m_CurrentTextMod->m_Text ); + + m_Style->SetSelection( m_CurrentTextMod->m_Italic ? 1 : 0 ); + + AddUnitSymbol( *m_SizeXTitle ); + PutValueInLocalUnits( *m_TxtSizeCtrlX, m_CurrentTextMod->m_Size.x, + m_Parent->m_InternalUnits ); + + AddUnitSymbol( *m_SizeYTitle ); + PutValueInLocalUnits( *m_TxtSizeCtrlY, m_CurrentTextMod->m_Size.y, + m_Parent->m_InternalUnits ); + + AddUnitSymbol( *m_PosXTitle ); + PutValueInLocalUnits( *m_TxtPosCtrlX, m_CurrentTextMod->m_Pos0.x, + m_Parent->m_InternalUnits ); + + AddUnitSymbol( *m_PosYTitle ); + PutValueInLocalUnits( *m_TxtPosCtrlY, m_CurrentTextMod->m_Pos0.y, + m_Parent->m_InternalUnits ); + + AddUnitSymbol( *m_WidthTitle ); + PutValueInLocalUnits( *m_TxtWidthCtlr, m_CurrentTextMod->m_Width, + m_Parent->m_InternalUnits ); + + int text_orient = m_CurrentTextMod->m_Orient; + NORMALIZE_ANGLE_90(text_orient) + if( (text_orient != 0) ) + m_Orient->SetSelection( 1 ); + + if( m_CurrentTextMod->m_NoShow ) + m_Show->SetSelection( 1 );; + + GetSizer()->Fit( this ); + GetSizer()->SetSizeHints( this ); +} + + +/*********************************************************************************/ +void DialogEditModuleText::OnOkClick( wxCommandEvent& event ) +/*********************************************************************************/ +{ + wxString msg; + + m_Parent->SaveCopyInUndoList( m_Parent->m_Pcb->m_Modules ); + if( m_DC ) //Erase old text on screen + { + m_CurrentTextMod->Draw( m_Parent->DrawPanel, m_DC, GR_XOR, + (m_CurrentTextMod->m_Flags & IS_MOVED) ? MoveVector : wxPoint( 0, 0 ) ); + } + m_CurrentTextMod->m_Text = m_Name->GetValue(); + + m_CurrentTextMod->m_Italic = m_Style->GetSelection() == 1 ? true : false; + + + msg = m_TxtPosCtrlX->GetValue(); + m_CurrentTextMod->m_Pos0.x = ReturnValueFromString( g_UnitMetric, msg, + m_Parent->m_InternalUnits ); + msg = m_TxtPosCtrlY->GetValue(); + m_CurrentTextMod->m_Pos0.y = ReturnValueFromString( g_UnitMetric, msg, + m_Parent->m_InternalUnits ); + + msg = m_TxtSizeCtrlX->GetValue(); + m_CurrentTextMod->m_Size.x = ReturnValueFromString( g_UnitMetric, msg, + m_Parent->m_InternalUnits ); + msg = m_TxtSizeCtrlY->GetValue(); + m_CurrentTextMod->m_Size.y = ReturnValueFromString( g_UnitMetric, msg, + m_Parent->m_InternalUnits ); + + // Test for a reasonnable size: + if( m_CurrentTextMod->m_Size.x< TEXTS_MIN_SIZE ) + m_CurrentTextMod->m_Size.x = TEXTS_MIN_SIZE; + if( m_CurrentTextMod->m_Size.y< TEXTS_MIN_SIZE ) + m_CurrentTextMod->m_Size.y = TEXTS_MIN_SIZE; + + msg = m_TxtWidthCtlr->GetValue(); + int width = ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits ); + + // Test for a reasonnable width: + if( width <= 1 ) + width = 1; + int minthickness = min(m_CurrentTextMod->m_Size.x, m_CurrentTextMod->m_Size.y) / 4; + if( width > minthickness ) + width = minthickness; + m_CurrentTextMod->SetWidth( width ); + + m_CurrentTextMod->m_NoShow = (m_Show->GetSelection() == 0) ? 0 : 1; + int text_orient = (m_Orient->GetSelection() == 0) ? 0 : 900; + m_CurrentTextMod->m_Orient = text_orient; + + m_CurrentTextMod->SetDrawCoord(); + if( m_DC ) // Display new text + { + m_CurrentTextMod->Draw( m_Parent->DrawPanel, m_DC, GR_XOR, + (m_CurrentTextMod->m_Flags & IS_MOVED) ? MoveVector : wxPoint( 0, 0 ) ); + } + m_Parent->GetScreen()->SetModify(); + ( (MODULE*) m_CurrentTextMod->GetParent() )->m_LastEdit_Time = time( NULL ); + + Close( TRUE ); +} diff --git a/pcbnew/dialog_edit_mod_text.h b/pcbnew/dialog_edit_module_text.h similarity index 100% rename from pcbnew/dialog_edit_mod_text.h rename to pcbnew/dialog_edit_module_text.h diff --git a/pcbnew/dialog_edit_module_text_base.cpp b/pcbnew/dialog_edit_module_text_base.cpp new file mode 100644 index 0000000000..432e989e86 --- /dev/null +++ b/pcbnew/dialog_edit_module_text_base.cpp @@ -0,0 +1,135 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 16 2008) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_edit_module_text_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DialogEditModuleText_base::DialogEditModuleText_base( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bMainSizer; + bMainSizer = new wxBoxSizer( wxVERTICAL ); + + m_ModuleInfoText = new wxStaticText( this, wxID_ANY, _("Module %s (%s) orient %.1f"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ModuleInfoText->Wrap( -1 ); + bMainSizer->Add( m_ModuleInfoText, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bMainSizer->Add( m_staticline1, 0, wxALL|wxEXPAND, 5 ); + + m_TextDataTitle = new wxStaticText( this, wxID_ANY, _("Reference:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_TextDataTitle->Wrap( -1 ); + bMainSizer->Add( m_TextDataTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_Name = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bMainSizer->Add( m_Name, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + wxBoxSizer* bSizer2; + bSizer2 = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bSizer3; + bSizer3 = new wxBoxSizer( wxVERTICAL ); + + m_SizeXTitle = new wxStaticText( this, wxID_ANY, _("Size X"), wxDefaultPosition, wxDefaultSize, 0 ); + m_SizeXTitle->Wrap( -1 ); + bSizer3->Add( m_SizeXTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_TxtSizeCtrlX = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer3->Add( m_TxtSizeCtrlX, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + m_SizeYTitle = new wxStaticText( this, wxID_ANY, _("Size Y"), wxDefaultPosition, wxDefaultSize, 0 ); + m_SizeYTitle->Wrap( -1 ); + bSizer3->Add( m_SizeYTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_TxtSizeCtrlY = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer3->Add( m_TxtSizeCtrlY, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + m_PosXTitle = new wxStaticText( this, wxID_ANY, _("Offset X"), wxDefaultPosition, wxDefaultSize, 0 ); + m_PosXTitle->Wrap( -1 ); + bSizer3->Add( m_PosXTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_TxtPosCtrlX = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer3->Add( m_TxtPosCtrlX, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + m_PosYTitle = new wxStaticText( this, wxID_ANY, _("Offset Y"), wxDefaultPosition, wxDefaultSize, 0 ); + m_PosYTitle->Wrap( -1 ); + bSizer3->Add( m_PosYTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_TxtPosCtrlY = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer3->Add( m_TxtPosCtrlY, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + bSizer2->Add( bSizer3, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxVERTICAL ); + + m_WidthTitle = new wxStaticText( this, wxID_ANY, _("Thickness"), wxDefaultPosition, wxDefaultSize, 0 ); + m_WidthTitle->Wrap( -1 ); + bSizer4->Add( m_WidthTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_TxtWidthCtlr = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer4->Add( m_TxtWidthCtlr, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + wxString m_OrientChoices[] = { _("horizontal"), _("vertical") }; + int m_OrientNChoices = sizeof( m_OrientChoices ) / sizeof( wxString ); + m_Orient = new wxRadioBox( this, wxID_ANY, _("Orientation"), wxDefaultPosition, wxDefaultSize, m_OrientNChoices, m_OrientChoices, 1, wxRA_SPECIFY_COLS ); + m_Orient->SetSelection( 0 ); + bSizer4->Add( m_Orient, 0, wxALL|wxEXPAND, 5 ); + + wxString m_ShowChoices[] = { _("Visible"), _("Invisible") }; + int m_ShowNChoices = sizeof( m_ShowChoices ) / sizeof( wxString ); + m_Show = new wxRadioBox( this, wxID_ANY, _("Display"), wxDefaultPosition, wxDefaultSize, m_ShowNChoices, m_ShowChoices, 1, wxRA_SPECIFY_COLS ); + m_Show->SetSelection( 0 ); + bSizer4->Add( m_Show, 0, wxALL|wxEXPAND, 5 ); + + bSizer2->Add( bSizer4, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer5; + bSizer5 = new wxBoxSizer( wxVERTICAL ); + + wxString m_StyleChoices[] = { _("Normal"), _("Italic") }; + int m_StyleNChoices = sizeof( m_StyleChoices ) / sizeof( wxString ); + m_Style = new wxRadioBox( this, wxID_ANY, _("Style"), wxDefaultPosition, wxDefaultSize, m_StyleNChoices, m_StyleChoices, 1, wxRA_SPECIFY_COLS ); + m_Style->SetSelection( 0 ); + bSizer5->Add( m_Style, 0, wxALL|wxEXPAND, 5 ); + + + bSizer5->Add( 10, 10, 0, 0, 5 ); + + m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonOK->SetDefault(); + m_buttonOK->SetForegroundColour( wxColour( 202, 0, 0 ) ); + + bSizer5->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_buttonCANCEL = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonCANCEL->SetForegroundColour( wxColour( 0, 0, 220 ) ); + + bSizer5->Add( m_buttonCANCEL, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + bSizer2->Add( bSizer5, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + bMainSizer->Add( bSizer2, 1, wxEXPAND, 5 ); + + this->SetSizer( bMainSizer ); + this->Layout(); + + // Connect Events + this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DialogEditModuleText_base::OnInitDialog ) ); + m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogEditModuleText_base::OnOkClick ), NULL, this ); + m_buttonCANCEL->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogEditModuleText_base::OnCancelClick ), NULL, this ); +} + +DialogEditModuleText_base::~DialogEditModuleText_base() +{ + // Disconnect Events + this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DialogEditModuleText_base::OnInitDialog ) ); + m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogEditModuleText_base::OnOkClick ), NULL, this ); + m_buttonCANCEL->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogEditModuleText_base::OnCancelClick ), NULL, this ); +} diff --git a/pcbnew/dialog_edit_module_text_base.fbp b/pcbnew/dialog_edit_module_text_base.fbp new file mode 100644 index 0000000000..1dd570f3e8 --- /dev/null +++ b/pcbnew/dialog_edit_module_text_base.fbp @@ -0,0 +1,1137 @@ + + + + + + C++ + 1 + UTF-8 + connect + dialog_edit_module_text_base + 1000 + none + 1 + DialogEditModuleText_base + + . + + 1 + 1 + 0 + + + + + 1 + + + + 0 + wxID_ANY + + + DialogEditModuleText_base + + 357,299 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + + Footprint text properties + + + + + + + + + + + + + + OnInitDialog + + + + + + + + + + + + + + + + + + + + + + + bMainSizer + wxVERTICAL + none + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + + + 1 + + + 0 + wxID_ANY + Module %s (%s) orient %.1f + + + m_ModuleInfoText + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + + + m_staticline1 + protected + + + wxLI_HORIZONTAL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + Reference: + + + m_TextDataTitle + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_Name + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer2 + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bSizer3 + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + Size X + + + m_SizeXTitle + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_TxtSizeCtrlX + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + Size Y + + + m_SizeYTitle + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_TxtSizeCtrlY + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + Offset X + + + m_PosXTitle + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_TxtPosCtrlX + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + Offset Y + + + m_PosYTitle + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_TxtPosCtrlY + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer4 + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + Thickness + + + m_WidthTitle + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_TxtWidthCtlr + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "horizontal" "vertical" + + 1 + + + 0 + wxID_ANY + Orientation + 1 + + + m_Orient + protected + + 0 + + wxRA_SPECIFY_COLS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "Visible" "Invisible" + + 1 + + + 0 + wxID_ANY + Display + 1 + + + m_Show + protected + + 0 + + wxRA_SPECIFY_COLS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 + + + bSizer5 + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + + "Normal" "Italic" + + 1 + + + 0 + wxID_ANY + Style + 1 + + + m_Style + protected + + 0 + + wxRA_SPECIFY_COLS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + 0 + + 10 + protected + 10 + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + + + 1 + 1 + 202,0,0 + + 0 + wxID_OK + OK + + + m_buttonOK + protected + + + + + + + + + OnOkClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + + + 0 + 1 + 0,0,220 + + 0 + wxID_CANCEL + Cancel + + + m_buttonCANCEL + protected + + + + + + + + + OnCancelClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialog_edit_module_text_base.h b/pcbnew/dialog_edit_module_text_base.h new file mode 100644 index 0000000000..7ff590f1d8 --- /dev/null +++ b/pcbnew/dialog_edit_module_text_base.h @@ -0,0 +1,69 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 16 2008) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __dialog_edit_module_text_base__ +#define __dialog_edit_module_text_base__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class DialogEditModuleText_base +/////////////////////////////////////////////////////////////////////////////// +class DialogEditModuleText_base : public wxDialog +{ + private: + + protected: + wxStaticText* m_ModuleInfoText; + wxStaticLine* m_staticline1; + wxStaticText* m_TextDataTitle; + wxTextCtrl* m_Name; + wxStaticText* m_SizeXTitle; + wxTextCtrl* m_TxtSizeCtrlX; + wxStaticText* m_SizeYTitle; + wxTextCtrl* m_TxtSizeCtrlY; + wxStaticText* m_PosXTitle; + wxTextCtrl* m_TxtPosCtrlX; + wxStaticText* m_PosYTitle; + wxTextCtrl* m_TxtPosCtrlY; + wxStaticText* m_WidthTitle; + wxTextCtrl* m_TxtWidthCtlr; + wxRadioBox* m_Orient; + wxRadioBox* m_Show; + wxRadioBox* m_Style; + + wxButton* m_buttonOK; + wxButton* m_buttonCANCEL; + + // Virtual event handlers, overide them in your derived class + virtual void OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); } + virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); } + + + public: + DialogEditModuleText_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Footprint text properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 357,299 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DialogEditModuleText_base(); + +}; + +#endif //__dialog_edit_module_text_base__ diff --git a/pcbnew/gen_drill_report_files.cpp b/pcbnew/gen_drill_report_files.cpp index beff09151d..493d6c88de 100644 --- a/pcbnew/gen_drill_report_files.cpp +++ b/pcbnew/gen_drill_report_files.cpp @@ -232,10 +232,11 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, w case PLOT_FORMAT_POST: wxString Text = wxT( "Infos" ); - Plot_1_texte( format, Text, 0, TextWidth, - x, y, - (int) (CharSize * CharScale), (int) (CharSize * CharScale), - FALSE ); + PlotGraphicText( format, wxPoint(x,y), BLACK, + Text, + 0, wxSize((int)(CharSize * CharScale), (int)(CharSize * CharScale)), + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + TextWidth ); break; } @@ -335,11 +336,11 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, w aToolListBuffer[ii].m_TotalCount, aToolListBuffer[ii].m_OvalCount ); msg += CONV_FROM_UTF8( line ); - Plot_1_texte( format, msg, 0, TextWidth, - x, y, - (int) (CharSize * CharScale), - (int) (CharSize * CharScale), - FALSE ); + PlotGraphicText( format, wxPoint(x,y), BLACK, + msg, + 0, wxSize((int)(CharSize * CharScale), (int)(CharSize * CharScale)), + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + TextWidth ); break; } diff --git a/pcbnew/makefile.include b/pcbnew/makefile.include index 84573dd66f..0236d24cc1 100644 --- a/pcbnew/makefile.include +++ b/pcbnew/makefile.include @@ -92,7 +92,8 @@ OBJECTS= $(TARGET).o classpcb.o\ globaleditpad.o \ editedge.o\ edtxtmod.o \ - dialog_edit_mod_text.o\ + dialog_edit_module_text.o\ + dialog_edit_module_text_base.o\ ratsnest.o drc.o \ block.o\ clean.o \ @@ -243,7 +244,9 @@ cotation.o: cotation.cpp edtxtmod.o: edtxtmod.cpp -dialog_edit_mod_text.o: dialog_edit_mod_text.cpp dialog_edit_mod_text.h +dialog_edit_module_text.o: dialog_edit_module_text.cpp dialog_edit_module_text_base.h + +dialog_edit_module_text_base.o: dialog_edit_module_text_base.cpp dialog_edit_module_text_base.h ratsnest.o: ratsnest.cpp @@ -259,7 +262,7 @@ pcbplot.o: pcbplot.cpp pcbplot.h plothpgl.o: plothpgl.cpp -plotgerb.o: plotgerb.cpp pcbplot.h plotgerb.h +plotgerb.o: plotgerb.cpp pcbplot.h plotps.o: plotps.cpp pcbplot.h diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index 0822443a0c..e34c339ea5 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -420,8 +420,8 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC ) pt_texte->m_Pos.y -= Module->m_Pos.y; pt_texte->m_Pos.y = -pt_texte->m_Pos.y; pt_texte->m_Pos.y += Module->m_Pos.y; - pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; - pt_texte->m_Miroir = false; + pt_texte->m_Pos0.y = -pt_texte->m_Pos0.y; + pt_texte->m_Mirror = false; NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient ); pt_texte->SetLayer( Module->GetLayer() ); pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) ); @@ -434,15 +434,15 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC ) if( (Module->GetLayer() == SILKSCREEN_N_CU) || (Module->GetLayer() == ADHESIVE_N_CU) || (Module->GetLayer() == COPPER_LAYER_N) ) - pt_texte->m_Miroir = true; + pt_texte->m_Mirror = true; /* Inversion miroir de la Valeur et mise en miroir : */ pt_texte = Module->m_Value; pt_texte->m_Pos.y -= Module->m_Pos.y; pt_texte->m_Pos.y = -pt_texte->m_Pos.y; pt_texte->m_Pos.y += Module->m_Pos.y; - pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; - pt_texte->m_Miroir = false; + pt_texte->m_Pos0.y = -pt_texte->m_Pos0.y; + pt_texte->m_Mirror = false; NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient ); pt_texte->SetLayer( Module->GetLayer() ); pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) ); @@ -455,7 +455,7 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC ) if( (Module->GetLayer() == SILKSCREEN_N_CU) || (Module->GetLayer() == ADHESIVE_N_CU) || (Module->GetLayer() == COPPER_LAYER_N) ) - pt_texte->m_Miroir = true; + pt_texte->m_Mirror = true; /* Inversion miroir des dessins de l'empreinte : */ PtStruct = Module->m_Drawings; @@ -488,8 +488,8 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC ) pt_texte->m_Pos.y -= Module->m_Pos.y; pt_texte->m_Pos.y = -pt_texte->m_Pos.y; pt_texte->m_Pos.y += Module->m_Pos.y; - pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; - pt_texte->m_Miroir = false; + pt_texte->m_Pos0.y = - pt_texte->m_Pos0.y; + pt_texte->m_Mirror = false; NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient ); pt_texte->SetLayer( Module->GetLayer() ); @@ -505,7 +505,7 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC ) || Module->GetLayer() == ADHESIVE_N_CU || Module->GetLayer() == COPPER_LAYER_N ) { - pt_texte->m_Miroir = true; + pt_texte->m_Mirror = true; } break; diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h index f6ab3e949e..dc15a049d7 100644 --- a/pcbnew/pcbplot.h +++ b/pcbnew/pcbplot.h @@ -123,36 +123,15 @@ eda_global int g_DrillShapeOpt #define GERB_OVALE 4 #define GERB_DONUT 5 -/* liste des D_CODES en fonction de leur numero d'ordre (numero d'outil) - (l'ordre 0 n'est pas utilise) ; - Tools have D_CODES >= 10 - D_CODES <= 9 are used for commands only: - D01 ... D9 = command codes for photo plotting: - D01 = Light on - D02 = Light off - D03 = Flash - D04 .. D08 = ? - D09 = VAPE Flash -*/ - - - /* Routines generales de trace : */ - - /* PLOT_RTN.CC */ void PlotTextePcb( TEXTE_PCB * pt_texte,int format_plot,int masque_layer); /* Trace 1 Texte type PCB , c.a.d autre que les textes sur modules, - prepare les parametres de trace de Plot_1_texte */ + prepare les parametres de trace de texte */ void PlotArc(int format_plot, wxPoint centre, int start_angle,int end_angle, int rayon,int width); void PlotCircle(int format_plot,int width, wxPoint centre, int rayon); void PlotFilledPolygon(int format_plot, int nbpoints, int * coord); void PlotPolygon(int format_plot, int nbpoints, int * coord, int width); -void Plot_1_texte( int format_plot, - const wxString & Text, int t_orient, - int width, int ox,int oy,int size_h,int size_v, - bool centreX = TRUE, bool centreY = TRUE); - /* Routine de base de trace de 1 chaine de caracteres */ void PlotDrawSegment( DRAWSEGMENT* PtSegm, int format_plot,int masque_layer ); @@ -165,10 +144,7 @@ void Plot_1_EdgeModule(int format_plot, EDGE_MODULE * PtEdge); void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat); /* PLOTGERB.CPP */ -void PlotGERBERLine(wxPoint start, wxPoint end, int width); -void PlotCircle_GERBER( wxPoint centre, int rayon, int width); -void PlotFilledPolygon_GERBER(int nb_segm, int * coord); -void PlotPolygon_GERBER(int nb_segm, int * coord, int width); +void SelectD_CODE_For_LineDraw( int aSize ); void trace_1_contour_GERBER(wxPoint pos, wxSize size, wxSize delta, int penwidth, int orient); /* Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque diff --git a/pcbnew/plot_rtn.cpp b/pcbnew/plot_rtn.cpp index 891925dbd0..0d02a36cb8 100644 --- a/pcbnew/plot_rtn.cpp +++ b/pcbnew/plot_rtn.cpp @@ -5,7 +5,6 @@ /* Fichier PLOT_RTN.CPP*/ #include "fctsys.h" -#include "gr_basic.h" #include "common.h" #include "plot_common.h" @@ -13,14 +12,10 @@ #include "pcbplot.h" #include "trigo.h" -#include "grfonte.h" - -#include "protos.h" - /* Fonctions locales */ static void Plot_Edges_Modules( BOARD* pcb, int format_plot, int masque_layer ); -static void PlotTextModule( TEXTE_MODULE* pt_texte ); +static void PlotTextModule( TEXTE_MODULE* pt_texte, int format_plot ); /**********************************************************/ @@ -247,7 +242,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, /* Trace effectif des textes */ if( trace_ref ) { - PlotTextModule( Module->m_Reference ); + PlotTextModule( Module->m_Reference, format_plot ); nb_items++; msg.Printf( wxT( "%d" ), nb_items ); Affiche_1_Parametre( this, 64, wxEmptyString, msg, LIGHTBLUE ); @@ -255,7 +250,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, if( trace_val ) { - PlotTextModule( Module->m_Value ); + PlotTextModule( Module->m_Value, format_plot ); nb_items++; msg.Printf( wxT( "%d" ), nb_items ); Affiche_1_Parametre( this, 64, wxEmptyString, msg, LIGHTBLUE ); @@ -287,7 +282,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, if( !( (1<m_Size; @@ -322,17 +317,21 @@ static void PlotTextModule( TEXTE_MODULE* pt_texte ) orient = pt_texte->GetDrawRotation(); - no_miroir = pt_texte->m_Miroir & 1; thickness = pt_texte->m_Width; if( Plot_Mode == FILAIRE ) thickness = g_PlotLine_Width; - if( no_miroir == 0 ) + if( pt_texte->m_Mirror ) size.x = -size.x; // Text is mirrored - Plot_1_texte( g_PlotFormat, pt_texte->m_Text, - orient, thickness, - pos.x, pos.y, size.x, size.y ); + if ( format_plot == PLOT_FORMAT_GERBER ) + SelectD_CODE_For_LineDraw(thickness); + + PlotGraphicText( format_plot, pos, BLACK, + pt_texte->m_Text, + orient, size, + pt_texte->m_HJustify, pt_texte->m_VJustify, + thickness, pt_texte->m_Italic ); } @@ -347,8 +346,6 @@ void PlotCotation( COTATION* Cotation, int format_plot, int masque_layer ) DrawTmp = new DRAWSEGMENT( NULL ); -// (Following command has been superceded by new commands elsewhere.) -// masque_layer |= EDGE_LAYER; DrawTmp->m_Width = Cotation->m_Width; DrawTmp->SetLayer( Cotation->GetLayer() ); @@ -398,8 +395,6 @@ void PlotMirePcb( MIREPCB* Mire, int format_plot, int masque_layer ) DrawTmp = new DRAWSEGMENT( NULL ); -// (Following command has been superceded by new commands elsewhere.) -// masque_layer |= EDGE_LAYER; DrawTmp->m_Width = Mire->m_Width; DrawTmp->SetLayer( Mire->GetLayer() ); @@ -581,136 +576,17 @@ void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer ) if( pt_texte->m_Mirror ) size.x = -size.x; - Plot_1_texte( format_plot, pt_texte->m_Text, orient, - thickness, pos.x, pos.y, size.x, size.y ); + if ( format_plot == PLOT_FORMAT_GERBER ) + SelectD_CODE_For_LineDraw(thickness); + + PlotGraphicText( format_plot, pos, BLACK, + pt_texte->m_Text, + orient, size, + pt_texte->m_HJustify, pt_texte->m_VJustify, + thickness, pt_texte->m_Italic ); } -/**********************************************************************/ -void Plot_1_texte( int format_plot, const wxString& Text, int angle, - int thickness, int cX, int cY, int size_h, int size_v, - bool centreX, bool centreY ) -/***********************************************************************/ - -/* - * Trace de 1 texte: - * ptr = pointeur sur le texte - * angle = angle d'orientation, dependant aussi du mode de trace (miroir..) - * cX, cY = position du centre du texte - * size_h , size_v = dimensions ( algebriques ); - */ -{ - int kk = 0, k1, k2, end; - int espacement; - char f_cod, plume; - const SH_CODE* ptcar; - int ox, oy, fx, fy; /* Coord de debut et fin des segments a tracer */ - int sx, sy; /* coord du debut du caractere courant */ - int nbcodes = Text.Len(); - - espacement = ( (10 * size_h) / 9 ) + ( (size_h >= 0 ) ? thickness : -thickness ); - - /* calcul de la position du debut du texte */ - if( centreX ) - sx = cX - ( (espacement * nbcodes) / 2 ); - else - sx = cX; - if( centreY ) - sy = cY + (size_v / 2); - else - sy = cY; - - /* trace du texte */ - for( ; kk < nbcodes; kk++ ) - { -#if defined(wxUSE_UNICODE) && defined(KICAD_CYRILLIC) - int code = Text.GetChar(kk) & 0x7FF; - if ( code > 0x40F && code < 0x450 ) // big small Cyr - code = utf8_to_ascii[code - 0x410] & 0xFF; - else - code = code & 0xFF; -#else - int code = Text.GetChar( kk ) & 0xFF; -#endif - ptcar = graphic_fonte_shape[code]; /* ptcar pointe la description - * du caractere a dessiner */ - - plume = 'U'; - ox = sx; - oy = sy; - - RotatePoint( &ox, &oy, cX, cY, angle ); - fx = ox; fy = oy; - - for( end = 0; end == 0; ptcar++ ) - { - f_cod = *ptcar; - - /* get code n de la forme selectionnee */ - switch( f_cod ) - { - case 'X': - end = 1; /* fin du caractere */ - break; - - case 'U': - case 'D': - plume = f_cod; break; - - default: - k1 = f_cod; // Coord X - k1 = (k1 * size_v) / 9; - ptcar++; - k2 = *ptcar; // Coord Y - k2 = (k2 * size_h) / 8; - - fx = k2 + sx; fy = -k1 + sy; - RotatePoint( &fx, &fy, cX, cY, angle ); - - /* Trace du segment */ - if( plume == 'D' ) - { - switch( format_plot ) - { - case PLOT_FORMAT_GERBER: - PlotGERBERLine( wxPoint( ox, oy ), wxPoint( fx, fy ), thickness ); - break; - - case PLOT_FORMAT_HPGL: - trace_1_segment_HPGL( ox, oy, fx, fy, thickness ); - break; - - case PLOT_FORMAT_POST: - PlotFilledSegmentPS( wxPoint( ox, oy ), wxPoint( fx, fy ), thickness ); - break; - } - } - ox = fx; oy = fy; - } - - /* fin switch decodade matrice de forme */ - } - - /* end boucle for = end trace de 1 caractere */ - - sx += espacement; - } - - /* end trace du texte */ -} - - -/***********************************/ -void Affiche_erreur( int nb_err ) -/***********************************/ - -/* Affiche le nombre d'erreurs commises ( segments traces avec plume trop grosse - * ou autres */ -{ -// sprintf(msg,"%d",nb_err) ; -// Affiche_1_Parametre(this, 30,"Err",msg,GREEN) ; -} - /*********************************************************/ void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat ) /*********************************************************/ @@ -835,6 +711,7 @@ void PlotCircle( int format_plot, int thickness, wxPoint centre, int radius ) switch( format_plot ) { case PLOT_FORMAT_GERBER: + SelectD_CODE_For_LineDraw(thickness); PlotCircle_GERBER( centre, radius, thickness ); break; @@ -878,6 +755,7 @@ void PlotPolygon( int format_plot, int nbpoints, int* coord, int width ) switch( format_plot ) { case PLOT_FORMAT_GERBER: + SelectD_CODE_For_LineDraw(width); PlotPolygon_GERBER( nbpoints, coord, width ); break; @@ -933,6 +811,9 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle, RotatePoint( &ox, &oy, start_angle ); + if ( format_plot == PLOT_FORMAT_GERBER ) + SelectD_CODE_For_LineDraw(thickness); + delta = 120; /* un cercle sera trace en 3600/delta = 30 segments / cercle*/ for( ii = start_angle + delta; ii < end_angle; ii += delta ) { @@ -944,7 +825,7 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle, switch( format_plot ) { case PLOT_FORMAT_GERBER: - PlotGERBERLine( wxPoint( centre.x + ox, centre.y + oy ), + PlotGERBERLine( wxPoint( centre.x + ox, centre.y + oy ), wxPoint( centre.x + fx, centre.y + fy ), thickness ); break; diff --git a/pcbnew/plotgerb.cpp b/pcbnew/plotgerb.cpp index 5d796b25d3..2a9ef5d01f 100644 --- a/pcbnew/plotgerb.cpp +++ b/pcbnew/plotgerb.cpp @@ -9,9 +9,25 @@ #include "pcbnew.h" #include "pcbplot.h" #include "trigo.h" -#include "plotgerb.h" -#include "protos.h" +/* Structure de Description d'un D_CODE GERBER : */ +#define FIRST_DCODE_VALUE 10 + +class D_CODE +{ +public: + D_CODE* m_Pnext, * m_Pback; /* for a linked list */ + wxSize m_Size; /* horiz and Vert size*/ + int m_Type; /* Type ( Line, rect , circulaire , ovale .. ); -1 = not used (free) descr */ + int m_NumDcode; /* code number ( >= 10 ); 0 = not in use */ + + D_CODE() + { + m_Pnext = m_Pback = NULL; + m_Type = -1; + m_NumDcode = 0; + } +}; /* Variables locales : */ @@ -22,19 +38,20 @@ wxString GerberFullFileName; static double scale_x, scale_y; // echelles de convertion en X et Y (compte tenu // des unites relatives du PCB et des traceurs static bool ShowDcodeError = TRUE; +static void CloseFileGERBER( void ); +static int Gen_D_CODE_File( FILE* penfile ); /* Routines Locales */ -static void Init_Trace_GERBER( WinEDA_BasePcbFrame* frame, FILE* gerbfile ); -static void Init_ApertureList(); -static void Fin_Trace_GERBER( WinEDA_BasePcbFrame* frame, FILE* gerbfile ); -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 PlotRectangularPad_GERBER( wxPoint pos, wxSize size, int orient ); +static void Init_ApertureList(); +static void CloseFileGERBER(); +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 PlotRectangularPad_GERBER( wxPoint pos, wxSize size, int orient ); -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, - int orient, int modetrace ); +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, + int orient, int modetrace ); /********************************************************************************/ @@ -67,15 +84,15 @@ void WinEDA_BasePcbFrame::Genere_GERBER( const wxString& FullFileName, int Layer if( PlotOriginIsAuxAxis ) g_PlotOffset = m_Auxiliary_Axis_Position; - dest = wxFopen( FullFileName, wxT( "wt" ) ); - if( dest == NULL ) + g_Plot_PlotOutputFile = wxFopen( FullFileName, wxT( "wt" ) ); + if( g_Plot_PlotOutputFile == NULL ) { wxString msg = _( "unable to create file " ) + FullFileName; DisplayError( this, msg ); return; } - SetLocaleTo_C_standard( ); + SetLocaleTo_C_standard(); InitPlotParametresGERBER( g_PlotOffset, scale_x, scale_y ); @@ -84,7 +101,9 @@ void WinEDA_BasePcbFrame::Genere_GERBER( const wxString& FullFileName, int Layer Affiche_1_Parametre( this, 0, _( "File" ), FullFileName, CYAN ); - Init_Trace_GERBER( this, dest ); + s_Last_D_code = 0; + + Write_Header_GERBER( g_Main_Title, g_Plot_PlotOutputFile ); nb_plot_erreur = 0; @@ -113,7 +132,7 @@ void WinEDA_BasePcbFrame::Genere_GERBER( const wxString& FullFileName, int Layer case LAYER_N_14: case LAYER_N_15: case LAST_COPPER_LAYER: - Plot_Layer_GERBER( dest, layer_mask, 0, 1 ); + Plot_Layer_GERBER( g_Plot_PlotOutputFile, layer_mask, 0, 1 ); break; case SOLDERMASK_N_CU: @@ -122,21 +141,21 @@ void WinEDA_BasePcbFrame::Genere_GERBER( const wxString& FullFileName, int Layer tracevia = 1; else tracevia = 0; - Plot_Layer_GERBER( dest, layer_mask, g_DesignSettings.m_MaskMargin, tracevia ); + Plot_Layer_GERBER( g_Plot_PlotOutputFile, layer_mask, g_DesignSettings.m_MaskMargin, tracevia ); break; case SOLDERPASTE_N_CU: case SOLDERPASTE_N_CMP: /* Trace du masque de pate de soudure */ - Plot_Layer_GERBER( dest, layer_mask, 0, 0 ); + Plot_Layer_GERBER( g_Plot_PlotOutputFile, layer_mask, 0, 0 ); break; default: - Plot_Serigraphie( PLOT_FORMAT_GERBER, dest, layer_mask ); + Plot_Serigraphie( PLOT_FORMAT_GERBER, g_Plot_PlotOutputFile, layer_mask ); break; } - Fin_Trace_GERBER( this, dest ); - SetLocaleTo_Default( ); + CloseFileGERBER(); + SetLocaleTo_Default(); } @@ -262,7 +281,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, trace_1_pad_TRAPEZE_GERBER( pos, size, delta, PtPad->m_Orient, FILLED ); } - break; + break; case PAD_RECT: default: @@ -325,6 +344,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, pos = track->m_Start; end = track->m_End; + SelectD_CODE_For_LineDraw( size.x ); PlotGERBERLine( pos, end, size.x ); nb_items++; @@ -348,6 +368,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, pos = track->m_Start; end = track->m_End; + SelectD_CODE_For_LineDraw( size.x ); PlotGERBERLine( pos, end, size.x ); nb_items++; @@ -358,10 +379,10 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, /* Plot filled ares */ for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) { - ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii); - if( ( (1 << edge_zone->GetLayer()) & masque_layer ) == 0 ) + ZONE_CONTAINER* edge_zone = m_Pcb->GetArea( ii ); + if( ( ( 1 << edge_zone->GetLayer() ) & masque_layer ) == 0 ) continue; - PlotFilledAreas(edge_zone, PLOT_FORMAT_GERBER); + PlotFilledAreas( edge_zone, PLOT_FORMAT_GERBER ); } } @@ -378,7 +399,7 @@ void trace_1_pastille_OVALE_GERBER( wxPoint pos, wxSize size, int orient ) */ { D_CODE* dcode_ptr; - char cbuf[256]; + char cbuf[256]; int x0, y0, x1, y1, delta; if( orient == 900 || orient == 2700 ) /* orient tournee de 90 deg */ @@ -394,11 +415,11 @@ void trace_1_pastille_OVALE_GERBER( wxPoint pos, wxSize size, int orient ) if( dcode_ptr->m_NumDcode != s_Last_D_code ) { sprintf( cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode ); - fputs( cbuf, dest ); + fputs( cbuf, g_Plot_PlotOutputFile ); s_Last_D_code = dcode_ptr->m_NumDcode; } sprintf( cbuf, "X%5.5dY%5.5dD03*\n", pos.x, pos.y ); - fputs( cbuf, dest ); + fputs( cbuf, g_Plot_PlotOutputFile ); } else /* Forme tracee comme un segment */ { @@ -418,6 +439,7 @@ void trace_1_pastille_OVALE_GERBER( wxPoint pos, wxSize size, int orient ) y1 = delta / 2; RotatePoint( &x0, &y0, orient ); RotatePoint( &x1, &y1, orient ); + SelectD_CODE_For_LineDraw( size.x ); PlotGERBERLine( wxPoint( pos.x + x0, pos.y + y0 ), wxPoint( pos.x + x1, pos.y + y1 ), size.x ); } @@ -432,9 +454,9 @@ void Plot_1_CIRCLE_pad_GERBER( wxPoint pos, int diametre ) */ { D_CODE* dcode_ptr; - char cbuf[256]; + char cbuf[256]; - wxSize size( diametre, diametre ); + wxSize size( diametre, diametre ); UserToDeviceCoordinate( pos ); UserToDeviceSize( size ); @@ -443,12 +465,12 @@ void Plot_1_CIRCLE_pad_GERBER( wxPoint pos, int diametre ) if( dcode_ptr->m_NumDcode != s_Last_D_code ) { sprintf( cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode ); - fputs( cbuf, dest ); + fputs( cbuf, g_Plot_PlotOutputFile ); s_Last_D_code = dcode_ptr->m_NumDcode; } sprintf( cbuf, "X%5.5dY%5.5dD03*\n", pos.x, pos.y ); - fputs( cbuf, dest ); + fputs( cbuf, g_Plot_PlotOutputFile ); } @@ -463,7 +485,7 @@ void PlotRectangularPad_GERBER( wxPoint pos, wxSize size, int orient ) */ { D_CODE* dcode_ptr; - char cbuf[256]; + char cbuf[256]; /* Trace de la forme flashee */ switch( orient ) @@ -472,7 +494,7 @@ void PlotRectangularPad_GERBER( wxPoint pos, wxSize size, int orient ) case 2700: /* la rotation de 90 ou 270 degres revient a permutter des dimensions */ EXCHG( size.x, size.y ); - // Pass through + // Pass through case 0: case 1800: @@ -483,11 +505,11 @@ void PlotRectangularPad_GERBER( wxPoint pos, wxSize size, int orient ) if( dcode_ptr->m_NumDcode != s_Last_D_code ) { sprintf( cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode ); - fputs( cbuf, dest ); + fputs( cbuf, g_Plot_PlotOutputFile ); s_Last_D_code = dcode_ptr->m_NumDcode; } sprintf( cbuf, "X%5.5dY%5.5dD03*\n", pos.x, pos.y ); - fputs( cbuf, dest ); + fputs( cbuf, g_Plot_PlotOutputFile ); break; default: /* plot pad shape as polygon */ @@ -535,6 +557,7 @@ void trace_1_contour_GERBER( wxPoint pos, wxSize size, wxSize delta, RotatePoint( &coord[ii].x, &coord[ii].y, pos.x, pos.y, orient ); } + SelectD_CODE_For_LineDraw( penwidth ); PlotGERBERLine( coord[0], coord[1], penwidth ); PlotGERBERLine( coord[1], coord[2], penwidth ); PlotGERBERLine( coord[2], coord[3], penwidth ); @@ -625,7 +648,8 @@ void trace_1_pad_TRAPEZE_GERBER( wxPoint pos, wxSize size, wxSize delta, if( modetrace != FILLED ) { - int plotLine_width = (int) (10 * g_PlotLine_Width * Gerb_scale_plot); + int plotLine_width = (int) ( 10 * g_PlotLine_Width * Gerb_scale_plot ); + SelectD_CODE_For_LineDraw( plotLine_width ); PlotGERBERLine( polygon[0], polygon[1], plotLine_width ); PlotGERBERLine( polygon[1], polygon[2], plotLine_width ); PlotGERBERLine( polygon[2], polygon[3], plotLine_width ); @@ -637,120 +661,21 @@ void trace_1_pad_TRAPEZE_GERBER( wxPoint pos, wxSize size, wxSize delta, /**********************************************************/ -void PlotGERBERLine( wxPoint start, wxPoint end, int width ) +void SelectD_CODE_For_LineDraw( int aSize ) /**********************************************************/ -/* Trace 1 segment de piste : +/** Selects a D_Code nn to draw lines and writes G54Dnn to output file + * @param aSize = D_CODE diameter */ { D_CODE* dcode_ptr; - char cbuf[256]; - UserToDeviceCoordinate( start ); - UserToDeviceCoordinate( end ); - - dcode_ptr = get_D_code( width, width, GERB_LINE, 0 ); + dcode_ptr = get_D_code( aSize, aSize, GERB_LINE, 0 ); if( dcode_ptr->m_NumDcode != s_Last_D_code ) { - sprintf( cbuf, "G54D%d*\n", dcode_ptr->m_NumDcode ); - fputs( cbuf, dest ); + fprintf( g_Plot_PlotOutputFile, "G54D%d*\n", dcode_ptr->m_NumDcode ); s_Last_D_code = dcode_ptr->m_NumDcode; } - sprintf( cbuf, "X%5.5dY%5.5dD02*\n", start.x, start.y ); - fputs( cbuf, dest ); - sprintf( cbuf, "X%5.5dY%5.5dD01*\n", end.x, end.y ); - fputs( cbuf, dest ); -} - - -/********************************************************************/ -void PlotCircle_GERBER( wxPoint centre, int rayon, int epaisseur ) -/********************************************************************/ - -/* Plot one cercle as segments (6 to 16 depending on its radius - */ -{ - int ii; - int ox, oy, fx, fy; - int delta; /* increment (en 0.1 degres) angulaire pour trace de cercles */ - - delta = 120; /* un cercle sera trace en 3600/delta segments */ - /* Correction pour petits cercles par rapport a l'epaisseur du trait */ - if( rayon < (epaisseur * 10) ) - delta = 225; /* 16 segm pour 360 deg */ - if( rayon < (epaisseur * 5) ) - delta = 300; /* 12 segm pour 360 deg */ - if( rayon < (epaisseur * 2) ) - delta = 600; /* 6 segm pour 360 deg */ - - ox = centre.x + rayon; - oy = centre.y; - for( ii = delta; ii < 3600; ii += delta ) - { - fx = centre.x + (int) (rayon * fcosinus[ii]); - fy = centre.y + (int) (rayon * fsinus[ii]); - PlotGERBERLine( wxPoint( ox, oy ), wxPoint( fx, fy ), epaisseur ); - ox = fx; - oy = fy; - } - - fx = centre.x + rayon; - fy = centre.y; - PlotGERBERLine( wxPoint( ox, oy ), wxPoint( fx, fy ), epaisseur ); -} - - -/***************************************************************/ -void PlotFilledPolygon_GERBER( int nb_segm, int* coord ) -/***************************************************************/ -{ - int ii; - wxPoint pos, startpos; - - fputs( "G36*\n", dest ); - pos.x = *coord; - coord++; - pos.y = *coord; - coord++; - UserToDeviceCoordinate( pos ); - startpos = pos; - fprintf( dest, "X%5.5dY%5.5dD02*\n", pos.x, pos.y ); - for( ii = 1; ii < nb_segm; ii++ ) - { - pos.x = *coord; - coord++; - pos.y = *coord; - coord++; - UserToDeviceCoordinate( pos ); - fprintf( dest, "X%5.5dY%5.5dD01*\n", pos.x, pos.y ); - } - - fprintf( dest, "X%5.5dY%5.5dD01*\n", startpos.x, startpos.y ); - fputs( "G37*\n", dest ); -} - - -/***************************************************************/ -void PlotPolygon_GERBER( int nb_segm, int* coord, int width ) -/***************************************************************/ -{ - wxPoint start, end, startpoint; - startpoint.x = *coord++; - startpoint.y = *coord++; - start = startpoint; - for( int ii = 0; ii < nb_segm-1; ii++ ) - { - end.x = *coord; - coord++; - end.y = *coord; - coord++; - PlotGERBERLine(start, end, width ); - start = end; - } - - if ( startpoint != end ) // Close poly - PlotGERBERLine(end, startpoint, width ); - } @@ -800,31 +725,6 @@ D_CODE* get_D_code( int dx, int dy, int type, int drill ) } -/******************************************************************/ -void Init_Trace_GERBER( WinEDA_BasePcbFrame* frame, FILE* gerbfile ) -/******************************************************************/ -{ - char Line[1024]; - - s_Last_D_code = 0; - - DateAndTime( Line ); - wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); - fprintf( gerbfile, "G04 (Genere par %s) le %s*\n", CONV_TO_UTF8( Title ), Line ); - - // Specify linear interpol (G01), unit = INCH (G70), abs format (G90): - fputs( "G01*\nG70*\nG90*\n", gerbfile ); - fputs( "%MOIN*%\n", gerbfile ); // set unites = INCHES - - /* Set gerber format to 3.4 */ - strcpy( Line, "G04 Gerber Fmt 3.4, Leading zero omitted, Abs format*\n%FSLAX34Y34*%\n" ); - - fputs( Line, gerbfile ); - - fputs( "G04 APERTURE LIST*\n", gerbfile ); -} - - /***********************************/ static void Init_ApertureList() /***********************************/ @@ -847,57 +747,8 @@ static void Init_ApertureList() } -/*****************************************************************/ -void Fin_Trace_GERBER( WinEDA_BasePcbFrame* frame, FILE* gerbfile ) -/*****************************************************************/ -{ - char line[1024]; - wxString TmpFileName, msg; - FILE* outfile; - - fputs( "M02*\n", gerbfile ); - fclose( gerbfile ); - - // Reouverture gerbfile pour ajout des Apertures - gerbfile = wxFopen( GerberFullFileName, wxT( "rt" ) ); - if( gerbfile == NULL ) - { - msg.Printf( _( "unable to reopen file <%s>" ), GerberFullFileName.GetData() ); - DisplayError( frame, msg ); - return; - } - - // Ouverture tmpfile - TmpFileName = GerberFullFileName + wxT( ".$$$" ); - outfile = wxFopen( TmpFileName, wxT( "wt" ) ); - if( outfile == NULL ) - { - fclose( gerbfile ); - DisplayError( frame, wxT( "Fin_Trace_GERBER(): Can't Open tmp file" ) ); - return; - } - - // Placement des Apertures en RS274X - rewind( gerbfile ); - while( fgets( line, 1024, gerbfile ) ) - { - fputs( line, outfile ); - if( strcmp( strtok( line, "\n\r" ), "G04 APERTURE LIST*" ) == 0 ) - { - frame->Gen_D_CODE_File( outfile ); - fputs( "G04 APERTURE END LIST*\n", outfile ); - } - } - - fclose( outfile ); - fclose( gerbfile ); - wxRemoveFile( GerberFullFileName ); - wxRenameFile( TmpFileName, GerberFullFileName ); -} - - /******************************************************/ -int WinEDA_BasePcbFrame::Gen_D_CODE_File( FILE* penfile ) +int Gen_D_CODE_File( FILE* penfile ) /******************************************************/ /* Genere la liste courante des D_CODES @@ -906,7 +757,7 @@ int WinEDA_BasePcbFrame::Gen_D_CODE_File( FILE* penfile ) */ { D_CODE* ptr_tool; - char cbuf[1024]; + char cbuf[1024]; int nb_dcodes = 0; /* Init : */ @@ -940,7 +791,7 @@ int WinEDA_BasePcbFrame::Gen_D_CODE_File( FILE* penfile ) break; default: - DisplayError( this, wxT( "Gen_D_CODE_File(): Dcode Type err" ) ); + DisplayError( NULL, wxT( "Gen_D_CODE_File(): Dcode Type err" ) ); break; } @@ -951,3 +802,55 @@ int WinEDA_BasePcbFrame::Gen_D_CODE_File( FILE* penfile ) return nb_dcodes; } + + +/*****************************/ +void CloseFileGERBER( void ) +/****************************/ + +/** Function CloseFileGERBER + */ +{ + char line[1024]; + wxString TmpFileName, msg; + FILE* tmpfile; + + fputs( "M02*\n", g_Plot_PlotOutputFile ); + fclose( g_Plot_PlotOutputFile ); + + // Reouverture g_Plot_PlotOutputFile pour ajout des Apertures + g_Plot_PlotOutputFile = wxFopen( GerberFullFileName, wxT( "rt" ) ); + if( g_Plot_PlotOutputFile == NULL ) + { + msg.Printf( _( "unable to reopen file <%s>" ), GerberFullFileName.GetData() ); + DisplayError( NULL, msg ); + return; + } + + // Ouverture tmpfile + TmpFileName = GerberFullFileName + wxT( ".$$$" ); + tmpfile = wxFopen( TmpFileName, wxT( "wt" ) ); + if( tmpfile == NULL ) + { + fclose( g_Plot_PlotOutputFile ); + DisplayError( NULL, wxT( "CloseFileGERBER(): Can't Open tmp file" ) ); + return; + } + + // Placement des Apertures en RS274X + rewind( g_Plot_PlotOutputFile ); + while( fgets( line, 1024, g_Plot_PlotOutputFile ) ) + { + fputs( line, tmpfile ); + if( strcmp( strtok( line, "\n\r" ), "G04 APERTURE LIST*" ) == 0 ) + { + Gen_D_CODE_File( tmpfile ); + fputs( "G04 APERTURE END LIST*\n", tmpfile ); + } + } + + fclose( tmpfile ); + fclose( g_Plot_PlotOutputFile ); + wxRemoveFile( GerberFullFileName ); + wxRenameFile( TmpFileName, GerberFullFileName ); +} diff --git a/pcbnew/plotgerb.h b/pcbnew/plotgerb.h deleted file mode 100644 index b8841647f3..0000000000 --- a/pcbnew/plotgerb.h +++ /dev/null @@ -1,111 +0,0 @@ - /************/ - /* pcbplot.h*/ - /************/ - -#ifndef PLOTGERB_H -#define PLOTGERB_H - - -/* Format Gerber : NOTES : -Fonctions preparatoires: - Gn = - G01 interpolation lineaire ( trace de droites ) - G02,G20,G21 Interpolation circulaire , sens trigo < 0 - G03,G30,G31 Interpolation circulaire , sens trigo > 0 - G04 commentaire - G06 Interpolation parabolique - G07 Interpolation cubique - G10 interpolation lineaire ( echelle 10x ) - G11 interpolation lineaire ( echelle 0.1x ) - G12 interpolation lineaire ( echelle 0.01x ) - G36 Start polygon description - G37 End polygon description - G52 plot symbole reference par Dnn code - G53 plot symbole reference par Dnn ; symbole tourne de -90 degres - G54 Selection d'outil - G55 Mode exposition photo - G56 plot symbole reference par Dnn A code - G57 affiche le symbole reference sur la console - G58 plot et affiche le symbole reference sur la console - G60 interpolation lineaire ( echelle 100x ) - G70 Unites = Inches - G71 Unites = Millimetres - G74 supprime interpolation circulaire sur 360 degre, revient a G01 - G75 Active interpolation circulaire sur 360 degre - G90 Mode Coordonnees absolues - G91 Mode Coordonnees Relatives - -Coordonnees X,Y - X,Y sont suivies de + ou - et de m+n chiffres (non separes) - m = partie entiere - n = partie apres la virgule - formats classiques : m = 2, n = 3 (format 2.3) - m = 3, n = 4 (format 3.4) - ex: - G__ X00345Y-06123 D__* - -Outils et D_CODES - numero d'outil ( identification des formes ) - 1 a 99 (classique) - 1 a 999 - D_CODES: - - D01 ... D9 = codes d'action: - D01 = activation de lumiere ( baisser de plume) - D02 = extinction de lumiere ( lever de plume) - D03 = Flash - D09 = VAPE Flash - D51 = precede par G54 -> Select VAPE - - D10 ... D255 = Indentification d'outils ( d'ouvertures ) - Ne sont pas tj dans l'ordre ( voir tableau ci dessous) -*/ - - - /*************************************/ - /* Constantes utiles en trace GERBER */ - /*************************************/ - -/* codes de type de forme d'outils */ - -/* -#define GERB_CIRCLE 1 -#define GERB_RECT 2 -#define GERB_LINE 3 -#define GERB_OVALE 4 -#define GERB_DONUT 5 -*/ - -/* liste des D_CODES en fonction de leur numero d'ordre (numero d'outil) - (l'ordre 0 n'est pas utilise) ; - Tools have D_CODES >= 10 - D_CODES <= 9 are used for commands only: - D01 ... D9 = command codes for photo plotting: - D01 = Light on - D02 = Light off - D03 = Flash - D04 .. D08 = ? - D09 = VAPE Flash -*/ - -#define FIRST_DCODE_VALUE 10 - -/* Structure de Description d'un D_CODE GERBER : */ -class D_CODE -{ -public: - D_CODE * m_Pnext, * m_Pback; /* for a linked list */ - wxSize m_Size; /* horiz and Vert size*/ - int m_Type; /* Type ( Line, rect , circulaire , ovale .. ); -1 = not used (free) descr */ - int m_NumDcode; /* code number ( >= 10 ); 0 = not in use */ - - D_CODE() - { - m_Pnext = m_Pback = NULL; - m_Type = -1; - m_NumDcode = 0; - } -} ; - - -#endif /* #define PLOTGERB_H */ diff --git a/pcbnew/plothpgl.cpp b/pcbnew/plothpgl.cpp index c6d07048cc..ac2926bd79 100644 --- a/pcbnew/plothpgl.cpp +++ b/pcbnew/plothpgl.cpp @@ -513,7 +513,7 @@ void trace_1_pastille_RONDE_HPGL( wxPoint pos, int diametre, int modetrace ) if( rayon < 0 ) { - rayon = 0; nb_plot_erreur++; Affiche_erreur( nb_plot_erreur ); + rayon = 0; nb_plot_erreur++; } wxSize rsize( rayon, rayon ); @@ -563,7 +563,7 @@ void PlotRectangularPad_HPGL( wxPoint padpos, wxSize padsize, if( (size.x < 0 ) || (size.y < 0) ) { - nb_plot_erreur++; Affiche_erreur( nb_plot_erreur ); + nb_plot_erreur++; } if( size.x < 0 ) size.x = 0;if( size.y < 0 ) @@ -810,7 +810,7 @@ void trace_1_segment_HPGL( int pos_X0, int pos_Y0, int pos_X1, int pos_Y1, dh = (epaisseur - (int) pen_diam ) / 2; if( dh < 0 ) { - dh = 0; nb_plot_erreur++; Affiche_erreur( nb_plot_erreur ); + dh = 0; nb_plot_erreur++; } if( (dh == 0) || (Plot_Mode == FILAIRE) ) /* Le trace se reduit a 1 trait */ diff --git a/pcbnew/protos.h b/pcbnew/protos.h index ba2c408df9..781ca3891b 100644 --- a/pcbnew/protos.h +++ b/pcbnew/protos.h @@ -326,12 +326,6 @@ void Trace_Block( WinEDA_DrawPanel* panel, wxDC* DC, int ox, int oy, int fx, /* Routine de trace d'un rectangle symbolisant un block * (toujours en mode XOR) */ -/***************/ -/* PLOT_RTN.CPP */ -/***************/ - -void Affiche_erreur( int nb_err ); - /*****************************************************************/ /* AFFICHE.CPP: (Fonctions d'affichage de messages, parametres... */