Commit 6f227c3c authored by saubatn's avatar saubatn
Browse files

FEATURE 589 Supress InterfaceFrame::getFrameName() warning. Update proposition...

FEATURE 589 Supress InterfaceFrame::getFrameName() warning. Update proposition for InterfaceFrame service (including return type of QVector<T> * changed to const QVector<T> &)

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1859 ec899d31-69d1-42ba-9299-647d76f65fb3
parent ccf3accc
......@@ -640,12 +640,12 @@ public:
/** an inherited class can redefine this method something specific.
* Default behaviour: do nothing.
*/
virtual void pointPicked(vtkIdType, bool) {};
virtual void pointPicked(vtkIdType, bool) {}
/** an inherited class can redefine this method something specific.
* Default behaviour: do nothing.
*/
virtual void cellPicked(vtkIdType, bool) {};
virtual void cellPicked(vtkIdType, bool) {}
// --
......@@ -657,9 +657,9 @@ public:
*/
virtual double getBoundingRadius();
delegate4(myGeometry, setPointPosition, const unsigned int, const double, const double, const double);
delegate4(myGeometry, setPointPosition, const unsigned int, const double, const double, const double)
delegateAndInvokeChildren1(myGeometry, setRenderingModes, const RenderingModes);
delegateAndInvokeChildren1(myGeometry, setRenderingModes, const RenderingModes)
/// see Component.cpp
virtual const InterfaceGeometry::RenderingModes getRenderingModes() const;
......@@ -691,7 +691,7 @@ public:
virtual void setGlyphType(const GlyphTypes type, const double size = 0.0);
delegate1(myGeometry, setLinesAsTubes, bool);
delegate1(myGeometry, setLinesAsTubes, bool)
delegate1(myGeometry, setMeshWorldTransform, vtkSmartPointer<vtkTransform>)
......@@ -720,9 +720,9 @@ public:
delegate0(mySlice, updatePickPlane)
delegate1(mySlice, setSlice, int);
delegate1(mySlice, setSlice, int)
delegate3(mySlice, setSlice, double, double, double);
delegate3(mySlice, setSlice, double, double, double)
delegate1(mySlice, setRotationX, double)
......@@ -758,24 +758,41 @@ public:
* All the implemented InterfaceFrame methods
*/
///@{
delegateGet0(myFrame, getFrameName, const QString & )
const QString & getFrameName() const {
if(myFrame)
return myFrame->getFrameName();
}
delegate1(myFrame, setFrameName, QString)
delegateGet0(myFrame, getParentFrame, InterfaceFrame *)
InterfaceFrame* getParentFrame() const {
if(myFrame)
return myFrame->getParentFrame();
}
void setParentFrame(InterfaceFrame* frame, bool keepTransform = true)
{
void setParentFrame(InterfaceFrame* frame, bool keepTransform = true) {
return myFrame->setParentFrame(frame, keepTransform);
}
delegateGet0(myFrame, getChildrenFrame, const QVector<InterfaceFrame *> *)
const QVector<InterfaceFrame *> & getChildrenFrame() const {
if(myFrame)
return myFrame->getChildrenFrame();
}
delegateGet0(myFrame, getTransformFromWorld, const vtkSmartPointer<vtkTransform>)
const vtkSmartPointer<vtkTransform> getTransformFromWorld() const {
if(myFrame)
return myFrame->getTransformFromWorld();
}
delegateGet0(myFrame, getTransformFromParent, const vtkSmartPointer<vtkTransform>)
const vtkSmartPointer<vtkTransform> getTransformFromParent() const {
if(myFrame)
return myFrame->getTransformFromParent();
}
delegateGet1(myFrame, getTransformFromFrame, vtkSmartPointer<vtkTransform>, InterfaceFrame *)
vtkSmartPointer<vtkTransform> getTransformFromFrame(InterfaceFrame * frame) const {
if(myFrame)
return myFrame->getTransformFromFrame(frame);
}
delegate1(myFrame, setTransformFromParent, vtkSmartPointer<vtkTransform>)
......@@ -789,22 +806,35 @@ public:
delegate3(myFrame, setRotation, double, double, double)
delegateGet0(myFrame, getFrameAxisActor, vtkSmartPointer<vtkAxesActor>)
vtkSmartPointer<vtkAxesActor> getFrameAxisActor() {
if(myFrame)
return myFrame->getFrameAxisActor();
}
delegate2(myFrame, setFrameVisibility, Viewer *, bool)
delegateGet1(myFrame, getFrameVisibility, bool, Viewer *)
bool getFrameVisibility(Viewer * viewer) const {
if(myFrame)
return myFrame->getFrameVisibility(viewer);
}
delegate1(myFrame, addFrameChild, InterfaceFrame *)
delegate1(myFrame, removeFrameChild, InterfaceFrame *)
delegateGet0(myFrame, getDescendantsFrame, QVector<InterfaceFrame *> *)
const QVector<InterfaceFrame *> & getDescendantsFrame() {
if(myFrame)
return myFrame->getDescendantsFrame();
}
delegateGet0(myFrame, getDescendantsFrameName, QVector<QString*> *)
const QVector<QString *> & getDescendantsFrameName() {
if(myFrame)
return myFrame->getDescendantsFrameName();
}
///@}
protected:
/// myGeometry is the 3d representation of this Component, the Component delegates all InterfaceGeometry activity to myGeometry (delegation pattern)
InterfaceGeometry * myGeometry;
......@@ -849,7 +879,7 @@ private:
QString myName;
/** Instanciate the concrete representation (either InterfaceGeometry or InterfaceBitMap) if needed.
* This method have to instanciate Slice (mySlice) or Geometry (myGeometry) that does all the work for this Component, i.e. the adaptee handler.
* This method has to instanciate Slice (mySlice) or Geometry (myGeometry) that does all the work for this Component, i.e. the adaptee handler.
* Generally this method should be called in the Component constructor.
*/
virtual void initRepresentation() = 0;
......
......@@ -34,15 +34,14 @@ using namespace camitk;
int Frame::nbTotalFrames = 0;
// ------------------------- Constructors ------------------------
Frame::Frame(vtkSmartPointer<vtkTransform> transform, Frame *parentFrame)
{
Frame::Frame(vtkSmartPointer<vtkTransform> transform, Frame *parentFrame) {
initAttributes();
if (transform != NULL) {
setTransformFromParent(transform);
}
// setParentFrame(parentFrame);
setParentFrame(parentFrame);
this->parentFrame = parentFrame;
this->transformWorldToMe->Identity();
this->transformWorldToMe->PostMultiply();
......@@ -100,80 +99,74 @@ Frame::~Frame() {
// -----------------* Hierarchy accessors / Modifyers *-----------------
// ------------------- getFrameName ----------------------------------
const QString & Frame::getFrameName()
{
const QString & Frame::getFrameName() const {
return frameName;
}
// ------------------- setFrameName ----------------------------------
void Frame::setFrameName(QString name)
{
void Frame::setFrameName(QString name){
this->frameName = name;
}
// ------------------- getParentFrame ----------------------------------
InterfaceFrame * Frame::getParentFrame()
{
InterfaceFrame * Frame::getParentFrame() const {
return parentFrame;
}
const QVector<InterfaceFrame *> * Frame::getChildrenFrame()
{
return &childrenFrame;
// ------------------- getChildrenFrame ----------------------------------
const QVector<InterfaceFrame *> & Frame::getChildrenFrame() const {
return childrenFrame;
}
// ------------------- getDescendantsFrame ----------------------------------
QVector<InterfaceFrame *> * Frame::getDescendantsFrame() {
QVector<InterfaceFrame *> * result = new QVector<InterfaceFrame *>();
const QVector<InterfaceFrame *> & Frame::getDescendantsFrame() {
descendantsFrame.clear();
foreach(InterfaceFrame * child, childrenFrame) {
result->append(child);
QVector<InterfaceFrame *> * grandChildren = child->getDescendantsFrame();
foreach(InterfaceFrame * grandChild, *grandChildren) {
result->append(grandChild);
descendantsFrame.append(child);
foreach(InterfaceFrame * grandChild, child->getDescendantsFrame()) {
descendantsFrame.append(grandChild);
}
delete grandChildren;
}
return result;
return descendantsFrame;
}
QVector<QString *> * Frame::getDescendantsFrameName() {
QVector<QString *> * result = new QVector<QString *>();
QVector<InterfaceFrame *> * frames = getDescendantsFrame();
foreach(InterfaceFrame * child, *frames) {
result->append((QString * const &)(child->getFrameName()));
// ------------------- getDescendantsFrameName ----------------------------------
const QVector<QString *> & Frame::getDescendantsFrameName() {
descendrantsFrameName.clear();
foreach(InterfaceFrame * child, getDescendantsFrame()) {
descendrantsFrameName.append((QString * const &)(child->getFrameName()));
}
delete frames;
return result;
return descendrantsFrameName;
}
// ------------------- setParentFrame ----------------------------------
void Frame::setParentFrame(InterfaceFrame *parent, bool keepTransform)
{
void Frame::setParentFrame(InterfaceFrame *parent, bool keepTransform) {
InterfaceFrame * checkedParent = parent;
if (checkedParent)
{
if (checkedParent) {
// setParentFrame(this) should not be possible...
// Neither should be setParentFrame from one of my child
QVector<QString *> * descendants = getDescendantsFrameName();
const QVector<QString *> & descendants = getDescendantsFrameName();
if(checkedParent->getFrameName() == getFrameName()) {
checkedParent = NULL;
}
else if(descendants->indexOf((QString * const &)(checkedParent->getFrameName())) != -1){
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);
}
delete descendants;
}
// If we don't keep transform => update it in order for the frame not to move during parent transition
if(!keepTransform)
{
if(!keepTransform) {
vtkSmartPointer<vtkTransform> newParentTransform = NULL;
newParentTransform = getTransformFromFrame(checkedParent);
setTransformFromParent(newParentTransform);
......@@ -183,14 +176,14 @@ void Frame::setParentFrame(InterfaceFrame *parent, bool keepTransform)
if (parentFrame != NULL) {
parentFrame->removeFrameChild(this);
}
this->parentFrame = checkedParent;
this->transformWorldToMe->Identity();
this->transformWorldToMe->PostMultiply();
this->transformWorldToMe->Concatenate(transformParentToMe);
this->transformWorldToMe->Update();
if (this->parentFrame != NULL)
{
if (this->parentFrame != NULL) {
this->transformWorldToMe->Concatenate(this->parentFrame->getTransformFromWorld());
this->transformWorldToMe->Update();
this->parentFrame->addFrameChild(this);
......@@ -199,10 +192,8 @@ void Frame::setParentFrame(InterfaceFrame *parent, bool keepTransform)
}
// ------------------- addFrameChild ----------------------------------
void Frame::addFrameChild(InterfaceFrame * frame)
{
if (! childrenFrame.contains(frame))
{
void Frame::addFrameChild(InterfaceFrame * frame) {
if (! childrenFrame.contains(frame)) {
childrenFrame.append(frame);
}
}
......@@ -214,17 +205,17 @@ void Frame::removeFrameChild(InterfaceFrame * frame) {
}
// -----------------* Transforms accessors / Modifyers *-----------------
// ------------------- getTransformFromWorld ----------------------------------
const vtkSmartPointer<vtkTransform> Frame::getTransformFromWorld() {
const vtkSmartPointer<vtkTransform> Frame::getTransformFromWorld() const {
return transformWorldToMe;
}
// ------------------- getTransformFromParent ----------------------------------
const vtkSmartPointer<vtkTransform> Frame::getTransformFromParent() {
const vtkSmartPointer<vtkTransform> Frame::getTransformFromParent() const {
return transformParentToMe;
}
// ------------------- getTransformFromFrame ----------------------------------
vtkSmartPointer<vtkTransform> Frame::getTransformFromFrame(InterfaceFrame * frame) {
vtkSmartPointer<vtkTransform> Frame::getTransformFromFrame(InterfaceFrame * frame) const {
// World -> Me
vtkSmartPointer<vtkMatrix4x4> worldToMeMatrix = transformWorldToMe->GetMatrix();
......@@ -373,7 +364,7 @@ vtkSmartPointer<vtkAxesActor> Frame::getFrameAxisActor() {
return axes;
}
// ------------------- setFrameVisibility ----------------------------------
void Frame::setFrameVisibility(Viewer * viewer, bool visible) {
QMap<Viewer *, bool>::iterator it = this->frameViewers.find(viewer);
......@@ -386,9 +377,9 @@ void Frame::setFrameVisibility(Viewer * viewer, bool visible) {
}
bool Frame::getFrameVisibility(Viewer * viewer) {
QMap<Viewer *, bool>::iterator it = this->frameViewers.find(viewer);
// ------------------- setFrameVisibility ----------------------------------
bool Frame::getFrameVisibility(Viewer * viewer) const {
QMap<Viewer *, bool>::const_iterator it = this->frameViewers.find(viewer);
if (it == frameViewers.end()) {
return false;
......
......@@ -49,13 +49,13 @@ public:
* @{
*/
/// Get the Frame Unique identifyer (can be set by user)
virtual const QString & getFrameName();
virtual const QString & getFrameName() const;
/// Set the Frame Unique identifyer
virtual void setFrameName(QString name);
/// Get the parent frame
virtual InterfaceFrame * getParentFrame();
virtual InterfaceFrame * getParentFrame() const;
/**
* Set the parent frame to the parameter frame.
......@@ -74,17 +74,17 @@ public:
* Get the Children Frames from the current Frame in the Frame Hierarchy
* The Frame hierarchy may not be the same as the Component Hierarchy.
*/
virtual const QVector<InterfaceFrame *> * getChildrenFrame();
virtual const QVector<InterfaceFrame *> & getChildrenFrame() const;
/// Returns a vector containing the children and the children of children and etc.
/// of the current frame.
virtual QVector<InterfaceFrame *> * getDescendantsFrame();
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 QVector<QString *> * getDescendantsFrameName();
virtual const QVector<QString *> & getDescendantsFrameName();
/** @} */
......@@ -94,19 +94,20 @@ public:
* @{
*/
/// Get a the transformation with respect to the world frame
virtual const vtkSmartPointer<vtkTransform> getTransformFromWorld();
virtual const vtkSmartPointer<vtkTransform> getTransformFromWorld() const;
/// Get a the transformation with respect to the parent frame
virtual const vtkSmartPointer<vtkTransform> getTransformFromParent();
virtual const vtkSmartPointer<vtkTransform> getTransformFromParent() const;
/// Get a COPY of the transformation with respect to another frame
virtual vtkSmartPointer<vtkTransform> getTransformFromFrame(InterfaceFrame * frame);
virtual 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.
*/
virtual void setTransformFromParent(vtkSmartPointer<vtkTransform> transform);
/**
* Sets the current frame position equal to its parent position (to the world position if no parent.
*/
......@@ -148,7 +149,8 @@ public:
/**
* Get the Component Frame visibility for a given viewer
*/
virtual bool getFrameVisibility(Viewer * viewer);
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);
......@@ -202,6 +204,16 @@ protected:
*/
QVector<InterfaceFrame *> childrenFrame;
/**
* @brief List of the frame's descendants.
*/
QVector<InterfaceFrame *> descendantsFrame;
/**
* @brief List of the frame's descendants' name.
*/
QVector<QString *> descendrantsFrameName;
private:
/// To be able to give a default unique identyfier to each created frame
static int nbTotalFrames;
......@@ -212,7 +224,6 @@ private:
/// List of Viewers in which the frame is visible
QMap<Viewer *, bool> frameViewers;
};
}
#endif // FRAME_H
......@@ -66,20 +66,20 @@ class InterfaceFrame {
public:
/// empty virtual destructor, to avoid memory leak
virtual ~InterfaceFrame() {};
virtual ~InterfaceFrame() {}
/**
* Hierarchy accessors / Modifyers
* @{
*/
/// Get the Frame Unique identifyer (can be set by user)
virtual const QString & getFrameName() = 0;
virtual const QString & getFrameName() const = 0;
/// Set the Frame Unique identifyer
virtual void setFrameName(QString name) = 0;
/// Get the parent frame
virtual InterfaceFrame * getParentFrame() = 0;
virtual InterfaceFrame * getParentFrame() const = 0;
/// Set the parent frame and update or not its transform during the parent transition
virtual void setParentFrame(InterfaceFrame * parent, bool keepTransform = true) = 0;
......@@ -88,17 +88,17 @@ public:
* Get the Children Frames from the current Frame in the Frame Hierarchy
* The Frame hierarchy may not be the same as the Component Hierarchy.
*/
virtual const QVector<InterfaceFrame *> * getChildrenFrame() = 0;
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 QVector<InterfaceFrame *> * getDescendantsFrame() = 0;
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 QVector<QString *> * getDescendantsFrameName() = 0;
virtual const QVector<QString *> & getDescendantsFrameName() = 0;
/** @} */
......@@ -107,13 +107,13 @@ public:
* @{
*/
/// Get a the transformation with respect to the world frame
virtual const vtkSmartPointer<vtkTransform> getTransformFromWorld() = 0;
virtual const vtkSmartPointer<vtkTransform> getTransformFromWorld() const = 0;
/// Get a the transformation with respect to the parent frame
virtual const vtkSmartPointer<vtkTransform> getTransformFromParent() = 0;
virtual const vtkSmartPointer<vtkTransform> getTransformFromParent() const = 0;
/// Get a COPY of the transformation with respect to another frame
virtual vtkSmartPointer<vtkTransform> getTransformFromFrame(InterfaceFrame * frame) = 0;
virtual vtkSmartPointer<vtkTransform> getTransformFromFrame(InterfaceFrame * frame) const = 0;
/**
* Sets the current frame position with respect to its parent Frame to
......@@ -161,7 +161,7 @@ public:
/**
* Get the Component Frame visibility for a given viewer
*/
virtual bool getFrameVisibility(Viewer * viewer) = 0;
virtual bool getFrameVisibility(Viewer * viewer) const = 0;
/**
* When the current Frame is set to parent, it must update its children list
......
Markdown is supported
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