Gerbview: add a error message for invalid files missing G74 or G75 commands.

They are mandatory to read arc coordinates.
This commit is contained in:
jean-pierre charras 2020-04-10 13:26:18 +02:00
parent b31af4891d
commit d6312c7b92
3 changed files with 15 additions and 2 deletions

View File

@ -211,8 +211,8 @@ void GERBER_FILE_IMAGE::ResetDefaultValues()
m_FmtLen.x = m_FmtLen.y = 3 + 4; // Initialize default format len = 3+4
m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ.
m_360Arc_enbl = false; // 360 deg circular
// interpolation disable
m_360Arc_enbl = false; // 360 deg circular interpolation disable
m_AsArcG74G75Cmd = false; // false until a G74 or G75 command 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

View File

@ -163,6 +163,8 @@ public:
bool m_Has_DCode; // true = DCodes in file
// (false = no DCode -> separate DCode 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

View File

@ -527,10 +527,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:
@ -633,6 +635,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( _( "Invalid Gerber file: missing G74 or G75 arc command" ) );
// Disable further warning messages:
m_AsArcG74G75Cmd = true;
}
gbritem = m_Drawings.GetLast();
fillArcPOLY( gbritem, m_PreviousPos,