ObjectInspectorWidget.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package MemoryX::gui-plugins::SceneEditor
19 * @date 2015
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
24/* Coin headers */
25#include <Inventor/engines/SoElapsedTime.h>
26#include <Inventor/nodes/SoPerspectiveCamera.h>
27#include <Inventor/nodes/SoRotationXYZ.h>
28
29/* Qt headers */
30#include <QVBoxLayout>
31
34
36 QWidget* parent) :
37 QWidget(parent),
39 propertyBrowser(new gui::PropertyBrowserWidget(control, this)),
40 currentObjectId()
41{
42 QVBoxLayout* layout = new QVBoxLayout(this);
43 QWidget* visualModelWidget = new QWidget(this);
44 visualModelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
45 visualModelWidget->setMinimumHeight(180);
46
47 // Empty SoQtExaminerViewer for preview image
48 viewer.reset(new scene3D::ObjectPreviewViewer(control, visualModelWidget));
49 viewer->showNoObject();
50
51 layout->addWidget(propertyBrowser);
52 layout->addWidget(visualModelWidget);
53
54 setMinimumWidth(200);
55
56 connect(control.get(),
57 SIGNAL(objectClassSelected(const std::string&, const std::string&)),
58 this,
59 SLOT(setClassAttributes(const std::string&, const std::string&)));
60 connect(control.get(),
61 SIGNAL(sceneObjectSelected(scene3D::SceneObjectPtr)),
62 this,
63 SLOT(setAllAttributes(scene3D::SceneObjectPtr)));
64 connect(control.get(),
65 SIGNAL(operationExecuted(controller::vector_string)),
66 this,
67 SLOT(sceneObjectsUpdated(controller::vector_string)));
68 connect(control.get(),
69 SIGNAL(objectsChanged(controller::vector_string)),
70 this,
71 SLOT(sceneObjectsUpdated(controller::vector_string)));
72}
73
78
79void
80gui::ObjectInspectorWidget::sceneObjectsUpdated(controller::vector_string objectIds)
81{
82
83 if (!currentObjectId.empty())
84 {
85 for (auto iterator = objectIds.begin(); iterator != objectIds.end(); ++iterator)
86 {
87 if (currentObjectId == *iterator)
88 {
90 {
91 propertyBrowser->updateSceneObject(currentObjectId);
92 }
93 }
94 }
95 }
96}
97
99gui::ObjectInspectorWidget::getObjectClass(const std::string& objectClass,
100 const std::string& collection)
101{
102
103 if (controller::ControllerPtr controller = control.lock())
104 {
105 return controller->getMemoryXController()->getPriorKnowlegdeController()->getObjectClassPtr(
106 objectClass, collection);
107 }
108
109 return NULL;
110}
111
112void
113gui::ObjectInspectorWidget::setClassAttributes(const std::string& objectClass,
114 const std::string& collection)
115{
116
117 currentObjectId.clear();
118 memoryx::ObjectClassPtr objectClassPtr = getObjectClass(objectClass, collection);
119
120 propertyBrowser->setProperties(objectClassPtr, collection);
121
122 showPreviewImage(objectClassPtr);
123}
124
125void
126gui::ObjectInspectorWidget::setAllAttributes(scene3D::SceneObjectPtr sceneObject)
127{
128 propertyBrowser->setProperties(sceneObject);
129
130 // SceneObject should not be null
131 if (sceneObject)
132 {
133 currentObjectId = sceneObject->getObjectId();
134 showPreviewImage(getObjectClass(sceneObject->getClassId(), sceneObject->getCollection()));
135 }
136 else
137 {
138 currentObjectId.clear();
139 viewer->showNoObject();
140 }
141}
142
143void
144gui::ObjectInspectorWidget::showPreviewImage(const memoryx::ObjectClassPtr& objectClass)
145{
146 if (controller::ControllerPtr controller = control.lock())
147 {
148 viewer->setObjectToDisplay(
149 controller->getMemoryXController()->getPriorKnowlegdeController()->getCoinVisualisation(
150 objectClass, false));
151 }
152}
153
154void
156{
157 // stays empty for now
158}
~ObjectInspectorWidget() override
Destructor.
ObjectInspectorWidget(const controller::ControllerPtr &control, QWidget *parent=0)
Constructor.
void retranslate()
Translates all translatable strings in this dialog.
This class provides a property browser which displays all properties of a scene object or prior knowl...
This file is part of ArmarX.
std::vector< std::string > vector_string
Definition Controller.h:47
std::shared_ptr< Controller > ControllerPtr
IceInternal::Handle< ObjectClass > ObjectClassPtr
Definition ObjectClass.h:35
boost::intrusive_ptr< SceneObject > SceneObjectPtr