diff --git a/gerbview/gerber_file_image.cpp b/gerbview/gerber_file_image.cpp index d93de4cabe..d94dda98ae 100644 --- a/gerbview/gerber_file_image.cpp +++ b/gerbview/gerber_file_image.cpp @@ -219,6 +219,7 @@ void GERBER_FILE_IMAGE::ResetDefaultValues() m_PreviousPos.x = m_PreviousPos.y = 0; // last specified coord m_IJPos.x = m_IJPos.y = 0; // current centre coord for // plot arcs & circles + m_LastCoordIsIJPos = false; // True only after a IJ coordinate is read m_ArcRadius = 0; // radius of arcs in circular interpol (given by A## command). // in command like X##Y##A## m_LastArcDataType = ARC_INFO_TYPE_NONE; // Extra coordinate info type for arcs diff --git a/gerbview/gerber_file_image.h b/gerbview/gerber_file_image.h index 64abce08a4..bb4f16d5df 100644 --- a/gerbview/gerber_file_image.h +++ b/gerbview/gerber_file_image.h @@ -154,6 +154,7 @@ public: wxPoint m_CurrentPos; // current specified coord for plot wxPoint m_PreviousPos; // old current specified coord for plot wxPoint m_IJPos; // IJ coord (for arcs & circles ) + bool m_LastCoordIsIJPos; // true if a IJ coord was read (for arcs & circles ) int m_ArcRadius; // A value ( = radius in circular routing in Excellon files ) LAST_EXTRA_ARC_DATA_TYPE m_LastArcDataType; // Identifier for arc data type (IJ (center) or A## (radius)) FILE* m_Current_File; // Current file to read diff --git a/gerbview/gerbview.h b/gerbview/gerbview.h index 15f7d0e062..83b0f8616a 100644 --- a/gerbview/gerbview.h +++ b/gerbview/gerbview.h @@ -40,9 +40,6 @@ extern const wxChar* g_GerberPageSizeList[8]; enum Gerb_Interpolation { GERB_INTERPOL_LINEAR_1X = 0, - GERB_INTERPOL_LINEAR_10X, - GERB_INTERPOL_LINEAR_01X, - GERB_INTERPOL_LINEAR_001X, GERB_INTERPOL_ARC_NEG, GERB_INTERPOL_ARC_POS }; @@ -56,9 +53,6 @@ enum Gerb_GCommand GC_CIRCLE_NEG_INTERPOL = 2, GC_CIRCLE_POS_INTERPOL = 3, GC_COMMENT = 4, - GC_LINEAR_INTERPOL_10X = 10, - GC_LINEAR_INTERPOL_0P1X = 11, - GC_LINEAR_INTERPOL_0P01X = 12, GC_TURN_ON_POLY_FILL = 36, GC_TURN_OFF_POLY_FILL = 37, GC_SELECT_TOOL = 54, diff --git a/gerbview/rs274_read_XY_and_IJ_coordinates.cpp b/gerbview/rs274_read_XY_and_IJ_coordinates.cpp index 6eb2de7c60..c2bdaf125d 100644 --- a/gerbview/rs274_read_XY_and_IJ_coordinates.cpp +++ b/gerbview/rs274_read_XY_and_IJ_coordinates.cpp @@ -269,6 +269,7 @@ wxPoint GERBER_FILE_IMAGE::ReadIJCoord( char*& Text ) m_IJPos = pos; m_LastArcDataType = ARC_INFO_TYPE_CENTER; + m_LastCoordIsIJPos = true; return pos; } diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index e5ddf760b1..de0c605cf9 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -37,11 +37,12 @@ #include -/* Gerber: NOTES about some important commands found in RS274D and RS274X (G codes): +/* Gerber: NOTES about some important commands found in RS274D and RS274X (G codes). + * Some are now deprecated, but deprecated commands must be known by the Gerber reader * Gn = - * G01 linear interpolation (right trace) - * G02, G20, G21 Circular interpolation, meaning trig <0 (clockwise) - * G03, G30, G31 Circular interpolation, meaning trigo> 0 (counterclockwise) + * G01 linear interpolation (linear trace) + * G02, G20, G21 Circular interpolation, clockwise + * G03, G30, G31 Circular interpolation, counterclockwise * G04 = comment. Since Sept 2014, file attributes and other X2 attributes can be found here * if the line starts by G04 #@! * G06 parabolic interpolation @@ -49,19 +50,14 @@ * G10 linear interpolation (scale x10) * G11 linear interpolation (0.1x range) * G12 linear interpolation (0.01x scale) - * G36 Start polygon mode + * G36 Start polygon mode (called a region, because the "polygon" can include arcs) * G37 Stop polygon mode (and close it) - * G54 Selection Tool + * G54 Selection Tool (outdated) * G60 linear interpolation (scale x100) * G70 Select Units = Inches * G71 Select Units = Millimeters - * G74 disable 360 degrees circular interpolation (return to 90 deg mode) - * and perhaps circular interpolation (return to linear interpolation ) - * see rs274xrevd_e.pdf pages 47 and 48 - * Unfortunately page 47 said G74 disable G02 or G03 - * and page 48 said G01 must be used to disable G02 or G03. - * Currently GerbView disable G02 or G03 after a G74 command (tests using 2 gerber files). - * G75 enable 360 degrees circular interpolation + * G74 enable 90 deg mode for arcs (CW or CCW) + * G75 enable 360 degrees for arcs (CW or CCW) * G90 mode absolute coordinates * * X, Y @@ -506,18 +502,6 @@ bool GERBER_FILE_IMAGE::Execute_G_Command( char*& text, int G_command ) text++; break; - case GC_LINEAR_INTERPOL_10X: - m_Iterpolation = GERB_INTERPOL_LINEAR_10X; - break; - - case GC_LINEAR_INTERPOL_0P1X: - m_Iterpolation = GERB_INTERPOL_LINEAR_01X; - break; - - case GC_LINEAR_INTERPOL_0P01X: - m_Iterpolation = GERB_INTERPOL_LINEAR_001X; - break; - case GC_SELECT_TOOL: { int D_commande = DCodeNumber( text ); @@ -574,6 +558,7 @@ bool GERBER_FILE_IMAGE::Execute_G_Command( char*& text, int G_command ) m_Exposure = false; m_PolygonFillMode = false; m_PolygonFillModeState = 0; + m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // not sure it should be done break; case GC_MOVE: // Non existent @@ -709,22 +694,27 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande ) StepAndRepeatItem( *gbritem ); break; - case GERB_INTERPOL_LINEAR_01X: - case GERB_INTERPOL_LINEAR_001X: - case GERB_INTERPOL_LINEAR_10X: - wxBell(); - break; - case GERB_INTERPOL_ARC_NEG: case GERB_INTERPOL_ARC_POS: gbritem = new GERBER_DRAW_ITEM( this ); m_Drawings.Append( gbritem ); - fillArcGBRITEM( gbritem, dcode, m_PreviousPos, - m_CurrentPos, m_IJPos, size, - ( m_Iterpolation == GERB_INTERPOL_ARC_NEG ) ? - false : true, m_360Arc_enbl, GetLayerParams().m_LayerNegative ); + if( m_LastCoordIsIJPos ) + { + fillArcGBRITEM( gbritem, dcode, m_PreviousPos, + m_CurrentPos, m_IJPos, size, + ( m_Iterpolation == GERB_INTERPOL_ARC_NEG ) ? + false : true, m_360Arc_enbl, GetLayerParams().m_LayerNegative ); + m_LastCoordIsIJPos = false; + } + else + { + fillLineGBRITEM( gbritem, dcode, m_PreviousPos, + m_CurrentPos, size, GetLayerParams().m_LayerNegative ); + } + StepAndRepeatItem( *gbritem ); + break; default: