Commit 02cee328 authored by cfouard's avatar cfouard
Browse files

FIXED bug not even yet reported: setParent used to perform a dynamic_cast...

FIXED bug not even yet reported: setParent used to perform a dynamic_cast frome InterfaceFrame * to Frame * which made setParent not work if a Component was passed as parameter (the delegation for the InterfaceFrame would not work).
The way to fix it is not optimal as it forces to write the function addChildFrame as public although it should be private as only setParent should be public. Any better fix is welcome.

FIXED another bug not even reported yet: now, setParent saves the previous world transform and you can change your parent frame without moving (and without going back to the origin of the World Frame).

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1587 ec899d31-69d1-42ba-9299-647d76f65fb3
parent a07c602a
......@@ -765,6 +765,8 @@ public:
delegateGet1(myFrame, getFrameVisibility, bool, Viewer *)
delegate1(myFrame, addFrameChild, InterfaceFrame *)
///@}
protected:
/// myGeometry is the 3d representation of this Component, the Component delegates all InterfaceGeometry activity to myGeometry (delegation pattern)
......
......@@ -42,9 +42,7 @@ Frame::Frame(vtkSmartPointer<vtkTransform> transform, Frame *parentFrame)
setTransformFromParent(transform);
}
this->parentFrame = parentFrame;
setParentFrame(parentFrame);
}
......@@ -103,7 +101,10 @@ const QVector<InterfaceFrame *> * Frame::getChildrenFrame()
// ------------------- setParentFrame ----------------------------------
void Frame::setParentFrame(InterfaceFrame *parent)
{
this->parentFrame = dynamic_cast<Frame *> (parent);
vtkSmartPointer<vtkTransform> newParentTransform = NULL;
newParentTransform = getTransformFromFrame(parent);
this->parentFrame = parent;
this->transformWorldToMe->Identity();
this->transformWorldToMe->PostMultiply();
this->transformWorldToMe->Concatenate(transformParentToMe);
......@@ -111,10 +112,13 @@ void Frame::setParentFrame(InterfaceFrame *parent)
if (this->parentFrame != NULL)
{
this->transformWorldToMe->Concatenate(this->parentFrame->transformWorldToMe);
this->transformWorldToMe->Concatenate(this->parentFrame->getTransformFromWorld());
this->transformWorldToMe->Update();
this->parentFrame->addFrameChild(this);
}
this->setTransformFromParent(newParentTransform);
}
// ------------------- setParentFrame ----------------------------------
......
......@@ -132,7 +132,9 @@ public:
* Get the Component Frame visibility for a given viewer
*/
virtual bool getFrameVisibility(Viewer * viewer);
/// When the current Frame is set to parent, it must update its children list
virtual void addFrameChild(InterfaceFrame * frame);
protected :
///@{ Constructors helpers
......@@ -140,9 +142,6 @@ protected :
void initAttributes();
///@}
/// When the current Frame is set to parent, it must update its children list
void addFrameChild(InterfaceFrame * frame);
/**
* Frame unique identifier
......@@ -153,7 +152,7 @@ protected :
* The Parent Frame.
* If it is NULL, then the parent is the World Frame.
*/
Frame * parentFrame;
InterfaceFrame * parentFrame;
/**
* Transformation to represent my points (expressed in my frame) in my parent's frame.
......
......@@ -154,6 +154,12 @@ public:
virtual bool getFrameVisibility(Viewer * viewer) = 0;
/**
* When the current Frame is set to parent, it must update its children list
* Note: This method is an helper method. You should use setParentFrame instead
*/
virtual void addFrameChild(InterfaceFrame * frame) = 0;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment