Commit b14b24e2 authored by saubatn's avatar saubatn
Browse files

UPDATED InterfaceFrame refactoring as discussed in EOS 7 meeting. Until new...

UPDATED InterfaceFrame refactoring as discussed in EOS 7 meeting. Until new decision, InterfaceFrame::addFrameChild(...) has been kept.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1915 ec899d31-69d1-42ba-9299-647d76f65fb3
parent caae3eb7
......@@ -111,7 +111,7 @@ QWidget * MoveFrame::getWidget() {
init();
inputFrame = dynamic_cast<Component *> (getTargets().last());
vtkSmartPointer<vtkTransform> initialTransform = inputFrame->getTransformFromParent();
vtkSmartPointer<vtkTransform> initialTransform = inputFrame->getTransform();
initialPosition.setX(initialTransform->GetPosition()[0]);
initialPosition.setY(initialTransform->GetPosition()[1]);
......@@ -212,7 +212,7 @@ Action::ApplyStatus MoveFrame::apply() {
//-- Set the Translation
transformation->Translate(double(ui.tX->getValue()), double(ui.tY->getValue()), double(ui.tZ->getValue()));
inputFrame->setTransformFromParent(transformation);
inputFrame->setTransform(transformation);
// Refresh all the used viewers
// InteractiveViewer::get3DViewer()->refresh();
......@@ -237,7 +237,7 @@ void MoveFrame::setTranslation() {
trans.setY(double (ui.tY->getValue()));
trans.setZ(double (ui.tZ->getValue()));
inputFrame->setTranslation(trans.x(), trans.y(), trans.z());
inputFrame->setTransformTranslation(trans.x(), trans.y(), trans.z());
}
void MoveFrame::rotate() {
......@@ -255,7 +255,7 @@ void MoveFrame::setRotation() {
rot.setY(double (ui.rY->getValue()));
rot.setZ(double (ui.rZ->getValue()));
inputFrame->setRotation(rot.x(), rot.y(), rot.z());
inputFrame->setTransformRotation(rot.x(), rot.y(), rot.z());
}
......@@ -321,4 +321,4 @@ void MoveFrame::save() {
file.close();
}
}
\ No newline at end of file
}
......@@ -325,28 +325,28 @@ Action::ApplyStatus ReorientImage::process( ImageComponent * image) {
image->replaceImageData(newData);
// Move the image back to the origin thanks to Frame
vtkSmartPointer<vtkMatrix4x4> originalMatrix = image->getTransformFromParent()->GetMatrix();
vtkSmartPointer<vtkMatrix4x4> originalMatrix = image->getTransform()->GetMatrix();
if (ui.resetImageOriginRadioButton->isChecked()) {
vtkSmartPointer<vtkMatrix4x4> backToOriginMatrix = ImageOrientationHelper::getTransformFromRAI(orient, dims[0], dims[1], dims[2]);
vtkSmartPointer<vtkTransform> backToOrigin = vtkSmartPointer<vtkTransform>::New();
backToOrigin->SetMatrix(backToOriginMatrix);
image->setTransformFromParent(backToOrigin);
image->setTransform(backToOrigin);
} else {
vtkSmartPointer<vtkMatrix4x4> idty = vtkSmartPointer<vtkMatrix4x4>::New();
idty->Identity();
vtkSmartPointer<vtkTransform> idtyTrans = vtkSmartPointer<vtkTransform>::New();
idtyTrans->SetMatrix(idty);
image->setTransformFromParent(idtyTrans);
image->setTransform(idtyTrans);
}
vtkSmartPointer<vtkMatrix4x4> newMatrix = image->getTransformFromParent()->GetMatrix();
vtkSmartPointer<vtkMatrix4x4> newMatrix = image->getTransform()->GetMatrix();
vtkSmartPointer<vtkMatrix4x4> updatedMatrix = vtkSmartPointer<vtkMatrix4x4>::New();
vtkMatrix4x4::Multiply4x4(originalMatrix, newMatrix, updatedMatrix);
vtkSmartPointer<vtkTransform> updatedTransform = vtkSmartPointer<vtkTransform>::New();
updatedTransform->SetMatrix(updatedMatrix);
image->setTransformFromParent(updatedTransform);
image->setTransform(updatedTransform);
image->setFrameVisibility(InteractiveViewer::get3DViewer(), true);
......@@ -358,18 +358,18 @@ Action::ApplyStatus ReorientImage::process( ImageComponent * image) {
vtkSmartPointer<vtkMatrix4x4> backToOriginMatrix = ImageOrientationHelper::getTransformFromRAI(orient, dims[0], dims[1], dims[2]);
vtkSmartPointer<vtkTransform> backToOrigin = vtkSmartPointer<vtkTransform>::New();
backToOrigin->SetMatrix(backToOriginMatrix);
result->setTransformFromParent(backToOrigin);
result->setTransform(backToOrigin);
}
result->setParentFrame(image->getParentFrame());
vtkSmartPointer<vtkMatrix4x4> originalMatrix = image->getTransformFromParent()->GetMatrix();
vtkSmartPointer<vtkMatrix4x4> newMatrix = result->getTransformFromParent()->GetMatrix();
vtkSmartPointer<vtkMatrix4x4> originalMatrix = image->getTransform()->GetMatrix();
vtkSmartPointer<vtkMatrix4x4> newMatrix = result->getTransform()->GetMatrix();
vtkSmartPointer<vtkMatrix4x4> updatedMatrix = vtkSmartPointer<vtkMatrix4x4>::New();
vtkMatrix4x4::Multiply4x4(originalMatrix, newMatrix, updatedMatrix);
vtkSmartPointer<vtkTransform> updatedTransform = vtkSmartPointer<vtkTransform>::New();
updatedTransform->SetMatrix(updatedMatrix);
result->setTransformFromParent(updatedTransform);
result->setTransform(updatedTransform);
result->setFrameVisibility(InteractiveViewer::get3DViewer(), true);
}
......
......@@ -788,29 +788,29 @@ public:
return myFrame->getTransformFromWorld();
}
const vtkSmartPointer<vtkTransform> getTransformFromParent() const {
const vtkSmartPointer<vtkTransform> getTransform() const {
if(!myFrame)
CAMITK_ERROR("Component", "getTransformFromParent", "Delegate myFrame is not instanciated.")
return myFrame->getTransformFromParent();
CAMITK_ERROR("Component", "getTransform", "Delegate myFrame is not instanciated.")
return myFrame->getTransform();
}
vtkSmartPointer<vtkTransform> getTransformFromFrame(InterfaceFrame * frame) const {
const vtkSmartPointer<vtkTransform> getTransformFromFrame(InterfaceFrame * frame) const {
if(!myFrame)
CAMITK_ERROR("Component", "getTransformFromFrame", "Delegate myFrame is not instanciated.")
return myFrame->getTransformFromFrame(frame);
}
delegate1(myFrame, setTransformFromParent, vtkSmartPointer<vtkTransform>)
delegate1(myFrame, setTransform, vtkSmartPointer<vtkTransform>)
delegate0(myFrame, setTransformFromParentToIdentity)
delegate0(myFrame, resetTransform)
delegate3(myFrame, translate, double, double, double)
delegate3(myFrame, rotate, double, double, double)
delegate3(myFrame, setTranslation, double, double, double)
delegate3(myFrame, setTransformTranslation, double, double, double)
delegate3(myFrame, setRotation, double, double, double)
delegate3(myFrame, setTransformRotation, double, double, double)
vtkSmartPointer<vtkAxesActor> getFrameAxisActor() {
if(!myFrame)
......
......@@ -41,7 +41,7 @@ Frame::Frame(vtkSmartPointer<vtkTransform> transform, Frame *parentFrame) {
initAttributes();
if (transform != NULL) {
setTransformFromParent(transform);
setTransform(transform);
}
setParentFrame(parentFrame);
......@@ -151,7 +151,7 @@ void Frame::setParentFrame(InterfaceFrame *parent, bool keepTransform) {
if(!keepTransform) {
vtkSmartPointer<vtkTransform> newParentTransform = NULL;
newParentTransform = getTransformFromFrame(checkedParent);
setTransformFromParent(newParentTransform);
setTransform(newParentTransform);
}
// tell my former parent that I am no more its child
......@@ -175,7 +175,7 @@ void Frame::setParentFrame(InterfaceFrame *parent, bool keepTransform) {
// ------------------- addFrameChild ----------------------------------
void Frame::addFrameChild(InterfaceFrame * frame) {
if (! childrenFrame.contains(frame)) {
if (!childrenFrame.contains(frame)) {
childrenFrame.append(frame);
}
}
......@@ -191,13 +191,13 @@ const vtkSmartPointer<vtkTransform> Frame::getTransformFromWorld() const {
return transformWorldToMe;
}
// ------------------- getTransformFromParent ----------------------------------
const vtkSmartPointer<vtkTransform> Frame::getTransformFromParent() const {
// ------------------- getTransform ----------------------------------
const vtkSmartPointer<vtkTransform> Frame::getTransform() const {
return transformParentToMe;
}
// ------------------- getTransformFromFrame ----------------------------------
vtkSmartPointer<vtkTransform> Frame::getTransformFromFrame(InterfaceFrame * frame) const {
const vtkSmartPointer<vtkTransform> Frame::getTransformFromFrame(InterfaceFrame * frame) const {
// World -> Me
vtkSmartPointer<vtkMatrix4x4> worldToMeMatrix = transformWorldToMe->GetMatrix();
......@@ -208,7 +208,6 @@ vtkSmartPointer<vtkTransform> Frame::getTransformFromFrame(InterfaceFrame * fram
worldToMeMatrix->Identity();
} else {
worldToFrameMatrix = frame->getTransformFromWorld()->GetMatrix();
//frame->getTransformFromParent()->GetConcatenatedTransform(frame->getTransformFromParent()->GetNumberOfConcatenatedTransforms())->GetMatrix();
}
// Frame -> World
......@@ -225,16 +224,16 @@ vtkSmartPointer<vtkTransform> Frame::getTransformFromFrame(InterfaceFrame * fram
return result;
}
// ------------------- setTransformFromParent ----------------------------------
void Frame::setTransformFromParent(vtkSmartPointer<vtkTransform> transform) {
// ------------------- setTransform ----------------------------------
void Frame::setTransform(vtkSmartPointer<vtkTransform> transform) {
transformParentToMe->SetMatrix(transform->GetMatrix());
transformParentToMe->Update();
transformWorldToMe->Update();
representationTransformFilter->Update();
}
// ------------------- setTransformFromParentToIdentity ----------------------------------
void Frame::setTransformFromParentToIdentity() {
// ------------------- resetTransform ----------------------------------
void Frame::resetTransform() {
transformParentToMe->Identity();
transformParentToMe->Update();
transformWorldToMe->Update();
......@@ -267,8 +266,8 @@ void Frame::rotate(double aroundX, double aroundY, double aroundZ) {
representationTransformFilter->Update();
}
// ------------------- setTranslation ----------------------------------
void Frame::setTranslation(double x, double y, double z) {
// ------------------- setTransformTranslation --------------------------
void Frame::setTransformTranslation(double x, double y, double z) {
double * initialRotation = transformParentToMe->GetOrientation();
transformParentToMe->Identity();
......@@ -282,8 +281,8 @@ void Frame::setTranslation(double x, double y, double z) {
representationTransformFilter->Update();
}
// ------------------- setRotation ----------------------------------
void Frame::setRotation(double aroundX, double aroundY, double aroundZ) {
// ------------------- setTransformRotation ------------------------------
void Frame::setTransformRotation(double aroundX, double aroundY, double aroundZ) {
double * initialTranslation = transformParentToMe->GetPosition();
transformParentToMe->Identity();
......
......@@ -85,21 +85,22 @@ public:
virtual const vtkSmartPointer<vtkTransform> getTransformFromWorld() const;
/// Get a the transformation with respect to the parent frame
virtual const vtkSmartPointer<vtkTransform> getTransformFromParent() const;
virtual const vtkSmartPointer<vtkTransform> getTransform() const;
/// Get a COPY of the transformation with respect to another frame
virtual vtkSmartPointer<vtkTransform> getTransformFromFrame(InterfaceFrame * frame) const;
virtual const vtkSmartPointer<vtkTransform> getTransformFromFrame(InterfaceFrame * frame) const;
/**
* Sets the current frame position with respect to its parent Frame to
* @transform parameter no matter its previous position.
* Set the current input frame position (according to its parent Frame)
* @param transform The 3D transform of the current frame to its parent.
*/
virtual void setTransformFromParent(vtkSmartPointer<vtkTransform> transform);
virtual void setTransform(vtkSmartPointer<vtkTransform> transform);
/**
* Sets the current frame position equal to its parent position (to the world position if no parent.
* Set the current frame transform to identity.
* In other words, the current frame and its parent share the same 3D location.
*/
virtual void setTransformFromParentToIdentity();
virtual void resetTransform();
/**
......@@ -113,14 +114,18 @@ public:
virtual void rotate(double aroundX, double aroundY, double aroundZ);
/**
* Apply an absolute translation (the current translation is replaced by the new translation).
* Set the translation part of the 3D space transformation of the current frame.
* @note Reminder: A 3D space transform is a 4x4 matrix, composed of a rotation and a translation.
*
*/
virtual void setTranslation(double x, double y, double z);
virtual void setTransformTranslation(double x, double y, double z);
/**
* Apply an absolute rotation (the current rotation is replaced by the new rotation).
* Set the rotation part of the 3D space transformation of the current frame.
* @note Reminder: A 3D space transform is a 4x4 matrix, composed of a rotation and a translation.
*
*/
virtual void setRotation(double aroundX, double aroundY, double aroundZ);
virtual void setTransformRotation(double aroundX, double aroundY, double aroundZ);
/** @} */
......@@ -139,8 +144,7 @@ public:
*/
virtual bool getFrameVisibility(Viewer * viewer) const;
/// When the current Frame is set to parent, it must update its children list
virtual void addFrameChild(InterfaceFrame * frame);
/**
* If the parent frame keeps track of its children, when a child is deleted
......@@ -155,7 +159,6 @@ public:
protected:
/**
* Frame unique identifier
*/
......@@ -199,6 +202,9 @@ protected:
private:
/// When the current Frame is set to parent, it must update its children list
virtual void addFrameChild(InterfaceFrame * frame);
/// To be able to give a default unique identifier to each created frame
static int nbTotalFrames;
......
......@@ -48,7 +48,7 @@ class Viewer;
* @ingroup group_sdk_libraries_core_component
*
* @brief
* This class describe what are the methods to implement in order to manage a Component position in space.
* This class describes what are the methods to implement in order to manage a Component position in space.
*
* The Frame hierarchy is inspired from IGSTK hierarchy:
* - Each Frame knows its parent frame
......@@ -80,12 +80,16 @@ public:
/// Get the parent frame
virtual InterfaceFrame * getParentFrame() const = 0;
/// Set the parent frame and update or not its transform during the parent transition
/**
* Set the parent frame and update or not its transform during the parent transition
* @param parent the new parent frame of current interface frame
* @param keepTransform if true keeps the local transform from parent. The current interface frame may move from world coordinates as its local transform is now expressed relatively to the new parent. If false, change the transform from parent to keep the global (world) transform the same as the previous one.
*/
virtual void setParentFrame(InterfaceFrame * parent, bool keepTransform = true) = 0;
/**
* Get the Children Frames from the current Frame in the Frame Hierarchy
* The Frame hierarchy may not be the same as the Component Hierarchy.
* The Frame hierarchy may not be the same as the Component Hierarchy.
*/
virtual const QVector<InterfaceFrame *> & getChildrenFrame() const = 0;
......@@ -98,21 +102,25 @@ public:
/// Get a the transformation with respect to the world frame
virtual const vtkSmartPointer<vtkTransform> getTransformFromWorld() const = 0;
/// Get a the transformation with respect to the parent frame
virtual const vtkSmartPointer<vtkTransform> getTransformFromParent() const = 0;
/// Get the transformation with respect to the parent frame
virtual const vtkSmartPointer<vtkTransform> getTransform() const = 0;
/// Get a COPY of the transformation with respect to another frame
virtual vtkSmartPointer<vtkTransform> getTransformFromFrame(InterfaceFrame * frame) const = 0;
/// Compute the transformation from any other frame to the current frame.
/// @note A new returned transformed is instancied at each call.
/// Caller takes ownership of the transform and is responsible for its deletion
virtual const vtkSmartPointer<vtkTransform> getTransformFromFrame(InterfaceFrame * frame) const = 0;
/**
* Sets the current frame position with respect to its parent Frame to
* @transform parameter no matter its previous position.
* Set the current input frame position (according to its parent Frame)
* @param transform The 3D transform of the current frame to its parent.
*/
virtual void setTransformFromParent(vtkSmartPointer<vtkTransform> transform) = 0;
virtual void setTransform(vtkSmartPointer<vtkTransform> transform) = 0;
/**
* Sets the current frame position equal to its parent position (to the world position if no parent.
* Set the current frame transform to identity.
* In other words, the current frame and its parent share the same 3D location.
*/
virtual void setTransformFromParentToIdentity() = 0;
virtual void resetTransform() = 0;
/**
......@@ -126,19 +134,23 @@ public:
virtual void rotate(double aroundX, double aroundY, double aroundZ) = 0;
/**
* Apply an absolute translation (the current translation is replaced by the new translation).
* Set the translation part of the 3D space transformation of the current frame.
* @note Reminder: A 3D space transform is a 4x4 matrix, composed of a rotation and a translation.
*
*/
virtual void setTranslation(double x, double y, double z) = 0;
virtual void setTransformTranslation(double x, double y, double z) = 0;
/**
* Apply an absolute rotation (the current rotation is replaced by the new rotation).
* Set the rotation part of the 3D space transformation of the current frame.
* @note Reminder: A 3D space transform is a 4x4 matrix, composed of a rotation and a translation.
*
*/
virtual void setRotation(double aroundX, double aroundY, double aroundZ) = 0;
virtual void setTransformRotation(double aroundX, double aroundY, double aroundZ) = 0;
/** @} */
/**
* Gives the 3D representation of the frame (based on xyd arrows)
* Gives the 3D representation of the frame (based on xyz arrows)
*/
virtual vtkSmartPointer<vtkAxesActor> getFrameAxisActor() = 0;
......@@ -149,19 +161,20 @@ public:
/**
* Get the Component Frame visibility for a given viewer
* @param viewer the viewer in which we check the visibility of the current frame.
*/
virtual bool getFrameVisibility(Viewer * viewer) const = 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
* Add the input frame as a child of the current frame.
* @param frame The child frame of the current one.
*/
virtual void addFrameChild(InterfaceFrame * frame) = 0;
/**
* If the parent frame keeps track of its children, when a child is deleted
* it should warn its parent
*/
* Remove the input frame as a child of the current frame.
* @param frame the input frame to remove from the current frame's children list
*/
virtual void removeFrameChild(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