cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
osaOSGBodyUI.h
Go to the documentation of this file.
1 #ifndef _osaOSGBodyUI_h
2 #define _osaOSGBodyUI_h
3 
4 #include <osg/Geode>
5 #include <osg/ShapeDrawable>
6 #include <osg/Shape>
7 
11 
12 // Handle for body dragger
14 
15  enum State { FREE, SELECTED, DRAG };
16  State state;
17 
18  osg::ref_ptr< osaOSGBody > body;
19 
20  osg::ref_ptr< osg::Geode > geode;
21  osg::ref_ptr< osg::ShapeDrawable > drawable;
22  osg::ref_ptr< osg::Sphere > sphere;
23 
24  // This is used to update the position of the body
25  class ResetCallback : public osg::NodeCallback {
26  public:
27  ResetCallback(){}
28  void operator()( osg::Node* node, osg::NodeVisitor* nv );
29  };
30  osg::ref_ptr<ResetCallback> resetcallback;
31 
32  public:
33 
34  osaOSGHandle( osaOSGBody* body,
35  const std::string& name,
36  const vctFixedSizeVector<double,3>& toh );
37 
38  osaOSGBody* GetBody(){ return body; }
39  void SetColor();
40 
41  bool IsSelected() const { return state == SELECTED; }
42  bool IsFree() const { return state == FREE; }
43 
44  void Reset();
45  void Select();
46  void Release();
47 
49 
50 };
51 
52 // Handle for body dragger
54 
55  protected:
56 
57  bool select;
59  osg::ref_ptr< osaOSGHandle > handle;
60 
61  public:
62 
63  osaOSGPointer2D() : select( false ), xyzprev( 0.0 ){}
64 
65  void PickHandler( osaOSGBody* body, osaOSGPick::Event e, double x, double y );
66 
67 };
68 
69 // Handle for body dragger
71 
72  protected:
73 
74  osg::ref_ptr< osg::Geode > geode;
75  osg::ref_ptr< osg::ShapeDrawable > drawable;
76  osg::ref_ptr< osg::Sphere > sphere;
77 
78  // This is used to update the position of the body
79  class IntersectionCallback : public osg::NodeCallback {
80  public:
82  void operator()( osg::Node* node, osg::NodeVisitor* nv );
83  };
84  osg::ref_ptr<IntersectionCallback> intersectioncallback;
85 
86  osg::ref_ptr< osaOSGWorld > world;
87 
89 
90  osg::Polytope polytope;
91  void BuildPolytope();
92 
93  bool select;
94 
95  public:
96 
98  const vctFrame4x4<double>& Rt,
99  const std::string& name,
100  double scale=1.0,
101  double alpha=1.0 );
102 
103  void CheckIntersection();
104 
105  void Select() { select = true; }
106  void Release() { select = false; }
107  void SetVelocity( const vctFixedSizeVector<double,3>& v );
108 
109 };
110 
112 
113  protected:
114 
115  osg::ref_ptr< osaOSGHandle > top, bottom, left, right, front, rear;
116 
117  public:
118 
119  osaOSGBodyUI( const std::string& model,
120  osaOSGWorld* world,
122  double scale = 1.0,
123  double alpha = 1.0,
124  const vctFrame4x4<double>& Rtoffset = vctFrame4x4<double>(),
125  const std::string& option = std::string("") );
126 
127 };
128 
129 #endif
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
osg::ref_ptr< osg::Sphere > sphere
Definition: osaOSGBodyUI.h:76
osaOSGBody * GetBody()
Definition: osaOSGBodyUI.h:38
Definition: osaOSGBody.h:34
Definition: osaOSGBodyUI.h:70
Definition: osaOSGBodyUI.h:53
Definition: osaOSGPick.h:10
void Select()
Definition: osaOSGBodyUI.h:105
osg::ref_ptr< osg::Geode > geode
Definition: osaOSGBodyUI.h:74
Definition: osaOSGWorld.h:24
bool select
Definition: osaOSGBodyUI.h:57
osg::ref_ptr< osaOSGHandle > handle
Definition: osaOSGBodyUI.h:59
Event
Definition: osaOSGPick.h:17
virtual void PickHandler(osaOSGBody *, Event, double, double)
Definition: osaOSGPick.h:21
vctFixedSizeVector< double, 3 > velocity
Definition: osaOSGBodyUI.h:88
osg::ref_ptr< osaOSGHandle > top
Definition: osaOSGBodyUI.h:115
Definition: osaOSGBodyUI.h:13
Definition: osaOSGBodyUI.h:79
vctFixedSizeVector< double, 3 > xyzprev
Definition: osaOSGBodyUI.h:58
void Release()
Definition: osaOSGBodyUI.h:106
osg::ref_ptr< osaOSGWorld > world
Definition: osaOSGBodyUI.h:86
IntersectionCallback()
Definition: osaOSGBodyUI.h:81
bool select
Definition: osaOSGBodyUI.h:93
bool IsFree() const
Definition: osaOSGBodyUI.h:42
Definition: osaOSGBodyUI.h:111
bool IsSelected() const
Definition: osaOSGBodyUI.h:41
osg::Polytope polytope
Definition: osaOSGBodyUI.h:90
osaOSGPointer2D()
Definition: osaOSGBodyUI.h:63
osg::ref_ptr< osg::ShapeDrawable > drawable
Definition: osaOSGBodyUI.h:75
osg::ref_ptr< IntersectionCallback > intersectioncallback
Definition: osaOSGBodyUI.h:84