ObjectClassEditDialog.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 Alexey Kozlov (kozlov 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 
23 #include "ObjectClassEditDialog.h"
24 
25 #include <SimoxUtility/algorithm/string/string_tools.h>
26 
27 #include <MemoryX/gui-plugins/PriorMemoryEditor/ui_ObjectClassEditDialog.h>
31 
32 using namespace memoryx;
33 using namespace memoryx::EntityWrappers;
34 
36  armarx::RobotStateComponentInterfacePrx robotStateComponent,
37  QWidget* parent) :
38  EntityEditDialog(parent),
39  ui(new Ui::ObjectClassEditDialog),
40  robotStateComponent(robotStateComponent)
41 {
42  // set up general UI
43  ui->setupUi(this);
45 
46  // construct and add attribute tabs
47  recognitionAttributesEditTab = new RecognitionAttributesEditTab();
48  ui->tabWidget->addTab(recognitionAttributesEditTab, "Recognition");
49 
50  manipulationAttributesEditTab = new ManipulationAttributesEditTab(robotStateComponent);
51  ui->tabWidget->addTab(manipulationAttributesEditTab, "Manipulation");
52 
53  motionAttributesEditTab = new MotionAttributesEditTab();
54  ui->tabWidget->addTab(motionAttributesEditTab, "Motion");
55 }
56 
58 {
59  delete ui;
60 }
61 
62 void
64 {
65  ui->editClassName->setReadOnly(!editable);
66 }
67 
68 void
70 {
71  ObjectClassPtr objectClass = ObjectClassPtr::dynamicCast(entity);
72 
73  // fill dialog (with default attributes)
74  ui->editClassName->setText(QString::fromStdString(objectClass->getName()));
75  NameList parents = objectClass->getParentClasses();
76  std::string parentsStr = simox::alg::join(parents, ",");
77  ui->editParentClasses->setText(QString::fromStdString(parentsStr));
78  bool isInstanceable = objectClass->isInstanceable();
79  ui->checkBoxIsInstanceable->setChecked(isInstanceable);
80 
81  // update tabs
82  manipulationAttributesEditTab->updateGui(entity);
83  recognitionAttributesEditTab->updateGui(entity);
84  motionAttributesEditTab->updateGui(entity);
85 }
86 
87 void
88 ObjectClassEditDialog::updateEntity(const EntityPtr& entity, std::string filesDBName)
89 {
90  ObjectClassPtr objectClass = ObjectClassPtr::dynamicCast(entity);
91 
92  // update default attributes
93  objectClass->setName(ui->editClassName->text().toStdString());
94  objectClass->clearParentClasses();
95  std::string parentsStr = ui->editParentClasses->text().toStdString();
96  NameList parents = simox::alg::split(parentsStr, ",");
97 
98  for (NameList::const_iterator it = parents.begin(); it != parents.end(); ++it)
99  {
100  objectClass->addParentClass(*it);
101  }
102 
103  objectClass->setInstanceable(ui->checkBoxIsInstanceable->isChecked());
104 
105  // update from tabs
106  manipulationAttributesEditTab->updateEntity(entity, filesDBName);
107  recognitionAttributesEditTab->updateEntity(entity, filesDBName);
108  motionAttributesEditTab->updateEntity(entity, filesDBName);
109 }
memoryx::ObjectClassEditDialog::~ObjectClassEditDialog
~ObjectClassEditDialog() override
Definition: ObjectClassEditDialog.cpp:57
memoryx::MotionAttributesEditTab
This tab allows to change the motion model attributes of an objectclass entity.
Definition: MotionAttributesEditTab.h:43
memoryx::ObjectClassEditDialog::ObjectClassEditDialog
ObjectClassEditDialog(armarx::RobotStateComponentInterfacePrx robotStateComponent, QWidget *parent=0)
Definition: ObjectClassEditDialog.cpp:35
memoryx::ObjectClassEditDialog
Definition: ObjectClassEditDialog.h:43
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::ManipulationAttributesEditTab::updateGui
void updateGui(const EntityPtr &entity) override
Pure virtual method.
Definition: ManipulationAttributesEditTab.cpp:85
memoryx::RecognitionAttributesEditTab::updateEntity
void updateEntity(const EntityPtr &entity, std::string filesDBName) override
Pure virtual method.
Definition: RecognitionAttributesEditTab.cpp:191
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::ObjectClassEditDialog::updateGui
void updateGui(const EntityPtr &entity) override
Pure virtual method.
Definition: ObjectClassEditDialog.cpp:69
memoryx::EntityEditDialog
The entity edit dialog is a superclass for all edit dialogs used to set attributes of entites.
Definition: EntityEditDialog.h:36
memoryx::ManipulationAttributesEditTab
This tab allows to change the simox attributes of an objectclass entity.
Definition: ManipulationAttributesEditTab.h:41
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
memoryx::ObjectClassEditDialog::setClassNameEditable
void setClassNameEditable(bool editable)
Definition: ObjectClassEditDialog.cpp:63
memoryx::MotionAttributesEditTab::updateEntity
void updateEntity(const EntityPtr &entity, std::string filesDBName) override
Pure virtual method.
Definition: MotionAttributesEditTab.cpp:82
memoryx::ManipulationAttributesEditTab::updateEntity
void updateEntity(const EntityPtr &entity, std::string filesDBName) override
Pure virtual method.
Definition: ManipulationAttributesEditTab.cpp:103
ObjectClassEditDialog.h
SimoxObjectWrapper.h
memoryx::EntityWrappers
Definition: AbstractEntityWrapper.cpp:30
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
memoryx::ObjectClassEditDialog::updateEntity
void updateEntity(const EntityPtr &entity, std::string filesDBName) override
Pure virtual method.
Definition: ObjectClassEditDialog.cpp:88
memoryx::RecognitionAttributesEditTab::updateGui
void updateGui(const EntityPtr &entity) override
Pure virtual method.
Definition: RecognitionAttributesEditTab.cpp:85
memoryx::RecognitionAttributesEditTab
This tab allows to change the recognition attributes of an objectclass entity.
Definition: RecognitionAttributesEditTab.h:41
armarx::split
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
Definition: StringHelpers.cpp:38