Gerber viewer: Ensure arc interpolation is used only after a arc command.

Remove also non existing G command codes.
This commit is contained in:
jean-pierre charras 2018-11-28 18:46:25 +01:00
parent 79e784455c
commit ecfe564f4d
5 changed files with 28 additions and 41 deletions

View File

@ -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

View File

@ -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

View File

@ -40,9 +40,6 @@ extern const wxChar* g_GerberPageSizeList[7];
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,

View File

@ -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;
}

View File

@ -37,11 +37,12 @@
#include <cmath>
/* 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: