V-ART
scenenode.h
Go to the documentation of this file.
1 
5 #ifndef VART_SCENENODE_H
6 #define VART_SCENENODE_H
7 
8 #include "vart/memoryobj.h"
9 #include <list>
10 #include <string>
11 #include <iostream> // for XmlPrintOn
12 
13 namespace VART {
14  class SGPath;
15  class SNOperator;
16  class SNLocator;
25  class SceneNode : public MemoryObj {
26  public:
27  // PUBLIC TYPES
34  // PUBLIC METHODS
36  SceneNode();
37  SceneNode(SceneNode& node);
38  virtual ~SceneNode();
39  SceneNode& operator=(const SceneNode& node);
40 
43  virtual SceneNode* Copy() = 0;
44 
47  virtual SceneNode* RecursiveCopy();
48 
50  const std::string& GetDescription() const { return description; }
51 
53  void SetDescription(const std::string& desc) { description = desc; }
54 
56  void AddChild(SceneNode& child);
57 
63  bool DetachChild(SceneNode* childPtr);
64 
67  virtual bool DrawOGL() const;
68 
73  virtual void DrawForPicking() const = 0;
74 
76  virtual TypeID GetID() const { return NONE; }
77 
79  void AutoDeleteChildren() const;
80 
83  SceneNode* FindChildByName(const std::string& name) const;
84 
88  std::list<SceneNode*> GetChilds();
89 
99  bool FindPathTo(SceneNode* targetPtr, SGPath* resultPtr) const;
100 
110  bool FindPathTo(const std::string& targetName, SGPath* resultPtr) const;
111 
116  int GetNodeTypeList(TypeID type, std::list<SceneNode*>& nodeList );
117 
122  virtual void TraverseDepthFirst(SNOperator* operatorPtr) const;
123 
128  virtual void TraverseBreadthFirst(SNOperator* operatorPtr) const;
129 
135  virtual void LocateDepthFirst(SNLocator* locatorPtr) const;
136 
141  virtual void LocateBreadthFirst(SNLocator* locatorPtr) const;
142 
144  virtual void XmlPrintOn(std::ostream& os, unsigned int indent) const;
145 
146  // STATIC PUBLIC ATTRIBUTES
147  static bool recursivePrinting;
148  protected:
149  // PROTECTED METHODS
151  virtual bool DrawInstanceOGL() const { return false; };
152 
154  bool RecursiveFindPathTo(SceneNode* targetPtr, SGPath* resultPtr) const;
155 
157  bool RecursiveFindPathTo(const std::string& targetName, SGPath* resultPtr) const;
158  // PROTECTED ATTRIBUTES
160  std::list<SceneNode*> childList;
162  std::string description;
163  }; // end class declaration
164 } // end namespace
165 #endif
virtual void TraverseDepthFirst(SNOperator *operatorPtr) const
Process all children in depth-first order.
Definition: scenenode.cpp:175
Base class for objects that compose a scene graph.
Definition: scenenode.h:25
Header file for V-ART class "MemoryObj".
std::list< SceneNode * > childList
Child list.
Definition: scenenode.h:160
virtual void TraverseBreadthFirst(SNOperator *operatorPtr) const
Process all children in breadth-first order.
Definition: scenenode.cpp:188
virtual bool DrawInstanceOGL() const
Non-recursive drawing - should be overriden by every derived class.
Definition: scenenode.h:151
virtual SceneNode * RecursiveCopy()
Definition: scenenode.cpp:23
A "Memory Object" is a V-ART object that has some memory allocation attributes, allowing V-ART to aut...
Definition: memoryobj.h:27
SceneNode()
Creates an uninitialized scene node.
Definition: scenenode.cpp:18
std::string description
Textual identification.
Definition: scenenode.h:162
const std::string & GetDescription() const
Returns a copy of the object's description.
Definition: scenenode.h:50
virtual TypeID GetID() const
Returns type identification of the node.
Definition: scenenode.h:76
virtual void DrawForPicking() const =0
Draws and object, setting pick info.
virtual SceneNode * Copy()=0
Objects that process scene nodes.
Definition: snoperator.h:19
virtual void XmlPrintOn(std::ostream &os, unsigned int indent) const
Recursively outputs XML representation of the scene node.
Definition: scenenode.cpp:281
virtual void LocateBreadthFirst(SNLocator *locatorPtr) const
Seaches for a particular scene node (breadth first)
Definition: scenenode.cpp:226
void AutoDeleteChildren() const
Deletes (dealocate memory) recursively all children marked as 'autoDelete'.
Definition: scenenode.cpp:85
virtual void LocateDepthFirst(SNLocator *locatorPtr) const
Seaches for a particular scene node (depth first)
Definition: scenenode.cpp:206
SceneNode & operator=(const SceneNode &node)
Definition: scenenode.cpp:47
void SetDescription(const std::string &desc)
Changes the object's description.
Definition: scenenode.h:53
std::list< SceneNode * > GetChilds()
Definition: scenenode.cpp:112
bool RecursiveFindPathTo(SceneNode *targetPtr, SGPath *resultPtr) const
Recursive auxiliar method for FindPathTo.
Definition: scenenode.cpp:134
static bool recursivePrinting
Definition: scenenode.h:147
virtual bool DrawOGL() const
Recursive drawing using OpenGL commands.
Definition: scenenode.cpp:76
SceneNode * FindChildByName(const std::string &name) const
Recusively searches its children for a given name.
Definition: scenenode.cpp:96
Scene Node Locator – used to find a particular object in the scene graph.
Definition: snlocator.h:25
virtual ~SceneNode()
Definition: scenenode.cpp:36
bool FindPathTo(SceneNode *targetPtr, SGPath *resultPtr) const
Search target among children.
Definition: scenenode.cpp:119
Scene Graph Path.
Definition: sgpath.h:23
int GetNodeTypeList(TypeID type, std::list< SceneNode * > &nodeList)
Find all the nodes of with typeID 'type'.
Definition: scenenode.cpp:242
bool DetachChild(SceneNode *childPtr)
Removes a child from the child list.
Definition: scenenode.cpp:59
void AddChild(SceneNode &child)
Add a child at the end of child list.
Definition: scenenode.cpp:54