You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.9 KiB

14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
  1. /**
  2. * @file footprint_info.cpp
  3. */
  4. /*
  5. * Functions to read footprint libraries and fill m_footprints by available footprints names
  6. * and their documentation (comments and keywords)
  7. */
  8. #include <fctsys.h>
  9. #include <wxstruct.h>
  10. #include <common.h>
  11. #include <kicad_string.h>
  12. #include <macros.h>
  13. #include <appl_wxstruct.h>
  14. #include <pcbcommon.h>
  15. #include <pcbstruct.h>
  16. #include <footprint_info.h>
  17. #include <io_mgr.h>
  18. #include <class_pad.h>
  19. #include <class_module.h>
  20. #include <wildcards_and_files_ext.h>
  21. /* Read the list of libraries (*.mod files)
  22. * for each module are stored
  23. * the module name
  24. * documentation string
  25. * associated keywords
  26. * lib name
  27. * Module description format:
  28. * $MODULE c64acmd First line of module description
  29. * Li c64acmd DIN connector Library reference
  30. * Cd Europe 96 AC male vertical documentation string
  31. * Kw PAD_CONN DIN associated keywords
  32. * ...... other data (pads, outlines ..)
  33. * $Endmodule
  34. */
  35. bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
  36. {
  37. // Clear data before reading files
  38. m_filesNotFound.Empty();
  39. m_filesInvalid.Empty();
  40. m_List.clear();
  41. // try
  42. {
  43. PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
  44. // Parse Libraries Listed
  45. for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ )
  46. {
  47. wxFileName filename = aFootprintsLibNames[ii];
  48. filename.SetExt( LegacyFootprintLibPathExtension );
  49. wxString libPath = wxGetApp().FindLibraryPath( filename );
  50. if( !libPath )
  51. {
  52. m_filesNotFound << filename.GetFullName() << wxT("\n");
  53. continue;
  54. }
  55. try
  56. {
  57. wxArrayString fpnames = pi->FootprintEnumerate( libPath );
  58. for( unsigned i=0; i<fpnames.GetCount(); ++i )
  59. {
  60. std::auto_ptr<MODULE> m( pi->FootprintLoad( libPath, fpnames[i] ) );
  61. // we're loading what we enumerated, all must be there.
  62. wxASSERT( m.get() );
  63. FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();
  64. fpinfo->m_Module = fpnames[i];
  65. fpinfo->m_LibName = libPath;
  66. fpinfo->m_padCount = m->GetPadCount();
  67. fpinfo->m_KeyWord = m->GetKeywords();
  68. fpinfo->m_Doc = m->GetDescription();
  69. AddItem( fpinfo );
  70. }
  71. }
  72. catch( IO_ERROR ioe )
  73. {
  74. m_filesInvalid << ioe.errorText << wxT("\n");
  75. }
  76. }
  77. }
  78. /* caller should catch this, UI seems not wanted here.
  79. catch( IO_ERROR ioe )
  80. {
  81. DisplayError( NULL, ioe.errorText );
  82. return false;
  83. }
  84. */
  85. m_List.sort();
  86. return true;
  87. }