diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index 72bc2544a1..2b92533f8a 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -57,6 +57,7 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME ) EVT_TOOL( wxID_FILE, GERBVIEW_FRAME::Files_io ) EVT_TOOL( ID_GERBVIEW_ERASE_ALL, GERBVIEW_FRAME::Files_io ) + EVT_TOOL( ID_GERBVIEW_RELOAD_ALL, GERBVIEW_FRAME::Files_io ) EVT_TOOL( ID_GERBVIEW_LOAD_DRILL_FILE, GERBVIEW_FRAME::Files_io ) EVT_TOOL( ID_GERBVIEW_LOAD_ZIP_ARCHIVE_FILE, GERBVIEW_FRAME::Files_io ) EVT_TOOL( ID_GERBVIEW_LOAD_JOB_FILE, GERBVIEW_FRAME::Files_io ) diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 56ba0d67ea..07d51aedfa 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -120,6 +120,32 @@ void GERBVIEW_FRAME::Files_io( wxCommandEvent& event ) ClearMsgPanel(); break; + case ID_GERBVIEW_RELOAD_ALL: + { + // Store filenames + wxArrayString listOfFilenames; + listOfFilenames.Empty(); + for( unsigned i = 0; i < GetImagesList()->ImagesMaxCount(); i++ ) + { + if( GetImagesList()->GetGbrImage( i ) != nullptr ) + { + if( GetImagesList()->GetGbrImage( i )->m_InUse == 1 ) + listOfFilenames.Add( GetImagesList()->GetGbrImage( i )->m_FileName ); + } + } + + // Clear all layers + Clear_DrawLayers( false ); + Zoom_Automatique( false ); + m_canvas->Refresh(); + ClearMsgPanel(); + + // Load the layers from stored paths + wxBusyCursor wait; + loadListOfGerberFiles( wxEmptyString, listOfFilenames ); + } + break; + case ID_GERBVIEW_LOAD_DRILL_FILE: LoadExcellonFiles( wxEmptyString ); m_canvas->Refresh(); diff --git a/gerbview/gerbview_id.h b/gerbview/gerbview_id.h index 6a3a690cdc..bd32694fe2 100644 --- a/gerbview/gerbview_id.h +++ b/gerbview/gerbview_id.h @@ -45,6 +45,7 @@ enum gerbview_ids ID_GERBVIEW_LOAD_JOB_FILE, ID_GERBVIEW_LOAD_ZIP_ARCHIVE_FILE, ID_GERBVIEW_ERASE_ALL, + ID_GERBVIEW_RELOAD_ALL, ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, ID_GERBVIEW_SHOW_SOURCE, ID_GERBVIEW_EXPORT_TO_PCBNEW, diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index d5687f53a5..792eaaf3a4 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -145,6 +145,13 @@ void GERBVIEW_FRAME::ReCreateMenuBar() _( "Clear all layers. All data will be deleted" ), KiBitmap( delete_gerber_xpm ) ); + // Reload all + AddMenuItem( fileMenu, + ID_GERBVIEW_RELOAD_ALL, + _( "Reload All Layers" ), + _( "Reload all layers. All data will be reloaded" ), + KiBitmap( reload2_xpm ) ); + // Separator fileMenu->AppendSeparator(); diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 2a66c5b2ca..843a060457 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -56,6 +56,10 @@ void GERBVIEW_FRAME::ReCreateHToolbar( void ) KiScaledBitmap( delete_gerber_xpm, this ), _( "Clear all layers" ) ); + m_mainToolBar->AddTool( ID_GERBVIEW_RELOAD_ALL, wxEmptyString, + KiScaledBitmap( reload2_xpm, this ), + _( "Reload all layers" ) ); + m_mainToolBar->AddTool( wxID_FILE, wxEmptyString, KiScaledBitmap( load_gerber_xpm, this ), _( "Open Gerber file(s) on the current layer. Previous data will be deleted" ) );