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.

145 lines
4.0 KiB

  1. /*******************/
  2. /* File: cvpcb.cpp */
  3. /*******************/
  4. #include "fctsys.h"
  5. #include "appl_wxstruct.h"
  6. #include "wxstruct.h"
  7. #include "common.h"
  8. #include "confirm.h"
  9. #include "gestfich.h"
  10. #include "cvpcb.h"
  11. #include "zones.h"
  12. #include "bitmaps.h"
  13. #include "protos.h"
  14. #include "cvstruct.h"
  15. #include "colors_selection.h"
  16. #include "build_version.h"
  17. #include <wx/snglinst.h>
  18. // Colors for layers and items
  19. COLORS_DESIGN_SETTINGS g_ColorsSettings;
  20. /* Constant string definitions for CvPcb */
  21. const wxString ComponentFileExtension( wxT( "cmp" ) );
  22. const wxString RetroFileExtension( wxT( "stf" ) );
  23. const wxString FootprintAliasFileExtension( wxT( "equ" ) );
  24. // Wildcard for schematic retroannotation (import footprint names in schematic):
  25. const wxString RetroFileWildcard( _( "Kicad retroannotation files (*.stf)|*.stf" ) );
  26. const wxString FootprintAliasFileWildcard( _( "Kicad footprint alias files (*.equ)|*.equ" ) );
  27. const wxString titleLibLoadError( _( "Library Load Error" ) );
  28. /* MacOSX: Needed for file association
  29. * http://wiki.wxwidgets.org/WxMac-specific_topics
  30. */
  31. void WinEDA_App::MacOpenFile(const wxString &fileName) {
  32. wxFileName filename = fileName;
  33. wxString oldPath;
  34. WinEDA_CvpcbFrame * frame = ((WinEDA_CvpcbFrame*)GetTopWindow());
  35. if(!filename.FileExists())
  36. return;
  37. if( frame->m_NetlistFileName.DirExists() )
  38. oldPath = frame->m_NetlistFileName.GetPath();
  39. /* Update the library search path list. */
  40. if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
  41. wxGetApp().GetLibraryPathList().Remove( oldPath );
  42. wxGetApp().GetLibraryPathList().Insert( filename.GetPath(), 0 );
  43. frame->m_NetlistFileName = filename;
  44. if( frame->ReadNetList() )
  45. {
  46. frame->SetLastProject( filename.GetFullPath() );
  47. frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
  48. wxT( " " ) + filename.GetFullPath() );
  49. }
  50. else
  51. {
  52. frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() );
  53. }
  54. frame->ReCreateMenuBar();
  55. }
  56. // Create a new application object
  57. IMPLEMENT_APP( WinEDA_App )
  58. /************************************/
  59. /* Called to initialize the program */
  60. /************************************/
  61. bool WinEDA_App::OnInit()
  62. {
  63. /* WXMAC application specific */
  64. #ifdef __WXMAC__
  65. // wxApp::SetExitOnFrameDelete(false);
  66. wxApp::s_macAboutMenuItemId = ID_KICAD_ABOUT;
  67. wxApp::s_macPreferencesMenuItemId = ID_OPTIONS_SETUP;
  68. #endif /* __WXMAC__ */
  69. wxFileName filename;
  70. wxString message;
  71. WinEDA_CvpcbFrame* frame = NULL;
  72. InitEDA_Appl( wxT( "CvPCB" ), APP_TYPE_CVPCB );
  73. if( m_Checker && m_Checker->IsAnotherRunning() )
  74. {
  75. if( !IsOK( NULL, _( "Cvpcb is already running, Continue?" ) ) )
  76. return false;
  77. }
  78. if( argc > 1 )
  79. {
  80. filename = argv[1];
  81. wxSetWorkingDirectory( filename.GetPath() );
  82. }
  83. // read current setup and reopen last directory if no filename to open in command line
  84. bool reopenLastUsedDirectory = argc == 1;
  85. GetSettings(reopenLastUsedDirectory);
  86. g_DrawBgColor = BLACK;
  87. wxString Title = GetTitle() + wxT( " " ) + GetBuildVersion();
  88. frame = new WinEDA_CvpcbFrame( Title );
  89. // Show the frame
  90. SetTopWindow( frame );
  91. frame->LoadProjectFile( filename.GetFullPath() );
  92. frame->Show( TRUE );
  93. frame->BuildFOOTPRINTS_LISTBOX();
  94. if( filename.IsOk() && filename.FileExists() )
  95. {
  96. frame->m_NetlistFileName = filename;
  97. if( frame->ReadNetList() )
  98. {
  99. frame->m_NetlistFileExtension = filename.GetExt();
  100. return true;
  101. }
  102. }
  103. LoadFootprintFiles( frame->m_ModuleLibNames, frame->m_footprints );
  104. frame->m_NetlistFileExtension = wxT( "net" );
  105. frame->m_NetlistFileName.Clear();
  106. frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() +
  107. wxGetCwd() + wxFileName::GetPathSeparator() +
  108. _( " [no file]" ) );
  109. return true;
  110. }