void MessageManager::Send(Message *m) { if (m->GetTimingMethod() == TIMER_GAME) { AddMessageToList(m_gameMessages, m); } else { AddMessageToList(m_systemMessages, m); } }
bool EXCELLON_IMAGE::readToolInformation( char*& aText ) { // Read a tool definition like T1C0.02 or T1F00S00C0.02 or T1C0.02F00S00 // and enter the TCODE param in list (using the D_CODE param management, which // is similar to TCODE params. if( *aText == 'T' ) // This is the beginning of the definition aText++; // Read tool number: int iprm = ReadInt( aText, false ); // Skip Feed rate and Spindle speed, if any here while( *aText && ( *aText == 'F' || *aText == 'S' ) ) { aText++; ReadInt( aText, false ); } // Read tool shape if( ! *aText ) AddMessageToList( wxString:: Format( _( "Tool definition shape not found" ) ) ); else if( *aText != 'C' ) AddMessageToList( wxString:: Format( _( "Tool definition '%c' not supported" ), *aText ) ); if( *aText ) aText++; //read tool diameter: double dprm = ReadDouble( aText, false ); m_Has_DCode = true; // Initialize Dcode to handle this Tool // Remember: dcodes are >= FIRST_DCODE D_CODE* dcode = GetDCODE( iprm + FIRST_DCODE ); if( dcode == NULL ) return false; // conv_scale = scaling factor from inch to Internal Unit double conv_scale = IU_PER_MILS * 1000; if( m_GerbMetric ) conv_scale /= 25.4; dcode->m_Size.x = dcode->m_Size.y = KiROUND( dprm * conv_scale ); dcode->m_Shape = APT_CIRCLE; dcode->m_Defined = true; return true; }
LRESULT CBackEndDialog::OnAddMessage(WPARAM wParam, LPARAM lParam) { //get the text CTaskMessage* pMsg = (CTaskMessage*)wParam; //now add that message to the current task if(m_pCurrTask) { m_pCurrTask->AddMessage(pMsg->GetSeverity(), pMsg->GetMessageText(), pMsg->GetHelp()); //see if this is the task currently being viewed CTask* pViewed = GetViewedTask(); if(pViewed == m_pCurrTask) { if(ShouldShowMessage(pMsg, m_eMsgFilter)) { //we need to add this message to the list box AddMessageToList(pMsg, true); } } } //free the memory delete pMsg; return 0; }
//resets the contents of the message list based upon the currently viewed task void CBackEndDialog::ResetMessageList() { //we need to fill the message list up with the message associated with the //newly selected task //flush existing messages EmptyMessageList(); CTask* pTask = GetViewedTask(); if(pTask) { //now fill up the message list with all of our messages CTaskMessage* pCurrMsg = pTask->GetMessageHead(); while(pCurrMsg) { if(ShouldShowMessage(pCurrMsg, m_eMsgFilter)) { //add this string and a pointer to the orinignal message AddMessageToList(pCurrMsg); } pCurrMsg = pCurrMsg->GetNext(); } } RedrawMessageList(); }
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)) ); AddMessageToList( 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_HEADER_Command( char*& text ) { EXCELLON_CMD* cmd = NULL; wxString msg; // Search command in list for( unsigned ii = 0; ; ii++ ) { EXCELLON_CMD* candidate = &excellonHeaderCmdList[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; break; } } if( !cmd ) { msg.Printf( wxT( "Unknown Excellon command <%s>" ), text ); AddMessageToList( msg ); while( *text ) text++; return false; } // Execute command // some do nothing switch( cmd->m_Code ) { case DRILL_SKIP: case DRILL_M_UNKNOWN: break; case DRILL_M_END: break; case DRILL_M_ENDREWIND: break; case DRILL_M_MESSAGE: break; case DRILL_M_LONGMESSAGE: break; case DRILL_M_HEADER: m_State = READ_HEADER_STATE; break; case DRILL_M_ENDHEADER: m_State = READ_PROGRAM_STATE; break; case DRILL_REWIND_STOP: // End of header. No action in a viewer m_State = READ_PROGRAM_STATE; break; case DRILL_M_METRIC: SelectUnits( true ); break; case DRILL_METRICHEADER: // command like METRIC,TZ or METRIC,LZ SelectUnits( true ); if( *text != ',' ) { AddMessageToList( _( "METRIC command has no parameter" ) ); break; } text++; // skip separator if( *text == 'T' ) m_NoTrailingZeros = false; else m_NoTrailingZeros = true; break; case DRILL_M_IMPERIAL: SelectUnits( false ); break; case DRILL_IMPERIALHEADER: // command like INCH,TZ or INCH,LZ SelectUnits( false ); if( *text != ',' ) { AddMessageToList( _( "INCH command has no parameter" ) ); break; } text++; // skip separator if( *text == 'T' ) m_NoTrailingZeros = false; else m_NoTrailingZeros = true; break; case DRILL_M_BEGINPATTERN: break; case DRILL_M_ENDPATTERN: break; case DRILL_M_CANNEDTEXT: break; case DRILL_M_TIPCHECK: break; case DRILL_DETECT_BROKEN: break; case DRILL_INCREMENTALHEADER: if( *text != ',' ) { AddMessageToList( _( "ICI command has no parameter" ) ); break; } text++; // skip separator // Parameter should be ON or OFF if( strncasecmp( text, "OFF", 3 ) == 0 ) m_Relative = false; else if( strncasecmp( text, "ON", 2 ) == 0 ) m_Relative = true; else AddMessageToList( _( "ICI command has incorrect parameter" ) ); break; case DRILL_TOOL_CHANGE_STOP: break; case DRILL_AUTOMATIC_SPEED: break; case DRILL_AXIS_VERSION: break; case DRILL_RESET_CMD: break; case DRILL_AUTOMATIC_TOOL_CHANGE: break; case DRILL_FMT: break; case DRILL_TOOL_INFORMATION: readToolInformation( text ); break; } while( *text ) text++; return true; }
bool EXCELLON_IMAGE::LoadFile( const wxString & aFullFileName ) { // Set the default parmeter values: ResetDefaultValues(); ClearMessageList(); m_Current_File = wxFopen( aFullFileName, wxT( "rt" ) ); if( m_Current_File == NULL ) return false; m_FileName = aFullFileName; LOCALE_IO toggleIo; // FILE_LINE_READER will close the file. FILE_LINE_READER excellonReader( m_Current_File, m_FileName ); while( true ) { if( excellonReader.ReadLine() == 0 ) break; char* line = excellonReader.Line(); char* text = StrPurge( line ); if( *text == ';' ) // comment: skip line continue; if( m_State == EXCELLON_IMAGE::READ_HEADER_STATE ) { Execute_HEADER_Command( text ); } else { switch( *text ) { case 'M': Execute_HEADER_Command( text ); break; case 'G': /* Line type Gxx : command */ Execute_EXCELLON_G_Command( text ); break; case 'X': case 'Y': // command like X12550Y19250 Execute_Drill_Command(text); break; case 'I': case 'J': /* Auxiliary Move command */ m_IJPos = ReadIJCoord( text ); if( *text == '*' ) // command like X35142Y15945J504 { Execute_Drill_Command( text); } break; case 'T': // Tool command Select_Tool( text ); break; case '%': break; default: { wxString msg; msg.Printf( wxT( "Unexpected symbol <%c>" ), *text ); AddMessageToList( msg ); } break; } // End switch } } // Add our file attribute, to identify the drill file X2_ATTRIBUTE dummy; char* text = (char*)file_attribute; dummy.ParseAttribCmd( m_Current_File, NULL, 0, text ); delete m_FileFunction; m_FileFunction = new X2_ATTRIBUTE_FILEFUNCTION( dummy ); m_InUse = true; 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; }