diff --git a/Common/Context.cpp b/Common/Context.cpp index 234aee965b89f31a4e971417d9806fad0f500a9c..43cd9ece96bf093e1c8d2261e7e16a563e4af135 100644 --- a/Common/Context.cpp +++ b/Common/Context.cpp @@ -15,8 +15,7 @@ CTX::CTX() { - // initialize everything that has no default value in - // DefaultOptions.h + // initialize everything that has no default value in DefaultOptions.h short int word = 0x0001; char *byte = (char*)&word; bigEndian = (byte[0] ? 0 : 1); @@ -40,6 +39,7 @@ CTX::CTX() outputFileName = ""; bgmFileName = ""; createAppendMeshStatReport = 0; + launchOnelabAtStartup = -2; lc = 1.; min[0] = min[1] = min[2] = max[2] = 0.; max[0] = max[1] = 1.; // for nice view when adding point in new model diff --git a/Common/Context.h b/Common/Context.h index dd512fd8e4e260f0dc4557628b769752412b5a80..efe936dc481d3c5c7ddf26409cd0aeca1517a65d 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -82,6 +82,8 @@ class CTX { std::vector<std::string> recentFiles; // create mesh statistics report (0: do nothing, 1: create, 2: append) int createAppendMeshStatReport; + // should we launch the onelab interface at startup? + int launchOnelabAtStartup ; // save session/option file on exit? int sessionSave, optionsSave; // ask confirmation when overwriting files? diff --git a/Common/Gmsh.cpp b/Common/Gmsh.cpp index ca824edb3993349208fa75e1d21fbb4b303c6987..573931a542dddc7d04b618d15c21d7b5d23f9d36 100644 --- a/Common/Gmsh.cpp +++ b/Common/Gmsh.cpp @@ -40,6 +40,7 @@ #include "FlGui.h" #include "menuWindow.h" #include "drawContext.h" +#include "onelabWindow.h" #endif int GmshInitialize(int argc, char **argv) @@ -255,12 +256,15 @@ int GmshFLTK(int argc, char **argv) Msg::Error("Invalid background mesh (no view)"); } - // listen to external solvers #if defined(HAVE_ONELAB) + // listen to external solvers if(CTX::instance()->solver.listen){ onelab::localNetworkClient *c = new onelab::localNetworkClient("Listen", ""); c->run(); } + if(CTX::instance()->launchOnelabAtStartup != -2){ + solver_cb(0, (void*)CTX::instance()->launchOnelabAtStartup); + } #endif // loop diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index 20285337f9eef19c0716ce03211bcbbf37f7c1e1..806bafc44a2ffe99dca9bfd2d6613be3765f1aec 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -791,6 +791,7 @@ void Msg::ExchangeOnelabParameter(const std::string &key, { #if defined(HAVE_ONELAB) if(!_onelabClient || val.empty()) return; + CTX::instance()->launchOnelabAtStartup = -1; std::string name = _getParameterName(key, copt); @@ -872,6 +873,7 @@ void Msg::ExchangeOnelabParameter(const std::string &key, { #if defined(HAVE_ONELAB) if(!_onelabClient || val.empty()) return; + CTX::instance()->launchOnelabAtStartup = -1; std::string name = _getParameterName(key, copt); diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp index d56159051536011bbfcc55e580ad839277372da9..9b1bb7a938b999c41edbb1b38bdb8a2becf76af4 100644 --- a/Common/OpenFile.cpp +++ b/Common/OpenFile.cpp @@ -376,12 +376,10 @@ int MergeFile(const std::string &fileName, bool warnIfMissing) #endif #if defined(HAVE_ONELAB) && defined(HAVE_FLTK) else if(ext == ".pro" && opt_solver_name(0, GMSH_GET, "") == "GetDP"){ - // FIXME: this is a hack -- think about a better way std::vector<std::string> split = SplitFileName(fileName); GModel::current()->setName(""); status = MergeFile(split[0] + split[1] + ".geo"); - CTX::instance()->lock = 0; // "uber hack for OpenProject in runGmshClient - solver_cb(0, 0); + CTX::instance()->launchOnelabAtStartup = 0; return status; } #endif diff --git a/Common/onelabUtils.cpp b/Common/onelabUtils.cpp index 7004a893e4be1f7144c897867ddb2e45052a2b3f..2c891e2aebbacb882302ca57b1bd406efaeb7f33 100644 --- a/Common/onelabUtils.cpp +++ b/Common/onelabUtils.cpp @@ -179,7 +179,7 @@ namespace onelabUtils { recompute = true; } else - numbers[i].setIndex(numbers[i].getMax()); + numbers[i].setIndex(numbers[i].getMax()); } else if(numbers[i].getStep() < 0){ int j = numbers[i].getIndex() + 1; @@ -283,6 +283,10 @@ namespace onelabUtils { return changed; } + static bool _firstComputation = true; + void setFirstComputationFlag(bool val){ _firstComputation = val; } + bool getFirstComputationFlag(){ return _firstComputation; } + bool runGmshClient(const std::string &action, bool meshAuto) { bool redraw = false; @@ -294,13 +298,12 @@ namespace onelabUtils { std::string mshFileName = onelabUtils::getMshFileName(c); static std::string modelName = GModel::current()->getName(); - static bool firstComputation = true; if(action == "initialize"){ // nothing to do } else if(action == "reset"){ - firstComputation = false; + setFirstComputationFlag(false); OpenProject(GModel::current()->getFileName()); } else if(action == "check"){ @@ -321,7 +324,7 @@ namespace onelabUtils { modelName = GModel::current()->getName(); redraw = true; OpenProject(GModel::current()->getFileName()); - if(firstComputation && !StatFile(mshFileName)){ + if(getFirstComputationFlag() && !StatFile(mshFileName)){ Msg::Info("Skipping mesh generation: assuming '%s' is up-to-date", mshFileName.c_str()); } @@ -338,7 +341,7 @@ namespace onelabUtils { CreateOutputFile(mshFileName, CTX::instance()->mesh.fileFormat); } } - firstComputation = false; + setFirstComputationFlag(false); onelab::server::instance()->setChanged(false, "Gmsh"); } diff --git a/Common/onelabUtils.h b/Common/onelabUtils.h index 3203316ed079d86f5fd692a374c4969f35366dcc..ec7605c95df502d484560c94b5370c2220b8a7be 100644 --- a/Common/onelabUtils.h +++ b/Common/onelabUtils.h @@ -20,6 +20,8 @@ namespace onelabUtils { std::vector<double> getRange(onelab::number &p); bool updateGraph(const std::string &graphNum); bool runGmshClient(const std::string &action, bool meshAuto); + bool getFirstComputationFlag(); + void setFirstComputationFlag(bool val); } #endif diff --git a/Fltk/onelabWindow.cpp b/Fltk/onelabWindow.cpp index 61cf07c490c3255fefc1a3947655cc3e24615602..5358c17b408d5c0c573b3c587d1f10a2a55061cb 100644 --- a/Fltk/onelabWindow.cpp +++ b/Fltk/onelabWindow.cpp @@ -792,6 +792,11 @@ static bool getFlColor(const std::string &str, Fl_Color &c) template<class T> static void autoCheck(const T &pold, const T &pnew, bool force=false) { + if(onelabUtils::getFirstComputationFlag()){ + if(pold.getValue() != pnew.getValue()) + onelabUtils::setFirstComputationFlag(false); + } + if((CTX::instance()->solver.autoCheck && pnew.getAttribute("AutoCheck") != "0") || pnew.getAttribute("AutoCheck") == "1"){ if(force || pold.getValue() != pnew.getValue()) diff --git a/demos/indheat.geo b/demos/indheat.geo index 399a36c067f8f540f875d27df86db2ade1961495..f706faed031d8118d07e2de160b8b0cec4fb9abe 100644 --- a/demos/indheat.geo +++ b/demos/indheat.geo @@ -12,7 +12,7 @@ DefineConstant rt2 = {0.092, Label "Tube external radius"}, lb = {1, Label "Infinite box width"}, left = {1, Choices{0,1}, Label "Terminals on the left?"} - // macro = {"aa.pos", Label "Run my macro!", Kind "macro", Path "Actions"}, + //macro = {"aa.pos", Label "Run my macro!", Kind "macro", Path "Actions"}, // showLines = {1, Choices {0,1}, Label "Show lines?"} ];