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 
32 #include "ObjectInspectorWidget.h"
33 #include "PropertyBrowserWidget.h"
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 
75 {
76  //
77 }
78 
79 void
80 gui::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 
99 gui::ObjectInspectorWidget::getObjectClass(const std::string& objectClass,
100  const std::string& collection)
101 {
102 
104  {
105  return controller->getMemoryXController()->getPriorKnowlegdeController()->getObjectClassPtr(
106  objectClass, collection);
107  }
108 
109  return NULL;
110 }
111 
112 void
113 gui::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 
125 void
126 gui::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 
143 void
144 gui::ObjectInspectorWidget::showPreviewImage(const memoryx::ObjectClassPtr& objectClass)
145 {
147  {
148  viewer->setObjectToDisplay(
149  controller->getMemoryXController()->getPriorKnowlegdeController()->getCoinVisualisation(
150  objectClass, false));
151  }
152 }
153 
154 void
156 {
157  // stays empty for now
158 }
ObjectInspectorWidget.h
gui::PropertyBrowserWidget
This class provides a property browser which displays all properties of a scene object or prior knowl...
Definition: PropertyBrowserWidget.h:45
IceInternal::Handle< ObjectClass >
controller::vector_string
std::vector< std::string > vector_string
Definition: Controller.h:47
controller
Definition: AddOperation.h:39
controller::ControllerPtr
std::shared_ptr< Controller > ControllerPtr
Definition: ClassDefinitions.h:41
PropertyBrowserWidget.h
scene3D::ObjectPreviewViewer
Definition: ObjectPreviewViewer.h:36
gui::ObjectInspectorWidget::ObjectInspectorWidget
ObjectInspectorWidget(const controller::ControllerPtr &control, QWidget *parent=0)
Constructor.
Definition: ObjectInspectorWidget.cpp:35
gui::ObjectInspectorWidget::~ObjectInspectorWidget
~ObjectInspectorWidget() override
Destructor.
Definition: ObjectInspectorWidget.cpp:74
gui::ObjectInspectorWidget::retranslate
void retranslate()
Translates all translatable strings in this dialog.
Definition: ObjectInspectorWidget.cpp:155
scene3D::SceneObjectPtr
boost::intrusive_ptr< SceneObject > SceneObjectPtr
Definition: PointerDefinitions.h:40
control
This file is part of ArmarX.