2005-04-15 05:41:28 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield
|
2003-01-21 21:14:29 +08:00
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2003-01-15 23:24:35 +08:00
|
|
|
|
|
|
|
#ifndef OSGGLUT_ProducerEventAdapter
|
|
|
|
#define OSGGLUT_ProducerEventAdapter 1
|
|
|
|
|
2003-01-18 02:34:35 +08:00
|
|
|
#include <osgProducer/Export>
|
|
|
|
|
2003-01-15 23:24:35 +08:00
|
|
|
#include <osgGA/GUIEventAdapter>
|
|
|
|
#include <Producer/KeyboardMouse>
|
|
|
|
|
2003-01-18 02:34:35 +08:00
|
|
|
|
|
|
|
namespace osgProducer {
|
|
|
|
|
|
|
|
/** Class for adapting Producer events so that they can be used as input to osgGA::CameraManipulators.*/
|
|
|
|
class OSGPRODUCER_EXPORT EventAdapter : public osgGA::GUIEventAdapter
|
2003-01-15 23:24:35 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2003-01-18 02:34:35 +08:00
|
|
|
EventAdapter();
|
|
|
|
virtual ~EventAdapter() {}
|
2003-01-15 23:24:35 +08:00
|
|
|
|
|
|
|
/** Get the EventType of the GUI event.*/
|
|
|
|
virtual EventType getEventType() const { return _eventType; }
|
|
|
|
|
2005-06-08 18:36:56 +08:00
|
|
|
inline void setKey(int key) { _key = key; }
|
|
|
|
|
2003-01-15 23:24:35 +08:00
|
|
|
/** key pressed, return -1 if inappropriate for this event. */
|
|
|
|
virtual int getKey() const { return _key; }
|
|
|
|
|
|
|
|
/** button pressed/released, return -1 if inappropriate for this event.*/
|
|
|
|
virtual int getButton() const { return _button; }
|
|
|
|
|
|
|
|
/** window minimum x. */
|
2003-04-05 03:10:37 +08:00
|
|
|
virtual float getXmin() const { return _Xmin; }
|
2003-01-15 23:24:35 +08:00
|
|
|
|
|
|
|
/** window maximum x. */
|
2003-04-05 03:10:37 +08:00
|
|
|
virtual float getXmax() const { return _Xmax; }
|
2003-01-15 23:24:35 +08:00
|
|
|
|
|
|
|
/** window minimum y. */
|
2003-04-05 03:10:37 +08:00
|
|
|
virtual float getYmin() const { return _Ymin; }
|
2003-01-15 23:24:35 +08:00
|
|
|
|
|
|
|
/** window maximum y. */
|
2003-04-05 03:10:37 +08:00
|
|
|
virtual float getYmax() const { return _Ymax; }
|
2003-01-15 23:24:35 +08:00
|
|
|
|
2005-06-08 18:36:56 +08:00
|
|
|
inline void setX(float x) { _mx = x; }
|
|
|
|
|
2003-01-15 23:24:35 +08:00
|
|
|
/** current mouse x position.*/
|
2003-04-05 03:10:37 +08:00
|
|
|
virtual float getX() const { return _mx; }
|
2003-01-15 23:24:35 +08:00
|
|
|
|
2005-06-08 18:36:56 +08:00
|
|
|
inline void setY(float y) { _my = y; }
|
|
|
|
|
2003-01-15 23:24:35 +08:00
|
|
|
/** current mouse y position.*/
|
2003-04-05 03:10:37 +08:00
|
|
|
virtual float getY() const { return _my; }
|
2003-01-15 23:24:35 +08:00
|
|
|
|
2005-06-08 18:36:56 +08:00
|
|
|
inline void setButtonMak(unsigned int mask) { _buttonMask = mask; }
|
|
|
|
|
2003-01-15 23:24:35 +08:00
|
|
|
/** current mouse button state */
|
|
|
|
virtual unsigned int getButtonMask() const { return _buttonMask; }
|
|
|
|
|
|
|
|
/** time in seconds of event. */
|
|
|
|
virtual double time() const { return _time; }
|
|
|
|
|
2003-01-17 19:26:16 +08:00
|
|
|
virtual unsigned int getModKeyMask() const { return _modKeyMask; }
|
2003-01-15 23:24:35 +08:00
|
|
|
|
|
|
|
/** static method for setting window dimensions.*/
|
2003-04-05 03:10:37 +08:00
|
|
|
static void setWindowSize(float Xmin, float Ymin, float Xmax, float Ymax);
|
2003-01-15 23:24:35 +08:00
|
|
|
|
|
|
|
/** static method for setting button state.*/
|
|
|
|
static void setButtonMask(unsigned int buttonMask);
|
|
|
|
|
|
|
|
|
2003-04-05 03:10:37 +08:00
|
|
|
/** method for adapting resize events. */
|
|
|
|
void adaptResize(double t, float Xmin, float Ymin, float Xmax, float Ymax);
|
2003-01-15 23:24:35 +08:00
|
|
|
|
2003-05-07 19:13:49 +08:00
|
|
|
/** method for adapting mouse scroll wheel events. */
|
2005-11-18 01:44:48 +08:00
|
|
|
void adaptMouseScroll(double t, Producer::KeyboardMouseCallback::ScrollingMotion sm);
|
2003-05-07 19:13:49 +08:00
|
|
|
|
2003-01-15 23:24:35 +08:00
|
|
|
/** method for adapting mouse motion events whilst mouse buttons are pressed.*/
|
|
|
|
void adaptMouseMotion(double t, float x, float y);
|
|
|
|
|
|
|
|
void adaptButtonPress(double t,float x, float y, unsigned int button);
|
|
|
|
|
|
|
|
void adaptButtonRelease(double t,float x, float y, unsigned int button);
|
|
|
|
|
|
|
|
/** method for adapting keyboard events.*/
|
2003-01-17 19:26:16 +08:00
|
|
|
void adaptKeyPress( double t, Producer::KeySymbol key);
|
2003-01-15 23:24:35 +08:00
|
|
|
|
|
|
|
void adaptKeyRelease( double t, Producer::KeySymbol key);
|
|
|
|
|
|
|
|
/** method for adapting frame events, i.e. idle/display callback.*/
|
|
|
|
void adaptFrame(double t);
|
|
|
|
|
2003-01-17 19:26:16 +08:00
|
|
|
|
2003-01-15 23:24:35 +08:00
|
|
|
void copyStaticVariables();
|
|
|
|
|
2005-08-29 20:05:17 +08:00
|
|
|
public:
|
2003-01-15 23:24:35 +08:00
|
|
|
|
|
|
|
EventType _eventType;
|
|
|
|
int _key;
|
|
|
|
int _button;
|
2003-04-05 03:10:37 +08:00
|
|
|
float _Xmin,_Xmax;
|
|
|
|
float _Ymin,_Ymax;
|
|
|
|
float _mx;
|
|
|
|
float _my;
|
2003-01-15 23:24:35 +08:00
|
|
|
unsigned int _buttonMask;
|
2003-01-17 19:26:16 +08:00
|
|
|
unsigned int _modKeyMask;
|
2003-01-15 23:24:35 +08:00
|
|
|
double _time;
|
|
|
|
|
2003-03-19 23:49:21 +08:00
|
|
|
public:
|
|
|
|
|
2003-01-15 23:24:35 +08:00
|
|
|
// used to accumulate the button mask state, it represents
|
|
|
|
// the current button mask state, which is modified by the
|
|
|
|
// adaptMouse() method which then copies it to value _buttonMask
|
|
|
|
// which required the mouse buttons state at the time of the event.
|
|
|
|
static unsigned int _s_accumulatedButtonMask;
|
|
|
|
|
2005-11-18 01:44:48 +08:00
|
|
|
// used to store current button value
|
|
|
|
static int _s_button;
|
2003-01-15 23:24:35 +08:00
|
|
|
|
|
|
|
// used to store window min and max values.
|
2003-04-05 03:10:37 +08:00
|
|
|
static float _s_Xmin;
|
|
|
|
static float _s_Xmax;
|
|
|
|
static float _s_Ymin;
|
|
|
|
static float _s_Ymax;
|
|
|
|
static float _s_mx;
|
|
|
|
static float _s_my;
|
2003-01-17 19:26:16 +08:00
|
|
|
static int _s_modKeyMask;
|
2003-03-24 21:43:22 +08:00
|
|
|
|
2003-01-15 23:24:35 +08:00
|
|
|
};
|
|
|
|
|
2003-01-18 02:34:35 +08:00
|
|
|
}
|
|
|
|
|
2003-01-15 23:24:35 +08:00
|
|
|
#endif
|