PropertyBrowserWidget.h
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 #pragma once
25 
26 /* QtPropertyBrowser headers */
27 #include <ArmarXGui/libraries/qtpropertybrowser/src/QtTreePropertyBrowser>
28 #include <ArmarXGui/libraries/qtpropertybrowser/src/QtDoubleSpinBoxFactory>
29 #include <ArmarXGui/libraries/qtpropertybrowser/src/QtDoublePropertyManager>
30 #include <ArmarXGui/libraries/qtpropertybrowser/src/QtGroupPropertyManager>
31 #include <ArmarXGui/libraries/qtpropertybrowser/src/QtStringPropertyManager>
32 
33 #include "../controller/Controller.h"
34 
35 namespace gui
36 {
37 
38  /**
39  * This class provides a property browser which displays all properties of a scene object or prior knowledge object class.
40  * The property browser is derived from the QtTreePropertyBrowser which is part of the QtPropertyBrowser library.
41  *
42  * @see QtPropertyBrowser::QtTreePropertyBrowser
43  *
44  */
46  {
47  Q_OBJECT
48  public:
49 
50  /**
51  * Constructor.
52  * Creates an instance of the property browser widget.
53  *
54  * @param control shared pointer to the controller::Controller
55  *
56  */
57  explicit PropertyBrowserWidget(const controller::ControllerPtr& control, QWidget* parent = 0);
58 
59  /**
60  * Fill property browser with class attributes of the given objectclass.
61  *
62  * @param objectClass shared pointer to a ObjectClass
63  * @param collection name of the collection to which the object class belongs
64  *
65  */
66  void setProperties(const memoryx::ObjectClassPtr& objectClass, std::string collection);
67 
68  /**
69  * Fill property browser with instance and class attributes of the given scene object.
70  *
71  * @param sceneObject pointer to a scene3D::SceneObject
72  *
73  */
74  void setProperties(scene3D::SceneObjectPtr sceneObject);
75 
76  /**
77  * Updates the instance properties of the selected object in the scene given by its ID.
78  *
79  * @param objectID string representing the object instance ID
80  *
81  */
82  void updateSceneObject(std::string objectID);
83 
84  private slots:
85  void valueChanged(QtProperty* property, double newValue);
86 
87  private:
88 
90  QPointer<QtDoubleSpinBoxFactory> spinBoxFactory;
91  QPointer<QtDoublePropertyManager> doubleManager;
92  QPointer<QtGroupPropertyManager> groupManager;
93  QPointer<QtStringPropertyManager> stringManager;
94 
95  QMap<QtProperty*, QString> propertyToId;
96  QMap<QString, QtProperty*> idToProperty;
97  QMap<QtProperty*, double> propertyToValue;
98  scene3D::SceneObjectPtr currentSceneObject;
99 
100  void setInstanceAttributes();
101 
102  void setClassAttributes(const memoryx::ObjectClassPtr& objectClass, const std::string& collection, bool expanded);
103 
104  void clearAll();
105 
106  inline void insertInMap(QtProperty* property, QString id);
107 
108  SbRotation createNewRotation(QtProperty* property, double val);
109 
110  SbVec3f createNewTranslation(QtProperty* property, double val);
111 
112  std::string getMatrix();
113 
114  };
115 }
116 
QtTreePropertyBrowser::expanded
void expanded(QtBrowserItem *item)
QtTreePropertyBrowser
The QtTreePropertyBrowser class provides QTreeWidget based property browser.
Definition: qttreepropertybrowser.h:51
gui::PropertyBrowserWidget
This class provides a property browser which displays all properties of a scene object or prior knowl...
Definition: PropertyBrowserWidget.h:45
QtProperty
The QtProperty class encapsulates an instance of a property.
Definition: qtpropertybrowser.h:71
gui::PropertyBrowserWidget::updateSceneObject
void updateSceneObject(std::string objectID)
Updates the instance properties of the selected object in the scene given by its ID.
Definition: PropertyBrowserWidget.cpp:286
controller::ControllerWeakPtr
std::weak_ptr< Controller > ControllerWeakPtr
Definition: ClassDefinitions.h:42
IceInternal::Handle< ObjectClass >
gui::PropertyBrowserWidget::setProperties
void setProperties(const memoryx::ObjectClassPtr &objectClass, std::string collection)
Fill property browser with class attributes of the given objectclass.
Definition: PropertyBrowserWidget.cpp:54
controller::ControllerPtr
std::shared_ptr< Controller > ControllerPtr
Definition: ClassDefinitions.h:41
gui::PropertyBrowserWidget::PropertyBrowserWidget
PropertyBrowserWidget(const controller::ControllerPtr &control, QWidget *parent=0)
Constructor.
Definition: PropertyBrowserWidget.cpp:40
scene3D::SceneObjectPtr
boost::intrusive_ptr< SceneObject > SceneObjectPtr
Definition: PointerDefinitions.h:40
control
This file is part of ArmarX.