leaf-node-line.h
Go to the documentation of this file.
1 //
2 // leaf-node-line.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_LEAFNODELINE_HH
10 #define GEPETTO_VIEWER_LEAFNODELINE_HH
11 
13 
14 namespace gepetto {
15 namespace viewer {
16  DEF_CLASS_SMART_PTR(LeafNodeLine)
17 
18  class LeafNodeLine : public Node
19  {
20  private:
21 
23  LeafNodeLineWeakPtr weak_ptr_;
24 
26  ::osg::GeometryRefPtr beam_ptr_;
27  ::osg::ref_ptr< ::osg::DrawArrays > drawArray_ptr_;
28  ::osg::Vec3ArrayRefPtr points_ptr_;
29  ::osg::Vec4ArrayRefPtr color_ptr_;
30 
31  void init ();
32 
33  /* Default constructor */
34  LeafNodeLine (const std::string& name, const osgVector3& start_point, const osgVector3& end_point);
35  LeafNodeLine (const std::string& name, const osgVector3& start_point, const osgVector3& end_point, const osgVector4& color);
36  LeafNodeLine (const std::string& name, const ::osg::Vec3ArrayRefPtr& points, const osgVector4& color);
37 
38  /* Copy constructor */
39  LeafNodeLine (const LeafNodeLine& other);
40 
42  void initWeakPtr (LeafNodeLineWeakPtr other_weak_ptr);
43 
44  protected:
45  public:
48  static LeafNodeLinePtr_t create (const std::string& name, const osgVector3& start_point, const osgVector3& end_point);
49  static LeafNodeLinePtr_t create (const std::string& name, const osgVector3& start_point, const osgVector3& end_point, const osgVector4& color);
50  static LeafNodeLinePtr_t create (const std::string& name, const ::osg::Vec3ArrayRefPtr& points, const osgVector4& color);
51 
54  static LeafNodeLinePtr_t createCopy (LeafNodeLinePtr_t other);
55 
58  virtual LeafNodeLinePtr_t clone (void) const;
59 
63  virtual NodePtr_t copy() const { return clone(); }
64 
67  LeafNodeLinePtr_t self (void) const;
68 
74  virtual void setStartPoint (const osgVector3& start_point);
75 
76  osgVector3 getStartPoint () const;
77 
80  virtual void setEndPoint (const osgVector3& end_point);
81 
82  osgVector3 getEndPoint() const;
83 
88  virtual void setMode (const GLenum& mode);
89 
90  GLenum getMode () const;
91 
94  virtual void setPoints (const osgVector3& start_point, const osgVector3& end_point);
95 
96  virtual void setPoints (const ::osg::Vec3ArrayRefPtr& points);
97 
100  void setPointsSubset (const int first, const std::size_t count);
101 
102  ::osg::Vec3ArrayRefPtr getPoints()
103  {
104  return points_ptr_;
105  }
106 
107  void setColor(const osgVector4& color);
108  void setColors(const ::osg::Vec4ArrayRefPtr& color);
109 
111  {
112  ::osg::Vec4ArrayRefPtr color_array_ptr = dynamic_cast<osg::Vec4Array*>(beam_ptr_->getColorArray());
113  ASSERT(color_array_ptr, "Problem of dynamic casting from VecArray to Vec4Array");
114 
115  return color_array_ptr->at(0);
116  }
117 
118  ::osg::GeometryRefPtr geometry () const
119  {
120  return beam_ptr_;
121  }
122 
124 
126  virtual ~LeafNodeLine();
127 
128  };
129 
130 } /* namespace viewer */
131 } /* namespace gepetto */
132 
133 #endif /* GEPETTO_VIEWER_LEAFNODELINE_HH */
::osg::Vec3f osgVector3
Definition: config-osg.h:109
::osg::Vec3ArrayRefPtr getPoints()
Definition: leaf-node-line.h:102
::osg::Vec4f osgVector4
Definition: config-osg.h:110
::osg::GeometryRefPtr geometry() const
Definition: leaf-node-line.h:118
viewer::NodePtr_t NodePtr_t
Definition: fwd.hh:47
Definition: action-search-bar.hh:27
Definition: leaf-node-line.h:18
#define DEF_CLASS_SMART_PTR(className)
Definition: macros.h:50
osgVector4 getColor() const
Definition: leaf-node-line.h:110
virtual NodePtr_t copy() const
Proceed to a copy of the currend object as clone.
Definition: leaf-node-line.h:63
#define ASSERT(condition, message)
Definition: macros.h:40
SCENE_VIEWER_ACCEPT_VISITOR
Definition: leaf-node-line.h:123
Abstract base class of 3D objects in a scene.
Definition: node.h:27