OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GUIEventAdapter.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSGGA_GUIEVENTADAPTER
15 #define OSGGA_GUIEVENTADAPTER 1
16 
17 #include <osg/Object>
18 #include <osg/Matrix>
19 #include <osg/GraphicsContext>
20 
21 #include <osgGA/Event>
22 
23 namespace osgGA{
24 
26 {
28  object(0),
29  x(0.0f),
30  xMin(-1.0f),
31  xMax(1.0f),
32  y(0.0f),
33  yMin(-1.0f),
34  yMax(1.0f) {}
35 
36  PointerData(osg::Object* obj, float in_x, float in_xMin, float in_xMax, float in_y, float in_yMin, float in_yMax):
37  object(obj),
38  x(in_x),
39  xMin(in_xMin),
40  xMax(in_xMax),
41  y(in_y),
42  yMin(in_yMin),
43  yMax(in_yMax) {}
44 
46  osg::Referenced(),
47  object(pd.object),
48  x(pd.x),
49  xMin(pd.xMin),
50  xMax(pd.xMax),
51  y(pd.y),
52  yMin(pd.yMin),
53  yMax(pd.yMax) {}
54 
56  {
57  if (&pd==this) return *this;
58 
59  object = pd.object;
60  x = pd.x;
61  xMin = pd.xMin;
62  xMax = pd.xMax;
63  y = pd.y;
64  yMin = pd.yMin;
65  yMax = pd.yMax;
66 
67  return *this;
68  }
69 
71  float x, xMin, xMax;
72  float y, yMin, yMax;
73 
74  float getXnormalized() const { return (x-xMin)/(xMax-xMin)*2.0f-1.0f; }
75  float getYnormalized() const { return (y-yMin)/(yMax-yMin)*2.0f-1.0f; }
76 };
77 
78 
82 {
83 public:
84 
86  LEFT_MOUSE_BUTTON = 1<<0,
87  MIDDLE_MOUSE_BUTTON = 1<<1,
88  RIGHT_MOUSE_BUTTON = 1<<2
89  };
90 
91  enum EventType {
92  NONE = 0,
93  PUSH = 1<<0,
94  RELEASE = 1<<1,
95  DOUBLECLICK = 1<<2,
96  DRAG = 1<<3,
97  MOVE = 1<<4,
98  KEYDOWN = 1<<5,
99  KEYUP = 1<<6,
100  FRAME = 1<<7,
101  RESIZE = 1<<8,
102  SCROLL = 1<<9,
103  PEN_PRESSURE = 1<<10,
104  PEN_ORIENTATION = 1<<11,
105  PEN_PROXIMITY_ENTER = 1<<12,
106  PEN_PROXIMITY_LEAVE = 1<<13,
107  CLOSE_WINDOW = 1<<14,
108  QUIT_APPLICATION = 1<<15,
109  USER = 1<<16
110  };
111 
113  {
114  KEY_Space = 0x20,
115 
116  KEY_0 = '0',
117  KEY_1 = '1',
118  KEY_2 = '2',
119  KEY_3 = '3',
120  KEY_4 = '4',
121  KEY_5 = '5',
122  KEY_6 = '6',
123  KEY_7 = '7',
124  KEY_8 = '8',
125  KEY_9 = '9',
126  KEY_A = 'a',
127  KEY_B = 'b',
128  KEY_C = 'c',
129  KEY_D = 'd',
130  KEY_E = 'e',
131  KEY_F = 'f',
132  KEY_G = 'g',
133  KEY_H = 'h',
134  KEY_I = 'i',
135  KEY_J = 'j',
136  KEY_K = 'k',
137  KEY_L = 'l',
138  KEY_M = 'm',
139  KEY_N = 'n',
140  KEY_O = 'o',
141  KEY_P = 'p',
142  KEY_Q = 'q',
143  KEY_R = 'r',
144  KEY_S = 's',
145  KEY_T = 't',
146  KEY_U = 'u',
147  KEY_V = 'v',
148  KEY_W = 'w',
149  KEY_X = 'x',
150  KEY_Y = 'y',
151  KEY_Z = 'z',
152 
153  KEY_Exclaim = 0x21,
154  KEY_Quotedbl = 0x22,
155  KEY_Hash = 0x23,
156  KEY_Dollar = 0x24,
157  KEY_Ampersand = 0x26,
158  KEY_Quote = 0x27,
159  KEY_Leftparen = 0x28,
160  KEY_Rightparen = 0x29,
161  KEY_Asterisk = 0x2A,
162  KEY_Plus = 0x2B,
163  KEY_Comma = 0x2C,
164  KEY_Minus = 0x2D,
165  KEY_Period = 0x2E,
166  KEY_Slash = 0x2F,
167  KEY_Colon = 0x3A,
168  KEY_Semicolon = 0x3B,
169  KEY_Less = 0x3C,
170  KEY_Equals = 0x3D,
171  KEY_Greater = 0x3E,
172  KEY_Question = 0x3F,
173  KEY_At = 0x40,
174  KEY_Leftbracket = 0x5B,
175  KEY_Backslash = 0x5C,
176  KEY_Rightbracket = 0x5D,
177  KEY_Caret = 0x5E,
178  KEY_Underscore = 0x5F,
179  KEY_Backquote = 0x60,
180 
181  KEY_BackSpace = 0xFF08, /* back space, back char */
182  KEY_Tab = 0xFF09,
183  KEY_Linefeed = 0xFF0A, /* Linefeed, LF */
184  KEY_Clear = 0xFF0B,
185  KEY_Return = 0xFF0D, /* Return, enter */
186  KEY_Pause = 0xFF13, /* Pause, hold */
187  KEY_Scroll_Lock = 0xFF14,
188  KEY_Sys_Req = 0xFF15,
189  KEY_Escape = 0xFF1B,
190  KEY_Delete = 0xFFFF, /* Delete, rubout */
191 
192 
193  /* Cursor control & motion */
194 
195  KEY_Home = 0xFF50,
196  KEY_Left = 0xFF51, /* Move left, left arrow */
197  KEY_Up = 0xFF52, /* Move up, up arrow */
198  KEY_Right = 0xFF53, /* Move right, right arrow */
199  KEY_Down = 0xFF54, /* Move down, down arrow */
200  KEY_Prior = 0xFF55, /* Prior, previous */
201  KEY_Page_Up = 0xFF55,
202  KEY_Next = 0xFF56, /* Next */
203  KEY_Page_Down = 0xFF56,
204  KEY_End = 0xFF57, /* EOL */
205  KEY_Begin = 0xFF58, /* BOL */
206 
207 
208  /* Misc Functions */
209 
210  KEY_Select = 0xFF60, /* Select, mark */
211  KEY_Print = 0xFF61,
212  KEY_Execute = 0xFF62, /* Execute, run, do */
213  KEY_Insert = 0xFF63, /* Insert, insert here */
214  KEY_Undo = 0xFF65, /* Undo, oops */
215  KEY_Redo = 0xFF66, /* redo, again */
216  KEY_Menu = 0xFF67, /* On Windows, this is VK_APPS, the context-menu key */
217  KEY_Find = 0xFF68, /* Find, search */
218  KEY_Cancel = 0xFF69, /* Cancel, stop, abort, exit */
219  KEY_Help = 0xFF6A, /* Help */
220  KEY_Break = 0xFF6B,
221  KEY_Mode_switch = 0xFF7E, /* Character set switch */
222  KEY_Script_switch = 0xFF7E, /* Alias for mode_switch */
223  KEY_Num_Lock = 0xFF7F,
224 
225  /* Keypad Functions, keypad numbers cleverly chosen to map to ascii */
226 
227  KEY_KP_Space = 0xFF80, /* space */
228  KEY_KP_Tab = 0xFF89,
229  KEY_KP_Enter = 0xFF8D, /* enter */
230  KEY_KP_F1 = 0xFF91, /* PF1, KP_A, ... */
231  KEY_KP_F2 = 0xFF92,
232  KEY_KP_F3 = 0xFF93,
233  KEY_KP_F4 = 0xFF94,
234  KEY_KP_Home = 0xFF95,
235  KEY_KP_Left = 0xFF96,
236  KEY_KP_Up = 0xFF97,
237  KEY_KP_Right = 0xFF98,
238  KEY_KP_Down = 0xFF99,
239  KEY_KP_Prior = 0xFF9A,
240  KEY_KP_Page_Up = 0xFF9A,
241  KEY_KP_Next = 0xFF9B,
242  KEY_KP_Page_Down = 0xFF9B,
243  KEY_KP_End = 0xFF9C,
244  KEY_KP_Begin = 0xFF9D,
245  KEY_KP_Insert = 0xFF9E,
246  KEY_KP_Delete = 0xFF9F,
247  KEY_KP_Equal = 0xFFBD, /* equals */
248  KEY_KP_Multiply = 0xFFAA,
249  KEY_KP_Add = 0xFFAB,
250  KEY_KP_Separator = 0xFFAC, /* separator, often comma */
251  KEY_KP_Subtract = 0xFFAD,
252  KEY_KP_Decimal = 0xFFAE,
253  KEY_KP_Divide = 0xFFAF,
254 
255  KEY_KP_0 = 0xFFB0,
256  KEY_KP_1 = 0xFFB1,
257  KEY_KP_2 = 0xFFB2,
258  KEY_KP_3 = 0xFFB3,
259  KEY_KP_4 = 0xFFB4,
260  KEY_KP_5 = 0xFFB5,
261  KEY_KP_6 = 0xFFB6,
262  KEY_KP_7 = 0xFFB7,
263  KEY_KP_8 = 0xFFB8,
264  KEY_KP_9 = 0xFFB9,
265 
266  /*
267  * Auxiliary Functions; note the duplicate definitions for left and right
268  * function keys; Sun keyboards and a few other manufactures have such
269  * function key groups on the left and/or right sides of the keyboard.
270  * We've not found a keyboard with more than 35 function keys total.
271  */
272 
273  KEY_F1 = 0xFFBE,
274  KEY_F2 = 0xFFBF,
275  KEY_F3 = 0xFFC0,
276  KEY_F4 = 0xFFC1,
277  KEY_F5 = 0xFFC2,
278  KEY_F6 = 0xFFC3,
279  KEY_F7 = 0xFFC4,
280  KEY_F8 = 0xFFC5,
281  KEY_F9 = 0xFFC6,
282  KEY_F10 = 0xFFC7,
283  KEY_F11 = 0xFFC8,
284  KEY_F12 = 0xFFC9,
285  KEY_F13 = 0xFFCA,
286  KEY_F14 = 0xFFCB,
287  KEY_F15 = 0xFFCC,
288  KEY_F16 = 0xFFCD,
289  KEY_F17 = 0xFFCE,
290  KEY_F18 = 0xFFCF,
291  KEY_F19 = 0xFFD0,
292  KEY_F20 = 0xFFD1,
293  KEY_F21 = 0xFFD2,
294  KEY_F22 = 0xFFD3,
295  KEY_F23 = 0xFFD4,
296  KEY_F24 = 0xFFD5,
297  KEY_F25 = 0xFFD6,
298  KEY_F26 = 0xFFD7,
299  KEY_F27 = 0xFFD8,
300  KEY_F28 = 0xFFD9,
301  KEY_F29 = 0xFFDA,
302  KEY_F30 = 0xFFDB,
303  KEY_F31 = 0xFFDC,
304  KEY_F32 = 0xFFDD,
305  KEY_F33 = 0xFFDE,
306  KEY_F34 = 0xFFDF,
307  KEY_F35 = 0xFFE0,
308 
309  /* Modifiers */
310 
311  KEY_Shift_L = 0xFFE1, /* Left shift */
312  KEY_Shift_R = 0xFFE2, /* Right shift */
313  KEY_Control_L = 0xFFE3, /* Left control */
314  KEY_Control_R = 0xFFE4, /* Right control */
315  KEY_Caps_Lock = 0xFFE5, /* Caps lock */
316  KEY_Shift_Lock = 0xFFE6, /* Shift lock */
317 
318  KEY_Meta_L = 0xFFE7, /* Left meta */
319  KEY_Meta_R = 0xFFE8, /* Right meta */
320  KEY_Alt_L = 0xFFE9, /* Left alt */
321  KEY_Alt_R = 0xFFEA, /* Right alt */
322  KEY_Super_L = 0xFFEB, /* Left super */
323  KEY_Super_R = 0xFFEC, /* Right super */
324  KEY_Hyper_L = 0xFFED, /* Left hyper */
325  KEY_Hyper_R = 0xFFEE /* Right hyper */
326  };
327 
328 
330  {
331  MODKEY_LEFT_SHIFT = 0x0001,
332  MODKEY_RIGHT_SHIFT = 0x0002,
333  MODKEY_LEFT_CTRL = 0x0004,
334  MODKEY_RIGHT_CTRL = 0x0008,
335  MODKEY_LEFT_ALT = 0x0010,
336  MODKEY_RIGHT_ALT = 0x0020,
337  MODKEY_LEFT_META = 0x0040,
338  MODKEY_RIGHT_META = 0x0080,
339  MODKEY_LEFT_SUPER = 0x0100,
340  MODKEY_RIGHT_SUPER = 0x0200,
341  MODKEY_LEFT_HYPER = 0x0400,
342  MODKEY_RIGHT_HYPER = 0x0800,
343  MODKEY_NUM_LOCK = 0x1000,
344  MODKEY_CAPS_LOCK = 0x2000,
345  MODKEY_CTRL = (MODKEY_LEFT_CTRL|MODKEY_RIGHT_CTRL),
346  MODKEY_SHIFT = (MODKEY_LEFT_SHIFT|MODKEY_RIGHT_SHIFT),
347  MODKEY_ALT = (MODKEY_LEFT_ALT|MODKEY_RIGHT_ALT),
348  MODKEY_META = (MODKEY_LEFT_META|MODKEY_RIGHT_META),
349  MODKEY_SUPER = (MODKEY_LEFT_SUPER|MODKEY_RIGHT_SUPER),
350  MODKEY_HYPER = (MODKEY_LEFT_HYPER|MODKEY_RIGHT_HYPER)
351  };
352 
354  {
356  Y_INCREASING_DOWNWARDS
357  };
358 
360  {
366  SCROLL_2D
367  };
368 
370  {
371  UNKNOWN = 0,
374  ERASER
375  };
376 
378  {
383  TOUCH_ENDED
384  };
385 
386  class TouchData : public osg::Object {
387  public:
388 
389  struct TouchPoint {
390  unsigned int id;
392  float x, y;
393 
394  unsigned int tapCount;
395  TouchPoint() : id(0), phase(TOUCH_UNKNOWN), x(0.0f), y(0.0f), tapCount(0) {}
396  TouchPoint(unsigned int in_id, TouchPhase in_phase, float in_x, float in_y, unsigned int in_tap_count)
397  : id(in_id),
398  phase(in_phase),
399  x(in_x),
400  y(in_y),
401  tapCount(in_tap_count)
402  {
403  }
404  };
405 
406  typedef std::vector<TouchPoint> TouchSet;
407 
408  typedef TouchSet::iterator iterator;
409  typedef TouchSet::const_iterator const_iterator;
410 
411  TouchData() : osg::Object() {}
412 
413  TouchData(const TouchData& td, const osg::CopyOp& copyop):
414  osg::Object(td,copyop),
415  _touches(td._touches) {}
416 
417 
419 
420 
421  unsigned int getNumTouchPoints() const { return static_cast<unsigned int>(_touches.size()); }
422 
423  iterator begin() { return _touches.begin(); }
424  const_iterator begin() const { return _touches.begin(); }
425 
426  iterator end() { return _touches.end(); }
427  const_iterator end() const { return _touches.end(); }
428 
429  const TouchPoint get(unsigned int i) const { return _touches[i]; }
430 
431  protected:
432 
433  virtual ~TouchData() {}
434 
435  void addTouchPoint(unsigned int id, TouchPhase phase, float x, float y, unsigned int tap_count) {
436  _touches.push_back(TouchPoint(id, phase, x, y, tap_count));
437  }
438 
439  TouchSet _touches;
440 
441  friend class GUIEventAdapter;
442  };
443 
444  public:
445 
446  GUIEventAdapter();
447 
449 
451 
452  virtual GUIEventAdapter* asGUIEventAdapter() { return this; }
453  virtual const GUIEventAdapter* asGUIEventAdapter() const { return this; }
454 
455 
459  static osg::ref_ptr<GUIEventAdapter>& getAccumulatedEventState();
460 
461 
463  void setEventType(EventType Type) { _eventType = Type; }
464 
466  virtual EventType getEventType() const { return _eventType; }
467 
469  double time() const { return _time; }
470 
471 
472  void setGraphicsContext(osg::GraphicsContext* context) { _context = context; }
473  osg::GraphicsContext* getGraphicsContext() { return _context.get(); }
474  const osg::GraphicsContext* getGraphicsContext() const { return _context.get(); }
475 
476 
478  void setWindowRectangle(int x, int y, int width, int height, bool updateMouseRange = true);
479 
481  void setWindowX(int v) { _windowX = v; }
482 
484  int getWindowX() const { return _windowX; }
485 
487  void setWindowY(int v) { _windowY = v; }
488 
490  int getWindowY() const { return _windowY; }
491 
493  void setWindowWidth(int v) { _windowWidth = v; }
494 
496  int getWindowWidth() const { return _windowWidth; }
497 
499  void setWindowHeight(int v) { _windowHeight = v; }
500 
502  int getWindowHeight() const { return _windowHeight; }
503 
504 
506  inline void setKey(int key) { _key = key; }
507 
509  virtual int getKey() const { return _key; }
510 
512  void setUnmodifiedKey(int key) { _unmodifiedKey = key; }
513 
515  int getUnmodifiedKey() const { return _unmodifiedKey; }
516 
518  void setButton(int button) { _button = button; }
519 
521  int getButton() const { return _button; }
522 
523 
525  void setInputRange(float Xmin, float Ymin, float Xmax, float Ymax);
526 
528  void setXmin(float v) { _Xmin = v; }
529 
531  float getXmin() const { return _Xmin; }
532 
534  void setXmax(float v) { _Xmax = v; }
535 
537  float getXmax() const { return _Xmax; }
538 
540  void setYmin(float v) { _Ymin = v; }
541 
543  float getYmin() const { return _Ymin; }
544 
546  void setYmax(float v) { _Ymax = v; }
547 
549  float getYmax() const { return _Ymax; }
550 
552  void setX(float x) { _mx = x; }
553 
555  float getX() const { return _mx; }
556 
558  void setY(float y) { _my = y; }
559 
561  float getY() const { return _my; }
562 
563 #if 1
564  inline float getXnormalized() const
565  {
566  return _pointerDataList.size()>=1 ?
567  _pointerDataList[_pointerDataList.size()-1]->getXnormalized():
568  2.0f*(getX()-getXmin())/(getXmax()-getXmin())-1.0f;
569  }
570 
571  inline float getYnormalized() const
572  {
573  if (_pointerDataList.size()>=1) return _pointerDataList[_pointerDataList.size()-1]->getYnormalized();
574  if (_mouseYOrientation==Y_INCREASING_UPWARDS) return 2.0f*(getY()-getYmin())/(getYmax()-getYmin())-1.0f;
575  else return -(2.0f*(getY()-getYmin())/(getYmax()-getYmin())-1.0f);
576  }
577 #else
578 
584  inline float getXnormalized() const { return 2.0f*(getX()-getXmin())/(getXmax()-getXmin())-1.0f; }
585 
592  inline float getYnormalized() const
593  {
594  if (_mouseYOrientation==Y_INCREASING_UPWARDS) return 2.0f*(getY()-getYmin())/(getYmax()-getYmin())-1.0f;
595  else return -(2.0f*(getY()-getYmin())/(getYmax()-getYmin())-1.0f);
596  }
597 #endif
598 
600  void setMouseYOrientation(MouseYOrientation myo) { _mouseYOrientation = myo; }
601 
603  MouseYOrientation getMouseYOrientation() const { return _mouseYOrientation; }
604 
606  void setMouseYOrientationAndUpdateCoords(MouseYOrientation myo);
607 
609  void setButtonMask(int mask) { _buttonMask = mask; }
610 
612  int getButtonMask() const { return _buttonMask; }
613 
615  void setModKeyMask(int mask) { _modKeyMask = mask; }
616 
618  int getModKeyMask() const { return _modKeyMask; }
619 
621  void setScrollingMotion(ScrollingMotion motion) { _scrolling.motion = motion; }
622 
624  ScrollingMotion getScrollingMotion() const { return _scrolling.motion; }
625 
627  void setScrollingMotionDelta(float x, float y) {
628  _scrolling.motion = SCROLL_2D;
629  _scrolling.deltaX = x;
630  _scrolling.deltaY = y;
631  }
632 
634  void setScrollingDeltaX(float v) { _scrolling.deltaX = v; }
635 
637  float getScrollingDeltaX() const { return _scrolling.deltaX; }
638 
640  void setScrollingDeltaY(float v) { _scrolling.deltaY = v; }
641 
643  float getScrollingDeltaY() const { return _scrolling.deltaY; }
644 
645 
647  void setPenPressure(float pressure) { _tabletPen.pressure = pressure; }
648 
650  float getPenPressure() const { return _tabletPen.pressure; }
651 
653  void setPenTiltX(float tiltX) { _tabletPen.tiltX = tiltX; }
654 
656  float getPenTiltX() const { return _tabletPen.tiltX; }
657 
659  void setPenTiltY(float tiltY) { _tabletPen.tiltY = tiltY; }
660 
662  float getPenTiltY() const { return _tabletPen.tiltY; }
663 
665  void setPenRotation(float rotation) { _tabletPen.rotation = rotation; }
666 
668  float getPenRotation() const { return _tabletPen.rotation; }
669 
671  void setTabletPointerType(TabletPointerType pt) { _tabletPen.tabletPointerType = pt; }
672 
674  TabletPointerType getTabletPointerType() const { return _tabletPen.tabletPointerType; }
675 
677  const osg::Matrix getPenOrientation() const;
678 
679  void addTouchPoint(unsigned int id, TouchPhase phase, float x, float y, unsigned int tapCount = 0);
680 
681  void setTouchData(TouchData* td) { _touchData = td; }
682  TouchData* getTouchData() const { return _touchData.get(); }
683  bool isMultiTouchEvent() const { return (_touchData.valid()); }
684 
685  inline float getTouchPointNormalizedX(unsigned int ndx) const {
686  return (getTouchData()->get(ndx).x-_Xmin)/(_Xmax-_Xmin)*2.0f-1.0f;
687  }
688 
689  inline float getTouchPointNormalizedY(unsigned int ndx) const {
690  if (_mouseYOrientation==Y_INCREASING_UPWARDS)
691  return (getTouchData()->get(ndx).y-_Ymin)/(_Ymax-_Ymin)*2.0f-1.0f;
692  else
693  return -((getTouchData()->get(ndx).y-_Ymin)/(_Ymax-_Ymin)*2.0f-1.0f);
694  }
695 
696  typedef std::vector< osg::ref_ptr<PointerData> > PointerDataList;
697  void setPointerDataList(const PointerDataList& pdl) { _pointerDataList = pdl; }
698  PointerDataList& getPointerDataList() { return _pointerDataList; }
699  const PointerDataList& getPointerDataList() const { return _pointerDataList; }
700 
701  unsigned int getNumPointerData() const { return static_cast<unsigned int>(_pointerDataList.size()); }
702  PointerData* getPointerData(unsigned int i) { return _pointerDataList[i].get(); }
703  const PointerData* getPointerData(unsigned int i) const { return _pointerDataList[i].get(); }
704 
705  PointerData* getPointerData(osg::Object* obj) { for(unsigned int i=0;i<_pointerDataList.size(); ++i) { if (_pointerDataList[i]->object==obj) return _pointerDataList[i].get(); } return 0; }
706  const PointerData* getPointerData(osg::Object* obj) const { for(unsigned int i=0;i<_pointerDataList.size(); ++i) { if (_pointerDataList[i]->object==obj) return _pointerDataList[i].get(); } return 0; }
707  void addPointerData(PointerData* pd) { _pointerDataList.push_back(pd); }
708 
709  void copyPointerDataFrom(const osgGA::GUIEventAdapter& sourceEvent);
710 
711  protected:
712 
714  virtual ~GUIEventAdapter();
715 
717 
719  int _windowX;
720  int _windowY;
723  int _key;
725  int _button;
726  float _Xmin,_Xmax;
727  float _Ymin,_Ymax;
728  float _mx;
729  float _my;
733 
734  struct Scrolling {
736  float deltaX;
737  float deltaY;
738 
739  Scrolling() : motion(SCROLL_NONE), deltaX(0), deltaY(0) {}
740  Scrolling(const Scrolling& rhs) : motion(rhs.motion), deltaX(rhs.deltaX), deltaY(rhs.deltaY) {}
741  };
743 
744  struct TabletPen {
745  float pressure;
746  float tiltX;
747  float tiltY;
748  float rotation;
750 
751  TabletPen() : pressure(0), tiltX(0), tiltY(0), rotation(0), tabletPointerType(UNKNOWN) {}
752  TabletPen(const TabletPen& rhs) : pressure(rhs.pressure), tiltX(rhs.tiltX), tiltY(rhs.tiltY), rotation(rhs.rotation), tabletPointerType(rhs.tabletPointerType) {}
753  };
755 
757 
758 
759  PointerDataList _pointerDataList;
760 };
761 
762 }
763 
764 #endif
float getPenTiltX() const
get the tablet pen tiltX in degrees.
PointerData(osg::Object *obj, float in_x, float in_xMin, float in_xMax, float in_y, float in_yMin, float in_yMax)
float getTouchPointNormalizedX(unsigned int ndx) const
void addTouchPoint(unsigned int id, TouchPhase phase, float x, float y, unsigned int tap_count)
int getWindowHeight() const
unsigned int getNumPointerData() const
float getYnormalized() const
PointerData(const PointerData &pd)
void setButtonMask(int mask)
set current mouse button state.
void setPenRotation(float rotation)
set the tablet pen rotation around the Z-axis in degrees.
PointerData * getPointerData(unsigned int i)
PointerDataList & getPointerDataList()
osg::observer_ptr< osg::Object > object
void setGraphicsContext(osg::GraphicsContext *context)
void setModKeyMask(int mask)
set modifier key mask.
float getScrollingDeltaX() const
get the scrolling x-delta.
void setPenTiltY(float tiltY)
set the tablet pen tiltY in degrees.
int getUnmodifiedKey() const
const_iterator begin() const
const PointerData * getPointerData(unsigned int i) const
TouchData * getTouchData() const
float getXnormalized() const
const TouchPoint get(unsigned int i) const
float getXnormalized() const
void setPenTiltX(float tiltX)
set the tablet pen tiltX in degrees.
void setScrollingDeltaY(float v)
set the scrolling y-delta.
float getPenRotation() const
get the tablet pen rotation around the Z-axis in degrees.
virtual const GUIEventAdapter * asGUIEventAdapter() const
PointerDataList _pointerDataList
void setPointerDataList(const PointerDataList &pdl)
void setTouchData(TouchData *td)
float getPenTiltY() const
get the tablet pen tiltY in degrees.
void setScrollingMotionDelta(float x, float y)
set the scrolling delta to x,y and the scrolling motion to SCROLL_2D.
#define OSGGA_EXPORT
Definition: Export.h:40
#define META_Object(library, name)
Definition: Object.h:42
TouchPoint(unsigned int in_id, TouchPhase in_phase, float in_x, float in_y, unsigned int in_tap_count)
unsigned int getNumTouchPoints() const
GLint GLenum GLsizei width
Definition: GLU.h:71
PointerData & operator=(const PointerData &pd)
void setEventType(EventType Type)
void setButton(int button)
void setScrollingDeltaX(float v)
set the scrolling x-delta.
const PointerDataList & getPointerDataList() const
TouchData(const TouchData &td, const osg::CopyOp &copyop)
void setUnmodifiedKey(int key)
TouchSet::const_iterator const_iterator
virtual int getKey() const
void setMouseYOrientation(MouseYOrientation myo)
set mouse-Y orientation (mouse-Y increases upwards or downwards).
MouseYOrientation getMouseYOrientation() const
get mouse-Y orientation (mouse-Y increases upwards or downwards).
float getYnormalized() const
PointerData * getPointerData(osg::Object *obj)
void setTabletPointerType(TabletPointerType pt)
set the tablet pointer type.
osg::ref_ptr< TouchData > _touchData
float getScrollingDeltaY() const
get the scrolling y-delta.
GLint GLenum GLsizei GLsizei height
Definition: GLU.h:71
const osg::GraphicsContext * getGraphicsContext() const
int getModKeyMask() const
get modifier key mask.
void addPointerData(PointerData *pd)
void setScrollingMotion(ScrollingMotion motion)
set scrolling motion (for EventType::SCROLL).
ScrollingMotion getScrollingMotion() const
get scrolling motion (for EventType::SCROLL).
virtual GUIEventAdapter * asGUIEventAdapter()
Definition: AlphaFunc.h:19
float getTouchPointNormalizedY(unsigned int ndx) const
MouseYOrientation _mouseYOrientation
bool isMultiTouchEvent() const
TabletPointerType getTabletPointerType() const
get the tablet pointer type.
float getPenPressure() const
get the tablet pen pressure (range 0..1).
osg::GraphicsContext * getGraphicsContext()
void setPenPressure(float pressure)
set the tablet pen pressure (range 0..1).
virtual EventType getEventType() const
int getButtonMask() const
get current mouse button state.
const PointerData * getPointerData(osg::Object *obj) const
osg::observer_ptr< osg::GraphicsContext > _context
std::vector< TouchPoint > TouchSet
std::vector< osg::ref_ptr< PointerData > > PointerDataList