From 9996f89e3bf761bbbbb0db4c51f0456928ee450c Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 20 Oct 2011 06:40:58 +0000 Subject: [PATCH] onelab refinements --- Common/DefaultOptions.h | 35 +++++++++++++++-------------------- Common/Options.cpp | 10 +++++----- Common/Options.h | 2 +- Common/onelab.h | 8 ++++++-- Fltk/onelabWindow.cpp | 20 +++++++++++--------- Fltk/onelabWindow.h | 3 ++- 6 files changed, 40 insertions(+), 38 deletions(-) diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index e928c6c7cf..27853d4e75 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -62,15 +62,15 @@ StringXString GeneralOptions_String[] = { { F|S, "OptionsFileName" , opt_general_options_filename , ".gmsh-options" , "Option file created with `Tools->Options->Save'; automatically read on startup" }, - { F|S, "RecentFile1", opt_general_recent_file1 , "untitled.geo" , + { F|S, "RecentFile0", opt_general_recent_file0 , "untitled.geo" , "Most recent opened file"}, - { F|S, "RecentFile2", opt_general_recent_file2 , "untitled.geo" , + { F|S, "RecentFile1", opt_general_recent_file1 , "untitled.geo" , "2nd most recent opened file"}, - { F|S, "RecentFile3", opt_general_recent_file3 , "untitled.geo" , + { F|S, "RecentFile2", opt_general_recent_file2 , "untitled.geo" , "3rd most recent opened file"}, - { F|S, "RecentFile4", opt_general_recent_file4 , "untitled.geo" , + { F|S, "RecentFile3", opt_general_recent_file3 , "untitled.geo" , "4th most recent opened file"}, - { F|S, "RecentFile5", opt_general_recent_file5 , "untitled.geo" , + { F|S, "RecentFile4", opt_general_recent_file4 , "untitled.geo" , "5th most recent opened file"}, { 0, "SessionFileName" , opt_general_session_filename , ".gmshrc" , @@ -114,31 +114,26 @@ StringXString MeshOptions_String[] = { } ; StringXString SolverOptions_String[] = { - { F|O, "Executable0" , opt_solver_executable0 , -#if defined(WIN32) - "getdp.exe" , -#else - "getdp" , -#endif + { F|S, "Executable0" , opt_solver_executable0 , "", "System command to launch solver 0 (should not contain the `&' character)" }, - { F|O, "Executable1" , opt_solver_executable1 , "" , + { F|S, "Executable1" , opt_solver_executable1 , "" , "System command to launch solver 1 (should not contain the `&' character)" }, - { F|O, "Executable2" , opt_solver_executable2 , "" , + { F|S, "Executable2" , opt_solver_executable2 , "" , "System command to launch solver 2 (should not contain the `&' character)" }, - { F|O, "Executable3" , opt_solver_executable3 , "" , + { F|S, "Executable3" , opt_solver_executable3 , "" , "System command to launch solver 3 (should not contain the `&' character)" }, - { F|O, "Executable4" , opt_solver_executable4 , "" , + { F|S, "Executable4" , opt_solver_executable4 , "" , "System command to launch solver 4 (should not contain the `&' character)" }, - { F|O, "Name0" , opt_solver_name0 , "GetDP" , + { F|S, "Name0" , opt_solver_name0 , "GetDP" , "Name of solver 0" }, - { F|O, "Name1" , opt_solver_name1 , "" , + { F|S, "Name1" , opt_solver_name1 , "" , "Name of solver 1" }, - { F|O, "Name2" , opt_solver_name1 , "" , + { F|S, "Name2" , opt_solver_name1 , "" , "Name of solver 2" }, - { F|O, "Name3" , opt_solver_name1 , "" , + { F|S, "Name3" , opt_solver_name1 , "" , "Name of solver 3" }, - { F|O, "Name4" , opt_solver_name1 , "" , + { F|S, "Name4" , opt_solver_name1 , "" , "Name of solver 4" }, { F|O, "SocketName" , opt_solver_socket_name , diff --git a/Common/Options.cpp b/Common/Options.cpp index ae2d20aada..7442decd66 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -989,35 +989,35 @@ std::string opt_general_options_filename(OPT_ARGS_STR) return CTX::instance()->optionsFileName; } -std::string opt_general_recent_file1(OPT_ARGS_STR) +std::string opt_general_recent_file0(OPT_ARGS_STR) { if(action & GMSH_SET) CTX::instance()->recentFiles[0] = val; return CTX::instance()->recentFiles[0]; } -std::string opt_general_recent_file2(OPT_ARGS_STR) +std::string opt_general_recent_file1(OPT_ARGS_STR) { if(action & GMSH_SET) CTX::instance()->recentFiles[1] = val; return CTX::instance()->recentFiles[1]; } -std::string opt_general_recent_file3(OPT_ARGS_STR) +std::string opt_general_recent_file2(OPT_ARGS_STR) { if(action & GMSH_SET) CTX::instance()->recentFiles[2] = val; return CTX::instance()->recentFiles[2]; } -std::string opt_general_recent_file4(OPT_ARGS_STR) +std::string opt_general_recent_file3(OPT_ARGS_STR) { if(action & GMSH_SET) CTX::instance()->recentFiles[3] = val; return CTX::instance()->recentFiles[3]; } -std::string opt_general_recent_file5(OPT_ARGS_STR) +std::string opt_general_recent_file4(OPT_ARGS_STR) { if(action & GMSH_SET) CTX::instance()->recentFiles[4] = val; diff --git a/Common/Options.h b/Common/Options.h index 3944fa320a..b576f07126 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -39,11 +39,11 @@ std::string opt_general_tmp_filename(OPT_ARGS_STR); std::string opt_general_error_filename(OPT_ARGS_STR); std::string opt_general_session_filename(OPT_ARGS_STR); std::string opt_general_options_filename(OPT_ARGS_STR); +std::string opt_general_recent_file0(OPT_ARGS_STR); std::string opt_general_recent_file1(OPT_ARGS_STR); std::string opt_general_recent_file2(OPT_ARGS_STR); std::string opt_general_recent_file3(OPT_ARGS_STR); std::string opt_general_recent_file4(OPT_ARGS_STR); -std::string opt_general_recent_file5(OPT_ARGS_STR); std::string opt_general_editor(OPT_ARGS_STR); std::string opt_general_web_browser(OPT_ARGS_STR); std::string opt_general_watch_file_pattern(OPT_ARGS_STR); diff --git a/Common/onelab.h b/Common/onelab.h index 3f88b7c48d..4f35d1bf12 100644 --- a/Common/onelab.h +++ b/Common/onelab.h @@ -451,12 +451,16 @@ namespace onelab{ std::string _name; // the id of the client, used to create a unique socket for this client int _id; + // the index of the client in an external solver list (if any) + int _index; public: - client(const std::string &name) : _name(name){} + client(const std::string &name) : _name(name), _id(0), _index(-1){} virtual ~client(){} std::string getName(){ return _name; } void setId(int id){ _id = id; } int getId(){ return _id; } + void setIndex(int index){ _index = index; } + int getIndex(){ return _index; } virtual bool run(const std::string &what){ return false; } virtual bool isNetworkClient(){ return false; } virtual bool kill(){ return false; } @@ -590,7 +594,7 @@ namespace onelab{ int getPid(){ return _pid; } void setPid(int pid){ _pid = pid; } GmshServer *getGmshServer(){ return _gmshServer; } - void setServer(GmshServer *server){ _gmshServer = server; } + void setGmshServer(GmshServer *server){ _gmshServer = server; } virtual bool run(const std::string &what); virtual bool kill(); }; diff --git a/Fltk/onelabWindow.cpp b/Fltk/onelabWindow.cpp index 88de82c7c8..e530f55c4b 100644 --- a/Fltk/onelabWindow.cpp +++ b/Fltk/onelabWindow.cpp @@ -65,7 +65,7 @@ class onelabGmshServer : public GmshServer{ else{ // an error happened _client->setPid(-1); - _client->setServer(0); + _client->setGmshServer(0); return 1; } } @@ -434,8 +434,8 @@ static void onelab_choose_executable_cb(Fl_Widget *w, void *data) if(fileChooser(FILE_CHOOSER_SINGLE, "Choose executable", pattern.c_str())){ std::string exe = fileChooserGetName(1); c->setCommandLine(exe); - // FIXME hack - opt_solver_executable(0, GMSH_SET, exe); + if(c->getIndex() >= 0 && c->getIndex() < 5) + opt_solver_executable(c->getIndex(), GMSH_SET, exe); } } @@ -604,11 +604,15 @@ void onelabWindow::rebuildSolverList() _win->label(_title.c_str()); } -void onelabWindow::addSolver(const std::string &name, const std::string &commandLine) +void onelabWindow::addSolver(const std::string &name, const std::string &commandLine, + int index) { onelab::server::citer it = onelab::server::instance()->findClient(name); - if(it == onelab::server::instance()->lastClient()) - new onelab::localNetworkClient(name, commandLine); + if(it == onelab::server::instance()->lastClient()){ + onelab::localNetworkClient *c = new onelab::localNetworkClient(name, commandLine); + c->setIndex(index); + if(commandLine.empty()) onelab_choose_executable_cb(0, (void *)c); + } FlGui::instance()->onelab->rebuildSolverList(); } @@ -624,21 +628,19 @@ void onelabWindow::removeSolver(const std::string &name) FlGui::instance()->onelab->rebuildSolverList(); } -// new solver interface (onelab-based) void solver_cb(Fl_Widget *w, void *data) { int num = (intptr_t)data; std::string name = opt_solver_name(num, GMSH_GET, ""); std::string exe = opt_solver_executable(num, GMSH_GET, ""); - FlGui::instance()->onelab->addSolver(name, exe); + FlGui::instance()->onelab->addSolver(name, exe, num); onelab_cb(0, (void*)"initial check"); } #else -// new solver interface (onelab-based) void solver_cb(Fl_Widget *w, void *data) { Msg::Error("The solver interface requires FLTK 1.3"); diff --git a/Fltk/onelabWindow.h b/Fltk/onelabWindow.h index 123f5a7e6d..7bb93a8c23 100644 --- a/Fltk/onelabWindow.h +++ b/Fltk/onelabWindow.h @@ -45,7 +45,8 @@ class onelabWindow{ _tree->item_pathname(path, 1024, item); return std::string(path); } - void addSolver(const std::string &name, const std::string &commandLine); + void addSolver(const std::string &name, const std::string &commandLine, + int index); void removeSolver(const std::string &name); }; -- GitLab