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

replaced manual "refresh" with automatic refresh based on requests from clients

parent 77fb25df
No related branches found
No related tags found
No related merge requests found
...@@ -60,9 +60,17 @@ class onelabGmshServer : public GmshServer{ ...@@ -60,9 +60,17 @@ class onelabGmshServer : public GmshServer{
// check if there is data (call select with a zero timeout to // check if there is data (call select with a zero timeout to
// return immediately, i.e., do polling) // return immediately, i.e., do polling)
int ret = Select(0, 0, socket); int ret = Select(0, 0, socket);
if(ret == 0){ if(ret == 0){ // nothing available
// nothing available: wait at most waitint seconds, and in the // if asked, refresh the onelab GUI
// meantime respond to FLTK events std::vector<onelab::string> ps;
onelab::server::instance()->get(ps, "Gmsh/Action");
if(ps.size() && ps[0].getValue() == "refresh"){
ps[0].setVisible(false);
ps[0].setValue("");
onelab::server::instance()->set(ps[0]);
onelab_cb(0, (void*)"refresh");
}
// wait at most waitint seconds and respond to FLTK events
FlGui::instance()->wait(waitint); FlGui::instance()->wait(waitint);
} }
else if(ret > 0){ else if(ret > 0){
...@@ -372,7 +380,7 @@ static void guessModelName(onelab::client *c) ...@@ -372,7 +380,7 @@ static void guessModelName(onelab::client *c)
} }
} }
static void initializeLoop(std::string level) static void initializeLoop(const std::string &level)
{ {
bool changed = false; bool changed = false;
std::vector<onelab::number> numbers; std::vector<onelab::number> numbers;
...@@ -399,7 +407,7 @@ static void initializeLoop(std::string level) ...@@ -399,7 +407,7 @@ static void initializeLoop(std::string level)
onelab::server::instance()->setChanged(true, "Gmsh"); onelab::server::instance()->setChanged(true, "Gmsh");
} }
static bool incrementLoop(std::string level) static bool incrementLoop(const std::string &level)
{ {
bool recompute = false, loop = false; bool recompute = false, loop = false;
std::vector<onelab::number> numbers; std::vector<onelab::number> numbers;
...@@ -478,20 +486,19 @@ static std::vector<double> getRange(onelab::number &p) ...@@ -478,20 +486,19 @@ static std::vector<double> getRange(onelab::number &p)
return v; return v;
} }
static bool updateOnelabGraph(int num) static bool updateOnelabGraph(const std::string &snum)
{ {
bool changed = false; bool changed = false;
std::stringstream snum;
snum << num;
for(unsigned int i = 0; i < PView::list.size(); i++){ for(unsigned int i = 0; i < PView::list.size(); i++){
if(PView::list[i]->getData()->getFileName() == "OneLab" + snum.str()){ if(PView::list[i]->getData()->getFileName() == "OneLab" + snum){
delete PView::list[i]; delete PView::list[i];
changed = true; changed = true;
break; break;
} }
} }
int num = atoi(snum.c_str());
std::vector<double> x, y; std::vector<double> x, y;
std::string xName, yName; std::string xName, yName;
std::vector<onelab::number> numbers; std::vector<onelab::number> numbers;
...@@ -514,7 +521,7 @@ static bool updateOnelabGraph(int num) ...@@ -514,7 +521,7 @@ static bool updateOnelabGraph(int num)
} }
if(x.size() && y.size()){ if(x.size() && y.size()){
PView *v = new PView(xName, yName, x, y); PView *v = new PView(xName, yName, x, y);
v->getData()->setFileName("OneLab" + snum.str()); v->getData()->setFileName("OneLab" + snum);
v->getOptions()->intervalsType = PViewOptions::Discrete; v->getOptions()->intervalsType = PViewOptions::Discrete;
changed = true; changed = true;
} }
...@@ -525,10 +532,10 @@ static bool updateOnelabGraph(int num) ...@@ -525,10 +532,10 @@ static bool updateOnelabGraph(int num)
static void updateOnelabGraphs() static void updateOnelabGraphs()
{ {
bool redraw0 = updateOnelabGraph(0); bool redraw0 = updateOnelabGraph("0");
bool redraw1 = updateOnelabGraph(1); bool redraw1 = updateOnelabGraph("1");
bool redraw2 = updateOnelabGraph(2); bool redraw2 = updateOnelabGraph("2");
bool redraw3 = updateOnelabGraph(3); bool redraw3 = updateOnelabGraph("3");
if(redraw0 || redraw1 || redraw2 || redraw3) if(redraw0 || redraw1 || redraw2 || redraw3)
drawContext::global()->draw(); drawContext::global()->draw();
} }
...@@ -599,10 +606,8 @@ void onelab_cb(Fl_Widget *w, void *data) ...@@ -599,10 +606,8 @@ void onelab_cb(Fl_Widget *w, void *data)
std::string action((const char*)data); std::string action((const char*)data);
if(action == "refresh"){ if(action == "refresh"){
FlGui::instance()->onelab->setButtonMode("", "stop");
updateOnelabGraphs(); updateOnelabGraphs();
FlGui::instance()->onelab->rebuildTree(); FlGui::instance()->onelab->rebuildTree();
FlGui::instance()->onelab->setButtonMode("refresh", "stop");
return; return;
} }
...@@ -665,10 +670,7 @@ void onelab_cb(Fl_Widget *w, void *data) ...@@ -665,10 +670,7 @@ void onelab_cb(Fl_Widget *w, void *data)
action = "check"; action = "check";
} }
if(action == "compute") FlGui::instance()->onelab->setButtonMode("", "stop");
FlGui::instance()->onelab->setButtonMode("refresh", "stop");
else
FlGui::instance()->onelab->setButtonMode("", "stop");
if(action == "compute") initializeLoop(); if(action == "compute") initializeLoop();
...@@ -994,11 +996,6 @@ void onelabWindow::setButtonMode(const std::string &butt0, const std::string &bu ...@@ -994,11 +996,6 @@ void onelabWindow::setButtonMode(const std::string &butt0, const std::string &bu
_butt[0]->label("Check"); _butt[0]->label("Check");
_butt[0]->callback(onelab_cb, (void*)"check"); _butt[0]->callback(onelab_cb, (void*)"check");
} }
else if(butt0 == "refresh"){
_butt[0]->activate();
_butt[0]->label("Refresh");
_butt[0]->callback(onelab_cb, (void*)"refresh");
}
else{ else{
_butt[0]->deactivate(); _butt[0]->deactivate();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment