diff --git a/Common/onelab.h b/Common/onelab.h index 9bee45d83d010f46c15b7471c1d0a64d9a28df91..876173c2fd06018628903a89271c10b62677c790 100644 --- a/Common/onelab.h +++ b/Common/onelab.h @@ -162,7 +162,7 @@ namespace onelab{ number(const std::string &name="", double value=0., const std::string &shortHelp="", const std::string &help="") : parameter(name, shortHelp, help), _value(value), - _min(-maxNumber()), _max(maxNumber()), _step(0.) {} + _min(-maxNumber()), _max(maxNumber()), _step(1.) {} void setValue(double value){ _value = value; } void setMin(double min){ _min = min; } void setMax(double max){ _max = max; } @@ -184,7 +184,7 @@ namespace onelab{ setMin(p.getMin()); if(p.getMax() != maxNumber()) setMax(p.getMax()); - if(p.getStep()) + if(p.getStep() != 1.) setStep(p.getStep()); if(p.getChoices().size()) setChoices(p.getChoices()); diff --git a/Fltk/inputRange.h b/Fltk/inputRange.h index 083c935772fbffc38ab8b69756359041840f78a7..29806d0586ad4ff83987afc77460bd2b2462357d 100644 --- a/Fltk/inputRange.h +++ b/Fltk/inputRange.h @@ -32,7 +32,7 @@ class inputRange : public Fl_Group { _input->maximum(_max); } if(_step){ - tmp << ":" << _step; + if(_step != 1.) tmp << ":" << _step; _input->step(_step); } _range->value(tmp.str().c_str()); @@ -96,7 +96,7 @@ class inputRange : public Fl_Group { } public: inputRange(int x, int y, int w, int h, double max_number, const char *l=0) - : Fl_Group(x,y,w,h,l), _min(-max_number), _max(max_number), _step(0), + : Fl_Group(x,y,w,h,l), _min(-max_number), _max(max_number), _step(1.), _max_number(max_number) { int dot_w = FL_NORMAL_SIZE - 2, loop_w = FL_NORMAL_SIZE + 6; diff --git a/Fltk/onelabWindow.cpp b/Fltk/onelabWindow.cpp index ef4b5fa1426b088a4de2c5d5b669328c7a1865f8..30cb5e2c251f1ca67ea7561aa0f576221376c3d1 100644 --- a/Fltk/onelabWindow.cpp +++ b/Fltk/onelabWindow.cpp @@ -320,6 +320,31 @@ static std::string getModelName(onelab::client *c) } } +static bool shouldRecompute() +{ + bool recompute = false; + std::vector<onelab::number> numbers; + onelab::server::instance()->get(numbers); + for(unsigned int i = 0; i < numbers.size(); i++){ + if(numbers[i].getAttribute("loop") == "true"){ + if(numbers[i].getMax() != onelab::parameter::maxNumber() && + numbers[i].getValue() < numbers[i].getMax() && + numbers[i].getStep()){ + numbers[i].setValue(numbers[i].getValue() + numbers[i].getStep()); + onelab::server::instance()->set(numbers[i]); + Msg::Info("Recomputing with %s=%g", numbers[i].getName().c_str(), + numbers[i].getValue()); + recompute = true; + } + } + } + + if(recompute) + FlGui::instance()->onelab->rebuildTree(); + + return recompute; +} + void onelab_cb(Fl_Widget *w, void *data) { if(!data) return; @@ -346,6 +371,8 @@ void onelab_cb(Fl_Widget *w, void *data) FlGui::instance()->onelab->deactivate(); + recompute: + // the Gmsh client is special: it always gets executed first. (The // meta-model will allow more flexibility: but in the simple GUI we // can assume this) @@ -411,10 +438,11 @@ void onelab_cb(Fl_Widget *w, void *data) } } - FlGui::instance()->onelab->activate(); - printf("Gmsh ONELAB db:\n%s\n", onelab::server::instance()->toChar().c_str()); + if(action == "compute" && shouldRecompute()) goto recompute; + + FlGui::instance()->onelab->activate(); FlGui::instance()->onelab->rebuildTree(); FlGui::instance()->onelab->show(); } @@ -551,7 +579,7 @@ static std::string getShortName(const std::string &name) void onelabWindow::rebuildTree() { - int width = (3*IW)/2; + int width = (int)(1.4*IW); _tree->clear(); _tree->sortorder(FL_TREE_SORT_ASCENDING);