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

basic loops OK!

parent b6fe4fda
Branches
Tags
No related merge requests found
...@@ -162,7 +162,7 @@ namespace onelab{ ...@@ -162,7 +162,7 @@ namespace onelab{
number(const std::string &name="", double value=0., number(const std::string &name="", double value=0.,
const std::string &shortHelp="", const std::string &help="") const std::string &shortHelp="", const std::string &help="")
: parameter(name, shortHelp, help), _value(value), : 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 setValue(double value){ _value = value; }
void setMin(double min){ _min = min; } void setMin(double min){ _min = min; }
void setMax(double max){ _max = max; } void setMax(double max){ _max = max; }
...@@ -184,7 +184,7 @@ namespace onelab{ ...@@ -184,7 +184,7 @@ namespace onelab{
setMin(p.getMin()); setMin(p.getMin());
if(p.getMax() != maxNumber()) if(p.getMax() != maxNumber())
setMax(p.getMax()); setMax(p.getMax());
if(p.getStep()) if(p.getStep() != 1.)
setStep(p.getStep()); setStep(p.getStep());
if(p.getChoices().size()) if(p.getChoices().size())
setChoices(p.getChoices()); setChoices(p.getChoices());
......
...@@ -32,7 +32,7 @@ class inputRange : public Fl_Group { ...@@ -32,7 +32,7 @@ class inputRange : public Fl_Group {
_input->maximum(_max); _input->maximum(_max);
} }
if(_step){ if(_step){
tmp << ":" << _step; if(_step != 1.) tmp << ":" << _step;
_input->step(_step); _input->step(_step);
} }
_range->value(tmp.str().c_str()); _range->value(tmp.str().c_str());
...@@ -96,7 +96,7 @@ class inputRange : public Fl_Group { ...@@ -96,7 +96,7 @@ class inputRange : public Fl_Group {
} }
public: public:
inputRange(int x, int y, int w, int h, double max_number, const char *l=0) 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) _max_number(max_number)
{ {
int dot_w = FL_NORMAL_SIZE - 2, loop_w = FL_NORMAL_SIZE + 6; int dot_w = FL_NORMAL_SIZE - 2, loop_w = FL_NORMAL_SIZE + 6;
......
...@@ -320,6 +320,31 @@ static std::string getModelName(onelab::client *c) ...@@ -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) void onelab_cb(Fl_Widget *w, void *data)
{ {
if(!data) return; if(!data) return;
...@@ -346,6 +371,8 @@ void onelab_cb(Fl_Widget *w, void *data) ...@@ -346,6 +371,8 @@ void onelab_cb(Fl_Widget *w, void *data)
FlGui::instance()->onelab->deactivate(); FlGui::instance()->onelab->deactivate();
recompute:
// the Gmsh client is special: it always gets executed first. (The // the Gmsh client is special: it always gets executed first. (The
// meta-model will allow more flexibility: but in the simple GUI we // meta-model will allow more flexibility: but in the simple GUI we
// can assume this) // can assume this)
...@@ -411,10 +438,11 @@ void onelab_cb(Fl_Widget *w, void *data) ...@@ -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()); 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->rebuildTree();
FlGui::instance()->onelab->show(); FlGui::instance()->onelab->show();
} }
...@@ -551,7 +579,7 @@ static std::string getShortName(const std::string &name) ...@@ -551,7 +579,7 @@ static std::string getShortName(const std::string &name)
void onelabWindow::rebuildTree() void onelabWindow::rebuildTree()
{ {
int width = (3*IW)/2; int width = (int)(1.4*IW);
_tree->clear(); _tree->clear();
_tree->sortorder(FL_TREE_SORT_ASCENDING); _tree->sortorder(FL_TREE_SORT_ASCENDING);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment