Skip to content

Commit

Permalink
Merge pull request #59 from vincefn/FOXGrid2
Browse files Browse the repository at this point in the history
Fox grid2
  • Loading branch information
vincefn authored Aug 28, 2024
2 parents 6770100 + d5b2bff commit 5f14da6
Show file tree
Hide file tree
Showing 44 changed files with 4,756 additions and 3,614 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ boost_1_68_0
/cctbx*
cctbx/gnu.mak

/Fox/.vs
/Fox/Debug
/Fox/Release
cctbx/gnu.mak
Fox/cctbx_vc12.vcxproj.user
Fox/Fox_vc12.vcxproj
Fox/Fox_vc12.vcxproj.user
Fox/newmat_vc12.vcxproj.user
*.vcxproj.user
158 changes: 91 additions & 67 deletions Fox/Fox.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

24 changes: 15 additions & 9 deletions Fox/Fox_vc12.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);__WX__CRYST__;HAVE_SSE_MATHFUN;USE_SSE2;OBJCRYST_GL;HAVE_FFTW;__FOX_COD__;__DEBUG__;_WINSOCKAPI_;BOOST_MULTI_INDEX_DISABLE_SERIALIZATION</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);__WX__CRYST__;HAVE_SSE_MATHFUN;USE_SSE2;OBJCRYST_GL;HAVE_FFTW;__FOX_COD__;__DEBUG__;WIN32_LEAN_AND_MEAN;BOOST_MULTI_INDEX_DISABLE_SERIALIZATION</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)..\;$(SolutionDir)..\cctbx\include;$(SolutionDir)..\ObjCryst;$(SolutionDir)..\wxWidgets\include\msvc;$(SolutionDir)..\wxWidgets\lib\vc_lib\mswu;$(SolutionDir)..\wxWidgets\include;$(SolutionDir)..\fftw\api;$(ProjectDir)\..\boost;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ObjectFileName>$(IntDir)\%(RelativeDir)</ObjectFileName>
Expand Down Expand Up @@ -149,6 +149,8 @@
<AdditionalDependencies>newmat.lib;cctbx.lib;libfftwf-3.3.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ShowProgress>LinkVerbose</ShowProgress>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<IgnoreAllDefaultLibraries>
</IgnoreAllDefaultLibraries>
</Link>
<ResourceCompile>
<AdditionalIncludeDirectories>$(SolutionDir)..\wxWidgets\include\msvc;$(SolutionDir)..\wxWidgets\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Expand Down Expand Up @@ -283,14 +285,18 @@
<ClCompile Include="..\ObjCryst\wxCryst\wxTrackerGraph.cpp" />
<ClCompile Include="..\ObjCryst\wxCryst\wxZScatterer.cpp" />
<ClCompile Include="src\Fox.cpp" />
<ClCompile Include="src\FoxClient.cpp" />
<ClCompile Include="src\FoxJob.cpp" />
<ClCompile Include="src\FoxServer.cpp" />
<ClCompile Include="src\GridResult.cpp" />
<ClCompile Include="src\IOSocket.cpp" />
<ClCompile Include="src\WXFoxClient.cpp" />
<ClCompile Include="src\WXFoxServer.cpp" />
<ClCompile Include="src\WXGridWindow.cpp" />
<ClCompile Include="src\foxgrid\FoxGridMaster.cpp" />
<ClCompile Include="src\foxgrid\FoxGridSlave.cpp" />
<ClCompile Include="src\foxgrid\GridClient.cpp" />
<ClCompile Include="src\foxgrid\GridCommunication.cpp" />
<ClCompile Include="src\foxgrid\GridMasterBase.cpp" />
<ClCompile Include="src\foxgrid\GridServer.cpp" />
<ClCompile Include="src\foxgrid\GridSlaveBase.cpp" />
<ClCompile Include="src\foxgrid\SocketThreadClient.cpp" />
<ClCompile Include="src\foxgrid\SocketThreadServer.cpp" />
<ClCompile Include="src\foxgrid\wxFoxMaster.cpp" />
<ClCompile Include="src\foxgrid\wxFoxSlave.cpp" />
<ClCompile Include="src\foxgrid\wxGridWindow.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="src\Fox.icns" />
Expand Down
32 changes: 22 additions & 10 deletions Fox/Fox_vc12.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -204,32 +204,44 @@
<ClCompile Include="src\Fox.cpp">
<Filter>Source Files\Fox</Filter>
</ClCompile>
<ClCompile Include="src\FoxClient.cpp">
<ClCompile Include="..\ObjCryst\ObjCryst\Undo.cpp">
<Filter>Source Files\ObjCryst</Filter>
</ClCompile>
<ClCompile Include="src\foxgrid\FoxGridMaster.cpp">
<Filter>Source Files\Fox</Filter>
</ClCompile>
<ClCompile Include="src\FoxJob.cpp">
<ClCompile Include="src\foxgrid\FoxGridSlave.cpp">
<Filter>Source Files\Fox</Filter>
</ClCompile>
<ClCompile Include="src\FoxServer.cpp">
<ClCompile Include="src\foxgrid\GridClient.cpp">
<Filter>Source Files\Fox</Filter>
</ClCompile>
<ClCompile Include="src\GridResult.cpp">
<ClCompile Include="src\foxgrid\GridCommunication.cpp">
<Filter>Source Files\Fox</Filter>
</ClCompile>
<ClCompile Include="src\IOSocket.cpp">
<ClCompile Include="src\foxgrid\GridMasterBase.cpp">
<Filter>Source Files\Fox</Filter>
</ClCompile>
<ClCompile Include="src\WXFoxClient.cpp">
<ClCompile Include="src\foxgrid\GridServer.cpp">
<Filter>Source Files\Fox</Filter>
</ClCompile>
<ClCompile Include="src\WXFoxServer.cpp">
<ClCompile Include="src\foxgrid\GridSlaveBase.cpp">
<Filter>Source Files\Fox</Filter>
</ClCompile>
<ClCompile Include="src\WXGridWindow.cpp">
<ClCompile Include="src\foxgrid\SocketThreadClient.cpp">
<Filter>Source Files\Fox</Filter>
</ClCompile>
<ClCompile Include="..\ObjCryst\ObjCryst\Undo.cpp">
<Filter>Source Files\ObjCryst</Filter>
<ClCompile Include="src\foxgrid\SocketThreadServer.cpp">
<Filter>Source Files\Fox</Filter>
</ClCompile>
<ClCompile Include="src\foxgrid\wxFoxMaster.cpp">
<Filter>Source Files\Fox</Filter>
</ClCompile>
<ClCompile Include="src\foxgrid\wxFoxSlave.cpp">
<Filter>Source Files\Fox</Filter>
</ClCompile>
<ClCompile Include="src\foxgrid\wxGridWindow.cpp">
<Filter>Source Files\Fox</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Fox/cctbx_vc12.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)\..\boost;$(ProjectDir)\..\cctbx\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_MULTI_INDEX_DISABLE_SERIALIZATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ObjectFileName>$(IntDir)\%(RelativeDir)</ObjectFileName>
Expand Down
59 changes: 46 additions & 13 deletions Fox/src/Fox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
#ifdef __WX__CRYST__
#include "ObjCryst/wxCryst/wxCrystal.h"
//FOXGrid
#include "WXGridWindow.h"
#include "foxgrid/wxGridWindow.h"
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
#include "Fox.xpm"
#endif
Expand Down Expand Up @@ -593,6 +593,7 @@ int main (int argc, char *argv[])
string outfilename("Fox-out.xml");
string working_dir("");
long filenameInsertCost=-1;
long filenameInsertRwp=-1;
bool randomize(false);
bool only3D(false);
bool loadFourierGRD(false);
Expand All @@ -610,6 +611,7 @@ int main (int argc, char *argv[])
bool runclient(false);
long nbCPUs = -1;
string IP;
string port;
bool testLSQ=false;
bool testMC=false;
bool testSPEED=false;
Expand All @@ -622,12 +624,23 @@ int main (int argc, char *argv[])

if(!useGUI) {
cout << "Client output: Run client with GUI only!"<<endl;
cout << "i.e. Fox --runclient 10.0.0.1 --CPUs 4 --working_dir c:\\FOXGrid"<<endl;
cout << "i.e. Fox --runclient 10.0.0.1:2854 --CPUs 4 --working_dir c:\\FOXGrid"<<endl;
exit(0);
}
runclient = true;
i++;
IP = string(wxString(argv[i]).ToAscii());
string tmpIP = string(wxString(argv[i]).ToAscii());

size_t colonPos = tmpIP.find(':');
if (colonPos != string::npos) {
IP = tmpIP.substr(0, colonPos);
port = tmpIP.substr(colonPos + 1);
} else {
cout << "ERROR: Can't read ip address and port: " << tmpIP << endl;
cout << "Use ip with port, e.g. 10.0.0.1:2853 "<< endl;
exit(0);
}

//get nb of CPUs to use
if(STRCMP(wxString("--CPUs"),argv[i+1])==0) {
i=i+2;
Expand Down Expand Up @@ -762,6 +775,11 @@ int main (int argc, char *argv[])
filenameInsertCost = outfilename.find("#cost",0);
cout <<"Fox:#cost, pos="<<filenameInsertCost<<","<<string::npos<<endl;
if((long)(string::npos)==filenameInsertCost) filenameInsertCost=-1;

filenameInsertRwp = outfilename.find("#Rwp",0);
cout <<"Fox:#Rwp, pos="<<filenameInsertRwp<<","<<string::npos<<endl;
if((long)(string::npos)==filenameInsertRwp) filenameInsertRwp=-1;

continue;
}
if(STRCMP("--loadfouriergrd",argv[i])==0)
Expand Down Expand Up @@ -1458,6 +1476,20 @@ int main (int argc, char *argv[])
string tmpstr2=costAsChar;
tmpstr.replace(filenameInsertCost,5,tmpstr2,0,tmpstr2.length());
}
if(filenameInsertRwp>=0)
{
//update actual position
filenameInsertRwp = tmpstr.find("#Rwp",0);
char RwpAsChar[50];
float Rwp = -1;
for(unsigned int i=0;i<gPowderPatternRegistry.GetNb();++i) {
//TODO: multiphase - now, it take Rwp of the last pattern in the registry...
Rwp = gPowderPatternRegistry.GetObj(i).GetRw();
}
sprintf(RwpAsChar,"-Rwp-%.4f", Rwp);
string tmpstr2=RwpAsChar;
tmpstr.replace(filenameInsertRwp,4,tmpstr2,0,tmpstr2.length());
}
XMLCrystFileSaveGlobal(tmpstr);
cout <<"End of Fox execution. Bye !"<<endl;
//TAU_REPORT_STATISTICS();
Expand Down Expand Up @@ -1556,10 +1588,11 @@ int main (int argc, char *argv[])
mpFrame->mpGridWindow->StartClientWindow();

if(nbCPUs!=-1) {
mpFrame->mpGridWindow->m_WXFoxClient->setNbCPU(nbCPUs);
mpFrame->mpGridWindow->m_WXFoxSlave->setNbCPU(nbCPUs);
}
mpFrame->mpGridWindow->m_WXFoxClient->m_IPWindow->SetValue(wxString::FromAscii(IP.c_str()));
mpFrame->mpGridWindow->m_WXFoxClient->OnConnectClient(com);
mpFrame->mpGridWindow->m_WXFoxSlave->m_IPWindow->SetValue(wxString::FromAscii(IP.c_str()));
mpFrame->mpGridWindow->m_WXFoxSlave->m_portWindow->SetValue(wxString::FromAscii(port.c_str()));
mpFrame->mpGridWindow->m_WXFoxSlave->OnConnectClient(com);
}

return TRUE;
Expand Down Expand Up @@ -1656,9 +1689,9 @@ WXCrystMainFrame::WXCrystMainFrame(const wxString& title, const wxPoint& pos, co
#endif
//FoxGrid////////////////////////////////////////////////////////////////////
wxMenu *gridMenu = new wxMenu;
gridMenu->Append(MENU_GRID_SERVER_RUN, _T("&Run Server"), _T("Start Fox Grid Server"));
gridMenu->Append(MENU_GRID_SERVER_RUN, _T("&Run Master"), _T("Start Fox Grid Master"));
gridMenu->AppendSeparator();
gridMenu->Append(MENU_GRID_CLIENT_START, _T("&Start Client"), _T("Start Fox Grid Client"));
gridMenu->Append(MENU_GRID_CLIENT_START, _T("&Start Slave"), _T("Start Fox Grid Slave"));

wxMenu *prefsMenu = new wxMenu;
prefsMenu->Append(MENU_PREFS_PREFERENCES, _T("&Preferences..."), _T("Fox Preferences..."));
Expand Down Expand Up @@ -2059,15 +2092,15 @@ void WXCrystMainFrame::OnClose(wxCloseEvent& event)
}
void WXCrystMainFrame::SafeQuit()
{
if(mpGridWindow->m_WXFoxServer!=NULL)
if(mpGridWindow->m_WXFoxMaster!=NULL)
{
wxMessageDialog d(this,_T("You are trying to close the FOX GRID server. Are you sure?"), _T(""), wxYES | wxNO | wxCENTER | wxSTAY_ON_TOP);
if(wxID_YES!=d.ShowModal()) return;
}
if(mpGridWindow->m_WXFoxClient!=NULL){
if(mpGridWindow->m_WXFoxSlave!=NULL){
wxMessageDialog d(this,_T("You are trying to close the FOX GRID client. Are you sure?"), _T(""), wxYES | wxNO | wxCENTER | wxSTAY_ON_TOP);
if(wxID_YES!=d.ShowModal()) return;
mpGridWindow->m_WXFoxClient->CloseClient();
mpGridWindow->m_WXFoxSlave->CloseClient();
}
bool safe=true;
wxConfigBase::Get()->Read(_T("Fox/BOOL/Ask confirmation before exiting Fox"),&safe);
Expand Down Expand Up @@ -2234,7 +2267,7 @@ void WXCrystMainFrame::OnRedo(wxCommandEvent &ev)
//FOXGrid
void WXCrystMainFrame::OnStartGridServer(wxCommandEvent &event)
{
if((mpGridWindow->m_WXFoxServer!=NULL)||(mpGridWindow->m_WXFoxClient!=NULL))
if((mpGridWindow->m_WXFoxMaster!=NULL)||(mpGridWindow->m_WXFoxSlave!=NULL))
{
wxMessageDialog d(this,"You have already either a Grid client or server\n running in this instance of Fox !","Error",wxOK|wxICON_ERROR);
d.ShowModal();
Expand All @@ -2257,7 +2290,7 @@ void WXCrystMainFrame::OnStartGridServer(wxCommandEvent &event)
}
void WXCrystMainFrame::OnStartGridClient(wxCommandEvent &event)
{
if((mpGridWindow->m_WXFoxServer!=NULL)||(mpGridWindow->m_WXFoxClient!=NULL))
if((mpGridWindow->m_WXFoxMaster!=NULL)||(mpGridWindow->m_WXFoxSlave!=NULL))
{
wxMessageDialog d(this,"You have already either a Grid client or server\n running in this instance of Fox !","Error",wxOK|wxICON_ERROR);
d.ShowModal();
Expand Down
Loading

0 comments on commit 5f14da6

Please sign in to comment.