Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50 #ifndef SKELETONEDITINGPLUGIN_HH
51 #define SKELETONEDITINGPLUGIN_HH
52
53 #include <QObject>
54 #include <QMenuBar>
55
56 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
57 #include <OpenFlipper/BasePlugin/MouseInterface.hh>
58 #include <OpenFlipper/BasePlugin/KeyInterface.hh>
59 #include <OpenFlipper/BasePlugin/PickingInterface.hh>
60 #include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
61 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
62 #include <OpenFlipper/BasePlugin/ScriptInterface.hh>
63 #include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
64 #include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
65 #include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
66 #include <OpenFlipper/BasePlugin/BackupInterface.hh>
67 #include <OpenFlipper/BasePlugin/RPCInterface.hh>
68 #include <OpenFlipper/common/Types.hh>
69
70 #include <ObjectTypes/Skeleton/Skeleton.hh>
71 #include "SkeletonMarker.hh"
72
75 class SkeletonEditingPlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, PickingInterface, ToolboxInterface, LoggingInterface, ScriptInterface,ToolbarInterface, ContextMenuInterface, LoadSaveInterface, BackupInterface, RPCInterface
76 {
77 Q_OBJECT
78 Q_INTERFACES(BaseInterface)
79 Q_INTERFACES(MouseInterface)
80 Q_INTERFACES(KeyInterface)
81 Q_INTERFACES(PickingInterface)
82 Q_INTERFACES(ToolboxInterface)
83 Q_INTERFACES(LoggingInterface)
84 Q_INTERFACES(ContextMenuInterface)
85 Q_INTERFACES(ScriptInterface)
86 Q_INTERFACES(ToolbarInterface)
87 Q_INTERFACES(LoadSaveInterface)
88 Q_INTERFACES(BackupInterface)
89 Q_INTERFACES(RPCInterface)
90
91 #if QT_VERSION >= 0x050000
92 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-SkeletonEditing")
93 #endif
94
95 signals:
96 // BaseInterface
97 void updateView();
98 void updatedObject(int, const UpdateType& _type);
99 void nodeVisibilityChanged(int);
100
101 void setRenderer(unsigned int _viewer, QString _rendererName);
102 void getCurrentRenderer(unsigned int _viewer, QString& _rendererName);
103
104 // PickingInterface
105 void addPickMode( const std::string& _mode );
106 void addHiddenPickMode( const std::string& _mode );
107 void setPickModeMouseTracking (const std::string& _mode, bool _mouseTracking);
108 void setPickModeToolbar (const std::string& _mode, QToolBar * _toolbar);
109
110 // ContextMenuInterface
111 void addContextMenuItem(QAction* _action , ContextMenuType _type);
112
113 // LoggingInterface
114 void log(Logtype _type, QString _message);
115 void log(QString _message);
116
117 // ScriptInterface
118 void scriptInfo( QString _functionName );
119 void setSlotDescription(QString _slotName, QString _slotDescription,
120 QStringList _parameters, QStringList _descriptions);
121
122 // ToolbarInterface
123 void addToolbar(QToolBar* _toolbar);
124 void getToolBar( QString _name, QToolBar*& _toolbar);
125
126 // KeyInterface
127 void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
128
129 // ToolboxInterface
130 void addToolbox( QString _name , QWidget* _widget );
131
132 // LoadSaveInterface
133 void addEmptyObject(DataType _type, int& _id);
134 void deleteObject( int _id);
135
136 // BackupInterface
137 void createBackup( int _objectid, QString _name, UpdateType _type = UPDATE_ALL );
138
139 private slots :
140
141 // BaseInterface
142 void initializePlugin();
143 void pluginsInitialized();
144 void slotObjectUpdated( int _id, const UpdateType& _type);
145
146 // MouseInterface
147 void slotMouseWheelEvent(QWheelEvent * _event, const std::string & _mode);
148 void slotMouseEvent( QMouseEvent* _event );
149
150 // KeyInterface
151 void slotKeyEvent (QKeyEvent* _event);
152 void slotKeyReleaseEvent (QKeyEvent* _event);
153
154 // PickingInterface
155 void slotPickModeChanged( const std::string& _mode);
156
157 private:
158 void moveJoint(QMouseEvent* _event);
159 bool canModify(QMouseEvent* _event);
160 void insertJoint(QMouseEvent* _event);
161 void cancelJointInsertion();
162 void deleteJoint(QMouseEvent* _event);
163 void selectJoint(QMouseEvent* _event);
164
165 Skeleton::Pose* activePose(SkeletonObject* _skeletonObj);
166 void setJointPosition(SkeletonObject* _skeletonObj, Skeleton::Joint* _joint, ACG::Vec3d& _position);
167
168 OpenMesh::Vec3d getNearestJoint(SkeletonObject* _skeletonObj, OpenMesh::Vec3d &_hitPoint, int& _bestJointID);
169 public:
170
172 SkeletonEditingPlugin();
173
175 ~SkeletonEditingPlugin();
176
178 QString name(){ return (QString("Skeleton Editing")); };
179
181 QString description() { return (QString(tr("Create and edit skeletons"))); };
182
183
184 //===========================================================================
187 //===========================================================================
188
189 public slots:
191 void splitBone( int _objectId, int _tailJoint);
192
194 void addJoint( int _objectId, int _parent, Vector _position );
195
197 void deleteJoint( int _objectId , int _jointId );
198
200 void transformJoint( int _objectId , int _jointId, Matrix4x4 _matrix );
201
203 Matrix4x4 globalMatrix(int _objectId, int _jointId);
204
206 Matrix4x4 localMatrix(int _objectId, int _jointId);
207
209 Vector globalTranslation(int _objectId, int _jointId);
210
212 Vector localTranslation(int _objectId, int _jointId);
213
215 int animationCount(int _objectId);
216
218 int frameCount(int _objectId, int _animationIndex);
219
221 int activeAnimation(int _objectId);
222
224 int activeFrame(int _objectId);
225
227 void setActivePose(int _objectId, int _animationIndex, int _frame);
228
230 void addAnimation(int _objectId, QString _name, int _frames);
231
233 void splitJoint(QMouseEvent* _event);
234
237 public slots:
238 QString version() { return QString("1.0"); };
239
240
241 private slots:
242 void slotSetEditingMode(QAction* _action);
243 void slotPickToolbarAction(QAction* _action);
244
245 void setDescriptions();
246
247 private:
248 QToolBar* toolbar_;
249 QActionGroup* toolBarActions_;
250 QAction* skeletonEditingAction_;
251
252 QToolBar* pickToolbar_;
253 QActionGroup* pickToolBarActions_;
254 QAction* selectJointAction_;
255 QAction* insertJointAction_;
256 QAction* splitJointAction_;
257 QAction* deleteJointAction_;
258 QAction* moveJointAction_;
259 QAction* transformChildManipAction_;
260 QAction* transformAllManipAction_;
261 QAction* rotateManipAction_;
262 QAction* inverseKinematicAction_;
263
264 int currentSkeleton_;
265 int currentJoint_;
266 bool jointPreview_;
267
268 bool transformChildJoints_;
269 bool transformAllFrames_;
270 bool inverseKinematic_;
271
272 bool dblClick_;
273
275 QString lastRenderer_;
277 bool rendererChanged_;
278
279 private:
280 // object ids of all objects with active Manipulator
281 std::vector< int > activeManipulators_;
282 // Size for the manipulators
283 double manip_size_;
284 // Modifier for the Size (changed by Mousewheel Events)
285 double manip_size_modifier_;
286
287 // Object marker to dimm Objects during manipulator transformation
288 SkeletonMarker objectMarker_;
289
290 ACG::Matrix4x4d accumMatrix_;
291
292 private:
294 void placeManip(QMouseEvent* _event);
295
297 void showManipulators();
298
300 void updateManipulatorPosition(BaseObjectData* _skeletonObj);
301
303 void inverseKinematic(ACG::Vec3d dest,Skeleton::Pose* currentPose,Skeleton::Joint* pickedJoint, std::vector<Skeleton::Joint*> rotatableJoints);
304
305 private slots:
307 void manipulatorMoved( QtTranslationManipulatorNode* _node , QMouseEvent* _event);
308
310 void ManipulatorPositionChanged(QtTranslationManipulatorNode* _node );
311
312 void slotRotateManipulator(bool _toggled);
313 };
314
315 #endif //SKELETONEDITINGPLUGIN_HH
SkeletonEditingPlugin::manipulatorMoved
void manipulatorMoved(QtTranslationManipulatorNode *_node, QMouseEvent *_event)
move the object when its manipulator moves
Definition: SkeletonEditingPlugin.cc:716
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:76
SkeletonEditingPlugin
Definition: SkeletonEditingPlugin.hh:75
KeyInterface
Keyboard Event Interface.
Definition: KeyInterface.hh:76
SkeletonEditingPlugin::description
QString description()
Description of the Plugin.
Definition: SkeletonEditingPlugin.hh:181
SkeletonEditingPlugin::globalMatrix
Matrix4x4 globalMatrix(int _objectId, int _jointId)
get global matrix of a joint in the active pose
Definition: SkeletonEditingScripting.cc:584
SkeletonEditingPlugin::lastRenderer_
QString lastRenderer_
Stores the last active renderer before we switched to skeleton editing mode.
Definition: SkeletonEditingPlugin.hh:275
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:103
SkeletonEditingPlugin::localMatrix
Matrix4x4 localMatrix(int _objectId, int _jointId)
get local matrix of a joint in the active pose
Definition: SkeletonEditingScripting.cc:628
SkeletonEditingPlugin::globalTranslation
Vector globalTranslation(int _objectId, int _jointId)
get global translation of a joint in the active pose
Definition: SkeletonEditingScripting.cc:671
ToolbarInterface.hh
BackupInterface.hh
BaseObjectData
Definition: BaseObjectData.hh:105
SkeletonEditingPlugin::updateManipulatorPosition
void updateManipulatorPosition(BaseObjectData *_skeletonObj)
make sure the manipulator is positioned on a joint
Definition: SkeletonEditingPlugin.cc:1448
SkeletonEditingPlugin::ManipulatorPositionChanged
void ManipulatorPositionChanged(QtTranslationManipulatorNode *_node)
update object when its manipulator changes position
Definition: SkeletonEditingPlugin.cc:845
SkeletonEditingPlugin::setDescriptions
void setDescriptions()
Set Descriptions for Scripting Slots.
Definition: SkeletonEditingScripting.cc:61
UpdateType
Update type class.
Definition: UpdateType.hh:70
UPDATE_ALL
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
SkeletonEditingPlugin::rendererChanged_
bool rendererChanged_
Remembers, if we changed the renderer.
Definition: SkeletonEditingPlugin.hh:277
SkeletonEditingPlugin::getNearestJoint
OpenMesh::Vec3d getNearestJoint(SkeletonObject *_skeletonObj, OpenMesh::Vec3d &_hitPoint, int &_bestJointID)
Get nearest joint to hitPoint (used for snapping)
Definition: SkeletonEditingPlugin.cc:1417
SkeletonEditingPlugin::addAnimation
void addAnimation(int _objectId, QString _name, int _frames)
add animation
Definition: SkeletonEditingScripting.cc:917
SkeletonEditingPlugin::~SkeletonEditingPlugin
~SkeletonEditingPlugin()
Destructor.
Definition: SkeletonEditingPlugin.cc:97
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:293
LoggingInterface.hh
KeyInterface.hh
SkeletonObject
Definition: SkeletonObject.hh:82
PoseT
A general pose, used to store the frames of the animation.
Definition: PoseT.hh:68
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:123
MouseInterface.hh
SkeletonEditingPlugin::placeManip
void placeManip(QMouseEvent *_event)
Place and show the Manipulator.
Definition: SkeletonEditingPlugin.cc:539
RPCInterface
Interface to call functions across plugins.
Definition: RPCInterface.hh:71
SkeletonEditingPlugin::slotPickModeChanged
void slotPickModeChanged(const std::string &_mode)
slot is called when the pickMode changed
Definition: SkeletonEditingPlugin.cc:391
SkeletonEditingPlugin::SkeletonEditingPlugin
SkeletonEditingPlugin()
Default Constructor.
Definition: SkeletonEditingPlugin.cc:61
ACG::SceneGraph::QtTranslationManipulatorNode
Definition: QtTranslationManipulatorNode.hh:87
Skeleton.hh
LoadSaveInterface.hh
SkeletonEditingPlugin::splitJoint
void splitJoint(QMouseEvent *_event)
split selected Joint
Definition: SkeletonEditingPlugin.cc:989
ContextMenuType
ContextMenuType
Definition: ContextMenuInterface.hh:72
OpenMesh::VectorT
Definition: Vector11T.hh:83
ToolbarInterface
Add a toolbox to OpenFlipper.
Definition: ToolbarInterface.hh:79
ScriptInterface
Interface for all Plugins which provide scriptable Functions.
Definition: ScriptInterface.hh:67
ContextMenuInterface.hh
RPCInterface.hh
LoadSaveInterface
Interface for all plugins which want to Load or Save files and create Objects.
Definition: LoadSaveInterface.hh:68
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:152
SkeletonEditingPlugin::pluginsInitialized
void pluginsInitialized()
Initialization of the plugin when it is loaded by the core.
Definition: SkeletonEditingPlugin.cc:110
PickingInterface
Allow access to picking functions.
Definition: PickingInterface.hh:81
PickingInterface.hh
BackupInterface
Interface class for backup handling.
Definition: BackupInterface.hh:75
SkeletonEditingPlugin::slotMouseEvent
void slotMouseEvent(QMouseEvent *_event)
MousePress event occured.
Definition: SkeletonEditingPlugin.cc:341
ScriptInterface.hh
BaseInterface.hh
ContextMenuInterface
Interface class for creating custom context menus.
Definition: ContextMenuInterface.hh:101
MouseInterface
Interface class for receiving mouse events.
Definition: MouseInterface.hh:75
SkeletonEditingPlugin::animationCount
int animationCount(int _objectId)
get the number of animations
Definition: SkeletonEditingScripting.cc:759
SkeletonEditingPlugin::setActivePose
void setActivePose(int _objectId, int _animationIndex, int _frame)
set active pose
Definition: SkeletonEditingScripting.cc:873
SkeletonEditingPlugin::transformJoint
void transformJoint(int _objectId, int _jointId, Matrix4x4 _matrix)
transform joint with given matrix
Definition: SkeletonEditingScripting.cc:306
ToolboxInterface
Plugins can add its own toolbox to the main widget's toolbox area by using this interface.
Definition: ToolboxInterface.hh:85
SkeletonEditingPlugin::name
QString name()
Name of the Plugin.
Definition: SkeletonEditingPlugin.hh:178
DataType
Predefined datatypes.
Definition: DataTypes.hh:96
SkeletonEditingPlugin::localTranslation
Vector localTranslation(int _objectId, int _jointId)
get local translation of a joint in the active pose
Definition: SkeletonEditingScripting.cc:715
SkeletonEditingPlugin::activeFrame
int activeFrame(int _objectId)
get active frame
Definition: SkeletonEditingScripting.cc:847
SkeletonMarker
Definition: SkeletonMarker.hh:58
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:635
Types.hh
SkeletonEditingPlugin::showManipulators
void showManipulators()
Show/Hide active manipulators.
Definition: SkeletonEditingPlugin.cc:865
JointT
Represents a single joint in the skeleton.
Definition: JointT.hh:66
ToolboxInterface.hh
ACG::Matrix4x4T< double >
SkeletonEditingPlugin::frameCount
int frameCount(int _objectId, int _animationIndex)
get the number of frames
Definition: SkeletonEditingScripting.cc:786
SkeletonEditingPlugin::addJoint
void addJoint(int _objectId, int _parent, Vector _position)
add joint to the skeleton
Definition: SkeletonEditingScripting.cc:224
SkeletonEditingPlugin::activeAnimation
int activeAnimation(int _objectId)
get active animation
Definition: SkeletonEditingScripting.cc:820