node-drawable.h
Go to the documentation of this file.
1 //
2 // node-drawable.h
3 // gepetto-viewer
4 //
5 // Created by Joseph Mirabel in 2018
6 // Copyright (c) 2018 LAAS-CNRS. All rights reserved.
7 //
8 
9 #ifndef GEPETTO_VIEWER_NODEDRAWABLE_HH
10 #define GEPETTO_VIEWER_NODEDRAWABLE_HH
11 
12 #include <gepetto/viewer/node.h>
13 
14 namespace gepetto {
15 namespace viewer {
16  DEF_CLASS_SMART_PTR(NodeDrawable)
17 
18 
19  class NodeDrawable : public Node
20  {
21  private:
22  void init ();
23 
24  protected:
25  ::osg::ShapeDrawableRefPtr shape_drawable_ptr_;
26 
27  void redrawShape ();
28 
30  NodeDrawable (const std::string& name) : Node (name) { init (); }
31 
33  NodeDrawable (const Node& other) : Node (other) { init (); }
34 
35  public:
36  virtual void setAlpha (const float& alpha)
37  {
38  osgVector4 color = this->getColor();
39  color[3] = alpha;
40  this->setColor (color);
41  }
42 
43  float getAlpha() const
44  {
45  return getColor () [3];
46  }
47 
48  virtual void setColor(const osgVector4 &color);
49 
50  virtual osgVector4 getColor() const;
51 
52  virtual void setTexture(const std::string& image_path);
53 
55  virtual ~NodeDrawable() {}
56  };
57 } /* namespace viewer */
58 } /* namespace gepetto */
59 
60 #endif /* GEPETTO_VIEWER_NODEDRAWABLE_HH */
Definition: node-drawable.h:19
float getAlpha() const
Definition: node-drawable.h:43
::osg::Vec4f osgVector4
Definition: config-osg.h:110
virtual ~NodeDrawable()
Definition: node-drawable.h:55
NodeDrawable(const std::string &name)
Definition: node-drawable.h:30
Definition: action-search-bar.hh:27
::osg::ShapeDrawableRefPtr shape_drawable_ptr_
Definition: node-drawable.h:25
#define DEF_CLASS_SMART_PTR(className)
Definition: macros.h:50
virtual void setAlpha(const float &alpha)
Definition: node-drawable.h:36
Abstract base class of 3D objects in a scene.
Definition: node.h:27
NodeDrawable(const Node &other)
Definition: node-drawable.h:33