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