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/nodes/SoRotationXYZ.h>
26 #include <Inventor/engines/SoElapsedTime.h>
27 #include <Inventor/nodes/SoPerspectiveCamera.h>
28 
29 /* Qt headers */
30 #include <QVBoxLayout>
31 
32 #include "PropertyBrowserWidget.h"
33 #include "ObjectInspectorWidget.h"
34 
36  QWidget(parent),
38  propertyBrowser(new gui::PropertyBrowserWidget(control, this)),
39  currentObjectId()
40 {
41  QVBoxLayout* layout = new QVBoxLayout(this);
42  QWidget* visualModelWidget = new QWidget(this);
43  visualModelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
44  visualModelWidget->setMinimumHeight(180);
45 
46  // Empty SoQtExaminerViewer for preview image
47  viewer.reset(new scene3D::ObjectPreviewViewer(control, visualModelWidget));
48  viewer->showNoObject();
49 
50  layout->addWidget(propertyBrowser);
51  layout->addWidget(visualModelWidget);
52 
53  setMinimumWidth(200);
54 
55  connect(control.get(), SIGNAL(objectClassSelected(const std::string&, const std::string&)), this, SLOT(setClassAttributes(const std::string&, const std::string&)));
56  connect(control.get(), SIGNAL(sceneObjectSelected(scene3D::SceneObjectPtr)), this, SLOT(setAllAttributes(scene3D::SceneObjectPtr)));
57  connect(control.get(), SIGNAL(operationExecuted(controller::vector_string)), this, SLOT(sceneObjectsUpdated(controller::vector_string)));
58  connect(control.get(), SIGNAL(objectsChanged(controller::vector_string)), this, SLOT(sceneObjectsUpdated(controller::vector_string)));
59 }
60 
62 {
63  //
64 }
65 
66 void gui::ObjectInspectorWidget::sceneObjectsUpdated(controller::vector_string objectIds)
67 {
68 
69  if (!currentObjectId.empty())
70  {
71  for (auto iterator = objectIds.begin(); iterator != objectIds.end(); ++iterator)
72  {
73  if (currentObjectId == *iterator)
74  {
76  {
77  propertyBrowser->updateSceneObject(currentObjectId);
78  }
79  }
80  }
81  }
82 
83 }
84 
85 memoryx::ObjectClassPtr gui::ObjectInspectorWidget::getObjectClass(const std::string& objectClass, const std::string& collection)
86 {
87 
89  {
90  return controller->getMemoryXController()->getPriorKnowlegdeController()->getObjectClassPtr(objectClass, collection);
91  }
92 
93  return NULL;
94 
95 }
96 
97 void gui::ObjectInspectorWidget::setClassAttributes(const std::string& objectClass, const std::string& collection)
98 {
99 
100  currentObjectId.clear();
101  memoryx::ObjectClassPtr objectClassPtr = getObjectClass(objectClass, collection);
102 
103  propertyBrowser->setProperties(objectClassPtr, collection);
104 
105  showPreviewImage(objectClassPtr);
106 
107 }
108 
109 void gui::ObjectInspectorWidget::setAllAttributes(scene3D::SceneObjectPtr sceneObject)
110 {
111  propertyBrowser->setProperties(sceneObject);
112 
113  // SceneObject should not be null
114  if (sceneObject)
115  {
116  currentObjectId = sceneObject->getObjectId();
117  showPreviewImage(getObjectClass(sceneObject->getClassId(), sceneObject->getCollection()));
118  }
119  else
120  {
121  currentObjectId.clear();
122  viewer->showNoObject();
123  }
124 }
125 
126 void gui::ObjectInspectorWidget::showPreviewImage(const memoryx::ObjectClassPtr& objectClass)
127 {
129  {
130  viewer->setObjectToDisplay(controller->getMemoryXController()->getPriorKnowlegdeController()->getCoinVisualisation(objectClass, false));
131  }
132 }
133 
135 {
136  // stays empty for now
137 }
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:61
gui::ObjectInspectorWidget::retranslate
void retranslate()
Translates all translatable strings in this dialog.
Definition: ObjectInspectorWidget.cpp:134
scene3D::SceneObjectPtr
boost::intrusive_ptr< SceneObject > SceneObjectPtr
Definition: PointerDefinitions.h:40
control
This file is part of ArmarX.