D_CODE* GERBER_DRAW_ITEM::GetDcodeDescr() { if( (m_DCode < FIRST_DCODE) || (m_DCode > LAST_DCODE) ) return NULL; GERBER_IMAGE* gerber = g_GERBER_List[m_Layer]; if( gerber == NULL ) return NULL; D_CODE* d_code = gerber->GetDCODE( m_DCode, false ); return d_code; }
void GERBVIEW_FRAME::UpdateTitleAndInfo() { GERBER_IMAGE* gerber = g_GERBER_List.GetGbrImage( getActiveLayer() ); wxString text; // Display the gerber filename if( gerber == NULL ) { text.Printf( wxT( "GerbView %s" ), GetChars( GetBuildVersion() ) ); SetTitle( text ); SetStatusText( wxEmptyString, 0 ); text.Printf( _( "Drawing layer %d not in use" ), getActiveLayer() + 1 ); m_TextInfo->SetValue( text ); ClearMsgPanel(); return; } text = _( "File:" ); text << wxT( " " ) << gerber->m_FileName; if( gerber->m_IsX2_file ) text << wxT( " " ) << _( "(with X2 Attributes)" ); SetTitle( text ); gerber->DisplayImageInfo(); // Display Image Name and Layer Name (from the current gerber data): text.Printf( _( "Image name: '%s' Layer name: '%s'" ), GetChars( gerber->m_ImageName ), GetChars( gerber->GetLayerParams().m_LayerName ) ); SetStatusText( text, 0 ); // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar text.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ), gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ), gerber->m_FmtLen.x - gerber->m_FmtScale.x, gerber->m_FmtScale.x, gerber->m_FmtLen.y - gerber->m_FmtScale.y, gerber->m_FmtScale.y, gerber->m_NoTrailingZeros ? 'T' : 'L' ); if( gerber->m_IsX2_file ) text << wxT(" ") << _( "X2 attr" ); m_TextInfo->SetValue( text ); if( EnsureTextCtrlWidth( m_TextInfo, &text ) ) // Resized m_auimgr.Update(); }
void GERBVIEW_FRAME::Liste_D_Codes() { int ii, jj; D_CODE* pt_D_code; wxString Line; wxArrayString list; double scale = g_UserUnit == INCHES ? IU_PER_MILS * 1000 : IU_PER_MM; int curr_layer = getActiveLayer(); for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer ) { GERBER_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer ); if( gerber == NULL ) continue; if( gerber->UsedDcodeNumber() == 0 ) continue; if( layer == curr_layer ) Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 ); else Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 ); list.Add( Line ); const char* units = g_UserUnit == INCHES ? "\"" : "mm"; for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ ) { pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE, false ); if( pt_D_code == NULL ) continue; if( !pt_D_code->m_InUse && !pt_D_code->m_Defined ) continue; Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s " ), jj, pt_D_code->m_Num_Dcode, pt_D_code->m_Size.y / scale, units, pt_D_code->m_Size.x / scale, units, D_CODE::ShowApertureType( pt_D_code->m_Shape ) ); if( !pt_D_code->m_Defined ) Line += wxT( "(not used)" ); if( !pt_D_code->m_InUse ) Line += wxT( "(in use)" ); list.Add( Line ); jj++; } } #if wxCHECK_VERSION( 2, 9, 4 ) wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (void**) NULL, wxCHOICEDLG_STYLE & ~wxCANCEL ); #else wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (char**) NULL, wxCHOICEDLG_STYLE & ~wxCANCEL ); #endif dlg.ShowModal(); }
void GERBVIEW_FRAME::Liste_D_Codes() { int ii, jj; D_CODE* pt_D_code; wxString Line; wxArrayString list; double scale = IU_PER_MILS * 1000; int curr_layer = getActiveLayer(); for( int layer = 0; layer < 32; layer++ ) { GERBER_IMAGE* gerber = g_GERBER_List[layer]; if( gerber == NULL ) continue; if( gerber->ReturnUsedDcodeNumber() == 0 ) continue; if( layer == curr_layer ) Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 ); else Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 ); list.Add( Line ); for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ ) { pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE, false ); if( pt_D_code == NULL ) continue; if( !pt_D_code->m_InUse && !pt_D_code->m_Defined ) continue; Line.Printf( wxT( "tool %2.2d: D%2.2d V %2.4f H %2.4f %s" ), jj, pt_D_code->m_Num_Dcode, (float) pt_D_code->m_Size.y / scale, (float) pt_D_code->m_Size.x / scale, D_CODE::ShowApertureType( pt_D_code->m_Shape ) ); if( !pt_D_code->m_Defined ) Line += wxT( " ?" ); if( !pt_D_code->m_InUse ) Line += wxT( " *" ); list.Add( Line ); jj++; } } #if wxCHECK_VERSION( 2, 9, 4 ) wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (void**) NULL, wxCHOICEDLG_STYLE & ~wxCANCEL ); #else wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (char**) NULL, wxCHOICEDLG_STYLE & ~wxCANCEL ); #endif dlg.ShowModal(); }
/* Read a gerber file, RS274D or RS274X format. */ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName, const wxString& D_Code_FullFileName ) { int G_command = 0; // command number for G commands like G04 int D_commande = 0; // command number for D commands like D02 char line[GERBER_BUFZ]; wxString msg; char* text; int layer; // current layer used in GerbView layer = getActiveLayer(); if( g_GERBER_List[layer] == NULL ) { g_GERBER_List[layer] = new GERBER_IMAGE( this, layer ); } GERBER_IMAGE* gerber = g_GERBER_List[layer]; ClearMessageList( ); /* Set the gerber scale: */ gerber->ResetDefaultValues(); /* Read the gerber file */ gerber->m_Current_File = wxFopen( GERBER_FullFileName, wxT( "rt" ) ); if( gerber->m_Current_File == 0 ) { msg.Printf( _( "File <%s> not found" ), GetChars( GERBER_FullFileName ) ); DisplayError( this, msg, 10 ); return false; } gerber->m_FileName = GERBER_FullFileName; wxString path = wxPathOnly( GERBER_FullFileName ); if( path != wxEmptyString ) wxSetWorkingDirectory( path ); SetLocaleTo_C_standard(); while( true ) { if( fgets( line, sizeof(line), gerber->m_Current_File ) == NULL ) { if( gerber->m_FilesPtr == 0 ) break; fclose( gerber->m_Current_File ); gerber->m_FilesPtr--; gerber->m_Current_File = gerber->m_FilesList[gerber->m_FilesPtr]; continue; } text = StrPurge( line ); while( text && *text ) { switch( *text ) { case ' ': case '\r': case '\n': text++; break; case '*': // End command gerber->m_CommandState = END_BLOCK; text++; break; case 'M': // End file gerber->m_CommandState = CMD_IDLE; while( *text ) text++; break; case 'G': /* Line type Gxx : command */ G_command = gerber->GCodeNumber( text ); gerber->Execute_G_Command( text, G_command ); break; case 'D': /* Line type Dxx : Tool selection (xx > 0) or * command if xx = 0..9 */ D_commande = gerber->DCodeNumber( text ); gerber->Execute_DCODE_Command( text, D_commande ); break; case 'X': case 'Y': /* Move or draw command */ gerber->m_CurrentPos = gerber->ReadXYCoord( text ); if( *text == '*' ) // command like X12550Y19250* { gerber->Execute_DCODE_Command( text, gerber->m_Last_Pen_Command ); } break; case 'I': case 'J': /* Auxiliary Move command */ gerber->m_IJPos = gerber->ReadIJCoord( text ); if( *text == '*' ) // command like X35142Y15945J504* { gerber->Execute_DCODE_Command( text, gerber->m_Last_Pen_Command ); } break; case '%': if( gerber->m_CommandState != ENTER_RS274X_CMD ) { gerber->m_CommandState = ENTER_RS274X_CMD; gerber->ReadRS274XCommand( line, text ); } else //Error { ReportMessage( wxT("Expected RS274X Command") ); gerber->m_CommandState = CMD_IDLE; text++; } break; default: text++; msg.Printf( wxT("Unexpected symbol <%c>"), *text ); ReportMessage( msg ); break; } } } fclose( gerber->m_Current_File ); SetLocaleTo_Default(); gerber->m_InUse = true; // Display errors list if( m_Messages.size() > 0 ) { HTML_MESSAGE_BOX dlg( this, _("Errors") ); dlg.ListSet(m_Messages); dlg.ShowModal(); } /* if the gerber file is only a RS274D file * (i.e. without any aperture information), wran the user: */ if( !gerber->m_Has_DCode ) { msg = _("Warning: this file has no D-Code definition\n" "It is perhaps an old RS274D file\n" "Therefore the size of items is undefined"); wxMessageBox( msg ); } return true; }