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
25#include <VirtualRobot/Robot.h>
26
28{
29 StringComboBoxPtr
30 makeStringSelectionComboBox(std::string name, std::vector<std::string> options)
31 {
32 StringComboBoxPtr rns = new StringComboBox;
33 rns->name = std::move(name);
34 rns->options = std::move(options);
35 rns->defaultIndex = 0;
36 return rns;
37 }
38
39 StringComboBoxPtr
41 std::vector<std::string> options,
42 const std::set<std::string>& preferredSet)
43 {
44 StringComboBoxPtr rns = makeStringSelectionComboBox(std::move(name), std::move(options));
45 for (std::size_t i = 0; i < rns->options.size(); ++i)
46 {
47 if (preferredSet.count(rns->options.at(i)))
48 {
49 rns->defaultIndex = i;
50 break;
51 }
52 }
53 return rns;
54 }
55
56 StringComboBoxPtr
58 std::vector<std::string> options,
59 const std::string& mostPreferred)
60 {
61 StringComboBoxPtr rns = makeStringSelectionComboBox(std::move(name), std::move(options));
62 for (std::size_t i = 0; i < rns->options.size(); ++i)
63 {
64 if (mostPreferred == rns->options.at(i))
65 {
66 rns->defaultIndex = i;
67 break;
68 }
69 }
70 return rns;
71 }
72
73 StringComboBoxPtr
75 std::vector<std::string> options,
76 const std::set<std::string>& preferredSet,
77 const std::string& mostPreferred)
78 {
79 StringComboBoxPtr rns =
80 makeStringSelectionComboBox(std::move(name), std::move(options), preferredSet);
81 for (std::size_t i = 0; i < rns->options.size(); ++i)
82 {
83 if (mostPreferred == rns->options.at(i))
84 {
85 rns->defaultIndex = i;
86 break;
87 }
88 }
89 return rns;
90 }
91
92 StringComboBoxPtr
94 std::string name,
95 const std::set<std::string>& preferredSet,
96 const std::string& mostPreferred)
97 {
99 std::move(name), robot->getRobotNodeSetNames(), preferredSet, mostPreferred);
100 }
101
102 StringComboBoxPtr
104 std::string name,
105 const std::set<std::string>& preferredSet,
106 const std::string& mostPreferred)
107 {
109 std::move(name), robot->getRobotNodeNames(), preferredSet, mostPreferred);
110 }
111
112 StringComboBoxPtr
114 std::vector<std::string> options,
115 const std::string& mostPreferred,
116 const std::set<std::string>& preferredSet)
117 {
119 std::move(name), std::move(options), preferredSet, mostPreferred);
120 }
121} // namespace armarx::WidgetDescription
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
StringComboBoxPtr makeRNSComboBox(const VirtualRobot::RobotPtr &robot, std::string name, const std::set< std::string > &preferredSet, const std::string &mostPreferred)
StringComboBoxPtr makeRobotNodeComboBox(const VirtualRobot::RobotPtr &robot, std::string name, const std::set< std::string > &preferredSet, const std::string &mostPreferred)
StringComboBoxPtr makeStringSelectionComboBox(std::string name, std::vector< std::string > options)