diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index 979e00d14ee4b9d3f1392b33159ae56aab6ae903..1ecbcbf8e8c9a7c8378c7706b7b980ecb9dbe571 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -787,6 +787,44 @@ void Msg::SetOnelabString(std::string name, std::string val, bool visible, #endif } +void Msg::AddOnelabStringChoice(std::string name, std::string kind, + std::string value, bool updateValue, + bool readOnly, bool visible) +{ +#if defined(HAVE_ONELAB) + if(_onelabClient){ + std::vector<std::string> choices; + std::vector<onelab::string> ps; + _onelabClient->get(ps, name); + if(ps.size()){ + choices = ps[0].getChoices(); + if(std::find(choices.begin(), choices.end(), value) == choices.end()) + choices.push_back(value); + if(updateValue) + ps[0].setValue(value); + } + else{ + ps.resize(1); + ps[0].setName(name); + ps[0].setKind(kind); + ps[0].setValue(value); + choices.push_back(value); + } + ps[0].setChoices(choices); + if(readOnly){ + ps[0].setReadOnly(true); + ps[0].setAttribute("AutoCheck", "0"); + } + else{ + ps[0].setReadOnly(false); + ps[0].setAttribute("AutoCheck", "1"); + } + ps[0].setVisible(visible); + _onelabClient->set(ps[0]); + } +#endif +} + double Msg::GetOnelabNumber(std::string name, double defaultValue, bool errorIfMissing) { @@ -953,6 +991,13 @@ void Msg::LoadOnelabClient(const std::string &clientName, const std::string &soc #endif } +int Msg::GetNumOnelabClients() +{ +#if defined(HAVE_ONELAB) + return onelab::server::instance()->getNumClients(); +#endif +} + #if defined(HAVE_ONELAB) static void _setStandardOptions(onelab::parameter *p, std::map<std::string, std::vector<double> > &fopt, diff --git a/Common/GmshMessage.h b/Common/GmshMessage.h index 1e6eaf3f145ce83c4289a46713a5e3fbf49ca7ea..11eced45c4e84de87140c027df26d1bafccfd98e 100644 --- a/Common/GmshMessage.h +++ b/Common/GmshMessage.h @@ -110,6 +110,7 @@ class Msg { static void SetExecutableName(const std::string &name) { _execName.assign(name); } static std::string GetExecutableName() { return _execName; } static void LoadOnelabClient(const std::string &name, const std::string &sockName); + static int GetNumOnelabClients(); static GmshClient *GetGmshClient(){ return _client; } #if defined(HAVE_ONELAB) static onelab::client *GetOnelabClient(){ return _onelabClient; } @@ -126,6 +127,9 @@ class Msg { bool errorIfMissing=false); static std::string GetOnelabString(std::string name, const std::string &defaultValue="", bool errorIfMissing=false); + static void AddOnelabStringChoice(std::string name, std::string kind, + std::string value, bool updateValue=true, + bool readOnly=false, bool visible=true); static void SetOnelabAction(const std::string &action); static std::string GetOnelabAction(); static void ExchangeOnelabParameter(const std::string &key, diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp index 8b139f64b621a6f52ccb73d9bd44468748a58903..2cd51772463491c8acf379305f685bceb76cb35d 100644 --- a/Common/OpenFile.cpp +++ b/Common/OpenFile.cpp @@ -192,6 +192,9 @@ int ParseFile(const std::string &fileName, bool close, bool warnIfMissing) return 0; } + Msg::AddOnelabStringChoice("Gmsh/}Input files", "file", fileName, true, true, + Msg::GetNumOnelabClients() > 1); + //#if defined(HAVE_FLTK) && defined(HAVE_POST) // int numViewsBefore = PView::list.size(); //#endif @@ -317,6 +320,9 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingB Msg::StatusBar(true, "Reading '%s'...", fileName.c_str()); + Msg::AddOnelabStringChoice("Gmsh/}Input files", "file", fileName, true, true, + Msg::GetNumOnelabClients() > 1); + std::vector<std::string> split = SplitFileName(fileName); std::string noExt = split[0] + split[1], ext = split[2]; diff --git a/Fltk/onelabGroup.cpp b/Fltk/onelabGroup.cpp index 75cd24562d29437474ca6d27014162e018901a91..00183f26004f327ff806dc50b46a5a7f10072feb 100644 --- a/Fltk/onelabGroup.cpp +++ b/Fltk/onelabGroup.cpp @@ -982,7 +982,7 @@ Fl_Widget *onelabGroup::_addParameterWidget(onelab::string &p, int ww, int hh, } // non-editable value - if(p.getReadOnly()){ + if(p.getReadOnly() && p.getKind() != "file"){ Fl_Output *but = new Fl_Output(1, 1, ww, hh); but->value(p.getValue().c_str()); but->align(FL_ALIGN_RIGHT | FL_ALIGN_CLIP); @@ -1031,12 +1031,14 @@ Fl_Widget *onelabGroup::_addParameterWidget(onelab::string &p, int ww, int hh, menu.push_back(it2); } if(p.getKind() == "file"){ - Fl_Menu_Item it = {"Choose...", 0, onelab_input_choice_file_chooser_cb, (void*)n}; - menu.push_back(it); - Fl_Menu_Item it2 = {"Edit...", 0, onelab_input_choice_file_edit_cb, (void*)n}; + if(!p.getReadOnly()){ + Fl_Menu_Item it = {"Choose File...", 0, onelab_input_choice_file_chooser_cb, (void*)n}; + menu.push_back(it); + } + Fl_Menu_Item it2 = {"Edit Selected File...", 0, onelab_input_choice_file_edit_cb, (void*)n}; menu.push_back(it2); if(GuessFileFormatFromFileName(p.getValue()) >= 0){ - Fl_Menu_Item it3 = {"Merge...", 0, onelab_input_choice_file_merge_cb, (void*)n}; + Fl_Menu_Item it3 = {"Merge Selected File...", 0, onelab_input_choice_file_merge_cb, (void*)n}; menu.push_back(it3); } } diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 6a6c8de608cc9df3129433ddf07cd8cee06c174a..8a55ab05be06df3b3dba71c113d609aa6b4959d8 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -123,7 +123,9 @@ void GModel::setFileName(std::string fileName) { _fileName = fileName; _fileNames.insert(fileName); - Msg::SetOnelabString("Gmsh/Model name", fileName, false, false, true, 0); + + Msg::SetOnelabString("Gmsh/Model name", fileName, + Msg::GetNumOnelabClients() > 1, false, true, 0); Msg::SetOnelabString ("Gmsh/Model absolute path", SplitFileName(GetAbsolutePath(fileName))[0], false, false, true, 0);