diff --git a/SkeletonEditingPlugin.cc b/SkeletonEditingPlugin.cc index 64f7b0a4482526a8da8761b7305e684048c6d91d..cf5828d9f137574b995956c14f15c83e37cc30bb 100644 --- a/SkeletonEditingPlugin.cc +++ b/SkeletonEditingPlugin.cc @@ -440,6 +440,15 @@ void SkeletonEditingPlugin::manipulatorMoved( QtTranslationManipulatorNode* _nod transformJoint( objectId, _node->getData().toInt(), mat ); + if (_event->type() == QEvent::MouseButtonPress) + accumMatrix_.identity(); + + accumMatrix_ *= mat; + + //only backup on mouseRelease + if ( (_event->type() == QEvent::MouseButtonRelease) && !accumMatrix_.is_identity() ) + emit createBackup(objectId, "Joint Transformation", UPDATE_GEOMETRY); + BaseObjectData* object = 0; PluginFunctions::getObject(objectId, object); @@ -590,6 +599,7 @@ void SkeletonEditingPlugin::deleteJoint(QMouseEvent* _event) skeleton->removeJoint(joint); PluginFunctions::skeletonObject(object)->updateIndices(); emit updatedObject(object->id(), UPDATE_ALL); + emit createBackup(object->id(), "Delete Joint", UPDATE_TOPOLOGY); } else emit deleteObject( object->id() ); } @@ -717,6 +727,7 @@ void SkeletonEditingPlugin::insertJoint(QMouseEvent* _event) // set joint position setJointPosition(PluginFunctions::skeletonObject(baseObject), rootJoint, lastHitPoint); emit updatedObject(baseObject->id(), UPDATE_ALL); + emit createBackup(baseObject->id(), "Add Joints", UPDATE_ALL); // add an additional joint which is moved on mousemove Skeleton::Joint* tmpJoint = new Skeleton::Joint(rootJoint); @@ -948,6 +959,7 @@ void SkeletonEditingPlugin::cancelJointInsertion(){ skeleton->removeJoint(joint); emit updatedObject(baseObject->id(), UPDATE_ALL); + emit createBackup(baseObject->id(), "Add Joints", UPDATE_ALL); } //-------------------------------------------------------------------------------- diff --git a/SkeletonEditingPlugin.hh b/SkeletonEditingPlugin.hh index ce2a3d567ad9dc4fef85321e32438b8fd557e9fa..e00c85bdf7539e81904bf8332805820d898f903b 100644 --- a/SkeletonEditingPlugin.hh +++ b/SkeletonEditingPlugin.hh @@ -78,7 +78,7 @@ class SkeletonEditingPlugin : public QObject, BaseInterface, MouseInterface, Key void deleteObject( int _id); // BackupInterface - void createBackup( int _objectid, QString _name); + void createBackup( int _objectid, QString _name, UpdateType _type = UPDATE_ALL ); private slots : @@ -217,6 +217,8 @@ class SkeletonEditingPlugin : public QObject, BaseInterface, MouseInterface, Key // Object marker to dimm Objects during manipulator transformation SkeletonMarker objectMarker_; + ACG::Matrix4x4d accumMatrix_; + private: /// Place and show the Manipulator void placeManip(QMouseEvent* _event); diff --git a/SkeletonEditingScripting.cc b/SkeletonEditingScripting.cc index 56f0e3867ff98c429924eb60e3dadc4d0df4e9f8..df769cd32d1f4fde208598dcd8e8a9fcfda45f77 100644 --- a/SkeletonEditingScripting.cc +++ b/SkeletonEditingScripting.cc @@ -120,12 +120,12 @@ void SkeletonEditingPlugin::splitBone( int _objectId, int _tailJoint){ } } - emit updatedObject(_objectId, UPDATE_ALL); + emit updatedObject(_objectId, UPDATE_GEOMETRY); emit scriptInfo("splitBone( ObjectId, " + QString::number(_tailJoint) + " )" ); // Create backup - emit createBackup(_objectId, "Split Bone"); + emit createBackup(_objectId, "Split Bone", UPDATE_TOPOLOGY); } //------------------------------------------------------------------------------ @@ -165,7 +165,7 @@ void SkeletonEditingPlugin::addJoint( int _objectId , int _parent, Vector _posit + QString::number(_position[2]) + ") )" ); // Create backup - emit createBackup(_objectId, "Remove Joint"); + emit createBackup(_objectId, "Add Joint", UPDATE_TOPOLOGY); } //------------------------------------------------------------------------------ @@ -196,7 +196,7 @@ void SkeletonEditingPlugin::deleteJoint( int _objectId , int _jointId ){ emit scriptInfo("deleteJoint( ObjectId, " + QString::number(_jointId) + " )" ); // Create backup - emit createBackup(_objectId, "Delete Joint"); + emit createBackup(_objectId, "Delete Joint", UPDATE_TOPOLOGY); emit updatedObject(_objectId, UPDATE_ALL); } @@ -290,8 +290,10 @@ void SkeletonEditingPlugin::transformJoint( int _objectId , int _jointId, Matrix emit scriptInfo( "transformJoint( ObjectId, " + QString::number(_jointId) + ", Matrix4x4(" + matString + " ) )" ); - // Create backup - emit createBackup(_objectId, "Joint Transformation"); + // Create backup if there was a change + // the backup is only created when the slot is called via scripting (sender == 0) + if ( !_matrix.is_identity() && (sender() == 0) ) + emit createBackup(_objectId, "Joint Transformation", UPDATE_GEOMETRY); } //------------------------------------------------------------------------------ @@ -662,7 +664,7 @@ void SkeletonEditingPlugin::addAnimation(int _objectId, QString _name, int _fram emit scriptInfo("addAnimation( ObjectId, " + _name + ", " + QString::number(_frames) + ")" ); // Create backup - emit createBackup(_objectId, "Add Animation"); + emit createBackup(_objectId, "Add Animation", UPDATE_ALL); } //------------------------------------------------------------------------------