diff --git a/source/RobotAPI/libraries/aron_component_config/PropertyDefinitionVisitors.cpp b/source/RobotAPI/libraries/aron_component_config/PropertyDefinitionVisitors.cpp index 94bb965973b6b280b1a30da360e5f92b1c97bf60..8945a6d2bf4a09d7fa618a11d0442ceabdff913c 100644 --- a/source/RobotAPI/libraries/aron_component_config/PropertyDefinitionVisitors.cpp +++ b/source/RobotAPI/libraries/aron_component_config/PropertyDefinitionVisitors.cpp @@ -92,8 +92,9 @@ namespace armarx::aron::component_config { in_list_ = true; const auto& name = pathToName(o); - const auto& t_desc = type::List::DynamicCast(t)->getAcceptedType()->getDescriptor(); - if (t_desc == type::Descriptor::OBJECT) + const auto& type = type::List::DynamicCast(t)->getAcceptedType()->getDescriptor(); + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) { return; } @@ -107,10 +108,10 @@ namespace armarx::aron::component_config }; int i = 0; std::vector<std::string> vector = get_list(); - std::for_each(vector.begin(), vector.end(), [&old_list, &i, &t_desc](const auto& el) + std::for_each(vector.begin(), vector.end(), [&old_list, &i, &type](const auto& el) { - old_list->addElement(factories::PropertyHelper::make(t_desc)->from_string(el, - old_list->getPath() + old_list->addElement(factories::PropertyHelper::make(type)->from_string(el, + old_list->getPath() .withIndex(i))); i++; }); @@ -150,8 +151,9 @@ namespace armarx::aron::component_config { in_list_ = true; const auto& name = pathToName(o); - const auto& t_desc = type::Dict::DynamicCast(t)->getAcceptedType()->getDescriptor(); - if (t_desc == type::Descriptor::OBJECT) + const auto& type = type::Dict::DynamicCast(t)->getAcceptedType()->getDescriptor(); + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) { return; } @@ -164,12 +166,12 @@ namespace armarx::aron::component_config return simox::alg::split(list, ","); }; std::vector<std::string> vector = get_list(); - std::for_each(vector.begin(), vector.end(), [&old_dict, &t_desc](const auto& el) + std::for_each(vector.begin(), vector.end(), [&old_dict, &type](const auto& el) { auto key_value = simox::alg::split(el, ":"); old_dict->addElement(key_value.front(), - factories::PropertyHelper::make(t_desc)->from_string(key_value.back(), - old_dict->getPath() + factories::PropertyHelper::make(type)->from_string(key_value.back(), + old_dict->getPath() .withElement(key_value.front()))); }); } @@ -276,17 +278,18 @@ namespace armarx::aron::component_config ARMARX_CHECK_NOT_NULL(l); in_list_ = true; const auto& name = pathToName(l); - const auto& t_desc = t->getAcceptedType()->getDescriptor(); - if (t_desc == type::Descriptor::OBJECT) + const auto& type = t->getAcceptedType()->getDescriptor(); + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) { return; } const auto& input = l->getElements(); std::string str; std::vector<std::string> vector; - std::transform(input.begin(), input.end(), std::back_inserter(vector), [&t_desc](const auto& el) + std::transform(input.begin(), input.end(), std::back_inserter(vector), [&type](const auto& el) { - return factories::PropertyHelper::make(t_desc)->to_string(el); + return factories::PropertyHelper::make(type)->to_string(el); }); str = simox::alg::to_string(vector, ", "); property_definitions_->defineOptionalProperty<std::string>(name, str); @@ -303,8 +306,9 @@ namespace armarx::aron::component_config { in_list_ = true; const auto& name = pathToName(d); - const auto& t_desc = t->getAcceptedType()->getDescriptor(); - if (t_desc == type::Descriptor::OBJECT) + const auto& type = t->getAcceptedType()->getDescriptor(); + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) { return; } @@ -313,7 +317,7 @@ namespace armarx::aron::component_config for (const auto& [key, el]: input) { ss << key << ":"; - ss << factories::PropertyHelper::make(t_desc)->to_string(el); + ss << factories::PropertyHelper::make(type)->to_string(el); ss << ","; } std::string value = ss.str(); diff --git a/source/RobotAPI/libraries/aron_component_config/RemoteGuiVisitors.cpp b/source/RobotAPI/libraries/aron_component_config/RemoteGuiVisitors.cpp index 49feb11a71e1a084e30f12adab9fbc41f9c36c12..553428bc98ee0da9e5c8f38bda620dc41d64ea0a 100644 --- a/source/RobotAPI/libraries/aron_component_config/RemoteGuiVisitors.cpp +++ b/source/RobotAPI/libraries/aron_component_config/RemoteGuiVisitors.cpp @@ -39,8 +39,7 @@ namespace armarx::aron::component_config void MakeConfigGuiVisitor::visitObjectOnEnter(DataInput& dict, TypeInput&) { - ARMARX_TRACE; - ARMARX_CHECK_NOT_NULL(dict); + INPUT_GUARD(dict); if (dict->getPath().hasElement()) { @@ -57,7 +56,7 @@ namespace armarx::aron::component_config void MakeConfigGuiVisitor::visitObjectOnExit(DataInput& dict, TypeInput&) { - ARMARX_TRACE; + INPUT_GUARD(dict); auto builder = *group_hierarchy_.back(); group_hierarchy_.pop_back(); if (!group_hierarchy_.empty()) @@ -71,10 +70,15 @@ namespace armarx::aron::component_config { INPUT_GUARD(i); auto value = data::Int::DynamicCastAndCheck(i); + const auto& name = pathToName(i); + auto group = RemoteGui::makeHBoxLayout(name + "_layout"); + group.addChild(RemoteGui::makeLabel(name + "_label").value(i->getPath().getLastElement())); + group.addHSpacer(); + group.addChild(RemoteGui::makeIntSpinBox(name).value(value->getValue()) + .min(-1000) + .max(1000).toolTip(name)); group_hierarchy_.back() - ->addChild(RemoteGui::makeIntSpinBox(pathToName(i)).value(value->getValue()) - .min(-1000) - .max(1000)); + ->addChild(group); } void @@ -82,10 +86,15 @@ namespace armarx::aron::component_config { INPUT_GUARD(f); auto value = data::Float::DynamicCastAndCheck(f); + const auto& name = pathToName(f); + auto group = RemoteGui::makeHBoxLayout(name + "_layout"); + group.addChild(RemoteGui::makeLabel(name + "_label").value(f->getPath().getLastElement())); + group.addHSpacer(); + group.addChild(RemoteGui::makeFloatSpinBox(name).value(value->getValue()) + .min(-1000) + .max(1000).toolTip(name)); group_hierarchy_.back() - ->addChild(RemoteGui::makeFloatSpinBox(pathToName(f)).value(value->getValue()) - .min(-1000) - .max(1000)); + ->addChild(group); } void @@ -93,10 +102,15 @@ namespace armarx::aron::component_config { INPUT_GUARD(d); auto value = data::Double::DynamicCastAndCheck(d); + const auto& name = pathToName(d); + auto group = RemoteGui::makeHBoxLayout(name + "_layout"); + group.addChild(RemoteGui::makeLabel(name + "_label").value(d->getPath().getLastElement())); + group.addHSpacer(); + group.addChild(RemoteGui::makeFloatSpinBox(name).value(value->getValue()) + .min(-1000) + .max(1000).toolTip(name)); group_hierarchy_.back() - ->addChild(RemoteGui::makeFloatSpinBox(pathToName(d)).value(value->getValue()) - .min(-1000) - .max(1000)); + ->addChild(group); } void @@ -114,7 +128,12 @@ namespace armarx::aron::component_config { INPUT_GUARD(string); auto value = data::String::DynamicCastAndCheck(string); - group_hierarchy_.back()->addChild(RemoteGui::makeLineEdit(pathToName(string)).value(value->getValue())); + const auto& name = pathToName(string); + auto group = RemoteGui::makeHBoxLayout(name + "_layout"); + group.addChild(RemoteGui::makeLabel(name + "_label").value(string->getPath().getLastElement())); + group.addHSpacer(); + group.addChild(RemoteGui::makeLineEdit(name).value(value->getValue()).toolTip(name)); + group_hierarchy_.back()->addChild(group); } MakeConfigGuiVisitor::MakeConfigGuiVisitor(const std::string& name) : @@ -135,7 +154,9 @@ namespace armarx::aron::component_config auto group = RemoteGui::makeSimpleGridLayout(pathToName(o) + "_grid").cols(20); auto data = data::List::DynamicCastAndCheck(o); auto type = type::List::DynamicCast(t)->getAcceptedType()->getDescriptor(); - if (type == type::Descriptor::OBJECT) + ARMARX_INFO << pathToName(data); + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) { return; } @@ -170,9 +191,14 @@ namespace armarx::aron::component_config INPUT_GUARD(o); auto data = data::Int::DynamicCastAndCheck(o); auto type = type::IntEnum::DynamicCast(t); + const auto& name = pathToName(o); + auto group = RemoteGui::makeHBoxLayout(name + "_layout"); + group.addChild(RemoteGui::makeLabel(name + "_label").value(o->getPath().getLastElement())); + group.addHSpacer(); + group.addChild(RemoteGui::makeComboBox(name).options(type->getAcceptedValueNames()) + .value(type->getValueName(data->getValue())).toolTip(name)); group_hierarchy_.back() - ->addChild(RemoteGui::makeComboBox(pathToName(o)).options(type->getAcceptedValueNames()) - .value(type->getValueName(data->getValue()))); + ->addChild(group); } void @@ -183,7 +209,8 @@ namespace armarx::aron::component_config auto group = RemoteGui::makeSimpleGridLayout(pathToName(o) + "_grid").cols(20); auto data = data::Dict::DynamicCastAndCheck(o); auto type = type::Dict::DynamicCast(t)->getAcceptedType()->getDescriptor(); - if (type == type::Descriptor::OBJECT) + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) { return; } @@ -385,7 +412,8 @@ namespace armarx::aron::component_config in_list_ = true; auto data = data::List::DynamicCastAndCheck(o); auto type = type::List::DynamicCast(t)->getAcceptedType()->getDescriptor(); - if (type == type::Descriptor::OBJECT) + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) { return; } @@ -427,7 +455,8 @@ namespace armarx::aron::component_config in_list_ = true; auto data = data::Dict::DynamicCastAndCheck(o); auto type = type::Dict::DynamicCast(t)->getAcceptedType()->getDescriptor(); - if (type == type::Descriptor::OBJECT) + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) { return; } diff --git a/source/RobotAPI/libraries/aron_component_config/TypeDescriptorFactories/PropertyHelper.h b/source/RobotAPI/libraries/aron_component_config/TypeDescriptorFactories/PropertyHelper.h index cc7152d41c6ea2a667864ca4985f41efd7d46fa8..f04b9c1fcf56fb32a9a83e2a5bcb53d5347e82c4 100644 --- a/source/RobotAPI/libraries/aron_component_config/TypeDescriptorFactories/PropertyHelper.h +++ b/source/RobotAPI/libraries/aron_component_config/TypeDescriptorFactories/PropertyHelper.h @@ -156,6 +156,14 @@ namespace armarx::aron::component_config const std::string&) const; + static inline const std::list<type::Descriptor> implementedListDescriptors = { + type::Descriptor::INT_ENUM, + type::Descriptor::INT, + type::Descriptor::STRING, + type::Descriptor::FLOAT, + type::Descriptor::DOUBLE, + type::Descriptor::BOOL, + }; extern template struct products::PropertyHelper<type::Descriptor::INT>; extern template struct products::PropertyHelper<type::Descriptor::FLOAT>; extern template struct products::PropertyHelper<type::Descriptor::DOUBLE>;