Commit ae88de84 authored by saubatn's avatar saubatn
Browse files

UPDATED Proposition of a new version of InterfaceFrame. Removed...

UPDATED Proposition of a new version of InterfaceFrame. Removed getDescendantsFrame[Name]() methods. See email for details and discussion

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1873 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 57f82571
......@@ -832,19 +832,6 @@ public:
delegate1(myFrame, addFrameChild, InterfaceFrame *)
delegate1(myFrame, removeFrameChild, InterfaceFrame *)
const QVector<InterfaceFrame *> & getDescendantsFrame() {
if(!myFrame)
CAMITK_ERROR("Component", "getDescendantsFrame", "Delegate myFrame is not instanciated.")
return myFrame->getDescendantsFrame();
}
const QVector<QString *> & getDescendantsFrameName() {
if(!myFrame)
CAMITK_ERROR("Component", "getDescendantsFrameName", "Delegate myFrame is not instanciated.")
return myFrame->getDescendantsFrameName();
}
///@}
......
......@@ -29,6 +29,9 @@
#include "Frame.h"
#include "Viewer.h"
// CamiTK includes
#include "Log.h"
using namespace camitk;
int Frame::nbTotalFrames = 0;
......@@ -118,32 +121,7 @@ const QVector<InterfaceFrame *> & Frame::getChildrenFrame() const {
return childrenFrame;
}
// ------------------- getDescendantsFrame ----------------------------------
const QVector<InterfaceFrame *> & Frame::getDescendantsFrame() {
descendantsFrame.clear();
foreach(InterfaceFrame * child, childrenFrame) {
descendantsFrame.append(child);
foreach(InterfaceFrame * grandChild, child->getDescendantsFrame()) {
descendantsFrame.append(grandChild);
}
}
return descendantsFrame;
}
// ------------------- getDescendantsFrameName ----------------------------------
const QVector<QString *> & Frame::getDescendantsFrameName() {
descendrantsFrameName.clear();
foreach(InterfaceFrame * child, getDescendantsFrame()) {
descendrantsFrameName.append((QString * const &)(child->getFrameName()));
}
return descendrantsFrameName;
}
// ------------------- setParentFrame ----------------------------------
void Frame::setParentFrame(InterfaceFrame *parent, bool keepTransform) {
......@@ -152,17 +130,21 @@ void Frame::setParentFrame(InterfaceFrame *parent, bool keepTransform) {
if (checkedParent) {
// setParentFrame(this) should not be possible...
// Neither should be setParentFrame from one of my child
const QVector<QString *> & descendants = getDescendantsFrameName();
if(checkedParent->getFrameName() == getFrameName()) {
checkedParent = NULL;
}
else if(descendants.indexOf((QString * const &)(checkedParent->getFrameName())) != -1){
//remove the new parent in the list of children
removeFrameChild(checkedParent);
//In this usecase, the former descendant is attached to the world frame
checkedParent->setParentFrame(NULL);
} else {
// compute all the descendants of the current frame
QVector<InterfaceFrame *> descendants = computeDescendants(this);
// check if one of the descendant if the checked parent
foreach(InterfaceFrame * descendant, descendants){
if(descendant->getFrameName() == checkedParent->getFrameName()){
//remove the new parent in the list of children
removeFrameChild(checkedParent);
//In this usecase, the former descendant is attached to the world frame
checkedParent->setParentFrame(NULL);
break;
}
}
}
}
......@@ -384,9 +366,21 @@ bool Frame::getFrameVisibility(Viewer * viewer) const {
if (it == frameViewers.end()) {
return false;
}
else {
} else {
return it.value();
}
}
// ------------------- computeDescendants -------------------------------
QVector<InterfaceFrame *> Frame::computeDescendants(InterfaceFrame *frame){
QVector<InterfaceFrame *> descendants;
// recursively call to get all the descendants of 'frame'
foreach(InterfaceFrame * child, frame->getChildrenFrame()) {
descendants.append(child);
descendants += computeDescendants(child);
}
return descendants;
}
......@@ -75,17 +75,6 @@ public:
* The Frame hierarchy may not be the same as the Component Hierarchy.
*/
virtual const QVector<InterfaceFrame *> & getChildrenFrame() const;
/// Returns a vector containing the children and the children of children and etc.
/// of the current frame.
virtual const QVector<InterfaceFrame *> & getDescendantsFrame();
/// Returns a vector containing names of the children and the children of children and etc.
/// of the current frame.
/// Note: as InterfaceFrame * are manipulated as different types(Frame*, even Component *) it is not
/// possible to compare objects with their pointer value. The frame name is something "more stable".
virtual const QVector<QString *> & getDescendantsFrameName();
/** @} */
......@@ -205,17 +194,13 @@ protected:
QVector<InterfaceFrame *> childrenFrame;
/**
* @brief List of the frame's descendants.
* @brief Compute all the descendants of the input frame.
*/
QVector<InterfaceFrame *> descendantsFrame;
/**
* @brief List of the frame's descendants' name.
*/
QVector<QString *> descendrantsFrameName;
QVector<InterfaceFrame *> computeDescendants(InterfaceFrame *);
private:
/// To be able to give a default unique identyfier to each created frame
/// To be able to give a default unique identifier to each created frame
static int nbTotalFrames;
/// Geometric representation of the frame (vtkAxes)
......
......@@ -90,16 +90,6 @@ public:
*/
virtual const QVector<InterfaceFrame *> & getChildrenFrame() const = 0;
/// Returns a vector containing the children and the children of children and etc.
/// of the current frame.
virtual const QVector<InterfaceFrame *> & getDescendantsFrame() = 0;
/// Returns a vector containing names of the children and the children of children and etc.
/// of the current frame.
/// Note: as InterfaceFrame * are manipulated as different types(Frame*, even Component *) it is not
/// possible to compare objects with their pointer value. The frame name is something "more stable".
virtual const QVector<QString *> & getDescendantsFrameName() = 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