diff --git a/source/RobotAPI/libraries/skills_gui/executions/SkillExecutionTreeWidget.cpp b/source/RobotAPI/libraries/skills_gui/executions/SkillExecutionTreeWidget.cpp index f1be93266363778b91902d85e21c3f87d9edfdd5..dd1f601f1c2d8ff7d59fa9479fdb2becfac69692 100644 --- a/source/RobotAPI/libraries/skills_gui/executions/SkillExecutionTreeWidget.cpp +++ b/source/RobotAPI/libraries/skills_gui/executions/SkillExecutionTreeWidget.cpp @@ -27,13 +27,13 @@ namespace armarx::skills::gui menu->addAction(stopSkillAction); menu->addAction(rerunSkillAction); connect(stopSkillAction, - SIGNAL(stopSkillAction.triggered()), + &QAction::triggered, this, - SIGNAL(stopSelectedExecution())); + &SkillExecutionTreeWidget::stopSelectedExecution); connect(rerunSkillAction, - SIGNAL(rerunSkillAction.triggered()), + &QAction::triggered, this, - SIGNAL(rerunSkillWithSimilarParams())); + &SkillExecutionTreeWidget::rerunSkillWithSimilarParams); // Temporarily disable rerun-skill-Action rerunSkillAction->setDisabled(true); @@ -48,6 +48,25 @@ namespace armarx::skills::gui memory->stopExecution(this->selectedExecution.skillExecutionId); } + void + SkillExecutionTreeWidget::rerunSkillWithSimilarParams() + { + // we don't want to hold state in the gui, so we need to get the parameters from memory: + skills::SkillExecutionID currentExecutionId = this->selectedExecution.skillExecutionId; + auto update = memory->getLatestUpdate(); + if (!update.statuses.contains(currentExecutionId)) + { + // we didn't find an entry for the execution id + ARMARX_IMPORTANT << "The selected execution was not found in memory. The GUI is unable " + "to determine the parametrization for this execution."; + return; + } + auto params = update.statuses[currentExecutionId].parameters; + + // give all information to manager + this->memory->startExecutionWithParams(currentExecutionId.skillId, params); + } + void SkillExecutionTreeWidget::refresh() { @@ -61,7 +80,12 @@ namespace armarx::skills::gui SkillExecutionTreeWidgetItem* found = nullptr; for (int i = 0; i < this->topLevelItemCount(); ++i) { - auto c = static_cast<SkillExecutionTreeWidgetItem*>(topLevelItem(i)); + auto c = dynamic_cast<SkillExecutionTreeWidgetItem*>(topLevelItem(i)); + if (!c) + { + // the item is probably not the correct type, skip... + continue; + } found = SkillExecutionTreeWidgetItem::SearchRecursiveForMatch(c, executionId); diff --git a/source/RobotAPI/libraries/skills_gui/executions/SkillExecutionTreeWidget.h b/source/RobotAPI/libraries/skills_gui/executions/SkillExecutionTreeWidget.h index 211538c64f66b6692df53feb6ca161c7e381446e..797e60d41c4f147341fd9dc8a1b36722c79a722d 100644 --- a/source/RobotAPI/libraries/skills_gui/executions/SkillExecutionTreeWidget.h +++ b/source/RobotAPI/libraries/skills_gui/executions/SkillExecutionTreeWidget.h @@ -47,14 +47,13 @@ namespace armarx::skills::gui SelectedExecution& getSelectedExecution(); - signals: - void rerunSkillWithSimilarParams(); private slots: void stopAllExecutions(); void executionSelectionChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous); void refresh(); void runContextMenu(const QPoint& pos); void stopSelectedExecution(); + void rerunSkillWithSimilarParams(); private: void setupUi(); diff --git a/source/RobotAPI/libraries/skills_gui/executions/SkillExecutionTreeWidgetItem.h b/source/RobotAPI/libraries/skills_gui/executions/SkillExecutionTreeWidgetItem.h index 18afc63562b0749248d44b2c12746721b0c09a92..270ef032187cf93ac4efd2292fcdf3f9433623db 100644 --- a/source/RobotAPI/libraries/skills_gui/executions/SkillExecutionTreeWidgetItem.h +++ b/source/RobotAPI/libraries/skills_gui/executions/SkillExecutionTreeWidgetItem.h @@ -27,12 +27,10 @@ namespace armarx::skills::gui SearchRecursiveForMatch(SkillExecutionTreeWidgetItem* haystack, const skills::SkillExecutionID& needle); - skills::SkillExecutionID getExecutionID(); - void updateItem(skills::SkillStatus status); - protected: skills::SkillExecutionID executionId; + private: void setupUi(); };