Gerbview: Fix outdated warning message about missing D-Codes and old RS274D files.

RS274X Gerber files using only regions (polygons) can be valid, and are not old RS274D files
Now a warning is raised only if there are some missing D codes definitions
(RS274D file or broken RS274X file)

Remove unused var and add comments

Fixes: lp:1850821
https://bugs.launchpad.net/kicad/+bug/1850821
This commit is contained in:
jean-pierre charras 2019-10-31 21:03:17 +01:00
parent 4a0bd46ed6
commit c59fa1b672
5 changed files with 27 additions and 11 deletions

View File

@ -336,10 +336,11 @@ int char2Hex( unsigned aCode )
wxString FormatStringFromGerber( const wxString& aString ) wxString FormatStringFromGerber( const wxString& aString )
{ {
// make the inverse conversion of FormatStringToGerber() // make the inverse conversion of FormatStringToGerber()
// It converts a "normalized" gerber string and convert it to a 16 bits sequence unicode // It converts a "normalized" gerber string containing escape sequences
// and convert it to a 16 bits unicode char
// and return a wxString (unicode 16) from the gerber string // and return a wxString (unicode 16) from the gerber string
// Note the initial gerber string can already contain unicode chars.
wxString txt; // The string converted from Gerber string wxString txt; // The string converted from Gerber string
wxString uniString; // the unicode string from UTF8 Gerber string but without converted escape sequence
unsigned count = aString.Length(); unsigned count = aString.Length();

View File

@ -202,8 +202,9 @@ void GERBER_FILE_IMAGE::ResetDefaultValues()
m_MirrorB = false; // true: miror / axe B (default = Y) m_MirrorB = false; // true: miror / axe B (default = Y)
m_SwapAxis = false; // false if A = X, B = Y; true if A =Y, B = Y m_SwapAxis = false; // false if A = X, B = Y; true if A =Y, B = Y
m_Has_DCode = false; // true = DCodes in file m_Has_DCode = false; // true = DCodes in file
// false = no DCode-> // false = no DCode-> perhaps deprecated RS274D file
// search for separate DCode file m_Has_MissingDCode = false; // true = some D_Codes are used, but not defined
// perhaps deprecated RS274D file
m_FmtScale.x = m_FmtScale.y = 4; // Initialize default format to 3.4 => 4 m_FmtScale.x = m_FmtScale.y = 4; // Initialize default format to 3.4 => 4
m_FmtLen.x = m_FmtLen.y = 3 + 4; // Initialize default format len = 3+4 m_FmtLen.x = m_FmtLen.y = 3 + 4; // Initialize default format len = 3+4

View File

@ -162,7 +162,9 @@ public:
int m_Selected_Tool; // For highlight: current selected Dcode int m_Selected_Tool; // For highlight: current selected Dcode
bool m_Has_DCode; // true = DCodes in file bool m_Has_DCode; // true = DCodes in file
// (false = no DCode -> separate DCode file // false = no DCode -> perhaps deprecated RS274D file
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_360Arc_enbl; // Enbl 360 deg circular interpolation
bool m_PolygonFillMode; // Enable polygon mode (read coord as a polygon descr) bool m_PolygonFillMode; // Enable polygon mode (read coord as a polygon descr)
int m_PolygonFillModeState; // In polygon mode: 0 = first segm, 1 = next segm int m_PolygonFillModeState; // In polygon mode: 0 = first segm, 1 = next segm

View File

@ -74,14 +74,20 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName )
dlg.ShowModal(); dlg.ShowModal();
} }
/* if the gerber file is only a RS274D file /* if the gerber file has items using D codes but missing D codes definitions,
* (i.e. without any aperture information, but with items), warn the user: * it can be a deprecated RS274D file (i.e. without any aperture information),
* or has missing definitions,
* warn the user:
*/ */
if( !gerber->m_Has_DCode && gerber->GetItemsList() ) if( gerber->GetItemsList() && gerber->m_Has_MissingDCode )
{ {
msg = _("Warning: this file has no D-Code definition\n" if( !gerber->m_Has_DCode )
"It is perhaps an old RS274D file\n" msg = _("Warning: this file has no D-Code definition\n"
"Therefore the size of items is undefined"); "Therefore the size of some items is undefined");
else
msg = _("Warning: this file has some missing D-Code definitions\n"
"Therefore the size of some items is undefined");
wxMessageBox( msg ); wxMessageBox( msg );
} }

View File

@ -505,14 +505,17 @@ bool GERBER_FILE_IMAGE::Execute_G_Command( char*& text, int G_command )
case GC_SELECT_TOOL: case GC_SELECT_TOOL:
{ {
int D_commande = DCodeNumber( text ); int D_commande = DCodeNumber( text );
if( D_commande < FIRST_DCODE ) if( D_commande < FIRST_DCODE )
return false; return false;
if( D_commande > (TOOLS_MAX_COUNT - 1) ) if( D_commande > (TOOLS_MAX_COUNT - 1) )
D_commande = TOOLS_MAX_COUNT - 1; D_commande = TOOLS_MAX_COUNT - 1;
m_Current_Tool = D_commande; m_Current_Tool = D_commande;
D_CODE* pt_Dcode = GetDCODE( D_commande ); D_CODE* pt_Dcode = GetDCODE( D_commande );
if( pt_Dcode ) if( pt_Dcode )
pt_Dcode->m_InUse = true; pt_Dcode->m_InUse = true;
break; break;
} }
@ -597,8 +600,11 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
m_Current_Tool = D_commande; m_Current_Tool = D_commande;
D_CODE* pt_Dcode = GetDCODE( D_commande ); D_CODE* pt_Dcode = GetDCODE( D_commande );
if( pt_Dcode ) if( pt_Dcode )
pt_Dcode->m_InUse = true; pt_Dcode->m_InUse = true;
else
m_Has_MissingDCode = true;
return true; return true;
} }