From 4c7fcc87f06ba8dfaee70f4a8d2527ba232e1773 Mon Sep 17 00:00:00 2001
From: Francois Henrotte <francois.henrotte@ulg.ac.be>
Date: Mon, 7 May 2012 13:24:08 +0000
Subject: [PATCH]

---
 Common/GmshMessage.cpp | 28 ++++++++++++++++++----------
 Common/onelab.h        |  2 +-
 Fltk/onelabWindow.cpp  |  9 +++++++++
 3 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp
index 0d0590d1e1..8b62857c7f 100644
--- a/Common/GmshMessage.cpp
+++ b/Common/GmshMessage.cpp
@@ -614,10 +614,11 @@ void Msg::InitializeOnelab(const std::string &name, const std::string &sockname)
     onelab::string o4(name + "/9ComputeCommand", "-3");
     o4.setVisible(false);
     _onelabClient->set(o4);
+
     std::vector<onelab::string> ps;
     _onelabClient->get(ps, name + "/Action");
     if(ps.size()){
-      Info("Performing OneLab '%s'", ps[0].getValue().c_str());
+      //Info("Performing OneLab '%s'", ps[0].getValue().c_str());
       if(ps[0].getValue() == "initialize") Exit(0);
     }
 
@@ -648,15 +649,21 @@ void Msg::ExchangeOnelabParameter(const std::string &key,
   std::vector<onelab::number> ps;
   _onelabClient->get(ps, name);
   bool noRange = true, noChoices = true, noLoop = true, noGraph = true;
-  if(ps.size()){ // use value from server
-    val[0] = ps[0].getValue();
-    // keep track of these attributes, which can be changed server-side
-    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.size()){ 
+    if(ps[0].getReadOnly()){ // use value of Gmsh
+      ps[0].setName(name);
+      ps[0].setValue(val[0]);
+    }
+    else{ // use value from server
+      val[0] = ps[0].getValue();
+      // keep track of these attributes, which can be changed server-side
+      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;
+    }
   }
   else{
     ps.resize(1);
@@ -682,6 +689,7 @@ void Msg::ExchangeOnelabParameter(const std::string &key,
     if(copt.count("Choices")) ps[0].setChoiceLabels(copt["Choices"]);
   }
   if(fopt.count("Visible")) ps[0].setVisible(fopt["Visible"][0] ? true : false);
+  if(fopt.count("ReadOnly")) ps[0].setReadOnly(fopt["ReadOnly"][0] ? true : false);
   if(copt.count("Help")) ps[0].setHelp(copt["Help"][0]);
   if(copt.count("Label")) ps[0].setLabel(copt["Label"][0]);
   if(copt.count("ShortHelp")) ps[0].setLabel(copt["ShortHelp"][0]);
diff --git a/Common/onelab.h b/Common/onelab.h
index eef474ea1f..93390b6fc3 100644
--- a/Common/onelab.h
+++ b/Common/onelab.h
@@ -261,7 +261,7 @@ namespace onelab{
     }
     void update(const number &p)
     {
-      addClients(p.getClients()); // complete the list
+      addClients(p.getClients()); // complete the list of clients
       setLabel(p.getLabel());
       setHelp(p.getHelp());
       setVisible(p.getVisible());
diff --git a/Fltk/onelabWindow.cpp b/Fltk/onelabWindow.cpp
index aa988eba97..cd38d72c38 100644
--- a/Fltk/onelabWindow.cpp
+++ b/Fltk/onelabWindow.cpp
@@ -436,6 +436,7 @@ static void guessModelName(onelab::client *c)
     std::string name(split[0] + split[1] + ext);
     onelab::string o(c->getName() + "/1ModelName", name, "Model name");
     o.setKind("file");
+    o.setVisible(false);
     c->set(o);
   }
 }
@@ -1094,6 +1095,10 @@ void onelabWindow::_addParameter(onelab::number &p)
     Fl_Color c;
     if(getFlColor(p.getAttribute("Highlight"), c))
       but->color(c);
+    if(p.getReadOnly()){
+      getFlColor("AliceBlue", c); // rendre également la case non éditable
+      but->color(c);
+    }
     but->align(FL_ALIGN_RIGHT);
     but->callback(onelab_input_range_cb, (void*)n);
     but->when(FL_WHEN_RELEASE | FL_WHEN_ENTER_KEY);
@@ -1138,6 +1143,10 @@ void onelabWindow::_addParameter(onelab::string &p)
   Fl_Color c;
   if(getFlColor(p.getAttribute("Highlight"), c))
     but->input()->color(c);
+  if(p.getReadOnly()){
+    getFlColor("ALiceBlue", c); // rendre également la case non éditable
+    but->input()->color(c);
+  }
   but->align(FL_ALIGN_RIGHT);
   but->callback(onelab_input_choice_cb, (void*)n);
   but->when(FL_WHEN_RELEASE | FL_WHEN_ENTER_KEY);
-- 
GitLab