Developer Documentation

SkeletonEditingPlugin.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42
43
44 #ifndef SKELETONEDITINGPLUGIN_HH
45 #define SKELETONEDITINGPLUGIN_HH
46
47 #include <QObject>
48 #include <QMenuBar>
49
50 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
51 #include <OpenFlipper/BasePlugin/MouseInterface.hh>
52 #include <OpenFlipper/BasePlugin/KeyInterface.hh>
53 #include <OpenFlipper/BasePlugin/PickingInterface.hh>
54 #include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
55 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
56 #include <OpenFlipper/BasePlugin/ScriptInterface.hh>
57 #include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
58 #include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
59 #include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
60 #include <OpenFlipper/BasePlugin/BackupInterface.hh>
61 #include <OpenFlipper/BasePlugin/RPCInterface.hh>
62 #include <OpenFlipper/common/Types.hh>
63
64 #include <ObjectTypes/Skeleton/Skeleton.hh>
65 #include "SkeletonMarker.hh"
66
67 #include <ACG/QtScenegraph/QtTranslationManipulatorNode.hh>
68
71 class SkeletonEditingPlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, PickingInterface, ToolboxInterface, LoggingInterface, ScriptInterface,ToolbarInterface, ContextMenuInterface, LoadSaveInterface, BackupInterface, RPCInterface
72 {
73 Q_OBJECT
74 Q_INTERFACES(BaseInterface)
75 Q_INTERFACES(MouseInterface)
76 Q_INTERFACES(KeyInterface)
77 Q_INTERFACES(PickingInterface)
78 Q_INTERFACES(ToolboxInterface)
79 Q_INTERFACES(LoggingInterface)
80 Q_INTERFACES(ContextMenuInterface)
81 Q_INTERFACES(ScriptInterface)
82 Q_INTERFACES(ToolbarInterface)
83 Q_INTERFACES(LoadSaveInterface)
84 Q_INTERFACES(BackupInterface)
85 Q_INTERFACES(RPCInterface)
86
87 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-SkeletonEditing")
88
89 signals:
90 // BaseInterface
91 void updateView();
92 void updatedObject(int, const UpdateType& _type);
93 void nodeVisibilityChanged(int);
94
95 void setRenderer(unsigned int _viewer, QString _rendererName);
96 void getCurrentRenderer(unsigned int _viewer, QString& _rendererName);
97
98 // PickingInterface
99 void addPickMode( const std::string& _mode );
100 void addHiddenPickMode( const std::string& _mode );
101 void setPickModeMouseTracking (const std::string& _mode, bool _mouseTracking);
102 void setPickModeToolbar (const std::string& _mode, QToolBar * _toolbar);
103
104 // ContextMenuInterface
105 void addContextMenuItem(QAction* _action , ContextMenuType _type);
106
107 // LoggingInterface
108 void log(Logtype _type, QString _message);
109 void log(QString _message);
110
111 // ScriptInterface
112 void scriptInfo( QString _functionName );
113 void setSlotDescription(QString _slotName, QString _slotDescription,
114 QStringList _parameters, QStringList _descriptions);
115
116 // ToolbarInterface
117 void addToolbar(QToolBar* _toolbar);
118 void getToolBar( QString _name, QToolBar*& _toolbar);
119
120 // KeyInterface
121 void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
122
123 // ToolboxInterface
124 void addToolbox( QString _name , QWidget* _widget );
125
126 // LoadSaveInterface
127 void addEmptyObject(DataType _type, int& _id);
128 void deleteObject( int _id);
129
130 // BackupInterface
131 void createBackup( int _objectid, QString _name, UpdateType _type = UPDATE_ALL );
132
133 private slots :
134
135 // BaseInterface
136 void initializePlugin();
137 void pluginsInitialized();
138 void slotObjectUpdated( int _id, const UpdateType& _type);
139
140 // MouseInterface
141 void slotMouseWheelEvent(QWheelEvent * _event, const std::string & _mode);
142 void slotMouseEvent( QMouseEvent* _event );
143
144 // KeyInterface
145 void slotKeyEvent (QKeyEvent* _event);
146 void slotKeyReleaseEvent (QKeyEvent* _event);
147
148 // PickingInterface
149 void slotPickModeChanged( const std::string& _mode);
150
151 private:
152 void moveJoint(QMouseEvent* _event);
153 bool canModify(QMouseEvent* _event);
154 void insertJoint(QMouseEvent* _event);
155 void cancelJointInsertion();
156 void deleteJoint(QMouseEvent* _event);
157 void selectJoint(QMouseEvent* _event);
158
159 Skeleton::Pose* activePose(SkeletonObject* _skeletonObj);
160 void setJointPosition(SkeletonObject* _skeletonObj, Skeleton::Joint* _joint, ACG::Vec3d& _position);
161
162 OpenMesh::Vec3d getNearestJoint(SkeletonObject* _skeletonObj, OpenMesh::Vec3d &_hitPoint, int& _bestJointID);
163 public:
164
166 SkeletonEditingPlugin();
167
169 ~SkeletonEditingPlugin();
170
172 QString name(){ return (QString("Skeleton Editing")); };
173
175 QString description() { return (QString(tr("Create and edit skeletons"))); };
176
177
178 //===========================================================================
181 //===========================================================================
182
183 public slots:
185 void splitBone( int _objectId, int _tailJoint);
186
188 void addJoint( int _objectId, int _parent, Vector _position );
189
191 void deleteJoint( int _objectId , int _jointId );
192
194 void transformJoint( int _objectId , int _jointId, Matrix4x4 _matrix );
195
197 Matrix4x4 globalMatrix(int _objectId, int _jointId);
198
200 Matrix4x4 localMatrix(int _objectId, int _jointId);
201
203 Vector globalTranslation(int _objectId, int _jointId);
204
206 Vector localTranslation(int _objectId, int _jointId);
207
209 int animationCount(int _objectId);
210
212 int frameCount(int _objectId, int _animationIndex);
213
215 int activeAnimation(int _objectId);
216
218 int activeFrame(int _objectId);
219
221 void setActivePose(int _objectId, int _animationIndex, int _frame);
222
224 void addAnimation(int _objectId, QString _name, int _frames);
225
227 void splitJoint(QMouseEvent* _event);
228
231 public slots:
232 QString version() { return QString("1.0"); };
233
234
235 private slots:
236 void slotSetEditingMode(QAction* _action);
237 void slotPickToolbarAction(QAction* _action);
238
239 void setDescriptions();
240
241 private:
242 QToolBar* toolbar_;
243 QActionGroup* toolBarActions_;
244 QAction* skeletonEditingAction_;
245
246 QToolBar* pickToolbar_;
247 QActionGroup* pickToolBarActions_;
248 QAction* selectJointAction_;
249 QAction* insertJointAction_;
250 QAction* splitJointAction_;
251 QAction* deleteJointAction_;
252 QAction* moveJointAction_;
253 QAction* transformChildManipAction_;
254 QAction* transformAllManipAction_;
255 QAction* rotateManipAction_;
256 QAction* inverseKinematicAction_;
257
258 int currentSkeleton_;
259 int currentJoint_;
260 bool jointPreview_;
261
262 bool transformChildJoints_;
263 bool transformAllFrames_;
264 bool inverseKinematic_;
265
266 bool dblClick_;
267
269 QString lastRenderer_;
271 bool rendererChanged_;
272
273 private:
274 // object ids of all objects with active Manipulator
275 std::vector< int > activeManipulators_;
276 // Size for the manipulators
277 double manip_size_;
278 // Modifier for the Size (changed by Mousewheel Events)
279 double manip_size_modifier_;
280
281 // Object marker to dimm Objects during manipulator transformation
282 SkeletonMarker objectMarker_;
283
284 ACG::Matrix4x4d accumMatrix_;
285
286 private:
288 void placeManip(QMouseEvent* _event);
289
291 void showManipulators();
292
294 void updateManipulatorPosition(BaseObjectData* _skeletonObj);
295
297 void inverseKinematic(ACG::Vec3d dest,Skeleton::Pose* currentPose,Skeleton::Joint* pickedJoint, std::vector<Skeleton::Joint*> rotatableJoints);
298
299 private slots:
301 void manipulatorMoved( QtTranslationManipulatorNode* _node , QMouseEvent* _event);
302
304 void ManipulatorPositionChanged(QtTranslationManipulatorNode* _node );
305
306 void slotRotateManipulator(bool _toggled);
307 };
308
309 #endif //SKELETONEDITINGPLUGIN_HH
SkeletonEditingPlugin::description
QString description()
Description of the Plugin.
Definition: SkeletonEditingPlugin.hh:175
ContextMenuInterface
Interface class for creating custom context menus.
Definition: ContextMenuInterface.hh:85
UpdateType
Update type class.
Definition: UpdateType.hh:60
RPCInterface
Interface to call functions across plugins.
Definition: RPCInterface.hh:61
UPDATE_ALL
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
SkeletonEditingPlugin::addAnimation
void addAnimation(int _objectId, QString _name, int _frames)
add animation
Definition: SkeletonEditingScripting.cc:911
Skeleton.hh
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:92
MouseInterface.hh
SkeletonEditingPlugin::placeManip
void placeManip(QMouseEvent *_event)
Place and show the Manipulator.
Definition: SkeletonEditingPlugin.cc:536
SkeletonEditingPlugin::localMatrix
Matrix4x4 localMatrix(int _objectId, int _jointId)
get local matrix of a joint in the active pose
Definition: SkeletonEditingScripting.cc:622
SkeletonEditingPlugin::lastRenderer_
QString lastRenderer_
Stores the last active renderer before we switched to skeleton editing mode.
Definition: SkeletonEditingPlugin.hh:269
LoadSaveInterface
Interface for all plugins which want to Load or Save files and create Objects.
Definition: LoadSaveInterface.hh:59
SkeletonEditingPlugin::globalMatrix
Matrix4x4 globalMatrix(int _objectId, int _jointId)
get global matrix of a joint in the active pose
Definition: SkeletonEditingScripting.cc:578
ScriptInterface
Interface for all Plugins which provide scriptable Functions.
Definition: ScriptInterface.hh:58
SkeletonEditingPlugin::SkeletonEditingPlugin
SkeletonEditingPlugin()
Default Constructor.
Definition: SkeletonEditingPlugin.cc:58
LoggingInterface.hh
SkeletonMarker
Definition: SkeletonMarker.hh:52
PickingInterface.hh
SkeletonEditingPlugin::frameCount
int frameCount(int _objectId, int _animationIndex)
get the number of frames
Definition: SkeletonEditingScripting.cc:780
SkeletonEditingPlugin::canModify
bool canModify(QMouseEvent *_event)
checks, if the skeleton can be modified. a skeleton can be modified, if the active pose is the refere...
Definition: SkeletonEditingPlugin.cc:290
SkeletonEditingPlugin::addJoint
void addJoint(int _objectId, int _parent, Vector _position)
add joint to the skeleton
Definition: SkeletonEditingScripting.cc:218
SkeletonEditingPlugin::globalTranslation
Vector globalTranslation(int _objectId, int _jointId)
get global translation of a joint in the active pose
Definition: SkeletonEditingScripting.cc:665
PoseT
A general pose, used to store the frames of the animation.
Definition: PoseT.hh:58
MouseInterface
Interface class for receiving mouse events.
Definition: MouseInterface.hh:61
SkeletonEditingPlugin::activeFrame
int activeFrame(int _objectId)
get active frame
Definition: SkeletonEditingScripting.cc:841
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:112
SkeletonEditingPlugin::~SkeletonEditingPlugin
~SkeletonEditingPlugin()
Destructor.
Definition: SkeletonEditingPlugin.cc:94
SkeletonEditingPlugin::pluginsInitialized
void pluginsInitialized()
Initialization of the plugin when it is loaded by the core.
Definition: SkeletonEditingPlugin.cc:107
BaseInterface.hh
PickingInterface
Allow access to picking functions.
Definition: PickingInterface.hh:62
SkeletonEditingPlugin
Definition: SkeletonEditingPlugin.hh:71
SkeletonEditingPlugin::showManipulators
void showManipulators()
Show/Hide active manipulators.
Definition: SkeletonEditingPlugin.cc:862
KeyInterface.hh
SkeletonEditingPlugin::getNearestJoint
OpenMesh::Vec3d getNearestJoint(SkeletonObject *_skeletonObj, OpenMesh::Vec3d &_hitPoint, int &_bestJointID)
Get nearest joint to hitPoint (used for snapping)
Definition: SkeletonEditingPlugin.cc:1414
ContextMenuInterface.hh
ToolboxInterface
Plugins can add its own toolbox to the main widget&#39;s toolbox area by using this interface.
Definition: ToolboxInterface.hh:68
ToolbarInterface.hh
SkeletonEditingPlugin::updateManipulatorPosition
void updateManipulatorPosition(BaseObjectData *_skeletonObj)
make sure the manipulator is positioned on a joint
Definition: SkeletonEditingPlugin.cc:1445
LoadSaveInterface.hh
SkeletonEditingPlugin::setDescriptions
void setDescriptions()
Set Descriptions for Scripting Slots.
Definition: SkeletonEditingScripting.cc:55
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:65
JointT
Represents a single joint in the skeleton.
Definition: JointT.hh:60
SkeletonEditingPlugin::localTranslation
Vector localTranslation(int _objectId, int _jointId)
get local translation of a joint in the active pose
Definition: SkeletonEditingScripting.cc:709
SkeletonEditingPlugin::inverseKinematic
void inverseKinematic(ACG::Vec3d dest, Skeleton::Pose *currentPose, Skeleton::Joint *pickedJoint, std::vector< Skeleton::Joint *> rotatableJoints)
function for computing the position of our joints using inverse Kinematic
Definition: SkeletonEditingPlugin.cc:632
ToolboxInterface.hh
ACG::SceneGraph::QtTranslationManipulatorNode
Definition: QtTranslationManipulatorNode.hh:81
ACG::Matrix4x4T< double >
ToolbarInterface
Add a toolbox to OpenFlipper.
Definition: ToolbarInterface.hh:62
SkeletonEditingPlugin::name
QString name()
Name of the Plugin.
Definition: SkeletonEditingPlugin.hh:172
SkeletonEditingPlugin::transformJoint
void transformJoint(int _objectId, int _jointId, Matrix4x4 _matrix)
transform joint with given matrix
Definition: SkeletonEditingScripting.cc:300
BackupInterface.hh
Types.hh
KeyInterface
Keyboard Event Interface.
Definition: KeyInterface.hh:59
SkeletonEditingPlugin::splitJoint
void splitJoint(QMouseEvent *_event)
split selected Joint
Definition: SkeletonEditingPlugin.cc:986
SkeletonEditingPlugin::splitBone
void splitBone(int _objectId, int _tailJoint)
insert a joint in the middle of a bone given by its (unique) tailJoint
Definition: SkeletonEditingScripting.cc:146
DataType
Predefined datatypes.
Definition: DataTypes.hh:83
SkeletonEditingPlugin::slotMouseEvent
void slotMouseEvent(QMouseEvent *_event)
MousePress event occured.
Definition: SkeletonEditingPlugin.cc:338
OpenMesh::VectorT
Definition: Vector11T.hh:83
SkeletonEditingPlugin::manipulatorMoved
void manipulatorMoved(QtTranslationManipulatorNode *_node, QMouseEvent *_event)
move the object when its manipulator moves
Definition: SkeletonEditingPlugin.cc:713
SkeletonObject
Definition: SkeletonObject.hh:72
BaseObjectData
Definition: BaseObjectData.hh:102
SkeletonEditingPlugin::slotPickModeChanged
void slotPickModeChanged(const std::string &_mode)
slot is called when the pickMode changed
Definition: SkeletonEditingPlugin.cc:388
BackupInterface
Interface class for backup handling.
Definition: BackupInterface.hh:59
RPCInterface.hh
SkeletonEditingPlugin::setActivePose
void setActivePose(int _objectId, int _animationIndex, int _frame)
set active pose
Definition: SkeletonEditingScripting.cc:867
SkeletonEditingPlugin::rendererChanged_
bool rendererChanged_
Remembers, if we changed the renderer.
Definition: SkeletonEditingPlugin.hh:271
SkeletonEditingPlugin::animationCount
int animationCount(int _objectId)
get the number of animations
Definition: SkeletonEditingScripting.cc:753
ContextMenuType
ContextMenuType
Definition: ContextMenuInterface.hh:56
SkeletonEditingPlugin::ManipulatorPositionChanged
void ManipulatorPositionChanged(QtTranslationManipulatorNode *_node)
update object when its manipulator changes position
Definition: SkeletonEditingPlugin.cc:842
ScriptInterface.hh
SkeletonEditingPlugin::activeAnimation
int activeAnimation(int _objectId)
get active animation
Definition: SkeletonEditingScripting.cc:814