diff --git a/source/RobotAPI/components/units/RobotUnit/CMakeLists.txt b/source/RobotAPI/components/units/RobotUnit/CMakeLists.txt index 418ffe703cde22f96aca2863cd6d8f560b65d539..d8a278be55755a01a34ee0133c77002f625587ba 100644 --- a/source/RobotAPI/components/units/RobotUnit/CMakeLists.txt +++ b/source/RobotAPI/components/units/RobotUnit/CMakeLists.txt @@ -15,6 +15,7 @@ set(LIB_FILES SyntaxCheck.cpp RobotUnit.cpp BasicControllers.cpp + DefaultWidgetDescriptions.cpp ControlTargets/ControlTargetBase.cpp @@ -41,6 +42,7 @@ set(LIB_HEADERS ControlModes.h RobotUnit.h BasicControllers.h + DefaultWidgetDescriptions.h ControlTargets/ControlTargetBase.h ControlTargets/ControlTarget1DoFActuator.h diff --git a/source/RobotAPI/components/units/RobotUnit/DefaultWidgetDescriptions.cpp b/source/RobotAPI/components/units/RobotUnit/DefaultWidgetDescriptions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f576152c547645d3a6923ab2ef199a6599efbd93 --- /dev/null +++ b/source/RobotAPI/components/units/RobotUnit/DefaultWidgetDescriptions.cpp @@ -0,0 +1,49 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::RobotUnit + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "DefaultWidgetDescriptions.h" + +namespace armarx +{ + namespace WidgetDescription + { + StringComboBoxPtr makeRNSComboBox( + const VirtualRobot::RobotPtr& robot, + const std::set<std::string>& preferredSet, + const std::string& mostPreferred) + { + StringComboBoxPtr rns = new StringComboBox; + rns->name = "rns"; + std::string currentPreferred; + for (const auto& name : robot->getRobotNodeSetNames()) + { + if (preferredSet.count(name) && (mostPreferred.empty() || currentPreferred != mostPreferred)) + { + currentPreferred = name; + rns->defaultIndex = rns->options.size(); + } + rns->options.emplace_back(name); + } + return rns; + } + } +} diff --git a/source/RobotAPI/components/units/RobotUnit/DefaultWidgetDescriptions.h b/source/RobotAPI/components/units/RobotUnit/DefaultWidgetDescriptions.h new file mode 100644 index 0000000000000000000000000000000000000000..d0e194f2e73bfb932e92237010fa726e3527b3ea --- /dev/null +++ b/source/RobotAPI/components/units/RobotUnit/DefaultWidgetDescriptions.h @@ -0,0 +1,43 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::RobotUnit + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_UNIT_RobotAPI_DefaultWidgetDescriptions_H +#define _ARMARX_UNIT_RobotAPI_DefaultWidgetDescriptions_H + +#include <string> +#include <set> + +#include <VirtualRobot/Robot.h> + +#include <ArmarXGui/interface/WidgetDescription.h> + +namespace armarx +{ + namespace WidgetDescription + { + StringComboBoxPtr makeRNSComboBox( + const VirtualRobot::RobotPtr& robot, + const std::set<std::string>& preferredSet = {}, + const std::string& mostPreferred = ""); + } +} +#endif