MotionAttributesEditTab.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 MemoryX::MemoryX::PriorMemoryEditorPlugin
17 * @author Kai Welke (welke at kit dot edu)
18 * @date 2013
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
24 
25 #include <MemoryX/gui-plugins/PriorMemoryEditor/ui_MotionAttributesEditTab.h>
29 
30 using namespace memoryx;
31 using namespace memoryx::EntityWrappers;
32 
35 {
36  ui->setupUi(this);
37 
38  // init feature file dialog
39  connect(ui->comboBoxMotionModel,
40  SIGNAL(currentIndexChanged(const QString&)),
41  this,
42  SLOT(motionModelChanged(const QString&)));
43  connect(ui->comboBoxSimulationType,
44  SIGNAL(currentIndexChanged(const QString&)),
45  this,
46  SLOT(simulationTypeChanged(const QString&)));
47 
50 }
51 
53 {
54  delete ui;
55 }
56 
57 void
59 {
60  ObjectClassPtr objectClass = ObjectClassPtr::dynamicCast(entity);
61 
62  ObjectRecognitionWrapperPtr objectRecognitionWrapper =
63  objectClass->getWrapper<ObjectRecognitionWrapper>();
64  int index = ui->comboBoxMotionModel->findText(
65  QString(objectRecognitionWrapper->getDefaultMotionModel().c_str()));
66  if (index != -1)
67  {
68  ui->comboBoxMotionModel->setCurrentIndex(index);
69  }
70 
71  SimoxObjectWrapperPtr simoxWrapper = objectClass->getWrapper<SimoxObjectWrapper>();
72  VirtualRobot::SceneObject::Physics::SimulationType simType =
73  simoxWrapper->getManipulationObject()->getSimulationType();
74  index = ui->comboBoxSimulationType->findText(simTypeToString(simType));
75  if (index != -1)
76  {
77  ui->comboBoxSimulationType->setCurrentIndex(index);
78  }
79 }
80 
81 void
82 MotionAttributesEditTab::updateEntity(const EntityPtr& entity, std::string filesDBName)
83 {
84  ObjectClassPtr objectClass = ObjectClassPtr::dynamicCast(entity);
85 
86  ObjectRecognitionWrapperPtr objectRecognitionWrapper =
87  objectClass->getWrapper<ObjectRecognitionWrapper>();
88  std::string motionModelName = ui->comboBoxMotionModel->currentText().toStdString();
89  ARMARX_INFO << "Setting motion model: " << motionModelName;
90  objectRecognitionWrapper->setDefaultMotionModel(motionModelName);
91 
92  SimoxObjectWrapperPtr simoxWrapper = objectClass->getWrapper<SimoxObjectWrapper>();
93  VirtualRobot::ManipulationObjectPtr mo = simoxWrapper->getManipulationObject();
94  QString simulationTypeName = ui->comboBoxSimulationType->currentText();
95 
96  ARMARX_INFO << simoxWrapper->getManipulationObjectFileName();
97  ARMARX_INFO << "Setting simulation type: " << simulationTypeName.toStdString();
98  mo->setSimulationType(stringToSimType(simulationTypeName));
99  simoxWrapper->setAndStoreManipulationObject(mo, filesDBName);
100 }
101 
102 void
104 {
105 }
106 
107 void
109 {
110 }
111 
112 QString
113 MotionAttributesEditTab::simTypeToString(VirtualRobot::SceneObject::Physics::SimulationType simType)
114 {
115  switch (simType)
116  {
117  case VirtualRobot::SceneObject::Physics::eStatic:
118  return "Static";
119  case VirtualRobot::SceneObject::Physics::eKinematic:
120  return "Kinematic";
121  case VirtualRobot::SceneObject::Physics::eDynamic:
122  return "Dynamic";
123  default:
124  return "Unknown";
125  }
126 }
127 
128 VirtualRobot::SceneObject::Physics::SimulationType
129 MotionAttributesEditTab::stringToSimType(const QString& string)
130 {
131  if (string == "Static")
132  {
133  return VirtualRobot::SceneObject::Physics::eStatic;
134  }
135  else if (string == "Kinematic")
136  {
137  return VirtualRobot::SceneObject::Physics::eKinematic;
138  }
139  else if (string == "Dynamic")
140  {
141  return VirtualRobot::SceneObject::Physics::eDynamic;
142  }
143  else
144  {
145  return VirtualRobot::SceneObject::Physics::eUnknown;
146  }
147 }
memoryx::MotionAttributesEditTab
This tab allows to change the motion model attributes of an objectclass entity.
Definition: MotionAttributesEditTab.h:43
index
uint8_t index
Definition: EtherCATFrame.h:59
memoryx::MotionAttributesEditTab::updateGui
void updateGui(const EntityPtr &entity) override
Pure virtual method.
Definition: MotionAttributesEditTab.cpp:58
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
ObjectRecognitionWrapper.h
ObjectClass.h
memoryx::MotionAttributesEditTab::~MotionAttributesEditTab
~MotionAttributesEditTab() override
Definition: MotionAttributesEditTab.cpp:52
memoryx::MotionAttributesEditTab::simulationTypeChanged
void simulationTypeChanged(const QString &method)
Definition: MotionAttributesEditTab.cpp:108
IceInternal::Handle
Definition: forward_declarations.h:8
MotionAttributesEditTab.h
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
memoryx::MotionAttributesEditTab::updateEntity
void updateEntity(const EntityPtr &entity, std::string filesDBName) override
Pure virtual method.
Definition: MotionAttributesEditTab.cpp:82
memoryx::MotionAttributesEditTab::MotionAttributesEditTab
MotionAttributesEditTab(QWidget *parent=0)
Definition: MotionAttributesEditTab.cpp:33
memoryx::EntityWrappers::SimoxObjectWrapper
SimoxObjectWrapper offers a simplified access to the Simox ManipulationObject (i.e visualization,...
Definition: SimoxObjectWrapper.h:46
SimoxObjectWrapper.h
memoryx::EntityWrappers
Definition: AbstractEntityWrapper.cpp:30
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
memoryx::EntityWrappers::ObjectRecognitionWrapper
Definition: ObjectRecognitionWrapper.h:40
memoryx::EntityAttributesEditTab
The entity edit dialog is a superclass for all edit dialogs used to set attributes of entites.
Definition: EntityAttributesEditTab.h:37
memoryx::MotionAttributesEditTab::motionModelChanged
void motionModelChanged(const QString &method)
Definition: MotionAttributesEditTab.cpp:103