diff --git a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp index 7403e833107e392c8ffdecc4f0544500b13568de..deeec0ebb3405b9ac61bdbf9dbc76549f3fa4564 100644 --- a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp +++ b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp @@ -350,4 +350,12 @@ namespace armarx::armem::server::obj } } + void ObjectMemory::reloadKnownObjectClasses(const Ice::Current& current) + { + ARMARX_INFO << "Reloading object classes ..."; + classSegment.reloadObjectClassesByObjectFinder(); + ARMARX_INFO << "Reloaded object classes."; + } + + } diff --git a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h index 9a97c2374a3010c5003978bf8f0eecdecb4af610..ec78eb3fa7493a890541e915317ccd1689d9e15d 100644 --- a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h +++ b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h @@ -110,6 +110,8 @@ namespace armarx::armem::server::obj void createRemoteGuiTab(); void RemoteGui_update() override; + // Updates the list of known classes and generates a new snapshot in the memory + void reloadKnownObjectClasses(const Ice::Current& current) override; private: diff --git a/source/RobotAPI/interface/armem/server/ObjectMemoryInterface.ice b/source/RobotAPI/interface/armem/server/ObjectMemoryInterface.ice index fdae53a727de5b00ad65e4d9edacca8734ce26fe..fa9d74f160dc12e05fd6b1395d03b85b36384bea 100644 --- a/source/RobotAPI/interface/armem/server/ObjectMemoryInterface.ice +++ b/source/RobotAPI/interface/armem/server/ObjectMemoryInterface.ice @@ -54,6 +54,7 @@ module armarx , FamiliarObjectInstanceSegmentInterface { + void reloadKnownObjectClasses(); }; }; diff --git a/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp b/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp index a9b406a13c1fa22384705afa88777a5a9c504a9e..c25da26b18023deecb52a83191ee4d17af11c609 100644 --- a/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp +++ b/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp @@ -56,11 +56,26 @@ namespace armarx::armem::server::obj::clazz if (p.loadFromObjectsPackage) { - ARMARX_VERBOSE << "Loading objects from package"; + ARMARX_VERBOSE << "Loading objects from package `" << p.objectsPackage << "`."; loadByObjectFinder(p.objectsPackage); } } + void + Segment::reloadObjectClassesByObjectFinder() + { + if (p.loadFromObjectsPackage) + { + ARMARX_VERBOSE << "Loading objects from package `" << p.objectsPackage << "`."; + loadByObjectFinder(p.objectsPackage); + } + else + { + ARMARX_INFO << "Loading object from package in `reloadObjectClassesByObjectFinder()` " + "is disabled via property. No object classes will be reloaded!"; + } + } + void Segment::connect(viz::Client arviz) { diff --git a/source/RobotAPI/libraries/armem_objects/server/class/Segment.h b/source/RobotAPI/libraries/armem_objects/server/class/Segment.h index ba42e0072097beb531b1fedbef3f6344eb208cc4..b2da5cd1b44faf2382c3a31eba5fcf9c3486029a 100644 --- a/source/RobotAPI/libraries/armem_objects/server/class/Segment.h +++ b/source/RobotAPI/libraries/armem_objects/server/class/Segment.h @@ -38,6 +38,8 @@ namespace armarx::armem::server::obj::clazz void loadByObjectFinder(const ObjectFinder& finder); void loadByObjectFinder(); + void reloadObjectClassesByObjectFinder(); + void visualizeClass(const MemoryID& entityID, bool showAABB = true, bool showOOBB = true); diff --git a/source/RobotAPI/libraries/skills/core/CMakeLists.txt b/source/RobotAPI/libraries/skills/core/CMakeLists.txt index 29145e60e305fa10decf06200685dcb99ec6a3d5..f757e4b5d8d069673c67d39e8b559250202d6c03 100644 --- a/source/RobotAPI/libraries/skills/core/CMakeLists.txt +++ b/source/RobotAPI/libraries/skills/core/CMakeLists.txt @@ -4,6 +4,8 @@ armarx_component_set_name("${LIB_NAME}") armarx_set_target("Library: ${LIB_NAME}") armarx_add_library( + ARON_FILES + aron/SkillErrorResult.xml LIBS ArmarXCoreInterfaces ArmarXCore diff --git a/source/RobotAPI/libraries/skills/core/aron/SkillErrorResult.xml b/source/RobotAPI/libraries/skills/core/aron/SkillErrorResult.xml new file mode 100644 index 0000000000000000000000000000000000000000..f222af7c14a350cfcb90c5081d938af5355ad2f4 --- /dev/null +++ b/source/RobotAPI/libraries/skills/core/aron/SkillErrorResult.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<AronTypeDefinition> + + <GenerateTypes> + + <Object name='armarx::skills::arondto::SkillErrorResult'> + <ObjectChild key='errorCode'> + <string /> + </ObjectChild> + + <ObjectChild key='data'> + <AnyObject shared_ptr="true" /> + </ObjectChild> + + <ObjectChild key='errorMessage'> + <string /> + </ObjectChild> + + </Object> + + </GenerateTypes> + +</AronTypeDefinition> diff --git a/source/RobotAPI/libraries/skills/provider/detail/SkillImplementationWrapper.cpp b/source/RobotAPI/libraries/skills/provider/detail/SkillImplementationWrapper.cpp index 773fc5af86c525950cd84846b6a641deabcb1c29..a244ae6593ec82b802dcbd930af07990ce3d4503 100644 --- a/source/RobotAPI/libraries/skills/provider/detail/SkillImplementationWrapper.cpp +++ b/source/RobotAPI/libraries/skills/provider/detail/SkillImplementationWrapper.cpp @@ -1,5 +1,8 @@ #include "SkillImplementationWrapper.h" +#include <ArmarXCore/core/exceptions/LocalException.h> +#include <RobotAPI/libraries/aron/core/data/variant/container/Dict.h> +#include <RobotAPI/libraries/skills/core/aron/SkillErrorResult.aron.generated.h> namespace armarx { namespace skills::detail @@ -75,6 +78,7 @@ namespace armarx { std::unique_lock l(skillStatusesMutex); statusUpdate.status = status; + statusUpdate.result = data; if (skill) // if skill has been constructed { @@ -89,14 +93,6 @@ namespace armarx } }; - auto createErrorMessageData = [](const std::string& message) - { - auto obj = aron::make_dict(); - auto m = aron::make_string(message, aron::Path({"errormessage"})); - obj->addElement("errormessage", m); - return obj; - }; - { std::unique_lock l(skillStatusesMutex); @@ -130,9 +126,14 @@ namespace armarx // set initial parameters that were attached to the execution request (only add as we are not sure whether some updates already arrived) this->updateSkillParameters(initial_aron_params); - auto makeAbortedResult = [&](const std::string& message) + auto makeAbortedResult = [&](const std::string& errorCode, const aron::data::DictPtr& data, const std::string& message) { - updateStatus(SkillStatus::Aborted, createErrorMessageData(message)); + armarx::skills::arondto::SkillErrorResult errorResult; + errorResult.errorCode = errorCode; + errorResult.data = data; + errorResult.errorMessage = message; + + updateStatus(SkillStatus::Aborted, errorResult.toAron()); std::unique_lock l(skillStatusesMutex); auto terminated = TerminatedSkillStatusUpdate{ @@ -145,9 +146,14 @@ namespace armarx }; - auto makeFailedResult = [&](const std::string& message) + auto makeFailedResult = [&](const std::string& errorCode, const aron::data::DictPtr& data, const std::string& message) { - updateStatus(SkillStatus::Failed, createErrorMessageData(message)); + armarx::skills::arondto::SkillErrorResult errorResult; + errorResult.errorCode = errorCode; + errorResult.data = data; + errorResult.errorMessage = message; + + updateStatus(SkillStatus::Failed, errorResult.toAron()); std::unique_lock l(skillStatusesMutex); auto terminated = TerminatedSkillStatusUpdate{ @@ -174,15 +180,15 @@ namespace armarx // } - auto exitAndMakeFailedResult = [&](const std::string& message) + auto exitAndMakeFailedResult = [&](const std::string& errorCode, const aron::data::DictPtr& data, const std::string& message) { skill->exitSkill(); // try to exit skill. Ignore return value - return makeFailedResult(message); + return makeFailedResult(errorCode, data, message); }; - auto exitAndMakeAbortedResult = [&](const std::string& message) + auto exitAndMakeAbortedResult = [&](const std::string& errorCode, const aron::data::DictPtr& data, const std::string& message) { skill->exitSkill(); // try to exit skill. Ignore return value - return makeAbortedResult(message); + return makeAbortedResult(errorCode, data, message); }; // Construction succeeded! @@ -199,16 +205,16 @@ namespace armarx { std::string message = "SkillError 101: The initialization of skill '" + skillName + "' did not succeed."; - return exitAndMakeFailedResult(message); + return exitAndMakeFailedResult("101", nullptr, message); } } catch (const error::SkillAbortedException& ex) { - return exitAndMakeAbortedResult(GetHandledExceptionString()); + return exitAndMakeAbortedResult("101x", nullptr, GetHandledExceptionString()); } catch (const error::SkillFailedException& ex) { - return exitAndMakeFailedResult(GetHandledExceptionString()); + return exitAndMakeFailedResult("101x", nullptr, GetHandledExceptionString()); } catch (const std::exception& ex) { @@ -216,7 +222,7 @@ namespace armarx "SkillError 101e: An error occured during the initialization of skill '" + skillName + "'. The error was: " + GetHandledExceptionString(); ARMARX_ERROR_S << message; - return exitAndMakeFailedResult(message); + return exitAndMakeFailedResult("101e", nullptr, message); } // Init succeeded! @@ -244,16 +250,16 @@ namespace armarx std::string message = "SkillError 201: The prepare method of skill '" + skillName + "' did not succeed."; ARMARX_ERROR_S << message; - return exitAndMakeFailedResult(message); + return exitAndMakeFailedResult("201", nullptr, message); } } catch (const error::SkillAbortedException& ex) { - return exitAndMakeAbortedResult(GetHandledExceptionString()); + return exitAndMakeAbortedResult("201x", nullptr, GetHandledExceptionString()); } catch (const error::SkillFailedException& ex) { - return exitAndMakeFailedResult(GetHandledExceptionString()); + return exitAndMakeFailedResult("201x", nullptr, GetHandledExceptionString()); } catch (const std::exception& ex) { @@ -262,7 +268,7 @@ namespace armarx skillName + "'. The error was: " + GetHandledExceptionString(); ARMARX_ERROR_S << message; - return exitAndMakeFailedResult(message); + return exitAndMakeFailedResult("201e", nullptr, message); } // Prepare succeeded! @@ -281,22 +287,23 @@ namespace armarx { std::string message = "SkillError 501: The main method of skill '" + skillName + "' did fail."; - return exitAndMakeFailedResult(message); + + return exitAndMakeFailedResult("501", mainRet.data, message); } else if (mainRet.status == TerminatedSkillStatus::Aborted) { std::string message = "SkillError 501: The main method of skill '" + skillName + "' got aborted."; - return exitAndMakeAbortedResult(message); + return exitAndMakeAbortedResult("501", mainRet.data, message); } } catch (const error::SkillAbortedException& ex) { - return exitAndMakeAbortedResult(GetHandledExceptionString()); + return exitAndMakeAbortedResult("501x", mainRet.data, GetHandledExceptionString()); } catch (const error::SkillFailedException& ex) { - return exitAndMakeFailedResult(GetHandledExceptionString()); + return exitAndMakeFailedResult("501x", mainRet.data, GetHandledExceptionString()); } catch (const std::exception& ex) { @@ -304,7 +311,7 @@ namespace armarx "SkillError 501e: An error occured during the main method of skill '" + skillName + "'. The error was: " + GetHandledExceptionString(); ARMARX_ERROR_S << message; - return exitAndMakeFailedResult(message); + return exitAndMakeFailedResult("501e", mainRet.data, message); } // Main succeeded! @@ -319,16 +326,16 @@ namespace armarx { std::string message = "SkillError 601: The exit method of skill '" + skillName + "' did not succeed."; - return makeFailedResult(message); + return makeFailedResult("601", mainRet.data, message); } } catch (const error::SkillAbortedException& ex) { - return makeAbortedResult(GetHandledExceptionString()); + return makeAbortedResult("601x", mainRet.data, GetHandledExceptionString()); } catch (const error::SkillFailedException& ex) { - return makeFailedResult(GetHandledExceptionString()); + return makeFailedResult("601x", mainRet.data, GetHandledExceptionString()); } catch (const std::exception& ex) { @@ -336,7 +343,7 @@ namespace armarx "SkillError 601e: An error occured during the exit method of skill '" + skillName + "'. The error was: " + GetHandledExceptionString(); ARMARX_ERROR_S << message; - return makeFailedResult(message); + return makeFailedResult("601e", mainRet.data, message); } // Exit succeeded! diff --git a/source/RobotAPI/libraries/skills_gui/aron_tree_widget/AronTreeWidgetController.cpp b/source/RobotAPI/libraries/skills_gui/aron_tree_widget/AronTreeWidgetController.cpp index 79d606639c320ffeba73918967d9a832de446e68..8c24f906fef8edea5f33db3b4a890431f5bc7bb4 100644 --- a/source/RobotAPI/libraries/skills_gui/aron_tree_widget/AronTreeWidgetController.cpp +++ b/source/RobotAPI/libraries/skills_gui/aron_tree_widget/AronTreeWidgetController.cpp @@ -136,6 +136,7 @@ namespace armarx::skills::gui void AronTreeWidgetController::onTreeWidgetItemChanged(QTreeWidgetItem* item, int column) { + tree->blockSignals(true); auto* aronElem = AronTreeWidgetItem::DynamicCast(item); @@ -143,13 +144,14 @@ namespace armarx::skills::gui { aronElem->onUserChange(column); } + // start conversion for entire tree -- this also sets the highlighting if (parent->childCount() == 1) { auto* aronTreeRoot = AronTreeWidgetItem::DynamicCast(parent->child(0)); - aronTreeRoot->resetError(); if (aronTreeRoot) { + aronTreeRoot->resetError(); AronTreeWidgetConverterVisitor v(parent, 0); aron::type::visit(v, type); aronTreeRoot->setValueErrorState(v.hasDirectError(), v.onlyChildFailedConversion()); @@ -158,6 +160,7 @@ namespace armarx::skills::gui // else perhaps the GUI was stopped or died. tree->blockSignals(false); + } } // namespace armarx::skills::gui diff --git a/source/RobotAPI/libraries/skills_gui/aron_tree_widget/AronTreeWidgetItem.cpp b/source/RobotAPI/libraries/skills_gui/aron_tree_widget/AronTreeWidgetItem.cpp index d76cee191fda8cb927548a795b53291875ae14e6..5f24c40c959e8008457c096b4d872e8407041ab8 100644 --- a/source/RobotAPI/libraries/skills_gui/aron_tree_widget/AronTreeWidgetItem.cpp +++ b/source/RobotAPI/libraries/skills_gui/aron_tree_widget/AronTreeWidgetItem.cpp @@ -149,6 +149,7 @@ namespace armarx::skills::gui void AronTreeWidgetItem::onUserChange(int changedColumn) { + QTreeWidgetItem* qParent = QTreeWidgetItem::parent(); ARMARX_CHECK(qParent); AronTreeWidgetItem* aronParent = DynamicCast(qParent); @@ -172,6 +173,7 @@ namespace armarx::skills::gui preventIllegalKeyChange(); } } + } void diff --git a/source/RobotAPI/libraries/skills_gui/aron_tree_widget/visitors/AronTreeWidgetConverter.cpp b/source/RobotAPI/libraries/skills_gui/aron_tree_widget/visitors/AronTreeWidgetConverter.cpp index 23be73d02da766a0b361f53cb53486fd91d65684..164e4498f0adcc2ca99bfdacbfcb36cf441a8879 100644 --- a/source/RobotAPI/libraries/skills_gui/aron_tree_widget/visitors/AronTreeWidgetConverter.cpp +++ b/source/RobotAPI/libraries/skills_gui/aron_tree_widget/visitors/AronTreeWidgetConverter.cpp @@ -75,16 +75,19 @@ namespace armarx::skills::gui void AronTreeWidgetConverterVisitor::handleErrors(bool ownFault) { + ARMARX_TRACE; isDirectError = ownFault; auto* aronItem = AronTreeWidgetItem::DynamicCast(parentItem->child(index)); ARMARX_CHECK(aronItem); aronItem->setValueErrorState(isDirectError, false); + } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::ObjectPtr& i) { + ARMARX_TRACE; auto createdAronDict = std::make_shared<aron::data::Dict>(i->getPath()); createdAron = createdAronDict; @@ -113,11 +116,13 @@ namespace armarx::skills::gui createdAronDict->addElement(key, v.createdAron); } } + } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::DictPtr& i) { + ARMARX_TRACE; auto createdAronDict = std::make_shared<aron::data::Dict>(i->getPath()); createdAron = createdAronDict; @@ -146,11 +151,13 @@ namespace armarx::skills::gui createdAronDict->addElement(key, v.createdAron); } } + } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::ListPtr& i) { + ARMARX_TRACE; auto createdAronList = std::make_shared<aron::data::List>(i->getPath()); createdAron = createdAronList; @@ -179,11 +186,13 @@ namespace armarx::skills::gui createdAronList->addElement(convVisitor.createdAron); } } + } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::PairPtr& i) { + ARMARX_TRACE; auto createdAronPair = std::make_shared<aron::data::List>(i->getPath()); createdAron = createdAronPair; @@ -208,11 +217,13 @@ namespace armarx::skills::gui createdAronPair->addElement(convVisitor.createdAron); } } + } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::TuplePtr& i) { + ARMARX_TRACE; auto createdAronList = std::make_shared<aron::data::List>(i->getPath()); createdAron = createdAronList; @@ -240,6 +251,7 @@ namespace armarx::skills::gui createdAronList->addElement(v.createdAron); } } + } void @@ -252,6 +264,7 @@ namespace armarx::skills::gui void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::MatrixPtr& i) { + ARMARX_TRACE; auto createdMatrix = std::make_shared<aron::data::NDArray>(i->getPath()); int dataSize = 0; @@ -276,6 +289,7 @@ namespace armarx::skills::gui break; }; + // UGLY HACK: FIX ME!!! switch (i->getElementType()) { @@ -308,6 +322,7 @@ namespace armarx::skills::gui break; }; + createdMatrix->setShape({i->getRows(), i->getCols(), dataSize}); int totalByteSize = i->getRows() * i->getCols() * dataSize; createdAron = createdMatrix; @@ -323,17 +338,21 @@ namespace armarx::skills::gui } } - + auto* rootWidget = el->treeWidget(); ARMARX_CHECK(rootWidget); auto* widget = rootWidget->itemWidget(el, 1); + ARMARX_CHECK(rootWidget); auto* matrixWidget = EditMatrixWidget::DynamicCastAndCheck(widget); + ARMARX_CHECK(matrixWidget); handleErrors(matrixWidget->hasParseErrors()); if (matrixWidget->hasParseErrors()) { return; } + + // write to aron data std::vector<unsigned char> elems; elems.reserve(totalByteSize); @@ -349,11 +368,13 @@ namespace armarx::skills::gui } } createdMatrix->setData(totalByteSize, elems.data()); + } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::QuaternionPtr& i) { + ARMARX_TRACE; auto createdQuat = std::make_shared<aron::data::NDArray>(i->getPath()); createdAron = createdQuat; @@ -390,6 +411,7 @@ namespace armarx::skills::gui << "serialized quaternions did not return byte sequence of correct length!"; } createdQuat->setData(serialized.size(), serialized.data()); + } void @@ -409,6 +431,7 @@ namespace armarx::skills::gui void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::IntEnumPtr& i) { + ARMARX_TRACE; QTreeWidgetItem* el = parentItem->child(index); @@ -433,11 +456,13 @@ namespace armarx::skills::gui std::tie(success, createdAron) = intEnumWidget->parseToAron(); handleErrors(!success); + } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::IntPtr& i) { + ARMARX_TRACE; auto createdAronInt = std::make_shared<aron::data::Int>(i->getPath()); createdAron = createdAronInt; @@ -472,11 +497,13 @@ namespace armarx::skills::gui return; } handleErrors(false); + } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::LongPtr& i) { + ARMARX_TRACE; auto createdAronLong = std::make_shared<aron::data::Long>(i->getPath()); createdAron = createdAronLong; @@ -510,11 +537,13 @@ namespace armarx::skills::gui return; } handleErrors(false); + } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::FloatPtr& i) { + ARMARX_TRACE; auto createdAronFloat = std::make_shared<aron::data::Float>(i->getPath()); createdAron = createdAronFloat; @@ -547,11 +576,13 @@ namespace armarx::skills::gui return; } handleErrors(false); + } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::DoublePtr& i) { + ARMARX_TRACE; auto createdAronDouble = std::make_shared<aron::data::Double>(i->getPath()); createdAron = createdAronDouble; @@ -584,11 +615,13 @@ namespace armarx::skills::gui return; } handleErrors(false); + } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::BoolPtr& i) { + ARMARX_TRACE; auto createdAronBool = std::make_shared<aron::data::Bool>(i->getPath()); createdAron = createdAronBool; @@ -621,16 +654,23 @@ namespace armarx::skills::gui return; } handleErrors(false); + } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::StringPtr& i) { + ARMARX_TRACE; auto createdAronString = std::make_shared<aron::data::String>(i->getPath()); createdAron = createdAronString; QTreeWidgetItem* el = parentItem->child(index); + if (el == nullptr) + { + return; + } + if (i->getMaybe() != armarx::aron::type::Maybe::NONE) { // its a maybetype. We have to check the state @@ -643,6 +683,7 @@ namespace armarx::skills::gui std::string str = el->text(1).toStdString(); createdAronString->setValue(str); + } void diff --git a/source/RobotAPI/libraries/skills_gui/aron_tree_widget/visitors/AronTreeWidgetSetter.cpp b/source/RobotAPI/libraries/skills_gui/aron_tree_widget/visitors/AronTreeWidgetSetter.cpp index 77887a000c8c5b7dddf955ba8eadeb1ec39b43ec..a9f7e4db55e3e90abcd02bf29e4d4e8c3527b4f6 100644 --- a/source/RobotAPI/libraries/skills_gui/aron_tree_widget/visitors/AronTreeWidgetSetter.cpp +++ b/source/RobotAPI/libraries/skills_gui/aron_tree_widget/visitors/AronTreeWidgetSetter.cpp @@ -35,11 +35,12 @@ template <typename T> std::string usString(T number, size_t precision = 3) { + std::stringstream ss; const char* locale = "C"; ss.imbue(std::locale(locale)); - ss << std::fixed << std::setprecision(precision) << number; + return ss.str(); } @@ -102,6 +103,7 @@ namespace armarx::skills::gui void AronTreeWidgetSetterVisitor::visitAronVariant(const aron::data::DictPtr& i) { + // either it is the root or it has a name if (i->getPath().size() == 0 || checkTreeWidgetItemForSimilarName(i->getPath().getLastElement())) @@ -126,11 +128,13 @@ namespace armarx::skills::gui el->setCheckState(2, Qt::CheckState::Checked); } } + } void AronTreeWidgetSetterVisitor::visitAronVariant(const aron::data::ListPtr& i) { + if (checkTreeWidgetItemForSimilarName(i->getPath().getLastElement())) { AronTreeWidgetItem* el = AronTreeWidgetItem::DynamicCast(parentItem->child(index)); @@ -161,6 +165,7 @@ namespace armarx::skills::gui el->setCheckState(2, Qt::CheckState::Checked); } } + } void @@ -168,6 +173,7 @@ namespace armarx::skills::gui const std::shared_ptr<armarx::aron::type::Matrix>& matrixType, const aron::data::NDArrayPtr& arr) { + auto elemType = matrixType->getElementType(); auto* rawData = arr->getData(); // string can convert any item @@ -250,6 +256,7 @@ namespace armarx::skills::gui std::shared_ptr<armarx::aron::type::Quaternion>& quatType, const aron::data::NDArrayPtr& arr) { + auto elemType = quatType->getElementType(); auto rawData = arr->getData(); auto shape = arr->getShape(); @@ -280,11 +287,13 @@ namespace armarx::skills::gui { quatWidget->setText((QuaternionWidget::QuaternionComponents)i, toString(i)); } + } void AronTreeWidgetSetterVisitor::visitAronVariant(const aron::data::NDArrayPtr& arr) { + // Matrices are handled as NDArray. Raw ndarrays cannot be created currently auto* el = AronTreeWidgetItem::DynamicCast(parentItem->child(index)); ARMARX_CHECK(el); @@ -315,11 +324,13 @@ namespace armarx::skills::gui { el->setCheckState(2, Qt::CheckState::Checked); } + } void AronTreeWidgetSetterVisitor::visitAronVariant(const aron::data::IntPtr& i) { + if (checkTreeWidgetItemForSimilarName(i->getPath().getLastElement())) { AronTreeWidgetItem* el = AronTreeWidgetItem::DynamicCast(parentItem->child(index)); @@ -341,11 +352,13 @@ namespace armarx::skills::gui el->setCheckState(2, Qt::CheckState::Checked); } } + } void AronTreeWidgetSetterVisitor::visitAronVariant(const aron::data::LongPtr& i) { + if (checkTreeWidgetItemForSimilarName(i->getPath().getLastElement())) { AronTreeWidgetItem* el = AronTreeWidgetItem::DynamicCast(parentItem->child(index)); @@ -356,6 +369,7 @@ namespace armarx::skills::gui el->setCheckState(2, Qt::CheckState::Checked); } } + } void @@ -364,18 +378,21 @@ namespace armarx::skills::gui if (checkTreeWidgetItemForSimilarName(i->getPath().getLastElement())) { AronTreeWidgetItem* el = AronTreeWidgetItem::DynamicCast(parentItem->child(index)); - el->setText(1, QString::fromStdString(usString<float>(i->getValue()))); - + std::string repr = usString<float>(i->getValue()); + QString qstr = QString::fromStdString(repr); + el->setText(1, qstr); if (el->aronType && el->aronType->getMaybe() != armarx::aron::type::Maybe::NONE) { el->setCheckState(2, Qt::CheckState::Checked); } } + } void AronTreeWidgetSetterVisitor::visitAronVariant(const aron::data::DoublePtr& i) { + if (checkTreeWidgetItemForSimilarName(i->getPath().getLastElement())) { AronTreeWidgetItem* el = AronTreeWidgetItem::DynamicCast(parentItem->child(index)); @@ -386,11 +403,13 @@ namespace armarx::skills::gui el->setCheckState(2, Qt::CheckState::Checked); } } + } void AronTreeWidgetSetterVisitor::visitAronVariant(const aron::data::BoolPtr& i) { + if (checkTreeWidgetItemForSimilarName(i->getPath().getLastElement())) { AronTreeWidgetItem* el = AronTreeWidgetItem::DynamicCast(parentItem->child(index)); @@ -401,11 +420,13 @@ namespace armarx::skills::gui el->setCheckState(2, Qt::CheckState::Checked); } } + } void AronTreeWidgetSetterVisitor::visitAronVariant(const aron::data::StringPtr& i) { + if (checkTreeWidgetItemForSimilarName(i->getPath().getLastElement())) { AronTreeWidgetItem* el = AronTreeWidgetItem::DynamicCast(parentItem->child(index)); @@ -416,6 +437,7 @@ namespace armarx::skills::gui el->setCheckState(2, Qt::CheckState::Checked); } } + } void