MotionPlanningServerTaskList.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package RobotComponents
19 * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
20 * @date 2015
21 * @copyright http://www.gnu.org/licenses/gpl.txt
22 * GNU General Public License
23 */
25
26#include <Ice/LocalException.h>
27
29#include <RobotComponents/gui-plugins/MotionPlanning/QtWidgets/ui_MotionPlanningServerTaskList.h>
30
31using namespace armarx;
32
34 QWidget(parent), ui(new Ui::MotionPlanningServerTaskList)
35{
36 ui->setupUi(this);
37 startTimer(100);
38 connect(ui->pushButtonRefresh, SIGNAL(clicked()), this, SLOT(updateList()));
39}
40
45
46std::optional<Ice::Long>
48{
49 const auto&& rowsSelection = ui->tableWidget->selectionModel()->selectedRows();
50 if (rowsSelection.empty())
51 {
52 return std::nullopt;
53 }
54 const auto rowIndex = rowsSelection.first().row();
55 return ui->tableWidget->item(rowIndex, 4)->text().toLong();
56}
57
58void
60{
61 auto selected = getSelectedId();
62 clearList();
63 if (!planningServerProxy)
64 {
65 return;
66 }
67 try
68 {
69 //get data
70 const auto data = planningServerProxy->getAllTaskInfo();
71 ui->tableWidget->setRowCount(data.size());
72 std::size_t rowToSelect = 0;
73 //fill table
74 for (std::size_t row = 0; row < data.size(); ++row)
75 {
76 const auto& datum = data.at(row);
77 ui->tableWidget->setItem(
78 row, 0, new QTableWidgetItem{QString::fromStdString(datum.taskName)});
79 ui->tableWidget->setItem(
80 row, 1, new QTableWidgetItem{QString::fromStdString(toString(datum.status))});
81 ui->tableWidget->setItem(
82 row,
83 2,
84 new QTableWidgetItem{datum.taskIdent.category.empty()
85 ? QString::fromStdString(datum.taskIdent.name)
86 : QString::fromStdString(datum.taskIdent.category) + '\n' +
87 QString::fromStdString(datum.taskIdent.name)});
88 ui->tableWidget->setItem(
89 row, 3, new QTableWidgetItem{QString::fromStdString(datum.typeId)});
90 ui->tableWidget->setItem(
91 row, 4, new QTableWidgetItem{QString::number(datum.internalId)});
92 if (selected && *selected == datum.internalId)
93 {
94 rowToSelect = row;
95 }
96 }
97 ui->tableWidget->selectRow(rowToSelect);
98 }
99 catch (Ice::UserException&)
100 {
101 //don't spamm on disconnect
102 return;
103 }
104 catch (Ice::NotRegisteredException&)
105 {
106 //don't spamm on disconnect
107 return;
108 }
109 catch (Ice::ConnectionRefusedException&)
110 {
111 //don't spamm on disconnect
112 return;
113 }
114}
115
116void
118{
119 ui->tableWidget->setRowCount(0);
120}
121
122void
124{
125 ui->checkBoxAutoRefresh->setChecked(enabled);
126}
127
128void
130{
131 if (ui->checkBoxAutoRefresh->isChecked())
132 {
133 updateList();
134 }
135}
ArmarX Headers.
This file offers overloads of toIce() and fromIce() functions for STL container types.