Skip to content
Snippets Groups Projects
Commit 6fb8538f authored by Peter Naumann's avatar Peter Naumann
Browse files

Indicate source scenario and package for linked applications

parent d6b193a8
No related branches found
No related tags found
1 merge request!90Extended support for linked scenarios
Pipeline #15703 failed
......@@ -31,12 +31,35 @@
#include <ArmarXCore/core/util/algorithm.h>
#include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h>
#include <ArmarXCore/core/application/properties/PropertyDefinitionHelpFormatter.h>
#include <ArmarXCore/util/ScenarioManagerCommon/parser/XMLScenarioParser.h>
#include <ArmarXCore/util/ScenarioManagerCommon/parser/PackageBuilder.h>
#define UPDATE_TIMER_INTERVAL 500
using namespace ScenarioManager;
using namespace Data_Structure;
// Returns {package, scenario}
std::pair<std::string, std::string> scenarioInfoFromLink(const std::filesystem::path& linkpath)
{
auto instancePath = std::filesystem::canonical(linkpath);
auto scenarioFolder = instancePath.parent_path().parent_path();
std::string scenarioName = scenarioFolder.filename();
auto scenarioScx = scenarioFolder / (scenarioName + ".scx");
if (!std::filesystem::exists(scenarioScx))
{
return {"unknown", "unknown"};
}
auto packageName = ScenarioManager::Parser::XMLScenarioParser().getPackageNameFromScx(scenarioScx);
if (packageName.empty())
{
return {"unknown", scenarioName};
}
return {packageName, scenarioName};
}
DetailedApplicationView::DetailedApplicationView(QWidget* parent) :
QWidget(parent),
ui(new Ui::DetailedApplicationView),
......@@ -210,9 +233,27 @@ void DetailedApplicationView::showApplicationInstance(ApplicationInstancePtr app
ui->makeLocalButton->setVisible(readOnly);
ui->addParameterButton->setVisible(!readOnly);
std::string label = appInstance->getName();
if (readOnly)
{
auto [package, scenario] = scenarioInfoFromLink(appInstance->getConfigPath());
label += " -> " + scenario;
std::string tooltip;
if (package == "unknown")
{
tooltip = "Could not determine original scenario for config '" +
std::string(std::filesystem::canonical(appInstance->getConfigPath())) + "'";
}
else
{
tooltip = "Original is in " +
(package == "unknown" ? "unknown package" : "package " + package) +
", scenario " + scenario;
}
ui->dataLabel->setToolTip(QString::fromStdString(tooltip));
}
ui->dataLabel->setText(QString::fromStdString(label));
ui->dataLabel->setText(QString::fromStdString(appInstance->getName()));
ui->stateLabel->setText(QString::fromStdString(appInstance->getStatus()));
statusUpdateRelevant = true;
lastAppInstance = appInstance;
lastScenario = ScenarioPtr(nullptr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment