OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
coSensor.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef CO_SENSOR_H
9 #define CO_SENSOR_H
10 
24 #include <util/DLinkList.h>
25 #include <util/coExport.h>
26 #include <osg/Vec3>
31 
32 namespace osg
33 {
34 class Node;
35 class MatrixTransform;
36 }
37 
38 class PLUGIN_UTILEXPORT coSensor
39 {
40 protected:
41  osg::Node *node;
42  int active; // status of the sensor, active = 1 as long as pointer intersects node
43  float threshold;
44  float sqrDistance;
46  int enabled;
47  vrui::coCombinedButtonInteraction *interaction = nullptr;
48 
49 public:
50  enum
51  {
52  NONE = 0,
57  HAND
58  };
60  virtual ~coSensor();
61 
62  // this method is called if intersection just started
63  // and should be overloaded
64  virtual void activate();
65 
66  // should be overloaded, is called if intersection finishes
67  virtual void disactivate();
68 
69  // enable intersection testing, default is enabled
70  virtual void enable();
71 
72  // disable intersection testing
73  virtual void disable();
74 
75  virtual int getType();
76  virtual void calcDistance(){};
77  virtual float getDistance()
78  {
79  return (sqrt(sqrDistance));
80  };
81  virtual void setThreshold(float d)
82  {
83  threshold = d * d;
84  };
85  virtual void update();
86  virtual void setButtonSensitive(int s);
87  osg::Node *getNode()
88  {
89  return node;
90  };
91 };
92 
93 class PLUGIN_UTILEXPORT coPickSensor : public coSensor, public vrui::coAction
94 {
95 public:
96  osg::Vec3 hitPoint; // last hitPoint in world coordinates
97 
98  bool hitActive;
101 
102  virtual int hit(vrui::vruiHit *hit);
103  virtual void miss();
105  virtual ~coPickSensor();
106  virtual void update();
107  virtual int getType();
108 };
109 
110 class PLUGIN_UTILEXPORT coSensorList : public covise::DLinkList<coSensor *>
111 {
112 public:
113  coSensorList();
114  void update();
115 };
116 #endif
osg::Vec3 hitPoint
Definition: coSensor.h:96
Definition: vruiHit.h:20
vrui::OSGVruiNode * vNode
Definition: coSensor.h:100
Definition: coSensor.h:110
Definition: coSensor.h:54
osg::Node * getNode()
Definition: coSensor.h:87
Definition: coInteraction.h:46
Definition: coSensor.h:53
bool hitActive
Definition: coSensor.h:98
Definition: coAction.h:25
int buttonSensitive
Definition: coSensor.h:45
float sqrDistance
Definition: coSensor.h:44
int enabled
Definition: coSensor.h:46
Definition: coSensor.h:93
Definition: coInteraction.h:38
Definition: coCombinedButtonInteraction.h:20
virtual void update()
virtual int getType()
virtual float getDistance()
Definition: coSensor.h:77
Definition: OSGVruiNode.h:20
bool hitWasActive
Definition: coSensor.h:99
virtual int hit(vruiHit *hit)=0
virtual void setThreshold(float d)
Definition: coSensor.h:81
Definition: coSensor.h:55
int active
Definition: coSensor.h:42
virtual void miss()
float threshold
Definition: coSensor.h:43
InteractionType
Definition: coInteraction.h:44
InteractionPriority
Definition: coInteraction.h:33
virtual void calcDistance()
Definition: coSensor.h:76
Definition: coSensor.h:38
osg::Node * node
Definition: coSensor.h:41
Definition: coSensor.h:56