Skip to content
Snippets Groups Projects
Commit 281f6c65 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

allow to change solver name and executable location interactively in the Solver module

parent b7488e9a
No related branches found
No related tags found
No related merge requests found
......@@ -9,11 +9,74 @@
#elif defined(HAVE_NO_INTPTR_T)
typedef unsigned long intptr_t;
#endif
#include <FL/fl_ask.H>
#include "GmshMessage.h"
#include "FlGui.h"
#include "Options.h"
#include "onelabGroup.h"
#include "solverButton.h"
#include "fileDialogs.h"
static void solver_rename_cb(Fl_Widget *w, void *data)
{
if(FlGui::instance()->onelab->isBusy()){
Msg::Warning("Cannot rename client while solver is running");
return;
}
int num = (intptr_t)data;
std::string name = opt_solver_name(num, GMSH_GET, "");
onelab::server::citer it = onelab::server::instance()->findClient(name);
if(it != onelab::server::instance()->lastClient()){
delete *it;
}
const char *n = fl_input("Solver name:", "");
if(n){
opt_solver_name(num, GMSH_SET, name);
std::string exe = opt_solver_executable(num, GMSH_GET, "");
std::string host = opt_solver_remote_login(num, GMSH_GET, "");
FlGui::instance()->onelab->addSolver(n, exe, host, num);
}
FlGui::instance()->onelab->rebuildSolverList();
}
static void solver_change_exe_cb(Fl_Widget *w, void *data)
{
if(FlGui::instance()->onelab->isBusy()){
Msg::Warning("Cannot change executable name while solver is running");
return;
}
int num = (intptr_t)data;
std::string name = opt_solver_name(num, GMSH_GET, "");
onelab::server::citer it = onelab::server::instance()->findClient(name);
if(it != onelab::server::instance()->lastClient()){
delete *it;
}
std::string exe = opt_solver_executable(num, GMSH_GET, "");
std::string host = opt_solver_remote_login(num, GMSH_GET, "");
const char *old = 0;
if(exe.size()) old = exe.c_str();
std::string title = "Choose location of " + name + " executable";
std::string pattern = "*";
#if defined(WIN32)
pattern += ".exe";
#endif
if(fileChooser(FILE_CHOOSER_SINGLE, title.c_str(), pattern.c_str(), old))
exe = fileChooserGetName(1);
if(exe.size()){
opt_solver_executable(num, GMSH_SET, exe);
FlGui::instance()->onelab->addSolver(name, exe, host, num);
}
FlGui::instance()->onelab->rebuildSolverList();
}
static void solver_remove_cb(Fl_Widget *w, void *data)
{
......@@ -62,6 +125,9 @@ solverButton::solverButton(int x, int y, int w, int h, int num, Fl_Color col)
_butt[1]->selection_color(col);
_popup = new Fl_Menu_Button(x + w - popw, y, popw, h);
_popup->type(Fl_Menu_Button::POPUP123);
_popup->add("Rename...", 0, (Fl_Callback *)solver_rename_cb, (void *)(intptr_t)num, 0);
_popup->add("Change Executable Location...", 0, (Fl_Callback *)solver_change_exe_cb, (void *)(intptr_t)num,
FL_MENU_DIVIDER);
_popup->add("Remove", 0, (Fl_Callback *)solver_remove_cb, (void *)(intptr_t)num, 0);
end(); // close the group
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment