bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text ) { D_CODE* tool; GERBER_DRAW_ITEM * gbritem; while( true ) { switch( *text ) { case 'X': ReadXYCoord( text ); break; case 'Y': ReadXYCoord( text ); break; case 'G': // G85 is found here for oval holes m_PreviousPos = m_CurrentPos; Execute_EXCELLON_G_Command( text ); break; case 0: // E.O.L: execute command tool = GetDCODE( m_Current_Tool, false ); if( !tool ) { wxString msg; msg.Printf( _( "Tool <%d> not defined" ), m_Current_Tool ); ReportMessage( msg ); return false; } gbritem = new GERBER_DRAW_ITEM( GetParent()->GetBoard(), this ); GetParent()->GetBoard()->m_Drawings.Append( gbritem ); if( m_SlotOn ) // Oval hole { fillLineGBRITEM( gbritem, tool->m_Num_Dcode, GetParent()->getActiveLayer(), m_PreviousPos, m_CurrentPos, tool->m_Size, false ); } else { fillFlashedGBRITEM( gbritem, tool->m_Shape, tool->m_Num_Dcode, GetParent()->getActiveLayer(), m_CurrentPos, tool->m_Size, false ); } StepAndRepeatItem( *gbritem ); m_PreviousPos = m_CurrentPos; return true; break; default: text++; break; } } return true; }
bool EXCELLON_IMAGE::Execute_EXCELLON_G_Command( char*& text ) { EXCELLON_CMD* cmd = NULL; bool success = false; int id = DRILL_G_UNKNOWN; // Search command in list EXCELLON_CMD* candidate; char * gcmd = text; // gcmd points the G command, for error messages. for( unsigned ii = 0; ; ii++ ) { candidate = &excellon_G_CmdList[ii]; int len = candidate->m_Name.size(); if( len == 0 ) // End of list reached break; if( candidate->m_Name.compare( 0, len, text, len ) == 0 ) // found. { cmd = candidate; text += len; success = true; id = cmd->m_Code; break; } } switch( id ) { case DRILL_G_ZERO_SET: ReadXYCoord( text ); m_Offset = m_CurrentPos; break; case DRILL_G_ROUT: m_SlotOn = false; m_PolygonFillMode = true; break; case DRILL_G_DRILL: m_SlotOn = false; m_PolygonFillMode = false; break; case DRILL_G_SLOT: m_SlotOn = true; break; case DRILL_G_LINEARMOVE: m_Iterpolation = GERB_INTERPOL_LINEAR_1X; break; case DRILL_G_CWMOVE: m_Iterpolation = GERB_INTERPOL_ARC_NEG; break; case DRILL_G_CCWMOVE: m_Iterpolation = GERB_INTERPOL_ARC_POS; break; case DRILL_G_ABSOLUTE: m_Relative = false; // false = absolute coord break; case DRILL_G_INCREMENTAL: m_Relative = true; // true = relative coord break; case DRILL_G_UNKNOWN: default: { wxString msg; msg.Printf( _( "Unknown Excellon G Code: <%s>" ), GetChars(FROM_UTF8(gcmd)) ); ReportMessage( msg ); while( *text ) text++; return false; } } return success; }
bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text ) { D_CODE* tool; GERBER_DRAW_ITEM * gbritem; while( true ) { switch( *text ) { case 'X': ReadXYCoord( text ); break; case 'Y': ReadXYCoord( text ); break; case 'G': // G85 is found here for oval holes m_PreviousPos = m_CurrentPos; Execute_EXCELLON_G_Command( text ); break; case 0: // E.O.L: execute command tool = GetDCODE( m_Current_Tool, false ); if( !tool ) { wxString msg; msg.Printf( _( "Tool %d not defined" ), m_Current_Tool ); AddMessageToList( msg ); return false; } gbritem = new GERBER_DRAW_ITEM( this ); m_Drawings.Append( gbritem ); if( m_SlotOn ) // Oblong hole { fillLineGBRITEM( gbritem, tool->m_Num_Dcode, m_PreviousPos, m_CurrentPos, tool->m_Size, false ); // the hole is made: reset the slot on command (G85) // (it is needed for each oblong hole) m_SlotOn = false; } else { fillFlashedGBRITEM( gbritem, tool->m_Shape, tool->m_Num_Dcode, m_CurrentPos, tool->m_Size, false ); } StepAndRepeatItem( *gbritem ); m_PreviousPos = m_CurrentPos; return true; break; default: text++; break; } } return true; }
bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text ) { D_CODE* tool; GERBER_DRAW_ITEM * gbritem; while( true ) { switch( *text ) { case 'X': case 'Y': // Decode the coordinate format if( !m_format_known ) { int nbdigits = 0; int integer = m_GerbMetric ? fmtIntegerMM : fmtIntegerInch; int mantissa; char* read = text + 1; while( IsNumber( *read ) ) { if( *read == '.' ) { integer = nbdigits; read++; continue; } if( ( *read >= '0' ) && ( *read <='9' ) ) nbdigits++; read++; } mantissa = nbdigits - integer; // Enforce minimum mantissa of 3 for metric if( m_GerbMetric && mantissa < 3 ) mantissa = 3; m_FmtScale.x = m_FmtScale.y = mantissa; m_FmtLen.x = m_FmtLen.y = integer + mantissa; m_format_known = true; } ReadXYCoord( text ); break; case 'G': // G85 is found here for oval holes m_PreviousPos = m_CurrentPos; Execute_EXCELLON_G_Command( text ); break; case 0: // E.O.L: execute command tool = GetDCODE( m_Current_Tool ); if( !tool ) { wxString msg; msg.Printf( _( "Tool %d not defined" ), m_Current_Tool ); AddMessageToList( msg ); return false; } gbritem = new GERBER_DRAW_ITEM( this ); m_Drawings.Append( gbritem ); if( m_SlotOn ) // Oblong hole { fillLineGBRITEM( gbritem, tool->m_Num_Dcode, m_PreviousPos, m_CurrentPos, tool->m_Size, false ); // the hole is made: reset the slot on command (G85) // (it is needed for each oblong hole) m_SlotOn = false; } else { fillFlashedGBRITEM( gbritem, tool->m_Shape, tool->m_Num_Dcode, m_CurrentPos, tool->m_Size, false ); } StepAndRepeatItem( *gbritem ); m_PreviousPos = m_CurrentPos; return true; break; default: text++; break; } } return true; }