diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index e5f9ded7eae1bdd510e8c000834bd79696def7d5..3d825064544f1a2d1366982b57d44666400010f3 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -310,7 +310,9 @@ void Msg::Error(const char *fmt, ...) #if defined(HAVE_FLTK) if(FlGui::available()){ +#ifndef HAVE_ONELAB2 FlGui::instance()->check(); +#endif std::string tmp = std::string("@C1@.") + "Error : " + str; FlGui::instance()->addMessage(tmp.c_str()); if(_firstError.empty()) _firstError = str; @@ -427,7 +429,9 @@ void Msg::Direct(const char *fmt, ...) #endif { if(FlGui::available()){ +#ifndef HAVE_ONELAB2 FlGui::instance()->check(); +#endif std::string tmp = std::string("@C4@.") + str; FlGui::instance()->addMessage(tmp.c_str()); } @@ -466,7 +470,9 @@ void Msg::StatusBar(bool log, const char *fmt, ...) #endif { if(FlGui::available()){ +#ifndef HAVE_ONELAB2 if(log) FlGui::instance()->check(); +#endif if(!log || _verbosity > 4) FlGui::instance()->setStatus(str); if(log){ @@ -728,14 +734,22 @@ void Msg::SetOnelabNumber(std::string name, double val, bool visible) #if defined(HAVE_ONELAB) if(_onelabClient){ std::vector<onelab::number> numbers; +#ifdef HAVE_ONELAB2 + _onelabClient->get(numbers, name, "Gmsh"); +#else _onelabClient->get(numbers, name); +#endif if(numbers.empty()){ numbers.resize(1); numbers[0].setName(name); } numbers[0].setValue(val); numbers[0].setVisible(visible); +#ifdef HAVE_ONELAB2 + _onelabClient->set(numbers[0], "Gmsh"); +#else _onelabClient->set(numbers[0]); +#endif } #endif } @@ -745,14 +759,22 @@ void Msg::SetOnelabString(std::string name, std::string val, bool visible) #if defined(HAVE_ONELAB) if(_onelabClient){ std::vector<onelab::string> strings; +#ifdef HAVE_ONELAB2 + _onelabClient->get(strings, name, "Gmsh"); +#else _onelabClient->get(strings, name); +#endif if(strings.empty()){ strings.resize(1); strings[0].setName(name); } strings[0].setValue(val); strings[0].setVisible(visible); +#ifdef HAVE_ONELAB2 + _onelabClient->set(strings[0], "Gmsh"); +#else _onelabClient->set(strings[0]); +#endif } #endif } @@ -820,7 +842,11 @@ void Msg::InitializeOnelab(const std::string &name, const std::string &sockname) SetOnelabString(name + "/9CheckCommand", "-", false); SetOnelabString(name + "/9ComputeCommand", "-3", false); std::vector<onelab::string> ps; +#ifdef HAVE_ONELAB2 + _onelabClient->get(ps, name + "/Action", "Gmsh"); +#else _onelabClient->get(ps, name + "/Action"); +#endif if(ps.size()){ Info("Performing ONELAB '%s'", ps[0].getValue().c_str()); if(ps[0].getValue() == "initialize") Exit(0); @@ -851,7 +877,11 @@ void Msg::InitializeOnelab(const std::string &name, const std::string &sockname) SetOnelabString(name + "/9ComputeCommand", "-3", false); std::vector<onelab::string> ps; +#ifdef HAVE_ONELAB2 + _onelabClient->get(ps, name + "/Action", "Gmsh"); +#else _onelabClient->get(ps, name + "/Action"); +#endif if(ps.size()){ //Info("Performing ONELAB '%s'", ps[0].getValue().c_str()); if(ps[0].getValue() == "initialize") Exit(0); @@ -961,7 +991,11 @@ void Msg::ExchangeOnelabParameter(const std::string &key, } std::vector<onelab::number> ps; +#ifdef HAVE_ONELAB2 + _onelabClient->get(ps, name, "Gmsh"); +#else _onelabClient->get(ps, name); +#endif bool noRange = true, noChoices = true, noLoop = true; bool noGraph = true, noClosed = true; if(ps.size()){ @@ -1041,8 +1075,12 @@ void Msg::ExchangeOnelabParameter(const std::string &key, if(noClosed && fopt.count("Closed")) ps[0].setAttribute("Closed", fopt["Closed"][0] ? "1" : "0"); _setStandardOptions(&ps[0], fopt, copt); +#ifdef HAVE_ONELAB2 + _onelabClient->set(ps[0], "Gmsh"); +#else _onelabClient->set(ps[0]); #endif +#endif } void Msg::ExchangeOnelabParameter(const std::string &key, @@ -1095,8 +1133,12 @@ void Msg::ExchangeOnelabParameter(const std::string &key, if(noMultipleSelection && copt.count("MultipleSelection")) ps[0].setAttribute("MultipleSelection", copt["MultipleSelection"][0]); _setStandardOptions(&ps[0], fopt, copt); +#ifdef HAVE_ONELAB2 + _onelabClient->set(ps[0], "Gmsh"); +#else _onelabClient->set(ps[0]); #endif +#endif } void Msg::UndefineOnelabParameter(const std::string &name) diff --git a/Common/onelab.h b/Common/onelab.h index b8f47ad690b86996e70fe95b52507585db907cc9..42e63d3c02798213a0f2852405146f233899e37f 100644 --- a/Common/onelab.h +++ b/Common/onelab.h @@ -93,7 +93,7 @@ namespace onelab{ } else{ for(std::map<std::string, bool>::iterator it = _clients.begin(); - it != _clients.end(); it++) + it != _clients.end(); it++) it->second = changed; } } @@ -1048,6 +1048,16 @@ namespace onelab{ } return true; } + template <class T> T* _getPtr(std::string name, const std::string client, std::set<T*, parameterLessThan> ps) + { + T tmp(name); + typename std::set<T*, parameterLessThan>::iterator it = ps.find(&tmp); + if(it != ps.end()){ + if(client.size()) (*it)->addClient(client, true); + return *it; + } + return NULL; + } void _getAllParameters(std::set<parameter*, parameterLessThan> &ps) const { ps.insert(_numbers.begin(), _numbers.end()); @@ -1102,16 +1112,6 @@ namespace onelab{ {*ptr = _getPtr(name, client, _regions);} void getPtr(function **ptr, const std::string name, const std::string client="") {*ptr = _getPtr(name, client, _functions);} - template <class T> T* _getPtr(std::string name, const std::string client, std::set<T*, parameterLessThan> ps) - { - T tmp(name); - typename std::set<T*, parameterLessThan>::iterator it = ps.find(&tmp); - if(it != ps.end()){ - if(client.size()) (*it)->addClient(client, true); - return *it; - } - return NULL; - } void getAllParameters(std::set<parameter*, parameterLessThan> &ps) const { ps.insert(_numbers.begin(), _numbers.end()); diff --git a/Common/onelabUtils.cpp b/Common/onelabUtils.cpp index 98c411f78bf77344067d6176a95cf436c636f045..be3bb476f617694c71e7d922f00f4d43bc7013d7 100644 --- a/Common/onelabUtils.cpp +++ b/Common/onelabUtils.cpp @@ -384,7 +384,6 @@ namespace onelabUtils { if(pn.size() && pn[0].getValue()) return redraw; OnelabLocalNetworkClient *c = OnelabServer::instance()->getClient("Gmsh"); - std::cout << ((c != NULL)?"not":"ok") << std::endl; if(c != NULL) return redraw; // Gmsh is remote TODO std::string mshFileName = onelabUtils::getMshFileName(); @@ -412,13 +411,6 @@ namespace onelabUtils { } } else if(action == "compute"){ - std::cout << - "Gmsh getChanged is " << OnelabServer::instance()->getChanged("Gmsh") << std::endl << - "modelName is " << modelName << std::endl << - "current GModel is" << GModel::current()->getName() << std::endl << - "stat file " << mshFileName << " is " << StatFile(mshFileName) << std::endl << - "meshAuto is " << meshAuto - << std::endl; if(OnelabServer::instance()->getChanged("Gmsh") || modelName != GModel::current()->getName()){ // reload the geometry, mesh it and save the mesh if Gmsh parameters diff --git a/Fltk/drawContextFltk.h b/Fltk/drawContextFltk.h index b72de068f2d6d5e67eb8bb751de4bdfb26574a2d..a6945a41173f21f058dda51494b39469d9247293 100644 --- a/Fltk/drawContextFltk.h +++ b/Fltk/drawContextFltk.h @@ -35,7 +35,9 @@ class drawContextFltk : public drawContextGlobal{ } } } +#ifndef HAVE_ONELAB2 FlGui::instance()->check(); +#endif } void drawCurrentOpenglWindow(bool make_current) { diff --git a/Fltk/onelab2Group.cpp b/Fltk/onelab2Group.cpp index 694aa53e5ae1240051f8bf6096f0a648eb51d42c..72740bd521415c4ed5acff200ee544d16481c5ae 100644 --- a/Fltk/onelab2Group.cpp +++ b/Fltk/onelab2Group.cpp @@ -19,33 +19,6 @@ #include "Options.h" #include "Context.h" -static void initializeLoops() -{ - onelabUtils::initializeLoop("1"); - onelabUtils::initializeLoop("2"); - onelabUtils::initializeLoop("3"); - - if(FlGui::available() && onelab::server::instance()->getChanged()) - FlGui::instance()->rebuildTree(false); -} - -static bool incrementLoops() -{ - bool ret = (onelabUtils::incrementLoop("3") || - onelabUtils::incrementLoop("2") || - onelabUtils::incrementLoop("1")); - - //Define ONELAB parameter indicating whether or not in a loop - onelab::number n("0Metamodel/Loop",ret?1:0); - n.setVisible(false); - onelab::server::instance()->set(n); - - if(FlGui::available() && onelab::server::instance()->getChanged()) - FlGui::instance()->rebuildTree(false); - - return ret; -} - static void updateGraphs() { bool redraw = true;//FIXME false; diff --git a/contrib/onelab2/OnelabDatabase.h b/contrib/onelab2/OnelabDatabase.h index 504e18461d5e6ca673ba2279256ec87895675c16..67f1ca20132bc9a1e6ebbc0482e7d7cece0bd02b 100644 --- a/contrib/onelab2/OnelabDatabase.h +++ b/contrib/onelab2/OnelabDatabase.h @@ -21,6 +21,8 @@ DWORD WINAPI OnelabDatabase_listen(LPVOID arg); DWORD WINAPI OnelabDatabase_server(void *arg); #endif +static void initializeLoops(); +static bool incrementLoops(); // OnelabDatabase is a singleton that get/set/... parameters from server/clients class OnelabDatabase { private: @@ -184,32 +186,37 @@ public: } } else { // run all client - run(action, "Gmsh"); // run Gmsh client - - if(CTX::instance()->solverToRun >= 0) { // launch the solver - std::string solver = opt_solver_name(CTX::instance()->solverToRun, GMSH_GET, ""); - std::string exe = opt_solver_executable(CTX::instance()->solverToRun, GMSH_GET, ""); - if(_client && exe.size()) { - onelab::string o(solver + "/CommandLine", exe); - o.setVisible(false); - o.setNeverChanged(true); - set(o, solver); - } - run(action, solver); - } - else { // send action to all connected client except Gmsh - if(_client) { - std::cout << "server is remote" << std::endl; - msg.attrs.push_back(new OnelabAttrAction(action, client)); - int size = msg.encodeMsg(buff, 1024); - sendbytes(buff, size); + if(action == "compute") initializeLoops(); + + do{ // enter loop + run(action, "Gmsh"); // run Gmsh client + + if(CTX::instance()->solverToRun >= 0) { // launch the solver + std::string solver = opt_solver_name(CTX::instance()->solverToRun, GMSH_GET, ""); + std::string exe = opt_solver_executable(CTX::instance()->solverToRun, GMSH_GET, ""); + if(_client && exe.size()) { + onelab::string o(solver + "/CommandLine", exe); + o.setVisible(false); + o.setNeverChanged(true); + set(o, solver); + } + run(action, solver); } - else { - std::cout << "server is local" << std::endl; - OnelabServer::instance()->performAction(action, client, true); + else { // send action to all connected client except Gmsh + if(_client) { + std::cout << "server is remote" << std::endl; + msg.attrs.push_back(new OnelabAttrAction(action, client)); + int size = msg.encodeMsg(buff, 1024); + sendbytes(buff, size); + } + else { + std::cout << "server is local" << std::endl; + OnelabServer::instance()->performAction(action, client, true); + } + return true; } - return true; - } + } while(action == "compute" && /*!FlGui::instance()->onelab->stop() &&*/ + incrementLoops()); } return false; } @@ -227,3 +234,25 @@ public: } }; +static void initializeLoops() +{ + onelabUtils::initializeLoop("1"); + onelabUtils::initializeLoop("2"); + onelabUtils::initializeLoop("3"); +} + +static bool incrementLoops() +{ + bool ret = false; + if(onelabUtils::incrementLoop("3")) ret = true; + else if(onelabUtils::incrementLoop("2")) ret = true; + else if(onelabUtils::incrementLoop("1")) ret = true; + + //Define ONELAB parameter indicating whether or not in a loop + onelab::number n("0Metamodel/Loop",ret?1:0); + n.setVisible(false); + OnelabDatabase::instance()->set(n); + + return ret; +} +