KinematicUnitConfigDialog.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::
17 * @author Mirko Waechter ( mirko.waechter at kit dot edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
24 #include <RobotAPI/gui-plugins/KinematicUnitPlugin/ui_KinematicUnitConfigDialog.h>
25 
26 #include <QTimer>
27 #include <QPushButton>
28 #include <QMessageBox>
29 
30 
31 // ArmarX
32 #include <RobotAPI/interface/units/KinematicUnitInterface.h>
33 
34 #include <IceUtil/UUID.h>
35 
37 
38 #include <RobotAPI/interface/core/RobotState.h>
39 
40 using namespace armarx;
41 
43  QDialog(parent),
45  uuid(IceUtil::generateUUID())
46 {
47  ui->setupUi(this);
48 
49  connect(this->ui->buttonBox, SIGNAL(accepted()), this, SLOT(verifyConfig()));
50  ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
51  ui->buttonBox->button(QDialogButtonBox::Cancel)->setDefault(false);
52  ui->buttonBox->button(QDialogButtonBox::Cancel)->setAutoDefault(false);
53  proxyFinder = new IceProxyFinder<KinematicUnitInterfacePrx>(this);
54  proxyFinder->setSearchMask("*KinematicUnit|KinematicUnit*");
55  ui->gridLayout->addWidget(proxyFinder, 0, 1, 1, 2);
56 
57  connect(proxyFinder->getProxyNameComboBox(), SIGNAL(currentIndexChanged(int)), this, SLOT(selectionChanged(int)));
58  connect(proxyFinder->getProxyNameComboBox(), SIGNAL(editTextChanged(QString)), this, SLOT(proxyNameChanged(QString)));
59 }
60 
62 {
63  delete ui;
64 }
65 
67 {
68  proxyFinder->setIceManager(getIceManager());
69 }
70 
72 {
73 
74 }
75 
77 {
78  QObject::disconnect();
79 
80 }
81 
83 {
84  if (proxyFinder->getSelectedProxyName().trimmed().length() == 0)
85  {
86  QMessageBox::critical(this, "Invalid Configuration", "The proxy name must not be empty");
87  }
88  else
89  {
90  this->accept();
91  }
92 }
93 
94 void KinematicUnitConfigDialog::updateSubconfig(std::string kinematicUnitName)
95 {
96 
97  try
98  {
99  ARMARX_INFO << "Connecting to KinematicUnitProxy " << kinematicUnitName;
100 
101  KinematicUnitInterfacePrx kinematicUnitInterfacePrx = getProxy<KinematicUnitInterfacePrx>(kinematicUnitName);
102  std::string topicName = kinematicUnitInterfacePrx->getReportTopicName();
103  std::string robotNodeSetName = kinematicUnitInterfacePrx->getRobotNodeSetName();
104  std::string rfile = kinematicUnitInterfacePrx->getRobotFilename();
105  ui->labelTopic->setText(QString(topicName.c_str()));
106  ui->labelRobotModel->setText(QString(rfile.c_str()));
107  ui->labelRNS->setText(QString(robotNodeSetName.c_str()));
108  }
109  catch (...)
110  {
111  ARMARX_INFO << "Could not connect to KinematicUnitProxy " << kinematicUnitName;
112  }
113 }
114 
116 {
117  ARMARX_LOG << "Selected entry:" << nr;
118  ui->labelTopic->setText("");
119  ui->labelRobotModel->setText("");
120  ui->labelRNS->setText("");
121  if (nr < 0)
122  {
123  return;
124  }
125  std::string kinematicUnitName = proxyFinder->getSelectedProxyName().toStdString();
126 
127  updateSubconfig(kinematicUnitName);
128 
129 }
130 
131 void KinematicUnitConfigDialog::proxyNameChanged(QString kinematicUnitName)
132 {
133  ui->labelTopic->setText("");
134  ui->labelRobotModel->setText("");
135  ui->labelRNS->setText("");
136  updateSubconfig(kinematicUnitName.toStdString());
137 }
138 
139 
140 
armarx::ManagedIceObject::getIceManager
IceManagerPtr getIceManager() const
Returns the IceManager.
Definition: ManagedIceObject.cpp:353
armarx::IceProxyFinderBase::setSearchMask
void setSearchMask(const QString &searchMask)
Definition: IceProxyFinder.cpp:88
armarx::IceProxyFinderBase::setIceManager
void setIceManager(IceManagerPtr icemanager, bool fetchProxies=true)
Definition: IceProxyFinder.cpp:64
armarx::KinematicUnitConfigDialog::~KinematicUnitConfigDialog
~KinematicUnitConfigDialog() override
Definition: KinematicUnitConfigDialog.cpp:61
armarx::KinematicUnitConfigDialog::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: KinematicUnitConfigDialog.cpp:66
armarx::KinematicUnitConfigDialog::verifyConfig
void verifyConfig()
Definition: KinematicUnitConfigDialog.cpp:82
armarx::KinematicUnitConfigDialog::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: KinematicUnitConfigDialog.cpp:76
IceUtil
Definition: Instance.h:21
armarx::KinematicUnitConfigDialog::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: KinematicUnitConfigDialog.cpp:71
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
armarx::KinematicUnitConfigDialog
Definition: KinematicUnitConfigDialog.h:40
IceProxyFinder.h
KinematicUnitConfigDialog.h
armarx::KinematicUnitConfigDialog::proxyNameChanged
void proxyNameChanged(QString)
Definition: KinematicUnitConfigDialog.cpp:131
ARMARX_LOG
#define ARMARX_LOG
Definition: Logging.h:163
armarx::IceProxyFinderBase::getSelectedProxyName
QString getSelectedProxyName() const
Definition: IceProxyFinder.cpp:73
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::IceProxyFinderBase::getProxyNameComboBox
QWidget * getProxyNameComboBox()
Definition: IceProxyFinder.cpp:110
armarx::KinematicUnitConfigDialog::KinematicUnitConfigDialog
KinematicUnitConfigDialog(QWidget *parent=0)
Definition: KinematicUnitConfigDialog.cpp:42
armarx::IceProxyFinder
Definition: StatechartViewerController.h:51
armarx::KinematicUnitConfigDialog::updateSubconfig
void updateSubconfig(std::string kinematicUnitName)
Definition: KinematicUnitConfigDialog.cpp:94
armarx::KinematicUnitConfigDialog::selectionChanged
void selectionChanged(int nr)
Definition: KinematicUnitConfigDialog.cpp:115
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28