int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& param ) { wxString FullFileName; FullFileName = FindKicadFile( ExecFile ); #ifdef __WXMAC__ if( wxFileExists( FullFileName ) || wxDir::Exists( FullFileName ) ) { ProcessExecute( wxT("open -a ") + ExecFile + wxT(" ") + param ); } else { ProcessExecute( wxT("open ") + param ); } return 0; #else if( wxFileExists( FullFileName ) ) { if( !param.IsEmpty() ) FullFileName += wxT( " " ) + param; ProcessExecute( FullFileName ); return 0; } #endif wxString msg; msg.Printf( _( "Command <%s> could not found" ), GetChars( FullFileName ) ); DisplayError( frame, msg, 20 ); return -1; }
int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& param, wxProcess *callback ) { wxString fullFileName; fullFileName = FindKicadFile( ExecFile ); #ifdef __WXMAC__ if( wxFileExists( fullFileName ) || wxDir::Exists( fullFileName ) ) { return ProcessExecute( Pgm().GetExecutablePath() + wxT( "/" ) + ExecFile + wxT( " " ) + param, wxEXEC_ASYNC, callback ); } else { return ProcessExecute( wxT( "/usr/bin/open " ) + param, wxEXEC_ASYNC, callback ); } #else if( wxFileExists( fullFileName ) ) { if( !param.IsEmpty() ) fullFileName += wxT( " " ) + param; return ProcessExecute( fullFileName, wxEXEC_ASYNC, callback ); } #endif wxString msg; msg.Printf( _( "Command <%s> could not found" ), GetChars( fullFileName ) ); DisplayError( frame, msg, 20 ); return -1; }
/* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RUN_FREEROUTE */ void DIALOG_FREEROUTE::OnLaunchButtonClick( wxCommandEvent& event ) { wxString url; wxString command; wxFileName fileName( FindKicadFile( wxT( "freeroute.jnlp" ) ), wxPATH_UNIX ); if( fileName.FileExists() ) { wxString javaWebStartCommand = wxT( "javaws" ); // Find the Java web start application on Windows. #ifdef __WINDOWS__ // If you thought the registry was brain dead before, now you have to deal with // accessing it in either 64 or 32 bit mode depending on the build version of // Windows and the build version of KiCad. // This key works for 32 bit Java on 32 bit Windows and 64 bit Java on 64 bit Windows. wxRegKey key( wxRegKey::HKLM, wxT( "SOFTWARE\\JavaSoft\\Java Web Start" ), wxIsPlatform64Bit() ? wxRegKey::WOW64ViewMode_64 : wxRegKey::WOW64ViewMode_Default ); // It's possible that 32 bit Java is installed on 64 bit Windows. if( !key.Exists() && wxIsPlatform64Bit() ) key.SetName( wxRegKey::HKLM, wxT( "SOFTWARE\\Wow6432Node\\JavaSoft\\Java Web Start" ) ); if( !key.Exists() ) { ::wxMessageBox( _( "It appears that the Java run time environment is not " "installed on this computer. Java is required to use " "FreeRoute." ), _( "Pcbnew Error" ), wxOK | wxICON_ERROR ); return; } key.Open( wxRegKey::Read ); // Get the current version of java installed to determine the executable path. wxString value; key.QueryValue( wxT( "CurrentVersion" ), value ); key.SetName( key.GetName() + wxT( "\\" ) + value ); key.QueryValue( wxT( "Home" ), value ); javaWebStartCommand = value + wxFileName::GetPathSeparator() + javaWebStartCommand; #endif // Wrap FullFileName in double quotes in case it has C:\Program Files in it. // The space is interpreted as an argument separator. command << javaWebStartCommand << wxChar( ' ' ) << wxChar( '"' ) << fileName.GetFullPath() << wxChar( '"' ); ProcessExecute( command ); return; } url = m_FreerouteURLName->GetValue() + wxT( "/java/freeroute.jnlp" ); wxLaunchDefaultBrowser( url ); }
// Specific data initialization void DIALOG_FREEROUTE::MyInit() { SetFocus(); m_freeRouterFound = false; wxFileName fileName( FindKicadFile( wxT( "freeroute.jar" ) ), wxPATH_UNIX ); if( fileName.FileExists() ) m_freeRouterFound = true; m_buttonLaunchFreeroute->Enable( m_freeRouterFound ); }
int ExecuteFile(wxWindow * frame, const wxString & ExecFile, const wxString & param) /***********************************************************************************/ /* appelle le logiciel ExecFile, avec les parametres filename */ { wxString FullFileName; FullFileName = FindKicadFile(ExecFile); if ( wxFileExists(FullFileName) ) { if( param != "" ) FullFileName += " " + param; wxExecute(FullFileName); return 0; } wxString msg; msg.Printf("Command file <%s> not found", FullFileName.GetData() ); DisplayError(frame, msg, 20); return -1; }
void Write_GENERIC_NetList(wxWindow * frame, const wxString & FullFileName) /***********************************************************************/ /* Create a generic netlist, and call an external netlister to change the netlist syntax and create the file */ { wxString Line, FootprintName; BASE_SCREEN *CurrScreen; EDA_BaseStruct *DrawList; EDA_SchComponentStruct *Component; wxString netname; int ii; FILE * tmpfile; wxString TmpFullFileName = FullFileName; ChangeFileNameExt(TmpFullFileName, ".tmp"); if ((tmpfile = fopen(TmpFullFileName, "wt")) == NULL) { wxString msg = _("Failed to create file ") + TmpFullFileName; DisplayError(frame, msg); return; } ClearUsedFlags(); /* Reset the flags FlagControlMulti in all schematic files*/ fprintf( tmpfile, "$BeginNetlist\n" ); /* Create netlist module section */ fprintf( tmpfile, "$BeginComponentList\n" ); for(CurrScreen = ScreenSch; CurrScreen != NULL; CurrScreen = (BASE_SCREEN*)CurrScreen->Pnext ) { for ( DrawList = CurrScreen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) { DrawList = Component = FindNextComponentAndCreatPinList(DrawList); if ( Component == NULL ) break; // No component left FootprintName.Empty(); if( ! Component->m_Field[FOOTPRINT].IsVoid() ) { FootprintName = Component->m_Field[FOOTPRINT].m_Text; FootprintName.Replace(" ", "_"); } fprintf( tmpfile, "\n$BeginComponent\n" ); fprintf(tmpfile, "TimeStamp=%8.8lX\n", Component->m_TimeStamp); fprintf(tmpfile, "Footprint=%s\n", FootprintName.GetData()); Line = "Reference=" + Component->m_Field[REFERENCE].m_Text + "\n"; Line.Replace(" ", "_"); fprintf(tmpfile, Line.GetData()); Line = Component->m_Field[VALUE].m_Text; Line.Replace(" ", "_"); fprintf(tmpfile, "Value=%s\n", Line.GetData()); Line = Component->m_ChipName; Line.Replace(" ", "_"); fprintf(tmpfile, "Libref=%s\n", Line.GetData()); // Write pin list: fprintf( tmpfile, "$BeginPinList\n" ); for (ii = 0; ii < s_SortedPinCount; ii++) { ObjetNetListStruct *Pin = s_SortedComponentPinList[ii]; if( ! Pin ) continue; netname = ReturnPinNetName(Pin, "$-%.6d"); if ( netname == "" ) netname = "?"; fprintf( tmpfile,"%.4s=%s\n",(char *)&Pin->m_PinNum, netname.GetData()); } fprintf( tmpfile, "$EndPinList\n" ); fprintf( tmpfile, "$EndComponent\n" ); } } MyFree(s_SortedComponentPinList); s_SortedComponentPinList = NULL; fprintf( tmpfile, "$EndComponentList\n" ); fprintf( tmpfile, "\n$BeginNets\n" ); WriteGENERICListOfNets( tmpfile, g_TabObjNet ); fprintf( tmpfile, "$EndNets\n" ); fprintf( tmpfile, "\n$EndNetlist\n" ); fclose(tmpfile); // Call the external module (plug in ) if ( g_NetListerCommandLine == "" ) return; wxString CommandFile; if ( wxIsAbsolutePath(g_NetListerCommandLine) ) CommandFile = g_NetListerCommandLine; else CommandFile = FindKicadFile(g_NetListerCommandLine); CommandFile += " " + TmpFullFileName; CommandFile += " " + FullFileName; wxExecute(CommandFile, wxEXEC_SYNC); }
// Run freeroute, if it is available (freeroute.jar found in kicad binaries) void DIALOG_FREEROUTE::OnLaunchButtonClick( wxCommandEvent& event ) { wxString dsnFile; if( m_freeRouterFound ) { dsnFile = createDSN_File(); if( dsnFile.IsEmpty() ) // Something is wrong or command cancelled return; } wxFileName jarfileName( FindKicadFile( wxT( "freeroute.jar" ) ), wxPATH_UNIX ); wxString command; // Find the Java application on Windows. // Colud be no more needed since we now have to run only java, not java web start #ifdef __WINDOWS__ // If you thought the registry was brain dead before, now you have to deal with // accessing it in either 64 or 32 bit mode depending on the build version of // Windows and the build version of KiCad. // This key works for 32 bit Java on 32 bit Windows and 64 bit Java on 64 bit Windows. wxString keyName = wxT( "SOFTWARE\\JavaSoft\\Java Runtime Environment" ); wxRegKey key( wxRegKey::HKLM, keyName, wxIsPlatform64Bit() ? wxRegKey::WOW64ViewMode_64 : wxRegKey::WOW64ViewMode_Default ); // It's possible that 32 bit Java is installed on 64 bit Windows. if( !key.Exists() && wxIsPlatform64Bit() ) { keyName = wxT( "SOFTWARE\\Wow6432Node\\JavaSoft\\Java Runtime Environment" ); key.SetName( wxRegKey::HKLM, keyName ); } if( !key.Exists() ) { ::wxMessageBox( _( "It appears that the Java run time environment is not " "installed on this computer. Java is required to use " "FreeRoute." ), _( "Pcbnew Error" ), wxOK | wxICON_ERROR ); return; } key.Open( wxRegKey::Read ); // Get the current version of java installed to determine the executable path. wxString value; key.QueryValue( wxT( "CurrentVersion" ), value ); key.SetName( key.GetName() + wxT( "\\" ) + value ); key.QueryValue( wxT( "JavaHome" ), value ); command = value + wxFileName::GetPathSeparator(); command << wxT("bin\\java"); #else // __WINDOWS__ command = wxT( "java" ); #endif command << wxT(" -jar "); // add "freeroute.jar" to command line: command << wxChar( '"' ) << jarfileName.GetFullPath() << wxChar( '"' ); // add option to load the .dsn file command << wxT( " -de " ); // add *.dsn full filename (quoted): command << wxChar( '"' ) << dsnFile << wxChar( '"' ); ProcessExecute( command ); }