Skip to content
Snippets Groups Projects
Commit 746e43cc authored by Raphael Grimm's avatar Raphael Grimm
Browse files

Add some more functions to RobotUnit/DefaultWidgetDescriptions

parent 2ecc1242
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ set(LIBS
ArmarXGuiInterfaces
RobotAPIUnits
RobotAPIInterfaces
DefaultWidgetDescriptions
${Simox_LIBRARIES}
)
......
......@@ -27,22 +27,64 @@ namespace armarx
namespace WidgetDescription
{
StringComboBoxPtr makeStringSelectionComboBox(
const std::vector<std::string> options,
const std::string& name,
std::string name,
std::vector<std::string> options)
{
StringComboBoxPtr rns = new StringComboBox;
rns->name = std::move(name);
rns->options = std::move(options);
rns->defaultIndex = 0;
return rns;
}
StringComboBoxPtr makeStringSelectionComboBox(
std::string name,
std::vector<std::string> options,
const std::set<std::string>& preferredSet)
{
StringComboBoxPtr rns = makeStringSelectionComboBox(std::move(name), std::move(options));
for(std::size_t i = 0; i < rns->options.size(); ++i)
{
if(preferredSet.count(rns->options.at(i)))
{
rns->defaultIndex = i;
break;
}
}
return rns;
}
StringComboBoxPtr makeStringSelectionComboBox(
std::string name,
std::vector<std::string> options,
const std::string& mostPreferred)
{
StringComboBoxPtr rns = makeStringSelectionComboBox(std::move(name), std::move(options));
for(std::size_t i = 0; i < rns->options.size(); ++i)
{
if(mostPreferred == rns->options.at(i))
{
rns->defaultIndex = i;
break;
}
}
return rns;
}
StringComboBoxPtr makeStringSelectionComboBox(
std::string name,
std::vector<std::string> options,
const std::set<std::string>& preferredSet,
const std::string& mostPreferred)
{
StringComboBoxPtr rns = new StringComboBox;
rns->name = name;
std::string currentPreferred;
for (const auto & name : options)
StringComboBoxPtr rns = makeStringSelectionComboBox(std::move(name), std::move(options), preferredSet);
for(std::size_t i = 0; i < rns->options.size(); ++i)
{
if (preferredSet.count(name) && (mostPreferred.empty() || currentPreferred != mostPreferred))
if(mostPreferred == rns->options.at(i))
{
currentPreferred = name;
rns->defaultIndex = rns->options.size();
rns->defaultIndex = i;
break;
}
rns->options.emplace_back(name);
}
return rns;
}
......
......@@ -29,33 +29,65 @@
#include <VirtualRobot/Robot.h>
#include <ArmarXGui/interface/WidgetDescription.h>
#include <ArmarXGui/libraries/DefaultWidgetDescriptions/DefaultWidgetDescriptions.h>
namespace armarx
{
namespace WidgetDescription
{
StringComboBoxPtr makeStringSelectionComboBox(
const std::vector<std::string> options,
const std::string& name,
const std::set<std::string>& preferredSet = {},
const std::string& mostPreferred = "");
std::string name,
std::vector<std::string> options);
StringComboBoxPtr makeStringSelectionComboBox(
std::string name,
std::vector<std::string> options,
const std::set<std::string>& preferredSet);
inline StringComboBoxPtr makeStringSelectionComboBox(
std::string name,
std::vector<std::string> options,
const std::initializer_list<std::string>& preferredSet)
{
return makeStringSelectionComboBox(std::move(name), std::move(options),std::set<std::string>{preferredSet});
}
StringComboBoxPtr makeStringSelectionComboBox(
std::string name,
std::vector<std::string> options,
const std::string& mostPreferred);
StringComboBoxPtr makeStringSelectionComboBox(
std::string name,
std::vector<std::string> options,
const std::set<std::string>& preferredSet,
const std::string& mostPreferred);
inline StringComboBoxPtr makeStringSelectionComboBox(
std::string name,
std::vector<std::string> options,
const std::string& mostPreferred,
const std::set<std::string>& preferredSet)
{
return makeStringSelectionComboBox(std::move(name), std::move(options), preferredSet, mostPreferred);
}
inline StringComboBoxPtr makeRNSComboBox(
const VirtualRobot::RobotPtr& robot,
const std::string& name = "RobotNodeSet",
std::string name = "RobotNodeSet",
const std::set<std::string>& preferredSet = {},
const std::string& mostPreferred = "")
{
return makeStringSelectionComboBox(robot->getRobotNodeSetNames(), name, preferredSet, mostPreferred);
return makeStringSelectionComboBox(std::move(name), robot->getRobotNodeSetNames(), preferredSet, mostPreferred);
}
inline StringComboBoxPtr makeRobotNodeComboBox(
const VirtualRobot::RobotPtr& robot,
const std::string& name = "RobotNode",
std::string name = "RobotNode",
const std::set<std::string>& preferredSet = {},
const std::string& mostPreferred = "")
{
return makeStringSelectionComboBox(robot->getRobotNodeNames(), name, preferredSet, mostPreferred);
return makeStringSelectionComboBox(std::move(name), robot->getRobotNodeNames(), preferredSet, mostPreferred);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment