From 7b3269c54fd1a24729f383c4423186a695f81423 Mon Sep 17 00:00:00 2001 From: Peter Albrecht <usnlf@student.kit.edu> Date: Thu, 19 Dec 2024 17:33:48 +0100 Subject: [PATCH] Add dead skill detection in details widget --- .../skill_details/SkillDetailsGroupBox.cpp | 4 +++ .../skill_details/SkillDetailsGroupBox.h | 2 ++ .../skill_details/SkillDetailsTreeWidget.cpp | 28 ++++++++++++++++++- .../skill_details/SkillDetailsTreeWidget.h | 5 +++- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsGroupBox.cpp b/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsGroupBox.cpp index 45925621c..c83a0f9b4 100644 --- a/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsGroupBox.cpp +++ b/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsGroupBox.cpp @@ -137,6 +137,10 @@ namespace armarx::skills::gui &SkillDetailGroupBox::disconnectGui, skillDetailsTreeWidget, &SkillDetailsTreeWidget::disconnectGui); + connect(this, + &SkillDetailGroupBox::updateGui, + skillDetailsTreeWidget, + &SkillDetailsTreeWidget::updateGui); // profile buttons connect(profileMenuWidget->copyArgsToClipboard, diff --git a/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsGroupBox.h b/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsGroupBox.h index 3d2a56b14..c8685bfe4 100644 --- a/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsGroupBox.h +++ b/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsGroupBox.h @@ -33,6 +33,8 @@ namespace armarx::skills::gui signals: void disconnectGui(); + void updateGui(SkillManagerWrapper::Snapshot update); + public slots: /** * @brief Notify subwidgets of an updated skill selection. diff --git a/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsTreeWidget.cpp b/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsTreeWidget.cpp index 57b26011b..1d7c734b8 100644 --- a/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsTreeWidget.cpp +++ b/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsTreeWidget.cpp @@ -5,6 +5,7 @@ #include <QHeaderView> #include <QResizeEvent> #include <QVBoxLayout> +#include <ArmarXCore/core/logging/Logging.h> #include <RobotAPI/libraries/aron/converter/json/NLohmannJSONConverter.h> @@ -80,7 +81,7 @@ namespace armarx::skills::gui } void - SkillDetailsTreeWidget::updateGui() + SkillDetailsTreeWidget::updateGui(SkillManagerWrapper::Snapshot update) { if (!shownSkill.has_value()) return; @@ -120,6 +121,31 @@ namespace armarx::skills::gui setColumnHidden(3, true); } + + void SkillDetailsTreeWidget::checkIfShownSkillIsAvailable(SkillManagerWrapper::Snapshot& update) + { + if (this->shownSkill.has_value()) + { + // iterate over all available skill ids + for (auto& availableProviderMap : update.skills) + { + for (auto& availableSkill : availableProviderMap.second) + { + // if we find a matching skill id, we return + if (availableSkill.first == this->shownSkill->skillId) + { + return; + } + } + } + + // in this case, no matching skill id has been found + // -> reset this view, as the shown skill is invalid + ARMARX_INFO << deactivateSpam(10) + << "The currently shown skill in the details widget has not been found in the latest manager update. Resetting the widget..."; + this->resetWidget(); + } + } /** * Problem: columns 0 and 1 have arbitrary size; so we want to limit their size, to make sure diff --git a/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsTreeWidget.h b/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsTreeWidget.h index 1ac3bcdd1..ae8b35215 100644 --- a/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsTreeWidget.h +++ b/source/RobotAPI/libraries/skills_gui/skill_details/SkillDetailsTreeWidget.h @@ -1,8 +1,10 @@ #ifndef SKILLDETAILSTREEWIDGET_H #define SKILLDETAILSTREEWIDGET_H +#include <vector> #include <QTreeWidget> +#include "RobotAPI/libraries/skills/core/SkillID.h" #include "RobotAPI/libraries/skills_gui/aron_tree_widget/AronTreeWidgetController.h" #include "../memory/MemoryCommunicatorBase.h" @@ -28,7 +30,7 @@ namespace armarx::skills::gui // this will reset the args to the profile defaults void resetCurrentConfig(); void disconnectGui(); - void updateGui(); + void updateGui(SkillManagerWrapper::Snapshot update); void resizeContents(); private: @@ -46,6 +48,7 @@ namespace armarx::skills::gui AronTreeWidgetControllerPtr aronTreeWidgetController = nullptr; void setupUi(); + void checkIfShownSkillIsAvailable(SkillManagerWrapper::Snapshot& update); }; } // namespace armarx::skills::gui -- GitLab