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 #include <MemoryX/gui-plugins/PriorMemoryEditor/ui_MotionAttributesEditTab.h>
25 
29 
30 using namespace memoryx;
31 using namespace memoryx::EntityWrappers;
32 
34  : EntityAttributesEditTab(parent),
36 {
37  ui->setupUi(this);
38 
39  // init feature file dialog
40  connect(ui->comboBoxMotionModel, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(motionModelChanged(const QString&)));
41  connect(ui->comboBoxSimulationType, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(simulationTypeChanged(const QString&)));
42 
45 }
46 
48 {
49  delete ui;
50 }
51 
53 {
54  ObjectClassPtr objectClass = ObjectClassPtr::dynamicCast(entity);
55 
56  ObjectRecognitionWrapperPtr objectRecognitionWrapper = objectClass->getWrapper<ObjectRecognitionWrapper>();
57  int index = ui->comboBoxMotionModel->findText(QString(objectRecognitionWrapper->getDefaultMotionModel().c_str()));
58  if (index != -1)
59  {
60  ui->comboBoxMotionModel->setCurrentIndex(index);
61  }
62 
63  SimoxObjectWrapperPtr simoxWrapper = objectClass->getWrapper<SimoxObjectWrapper>();
64  VirtualRobot::SceneObject::Physics::SimulationType simType = simoxWrapper->getManipulationObject()->getSimulationType();
65  index = ui->comboBoxSimulationType->findText(simTypeToString(simType));
66  if (index != -1)
67  {
68  ui->comboBoxSimulationType->setCurrentIndex(index);
69  }
70 }
71 
72 
73 void MotionAttributesEditTab::updateEntity(const EntityPtr& entity, std::string filesDBName)
74 {
75  ObjectClassPtr objectClass = ObjectClassPtr::dynamicCast(entity);
76 
77  ObjectRecognitionWrapperPtr objectRecognitionWrapper = objectClass->getWrapper<ObjectRecognitionWrapper>();
78  std::string motionModelName = ui->comboBoxMotionModel->currentText().toStdString();
79  ARMARX_INFO << "Setting motion model: " << motionModelName;
80  objectRecognitionWrapper->setDefaultMotionModel(motionModelName);
81 
82  SimoxObjectWrapperPtr simoxWrapper = objectClass->getWrapper<SimoxObjectWrapper>();
83  VirtualRobot::ManipulationObjectPtr mo = simoxWrapper->getManipulationObject();
84  QString simulationTypeName = ui->comboBoxSimulationType->currentText();
85 
86  ARMARX_INFO << simoxWrapper->getManipulationObjectFileName();
87  ARMARX_INFO << "Setting simulation type: " << simulationTypeName.toStdString();
88  mo->setSimulationType(stringToSimType(simulationTypeName));
89  simoxWrapper->setAndStoreManipulationObject(mo, filesDBName);
90 }
91 
93 {
94 }
95 
97 {
98 }
99 
100 QString MotionAttributesEditTab::simTypeToString(VirtualRobot::SceneObject::Physics::SimulationType simType)
101 {
102  switch (simType)
103  {
104  case VirtualRobot::SceneObject::Physics::eStatic:
105  return "Static";
106  case VirtualRobot::SceneObject::Physics::eKinematic:
107  return "Kinematic";
108  case VirtualRobot::SceneObject::Physics::eDynamic:
109  return "Dynamic";
110  default:
111  return "Unknown";
112  }
113 }
114 
115 VirtualRobot::SceneObject::Physics::SimulationType MotionAttributesEditTab::stringToSimType(const QString& string)
116 {
117  if (string == "Static")
118  {
119  return VirtualRobot::SceneObject::Physics::eStatic;
120  }
121  else if (string == "Kinematic")
122  {
123  return VirtualRobot::SceneObject::Physics::eKinematic;
124  }
125  else if (string == "Dynamic")
126  {
127  return VirtualRobot::SceneObject::Physics::eDynamic;
128  }
129  else
130  {
131  return VirtualRobot::SceneObject::Physics::eUnknown;
132  }
133 }
memoryx::MotionAttributesEditTab
This tab allows to change the motion model attributes of an objectclass entity.
Definition: MotionAttributesEditTab.h:42
index
uint8_t index
Definition: EtherCATFrame.h:59
memoryx::MotionAttributesEditTab::updateGui
void updateGui(const EntityPtr &entity) override
Pure virtual method.
Definition: MotionAttributesEditTab.cpp:52
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
ObjectRecognitionWrapper.h
ObjectClass.h
memoryx::MotionAttributesEditTab::~MotionAttributesEditTab
~MotionAttributesEditTab() override
Definition: MotionAttributesEditTab.cpp:47
memoryx::MotionAttributesEditTab::simulationTypeChanged
void simulationTypeChanged(const QString &method)
Definition: MotionAttributesEditTab.cpp:96
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:73
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:28
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
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:36
memoryx::MotionAttributesEditTab::motionModelChanged
void motionModelChanged(const QString &method)
Definition: MotionAttributesEditTab.cpp:92