OpenDAFF C++ API  v1.7
Directional Audio File Format
Public Member Functions | Protected Member Functions | Friends | List of all members
DAFFViz::SGNode Class Reference

Base class for scene graph nodes. More...

#include <DAFFVizSGNode.h>

Inheritance diagram for DAFFViz::SGNode:
DAFFViz::Arrow DAFFViz::BalloonPlot DAFFViz::CarpetPlot DAFFViz::CartesianCoordinateAssistant DAFFViz::Grid DAFFViz::Label DAFFViz::Line DAFFViz::Plane DAFFViz::Sphere DAFFViz::SphericalCoordinateAssistant DAFFViz::SphericalDirectionIndicator

Public Member Functions

 SGNode (DAFFViz::SGNode *pParentNode=NULL)
 Constructor with optional linking to a parent node. More...
 
virtual ~SGNode ()
 Destructor. More...
 
DAFFViz::SGNodeGetRootNode () const
 Traverses up to the root (recursively) and returns the node pointer. More...
 
DAFFViz::SGNodeGetParentNode () const
 Returns the parent node pointer. More...
 
bool HasParentNode () const
 Returns true if the node is appended to a parent node. More...
 
bool IsRoot () const
 Returns true if the node is a root node (... has no parent node) More...
 
bool HasChildNodes () const
 Returns true if the node combines one or more child nodes. More...
 
bool IsLeaf () const
 Returns true if the node appears as a leaf node (... has no child nodes) More...
 
const DAFFViz::SGNodeGetChildNode (int iIndex) const
 Returns the pointer to the child node of given index (for const correctness) More...
 
DAFFViz::SGNodeGetChildNode (int iIndex)
 Returns the pointer to the child node of given index. More...
 
void GetChildNodes (std::vector< const DAFFViz::SGNode * > &vpChildren) const
 Returns all the pointers to the child nodes (for const correctness, clears vector if no childs available) More...
 
void GetChildNodes (std::vector< DAFFViz::SGNode * > &vpChildren)
 Returns all the pointers to the child nodes (clears vector if no childs available) More...
 
bool AddChildNode (DAFFViz::SGNode *pChild)
 Appends a single child node. More...
 
bool AddChildNodes (const std::vector< DAFFViz::SGNode * > &vpChildren)
 Appends a vector child nodes. More...
 
bool RemoveChildNode (DAFFViz::SGNode *pChild)
 Removes a single child node. More...
 
bool RemoveChildNodes (const std::vector< DAFFViz::SGNode * > &vpChildren)
 Removes a vector of child nodes. More...
 
void GetPosition (double &x, double &y, double &z) const
 Position setter (unit is meter) More...
 
void SetPosition (double x, double y, double z)
 Position getter (unit is meter) More...
 
void GetOrientation (double &dRotXDeg, double &dRotYDeg, double &dRotZDeg) const
 Orientation getter (angles in [°]) More...
 
void SetOrientation (double dRotXDeg, double dRotYDeg, double dRotZDeg)
 Sets the orientation of the node assembly based on world coordinate axis (angles in [°]) More...
 
void SetOrientationYPR (double dYawDeg, double dPitchDeg, double dRollDeg)
 Sets the orientation of the node assembly based on yaw, pitch and roll angles around own coordinate axis (angles in [°]) More...
 
void GetOrientationYPR (double &dYawDeg, double &dPitchDeg, double &dRollDeg)
 Orientation getter of the node assembly based on yaw, pitch and roll angles around own coordinate axis (angles in [°]) More...
 
void SetOrientationVU (double vx, double vy, double vz, double ux, double uy, double uz)
 Sets the orientation of the node assembly based on view- and up-vectors. More...
 
void GetOrientationVU (double &vx, double &vy, double &vz, double &ux, double &uy, double &uz)
 Returns the orientation of the node assembly based on view- and up-vectors. More...
 
void GetScale (double &sx, double &sy, double &sz) const
 Scale getter. More...
 
void SetScale (double sx, double sy, double sz)
 Scale setter. More...
 
virtual void SetVisible (bool bVisible)
 Set visibility. More...
 
virtual bool IsVisible () const
 Returns true if the node is visible. More...
 

Protected Member Functions

void AddActor (vtkSmartPointer< vtkActor > pActor)
 Add a VTK actor to the node. More...
 
void RemoveActor (vtkSmartPointer< vtkActor > pActor)
 Remove a VTK actor from the assembly of the node. More...
 
void AddAssembly (vtkSmartPointer< vtkAssembly > pAssembly)
 Add a VTK assembly to the node. More...
 
void RemoveAssembly (vtkSmartPointer< vtkAssembly > pAssembly)
 Release an assembly from the assembly of the node. More...
 
virtual void OnSetFollowerCamera (vtkSmartPointer< vtkCamera > pCamera)
 Set active camera for followers. More...
 

Friends

class VTKDAFFVizWindow
 
class QDAFFVTKWidget
 
class QtDAFFVizTestWindow
 

Detailed Description

Base class for scene graph nodes.

This class defines the base class for all nodes within an DAFFViz scene graph. It implements basic functionality, like the scene graph tree and operations. Internally it projects the DAFFViz scene graph onto a matching VTK scene assembly making it possible to use VTK objects in the classical scene graph way. DAFFViz includes subclasses for common objects (cube, cylinder, sphere and so on). But the SGNode design is flexible to incorporate any VTK object into the DAFFViz hierarchy.

The tree operations include modification of the scene graph (adding/removing child nodes, traversal, etc.). Moreover each node implements a common set of transformation operations (translation, rotation, scaling), which is applicable to all node implementations.

The usage of a node in your tree structure has strict rules. Any scene graph node may only be member of one parent scene graph. Therefore each scene graph node has a defined identity and may not be cloned/copied during runtime.

Any transformation on a node will treat the subtree (if node has child nodes) as a fixed single object. For instance you want to create a table, then you might want to join the desktop and the legs to form a simple table which then can be placed and rotated within the scene as one object.

Nodes that only group other nodes does not have material properties, e.g. no color. You have to colorize the leaf nodes which as a rule are derived objects of the SGNode class. Those leaves implement the appearing objects like cubes, cylinders and so on.

If you want to use the scene graph tree, you normally do it like this: Create a scene root node. Add children like primitive objects or create your own node by copying from the provided classes and fabricate any geometric that is possible with VTK. You can also group DAFFViz primitive objects to form a more complicated construction and append this to your scene graph root or any subtree. At the very end you will apply the scene graph root to your DAFFViz::QtDAFFWidget which will render your own scene and display it in your Qt application.

Definition at line 67 of file DAFFVizSGNode.h.

Constructor & Destructor Documentation

DAFFViz::SGNode::SGNode ( DAFFViz::SGNode pParentNode = NULL)

Constructor with optional linking to a parent node.

Generates a node and connects it with the given parent node [optional]

Parameters
[in]pParentNodeParent scene graph node of this child

Definition at line 18 of file DAFFVizSGNode.cpp.

DAFFViz::SGNode::~SGNode ( )
virtual

Destructor.

Note
This destructor automatically frees all objects within its subtree.

Definition at line 27 of file DAFFVizSGNode.cpp.

Member Function Documentation

void DAFFViz::SGNode::AddActor ( vtkSmartPointer< vtkActor >  pActor)
protected

Add a VTK actor to the node.

Will assert if the pointer is NULL in debug mode.

Parameters
[in]pActorPointer to VTK actor

Definition at line 505 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::AddAssembly ( vtkSmartPointer< vtkAssembly >  pAssembly)
protected

Add a VTK assembly to the node.

Will assert if the pointer is NULL in debug mode.

Parameters
[in]pAssemblyPointer to VTK assembly

Definition at line 524 of file DAFFVizSGNode.cpp.

bool DAFFViz::SGNode::AddChildNode ( DAFFViz::SGNode pChild)

Appends a single child node.

Will return true if successful, false if the given Child is not a root node.

Parameters
[in]pChildAdds a child to this node
Returns
True, if possible, false, if child node already has a parent (is not a root node)
See also
isRoot() hasParentNode()

Definition at line 129 of file DAFFVizSGNode.cpp.

bool DAFFViz::SGNode::AddChildNodes ( const std::vector< DAFFViz::SGNode * > &  vpChildren)

Appends a vector child nodes.

Will return true if successful, false if any given Child is not a root node, though it will continue appending the other given nodes.

Parameters
[in]vpChildrenAdds the children to this node
Returns
True, if possible for all, false, if any child node already has a parent (is not a root node)
See also
isRoot() hasParentNode()

Definition at line 164 of file DAFFVizSGNode.cpp.

const DAFFViz::SGNode * DAFFViz::SGNode::GetChildNode ( int  iIndex) const

Returns the pointer to the child node of given index (for const correctness)

Parameters
[in]iIndexIndex number of child node
Returns
Const pointer to child node

Definition at line 86 of file DAFFVizSGNode.cpp.

DAFFViz::SGNode * DAFFViz::SGNode::GetChildNode ( int  iIndex)

Returns the pointer to the child node of given index.

Parameters
[in]iIndexIndex number of child node
Returns
Pointer to child node

Definition at line 96 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::GetChildNodes ( std::vector< const DAFFViz::SGNode * > &  vpChildren) const

Returns all the pointers to the child nodes (for const correctness, clears vector if no childs available)

Parameters
[out]vpChildrenVector of const pointers to child nodes

Definition at line 106 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::GetChildNodes ( std::vector< DAFFViz::SGNode * > &  vpChildren)

Returns all the pointers to the child nodes (clears vector if no childs available)

Parameters
[out]vpChildrenVector of pointers to child nodes

Definition at line 118 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::GetOrientation ( double &  dRotXDeg,
double &  dRotYDeg,
double &  dRotZDeg 
) const

Orientation getter (angles in [°])

Corresponds to euler angles with first rotation around z axis, then x, then y. Orientations are right-handed.

Parameters
[out]dRotXDegX axis rotation value
[out]dRotYDegY axis rotation value
[out]dRotZDegZ axis rotation value
See also
SetOrientation()

Definition at line 214 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::GetOrientationVU ( double &  vx,
double &  vy,
double &  vz,
double &  ux,
double &  uy,
double &  uz 
)

Returns the orientation of the node assembly based on view- and up-vectors.

Parameters
[out]vxX axis view vector value
[out]vyY axis view vector value
[out]vzZ axis view vector value
[out]uxX axis up vector value
[out]uyY axis up vector value
[out]uzZ axis up vector value
See also
SetOrientationVU()

Definition at line 367 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::GetOrientationYPR ( double &  dYawDeg,
double &  dPitchDeg,
double &  dRollDeg 
)

Orientation getter of the node assembly based on yaw, pitch and roll angles around own coordinate axis (angles in [°])

Will first rotate around -z axis (roll), then x (pitch), then y (yaw)

Parameters
[out]dYawDegYaw rotation value(first rotation around Y)
[out]dPitchDegPitch rotation value(first rotation around X)
[out]dRollDegRoll rotation value(first rotation around - Z)
See also
SetOrientationYPR()

Definition at line 405 of file DAFFVizSGNode.cpp.

DAFFViz::SGNode * DAFFViz::SGNode::GetParentNode ( ) const

Returns the parent node pointer.

Returns
Parent scene graph node pointer, NULL if root node
See also
HasParentNode()

Definition at line 61 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::GetPosition ( double &  x,
double &  y,
double &  z 
) const

Position setter (unit is meter)

Parameters
[out]xX axis value
[out]yY axis value
[out]zZ axis value
See also
SetPosition()

Definition at line 198 of file DAFFVizSGNode.cpp.

DAFFViz::SGNode * DAFFViz::SGNode::GetRootNode ( ) const

Traverses up to the root (recursively) and returns the node pointer.

Returns
Root scene graph node pointer

Definition at line 55 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::GetScale ( double &  sx,
double &  sy,
double &  sz 
) const

Scale getter.

Parameters
[out]sxX axis scale value
[out]syY axis scale value
[out]szZ axis scale value
See also
SetScale()

Definition at line 471 of file DAFFVizSGNode.cpp.

bool DAFFViz::SGNode::HasChildNodes ( ) const

Returns true if the node combines one or more child nodes.

Returns
True, if node has child nodes (is not a leaf node)

Definition at line 76 of file DAFFVizSGNode.cpp.

bool DAFFViz::SGNode::HasParentNode ( ) const

Returns true if the node is appended to a parent node.

Returns
True, if node has a parent (is not a root node)

Definition at line 66 of file DAFFVizSGNode.cpp.

bool DAFFViz::SGNode::IsLeaf ( ) const

Returns true if the node appears as a leaf node (... has no child nodes)

Returns
True, if node is a leaf nodes (has no child nodes)

Definition at line 81 of file DAFFVizSGNode.cpp.

bool DAFFViz::SGNode::IsRoot ( ) const

Returns true if the node is a root node (... has no parent node)

Returns
True, if node is a root node (has no parent)

Definition at line 71 of file DAFFVizSGNode.cpp.

bool DAFFViz::SGNode::IsVisible ( ) const
virtual

Returns true if the node is visible.

If this node is visible, the method will return true. Note, that this does not actually mean, that the child nodes are visible, too.

Returns
True if visible, false if hidden
See also
SetVisible()

Reimplemented in DAFFViz::Arrow, DAFFViz::Sphere, DAFFViz::Line, DAFFViz::Label, DAFFViz::Plane, and DAFFViz::Grid.

Definition at line 486 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::OnSetFollowerCamera ( vtkSmartPointer< vtkCamera >  pCamera)
protectedvirtual

Set active camera for followers.

Parameters
[in]pCameraVTK camera followers shall face

Definition at line 542 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::RemoveActor ( vtkSmartPointer< vtkActor >  pActor)
protected

Remove a VTK actor from the assembly of the node.

Will assert if the pointer is NULL in debug mode.

Parameters
[in]pActorPointer to VTK actor

Definition at line 514 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::RemoveAssembly ( vtkSmartPointer< vtkAssembly >  pAssembly)
protected

Release an assembly from the assembly of the node.

Will assert if the pointer is NULL in debug mode.

Parameters
[in]pAssemblyPointer to VTK assembly

Definition at line 533 of file DAFFVizSGNode.cpp.

bool DAFFViz::SGNode::RemoveChildNode ( DAFFViz::SGNode pChild)

Removes a single child node.

Will return true if successful, false if the given child node is non existent.

Parameters
[in]pChildChild node to be removed
Returns
True on success, false if child is not existent.

Definition at line 171 of file DAFFVizSGNode.cpp.

bool DAFFViz::SGNode::RemoveChildNodes ( const std::vector< DAFFViz::SGNode * > &  vpChildren)

Removes a vector of child nodes.

Will return true if successful, false if any given child node is non existent, though it will continue removing the other given nodes.

Parameters
[in]vpChildrenVector of child nodes to be removed
Returns
True on success for all, false if any child is not existent.

Definition at line 191 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::SetOrientation ( double  dRotXDeg,
double  dRotYDeg,
double  dRotZDeg 
)

Sets the orientation of the node assembly based on world coordinate axis (angles in [°])

Will first rotate around z axis, then x, then y. Orientations are right-handed.

Parameters
[in]dRotXDegX axis rotation value
[in]dRotYDegY axis rotation value
[in]dRotZDegZ axis rotation value
See also
GetOrientation()

Definition at line 222 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::SetOrientationVU ( double  vx,
double  vy,
double  vz,
double  ux,
double  uy,
double  uz 
)

Sets the orientation of the node assembly based on view- and up-vectors.

Parameters
[in]vxX axis view vector value
[in]vyY axis view vector value
[in]vzZ axis view vector value
[in]uxX axis up vector value
[in]uyY axis up vector value
[in]uzZ axis up vector value
See also
GetOrientationVU()

Definition at line 316 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::SetOrientationYPR ( double  dYawDeg,
double  dPitchDeg,
double  dRollDeg 
)

Sets the orientation of the node assembly based on yaw, pitch and roll angles around own coordinate axis (angles in [°])

Will first rotate around -z axis (roll), then x (pitch), then y (yaw)

Parameters
[in]dYawDegYaw rotation value (first rotation around Y)
[in]dPitchDegPitch rotation value (first rotation around X)
[in]dRollDegRoll rotation value (first rotation around -Z)
See also
GetOrientationYPR()

Definition at line 230 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::SetPosition ( double  x,
double  y,
double  z 
)

Position getter (unit is meter)

Parameters
[in]xX axis value
[in]yY axis value
[in]zZ axis value
See also
GetPosition()

Definition at line 206 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::SetScale ( double  sx,
double  sy,
double  sz 
)

Scale setter.

Parameters
[in]sxX axis scale value
[in]syY axis scale value
[in]szZ axis scale value
See also
SetScale()

Definition at line 479 of file DAFFVizSGNode.cpp.

void DAFFViz::SGNode::SetVisible ( bool  bVisible)
virtual

Set visibility.

The method will traverse the subtree and set the visibility of all nodes. If you want to hide a leaf node or a subtree, you have to manually hide it afterwards.

Parameters
[in]bVisibleTrue for visible, false for hidden
See also
IsVisible()

Reimplemented in DAFFViz::Arrow, DAFFViz::CartesianCoordinateAssistant, DAFFViz::SphericalCoordinateAssistant, DAFFViz::Sphere, DAFFViz::Line, DAFFViz::Label, DAFFViz::Plane, and DAFFViz::Grid.

Definition at line 491 of file DAFFVizSGNode.cpp.

Friends And Related Function Documentation

friend class QDAFFVTKWidget
friend

Definition at line 401 of file DAFFVizSGNode.h.

friend class QtDAFFVizTestWindow
friend

Definition at line 402 of file DAFFVizSGNode.h.

friend class VTKDAFFVizWindow
friend

Definition at line 400 of file DAFFVizSGNode.h.


The documentation for this class was generated from the following files:
OpenDAFF is a project from the Institute of Technical Acoustics, RWTH Aachen University, Germany.