bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) { wxString msg; int layerId = getActiveLayer(); // current layer used in GerbView GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList(); EXCELLON_IMAGE* drill_Layer = (EXCELLON_IMAGE*) images->GetGbrImage( layerId ); if( drill_Layer == NULL ) { drill_Layer = new EXCELLON_IMAGE( layerId ); layerId = images->AddGbrImage( drill_Layer, layerId ); } if( layerId < 0 ) { DisplayError( this, _( "No room to load file" ) ); return false; } // Read the Excellon drill file: bool success = drill_Layer->LoadFile( aFullFileName ); if( !success ) { msg.Printf( _( "File %s not found" ), GetChars( aFullFileName ) ); DisplayError( this, msg ); return false; } // Display errors list if( drill_Layer->GetMessages().size() > 0 ) { HTML_MESSAGE_BOX dlg( this, _( "Error reading EXCELLON drill file" ) ); dlg.ListSet( drill_Layer->GetMessages() ); dlg.ShowModal(); } return success; }
bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) { wxString msg; int layerId = GetActiveLayer(); // current layer used in GerbView GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList(); auto gerber_layer = images->GetGbrImage( layerId ); auto drill_layer = dynamic_cast<EXCELLON_IMAGE*>( gerber_layer ); if( gerber_layer && !drill_layer ) { // The active layer contains old gerber data we have to clear Erase_Current_DrawLayer( false ); } if( drill_layer == nullptr ) { drill_layer = new EXCELLON_IMAGE( layerId ); layerId = images->AddGbrImage( drill_layer, layerId ); } if( layerId < 0 ) { DisplayError( this, _( "No room to load file" ) ); return false; } // Read the Excellon drill file: bool success = drill_layer->LoadFile( aFullFileName ); if( !success ) { msg.Printf( _( "File %s not found" ), GetChars( aFullFileName ) ); DisplayError( this, msg ); return false; } // Display errors list if( drill_layer->GetMessages().size() > 0 ) { HTML_MESSAGE_BOX dlg( this, _( "Error reading EXCELLON drill file" ) ); dlg.ListSet( drill_layer->GetMessages() ); dlg.ShowModal(); } if( success ) { EDA_DRAW_PANEL_GAL* canvas = GetGalCanvas(); if( canvas ) { KIGFX::VIEW* view = canvas->GetView(); for( GERBER_DRAW_ITEM* item = drill_layer->GetItemsList(); item; item = item->Next() ) { view->Add( (KIGFX::VIEW_ITEM*) item ); } } } return success; }