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

better ReadOnlyRange + AutoCheck should be a number

parent 8a5fe77a
No related branches found
No related tags found
No related merge requests found
......@@ -404,9 +404,9 @@ StringXNumber GeneralOptions_Number[] = {
"Horizontal position (in pixels) of the upper left corner of the field window" },
{ F|S, "FieldPositionY" , opt_general_field_position1 , 550. ,
"Vertical position (in pixels) of the upper left corner of the field window" },
{ F|S, "FieldHeight" , opt_general_field_size1 , 300. ,
{ F|S, "FieldHeight" , opt_general_field_size1 , 320. ,
"Height (in pixels) of the field window" },
{ F|S, "FieldWidth" , opt_general_field_size0 , 300. ,
{ F|S, "FieldWidth" , opt_general_field_size0 , 420. ,
"Width (in pixels) of the field window" },
{ F|S, "FileChooserPositionX" , opt_general_file_chooser_position0 , 200. ,
"Horizontal position (in pixels) of the upper left corner of the file chooser "
......@@ -558,9 +558,9 @@ StringXNumber GeneralOptions_Number[] = {
"window" },
{ F|S, "PluginPositionY" , opt_general_plugin_position1 , 550. ,
"Vertical position (in pixels) of the upper left corner of the plugin window" },
{ F|S, "PluginHeight" , opt_general_plugin_size1 , 300. ,
{ F|S, "PluginHeight" , opt_general_plugin_size1 , 320. ,
"Height (in pixels) of the plugin window" },
{ F|S, "PluginWidth" , opt_general_plugin_size0 , 300. ,
{ F|S, "PluginWidth" , opt_general_plugin_size0 , 420. ,
"Width (in pixels) of the plugin window" },
{ F|O, "PointSize" , opt_general_point_size , 3. ,
"Display size of points (in pixels)" },
......
......@@ -789,15 +789,24 @@ static void _setStandardOptions(onelab::parameter *p,
std::map<std::string, std::vector<double> > &fopt,
std::map<std::string, std::vector<std::string> > &copt)
{
// strings
if(copt.count("Label")) p->setLabel(copt["Label"][0]);
if(copt.count("ShortHelp")) p->setLabel(copt["ShortHelp"][0]);
if(copt.count("ShortHelp")) // for backward compatibility
p->setLabel(copt["ShortHelp"][0]);
if(copt.count("Help")) p->setHelp(copt["Help"][0]);
if(fopt.count("Visible")) p->setVisible(fopt["Visible"][0] ? true : false);
if(fopt.count("ReadOnly")) p->setReadOnly(fopt["ReadOnly"][0] ? true : false);
if(copt.count("Highlight")) p->setAttribute("Highlight", copt["Highlight"][0]);
if(copt.count("AutoCheck")) p->setAttribute("AutoCheck", copt["AutoCheck"][0]);
if(copt.count("Macro")) p->setAttribute("Macro", copt["Macro"][0]);
if(copt.count("GmshOption")) p->setAttribute("GmshOption", copt["GmshOption"][0]);
if(copt.count("AutoCheck")) // for backward compatibility
p->setAttribute("AutoCheck", copt["AutoCheck"][0]);
// numbers
if(fopt.count("Visible")) p->setVisible(fopt["Visible"][0] ? true : false);
if(fopt.count("ReadOnly")) p->setReadOnly(fopt["ReadOnly"][0] ? true : false);
if(fopt.count("ReadOnlyRange"))
p->setAttribute("ReadOnlyRange", fopt["ReadOnlyRange"][0] ? "1" : "0");
if(fopt.count("AutoCheck"))
p->setAttribute("AutoCheck", fopt["AutoCheck"][0] ? "1" : "0");
}
static std::string _getParameterName(const std::string &key,
......@@ -837,11 +846,15 @@ void Msg::ExchangeOnelabParameter(const std::string &key,
ps[0].setValue(val[0]); // use local value
else
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 (unless,
// for the range/choices, when explicitely setting these attributes as
// ReadOnly)
if(!(fopt.count("ReadOnlyRange") && fopt["ReadOnlyRange"][0])){
if(ps[0].getMin() != -onelab::parameter::maxNumber() ||
ps[0].getMax() != onelab::parameter::maxNumber() ||
ps[0].getStep() != 0.) noRange = false;
if(ps[0].getChoices().size()) noChoices = false;
}
if(ps[0].getAttribute("Loop").size()) noLoop = false;
if(ps[0].getAttribute("Graph").size()) noGraph = false;
if(ps[0].getAttribute("Closed").size()) noClosed = false;
......
......@@ -255,7 +255,8 @@ class inputRange : public Fl_Group {
b->do_callback();
}
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, bool readOnlyRange=false,
const char *l=0)
: Fl_Group(x,y,w,h,l), _min(-max_number), _max(max_number), _step(1.),
_max_number(max_number), _do_callback_on_values(true)
{
......@@ -273,6 +274,7 @@ class inputRange : public Fl_Group {
_range->callback(_range_cb, this);
_range->when(FL_WHEN_ENTER_KEY|FL_WHEN_RELEASE);
_range->hide();
if(readOnlyRange) _range->deactivate();
_range_butt = new Fl_Toggle_Button(x + input_w, y, dot_w, h, ":");
_range_butt->callback(_range_butt_cb, this);
......
......@@ -1084,7 +1084,8 @@ Fl_Widget *onelabGroup::_addParameterWidget(onelab::number &p, Fl_Tree_Item *n,
}
// general number input
inputRange *but = new inputRange(1, 1, ww, 1, onelab::parameter::maxNumber());
inputRange *but = new inputRange(1, 1, ww, 1, onelab::parameter::maxNumber(),
p.getAttribute("ReadOnlyRange") == "1");
but->value(p.getValue());
but->minimum(p.getMin());
but->maximum(p.getMax());
......
......@@ -13,9 +13,9 @@ DefineConstant
lb = {1, Label "Infinite box width", Path "Parameters"},
left = {1, Choices{0,1}, Label "Terminals on the left?", Path "Parameters"}
macro = {"title.script", Label "Add title", Path "Macros",
Macro "Gmsh", AutoCheck "0" /*, Highlight "Turquoise"*/ },
Macro "Gmsh", AutoCheck 0 /*, Highlight "Turquoise"*/ },
showLines = {Geometry.Lines, Choices {0,1}, Label "Show lines?", Path "Options",
GmshOption "Geometry.Lines", AutoCheck "0"}
GmshOption "Geometry.Lines", AutoCheck 0}
];
// inductor
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment