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 #include <RobotComponents/gui-plugins/MotionPlanning/QtWidgets/ui_MotionPlanningServerTaskList.h>
26 
27 #include <Ice/LocalException.h>
28 
30 
31 using namespace armarx;
32 
34  QWidget(parent),
36 {
37  ui->setupUi(this);
38  startTimer(100);
39  connect(ui->pushButtonRefresh, SIGNAL(clicked()), this, SLOT(updateList()));
40 }
41 
43 {
44  delete ui;
45 }
46 
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 
59 {
60  auto selected = getSelectedId();
61  clearList();
62  if (!planningServerProxy)
63  {
64  return;
65  }
66  try
67  {
68  //get data
69  const auto data = planningServerProxy->getAllTaskInfo();
70  ui->tableWidget->setRowCount(data.size());
71  std::size_t rowToSelect = 0;
72  //fill table
73  for (std::size_t row = 0; row < data.size(); ++row)
74  {
75  const auto& datum = data.at(row);
76  ui->tableWidget->setItem(row, 0, new QTableWidgetItem {QString::fromStdString(datum.taskName)});
77  ui->tableWidget->setItem(row, 1, new QTableWidgetItem {QString::fromStdString(toString(datum.status))});
78  ui->tableWidget->setItem(row, 2, new QTableWidgetItem
79  {
80  datum.taskIdent.category.empty() ?
81  QString::fromStdString(datum.taskIdent.name) :
82  QString::fromStdString(datum.taskIdent.category) + '\n' + QString::fromStdString(datum.taskIdent.name)
83  });
84  ui->tableWidget->setItem(row, 3, new QTableWidgetItem {QString::fromStdString(datum.typeId)});
85  ui->tableWidget->setItem(row, 4, new QTableWidgetItem {QString::number(datum.internalId)});
86  if (selected && *selected == datum.internalId)
87  {
88  rowToSelect = row;
89  }
90  }
91  ui->tableWidget->selectRow(rowToSelect);
92  }
93  catch (Ice::UserException&)
94  {
95  //don't spamm on disconnect
96  return;
97  }
98  catch (Ice::NotRegisteredException&)
99  {
100  //don't spamm on disconnect
101  return;
102  }
103  catch (Ice::ConnectionRefusedException&)
104  {
105  //don't spamm on disconnect
106  return;
107  }
108 }
109 
111 {
112  ui->tableWidget->setRowCount(0);
113 }
114 
116 {
117  ui->checkBoxAutoRefresh->setChecked(enabled);
118 }
119 
121 {
122  if (ui->checkBoxAutoRefresh->isChecked())
123  {
124  updateList();
125  }
126 }
armarx::MotionPlanningServerTaskList::getSelectedId
std::optional< Ice::Long > getSelectedId()
Definition: MotionPlanningServerTaskList.cpp:47
armarx::MotionPlanningServerTaskList::updateList
void updateList()
Definition: MotionPlanningServerTaskList.cpp:58
MotionPlanningServerTaskList.h
armarx::MotionPlanningServerTaskList::enableAutoUpdate
void enableAutoUpdate(bool enabled)
Definition: MotionPlanningServerTaskList.cpp:115
armarx::MotionPlanningServerTaskList::timerEvent
void timerEvent(QTimerEvent *) override
Definition: MotionPlanningServerTaskList.cpp:120
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:58
armarx::MotionPlanningServerTaskList::~MotionPlanningServerTaskList
~MotionPlanningServerTaskList() override
Definition: MotionPlanningServerTaskList.cpp:42
armarx::MotionPlanningServerTaskList::MotionPlanningServerTaskList
MotionPlanningServerTaskList(QWidget *parent=nullptr)
Definition: MotionPlanningServerTaskList.cpp:33
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
enabled
std::atomic< bool > * enabled
Definition: RemoteGuiWidgetController.cpp:75
armarx::MotionPlanningServerTaskList::clearList
void clearList()
Definition: MotionPlanningServerTaskList.cpp:110
armarx::MotionPlanningServerTaskList
Definition: MotionPlanningServerTaskList.h:40
armarx::viz::toString
const char * toString(InteractionFeedbackType type)
Definition: Interaction.h:27
PlanningUtil.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28