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

work on regions

parent 876e2e1d
Branches
Tags
No related merge requests found
...@@ -733,7 +733,7 @@ void Msg::ExchangeOnelabParameter(const std::string &key, ...@@ -733,7 +733,7 @@ void Msg::ExchangeOnelabParameter(const std::string &key,
bool noRange = true, noChoices = true, noLoop = true; bool noRange = true, noChoices = true, noLoop = true;
bool noGraph = true, noClosed = true; bool noGraph = true, noClosed = true;
if(ps.size()){ if(ps.size()){
//if(!ps[0].getReadOnly()) if(!ps[0].getReadOnly())
val[0] = ps[0].getValue(); // use value from server val[0] = ps[0].getValue(); // use value from server
// keep track of these attributes, which can be changed server-side // keep track of these attributes, which can be changed server-side
if(ps[0].getMin() != -onelab::parameter::maxNumber() || if(ps[0].getMin() != -onelab::parameter::maxNumber() ||
......
...@@ -68,7 +68,6 @@ namespace onelabUtils { ...@@ -68,7 +68,6 @@ namespace onelabUtils {
} }
onelab::string o("Gmsh/MshFileName", name, "Mesh name"); onelab::string o("Gmsh/MshFileName", name, "Mesh name");
o.setKind("file"); o.setKind("file");
o.setAttribute("Closed", "1");
c->set(o); c->set(o);
return name; return name;
} }
......
...@@ -18,6 +18,8 @@ static void con_geometry_define_parameter_cb(Fl_Widget *w, void *data) ...@@ -18,6 +18,8 @@ static void con_geometry_define_parameter_cb(Fl_Widget *w, void *data)
{ {
add_param(FlGui::instance()->geoContext->input[0]->value(), add_param(FlGui::instance()->geoContext->input[0]->value(),
FlGui::instance()->geoContext->input[1]->value(), FlGui::instance()->geoContext->input[1]->value(),
FlGui::instance()->geoContext->input[24]->value(),
FlGui::instance()->geoContext->input[25]->value(),
GModel::current()->getFileName()); GModel::current()->getFileName());
FlGui::instance()->resetVisibility(); FlGui::instance()->resetVisibility();
} }
...@@ -62,9 +64,12 @@ geometryContextWindow::geometryContextWindow(int deltaFontSize) ...@@ -62,9 +64,12 @@ geometryContextWindow::geometryContextWindow(int deltaFontSize)
input[0]->value("lc"); input[0]->value("lc");
input[1] = new Fl_Input(2 * WB, 2 * WB + 2 * BH, IW, BH, "Value"); input[1] = new Fl_Input(2 * WB, 2 * WB + 2 * BH, IW, BH, "Value");
input[1]->value("0.1"); input[1]->value("0.1");
for(int i = 0; i < 2; i++) { input[24] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Label");
input[i]->align(FL_ALIGN_RIGHT); input[24]->value("");
} input[25] = new Fl_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "Path");
input[25]->value("Gmsh/Parameters");
for(int i = 0; i < 2; i++) input[i]->align(FL_ALIGN_RIGHT);
for(int i = 24; i < 26; i++) input[i]->align(FL_ALIGN_RIGHT);
{ {
Fl_Return_Button *o = new Fl_Return_Button Fl_Return_Button *o = new Fl_Return_Button
(width - BB - 2 * WB, 2 * WB + 7 * BH, BB, BH, "Add"); (width - BB - 2 * WB, 2 * WB + 7 * BH, BB, BH, "Add");
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <FL/Fl_Output.H> #include <FL/Fl_Output.H>
#include <FL/fl_ask.H> #include <FL/fl_ask.H>
#include "inputRange.h" #include "inputRange.h"
#include "inputRegion.h"
#include "paletteWindow.h" #include "paletteWindow.h"
#include "menuWindow.h" #include "menuWindow.h"
#include "fileDialogs.h" #include "fileDialogs.h"
...@@ -983,37 +984,6 @@ Fl_Widget *onelabWindow::_addParameterWidget(onelab::string &p, Fl_Tree_Item *n, ...@@ -983,37 +984,6 @@ Fl_Widget *onelabWindow::_addParameterWidget(onelab::string &p, Fl_Tree_Item *n,
return but; return but;
} }
static std::string _set2string(const std::set<std::string> &s)
{
std::string out;
for(std::set<std::string>::const_iterator it = s.begin(); it != s.end(); it++){
if(it != s.begin()) out += ", ";
out += *it;
}
return out;
}
static std::string trim(const std::string &str, const std::string& white=" ")
{
size_t beg = str.find_first_not_of(white);
if(beg == std::string::npos) return "";
size_t end = str.find_last_not_of(white);
return str.substr(beg, end - beg + 1);
}
static std::set<std::string> _string2set(const std::string &s)
{
std::set<std::string> out;
std::string::size_type first = 0;
while(1){
std::string str = trim(onelab::parameter::getNextToken(s, first, ','));
//str.erase(std::remove(str.begin(), str.end(), ' '), str.end());
if(str.empty()) break;
out.insert(str);
}
return out;
}
static void onelab_region_input_cb(Fl_Widget *w, void *data) static void onelab_region_input_cb(Fl_Widget *w, void *data)
{ {
if(!data) return; if(!data) return;
...@@ -1021,8 +991,8 @@ static void onelab_region_input_cb(Fl_Widget *w, void *data) ...@@ -1021,8 +991,8 @@ static void onelab_region_input_cb(Fl_Widget *w, void *data)
std::vector<onelab::region> regions; std::vector<onelab::region> regions;
onelab::server::instance()->get(regions, name); onelab::server::instance()->get(regions, name);
if(regions.size()){ if(regions.size()){
Fl_Input *o = (Fl_Input*)w; inputRegion *o = (inputRegion*)w;
regions[0].setValue(_string2set(o->value())); regions[0].setValue(o->value());
onelab::server::instance()->set(regions[0]); onelab::server::instance()->set(regions[0]);
} }
} }
...@@ -1032,16 +1002,15 @@ Fl_Widget *onelabWindow::_addParameterWidget(onelab::region &p, Fl_Tree_Item *n, ...@@ -1032,16 +1002,15 @@ Fl_Widget *onelabWindow::_addParameterWidget(onelab::region &p, Fl_Tree_Item *n,
{ {
// non-editable value // non-editable value
if(p.getReadOnly()){ if(p.getReadOnly()){
Fl_Output *but = new Fl_Output(1, 1, _itemWidth, 1); inputRegion *but = new inputRegion(1, 1, _itemWidth, 1, true);
but->value(_set2string(p.getValue()).c_str()); but->value(p.getValue());
but->align(FL_ALIGN_RIGHT); but->align(FL_ALIGN_RIGHT);
if(highlight) but->color(c); if(highlight) but->color(c);
return but; return but;
} }
// general group input -- will be improved :-) inputRegion *but = new inputRegion(1, 1, _itemWidth, 1, false);
Fl_Input *but = new Fl_Input(1, 1, _itemWidth, 1); but->value(p.getValue());
but->value(_set2string(p.getValue()).c_str());
but->align(FL_ALIGN_RIGHT); but->align(FL_ALIGN_RIGHT);
but->callback(onelab_region_input_cb, (void*)n); but->callback(onelab_region_input_cb, (void*)n);
if(highlight) but->color(c); if(highlight) but->color(c);
...@@ -1052,13 +1021,13 @@ Fl_Widget *onelabWindow::_addParameterWidget(onelab::function &p, Fl_Tree_Item * ...@@ -1052,13 +1021,13 @@ Fl_Widget *onelabWindow::_addParameterWidget(onelab::function &p, Fl_Tree_Item *
bool highlight, Fl_Color c) bool highlight, Fl_Color c)
{ {
// non-editable value // non-editable value
//if(p.getReadOnly()){ if(1 || p.getReadOnly()){
Fl_Output *but = new Fl_Output(1, 1, _itemWidth, 1); Fl_Output *but = new Fl_Output(1, 1, _itemWidth, 1);
but->value("TODO function"); but->value("TODO function");
but->align(FL_ALIGN_RIGHT); but->align(FL_ALIGN_RIGHT);
if(highlight) but->color(c); if(highlight) but->color(c);
return but; return but;
//} }
} }
void onelabWindow::rebuildTree() void onelabWindow::rebuildTree()
......
...@@ -194,10 +194,14 @@ void add_embedded(std::string what, std::vector<int> &l, std::string fileName) ...@@ -194,10 +194,14 @@ void add_embedded(std::string what, std::vector<int> &l, std::string fileName)
add_infile(sstream.str(), fileName, true); add_infile(sstream.str(), fileName, true);
} }
void add_param(std::string par, std::string value, std::string fileName) void add_param(std::string par, std::string value, std::string label,
std::string path, std::string fileName)
{ {
std::ostringstream sstream; std::ostringstream sstream;
sstream << par << " = " << value << ";"; sstream << "DefineConstant[ " << par << " = { " << value;
if(label.size()) sstream << ", Label \"" << label << "\"";
if(path.size()) sstream << ", Path \"" << path << "\"";
sstream << "}];";
add_infile(sstream.str(), fileName); add_infile(sstream.str(), fileName);
} }
......
...@@ -20,7 +20,8 @@ void add_trsfline(std::vector<int> &l, std::string fileName, std::string type, ...@@ -20,7 +20,8 @@ void add_trsfline(std::vector<int> &l, std::string fileName, std::string type,
void add_trsfsurf(std::vector<int> &l, std::string fileName, std::string dir); void add_trsfsurf(std::vector<int> &l, std::string fileName, std::string dir);
void add_trsfvol(std::vector<int> &l, std::string fileName); void add_trsfvol(std::vector<int> &l, std::string fileName);
void add_embedded(std::string what, std::vector<int> &l, std::string fileName); void add_embedded(std::string what, std::vector<int> &l, std::string fileName);
void add_param(std::string par, std::string value, std::string fileName); void add_param(std::string par, std::string value, std::string label,
std::string path, std::string fileName);
void add_point(std::string fileName, std::string x, std::string y, std::string z, void add_point(std::string fileName, std::string x, std::string y, std::string z,
std::string lc); std::string lc);
void add_multline(std::string type, std::vector<int> &p, std::string fileName); void add_multline(std::string type, std::vector<int> &p, std::string fileName);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment