Gerbview: clean up loading files to prepare for more autodetection
This commit is contained in:
parent
eee20f9f67
commit
db407a1c0b
|
@ -22,6 +22,7 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <wx/debug.h>
|
||||
#include <wx/filedlg.h>
|
||||
#include <wx/wfstream.h>
|
||||
#include <wx/zipstrm.h>
|
||||
|
@ -208,8 +209,11 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
|
|||
|
||||
bool GERBVIEW_FRAME::LoadListOfGerberAndDrillFiles( const wxString& aPath,
|
||||
const wxArrayString& aFilenameList,
|
||||
const std::vector<int>* aFileType )
|
||||
std::vector<int>* aFileType )
|
||||
{
|
||||
wxCHECK_MSG( aFilenameList.Count() == aFileType->size(), false,
|
||||
"Mismatch in file names and file types count" );
|
||||
|
||||
wxFileName filename;
|
||||
|
||||
// Read gerber files: each file is loaded on a new GerbView layer
|
||||
|
@ -302,8 +306,33 @@ bool GERBVIEW_FRAME::LoadListOfGerberAndDrillFiles( const wxString& aPath,
|
|||
|
||||
try
|
||||
{
|
||||
if( aFileType && ( *aFileType )[ii] == 1 )
|
||||
// 2 = Autodetect
|
||||
if( ( *aFileType )[ii] == 2 )
|
||||
{
|
||||
if( EXCELLON_IMAGE::TestFileIsExcellon( filename.GetFullPath() ) )
|
||||
( *aFileType )[ii] = 1;
|
||||
else if( GERBER_FILE_IMAGE::TestFileIsRS274( filename.GetFullPath() ) )
|
||||
( *aFileType )[ii] = 0;
|
||||
}
|
||||
|
||||
switch( ( *aFileType )[ii] )
|
||||
{
|
||||
case 0:
|
||||
|
||||
if( Read_GERBER_File( filename.GetFullPath() ) )
|
||||
{
|
||||
UpdateFileHistory( filename.GetFullPath() );
|
||||
|
||||
if( firstLoadedLayer == NO_AVAILABLE_LAYERS )
|
||||
{
|
||||
firstLoadedLayer = layer;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
if( Read_EXCELLON_File( filename.GetFullPath() ) )
|
||||
{
|
||||
UpdateFileHistory( filename.GetFullPath(), &m_drillFileHistory );
|
||||
|
@ -314,18 +343,11 @@ bool GERBVIEW_FRAME::LoadListOfGerberAndDrillFiles( const wxString& aPath,
|
|||
firstLoadedLayer = layer;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Read_GERBER_File( filename.GetFullPath() ) )
|
||||
{
|
||||
UpdateFileHistory( filename.GetFullPath() );
|
||||
|
||||
if( firstLoadedLayer == NO_AVAILABLE_LAYERS )
|
||||
{
|
||||
firstLoadedLayer = layer;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
wxString txt = wxString::Format( MSG_NOT_LOADED, filename.GetFullName() );
|
||||
reporter.Report( txt, RPT_SEVERITY_ERROR );
|
||||
}
|
||||
}
|
||||
catch( const std::bad_alloc& )
|
||||
|
|
|
@ -67,13 +67,12 @@ public:
|
|||
*
|
||||
* @param aPath is the base path for the filenames if they are relative
|
||||
* @param aFilenameList is a list of filenames to load
|
||||
* @param aFileType is a list of type of files to load (0 = Gerber, 1 = NC drill)
|
||||
* if nullptr, files are expected Gerber type.
|
||||
* @param aFileType is a list of type of files to load (0 = Gerber, 1 = NC drill, 2 Autodetect)
|
||||
* Successfully autodetected files will have their type changed
|
||||
* @return true if every file loaded successfully
|
||||
*/
|
||||
bool LoadListOfGerberAndDrillFiles( const wxString& aPath,
|
||||
const wxArrayString& aFilenameList,
|
||||
const std::vector<int>* aFileType = nullptr );
|
||||
bool LoadListOfGerberAndDrillFiles( const wxString& aPath, const wxArrayString& aFilenameList,
|
||||
std::vector<int>* aFileType );
|
||||
|
||||
// Virtual basic functions:
|
||||
void ReCreateHToolbar() override;
|
||||
|
|
|
@ -226,7 +226,9 @@ bool GERBVIEW_FRAME::LoadGerberJobFile( const wxString& aFullFileName )
|
|||
|
||||
wxArrayString& gbrfiles = gbjReader.GetGerberFiles();
|
||||
|
||||
success = LoadListOfGerberAndDrillFiles( currentPath, gbrfiles );
|
||||
// 0 = Gerber file type
|
||||
std::vector<int> fileTypesVec( gbrfiles.Count(), 0 );
|
||||
success = LoadListOfGerberAndDrillFiles( currentPath, gbrfiles, &fileTypesVec );
|
||||
|
||||
Zoom_Automatique( false );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue