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/QtDoublePropertyManager>
28 #include <ArmarXGui/libraries/qtpropertybrowser/src/QtDoubleSpinBoxFactory>
29 #include <ArmarXGui/libraries/qtpropertybrowser/src/QtGroupPropertyManager>
30 #include <ArmarXGui/libraries/qtpropertybrowser/src/QtStringPropertyManager>
31 #include <ArmarXGui/libraries/qtpropertybrowser/src/QtTreePropertyBrowser>
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  * Constructor.
51  * Creates an instance of the property browser widget.
52  *
53  * @param control shared pointer to the controller::Controller
54  *
55  */
57  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:
89  QPointer<QtDoubleSpinBoxFactory> spinBoxFactory;
90  QPointer<QtDoublePropertyManager> doubleManager;
91  QPointer<QtGroupPropertyManager> groupManager;
92  QPointer<QtStringPropertyManager> stringManager;
93 
94  QMap<QtProperty*, QString> propertyToId;
95  QMap<QString, QtProperty*> idToProperty;
96  QMap<QtProperty*, double> propertyToValue;
97  scene3D::SceneObjectPtr currentSceneObject;
98 
99  void setInstanceAttributes();
100 
101  void setClassAttributes(const memoryx::ObjectClassPtr& objectClass,
102  const std::string& collection,
103  bool expanded);
104 
105  void clearAll();
106 
107  inline void insertInMap(QtProperty* property, QString id);
108 
109  SbRotation createNewRotation(QtProperty* property, double val);
110 
111  SbVec3f createNewTranslation(QtProperty* property, double val);
112 
113  std::string getMatrix();
114  };
115 } // namespace gui
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:313
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:59
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:41
scene3D::SceneObjectPtr
boost::intrusive_ptr< SceneObject > SceneObjectPtr
Definition: PointerDefinitions.h:40
control
This file is part of ArmarX.