Changeset 13041 for OpenSceneGraph/trunk/include/osgGA/GUIEventAdapter
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgGA/GUIEventAdapter
r12125 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 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 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 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ 13 13 14 14 #ifndef OSGGA_EVENT 15 #define OSGGA_EVENT 1 15 #define OSGGA_EVENT 1 16 16 17 17 #include <osg/Object> … … 29 29 public: 30 30 31 enum MouseButtonMask { 31 enum MouseButtonMask { 32 32 LEFT_MOUSE_BUTTON = 1<<0, 33 33 MIDDLE_MOUSE_BUTTON = 1<<1, … … 37 37 enum EventType { 38 38 NONE = 0, 39 PUSH = 1<<0, 39 PUSH = 1<<0, 40 40 RELEASE = 1<<1, 41 41 DOUBLECLICK = 1<<2, … … 209 209 KEY_KP_8 = 0xFFB8, 210 210 KEY_KP_9 = 0xFFB9, 211 211 212 212 /* 213 213 * Auxiliary Functions; note the duplicate definitions for left and right … … 303 303 }; 304 304 305 enum ScrollingMotion 305 enum ScrollingMotion 306 306 { 307 307 SCROLL_NONE, … … 313 313 }; 314 314 315 enum TabletPointerType 315 enum TabletPointerType 316 316 { 317 317 UNKNOWN = 0, … … 320 320 ERASER 321 321 }; 322 323 enum TouchPhase 322 323 enum TouchPhase 324 324 { 325 325 TOUCH_UNKNOWN, … … 329 329 TOUCH_ENDED 330 330 }; 331 331 332 332 class TouchData : public osg::Referenced { 333 333 public: … … 336 336 TouchPhase phase; 337 337 float x, y; 338 338 339 339 unsigned int tapCount; 340 340 TouchPoint() : id(0), phase(TOUCH_UNKNOWN), x(0.0f), y(0.0f), tapCount(0) {} 341 TouchPoint(unsigned int in_id, TouchPhase in_phase, float in_x, float in_y, unsigned int in_tap_count) 342 : id(in_id), 341 TouchPoint(unsigned int in_id, TouchPhase in_phase, float in_x, float in_y, unsigned int in_tap_count) 342 : id(in_id), 343 343 phase(in_phase), 344 x(in_x), 345 y(in_y), 346 tapCount(in_tap_count) 344 x(in_x), 345 y(in_y), 346 tapCount(in_tap_count) 347 347 { 348 348 } 349 349 }; 350 350 351 351 typedef std::vector<TouchPoint> TouchSet; 352 352 353 353 typedef TouchSet::iterator iterator; 354 354 typedef TouchSet::const_iterator const_iterator; 355 355 356 356 TouchData() : osg::Referenced() {} 357 357 358 358 unsigned int getNumTouchPoints() const { return _touches.size(); } 359 359 360 360 iterator begin() { return _touches.begin(); } 361 361 const_iterator begin() const { return _touches.begin(); } 362 362 363 363 iterator end() { return _touches.end(); } 364 364 const_iterator end() const { return _touches.end(); } 365 365 366 366 const TouchPoint get(unsigned int i) const { return _touches[i]; } 367 367 368 368 protected: 369 369 370 370 void addTouchPoint(unsigned int id, TouchPhase phase, float x, float y, unsigned int tap_count) { 371 371 _touches.push_back(TouchPoint(id, phase, x, y, tap_count)); 372 372 } 373 373 374 374 TouchSet _touches; 375 376 friend class GUIEventAdapter; 377 }; 378 375 376 friend class GUIEventAdapter; 377 }; 378 379 379 public: 380 380 … … 384 384 385 385 META_Object(osgGA, GUIEventAdapter); 386 386 387 387 388 388 /** Get the accumulated event state singleton. … … 416 416 void setGraphicsContext(osg::GraphicsContext* context) { _context = context; } 417 417 const osg::GraphicsContext* getGraphicsContext() const { return _context.get(); } 418 418 419 419 420 420 /** set window rectangle. */ … … 442 442 /** set virtual key pressed. */ 443 443 void setUnmodifiedKey(int key) { _unmodifiedKey = key; } 444 444 445 445 /** get virtual key pressed. */ 446 446 int getUnmodifiedKey() const { return _unmodifiedKey; } 447 447 448 448 /** set button pressed/released.*/ 449 449 void setButton(int button) { _button = button; } … … 483 483 * return the current mouse x value normalized to the range of -1 to 1. 484 484 * -1 would be the left hand side of the window. 485 * 0.0 would be the middle of the window. 485 * 0.0 would be the middle of the window. 486 486 * +1 would be the right hand side of the window. 487 487 */ … … 491 491 * return the current mouse y value normalized to the range of -1 to 1. 492 492 * -1 would be the bottom of the window. 493 * 0.0 would be the middle of the window. 493 * 0.0 would be the middle of the window. 494 494 * +1 would be the top of the window. 495 495 */ … … 572 572 573 573 void addTouchPoint(unsigned int id, TouchPhase phase, float x, float y, unsigned int tapCount = 0); 574 574 575 575 TouchData* getTouchData() const { return _touchData.get(); } 576 576 bool isMultiTouchEvent() const { return (_touchData.valid()); } 577 577 578 578 protected: 579 579 … … 581 581 virtual ~GUIEventAdapter(); 582 582 583 mutable bool _handled; 583 mutable bool _handled; 584 584 EventType _eventType; 585 585 double _time; … … 622 622 }; 623 623 TabletPen _tabletPen; 624 625 osg::ref_ptr<TouchData> _touchData; 624 625 osg::ref_ptr<TouchData> _touchData; 626 626 }; 627 627
