From aac13e7ae159c6514ad35fbdc0fb822e582b6d54 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 26 Jan 2017 13:16:49 +0100 Subject: [PATCH] More detailed error messages when loading Gerber or drill files and if no room to load some files. --- gerbview/files.cpp | 89 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 14 deletions(-) diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 7d10fa9495..746e9e6b4a 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -197,8 +198,13 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) } // Read gerber files: each file is loaded on a new GerbView layer + bool success = true; int layer = getActiveLayer(); + // Manage errors when loading files + wxString msg; + WX_STRING_REPORTER reporter( &msg ); + for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ ) { filename = filenamesList[ii]; @@ -216,11 +222,23 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) layer = getNextAvailableLayer( layer ); - if( layer == NO_AVAILABLE_LAYERS ) + if( layer == NO_AVAILABLE_LAYERS && ii < filenamesList.GetCount()-1 ) { - wxString msg = wxT( "No more empty available layers.\n" - "The remaining gerber files will not be loaded." ); - wxMessageBox( msg ); + success = false; + + reporter.Report( _( "No available graphic layer in Gerbview to load files" ), + REPORTER::RPT_ERROR ); + + // Report the name of not loaded files: + ii += 1; + while( ii < filenamesList.GetCount() ) + { + filename = filenamesList[ii++]; + wxString txt; + txt.Printf( _( "\nNot loaded: '%s'" ), + GetChars( filename.GetFullName() ) ); + reporter.Report( txt, REPORTER::RPT_ERROR ); + } break; } @@ -228,6 +246,13 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) } } + if( !success ) + { + HTML_MESSAGE_BOX mbox( this, _( "Errors" ) ); + mbox.ListSet( msg ); + mbox.ShowModal(); + } + Zoom_Automatique( false ); // Synchronize layers tools with actual active layer: @@ -235,7 +260,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) setActiveLayer( getActiveLayer() ); m_LayersManager->UpdateLayerIcons(); syncLayerBox(); - return true; + return success; } @@ -280,9 +305,14 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) m_mruPath = currentPath; } - // Read gerber files: each file is loaded on a new GerbView layer + // Read Excellon drill files: each file is loaded on a new GerbView layer + bool success = true; int layer = getActiveLayer(); + // Manage errors when loading files + wxString msg; + WX_STRING_REPORTER reporter( &msg ); + for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ ) { filename = filenamesList[ii]; @@ -301,11 +331,23 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) layer = getNextAvailableLayer( layer ); - if( layer == NO_AVAILABLE_LAYERS ) + if( layer == NO_AVAILABLE_LAYERS && ii < filenamesList.GetCount()-1 ) { - wxString msg = wxT( "No more empty available layers.\n" - "The remaining gerber files will not be loaded." ); - wxMessageBox( msg ); + success = false; + + reporter.Report( _( "No available graphic layer in Gerbview to load files" ), + REPORTER::RPT_ERROR ); + + // Report the name of not loaded files: + ii += 1; + while( ii < filenamesList.GetCount() ) + { + filename = filenamesList[ii++]; + wxString txt; + txt.Printf( _( "\nNot loaded: '%s'" ), + GetChars( filename.GetFullName() ) ); + reporter.Report( txt, REPORTER::RPT_ERROR ); + } break; } @@ -313,6 +355,13 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) } } + if( !success ) + { + HTML_MESSAGE_BOX mbox( this, _( "Errors" ) ); + mbox.ListSet( msg ); + mbox.ShowModal(); + } + Zoom_Automatique( false ); // Synchronize layers tools with actual active layer: @@ -321,7 +370,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) m_LayersManager->UpdateLayerIcons(); syncLayerBox(); - return true; + return success; } @@ -430,9 +479,17 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR if( aReporter ) { - msg = _( "No available graphic layer in Gerbview.\n" - "The remaining files will not be loaded." ); + msg = _( "No available graphic layer in Gerbview to load files" ); aReporter->Report( msg, REPORTER::RPT_ERROR ); + + // Report the name of not loaded files: + while( !localfilename.IsEmpty() ) + { + msg.Printf( _( "\nNot loaded: '%s'" ), + GetChars( localfilename.AfterLast( ':' ) ) ); + aReporter->Report( msg, REPORTER::RPT_ERROR ); + localfilename = zipfilesys.FindNext(); + } } break; } @@ -487,7 +544,11 @@ bool GERBVIEW_FRAME::LoadZipArchiveFile( const wxString& aFullFileName ) bool success = unarchiveFiles( filename.GetFullPath(), &reporter ); if( !success ) - wxMessageBox( msg ); + { + HTML_MESSAGE_BOX mbox( this, _( "Errors" ) ); + mbox.ListSet( msg ); + mbox.ShowModal(); + } } Zoom_Automatique( false );