2003-01-21 21:14:29 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
|
|
|
|
*
|
|
|
|
* 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; }
|
|
|
|
|
|
|
|
/** 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. */
|
|
|
|
virtual int getXmin() const { return _Xmin; }
|
|
|
|
|
|
|
|
/** window maximum x. */
|
|
|
|
virtual int getXmax() const { return _Xmax; }
|
|
|
|
|
|
|
|
/** window minimum y. */
|
|
|
|
virtual int getYmin() const { return _Ymin; }
|
|
|
|
|
|
|
|
/** window maximum y. */
|
|
|
|
virtual int getYmax() const { return _Ymax; }
|
|
|
|
|
|
|
|
/** current mouse x position.*/
|
|
|
|
virtual int getX() const { return _mx; }
|
|
|
|
|
|
|
|
/** current mouse y position.*/
|
|
|
|
virtual int getY() const { return _my; }
|
|
|
|
|
|
|
|
/** 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.*/
|
|
|
|
static void setWindowSize(int Xmin, int Ymin, int Xmax, int Ymax);
|
|
|
|
|
|
|
|
/** static method for setting button state.*/
|
|
|
|
static void setButtonMask(unsigned int buttonMask);
|
|
|
|
|
|
|
|
/** method for adapting resize events. */
|
|
|
|
void adaptResize(double t, int Xmin, int Ymin, int Xmax, int Ymax);
|
|
|
|
|
|
|
|
|
|
|
|
/** 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();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
|
|
EventType _eventType;
|
|
|
|
int _key;
|
|
|
|
int _button;
|
|
|
|
int _Xmin,_Xmax;
|
|
|
|
int _Ymin,_Ymax;
|
|
|
|
int _mx;
|
|
|
|
int _my;
|
|
|
|
unsigned int _buttonMask;
|
2003-01-17 19:26:16 +08:00
|
|
|
unsigned int _modKeyMask;
|
2003-01-15 23:24:35 +08:00
|
|
|
double _time;
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
// used to store current button value
|
|
|
|
static int _s_button;
|
|
|
|
|
|
|
|
// used to store window min and max values.
|
|
|
|
static int _s_Xmin;
|
|
|
|
static int _s_Xmax;
|
|
|
|
static int _s_Ymin;
|
|
|
|
static int _s_Ymax;
|
|
|
|
static int _s_mx;
|
|
|
|
static int _s_my;
|
2003-01-17 19:26:16 +08:00
|
|
|
static int _s_modKeyMask;
|
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
|