[Gmsh] adding strings to onelab parameter choices

Nigel Nunn nnnunnn at gmail.com
Mon Jan 16 17:37:54 CET 2017

In our onelab GUI, I'm trying to add the name of a user-selected input file
to a list of choices for a string parameter, kind=file.

The idea is to allow the user to select an input file for a simulation, and
if that file name is not already in the list of choices for parameter
/04InputFile, then add it to the list.

The code below used to work, but now things only seem to work for a
hard-wired list of filenames.  Do I need to call setChanged or something?

  std::vector<onelab::string> ps;
  std::vector<std::string> choices;
  std::map<std::string, std::string> attrP, attrB;

  // select input/parameter file
  ps.clear(); choices.clear();
  c->get(ps, name + "/04InputFile");
  if (ps.empty()) {
    ps[0].setLabel("Input File");
    ps[0].setName(name + "/04InputFile");
    ps[0].setValue   ("no input");
    choices.push_back("no input");
    tmpstr = ps[0].getValue();
    std::vector<std::string> ch = ps[0].getChoices();
    std::vector<std::string>::iterator it;
    it = std::find(ch.begin(), ch.end(), tmpstr);
    if (it == ch.end()) {
      ch.push_back(tmpstr);   // not found, add to list.
      ps[0].setChoices(ch);     // not getting added to list ?

thanks for any help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20170117/4c926a3f/attachment.html>

More information about the gmsh mailing list