DefaultWidgetDescriptions.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package RobotAPI::ArmarXObjects::RobotUnit
17  * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
18  * @date 2017
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
24 
26 {
27  StringComboBoxPtr
28  makeStringSelectionComboBox(std::string name, std::vector<std::string> options)
29  {
30  StringComboBoxPtr rns = new StringComboBox;
31  rns->name = std::move(name);
32  rns->options = std::move(options);
33  rns->defaultIndex = 0;
34  return rns;
35  }
36 
37  StringComboBoxPtr
38  makeStringSelectionComboBox(std::string name,
39  std::vector<std::string> options,
40  const std::set<std::string>& preferredSet)
41  {
42  StringComboBoxPtr rns = makeStringSelectionComboBox(std::move(name), std::move(options));
43  for (std::size_t i = 0; i < rns->options.size(); ++i)
44  {
45  if (preferredSet.count(rns->options.at(i)))
46  {
47  rns->defaultIndex = i;
48  break;
49  }
50  }
51  return rns;
52  }
53 
54  StringComboBoxPtr
55  makeStringSelectionComboBox(std::string name,
56  std::vector<std::string> options,
57  const std::string& mostPreferred)
58  {
59  StringComboBoxPtr rns = makeStringSelectionComboBox(std::move(name), std::move(options));
60  for (std::size_t i = 0; i < rns->options.size(); ++i)
61  {
62  if (mostPreferred == rns->options.at(i))
63  {
64  rns->defaultIndex = i;
65  break;
66  }
67  }
68  return rns;
69  }
70 
71  StringComboBoxPtr
72  makeStringSelectionComboBox(std::string name,
73  std::vector<std::string> options,
74  const std::set<std::string>& preferredSet,
75  const std::string& mostPreferred)
76  {
77  StringComboBoxPtr rns =
78  makeStringSelectionComboBox(std::move(name), std::move(options), preferredSet);
79  for (std::size_t i = 0; i < rns->options.size(); ++i)
80  {
81  if (mostPreferred == rns->options.at(i))
82  {
83  rns->defaultIndex = i;
84  break;
85  }
86  }
87  return rns;
88  }
89 } // namespace armarx::WidgetDescription
DefaultWidgetDescriptions.h
armarx::WidgetDescription::makeStringSelectionComboBox
StringComboBoxPtr makeStringSelectionComboBox(std::string name, std::vector< std::string > options)
Definition: DefaultWidgetDescriptions.cpp:28
armarx::WidgetDescription
Definition: DefaultWidgetDescriptions.cpp:27