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

removed limit (was 100) on number of possible values for a solver option

parent 410556b9
No related branches found
No related tags found
No related merge requests found
...@@ -165,11 +165,10 @@ int Solver(int num, const char *args) ...@@ -165,11 +165,10 @@ int Solver(int num, const char *args)
} }
if(num >= 0){ if(num >= 0){
for(int i = 0; i < SINFO[num].nboptions; i++)
SINFO[num].nbval[i] = 0;
SINFO[num].pid = 0; SINFO[num].pid = 0;
SINFO[num].server = 0; SINFO[num].server = 0;
} }
bool initOption[5] = {true, true, true, true, true};
Msg::StatusBar(2, false, "Running '%s'", prog.c_str()); Msg::StatusBar(2, false, "Running '%s'", prog.c_str());
...@@ -211,24 +210,44 @@ int Solver(int num, const char *args) ...@@ -211,24 +210,44 @@ int Solver(int num, const char *args)
Msg::StatusBar(2, false, "%s", message); Msg::StatusBar(2, false, "%s", message);
break; break;
case GmshServer::CLIENT_OPTION_1: case GmshServer::CLIENT_OPTION_1:
if(initOption[0]){
SINFO[num].option[0].clear();
initOption[0] = false;
}
if(num >= 0) if(num >= 0)
SINFO[num].option[0][SINFO[num].nbval[0]++] = message; SINFO[num].option[0].push_back(message);
break; break;
case GmshServer::CLIENT_OPTION_2: case GmshServer::CLIENT_OPTION_2:
if(initOption[1]){
SINFO[num].option[1].clear();
initOption[1] = false;
}
if(num >= 0) if(num >= 0)
SINFO[num].option[1][SINFO[num].nbval[1]++] = message; SINFO[num].option[1].push_back(message);
break; break;
case GmshServer::CLIENT_OPTION_3: case GmshServer::CLIENT_OPTION_3:
if(initOption[2]){
SINFO[num].option[2].clear();
initOption[2] = false;
}
if(num >= 0) if(num >= 0)
SINFO[num].option[2][SINFO[num].nbval[2]++] = message; SINFO[num].option[2].push_back(message);
break; break;
case GmshServer::CLIENT_OPTION_4: case GmshServer::CLIENT_OPTION_4:
if(initOption[3]){
SINFO[num].option[3].clear();
initOption[3] = false;
}
if(num >= 0) if(num >= 0)
SINFO[num].option[3][SINFO[num].nbval[3]++] = message; SINFO[num].option[3].push_back(message);
break; break;
case GmshServer::CLIENT_OPTION_5: case GmshServer::CLIENT_OPTION_5:
if(initOption[4]){
SINFO[num].option[4].clear();
initOption[4] = false;
}
if(num >= 0) if(num >= 0)
SINFO[num].option[4][SINFO[num].nbval[4]++] = message; SINFO[num].option[4].push_back(message);
break; break;
case GmshServer::CLIENT_MERGE_FILE: case GmshServer::CLIENT_MERGE_FILE:
if(num < 0 || (num >= 0 && SINFO[num].merge_views)) { if(num < 0 || (num >= 0 && SINFO[num].merge_views)) {
...@@ -281,10 +300,11 @@ int Solver(int num, const char *args) ...@@ -281,10 +300,11 @@ int Solver(int num, const char *args)
} }
if(num >= 0){ if(num >= 0){
if(!initOption[0] || !initOption[1] || !initOption[2] ||
!initOption[3] || !initOption[4]){ // some options have been changed
for(int i = 0; i < SINFO[num].nboptions; i++) { for(int i = 0; i < SINFO[num].nboptions; i++) {
if(SINFO[num].nbval[i]) {
GUI::instance()->solver[num]->choice[i]->clear(); GUI::instance()->solver[num]->choice[i]->clear();
for(int j = 0; j < SINFO[num].nbval[i]; j++) for(int j = 0; j < SINFO[num].option[i].size(); j++)
GUI::instance()->solver[num]->choice[i]->add(SINFO[num].option[i][j].c_str()); GUI::instance()->solver[num]->choice[i]->add(SINFO[num].option[i][j].c_str());
GUI::instance()->solver[num]->choice[i]->value(0); GUI::instance()->solver[num]->choice[i]->value(0);
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#define _SOLVERS_H_ #define _SOLVERS_H_
#include <string> #include <string>
#include <vector>
#define MAX_NUM_SOLVERS 5 #define MAX_NUM_SOLVERS 5
#define MAX_NUM_SOLVER_OPTIONS 5 #define MAX_NUM_SOLVER_OPTIONS 5
...@@ -21,8 +22,8 @@ typedef struct{ ...@@ -21,8 +22,8 @@ typedef struct{
std::string button_name[MAX_NUM_SOLVER_OPTIONS]; std::string button_name[MAX_NUM_SOLVER_OPTIONS];
std::string button_command[MAX_NUM_SOLVER_OPTIONS]; std::string button_command[MAX_NUM_SOLVER_OPTIONS];
std::string option_name[MAX_NUM_SOLVER_OPTIONS], option_command; std::string option_name[MAX_NUM_SOLVER_OPTIONS], option_command;
std::string option[MAX_NUM_SOLVER_OPTIONS][100]; std::vector<std::string> option[MAX_NUM_SOLVER_OPTIONS];
int nboptions, nbval[MAX_NUM_SOLVER_OPTIONS]; int nboptions;
std::string help; std::string help;
int client_server, popup_messages, merge_views; int client_server, popup_messages, merge_views;
int pid; int pid;
......
...@@ -110,7 +110,7 @@ static void solver_command_cb(Fl_Widget *w, void *data) ...@@ -110,7 +110,7 @@ static void solver_command_cb(Fl_Widget *w, void *data)
char tmp[256], mesh[256], arg[512], command[256]; char tmp[256], mesh[256], arg[512], command[256];
int num = ((int *)data)[0]; int num = ((int *)data)[0];
int idx = ((int *)data)[1]; int idx = ((int *)data)[1];
int i, usedopts = 0; int usedopts = 0;
if(SINFO[num].popup_messages) if(SINFO[num].popup_messages)
GUI::instance()->messages->show(true); GUI::instance()->messages->show(true);
...@@ -125,14 +125,18 @@ static void solver_command_cb(Fl_Widget *w, void *data) ...@@ -125,14 +125,18 @@ static void solver_command_cb(Fl_Widget *w, void *data)
} }
if(nbs(SINFO[num].button_command[idx].c_str())) { if(nbs(SINFO[num].button_command[idx].c_str())) {
for(i = 0; i < idx; i++) for(int i = 0; i < idx; i++)
usedopts += nbs(SINFO[num].button_command[i].c_str()); usedopts += nbs(SINFO[num].button_command[i].c_str());
if(usedopts > SINFO[num].nboptions) { if(usedopts > SINFO[num].nboptions) {
Msg::Error("Missing options to execute command"); Msg::Error("Missing options to execute command");
return; return;
} }
sprintf(command, SINFO[num].button_command[idx].c_str(), SINFO[num].option int val = GUI::instance()->solver[num]->choice[usedopts]->value();
[usedopts][GUI::instance()->solver[num]->choice[usedopts]->value()].c_str()); if(val < SINFO[num].option[usedopts].size())
sprintf(command, SINFO[num].button_command[idx].c_str(),
SINFO[num].option[usedopts][val].c_str());
else
Msg::Error("Invalid option index: missing value");
} }
else { else {
strcpy(command, SINFO[num].button_command[idx].c_str()); strcpy(command, SINFO[num].button_command[idx].c_str());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment