Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | List of all members
camitk::InterfaceNode Class Reference

This class describe what are the methods to implement for a hierarchical tree node. More...

#include <InterfaceNode.h>

+ Inheritance diagram for camitk::InterfaceNode:

Public Member Functions

virtual void addChild (InterfaceNode *)=0
 add a child Component (sub item in the hierarchy), and modify the child's parent to be equal to this instance
virtual void attachChild (InterfaceNode *)=0
 add a child Component (but leave its parent unchanged)
virtual void deleteChildren ()=0
 delete all sub Component, but do not delete the pointer (only the top-level component has the right to do that)
virtual bool doubleClicked ()=0
 this method is called each time the InterfaceNode is double clicked by the user.
virtual const ComponentListgetChildren ()=0
 get the list of the InterfaceNode children (sub items in the hierarchy)
virtual QPixmap getIcon ()=0
 Get the pixmap that will be displayed for this node.
virtual QString getName () const =0
 get the name to be displayed
virtual InterfaceNodegetParent ()=0
 get the parent Component
virtual QMenu * getPopupMenu (QWidget *parent=0)=0
 get the popup menu to display (or NULL if inexistant)
virtual bool inItalic () const =0
 should the name be displayed in italic?
virtual void removeChild (InterfaceNode *)=0
 remove a sub Component (only the top-level component has the right to do that)
virtual void setName (const QString &)=0
 set the name to be displayed
virtual void setParent (InterfaceNode *)=0
 set the parent Component
virtual ~InterfaceNode ()
 empty virtual destructor, to avoid memory leak

Detailed Description

This class describe what are the methods to implement for a hierarchical tree node.

An InterfaceNode can only have one parent, even if it is a child of more than one InterfaceNodes.

Consequence: an InterfaceNode can be present many times in the hierarchy, but can only depends from one parent. To add an InterfaceNode as a child and change its parent to this use addChild(). To add an InterfaceNode as a child without modifying its parent, use attachChild().

This class defines an "interface" (in the OOP/java meaning of the term). See the introduction of GoF: "Program to an interface, not an implementation." To see what Erich Gamma has to say about it: http://www.artima.com/lejava/articles/designprinciplesP.html To see what Bjarne Stroustrup has to say about it: http://www.artima.com/intv/modern.html

Constructor & Destructor Documentation

virtual camitk::InterfaceNode::~InterfaceNode ( )
inlinevirtual

empty virtual destructor, to avoid memory leak

Member Function Documentation

virtual void camitk::InterfaceNode::addChild ( InterfaceNode )
pure virtual

add a child Component (sub item in the hierarchy), and modify the child's parent to be equal to this instance

Implemented in camitk::Component, StructuralComponentDC, and MultiComponentDC.

virtual void camitk::InterfaceNode::attachChild ( InterfaceNode )
pure virtual

add a child Component (but leave its parent unchanged)

Implemented in camitk::Component.

virtual void camitk::InterfaceNode::deleteChildren ( )
pure virtual

delete all sub Component, but do not delete the pointer (only the top-level component has the right to do that)

Implemented in camitk::Component, and ComponentDC.

virtual bool camitk::InterfaceNode::doubleClicked ( )
pure virtual

this method is called each time the InterfaceNode is double clicked by the user.

Returns
a boolean telling if there was modification made in the Component due to this double click

Implemented in camitk::Component, and AtomDC.

virtual const ComponentList& camitk::InterfaceNode::getChildren ( )
pure virtual

get the list of the InterfaceNode children (sub items in the hierarchy)

Implemented in camitk::Component.

virtual QPixmap camitk::InterfaceNode::getIcon ( )
pure virtual

Get the pixmap that will be displayed for this node.

If you want your component to have a nice pixmap displayed in the explorer, for example, you just need to
1. declare a new static member and redefines the getIcon() method (in MyComponent.h):
@code 

public: virtual QPixmap getIcon(); private: static QPixmap * myPixmap; // declare a ptr here (it is static for optimization)

  1. add these lines in your code (in MyComponent.cpp):
    // use this two lines or better use a Qt resource bundle (recommanded!)
    #include "myComponent_pixmap.xpm" // include the pixmap resource file or use a Qt resource bundle
    QPixmap * MyComponent::myPixmap = NULL; // static initialization
    // check if the class instance was already used somewhere
    if (!myPixmap) {
    // create the pixmap from the data like this (or using the Qt resource bundle, see Qt documentation)
    myPixmap = new QPixmap(myComponent_pixmap); // myComponent_pixmap is the name of the char[] found in the .xpm file
    }
    // return the object (not the pointer
    return (*myPixmap);
    }
    And that all folks! A nice icon will be now used to display your component!
Note
Recommanded pixmap size is 20x20 (not nice, but efficient)...

Implemented in camitk::Component, PMManagerDC, StructuralComponentDC, AtomDC, VtkMeshComponent, MultiComponentDC, and CellDC.

virtual QString camitk::InterfaceNode::getName ( ) const
pure virtual

get the name to be displayed

Implemented in camitk::Component.

virtual InterfaceNode* camitk::InterfaceNode::getParent ( )
pure virtual

get the parent Component

Implemented in camitk::Component.

virtual QMenu* camitk::InterfaceNode::getPopupMenu ( QWidget *  parent = 0)
pure virtual

get the popup menu to display (or NULL if inexistant)

Implemented in camitk::Component, StructuralComponentDC, PMManagerDC, AtomDC, MMLComponent, VtkMeshComponent, and MultiComponentDC.

virtual bool camitk::InterfaceNode::inItalic ( ) const
pure virtual

should the name be displayed in italic?

Implemented in camitk::Component.

virtual void camitk::InterfaceNode::removeChild ( InterfaceNode )
pure virtual

remove a sub Component (only the top-level component has the right to do that)

Implemented in camitk::Component, StructuralComponentDC, and MultiComponentDC.

Referenced by camitk::Component::setParent().

virtual void camitk::InterfaceNode::setName ( const QString &  )
pure virtual

set the name to be displayed

Implemented in camitk::Component, PMManagerDC, AtomDC, ComponentDC, and CellDC.

virtual void camitk::InterfaceNode::setParent ( InterfaceNode )
pure virtual

The documentation for this class was generated from the following file: