SceneObject.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#include <map>
27#include <string>
28
29#include <Inventor/SbRotation.h>
30#include <Inventor/manips/SoTransformManip.h>
31#include <Inventor/nodekits/SoBaseKit.h>
32#include <Inventor/nodes/SoSeparator.h>
33#include <Inventor/nodes/SoSwitch.h>
34#include <Inventor/nodes/SoTransform.h>
35
36namespace scene3D
37{
38 class SceneGroup;
39}
40
41namespace scene3D
42{
43 class SceneObject : public SoBaseKit
44 {
45
47
48 SO_KIT_HEADER(SceneObject);
49
50 SO_KIT_CATALOG_ENTRY_HEADER(root);
51 SO_KIT_CATALOG_ENTRY_HEADER(transform);
52 SO_KIT_CATALOG_ENTRY_HEADER(transformManip);
53 SO_KIT_CATALOG_ENTRY_HEADER(modelswitch);
54 SO_KIT_CATALOG_ENTRY_HEADER(visual);
55 SO_KIT_CATALOG_ENTRY_HEADER(collision);
56
57 public:
58 /**
59 * @brief
60 *
61 * @param objectId
62 * @param classId
63 * @param collection
64 * @param geometry
65 * @param collision
66 */
67 SceneObject(std::string objectId,
68 std::string classId,
69 std::string collection,
70 SoSeparator* geometry,
71 SoSeparator* collision);
72
73 /**
74 * Returns the Translation of the SceneObject.
75 *
76 * @return SbVec3f Translation of SceneObject
77 */
78 SbVec3f getTranslation();
79
80 /**
81 * Sets the Translation of the SceneObject.
82 *
83 * @param translation Translation of SceneObject
84 */
85 void setTranslation(SbVec3f translation);
86
87 /**
88 * Returns the Rotation of the SceneObject.
89 *
90 * @return SbRotation Rotation of SceneObject
91 */
92 SbRotation getRotation();
93
94 /**
95 * Sets the Rotation of the SceneObject.
96 *
97 * @param rotation Rotation of SceneObject
98 */
99 void setRotation(SbRotation rotation);
100
101 /**
102 * Decides, whether CollisionMesh is beeing shown.
103 *
104 * @param show Show Collision Mesh
105 */
106 void showCollisionMesh(bool show);
107
108 /**
109 * Initializes Class.
110 *
111 */
112 static void initClass();
113
114 /**
115 * Returns the ObjectId of the SceneObject.
116 *
117 * @return std::string ObjectId of the SceneObject
118 */
119 std::string getObjectId() const;
120 /**
121 * Sets the ObjectId of the SceneObject.
122 *
123 * @param objectId ObjectId of the SceneObject
124 */
125 void setObjectId(std::string& objectId);
126 /**
127 * Returns the ClassId of the SceneObject.
128 *
129 * @return std::string ClassId of the SceneObject
130 */
131 std::string getClassId() const;
132 /**
133 * Sets the ClassId of the SceneObject.
134 *
135 * @param classId ClassId of the SceneObject
136 */
137 void setClassId(std::string& classId);
138 /**
139 * Returns the Collection of the SceneObject.
140 *
141 * @return std::string Collection of the SceneObject
142 */
143 std::string getCollection() const;
144 /**
145 * Sets the Collection of the SceneObject.
146 *
147 * @param collection Collection of the SceneObject
148 */
149 void setCollection(std::string& collection);
150
151 /**
152 * Returns all Attributes of the SceneObject as Map.
153 *
154 * @return std::map<std::string, std::string> All Attributes as Map
155 */
156 std::map<std::string, std::string> getAllAttributes();
157
158 /**
159 * Returns if you are allowed to change this object.
160 *
161 * @return true, if you are allowed; false otherwise
162 */
163 bool isMutable();
164
165 private:
166 static bool isInitialized;
167 std::string classId;
168 std::string collection;
169 std::string objectId;
170
171 SceneObject();
172
173 void addManipulator(SoTransformManip* manip);
174
175 void applyManipulator();
176
177 bool hasManipulator();
178
179 void trackThisTransformation(SoTransform* transformation);
180 void untrackTransformations();
181
182 SbVec3f lastTranslation;
183 SbRotation lastRotation;
184 void pushHistory();
185
186 SbRotation getHistoryRotation();
187 SbVec3f getHistoryTranslation();
188
189 SoTransformManip* manipNode;
190 SoTransform* transformNode;
191 SoSwitch* switchNode;
192
193 bool isManipulated;
194 };
195} // namespace scene3D
void setTranslation(SbVec3f translation)
Sets the Translation of the SceneObject.
std::string getObjectId() const
Returns the ObjectId of the SceneObject.
SbVec3f getTranslation()
Returns the Translation of the SceneObject.
std::string getClassId() const
Returns the ClassId of the SceneObject.
std::string getCollection() const
Returns the Collection of the SceneObject.
SceneObject(std::string objectId, std::string classId, std::string collection, SoSeparator *geometry, SoSeparator *collision)
std::map< std::string, std::string > getAllAttributes()
Returns all Attributes of the SceneObject as Map.
void showCollisionMesh(bool show)
Decides, whether CollisionMesh is beeing shown.
void setObjectId(std::string &objectId)
Sets the ObjectId of the SceneObject.
void setRotation(SbRotation rotation)
Sets the Rotation of the SceneObject.
bool isMutable()
Returns if you are allowed to change this object.
void setClassId(std::string &classId)
Sets the ClassId of the SceneObject.
static void initClass()
Initializes Class.
SbRotation getRotation()
Returns the Rotation of the SceneObject.
friend class SceneManipulatorManager
Definition SceneObject.h:46
void setCollection(std::string &collection)
Sets the Collection of the SceneObject.