ACG::SceneGraph::BaseNode Class Reference

#include <ACG/Scenegraph/BaseNode.hh>

Inheritance diagram for ACG::SceneGraph::BaseNode:
Inheritance graph
[legend]
Collaboration diagram for ACG::SceneGraph::BaseNode:
Collaboration graph
[legend]

List of all members.

Public Types

enum  StatusMode { Active = 0x1, HideNode = 0x2, HideChildren = 0x4, HideSubtree = 0x8 }
 

Status modi.

More...
enum  TraverseMode { NodeFirst = 0x1, ChildrenFirst = 0x2, SecondPass = 0x4 }
 

Node traverse types.

More...
typedef std::list< BaseNode * >
::const_iterator 
ConstChildIter
 allows to iterate over children
typedef std::list< BaseNode * >
::iterator 
ChildIter
 allows to iterate over children
typedef std::list< BaseNode * >
::const_reverse_iterator 
ConstChildRIter
 allows to reverse iterate over children
typedef std::list< BaseNode * >
::reverse_iterator 
ChildRIter
 allows to reverse iterate over children

Public Member Functions

 BaseNode (BaseNode *_parent=0, std::string _name="<unknown>")
 Default constructor.
 BaseNode (BaseNode *_parent, BaseNode *_child, std::string _name="<unknown>")
 Put this node between _parent and _child.
virtual ~BaseNode ()
 Destructor.
void delete_subtree ()
 Delete the whole subtree of this node.
virtual const std::string & className () const =0
 Return class name (implemented by the ACG_CLASSNAME macro).
virtual unsigned int availableDrawModes () const
virtual void boundingBox (Vec3f &, Vec3f &)
virtual void enter (GLState &, unsigned int)
virtual void draw (GLState &, unsigned int)
virtual void leave (GLState &, unsigned int)
virtual void enterPick (GLState &_state, PickTarget _target, unsigned int _drawMode)
virtual void pick (GLState &, PickTarget)
virtual void leavePick (GLState &_state, PickTarget _target, unsigned int _drawMode)
void enablePicking (bool _enable)
bool pickingEnabled ()
virtual void mouseEvent (GLState &, QMouseEvent *)
 Handle mouse event (some interaction, e.g. modeling).
GLenum depthFunc () const
 get glDepthFunc() parameter
void depthFunc (GLenum _func)
 set glDepthFunc parameter (it's GL_LESS by default)
void setDirty (bool _dirty=true)
 mark node for redrawn
bool isDirty () const
 Check if node should be redrawn.
ChildIter childrenBegin ()
 Returns: begin-iterator of children.
ConstChildIter childrenBegin () const
 Same but cont.
ChildIter childrenEnd ()
 Returns: end-iterator of children.
ConstChildIter childrenEnd () const
 Same but const.
ChildRIter childrenRBegin ()
 Returns: reverse begin-iterator of children.
ConstChildRIter childrenRBegin () const
 Same but const.
ChildRIter childrenREnd ()
 Returns: reverse end-iterator of children.
ConstChildRIter childrenREnd () const
 Same but const.
void push_back (BaseNode *_node)
 Insert _node at the end of the list of children.
void remove (ChildIter _pos)
unsigned int nChildren () const
 number of children
ChildIter find (BaseNode *_node)
BaseNodefind (const std::string &_name)
BaseNodeparent ()
 Get the nodes parent node.
void set_parent (BaseNode *_parent)
 Set the parent of this node.
StatusMode status () const
 Get node's status.
void set_status (StatusMode _s)
 Set the status of this node.
void hide ()
 Hide Node: set status to HideNode.
void show ()
 Show node: set status to Active.
bool visible ()
 Is node visible (status == Active)?
bool hidden ()
 Is node not visible (status != Active)?
std::string name () const
 Returns: name of node (needs not be unique).
void name (const std::string &_name)
 rename a node
unsigned int id () const
unsigned int drawMode () const
 Return the own draw modes of this node.
void drawMode (unsigned int _drawMode)
unsigned int traverseMode () const
 Return how the node should be traversed.
void setTraverseMode (unsigned int _mode)
 Set traverse mode for node.

Private Member Functions

 BaseNode (const BaseNode &)
 Copy constructor. Disabled.
void operator= (const BaseNode &)
 Assigment operator. Disabled.

Private Attributes

BaseNodeparent_
 pointer to parent node
std::string name_
 name of node
StatusMode status_
 node status()
std::list< BaseNode * > children_
 list of children
unsigned int id_
 ID of node.
unsigned int drawMode_
 private draw mode
GLenum depth_func_
 depth func
bool pickingEnabled_
bool dirty_
 Flag indicating that the node has to be redrawn.
unsigned int traverseMode_
 traverse mode

Static Private Attributes

static unsigned int last_id_used__ = 0
 used to provide unique IDs to nodes

Detailed Description

This is the base for all scenegraph nodes. All virtual functions should be reimplemented when inheriting from this class.

Definition at line 118 of file BaseNode.hh.


Member Enumeration Documentation

Status modi.

Enumerator:
Active 

Draw node & children.

HideNode 

Hide this node, but draw children.

HideChildren 

Draw this node, but hide children.

HideSubtree 

Hide this node and its children.

Definition at line 327 of file BaseNode.hh.

Node traverse types.

Enumerator:
NodeFirst 

Execute action on node first and then on its children.

ChildrenFirst 

Execute action the children first and then on this node.

SecondPass 

Draw node in second pass.

Definition at line 376 of file BaseNode.hh.


Member Function Documentation

virtual unsigned int ACG::SceneGraph::BaseNode::availableDrawModes (  )  const [inline, virtual]
virtual void ACG::SceneGraph::BaseNode::boundingBox ( Vec3f &  ,
Vec3f &   
) [inline, virtual]
void ACG::SceneGraph::BaseNode::delete_subtree (  ) 

Delete the whole subtree of this node.

This function will remove the whole subtree below this node. All children in this nodes bubtree will be automatically removed from the tree and their destructor is called. The node itself will be removed from the list of its parents children. Afterwards it will also call its own destructor.

Definition at line 162 of file BaseNode.cc.

References children_.

Referenced by BaseObjectData::cleanup(), and BaseObjectData::~BaseObjectData().

virtual void ACG::SceneGraph::BaseNode::draw ( GLState ,
unsigned int   
) [inline, virtual]
void ACG::SceneGraph::BaseNode::drawMode ( unsigned int  _drawMode  )  [inline]

Set this node's own draw mode. It will be used for drawing instead of the the global draw mode.

Definition at line 371 of file BaseNode.hh.

void ACG::SceneGraph::BaseNode::enablePicking ( bool  _enable  )  [inline]

Enable or Disable picking for this node ( default: enabled )

Definition at line 199 of file BaseNode.hh.

Referenced by PlaneObject::enablePicking(), and MeshObject< MeshT, objectDataType >::enablePicking().

virtual void ACG::SceneGraph::BaseNode::enter ( GLState ,
unsigned int   
) [inline, virtual]

This function is called when traversing the scene graph and arriving at this node. It can be used to store GL states that will be changed in order to restore then in the leave() function.

See also:
MaterialNode

Reimplemented in ACG::SceneGraph::CartesianClippingNode, ACG::SceneGraph::ClippingNode, ACG::SceneGraph::EnvMapNode, ACG::SceneGraph::LightSourceNode, ACG::SceneGraph::Material2Node, ACG::SceneGraph::MaterialNode, ACG::SceneGraph::ShaderNode, ACG::SceneGraph::StencilRefNode, ACG::SceneGraph::Texture3DNode, ACG::SceneGraph::TextureNode, and ACG::SceneGraph::TransformNode.

Definition at line 165 of file BaseNode.hh.

Referenced by enterPick().

void ACG::SceneGraph::BaseNode::enterPick ( GLState _state,
PickTarget  _target,
unsigned int  _drawMode 
) [virtual]

This function is called when traversing the scene graph during picking and arriving at this node. It can be used to store GL states that will be changed in order to restore then in the leavePick() function. Its default implementation will call the enter() function.

Reimplemented in ACG::SceneGraph::EnvMapNode, ACG::SceneGraph::MaterialNode, ACG::SceneGraph::ShaderNode, ACG::SceneGraph::StencilRefNode, and ACG::SceneGraph::TextureNode.

Definition at line 172 of file BaseNode.cc.

References enter().

BaseNode* ACG::SceneGraph::BaseNode::find ( const std::string &  _name  )  [inline]

Find a node of a given name

Definition at line 296 of file BaseNode.hh.

ChildIter ACG::SceneGraph::BaseNode::find ( BaseNode _node  )  [inline]

Find a specific node in the list of children.
This method is designed to convert a node pointer to an iterator that may be used e.g. for insert()'ing a new node at a distinct position.
Returns childrenEnd() if no appropriate node is found.

Definition at line 287 of file BaseNode.hh.

Referenced by set_parent(), CoreWidget::slotCoordSysVisibility(), CoreWidget::updatePopupMenuBackground(), and ~BaseNode().

unsigned int ACG::SceneGraph::BaseNode::id (  )  const [inline]

Get unique ID of node. IDs are always positive and may be used e.g. for picking.

Definition at line 361 of file BaseNode.hh.

Referenced by PlaneObject::picked(), MeshObject< MeshT, objectDataType >::picked(), and CoreWidget::updatePopupMenuNode().

virtual void ACG::SceneGraph::BaseNode::leave ( GLState ,
unsigned int   
) [inline, virtual]
void ACG::SceneGraph::BaseNode::leavePick ( GLState _state,
PickTarget  _target,
unsigned int  _drawMode 
) [virtual]

The leavePick function is used to restore GL states the have been changed. This function must restore the status before enterPick() ! Its default implementation will call the leave() function.

Reimplemented in ACG::SceneGraph::EnvMapNode, ACG::SceneGraph::MaterialNode, ACG::SceneGraph::ShaderNode, ACG::SceneGraph::StencilRefNode, and ACG::SceneGraph::TextureNode.

Definition at line 180 of file BaseNode.cc.

References leave().

virtual void ACG::SceneGraph::BaseNode::pick ( GLState ,
PickTarget   
) [inline, virtual]
bool ACG::SceneGraph::BaseNode::pickingEnabled (  )  [inline]

Check if picking is enabled for this node

Definition at line 203 of file BaseNode.hh.

Referenced by PlaneObject::pickingEnabled(), and MeshObject< MeshT, objectDataType >::pickingEnabled().

void ACG::SceneGraph::BaseNode::remove ( ChildIter  _pos  )  [inline]

Remove child node at position _pos. This _pos must be reachable from childrenBegin().
This method has no effect if called with childrenEnd() as parameter.

Definition at line 271 of file BaseNode.hh.

Referenced by set_parent(), and ~BaseNode().

void ACG::SceneGraph::BaseNode::set_parent ( BaseNode _parent  ) 

Set the parent of this node.

This function will remove this node from its original parents children, if the parent exists. And will add it to the new parents children.

Definition at line 138 of file BaseNode.cc.

References childrenEnd(), find(), parent_, push_back(), and remove().

Referenced by BaseNode().


Member Data Documentation

Flag indicating if picking should be done for this object This flag has to be checked by your node if you implement picking

Definition at line 427 of file BaseNode.hh.


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

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .