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.

213 lines
6.5 KiB

* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
16 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. /**
  24. * @file dialog_freeroute_exchange.cpp
  25. * Dialog to access to FreeRoute, the web bases free router, export/import files
  26. * to/from FreeRoute
  27. */
  28. #include <fctsys.h>
  29. #include <kiface_i.h>
  30. #include <confirm.h>
  31. #include <gestfich.h>
  32. #include <wildcards_and_files_ext.h>
  33. #include <pcbnew.h>
  34. #include <pcb_edit_frame.h>
  35. #include <macros.h>
  36. #include <class_board.h>
  37. #include <../common/dialogs/dialog_display_info_HTML_base.h>
  38. #include <dialog_freeroute_exchange.h>
  39. #ifdef __WINDOWS__
  40. #include <wx/msw/registry.h>
  41. #endif
  42. void PCB_EDIT_FRAME::Access_to_External_Tool( wxCommandEvent& event )
  43. {
  44. DIALOG_FREEROUTE dialog( this );
  45. dialog.ShowModal();
  46. }
  47. DIALOG_FREEROUTE::DIALOG_FREEROUTE( PCB_EDIT_FRAME* parent ):
  48. DIALOG_FREEROUTE_BASE( parent )
  49. {
  50. m_Parent = parent;
  51. init();
  52. m_sdbSizerCancel->SetDefault();
  53. // Rename "Cancel" button label to "Close", because:
  54. // wxFormBuilder has no option to create/rename a Close button in the wxStdDialogButtonSizer
  55. // and a Cancel button (id = wxID_CANCEL) is mandatory to allow dismiss dialog by ESC key
  56. wxButton* button = dynamic_cast<wxButton*>( wxWindow::FindWindowById( wxID_CANCEL, this ) );
  57. if( button )
  58. button->SetLabel( _( "Close" ) );
  59. GetSizer()->SetSizeHints( this );
  60. Centre();
  61. }
  62. // Specific data initialization
  63. void DIALOG_FREEROUTE::init()
  64. {
  65. SetFocus();
  66. m_freeRouterFound = false;
  67. wxFileName fileName( FindKicadFile( wxT( "freeroute.jar" ) ), wxPATH_UNIX );
  68. if( fileName.FileExists() )
  69. m_freeRouterFound = true;
  70. m_buttonLaunchFreeroute->Enable( m_freeRouterFound );
  71. }
  72. const char * s_FreeRouteHelpInfo =
  73. #include <dialog_freeroute_exchange_help_html.h>
  74. ;
  75. void DIALOG_FREEROUTE::OnHelpButtonClick( wxCommandEvent& event )
  76. {
  77. DIALOG_DISPLAY_HTML_TEXT_BASE help_Dlg( this, wxID_ANY,
  78. _("Freeroute Help"),wxDefaultPosition, wxSize( 650,550 ) );
  79. wxString msg = FROM_UTF8(s_FreeRouteHelpInfo);
  80. help_Dlg.m_htmlWindow->AppendToPage( msg );
  81. help_Dlg.ShowModal();
  82. }
  83. void DIALOG_FREEROUTE::OnExportButtonClick( wxCommandEvent& event )
  84. {
  85. m_Parent->ExportToSpecctra( event );
  86. }
  87. void DIALOG_FREEROUTE::OnImportButtonClick( wxCommandEvent& event )
  88. {
  89. m_Parent->ImportSpecctraSession( event );
  90. }
  91. // Run freeroute, if it is available (freeroute.jar found in kicad binaries)
  92. void DIALOG_FREEROUTE::OnLaunchButtonClick( wxCommandEvent& event )
  93. {
  94. wxString dsnFile;
  95. if( m_freeRouterFound )
  96. {
  97. dsnFile = createDSN_File();
  98. if( dsnFile.IsEmpty() ) // Something is wrong or command cancelled
  99. return;
  100. }
  101. wxFileName jarfileName( FindKicadFile( wxT( "freeroute.jar" ) ), wxPATH_UNIX );
  102. wxString command;
  103. // Find the Java application on Windows.
  104. // Colud be no more needed since we now have to run only java, not java web start
  105. #ifdef __WINDOWS__
  106. // If you thought the registry was brain dead before, now you have to deal with
  107. // accessing it in either 64 or 32 bit mode depending on the build version of
  108. // Windows and the build version of KiCad.
  109. // This key works for 32 bit Java on 32 bit Windows and 64 bit Java on 64 bit Windows.
  110. wxString keyName = wxT( "SOFTWARE\\JavaSoft\\Java Runtime Environment" );
  111. wxRegKey key( wxRegKey::HKLM, keyName,
  112. wxIsPlatform64Bit() ? wxRegKey::WOW64ViewMode_64 :
  113. wxRegKey::WOW64ViewMode_Default );
  114. // It's possible that 32 bit Java is installed on 64 bit Windows.
  115. if( !key.Exists() && wxIsPlatform64Bit() )
  116. {
  117. keyName = wxT( "SOFTWARE\\Wow6432Node\\JavaSoft\\Java Runtime Environment" );
  118. key.SetName( wxRegKey::HKLM, keyName );
  119. }
  120. if( !key.Exists() )
  121. {
  122. ::wxMessageBox( _( "It appears that the Java run time environment is not "
  123. "installed on this computer. Java is required to use "
  124. "FreeRoute." ),
  125. _( "Pcbnew Error" ), wxOK | wxICON_ERROR );
  126. return;
  127. }
  128. key.Open( wxRegKey::Read );
  129. // Get the current version of java installed to determine the executable path.
  130. wxString value;
  131. key.QueryValue( wxT( "CurrentVersion" ), value );
  132. key.SetName( key.GetName() + wxT( "\\" ) + value );
  133. key.QueryValue( wxT( "JavaHome" ), value );
  134. command = value + wxFileName::GetPathSeparator();
  135. command << wxT("bin\\java");
  136. #else // __WINDOWS__
  137. command = wxT( "java" );
  138. #endif
  139. command << wxT(" -jar ");
  140. // add "freeroute.jar" to command line:
  141. command << wxChar( '"' ) << jarfileName.GetFullPath() << wxChar( '"' );
  142. // add option to load the .dsn file
  143. command << wxT( " -de " );
  144. // add *.dsn full filename (quoted):
  145. command << wxChar( '"' ) << dsnFile << wxChar( '"' );
  146. ProcessExecute( command );
  147. }
  148. const wxString DIALOG_FREEROUTE::createDSN_File()
  149. {
  150. wxFileName fn( m_Parent->GetBoard()->GetFileName() );
  151. wxString dsn_ext = SpecctraDsnFileExtension;
  152. fn.SetExt( dsn_ext );
  153. wxString mask = SpecctraDsnFileWildcard();
  154. wxString fullFileName = EDA_FILE_SELECTOR( _( "Specctra DSN File" ),
  155. fn.GetPath(), fn.GetFullName(),
  156. dsn_ext, mask,
  157. this, wxFD_SAVE, false );
  158. if( !fullFileName.IsEmpty() )
  159. {
  160. if( ! m_Parent->ExportSpecctraFile( fullFileName ) ) // the file was not created
  161. return wxEmptyString;
  162. }
  163. return fullFileName;
  164. }