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 
14 
15 namespace gepetto {
16 namespace viewer {
17  DEF_CLASS_SMART_PTR(LeafNodeLine)
18 
19  class LeafNodeLine : public Node
20  {
21  private:
22 
24  LeafNodeLineWeakPtr weak_ptr_;
25 
27  ::osg::GeometryRefPtr beam_ptr_;
28  ::osg::ref_ptr< ::osg::DrawArrays > drawArray_ptr_;
29  ::osg::Vec3ArrayRefPtr points_ptr_;
30  ::osg::Vec4ArrayRefPtr color_ptr_;
31 
32  BackfaceDrawingProperty backfaceDrawing_;
33 
34  void init ();
35 
36  /* Default constructor */
37  LeafNodeLine (const std::string& name, const osgVector3& start_point, const osgVector3& end_point);
38  LeafNodeLine (const std::string& name, const osgVector3& start_point, const osgVector3& end_point, const osgVector4& color);
39  LeafNodeLine (const std::string& name, const ::osg::Vec3ArrayRefPtr& points, const osgVector4& color);
40 
41  /* Copy constructor */
42  LeafNodeLine (const LeafNodeLine& other);
43 
45  void initWeakPtr (LeafNodeLineWeakPtr other_weak_ptr);
46 
47  protected:
48  public:
51  static LeafNodeLinePtr_t create (const std::string& name, const osgVector3& start_point, const osgVector3& end_point);
52  static LeafNodeLinePtr_t create (const std::string& name, const osgVector3& start_point, const osgVector3& end_point, const osgVector4& color);
53  static LeafNodeLinePtr_t create (const std::string& name, const ::osg::Vec3ArrayRefPtr& points, const osgVector4& color);
54 
57  static LeafNodeLinePtr_t createCopy (LeafNodeLinePtr_t other);
58 
61  virtual LeafNodeLinePtr_t clone (void) const;
62 
66  virtual NodePtr_t copy() const { return clone(); }
67 
70  LeafNodeLinePtr_t self (void) const;
71 
77  virtual void setStartPoint (const osgVector3& start_point);
78 
79  osgVector3 getStartPoint () const;
80 
83  virtual void setEndPoint (const osgVector3& end_point);
84 
85  osgVector3 getEndPoint() const;
86 
91  virtual void setMode (const GLenum& mode);
92 
93  GLenum getMode () const;
94 
97  virtual void setPoints (const osgVector3& start_point, const osgVector3& end_point);
98 
99  virtual void setPoints (const ::osg::Vec3ArrayRefPtr& points);
100 
103  void setPointsSubset (const int first, const std::size_t count);
104 
105  ::osg::Vec3ArrayRefPtr getPoints()
106  {
107  return points_ptr_;
108  }
109 
110  void setColor(const osgVector4& color);
111  void setColors(const ::osg::Vec4ArrayRefPtr& color);
112 
114  {
115  ::osg::Vec4ArrayRefPtr color_array_ptr = dynamic_cast<osg::Vec4Array*>(beam_ptr_->getColorArray());
116  ASSERT(color_array_ptr, "Problem of dynamic casting from VecArray to Vec4Array");
117 
118  return color_array_ptr->at(0);
119  }
120 
121  ::osg::GeometryRefPtr geometry () const
122  {
123  return beam_ptr_;
124  }
125 
127 
129  virtual ~LeafNodeLine();
130 
131  };
132 
133 } /* namespace viewer */
134 } /* namespace gepetto */
135 
136 #endif /* GEPETTO_VIEWER_LEAFNODELINE_HH */
::osg::Vec3f osgVector3
Definition: config-osg.h:109
::osg::Vec3ArrayRefPtr getPoints()
Definition: leaf-node-line.h:105
Definition: properties.h:16
::osg::Vec4f osgVector4
Definition: config-osg.h:110
::osg::GeometryRefPtr geometry() const
Definition: leaf-node-line.h:121
viewer::NodePtr_t NodePtr_t
Definition: fwd.hh:47
Definition: action-search-bar.hh:27
Definition: leaf-node-line.h:19
#define DEF_CLASS_SMART_PTR(className)
Definition: macros.h:50
osgVector4 getColor() const
Definition: leaf-node-line.h:113
virtual NodePtr_t copy() const
Proceed to a copy of the currend object as clone.
Definition: leaf-node-line.h:66
#define ASSERT(condition, message)
Definition: macros.h:40
SCENE_VIEWER_ACCEPT_VISITOR
Definition: leaf-node-line.h:126
Abstract base class of 3D objects in a scene.
Definition: node.h:28