diff --git a/gerbview/gerber_file_image.cpp b/gerbview/gerber_file_image.cpp index 1c6a7d271e..801c849fcf 100644 --- a/gerbview/gerber_file_image.cpp +++ b/gerbview/gerber_file_image.cpp @@ -206,6 +206,7 @@ void GERBER_FILE_IMAGE::ResetDefaultValues() m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ. m_360Arc_enbl = false; // 360 deg circular // interpolation disable + m_AsArcG74G75Cmd = false; // false untile a G74 or G75 comand is found m_Current_Tool = 0; // Current Dcode selected m_CommandState = 0; // State of the current command m_CurrentPos.x = m_CurrentPos.y = 0; // current specified coord diff --git a/gerbview/gerber_file_image.h b/gerbview/gerber_file_image.h index db91dce13c..0b76c275a7 100644 --- a/gerbview/gerber_file_image.h +++ b/gerbview/gerber_file_image.h @@ -167,6 +167,8 @@ public: bool m_Has_MissingDCode; // true = some DCodes in file are not defined // (broken file or deprecated RS274D file) bool m_360Arc_enbl; // Enbl 360 deg circular interpolation + bool m_AsArcG74G75Cmd; // Set to true when a circular interpolation command + // type is found. Mandatory before drawing an arc. bool m_PolygonFillMode; // Enable polygon mode (read coord as a polygon descr) int m_PolygonFillModeState; // In polygon mode: 0 = first segm, 1 = next segm diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index 043b122b7b..5f90b61c53 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -530,10 +530,12 @@ bool GERBER_FILE_IMAGE::Execute_G_Command( char*& text, int G_command ) case GC_TURN_OFF_360_INTERPOL: // disable Multi cadran arc and Arc interpol m_360Arc_enbl = false; m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // not sure it should be done + m_AsArcG74G75Cmd = true; break; case GC_TURN_ON_360_INTERPOL: m_360Arc_enbl = true; + m_AsArcG74G75Cmd = true; break; case GC_SPECIFY_ABSOLUES_COORD: @@ -639,6 +641,15 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande ) { case GERB_INTERPOL_ARC_NEG: case GERB_INTERPOL_ARC_POS: + // Before any arc command, a G74 or G75 command must be set. + // Otherwise the Gerber file is invalid + if( !m_AsArcG74G75Cmd ) + { + AddMessageToList( _( "Invalide Gerber file: missing G74 or G75 arc command" ) ); + // Disable further warning messages: + m_AsArcG74G75Cmd = true; + } + gbritem = GetLastItemInList(); fillArcPOLY( gbritem, m_PreviousPos,