|
|
@ -4,7 +4,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions to read footprint libraries and fill m_footprints by availlable footprints names |
|
|
|
* Functions to read footprint libraries and fill m_footprints by available footprints names |
|
|
|
* and their documentation (comments and keywords) |
|
|
|
*/ |
|
|
|
#include "fctsys.h"
|
|
|
@ -20,14 +20,13 @@ |
|
|
|
#include "filter_reader.h"
|
|
|
|
#include "footprint_info.h"
|
|
|
|
|
|
|
|
#include "dialog_load_error.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the list of libraries (*.mod files) and populates m_footprints ( list of availaible modules in libs ). |
|
|
|
/* Read the list of libraries (*.mod files)
|
|
|
|
* for each module are stored |
|
|
|
* the module name |
|
|
|
* documentation string |
|
|
|
* associated keywords |
|
|
|
* lib name |
|
|
|
* Module description format: |
|
|
|
* $MODULE c64acmd First line of module description |
|
|
|
* Li c64acmd DIN connector Library reference |
|
|
@ -35,39 +34,29 @@ |
|
|
|
* Kw PAD_CONN DIN associated keywords |
|
|
|
* ...... other data (pads, outlines ..) |
|
|
|
* $Endmodule |
|
|
|
* |
|
|
|
*/ |
|
|
|
bool CVPCB_MAINFRAME::LoadFootprintFiles( ) |
|
|
|
bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames ) |
|
|
|
{ |
|
|
|
FILE* file; |
|
|
|
wxFileName filename; |
|
|
|
wxString libname; |
|
|
|
wxString files_not_found; |
|
|
|
wxString files_invalid; |
|
|
|
|
|
|
|
/* Check if footprint m_footprints is not empty */ |
|
|
|
if( !m_footprints.empty() ) |
|
|
|
m_footprints.clear(); |
|
|
|
|
|
|
|
/* Check if there are footprint libraries in project file */ |
|
|
|
if( m_ModuleLibNames.GetCount() == 0 ) |
|
|
|
{ |
|
|
|
wxMessageBox( _( "No PCB footprint libraries are listed in the current project file." ), |
|
|
|
_( "Project File Error" ), wxOK | wxICON_ERROR ); |
|
|
|
return false; |
|
|
|
} |
|
|
|
// Clear data before reading files
|
|
|
|
m_filesNotFound.Empty(); |
|
|
|
m_filesInvalid.Empty(); |
|
|
|
m_List.clear(); |
|
|
|
|
|
|
|
/* Parse Libraries Listed */ |
|
|
|
for( unsigned ii = 0; ii < m_ModuleLibNames.GetCount(); ii++ ) |
|
|
|
for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ ) |
|
|
|
{ |
|
|
|
filename = m_ModuleLibNames[ii]; |
|
|
|
filename = aFootprintsLibNames[ii]; |
|
|
|
filename.SetExt( ModuleFileExtension ); |
|
|
|
|
|
|
|
libname = wxGetApp().FindLibraryPath( filename ); |
|
|
|
|
|
|
|
if( libname.IsEmpty() ) |
|
|
|
{ |
|
|
|
files_not_found << filename.GetFullName() << wxT("\n"); |
|
|
|
m_filesNotFound << filename.GetFullName() << wxT("\n"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
@ -76,7 +65,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) |
|
|
|
|
|
|
|
if( file == NULL ) |
|
|
|
{ |
|
|
|
files_invalid << libname << _(" (file cannot be opened)") << wxT("\n"); |
|
|
|
m_filesInvalid << libname << _(" (file cannot be opened)") << wxT("\n"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
@ -93,7 +82,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) |
|
|
|
wxString msg; |
|
|
|
msg.Printf( _( "<%s> is not a valid Kicad PCB footprint library." ), |
|
|
|
GetChars( libname ) ); |
|
|
|
files_invalid << msg << wxT("\n"); |
|
|
|
m_filesInvalid << msg << wxT("\n"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
@ -115,7 +104,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) |
|
|
|
FOOTPRINT_INFO* ItemLib = new FOOTPRINT_INFO(); |
|
|
|
ItemLib->m_Module = CONV_FROM_UTF8( StrPurge( line ) ); |
|
|
|
ItemLib->m_LibName = libname; |
|
|
|
m_footprints.push_back( ItemLib ); |
|
|
|
AddItem( ItemLib ); |
|
|
|
|
|
|
|
while( reader.ReadLine() ) |
|
|
|
{ |
|
|
@ -143,30 +132,11 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) |
|
|
|
|
|
|
|
if( !end ) |
|
|
|
{ |
|
|
|
files_invalid << libname << _(" (Unexpected end of file)") << wxT("\n"); |
|
|
|
m_filesInvalid << libname << _(" (Unexpected end of file)") << wxT("\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
m_footprints.sort(); |
|
|
|
|
|
|
|
/* Display error messages, if any */ |
|
|
|
if( !files_not_found.IsEmpty() || !files_invalid.IsEmpty() ) |
|
|
|
{ |
|
|
|
DIALOG_LOAD_ERROR dialog(NULL); |
|
|
|
if( !files_not_found.IsEmpty() ) |
|
|
|
{ |
|
|
|
wxString message = _("Some files could not be found!"); |
|
|
|
dialog.MessageSet(message); |
|
|
|
dialog.ListSet(files_not_found); |
|
|
|
} |
|
|
|
|
|
|
|
/* Display if there are invalid files */ |
|
|
|
if( !files_invalid.IsEmpty() ) |
|
|
|
{ |
|
|
|
dialog.MessageSet( _("Some files are invalid!")); |
|
|
|
dialog.ListSet(files_invalid); |
|
|
|
} |
|
|
|
dialog.ShowModal(); |
|
|
|
} |
|
|
|
m_List.sort(); |
|
|
|
|
|
|
|
return true; |
|
|
|
} |