scg3  0.6
scg::Node Class Referenceabstract

Base class for all nodes (composite pattern, abstract). More...

#include "Node.h"

Inheritance diagram for scg::Node:
[legend]
Collaboration diagram for scg::Node:
[legend]

Public Member Functions

 Node ()
 
virtual ~Node ()=0
 
virtual void clear ()
 
virtual void destroy ()
 
int getNCores () const
 
const std::string & getMetaInfo (const std::string &key) const
 
void setMetaInfo (const std::string &key, const std::string &value)
 
bool isVisible () const
 
void setVisible (bool isVisible=true)
 
virtual void traverse (Traverser *traverser)=0
 
virtual void accept (Traverser *traverser)
 
virtual void render (RenderState *renderState)
 

Protected Member Functions

void addSibling_ (NodeSP sibling)
 
void removeSibling_ (Node *node, bool &result)
 
void processCores_ (RenderState *renderState)
 
void postProcessCores_ (RenderState *renderState)
 

Protected Attributes

NodeSP rightSibling_
 
Compositeparent_
 
std::vector< CoreSPcores_
 
bool isVisible_
 
std::unordered_map< std::string, std::string > metaInfo_
 

Friends

class Composite
 

Detailed Description

Base class for all nodes (composite pattern, abstract).

The node tree of the scene graph is organized as a left-child right-sibling tree. While all nodes may have siblings and a parent, only composite nodes may have children (cf. Composite). Certain nodes may possess one or several cores (cf. Core).

Note: When the node is rendered, its cores are procesed in the order they have been added to the node.

Definition at line 47 of file Node.h.

Constructor & Destructor Documentation

◆ Node()

scg::Node::Node ( )

Constructor.

◆ ~Node()

virtual scg::Node::~Node ( )
pure virtual

Destructor.

Member Function Documentation

◆ accept()

virtual void scg::Node::accept ( Traverser traverser)
virtual

Accept traverser (visitor pattern).

Reimplemented in scg::Camera, scg::Light, scg::Transformation, scg::Shape, scg::LightPosition, and scg::Group.

◆ addSibling_()

void scg::Node::addSibling_ ( NodeSP  sibling)
protected

Add sibling to this node, i.e., child to its parent (recursively). Called by Composite::addChild().

◆ clear()

virtual void scg::Node::clear ( )
virtual

Clear node data.

◆ destroy()

virtual void scg::Node::destroy ( )
virtual

Remove node from scene graph, clear node data.

Reimplemented in scg::Composite.

◆ getMetaInfo()

const std::string& scg::Node::getMetaInfo ( const std::string &  key) const

Get meta-information value for a given key.

Parameters
keykey to search for
Returns
value for the key or an empty string if there is no such key

◆ getNCores()

int scg::Node::getNCores ( ) const

Get number of cores associated with this node.

◆ isVisible()

bool scg::Node::isVisible ( ) const

Check if node is visible.

◆ postProcessCores_()

void scg::Node::postProcessCores_ ( RenderState renderState)
protected

Post-process node cores by calling their renderPost() methods, accessing vector from last to first element.

◆ processCores_()

void scg::Node::processCores_ ( RenderState renderState)
protected

Process node cores by calling their render() methods, accessing vector from first to last element.

◆ removeSibling_()

void scg::Node::removeSibling_ ( Node node,
bool &  result 
)
protected

Remove sibling from this node, i.e., child from its parent (recursively). Called by Composite::removeChild().

Parameters
nodepointer to node to be removed
resulttrue if node has been found and removed

◆ render()

virtual void scg::Node::render ( RenderState renderState)
virtual

◆ setMetaInfo()

void scg::Node::setMetaInfo ( const std::string &  key,
const std::string &  value 
)

Set meta-information as key-value pair.

Parameters
keykey; if there is already a key with that name, the value is overwritten
valuevalue for the key

◆ setVisible()

void scg::Node::setVisible ( bool  isVisible = true)

Set visibility of this node.

◆ traverse()

virtual void scg::Node::traverse ( Traverser traverser)
pure virtual

Traverse node tree (depth-first, pre-order) with given traverser.

Implemented in scg::Composite, and scg::Leaf.

Friends And Related Function Documentation

◆ Composite

friend class Composite
friend

Definition at line 49 of file Node.h.

Member Data Documentation

◆ cores_

std::vector<CoreSP> scg::Node::cores_
protected

Definition at line 149 of file Node.h.

◆ isVisible_

bool scg::Node::isVisible_
protected

Definition at line 150 of file Node.h.

◆ metaInfo_

std::unordered_map<std::string, std::string> scg::Node::metaInfo_
mutableprotected

Definition at line 151 of file Node.h.

◆ parent_

Composite* scg::Node::parent_
protected

Definition at line 148 of file Node.h.

◆ rightSibling_

NodeSP scg::Node::rightSibling_
protected

Definition at line 147 of file Node.h.


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