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.

123 lines
3.1 KiB

  1. /**
  2. * @file cvpcb.cpp
  3. */
  4. #include <fctsys.h>
  5. #include <gr_basic.h>
  6. #include <appl_wxstruct.h>
  7. #include <wxstruct.h>
  8. #include <confirm.h>
  9. #include <gestfich.h>
  10. #include <cvpcb.h>
  11. #include <zones.h>
  12. #include <cvpcb_mainframe.h>
  13. #include <colors_selection.h>
  14. #include <cvpcb_id.h>
  15. #include <build_version.h>
  16. #include <wx/snglinst.h>
  17. // Colors for layers and items
  18. COLORS_DESIGN_SETTINGS g_ColorsSettings;
  19. /* Constant string definitions for CvPcb */
  20. const wxString RetroFileExtension( wxT( "stf" ) );
  21. const wxString FootprintAliasFileExtension( wxT( "equ" ) );
  22. // Wildcard for schematic retroannotation (import footprint names in schematic):
  23. const wxString FootprintAliasFileWildcard( _( "KiCad footprint alias files (*.equ)|*.equ" ) );
  24. const wxString titleLibLoadError( _( "Library Load Error" ) );
  25. /*
  26. * MacOSX: Needed for file association
  27. * http://wiki.wxwidgets.org/WxMac-specific_topics
  28. */
  29. void EDA_APP::MacOpenFile(const wxString &fileName)
  30. {
  31. wxFileName filename = fileName;
  32. wxString oldPath;
  33. CVPCB_MAINFRAME* frame = (CVPCB_MAINFRAME*) GetTopWindow();
  34. if( !filename.FileExists() )
  35. return;
  36. if( frame->m_NetlistFileName.DirExists() )
  37. oldPath = frame->m_NetlistFileName.GetPath();
  38. /* Update the library search path list. */
  39. if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
  40. wxGetApp().GetLibraryPathList().Remove( oldPath );
  41. wxGetApp().GetLibraryPathList().Insert( filename.GetPath(), 0 );
  42. frame->m_NetlistFileName = filename;
  43. frame->ReadNetListAndLinkFiles();
  44. }
  45. // Create a new application object
  46. IMPLEMENT_APP( EDA_APP )
  47. /************************************/
  48. /* Called to initialize the program */
  49. /************************************/
  50. bool EDA_APP::OnInit()
  51. {
  52. wxFileName filename;
  53. wxString message;
  54. CVPCB_MAINFRAME* frame = NULL;
  55. InitEDA_Appl( wxT( "CvPcb" ), APP_CVPCB_T );
  56. if( m_Checker && m_Checker->IsAnotherRunning() )
  57. {
  58. if( !IsOK( NULL, _( "CvPcb is already running, Continue?" ) ) )
  59. return false;
  60. }
  61. if( argc > 1 )
  62. {
  63. filename = argv[1];
  64. wxSetWorkingDirectory( filename.GetPath() );
  65. }
  66. // read current setup and reopen last directory if no filename to open in command line
  67. bool reopenLastUsedDirectory = argc == 1;
  68. GetSettings(reopenLastUsedDirectory);
  69. g_DrawBgColor = BLACK;
  70. wxString Title = GetTitle() + wxT( " " ) + GetBuildVersion();
  71. frame = new CVPCB_MAINFRAME( Title );
  72. // Show the frame
  73. SetTopWindow( frame );
  74. frame->LoadProjectFile( filename.GetFullPath() );
  75. frame->Show( true );
  76. frame->BuildFOOTPRINTS_LISTBOX();
  77. frame->BuildLIBRARY_LISTBOX();
  78. if( filename.IsOk() && filename.FileExists() )
  79. {
  80. frame->m_NetlistFileName = filename;
  81. if( frame->ReadNetListAndLinkFiles() )
  82. {
  83. frame->m_NetlistFileExtension = filename.GetExt();
  84. return true;
  85. }
  86. }
  87. frame->LoadFootprintFiles();
  88. frame->m_NetlistFileExtension = wxT( "net" );
  89. frame->m_NetlistFileName.Clear();
  90. frame->UpdateTitle();
  91. return true;
  92. }