group-node.h
Go to the documentation of this file.
1 //
2 // group-node.h
3 // gepetto-viewer
4 //
5 // Created by Justin Carpentier, Mathieu Geisert in November 2014.
6 // Copyright (c) 2014 LAAS-CNRS. All rights reserved.
7 //
8 
9 #ifndef GEPETTO_VIEWER_GROUPNODE_HH
10 #define GEPETTO_VIEWER_GROUPNODE_HH
11 
12 #include <gepetto/viewer/node.h>
13 
14 namespace gepetto {
15 namespace viewer {
16 
17  DEF_CLASS_SMART_PTR(GroupNode)
18 
19  class GroupNode : public Node
20  {
21  private:
25  typedef std::vector<NodePtr_t> Nodes_t;
26  Nodes_t list_of_objects_;
27 
29  GroupNodeWeakPtr weak_ptr_;
30 
31  protected:
35  GroupNode (const std::string& name);
36 
38  GroupNode (const GroupNode& other);
39 
41  void initWeakPtr(GroupNodeWeakPtr other_weak_ptr);
42 
43  public:
46  static GroupNodePtr_t create(const std::string& name);
47 
50  static GroupNodePtr_t createCopy(GroupNodePtr_t other);
51 
54  GroupNodePtr_t clone(void) const;
55 
58  GroupNodePtr_t self(void) const;
59 
60 
63  virtual bool addChild (NodePtr_t child_ptr);
64 
67  virtual bool removeChild (NodePtr_t child_ptr);
68 
71  virtual bool hasChild (NodePtr_t child_ptr) const;
72 
75  virtual void removeAllChildren();
76 
77  virtual size_t getNumOfChildren() const
78  {
79  return list_of_objects_.size();
80  }
81 
82  virtual NodePtr_t getChild(size_t i) const
83  {
84  Nodes_t::const_iterator it = list_of_objects_.begin();
85  if (list_of_objects_.size() > i)
86  {
87  std::advance(it, (long)i);
88  }
89  return *it;
90  }
91 
96  virtual void setLightingMode (const LightingMode& lighting_state);
97 
102  virtual void setWireFrameMode (const WireFrameMode& wireframe_state);
103 
107  virtual void setAlpha (const float& alpha);
108 
110  void setColor (const osgVector4& color);
111 
112  void traverse (NodeVisitor& visitor);
113 
114  virtual osg::ref_ptr<osg::Node> getOsgNode() const;
115 
117 
118  /* Destructor */
119  virtual ~GroupNode();
120 
121  }; /* class GraphicalGroupOSG */
122 
123 } /* namespace viewer */
124 } /* namespace gepetto */
125 
126 #endif /* GEPETTO_VIEWER_GROUPNODE_HH */
::osg::Vec4f osgVector4
Definition: config-osg.h:110
virtual NodePtr_t getChild(size_t i) const
Definition: group-node.h:82
Definition: node-visitor.h:35
viewer::NodePtr_t NodePtr_t
Definition: fwd.hh:47
Definition: action-search-bar.hh:27
viewer::GroupNodePtr_t GroupNodePtr_t
Definition: fwd.hh:50
LightingMode
Definition: config-osg.h:124
#define DEF_CLASS_SMART_PTR(className)
Definition: macros.h:50
virtual size_t getNumOfChildren() const
Definition: group-node.h:77
SCENE_VIEWER_ACCEPT_VISITOR
Definition: group-node.h:116
Definition: group-node.h:19
WireFrameMode
Definition: config-osg.h:130
Abstract base class of 3D objects in a scene.
Definition: node.h:27