Converted osgGA::GUIEventAdapter into a concrete class capable of respresenting
keyboard and mouse events. Added osgGA::EventQueue class to support a thread safe event queue and adaption of keyboard and mouse events. Removed osgProducer::EventAdapter as GUIEventAdapter replaces it. Adapted osgProducer and examples to work with the new changes to osgGA.
This commit is contained in:
parent
582967286a
commit
dbbabf87c6
@ -99,6 +99,10 @@ SOURCE=..\..\src\osgGA\AnimationPathManipulator.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgGA\EventQueue.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgGA\EventVisitor.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -175,6 +179,10 @@ SOURCE=..\..\Include\osgGA\Export
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\osgGA\EventQueue
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\osgGA\EventVisitor
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -95,10 +95,6 @@ LINK32=link.exe
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgProducer\EventAdapter.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgProducer\KeyboardMouseCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -131,10 +127,6 @@ SOURCE=..\..\src\osgProducer\ViewerEventHandler.cpp
|
||||
# PROP Default_Filter ";h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\osgProducer\EventAdapter
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\osgProducer\Export
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -103,6 +103,14 @@ SOURCE=..\..\..\src\osgWrappers\osgGA\AnimationPathManipulator.cpp
|
||||
SOURCE=..\..\..\src\osgWrappers\osgGA\DriveManipulator.cpp
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
SOURCE=..\..\..\src\osgWrappers\osgGA\Event.cpp
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
SOURCE=..\..\..\src\osgWrappers\osgGA\EventQueue.cpp
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
SOURCE=..\..\..\src\osgWrappers\osgGA\EventVisitor.cpp
|
||||
# End Source File
|
||||
|
@ -96,7 +96,7 @@ LINK32=link.exe
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
|
||||
# Begin Source File
|
||||
SOURCE=..\..\..\src\osgWrappers\osgProducer\EventAdapter.cpp
|
||||
SOURCE=..\..\..\src\osgWrappers\osgProducer\Export.cpp
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
@ -862,9 +862,9 @@ bool GameEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA
|
||||
if (_numberOfPlayers>=2) _players[1].moveRight();
|
||||
}
|
||||
|
||||
static double previous_time = ea.time();
|
||||
double dt = ea.time()-previous_time;
|
||||
previous_time = ea.time();
|
||||
static double previous_time = ea.getTime();
|
||||
double dt = ea.getTime()-previous_time;
|
||||
previous_time = ea.getTime();
|
||||
|
||||
// move objects
|
||||
for(CatchableObjectList::iterator itr=_catchableObjects.begin();
|
||||
@ -921,7 +921,7 @@ bool GameEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA
|
||||
}
|
||||
|
||||
if (!(*itr)->anyInside(_origin, _origin+_width+_height) ||
|
||||
(*itr)->needToRemove(ea.time()) ||
|
||||
(*itr)->needToRemove(ea.getTime()) ||
|
||||
removeEntry)
|
||||
{
|
||||
// need to remove
|
||||
@ -944,16 +944,16 @@ bool GameEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA
|
||||
// hit base line
|
||||
(*itr)->explode();
|
||||
(*itr)->stop();
|
||||
(*itr)->setTimeToRemove(ea.time()+3.0);
|
||||
(*itr)->setTimeToRemove(ea.getTime()+3.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// create new catchable objects
|
||||
static double previousTime = ea.time();
|
||||
double deltaTime = ea.time()-previousTime;
|
||||
previousTime = ea.time();
|
||||
static double previousTime = ea.getTime();
|
||||
double deltaTime = ea.getTime()-previousTime;
|
||||
previousTime = ea.getTime();
|
||||
|
||||
float numDropsPerSecond = _initialNumDropsPerSecond * (_level+1);
|
||||
float r = (float)rand()/(float)RAND_MAX;
|
||||
|
@ -64,7 +64,7 @@ class CameraPacket {
|
||||
// us to do this, even though its a reference counted object.
|
||||
osg::FrameStamp _frameStamp;
|
||||
|
||||
osgProducer::KeyboardMouseCallback::EventQueue _events;
|
||||
osgGA::EventQueue::Events _events;
|
||||
|
||||
};
|
||||
|
||||
@ -295,36 +295,36 @@ class DataConverter
|
||||
|
||||
}
|
||||
|
||||
void write(const osgProducer::EventAdapter& event)
|
||||
void write(const osgGA::GUIEventAdapter& event)
|
||||
{
|
||||
writeUInt(event._eventType);
|
||||
writeUInt(event._key);
|
||||
writeUInt(event._button);
|
||||
writeFloat(event._Xmin);
|
||||
writeFloat(event._Xmax);
|
||||
writeFloat(event._Ymin);
|
||||
writeFloat(event._Ymax);
|
||||
writeFloat(event._mx);
|
||||
writeFloat(event._my);
|
||||
writeUInt(event._buttonMask);
|
||||
writeUInt(event._modKeyMask);
|
||||
writeDouble(event._time);
|
||||
writeUInt(event.getEventType());
|
||||
writeUInt(event.getKey());
|
||||
writeUInt(event.getButton());
|
||||
writeFloat(event.getXmin());
|
||||
writeFloat(event.getXmax());
|
||||
writeFloat(event.getYmin());
|
||||
writeFloat(event.getYmax());
|
||||
writeFloat(event.getX());
|
||||
writeFloat(event.getY());
|
||||
writeUInt(event.getButtonMask());
|
||||
writeUInt(event.getModKeyMask());
|
||||
writeDouble(event.getTime());
|
||||
}
|
||||
|
||||
void read(osgProducer::EventAdapter& event)
|
||||
void read(osgGA::GUIEventAdapter& event)
|
||||
{
|
||||
event._eventType = (osgGA::GUIEventAdapter::EventType)readUInt();
|
||||
event._key = readUInt();
|
||||
event._button = readUInt();
|
||||
event._Xmin = readFloat();
|
||||
event._Xmax = readFloat();
|
||||
event._Ymin = readFloat();
|
||||
event._Ymax = readFloat();
|
||||
event._mx = readFloat();
|
||||
event._my = readFloat();
|
||||
event._buttonMask = readUInt();
|
||||
event._modKeyMask = readUInt();
|
||||
event._time = readDouble();
|
||||
event.setEventType((osgGA::GUIEventAdapter::EventType)readUInt());
|
||||
event.setKey(readUInt());
|
||||
event.setButton(readUInt());
|
||||
event.setXmin(readFloat());
|
||||
event.setXmax(readFloat());
|
||||
event.setYmin(readFloat());
|
||||
event.setYmax(readFloat());
|
||||
event.setX(readFloat());
|
||||
event.setY(readFloat());
|
||||
event.setButtonMask(readUInt());
|
||||
event.setModKeyMask(readUInt());
|
||||
event.setTime(readDouble());
|
||||
}
|
||||
|
||||
void write(CameraPacket& cameraPacket)
|
||||
@ -337,9 +337,11 @@ class DataConverter
|
||||
write(cameraPacket._frameStamp);
|
||||
|
||||
writeUInt(cameraPacket._events.size());
|
||||
for(unsigned int i=0;i<cameraPacket._events.size();++i)
|
||||
for(osgGA::EventQueue::Events::iterator itr = cameraPacket._events.begin();
|
||||
itr != cameraPacket._events.end();
|
||||
++itr)
|
||||
{
|
||||
write(*(cameraPacket._events[i]));
|
||||
write(*(*itr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -360,7 +362,7 @@ class DataConverter
|
||||
unsigned int numEvents = readUInt();
|
||||
for(unsigned int i=0;i<numEvents;++i)
|
||||
{
|
||||
osgProducer::EventAdapter* event = new osgProducer::EventAdapter;
|
||||
osgGA::GUIEventAdapter* event = new osgGA::GUIEventAdapter;
|
||||
read(*(event));
|
||||
cameraPacket._events.push_back(event);
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ bool GliderManipulator::calcMovement()
|
||||
if (_ga_t0.get()==NULL || _ga_t1.get()==NULL) return false;
|
||||
|
||||
|
||||
double dt = _ga_t0->time()-_ga_t1->time();
|
||||
double dt = _ga_t0->getTime()-_ga_t1->getTime();
|
||||
|
||||
if (dt<0.0f)
|
||||
{
|
||||
|
@ -160,7 +160,7 @@ bool TestManipulator::isMouseMoving()
|
||||
float dx = _ga_t0->getXnormalized()-_ga_t1->getXnormalized();
|
||||
float dy = _ga_t0->getYnormalized()-_ga_t1->getYnormalized();
|
||||
float len = sqrtf(dx*dx+dy*dy);
|
||||
float dt = _ga_t0->time()-_ga_t1->time();
|
||||
float dt = _ga_t0->getTime()-_ga_t1->getTime();
|
||||
|
||||
return (len>dt*velocity);
|
||||
}
|
||||
|
@ -612,17 +612,17 @@ bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
|
||||
if (ea.getKey()=='a')
|
||||
{
|
||||
_autoSteppingActive = !_autoSteppingActive;
|
||||
_previousTime = ea.time();
|
||||
_previousTime = ea.getTime();
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='n')
|
||||
{
|
||||
_album->nextPage(ea.time()+1.0f);
|
||||
_album->nextPage(ea.getTime()+1.0f);
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='p')
|
||||
{
|
||||
_album->previousPage(ea.time()+1.0f);
|
||||
_album->previousPage(ea.getTime()+1.0f);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -634,13 +634,13 @@ bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
|
||||
if (_firstTraversal)
|
||||
{
|
||||
_firstTraversal = false;
|
||||
_previousTime = ea.time();
|
||||
_previousTime = ea.getTime();
|
||||
}
|
||||
else if (ea.time()-_previousTime>_timePerSlide)
|
||||
else if (ea.getTime()-_previousTime>_timePerSlide)
|
||||
{
|
||||
_previousTime = ea.time();
|
||||
_previousTime = ea.getTime();
|
||||
|
||||
_album->nextPage(ea.time()+1.0f);
|
||||
_album->nextPage(ea.getTime()+1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
|
||||
if (ea.getKey()=='a')
|
||||
{
|
||||
_autoSteppingActive = !_autoSteppingActive;
|
||||
_previousTime = ea.time();
|
||||
_previousTime = ea.getTime();
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='n')
|
||||
|
@ -667,8 +667,8 @@ class FollowMouseCallback : public osgGA::GUIEventHandler, public osg::StateSet:
|
||||
if (ev)
|
||||
{
|
||||
osgGA::GUIActionAdapter* aa = ev->getActionAdapter();
|
||||
osgGA::EventVisitor::EventList& events = ev->getEventList();
|
||||
for(osgGA::EventVisitor::EventList::iterator itr=events.begin();
|
||||
osgGA::EventQueue::Events& events = ev->getEvents();
|
||||
for(osgGA::EventQueue::Events::iterator itr=events.begin();
|
||||
itr!=events.end();
|
||||
++itr)
|
||||
{
|
||||
|
@ -27,8 +27,7 @@
|
||||
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
#include <osgGA/GUIActionAdapter>
|
||||
|
||||
#include <list>
|
||||
#include <osgGA/EventQueue>
|
||||
|
||||
namespace osgGA {
|
||||
|
||||
@ -54,42 +53,16 @@ class OSGGA_EXPORT EventVisitor : public osg::NodeVisitor
|
||||
|
||||
typedef std::list< osg::ref_ptr<GUIEventAdapter> > EventList;
|
||||
|
||||
void setEventList(const EventList& events) { _events = events; }
|
||||
EventList& getEventList() { return _events; }
|
||||
const EventList& getEventList() const { return _events; }
|
||||
|
||||
void addEvent(GUIEventAdapter* event);
|
||||
void removeEvent(GUIEventAdapter* event);
|
||||
|
||||
void setEventHandled(bool handled) { _handled = handled; }
|
||||
bool getEventHandled() const { return _handled; }
|
||||
|
||||
public:
|
||||
|
||||
|
||||
/** method for adapting resize events. */
|
||||
void eventResize(float Xmin, float Ymin, float Xmax, float Ymax);
|
||||
|
||||
/** method for adapting mouse scroll wheel events. */
|
||||
void eventMouseScroll(GUIEventAdapter::ScrollingMotion sm);
|
||||
|
||||
/** method for adapting mouse motion events whilst mouse buttons are pressed.*/
|
||||
void adaptMouseMotion(float x, float y);
|
||||
|
||||
void adaptButtonPress(float x, float y, unsigned int button);
|
||||
|
||||
void adaptButtonRelease(float x, float y, unsigned int button);
|
||||
|
||||
/** method for adapting keyboard events.*/
|
||||
void adaptKeyPress( GUIEventAdapter::KeySymbol key);
|
||||
|
||||
void adaptKeyRelease( GUIEventAdapter::KeySymbol key);
|
||||
|
||||
/** method for adapting frame events, i.e. idle/display callback.*/
|
||||
void adaptFrame(double t);
|
||||
|
||||
|
||||
|
||||
void setEvents(const EventQueue::Events& events) { _events = events; }
|
||||
EventQueue::Events& getEvents() { return _events; }
|
||||
const EventQueue::Events& getEvents() const { return _events; }
|
||||
|
||||
public:
|
||||
|
||||
@ -113,9 +86,6 @@ class OSGGA_EXPORT EventVisitor : public osg::NodeVisitor
|
||||
|
||||
protected:
|
||||
|
||||
// /** Prevent unwanted copy construction.*/
|
||||
// EventVisitor(const EventVisitor&):osg::NodeVisitor() {}
|
||||
|
||||
/** Prevent unwanted copy operator.*/
|
||||
EventVisitor& operator = (const EventVisitor&) { return *this; }
|
||||
|
||||
@ -164,8 +134,8 @@ class OSGGA_EXPORT EventVisitor : public osg::NodeVisitor
|
||||
|
||||
osg::ref_ptr<GUIEventAdapter> _accumulateEventState;
|
||||
|
||||
EventList _events;
|
||||
bool _handled;
|
||||
EventQueue::Events _events;
|
||||
|
||||
};
|
||||
|
||||
|
@ -11,21 +11,22 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGGA_GUIEVENTADAPTER
|
||||
#define OSGGA_GUIEVENTADAPTER 1
|
||||
#ifndef OSGGA_EVENT
|
||||
#define OSGGA_EVENT 1
|
||||
|
||||
#include <osg/Referenced>
|
||||
#include <osgGA/Export>
|
||||
|
||||
namespace osgGA{
|
||||
|
||||
|
||||
/**
|
||||
Pure virtual base class for adapting platform specific events into
|
||||
generic keyboard and mouse events.
|
||||
Pure virtual base class for adapting platform specific GUIEventAdapters into
|
||||
generic keyboard and mouse GUIEventAdapters.
|
||||
|
||||
Used as GUI toolkit-independent input into GUIEventAdapters. Viewer
|
||||
writers should subclass this base class to implement the functionality
|
||||
to translate one of their GUI events, e.g. a Qt Event or an MFC Event,
|
||||
to translate one of their GUI GUIEventAdapters, e.g. a Qt GUIEventAdapter or an MFC GUIEventAdapter,
|
||||
as appropriate.
|
||||
*/
|
||||
class OSGGA_EXPORT GUIEventAdapter : public osg::Referenced
|
||||
@ -49,10 +50,7 @@ public:
|
||||
KEYUP,
|
||||
FRAME,
|
||||
RESIZE,
|
||||
SCROLLUP,
|
||||
SCROLLDOWN,
|
||||
SCROLLLEFT,
|
||||
SCROLLRIGHT
|
||||
SCROLL
|
||||
};
|
||||
|
||||
enum KeySymbol
|
||||
@ -233,63 +231,99 @@ public:
|
||||
|
||||
enum ScrollingMotion
|
||||
{
|
||||
SCROLL_LEFT,
|
||||
SCROLL_RIGHT,
|
||||
SCROLL_UP,
|
||||
SCROLL_DOWN
|
||||
};
|
||||
|
||||
/** Get the EventType of the GUI event.*/
|
||||
void setEventType(EventType eventType) { _eventType = eventType; }
|
||||
public:
|
||||
|
||||
/** Get the EventType of the GUI event.*/
|
||||
GUIEventAdapter();
|
||||
|
||||
GUIEventAdapter(const GUIEventAdapter& rhs);
|
||||
|
||||
/** Get the Type of the GUI GUIEventAdapter.*/
|
||||
void setEventType(EventType Type) { _eventType = Type; }
|
||||
|
||||
/** Get the Type of the GUI GUIEventAdapter.*/
|
||||
virtual EventType getEventType() const { return _eventType; }
|
||||
|
||||
/** time in seconds of event. */
|
||||
/** set time in seconds of event. */
|
||||
void setTime(double time) { _time = time; }
|
||||
|
||||
/** time in seconds of event. */
|
||||
/** get time in seconds of event. */
|
||||
double getTime() const { return _time; }
|
||||
|
||||
/** deprecated function for getting time of event. */
|
||||
double time() const { return _time; }
|
||||
|
||||
/** time in seconds of event. */
|
||||
virtual double time() const { return getTime(); }
|
||||
|
||||
|
||||
/** set key pressed. */
|
||||
inline void setKey(int key) { _key = key; }
|
||||
|
||||
/** key pressed, return -1 if inappropriate for this event. */
|
||||
/** get key pressed, return -1 if inappropriate for this GUIEventAdapter. */
|
||||
virtual int getKey() const { return _key; }
|
||||
|
||||
/** button pressed/released, return -1 if inappropriate for this event.*/
|
||||
virtual int getButton() const { return _button; }
|
||||
/** set button pressed/released.*/
|
||||
void setButton(int button) { _button = button; }
|
||||
|
||||
/** window minimum x. */
|
||||
virtual float getXmin() const { return _Xmin; }
|
||||
/** button pressed/released, return -1 if inappropriate for this GUIEventAdapter.*/
|
||||
int getButton() const { return _button; }
|
||||
|
||||
/** window maximum x. */
|
||||
virtual float getXmax() const { return _Xmax; }
|
||||
/** set window minimum x. */
|
||||
void setWindowSize(float Xmin, float Ymin, float Xmax, float Ymax);
|
||||
|
||||
/** window minimum y. */
|
||||
virtual float getYmin() const { return _Ymin; }
|
||||
/** set window minimum x. */
|
||||
void setXmin(float x) { _Xmin = x; }
|
||||
|
||||
/** window maximum y. */
|
||||
virtual float getYmax() const { return _Ymax; }
|
||||
/** get window minimum x. */
|
||||
float getXmin() const { return _Xmin; }
|
||||
|
||||
inline void setX(float x) { _mx = x; }
|
||||
/** set window maximum x. */
|
||||
void setXmax(float x) { _Xmax = x; }
|
||||
|
||||
/** current mouse x position.*/
|
||||
virtual float getX() const { return _mx; }
|
||||
/** get window maximum x. */
|
||||
float getXmax() const { return _Xmax; }
|
||||
|
||||
inline void setY(float y) { _my = y; }
|
||||
/** set window minimum y. */
|
||||
void setYmin(float y) { _Ymin = y; }
|
||||
|
||||
/** current mouse y position.*/
|
||||
virtual float getY() const { return _my; }
|
||||
/** get window minimum y. */
|
||||
float getYmin() const { return _Ymin; }
|
||||
|
||||
inline void setButtonMask(unsigned int mask) { _buttonMask = mask; }
|
||||
/** set window maYimum y. */
|
||||
void setYmax(float y) { _Ymax = y; }
|
||||
|
||||
/** current mouse button state */
|
||||
virtual unsigned int getButtonMask() const { return _buttonMask; }
|
||||
/** get window maYimum y. */
|
||||
float getYmax() const { return _Ymax; }
|
||||
|
||||
/** set current mouse x position.*/
|
||||
void setX(float x) { _mx = x; }
|
||||
|
||||
/** get current mouse x position.*/
|
||||
float getX() const { return _mx; }
|
||||
|
||||
/** set current mouse y position.*/
|
||||
void setY(float y) { _my = y; }
|
||||
|
||||
/** get current mouse y position.*/
|
||||
float getY() const { return _my; }
|
||||
|
||||
/** set current mouse button state */
|
||||
void setButtonMask(unsigned int mask) { _buttonMask = mask; }
|
||||
|
||||
/** get current mouse button state */
|
||||
unsigned int getButtonMask() const { return _buttonMask; }
|
||||
|
||||
void setModKeyMask(unsigned int mask) { _modKeyMask = mask; }
|
||||
|
||||
unsigned int getModKeyMask() const { return _modKeyMask; }
|
||||
|
||||
|
||||
void setScrollingMotion(ScrollingMotion motion) { _scrollingMotion = motion; }
|
||||
|
||||
ScrollingMotion getScrollingMotion() const { return _scrollingMotion; }
|
||||
|
||||
virtual unsigned int getModKeyMask() const { return _modKeyMask; }
|
||||
|
||||
/** return the getX() value normalised to the range of -1 to 1.
|
||||
* -1 would be the left hand side of the window.
|
||||
@ -310,32 +344,13 @@ public:
|
||||
void setMouseYOrientation(MouseYOrientation myo) { _mouseYOrientation = myo; }
|
||||
MouseYOrientation getMouseYOrientation() const { return _mouseYOrientation; }
|
||||
|
||||
protected:
|
||||
|
||||
GUIEventAdapter(MouseYOrientation myo=Y_INCREASING_DOWNWARDS):_mouseYOrientation(myo) {}
|
||||
|
||||
GUIEventAdapter(const GUIEventAdapter& rhs):
|
||||
Referenced(),
|
||||
_eventType(rhs._eventType),
|
||||
_time(rhs._time),
|
||||
_key(rhs._key),
|
||||
_button(rhs._button),
|
||||
_Xmin(rhs._Xmin),
|
||||
_Xmax(rhs._Xmax),
|
||||
_Ymin(rhs._Ymin),
|
||||
_Ymax(rhs._Ymax),
|
||||
_mx(rhs._mx),
|
||||
_my(rhs._my),
|
||||
_buttonMask(rhs._buttonMask),
|
||||
_modKeyMask(rhs._modKeyMask),
|
||||
_mouseYOrientation(rhs._mouseYOrientation) {}
|
||||
|
||||
protected:
|
||||
|
||||
/** Force users to create on heap, so that multiple referencing is safe.*/
|
||||
virtual ~GUIEventAdapter();
|
||||
|
||||
public:
|
||||
|
||||
EventType _eventType;
|
||||
double _time;
|
||||
|
||||
@ -347,6 +362,7 @@ protected:
|
||||
float _my;
|
||||
unsigned int _buttonMask;
|
||||
unsigned int _modKeyMask;
|
||||
ScrollingMotion _scrollingMotion;
|
||||
MouseYOrientation _mouseYOrientation;
|
||||
};
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace osgGA{
|
||||
|
||||
class GUIEventAdapter;
|
||||
class GUIActionAdapter;
|
||||
|
||||
/**
|
||||
|
@ -1,89 +0,0 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 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.
|
||||
*/
|
||||
|
||||
#ifndef OSGGLUT_ProducerEventAdapter
|
||||
#define OSGGLUT_ProducerEventAdapter 1
|
||||
|
||||
#include <osgProducer/Export>
|
||||
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
#include <Producer/KeyboardMouse>
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
public:
|
||||
EventAdapter();
|
||||
virtual ~EventAdapter() {}
|
||||
|
||||
|
||||
/** static method for setting window dimensions.*/
|
||||
static void setWindowSize(float Xmin, float Ymin, float Xmax, float Ymax);
|
||||
|
||||
/** static method for setting button state.*/
|
||||
static void setButtonMask(unsigned int buttonMask);
|
||||
|
||||
|
||||
/** method for adapting resize events. */
|
||||
void adaptResize(double t, float Xmin, float Ymin, float Xmax, float Ymax);
|
||||
|
||||
/** method for adapting mouse scroll wheel events. */
|
||||
void adaptMouseScroll(double t, Producer::KeyboardMouseCallback::ScrollingMotion sm);
|
||||
|
||||
/** 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.*/
|
||||
void adaptKeyPress( double t, Producer::KeySymbol key);
|
||||
|
||||
void adaptKeyRelease( double t, Producer::KeySymbol key);
|
||||
|
||||
/** method for adapting frame events, i.e. idle/display callback.*/
|
||||
void adaptFrame(double t);
|
||||
|
||||
|
||||
void copyStaticVariables();
|
||||
|
||||
public:
|
||||
|
||||
// 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 float _s_Xmin;
|
||||
static float _s_Xmax;
|
||||
static float _s_Ymin;
|
||||
static float _s_Ymax;
|
||||
static float _s_mx;
|
||||
static float _s_my;
|
||||
static int _s_modKeyMask;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -20,8 +20,7 @@
|
||||
|
||||
#include <Producer/RenderSurface> // For definition of KeySymbol
|
||||
#include <Producer/KeyboardMouse>
|
||||
|
||||
#include <osgProducer/EventAdapter>
|
||||
#include <osgGA/EventQueue>
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Timer>
|
||||
@ -32,13 +31,7 @@ namespace osgProducer {
|
||||
class OSGPRODUCER_EXPORT KeyboardMouseCallback : public Producer::KeyboardMouseCallback
|
||||
{
|
||||
public:
|
||||
KeyboardMouseCallback(Producer::KeyboardMouse* keyboardMouse, bool &done, bool escapeKeySetsDone=true) :
|
||||
Producer::KeyboardMouseCallback(),
|
||||
_keyboardMouse(keyboardMouse),
|
||||
_mx(0.0f),_my(0.0f),_mbutton(0),
|
||||
_done(done),
|
||||
_escapeKeySetsDone(escapeKeySetsDone)
|
||||
{}
|
||||
KeyboardMouseCallback(Producer::KeyboardMouse* keyboardMouse, bool &done, bool escapeKeySetsDone=true);
|
||||
|
||||
virtual ~KeyboardMouseCallback() {}
|
||||
|
||||
@ -68,27 +61,25 @@ class OSGPRODUCER_EXPORT KeyboardMouseCallback : public Producer::KeyboardMouseC
|
||||
|
||||
|
||||
// local methods and members
|
||||
typedef std::vector< osg::ref_ptr<EventAdapter> > EventQueue;
|
||||
typedef osgGA::EventQueue::Events EventQueue;
|
||||
|
||||
double getEventQueue(EventQueue& queue);
|
||||
double copyEventQueue(EventQueue& queue) const;
|
||||
double setEventQueue(EventQueue& queue);
|
||||
double appendEventQueue(EventQueue& queue);
|
||||
osgGA::EventQueue* getEventQueue() { return _eventQueue.get(); }
|
||||
|
||||
bool takeEventQueue(EventQueue& queue);
|
||||
bool copyEventQueue(EventQueue& queue) const;
|
||||
void setEventQueue(EventQueue& queue);
|
||||
void appendEventQueue(EventQueue& queue);
|
||||
|
||||
bool done() const { return _done; }
|
||||
float mx() const { return _mx; }
|
||||
float my() const { return _my; }
|
||||
unsigned int mbutton() const { return _mbutton; }
|
||||
|
||||
void setStartTick(osg::Timer_t tick) { _startTick = tick; }
|
||||
osg::Timer_t getStartTick() const { return _startTick; }
|
||||
|
||||
double getTime() const { return _timer.delta_s(_startTick,_timer.tick()); }
|
||||
double getTime() const { return _eventQueue->getTime(); }
|
||||
|
||||
Producer::KeyboardMouse* getKeyboardMouse() { return _keyboardMouse; }
|
||||
const Producer::KeyboardMouse* getKeyboardMouse() const { return _keyboardMouse; }
|
||||
|
||||
EventAdapter* createEventAdapter();
|
||||
osgGA::GUIEventAdapter* createEventAdapter();
|
||||
|
||||
void updateWindowSize();
|
||||
|
||||
protected:
|
||||
|
||||
@ -99,10 +90,7 @@ class OSGPRODUCER_EXPORT KeyboardMouseCallback : public Producer::KeyboardMouseC
|
||||
bool &_done;
|
||||
bool _escapeKeySetsDone;
|
||||
|
||||
osg::Timer_t _startTick;
|
||||
osg::Timer _timer;
|
||||
mutable OpenThreads::Mutex _eventQueueMutex;
|
||||
EventQueue _eventQueue;
|
||||
osg::ref_ptr<osgGA::EventQueue> _eventQueue;
|
||||
|
||||
};
|
||||
|
||||
|
@ -57,7 +57,7 @@ void AnimationPathManipulator::home(double currentTime)
|
||||
|
||||
void AnimationPathManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter&)
|
||||
{
|
||||
home(ea.time());
|
||||
home(ea.getTime());
|
||||
}
|
||||
|
||||
void AnimationPathManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& aa)
|
||||
@ -78,7 +78,7 @@ bool AnimationPathManipulator::handle(const osgGA::GUIEventAdapter& ea,osgGA::GU
|
||||
}
|
||||
else
|
||||
{
|
||||
handleFrame( ea.time() );
|
||||
handleFrame( ea.getTime() );
|
||||
}
|
||||
return false;
|
||||
case GUIEventAdapter::KEYDOWN:
|
||||
@ -96,12 +96,12 @@ bool AnimationPathManipulator::handle(const osgGA::GUIEventAdapter& ea,osgGA::GU
|
||||
if( _isPaused )
|
||||
{
|
||||
_isPaused = false;
|
||||
_timeOffset -= ea.time() - _pauseTime;
|
||||
_timeOffset -= ea.getTime() - _pauseTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isPaused = true;
|
||||
_pauseTime = ea.time();
|
||||
_pauseTime = ea.getTime();
|
||||
}
|
||||
us.requestRedraw();
|
||||
us.requestContinuousUpdate(false);
|
||||
|
@ -486,7 +486,7 @@ bool DriveManipulator::calcMovement()
|
||||
// return if less then two events have been added.
|
||||
if (_ga_t0.get()==NULL || _ga_t1.get()==NULL) return false;
|
||||
|
||||
double dt = _ga_t0->time()-_ga_t1->time();
|
||||
double dt = _ga_t0->getTime()-_ga_t1->getTime();
|
||||
|
||||
if (dt<0.0f)
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ bool FlightManipulator::calcMovement()
|
||||
if (_ga_t0.get()==NULL || _ga_t1.get()==NULL) return false;
|
||||
|
||||
|
||||
double dt = _ga_t0->time()-_ga_t1->time();
|
||||
double dt = _ga_t0->getTime()-_ga_t1->getTime();
|
||||
|
||||
if (dt<0.0f)
|
||||
{
|
||||
|
@ -9,6 +9,7 @@ CXXFILES = \
|
||||
EventVisitor.cpp\
|
||||
FlightManipulator.cpp\
|
||||
UFOManipulator.cpp\
|
||||
EventQueue.cpp\
|
||||
GUIEventAdapter.cpp\
|
||||
GUIEventHandler.cpp\
|
||||
GUIEventHandlerVisitor.cpp\
|
||||
|
@ -11,10 +11,53 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#include <osgGA/GUIEventHandler>
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
|
||||
using namespace osgGA;
|
||||
|
||||
GUIEventAdapter::GUIEventAdapter():
|
||||
_eventType(NONE),
|
||||
_time(0.0),
|
||||
_key(0),
|
||||
_button(0),
|
||||
_Xmin(0.0),
|
||||
_Xmax(1.0),
|
||||
_Ymin(0.0),
|
||||
_Ymax(1.0),
|
||||
_mx(0.5),
|
||||
_my(0.5),
|
||||
_buttonMask(0),
|
||||
_modKeyMask(0),
|
||||
_scrollingMotion(SCROLL_DOWN),
|
||||
_mouseYOrientation(Y_INCREASING_DOWNWARDS)
|
||||
{}
|
||||
|
||||
GUIEventAdapter::GUIEventAdapter(const GUIEventAdapter& rhs):
|
||||
Referenced(),
|
||||
_eventType(rhs._eventType),
|
||||
_time(rhs._time),
|
||||
_key(rhs._key),
|
||||
_button(rhs._button),
|
||||
_Xmin(rhs._Xmin),
|
||||
_Xmax(rhs._Xmax),
|
||||
_Ymin(rhs._Ymin),
|
||||
_Ymax(rhs._Ymax),
|
||||
_mx(rhs._mx),
|
||||
_my(rhs._my),
|
||||
_buttonMask(rhs._buttonMask),
|
||||
_modKeyMask(rhs._modKeyMask),
|
||||
_scrollingMotion(rhs._scrollingMotion),
|
||||
_mouseYOrientation(rhs._mouseYOrientation)
|
||||
{}
|
||||
|
||||
GUIEventAdapter::~GUIEventAdapter()
|
||||
{
|
||||
}
|
||||
|
||||
void GUIEventAdapter::setWindowSize(float Xmin, float Ymin, float Xmax, float Ymax)
|
||||
{
|
||||
_Xmin = Xmin;
|
||||
_Ymin = Ymin;
|
||||
_Xmax = Xmax;
|
||||
_Ymax = Ymax;
|
||||
}
|
||||
|
@ -20,15 +20,14 @@ using namespace osgGA;
|
||||
void GUIEventHandler::operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
|
||||
if (ev && ev->getActionAdapter() && !ev->getEventList().empty())
|
||||
if (ev && ev->getActionAdapter() && !ev->getEvents().empty())
|
||||
{
|
||||
for(osgGA::EventVisitor::EventList::iterator itr = ev->getEventList().begin();
|
||||
itr != ev->getEventList().end();
|
||||
for(osgGA::EventQueue::Events::iterator itr = ev->getEvents().begin();
|
||||
itr != ev->getEvents().end();
|
||||
++itr)
|
||||
{
|
||||
if (handle(*(*itr), *(ev->getActionAdapter()), node, nv))
|
||||
{
|
||||
ev->setEventHandled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -39,10 +38,10 @@ void GUIEventHandler::operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
void GUIEventHandler::event(osg::NodeVisitor* nv, osg::Drawable* drawable)
|
||||
{
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
|
||||
if (ev && ev->getActionAdapter() && !ev->getEventList().empty())
|
||||
if (ev && ev->getActionAdapter() && !ev->getEvents().empty())
|
||||
{
|
||||
for(osgGA::EventVisitor::EventList::iterator itr = ev->getEventList().begin();
|
||||
itr != ev->getEventList().end();
|
||||
for(osgGA::EventQueue::Events::iterator itr = ev->getEvents().begin();
|
||||
itr != ev->getEvents().end();
|
||||
++itr)
|
||||
{
|
||||
handle(*(*itr), *(ev->getActionAdapter()), drawable, nv);
|
||||
|
@ -288,7 +288,7 @@ bool NodeTrackerManipulator::isMouseMoving()
|
||||
float dx = _ga_t0->getXnormalized()-_ga_t1->getXnormalized();
|
||||
float dy = _ga_t0->getYnormalized()-_ga_t1->getYnormalized();
|
||||
float len = sqrtf(dx*dx+dy*dy);
|
||||
float dt = _ga_t0->time()-_ga_t1->time();
|
||||
float dt = _ga_t0->getTime()-_ga_t1->getTime();
|
||||
|
||||
return (len>dt*velocity);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ bool TerrainManipulator::isMouseMoving()
|
||||
float dx = _ga_t0->getXnormalized()-_ga_t1->getXnormalized();
|
||||
float dy = _ga_t0->getYnormalized()-_ga_t1->getYnormalized();
|
||||
float len = sqrtf(dx*dx+dy*dy);
|
||||
float dt = _ga_t0->time()-_ga_t1->time();
|
||||
float dt = _ga_t0->getTime()-_ga_t1->getTime();
|
||||
|
||||
return (len>dt*velocity);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ void TrackballManipulator::home(double /*currentTime*/)
|
||||
|
||||
void TrackballManipulator::home(const GUIEventAdapter& ea ,GUIActionAdapter& us)
|
||||
{
|
||||
home(ea.time());
|
||||
home(ea.getTime());
|
||||
us.requestRedraw();
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ bool TrackballManipulator::isMouseMoving()
|
||||
float dx = _ga_t0->getXnormalized()-_ga_t1->getXnormalized();
|
||||
float dy = _ga_t0->getYnormalized()-_ga_t1->getYnormalized();
|
||||
float len = sqrtf(dx*dx+dy*dy);
|
||||
float dt = _ga_t0->time()-_ga_t1->time();
|
||||
float dt = _ga_t0->getTime()-_ga_t1->getTime();
|
||||
|
||||
return (len>dt*velocity);
|
||||
}
|
||||
|
@ -161,14 +161,14 @@ void UFOManipulator::computeHomePosition()
|
||||
|
||||
void UFOManipulator::init(const GUIEventAdapter&, GUIActionAdapter&)
|
||||
{
|
||||
//home(ea.time());
|
||||
//home(ea.getTime());
|
||||
|
||||
_stop();
|
||||
}
|
||||
|
||||
void UFOManipulator::home(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&)
|
||||
{
|
||||
home(ea.time());
|
||||
home(ea.getTime());
|
||||
}
|
||||
|
||||
void UFOManipulator::home(double)
|
||||
@ -398,17 +398,17 @@ void UFOManipulator::_keyDown( const osgGA::GUIEventAdapter &ea, osgGA::GUIActio
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
home(ea.time());
|
||||
home(ea.getTime());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void UFOManipulator::_frame( const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter & )
|
||||
{
|
||||
double t1 = ea.time();
|
||||
double t1 = ea.getTime();
|
||||
if( _t0 == 0.0 )
|
||||
{
|
||||
_t0 = ea.time();
|
||||
_t0 = ea.getTime();
|
||||
_dt = 0.0;
|
||||
}
|
||||
else
|
||||
|
@ -1,229 +0,0 @@
|
||||
#include <osgProducer/EventAdapter>
|
||||
|
||||
using namespace osgProducer;
|
||||
|
||||
// default to no mouse buttons being pressed.
|
||||
unsigned int EventAdapter::_s_accumulatedButtonMask = 0;
|
||||
|
||||
int EventAdapter::_s_button = 0;
|
||||
int EventAdapter::_s_modKeyMask = 0;
|
||||
float EventAdapter::_s_Xmin = 0;
|
||||
float EventAdapter::_s_Xmax = 1280;
|
||||
float EventAdapter::_s_Ymin = 0;
|
||||
float EventAdapter::_s_Ymax = 1024;
|
||||
float EventAdapter::_s_mx = 0;
|
||||
float EventAdapter::_s_my = 0;
|
||||
|
||||
EventAdapter::EventAdapter():
|
||||
osgGA::GUIEventAdapter(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS)
|
||||
{
|
||||
_eventType = NONE; // adaptor does not encapsulate any events.
|
||||
_key = -1; // set to 'invalid' key value.
|
||||
_button = -1; // set to 'invalid' button value.
|
||||
_mx = -1; // set to 'invalid' position value.
|
||||
_my = -1; // set to 'invalid' position value.
|
||||
_buttonMask = 0; // default to no mouse buttons being pressed.
|
||||
_modKeyMask = 0; // default to no mouse buttons being pressed.
|
||||
_time = 0.0f; // default to no time has been set.
|
||||
|
||||
copyStaticVariables();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void EventAdapter::copyStaticVariables()
|
||||
{
|
||||
_buttonMask = _s_accumulatedButtonMask;
|
||||
_modKeyMask = _s_modKeyMask;
|
||||
_button = _s_button;
|
||||
_Xmin = _s_Xmin;
|
||||
_Xmax = _s_Xmax;
|
||||
_Ymin = _s_Ymin;
|
||||
_Ymax = _s_Ymax;
|
||||
_mx = _s_mx;
|
||||
_my = _s_my;
|
||||
}
|
||||
|
||||
|
||||
void EventAdapter::setWindowSize(float Xmin, float Ymin, float Xmax, float Ymax)
|
||||
{
|
||||
_s_Xmin = Xmin;
|
||||
_s_Xmax = Xmax;
|
||||
_s_Ymin = Ymin;
|
||||
_s_Ymax = Ymax;
|
||||
}
|
||||
|
||||
|
||||
void EventAdapter::setButtonMask(unsigned int buttonMask)
|
||||
{
|
||||
_s_accumulatedButtonMask = buttonMask;
|
||||
}
|
||||
|
||||
|
||||
void EventAdapter::adaptResize(double time, float Xmin, float Ymin, float Xmax, float Ymax)
|
||||
{
|
||||
setWindowSize(Xmin,Ymin,Xmax,Ymax);
|
||||
_eventType = RESIZE;
|
||||
_time = time;
|
||||
copyStaticVariables();
|
||||
}
|
||||
|
||||
void EventAdapter::adaptMouseScroll(double time, Producer::KeyboardMouseCallback::ScrollingMotion sm)
|
||||
{
|
||||
_time = time;
|
||||
|
||||
if (sm == Producer::KeyboardMouseCallback::ScrollUp)
|
||||
_eventType = SCROLLUP;
|
||||
else if (sm == Producer::KeyboardMouseCallback::ScrollDown)
|
||||
_eventType = SCROLLDOWN;
|
||||
else
|
||||
_eventType = NONE;
|
||||
|
||||
copyStaticVariables();
|
||||
}
|
||||
|
||||
void EventAdapter::adaptButtonPress(double time,float x, float y, unsigned int button)
|
||||
{
|
||||
_time = time;
|
||||
|
||||
_eventType = PUSH;
|
||||
_button = button-1;
|
||||
|
||||
switch(_button)
|
||||
{
|
||||
case(0):
|
||||
_s_accumulatedButtonMask = _s_accumulatedButtonMask | LEFT_MOUSE_BUTTON;
|
||||
_s_button = LEFT_MOUSE_BUTTON;
|
||||
break;
|
||||
case(1):
|
||||
_s_accumulatedButtonMask = _s_accumulatedButtonMask | MIDDLE_MOUSE_BUTTON;
|
||||
_s_button = MIDDLE_MOUSE_BUTTON;
|
||||
break;
|
||||
case(2):
|
||||
_s_accumulatedButtonMask = _s_accumulatedButtonMask | RIGHT_MOUSE_BUTTON;
|
||||
_s_button = RIGHT_MOUSE_BUTTON;
|
||||
break;
|
||||
}
|
||||
|
||||
_s_mx = x;
|
||||
_s_my = y;
|
||||
|
||||
copyStaticVariables();
|
||||
}
|
||||
|
||||
void EventAdapter::adaptButtonRelease(double time,float x, float y, unsigned int button)
|
||||
{
|
||||
_time = time;
|
||||
|
||||
_eventType = RELEASE;
|
||||
_button = button-1;
|
||||
|
||||
switch(_button)
|
||||
{
|
||||
case(0):
|
||||
_s_accumulatedButtonMask = _s_accumulatedButtonMask & ~LEFT_MOUSE_BUTTON;
|
||||
_s_button = LEFT_MOUSE_BUTTON;
|
||||
break;
|
||||
case(1):
|
||||
_s_accumulatedButtonMask = _s_accumulatedButtonMask & ~MIDDLE_MOUSE_BUTTON;
|
||||
_s_button = MIDDLE_MOUSE_BUTTON;
|
||||
break;
|
||||
case(2):
|
||||
_s_accumulatedButtonMask = _s_accumulatedButtonMask & ~RIGHT_MOUSE_BUTTON;
|
||||
_s_button = RIGHT_MOUSE_BUTTON;
|
||||
break;
|
||||
}
|
||||
|
||||
_s_mx = x;
|
||||
_s_my = y;
|
||||
|
||||
copyStaticVariables();
|
||||
}
|
||||
|
||||
/** method for adapting mouse motion events whilst mouse buttons are pressed.*/
|
||||
void EventAdapter::adaptMouseMotion(double time, float x, float y)
|
||||
{
|
||||
|
||||
_eventType = (_s_accumulatedButtonMask) ?
|
||||
DRAG :
|
||||
MOVE;
|
||||
|
||||
_time = time;
|
||||
_s_mx = x;
|
||||
_s_my = y;
|
||||
copyStaticVariables();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** method for adapting keyboard events.*/
|
||||
void EventAdapter::adaptKeyPress( double time, Producer::KeySymbol key)
|
||||
{
|
||||
_eventType = KEYDOWN;
|
||||
_time = time;
|
||||
_key = key;
|
||||
|
||||
switch(key)
|
||||
{
|
||||
case(KEY_Shift_L): _s_modKeyMask = MODKEY_LEFT_SHIFT | _s_modKeyMask; break;
|
||||
case(KEY_Shift_R): _s_modKeyMask = MODKEY_RIGHT_SHIFT | _s_modKeyMask; break;
|
||||
case(KEY_Control_L): _s_modKeyMask = MODKEY_LEFT_CTRL | _s_modKeyMask; break;
|
||||
case(KEY_Control_R): _s_modKeyMask = MODKEY_RIGHT_CTRL | _s_modKeyMask; break;
|
||||
case(KEY_Meta_L): _s_modKeyMask = MODKEY_LEFT_META | _s_modKeyMask; break;
|
||||
case(KEY_Meta_R): _s_modKeyMask = MODKEY_RIGHT_META | _s_modKeyMask; break;
|
||||
case(KEY_Alt_L): _s_modKeyMask = MODKEY_LEFT_ALT | _s_modKeyMask; break;
|
||||
case(KEY_Alt_R): _s_modKeyMask = MODKEY_LEFT_ALT | _s_modKeyMask; break;
|
||||
|
||||
case(KEY_Caps_Lock):
|
||||
{
|
||||
if ((_s_modKeyMask & MODKEY_CAPS_LOCK)!=0)
|
||||
_s_modKeyMask = ~MODKEY_CAPS_LOCK & _s_modKeyMask;
|
||||
else
|
||||
_s_modKeyMask = MODKEY_CAPS_LOCK | _s_modKeyMask;
|
||||
break;
|
||||
}
|
||||
case(KEY_Num_Lock):
|
||||
{
|
||||
if ((_s_modKeyMask & MODKEY_NUM_LOCK)!=0)
|
||||
_s_modKeyMask = ~MODKEY_NUM_LOCK & _s_modKeyMask;
|
||||
else
|
||||
_s_modKeyMask = MODKEY_NUM_LOCK | _s_modKeyMask;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
copyStaticVariables();
|
||||
}
|
||||
|
||||
void EventAdapter::adaptKeyRelease( double time, Producer::KeySymbol key)
|
||||
{
|
||||
// we won't handle this correctly right now.. GUIEventAdapter isn't up to it
|
||||
_eventType = KEYUP;
|
||||
_time = time;
|
||||
_key = key;
|
||||
|
||||
switch(key)
|
||||
{
|
||||
case(KEY_Shift_L): _s_modKeyMask = ~MODKEY_LEFT_SHIFT & _s_modKeyMask; break;
|
||||
case(KEY_Shift_R): _s_modKeyMask = ~MODKEY_RIGHT_SHIFT & _s_modKeyMask; break;
|
||||
case(KEY_Control_L): _s_modKeyMask = ~MODKEY_LEFT_CTRL & _s_modKeyMask; break;
|
||||
case(KEY_Control_R): _s_modKeyMask = ~MODKEY_RIGHT_CTRL & _s_modKeyMask; break;
|
||||
case(KEY_Meta_L): _s_modKeyMask = ~MODKEY_LEFT_META & _s_modKeyMask; break;
|
||||
case(KEY_Meta_R): _s_modKeyMask = ~MODKEY_RIGHT_META & _s_modKeyMask; break;
|
||||
case(KEY_Alt_L): _s_modKeyMask = ~MODKEY_LEFT_ALT & _s_modKeyMask; break;
|
||||
case(KEY_Alt_R): _s_modKeyMask = ~MODKEY_LEFT_ALT & _s_modKeyMask; break;
|
||||
}
|
||||
|
||||
copyStaticVariables();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** method for adapting frame events, i.e. iddle/display callback.*/
|
||||
void EventAdapter::adaptFrame(double time)
|
||||
{
|
||||
_eventType = FRAME;
|
||||
_time = time;
|
||||
|
||||
copyStaticVariables();
|
||||
}
|
@ -2,7 +2,6 @@ TOPDIR = ../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
EventAdapter.cpp\
|
||||
KeyboardMouseCallback.cpp\
|
||||
GraphicsContextImplementation.cpp\
|
||||
OsgCameraGroup.cpp\
|
||||
|
@ -7,212 +7,98 @@
|
||||
|
||||
using namespace osgProducer;
|
||||
|
||||
KeyboardMouseCallback::KeyboardMouseCallback(Producer::KeyboardMouse* keyboardMouse, bool &done, bool escapeKeySetsDone):
|
||||
Producer::KeyboardMouseCallback(),
|
||||
_keyboardMouse(keyboardMouse),
|
||||
_mx(0.0f),_my(0.0f),_mbutton(0),
|
||||
_done(done),
|
||||
_escapeKeySetsDone(escapeKeySetsDone)
|
||||
{
|
||||
_eventQueue = new osgGA::EventQueue;
|
||||
_eventQueue->getCurrentEventState()->setMouseYOrientation(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS);
|
||||
updateWindowSize();
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::mouseScroll( Producer::KeyboardMouseCallback::ScrollingMotion sm )
|
||||
{
|
||||
osg::ref_ptr<EventAdapter> event = createEventAdapter();
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
event->adaptMouseScroll(getTime(), sm);
|
||||
_eventQueue.push_back(event);
|
||||
_eventQueueMutex.unlock();
|
||||
updateWindowSize();
|
||||
_eventQueue->mouseScroll((osgGA::GUIEventAdapter::ScrollingMotion)sm);
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::buttonPress( float mx, float my, unsigned int mbutton )
|
||||
{
|
||||
_mx = mx;
|
||||
_my = my;
|
||||
_mbutton |= (1<<(mbutton-1));
|
||||
|
||||
osg::ref_ptr<EventAdapter> event = createEventAdapter();
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
event->adaptButtonPress(getTime(),mx,my,mbutton);
|
||||
_eventQueue.push_back(event);
|
||||
_eventQueueMutex.unlock();
|
||||
updateWindowSize();
|
||||
_eventQueue->mouseButtonPress(mx,my,mbutton);
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::buttonRelease( float mx, float my, unsigned int mbutton )
|
||||
{
|
||||
_mx = mx;
|
||||
_my = my;
|
||||
_mbutton &= ~(1<<(mbutton-1));
|
||||
|
||||
osg::ref_ptr<EventAdapter> event = createEventAdapter();
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
event->adaptButtonRelease(getTime(),mx,my,mbutton);
|
||||
_eventQueue.push_back(event);
|
||||
_eventQueueMutex.unlock();
|
||||
updateWindowSize();
|
||||
_eventQueue->mouseButtonRelease(mx,my,mbutton);
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::doubleButtonPress( float mx, float my, unsigned int mbutton )
|
||||
{
|
||||
_mx = mx;
|
||||
_my = my;
|
||||
_mbutton |= (1<<(mbutton-1));
|
||||
|
||||
osg::ref_ptr<EventAdapter> event = createEventAdapter();
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
event->adaptButtonPress(getTime(),mx,my,mbutton);
|
||||
_eventQueue.push_back(event);
|
||||
_eventQueueMutex.unlock();
|
||||
updateWindowSize();
|
||||
_eventQueue->mouseButtonPress(mx,my,mbutton);
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::keyPress( Producer::KeyCharacter key )
|
||||
{
|
||||
osg::ref_ptr<EventAdapter> event = createEventAdapter();
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
event->adaptKeyPress(getTime(),key);
|
||||
_eventQueue.push_back(event);
|
||||
_eventQueueMutex.unlock();
|
||||
updateWindowSize();
|
||||
_eventQueue->keyPress((osgGA::GUIEventAdapter::KeySymbol)key);
|
||||
|
||||
// check against adapted key symbol.
|
||||
if (_escapeKeySetsDone &&
|
||||
event->getKey()==osgGA::GUIEventAdapter::KEY_Escape) _done = true;
|
||||
(osgGA::GUIEventAdapter::KeySymbol)key==osgGA::GUIEventAdapter::KEY_Escape) _done = true;
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::keyRelease( Producer::KeyCharacter key )
|
||||
{
|
||||
osg::ref_ptr<EventAdapter> event = createEventAdapter();
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
event->adaptKeyRelease(getTime(),key);
|
||||
_eventQueue.push_back(event);
|
||||
_eventQueueMutex.unlock();
|
||||
updateWindowSize();
|
||||
_eventQueue->keyRelease((osgGA::GUIEventAdapter::KeySymbol)key);
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::specialKeyPress( Producer::KeyCharacter key )
|
||||
{
|
||||
osg::ref_ptr<EventAdapter> event = createEventAdapter();
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
event->adaptKeyPress(getTime(),key);
|
||||
_eventQueue.push_back(event);
|
||||
_eventQueueMutex.unlock();
|
||||
|
||||
// check against adapted key symbol.
|
||||
if (_escapeKeySetsDone &&
|
||||
event->getKey()==osgGA::GUIEventAdapter::KEY_Escape) _done = true;
|
||||
updateWindowSize();
|
||||
keyPress(key);
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::specialKeyRelease( Producer::KeyCharacter key )
|
||||
{
|
||||
osg::ref_ptr<EventAdapter> event = createEventAdapter();
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
event->adaptKeyRelease(getTime(),key);
|
||||
_eventQueue.push_back(event);
|
||||
_eventQueueMutex.unlock();
|
||||
updateWindowSize();
|
||||
keyRelease(key);
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::windowConfig( int x, int y, unsigned int width, unsigned int height )
|
||||
{
|
||||
osg::ref_ptr<EventAdapter> event = createEventAdapter();
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
event->adaptResize(getTime(), x, y, x+width, y+height );
|
||||
_eventQueue.push_back(event);
|
||||
_eventQueueMutex.unlock();
|
||||
updateWindowSize();
|
||||
_eventQueue->windowResize(x,y,x+width,y+height);
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::mouseMotion( float mx, float my)
|
||||
{
|
||||
_mx = mx;
|
||||
_my = my;
|
||||
|
||||
osg::ref_ptr<EventAdapter> event = createEventAdapter();
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
event->adaptMouseMotion(getTime(),mx,my);
|
||||
_eventQueue.push_back(event);
|
||||
_eventQueueMutex.unlock();
|
||||
|
||||
updateWindowSize();
|
||||
_eventQueue->mouseMotion(mx,my);
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::passiveMouseMotion( float mx, float my)
|
||||
{
|
||||
_mx = mx;
|
||||
_my = my;
|
||||
|
||||
//std::cout << "mx="<<mx<<" my="<<my<<std::endl;
|
||||
|
||||
osg::ref_ptr<EventAdapter> event = createEventAdapter();
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
event->adaptMouseMotion(getTime(),mx,my);
|
||||
_eventQueue.push_back(event);
|
||||
_eventQueueMutex.unlock();
|
||||
|
||||
updateWindowSize();
|
||||
_eventQueue->mouseMotion(mx,my);
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::mouseWarp( float mx, float my)
|
||||
{
|
||||
_mx = mx;
|
||||
_my = my;
|
||||
|
||||
osg::ref_ptr<EventAdapter> event = createEventAdapter();
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
_eventQueue.push_back(event);
|
||||
_eventQueueMutex.unlock();
|
||||
|
||||
updateWindowSize();
|
||||
_eventQueue->mouseMotion(mx,my); // need mouse warp??
|
||||
}
|
||||
|
||||
double KeyboardMouseCallback::getEventQueue(EventQueue& queue)
|
||||
|
||||
void KeyboardMouseCallback::updateWindowSize()
|
||||
{
|
||||
double swapTime;
|
||||
|
||||
queue.clear();
|
||||
_eventQueueMutex.lock();
|
||||
_eventQueue.swap(queue);
|
||||
swapTime = getTime();
|
||||
_eventQueueMutex.unlock();
|
||||
|
||||
return swapTime;
|
||||
}
|
||||
|
||||
double KeyboardMouseCallback::copyEventQueue(EventQueue& queue) const
|
||||
{
|
||||
double swapTime;
|
||||
|
||||
queue.clear();
|
||||
_eventQueueMutex.lock();
|
||||
queue = _eventQueue;
|
||||
swapTime = getTime();
|
||||
_eventQueueMutex.unlock();
|
||||
|
||||
return swapTime;
|
||||
}
|
||||
|
||||
double KeyboardMouseCallback::setEventQueue(EventQueue& queue)
|
||||
{
|
||||
double swapTime;
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
_eventQueue = queue;
|
||||
swapTime = getTime();
|
||||
_eventQueueMutex.unlock();
|
||||
|
||||
return swapTime;
|
||||
}
|
||||
|
||||
double KeyboardMouseCallback::appendEventQueue(EventQueue& queue)
|
||||
{
|
||||
double swapTime;
|
||||
|
||||
_eventQueueMutex.lock();
|
||||
_eventQueue.insert(_eventQueue.end(),queue.begin(),queue.end());
|
||||
swapTime = getTime();
|
||||
_eventQueueMutex.unlock();
|
||||
|
||||
return swapTime;
|
||||
}
|
||||
|
||||
EventAdapter* KeyboardMouseCallback::createEventAdapter()
|
||||
{
|
||||
EventAdapter* ea = new EventAdapter;
|
||||
osgGA::GUIEventAdapter* ea = _eventQueue->getCurrentEventState();
|
||||
|
||||
Producer::InputArea* ia = _keyboardMouse->getInputArea();
|
||||
Producer::RenderSurface* rs = _keyboardMouse->getRenderSurface();
|
||||
@ -257,8 +143,27 @@ EventAdapter* KeyboardMouseCallback::createEventAdapter()
|
||||
|
||||
ea->setWindowSize(minX,minY,maxX,maxY);
|
||||
}
|
||||
}
|
||||
|
||||
return ea;
|
||||
bool KeyboardMouseCallback::takeEventQueue(EventQueue& queue)
|
||||
{
|
||||
updateWindowSize();
|
||||
return _eventQueue->takeEvents(queue);
|
||||
}
|
||||
|
||||
bool KeyboardMouseCallback::copyEventQueue(EventQueue& queue) const
|
||||
{
|
||||
return _eventQueue->copyEvents(queue);
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::setEventQueue(EventQueue& queue)
|
||||
{
|
||||
_eventQueue->setEvents(queue);
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::appendEventQueue(EventQueue& queue)
|
||||
{
|
||||
_eventQueue->appendEvents(queue);
|
||||
}
|
||||
|
||||
void KeyboardMouseCallback::shutdown()
|
||||
@ -266,3 +171,8 @@ void KeyboardMouseCallback::shutdown()
|
||||
_done = true;
|
||||
_keyboardMouse->cancel();
|
||||
}
|
||||
|
||||
osgGA::GUIEventAdapter* KeyboardMouseCallback::createEventAdapter()
|
||||
{
|
||||
return new osgGA::GUIEventAdapter(*(_eventQueue->getCurrentEventState()));
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ void Viewer::setUpViewer(unsigned int options)
|
||||
if (!_kbmcb)
|
||||
_kbmcb = new osgProducer::KeyboardMouseCallback( _kbm.get(), _done, (options & ESCAPE_SETS_DONE)!=0 );
|
||||
|
||||
_kbmcb->setStartTick(_start_tick);
|
||||
_kbmcb->getEventQueue()->setStartTick(_start_tick);
|
||||
|
||||
// register the callback with the keyboard mouse manger.
|
||||
_kbm->setCallback( _kbmcb.get() );
|
||||
@ -541,8 +541,9 @@ bool Viewer::realize()
|
||||
{
|
||||
_keyswitchManipulator->setCoordinateFrameCallback(new ViewerCoordinateFrameCallback(this));
|
||||
|
||||
osg::ref_ptr<osgProducer::EventAdapter> init_event = _kbmcb->createEventAdapter();
|
||||
init_event->adaptFrame(0.0);
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> init_event = new osgGA::GUIEventAdapter;
|
||||
init_event->setEventType(osgGA::GUIEventAdapter::FRAME);
|
||||
init_event->setTime(0.0);
|
||||
|
||||
_keyswitchManipulator->setNode(getTopMostSceneData());
|
||||
_keyswitchManipulator->home(*init_event,*this);
|
||||
@ -565,14 +566,12 @@ void Viewer::update()
|
||||
if (_kbm.valid() && !_kbm->isRunning()) _kbm->update(*(_kbm->getCallback()));
|
||||
#endif
|
||||
|
||||
// create an event to signal the new frame.
|
||||
_kbmcb->getEventQueue()->frame(_frameStamp->getReferenceTime());
|
||||
|
||||
// get the event since the last frame.
|
||||
osgProducer::KeyboardMouseCallback::EventQueue queue;
|
||||
if (_kbmcb.valid()) _kbmcb->getEventQueue(queue);
|
||||
|
||||
// create an event to signal the new frame.
|
||||
osg::ref_ptr<osgProducer::EventAdapter> frame_event = new osgProducer::EventAdapter;
|
||||
frame_event->adaptFrame(_frameStamp->getReferenceTime());
|
||||
queue.push_back(frame_event);
|
||||
if (_kbmcb.valid()) _kbmcb->takeEventQueue(queue);
|
||||
|
||||
if (_eventVisitor.valid())
|
||||
{
|
||||
@ -842,9 +841,11 @@ void Viewer::selectCameraManipulator(unsigned int no)
|
||||
// keyswitch manipulator doesn't yet force manipulators to init themselves
|
||||
// so we'll do this mannually. Note pretty, and needs replacing by a refactor
|
||||
// of MatrixMinpulators in the longer term.
|
||||
osg::ref_ptr<EventAdapter> ea = new EventAdapter;
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> ea = new osgGA::GUIEventAdapter;
|
||||
double time = _kbmcb.valid() ? _kbmcb->getTime() : 0.0;
|
||||
ea->adaptKeyPress(time, osgGA::GUIEventAdapter::KEY_KP_1+no);
|
||||
ea->setTime(time);
|
||||
ea->setEventType(osgGA::GUIEventAdapter::KEYDOWN);
|
||||
ea->setKey(osgGA::GUIEventAdapter::KEY_KP_1+no);
|
||||
_keyswitchManipulator->init(*ea, *this);
|
||||
}
|
||||
}
|
||||
@ -914,8 +915,8 @@ void Viewer::requestWarpPointer(float x,float y)
|
||||
{
|
||||
osg::notify(osg::INFO) << "requestWarpPointer x= "<<x<<" y="<<y<<std::endl;
|
||||
|
||||
EventAdapter::_s_mx = x;
|
||||
EventAdapter::_s_my = y;
|
||||
_kbmcb->getEventQueue()->getCurrentEventState()->setX(x);
|
||||
_kbmcb->getEventQueue()->getCurrentEventState()->setY(y);
|
||||
_kbmcb->getKeyboardMouse()->positionPointer(x,y);
|
||||
return;
|
||||
}
|
||||
|
66
src/osgWrappers/osgGA/EventQueue.cpp
Normal file
66
src/osgWrappers/osgGA/EventQueue.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
// ***************************************************************************
|
||||
//
|
||||
// Generated automatically by genwrapper.
|
||||
// Please DO NOT EDIT this file!
|
||||
//
|
||||
// ***************************************************************************
|
||||
|
||||
#include <osgIntrospection/ReflectionMacros>
|
||||
#include <osgIntrospection/TypedMethodInfo>
|
||||
#include <osgIntrospection/Attributes>
|
||||
|
||||
#include <osg/Timer>
|
||||
#include <osgGA/EventQueue>
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
|
||||
// Must undefine IN and OUT macros defined in Windows headers
|
||||
#ifdef IN
|
||||
#undef IN
|
||||
#endif
|
||||
#ifdef OUT
|
||||
#undef OUT
|
||||
#endif
|
||||
|
||||
TYPE_NAME_ALIAS(std::list< osg::ref_ptr< osgGA::GUIEventAdapter > >, osgGA::EventQueue::Events);
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osgGA::EventQueue)
|
||||
I_BaseType(osg::Referenced);
|
||||
I_Constructor0();
|
||||
I_Method1(void, setEvents, IN, osgGA::EventQueue::Events &, events);
|
||||
I_Method1(bool, takeEvents, IN, osgGA::EventQueue::Events &, events);
|
||||
I_Method1(bool, copyEvents, IN, osgGA::EventQueue::Events &, events);
|
||||
I_Method1(void, appendEvents, IN, osgGA::EventQueue::Events &, events);
|
||||
I_Method1(void, addEvent, IN, osgGA::GUIEventAdapter *, event);
|
||||
I_Method4(void, windowResize, IN, float, Xmin, IN, float, Ymin, IN, float, Xmax, IN, float, Ymax);
|
||||
I_Method1(void, mouseScroll, IN, osgGA::GUIEventAdapter::ScrollingMotion, sm);
|
||||
I_Method2(void, mouseMotion, IN, float, x, IN, float, y);
|
||||
I_Method3(void, mouseButtonPress, IN, float, x, IN, float, y, IN, unsigned int, button);
|
||||
I_Method3(void, mouseButtonRelease, IN, float, x, IN, float, y, IN, unsigned int, button);
|
||||
I_Method1(void, keyPress, IN, osgGA::GUIEventAdapter::KeySymbol, key);
|
||||
I_Method1(void, keyRelease, IN, osgGA::GUIEventAdapter::KeySymbol, key);
|
||||
I_Method1(void, frame, IN, double, t);
|
||||
I_Method1(void, setStartTick, IN, osg::Timer_t, tick);
|
||||
I_Method0(osg::Timer_t, getStartTick);
|
||||
I_Method0(double, getTime);
|
||||
I_Method0(osgGA::GUIEventAdapter *, getCurrentEventState);
|
||||
I_Method0(const osgGA::GUIEventAdapter *, getCurrentEventState);
|
||||
I_ReadOnlyProperty(osgGA::GUIEventAdapter *, CurrentEventState);
|
||||
I_WriteOnlyProperty(osgGA::EventQueue::Events &, Events);
|
||||
I_Property(osg::Timer_t, StartTick);
|
||||
I_ReadOnlyProperty(double, Time);
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osgGA::GUIEventAdapter >)
|
||||
I_Constructor0();
|
||||
I_Constructor1(IN, osgGA::GUIEventAdapter *, t);
|
||||
I_Constructor1(IN, const osg::ref_ptr< osgGA::GUIEventAdapter > &, rp);
|
||||
I_Method0(bool, valid);
|
||||
I_Method0(osgGA::GUIEventAdapter *, get);
|
||||
I_Method0(const osgGA::GUIEventAdapter *, get);
|
||||
I_Method0(osgGA::GUIEventAdapter *, take);
|
||||
I_Method0(osgGA::GUIEventAdapter *, release);
|
||||
I_ReadOnlyProperty(osgGA::GUIEventAdapter *, );
|
||||
END_REFLECTOR
|
||||
|
||||
STD_LIST_REFLECTOR(std::list< osg::ref_ptr< osgGA::GUIEventAdapter > >);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <osg/Projection>
|
||||
#include <osg/Switch>
|
||||
#include <osg/Transform>
|
||||
#include <osgGA/EventQueue>
|
||||
#include <osgGA/EventVisitor>
|
||||
#include <osgGA/GUIActionAdapter>
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
@ -39,13 +40,13 @@ BEGIN_OBJECT_REFLECTOR(osgGA::EventVisitor)
|
||||
I_Method1(void, setActionAdapter, IN, osgGA::GUIActionAdapter *, actionAdapter);
|
||||
I_Method0(osgGA::GUIActionAdapter *, getActionAdapter);
|
||||
I_Method0(const osgGA::GUIActionAdapter *, getActionAdapter);
|
||||
I_Method1(void, setEventList, IN, const osgGA::EventVisitor::EventList &, events);
|
||||
I_Method0(osgGA::EventVisitor::EventList &, getEventList);
|
||||
I_Method0(const osgGA::EventVisitor::EventList &, getEventList);
|
||||
I_Method1(void, addEvent, IN, osgGA::GUIEventAdapter *, event);
|
||||
I_Method1(void, removeEvent, IN, osgGA::GUIEventAdapter *, event);
|
||||
I_Method0(bool, getEventHandled);
|
||||
I_Method1(void, setEventHandled, IN, bool, handled);
|
||||
I_Method0(bool, getEventHandled);
|
||||
I_Method1(void, setEvents, IN, const osgGA::EventQueue::Events &, events);
|
||||
I_Method0(osgGA::EventQueue::Events &, getEvents);
|
||||
I_Method0(const osgGA::EventQueue::Events &, getEvents);
|
||||
I_Method0(void, reset);
|
||||
I_Method1(void, apply, IN, osg::Node &, node);
|
||||
I_Method1(void, apply, IN, osg::Geode &, node);
|
||||
@ -59,20 +60,6 @@ BEGIN_OBJECT_REFLECTOR(osgGA::EventVisitor)
|
||||
I_Method1(void, apply, IN, osg::OccluderNode &, node);
|
||||
I_Property(osgGA::GUIActionAdapter *, ActionAdapter);
|
||||
I_Property(bool, EventHandled);
|
||||
I_Property(const osgGA::EventVisitor::EventList &, EventList);
|
||||
I_Property(const osgGA::EventQueue::Events &, Events);
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osgGA::GUIEventAdapter >)
|
||||
I_Constructor0();
|
||||
I_Constructor1(IN, osgGA::GUIEventAdapter *, t);
|
||||
I_Constructor1(IN, const osg::ref_ptr< osgGA::GUIEventAdapter > &, rp);
|
||||
I_Method0(bool, valid);
|
||||
I_Method0(osgGA::GUIEventAdapter *, get);
|
||||
I_Method0(const osgGA::GUIEventAdapter *, get);
|
||||
I_Method0(osgGA::GUIEventAdapter *, take);
|
||||
I_Method0(osgGA::GUIEventAdapter *, release);
|
||||
I_ReadOnlyProperty(osgGA::GUIEventAdapter *, );
|
||||
END_REFLECTOR
|
||||
|
||||
STD_LIST_REFLECTOR(std::list< osg::ref_ptr< osgGA::GUIEventAdapter > >);
|
||||
|
||||
|
@ -4,6 +4,8 @@ include $(TOPDIR)/Make/makedefs
|
||||
CXXFILES =\
|
||||
AnimationPathManipulator.cpp\
|
||||
DriveManipulator.cpp\
|
||||
Event.cpp\
|
||||
EventQueue.cpp\
|
||||
EventVisitor.cpp\
|
||||
FlightManipulator.cpp\
|
||||
GUIActionAdapter.cpp\
|
||||
|
@ -36,10 +36,7 @@ BEGIN_ENUM_REFLECTOR(osgGA::GUIEventAdapter::EventType)
|
||||
I_EnumLabel(osgGA::GUIEventAdapter::KEYUP);
|
||||
I_EnumLabel(osgGA::GUIEventAdapter::FRAME);
|
||||
I_EnumLabel(osgGA::GUIEventAdapter::RESIZE);
|
||||
I_EnumLabel(osgGA::GUIEventAdapter::SCROLLUP);
|
||||
I_EnumLabel(osgGA::GUIEventAdapter::SCROLLDOWN);
|
||||
I_EnumLabel(osgGA::GUIEventAdapter::SCROLLLEFT);
|
||||
I_EnumLabel(osgGA::GUIEventAdapter::SCROLLRIGHT);
|
||||
I_EnumLabel(osgGA::GUIEventAdapter::SCROLL);
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_ENUM_REFLECTOR(osgGA::GUIEventAdapter::KeySymbol)
|
||||
@ -189,37 +186,64 @@ BEGIN_ENUM_REFLECTOR(osgGA::GUIEventAdapter::MouseYOrientation)
|
||||
I_EnumLabel(osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS);
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_ABSTRACT_OBJECT_REFLECTOR(osgGA::GUIEventAdapter)
|
||||
BEGIN_ENUM_REFLECTOR(osgGA::GUIEventAdapter::ScrollingMotion)
|
||||
I_EnumLabel(osgGA::GUIEventAdapter::SCROLL_LEFT);
|
||||
I_EnumLabel(osgGA::GUIEventAdapter::SCROLL_RIGHT);
|
||||
I_EnumLabel(osgGA::GUIEventAdapter::SCROLL_UP);
|
||||
I_EnumLabel(osgGA::GUIEventAdapter::SCROLL_DOWN);
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osgGA::GUIEventAdapter)
|
||||
I_BaseType(osg::Referenced);
|
||||
I_Constructor0();
|
||||
I_Constructor1(IN, const osgGA::GUIEventAdapter &, rhs);
|
||||
I_Method1(void, setEventType, IN, osgGA::GUIEventAdapter::EventType, Type);
|
||||
I_Method0(osgGA::GUIEventAdapter::EventType, getEventType);
|
||||
I_Method0(int, getKey);
|
||||
I_Method0(int, getButton);
|
||||
I_Method1(void, setMouseYOrientation, IN, osgGA::GUIEventAdapter::MouseYOrientation, myo);
|
||||
I_Method0(osgGA::GUIEventAdapter::MouseYOrientation, getMouseYOrientation);
|
||||
I_Method0(float, getXmin);
|
||||
I_Method0(float, getXmax);
|
||||
I_Method0(float, getYmin);
|
||||
I_Method0(float, getYmax);
|
||||
I_Method0(float, getX);
|
||||
I_Method0(float, getY);
|
||||
I_Method0(unsigned int, getButtonMask);
|
||||
I_Method0(unsigned int, getModKeyMask);
|
||||
I_Method1(void, setTime, IN, double, time);
|
||||
I_Method0(double, getTime);
|
||||
I_Method0(double, time);
|
||||
I_Method1(void, setKey, IN, int, key);
|
||||
I_Method0(int, getKey);
|
||||
I_Method1(void, setButton, IN, int, button);
|
||||
I_Method0(int, getButton);
|
||||
I_Method4(void, setWindowSize, IN, float, Xmin, IN, float, Ymin, IN, float, Xmax, IN, float, Ymax);
|
||||
I_Method1(void, setXmin, IN, float, x);
|
||||
I_Method0(float, getXmin);
|
||||
I_Method1(void, setXmax, IN, float, x);
|
||||
I_Method0(float, getXmax);
|
||||
I_Method1(void, setYmin, IN, float, y);
|
||||
I_Method0(float, getYmin);
|
||||
I_Method1(void, setYmax, IN, float, y);
|
||||
I_Method0(float, getYmax);
|
||||
I_Method1(void, setX, IN, float, x);
|
||||
I_Method0(float, getX);
|
||||
I_Method1(void, setY, IN, float, y);
|
||||
I_Method0(float, getY);
|
||||
I_Method1(void, setButtonMask, IN, unsigned int, mask);
|
||||
I_Method0(unsigned int, getButtonMask);
|
||||
I_Method1(void, setModKeyMask, IN, unsigned int, mask);
|
||||
I_Method0(unsigned int, getModKeyMask);
|
||||
I_Method1(void, setScrollingMotion, IN, osgGA::GUIEventAdapter::ScrollingMotion, motion);
|
||||
I_Method0(osgGA::GUIEventAdapter::ScrollingMotion, getScrollingMotion);
|
||||
I_Method0(float, getXnormalized);
|
||||
I_Method0(float, getYnormalized);
|
||||
I_ReadOnlyProperty(int, Button);
|
||||
I_ReadOnlyProperty(unsigned int, ButtonMask);
|
||||
I_ReadOnlyProperty(osgGA::GUIEventAdapter::EventType, EventType);
|
||||
I_ReadOnlyProperty(int, Key);
|
||||
I_ReadOnlyProperty(unsigned int, ModKeyMask);
|
||||
I_Method1(void, setMouseYOrientation, IN, osgGA::GUIEventAdapter::MouseYOrientation, myo);
|
||||
I_Method0(osgGA::GUIEventAdapter::MouseYOrientation, getMouseYOrientation);
|
||||
I_Property(int, Button);
|
||||
I_Property(unsigned int, ButtonMask);
|
||||
I_Property(osgGA::GUIEventAdapter::EventType, EventType);
|
||||
I_Property(int, Key);
|
||||
I_Property(unsigned int, ModKeyMask);
|
||||
I_Property(osgGA::GUIEventAdapter::MouseYOrientation, MouseYOrientation);
|
||||
I_ReadOnlyProperty(float, X);
|
||||
I_ReadOnlyProperty(float, Xmax);
|
||||
I_ReadOnlyProperty(float, Xmin);
|
||||
I_Property(osgGA::GUIEventAdapter::ScrollingMotion, ScrollingMotion);
|
||||
I_Property(double, Time);
|
||||
I_Property(float, X);
|
||||
I_Property(float, Xmax);
|
||||
I_Property(float, Xmin);
|
||||
I_ReadOnlyProperty(float, Xnormalized);
|
||||
I_ReadOnlyProperty(float, Y);
|
||||
I_ReadOnlyProperty(float, Ymax);
|
||||
I_ReadOnlyProperty(float, Ymin);
|
||||
I_Property(float, Y);
|
||||
I_Property(float, Ymax);
|
||||
I_Property(float, Ymin);
|
||||
I_ReadOnlyProperty(float, Ynormalized);
|
||||
END_REFLECTOR
|
||||
|
||||
|
@ -1,64 +0,0 @@
|
||||
// ***************************************************************************
|
||||
//
|
||||
// Generated automatically by genwrapper.
|
||||
// Please DO NOT EDIT this file!
|
||||
//
|
||||
// ***************************************************************************
|
||||
|
||||
#include <osgIntrospection/ReflectionMacros>
|
||||
#include <osgIntrospection/TypedMethodInfo>
|
||||
#include <osgIntrospection/Attributes>
|
||||
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
#include <osgProducer/EventAdapter>
|
||||
|
||||
// Must undefine IN and OUT macros defined in Windows headers
|
||||
#ifdef IN
|
||||
#undef IN
|
||||
#endif
|
||||
#ifdef OUT
|
||||
#undef OUT
|
||||
#endif
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osgProducer::EventAdapter)
|
||||
I_BaseType(osgGA::GUIEventAdapter);
|
||||
I_Constructor0();
|
||||
I_Method0(osgGA::GUIEventAdapter::EventType, getEventType);
|
||||
I_Method1(void, setKey, IN, int, key);
|
||||
I_Method0(int, getKey);
|
||||
I_Method0(int, getButton);
|
||||
I_Method0(float, getXmin);
|
||||
I_Method0(float, getXmax);
|
||||
I_Method0(float, getYmin);
|
||||
I_Method0(float, getYmax);
|
||||
I_Method1(void, setX, IN, float, x);
|
||||
I_Method0(float, getX);
|
||||
I_Method1(void, setY, IN, float, y);
|
||||
I_Method0(float, getY);
|
||||
I_Method1(void, setButtonMak, IN, unsigned int, mask);
|
||||
I_Method0(unsigned int, getButtonMask);
|
||||
I_Method0(double, time);
|
||||
I_Method0(unsigned int, getModKeyMask);
|
||||
I_Method5(void, adaptResize, IN, double, t, IN, float, Xmin, IN, float, Ymin, IN, float, Xmax, IN, float, Ymax);
|
||||
I_Method2(void, adaptMouseScroll, IN, double, t, IN, Producer::KeyboardMouseCallback::ScrollingMotion, sm);
|
||||
I_Method3(void, adaptMouseMotion, IN, double, t, IN, float, x, IN, float, y);
|
||||
I_Method4(void, adaptButtonPress, IN, double, t, IN, float, x, IN, float, y, IN, unsigned int, button);
|
||||
I_Method4(void, adaptButtonRelease, IN, double, t, IN, float, x, IN, float, y, IN, unsigned int, button);
|
||||
I_Method2(void, adaptKeyPress, IN, double, t, IN, Producer::KeySymbol, key);
|
||||
I_Method2(void, adaptKeyRelease, IN, double, t, IN, Producer::KeySymbol, key);
|
||||
I_Method1(void, adaptFrame, IN, double, t);
|
||||
I_Method0(void, copyStaticVariables);
|
||||
I_ReadOnlyProperty(int, Button);
|
||||
I_WriteOnlyProperty(unsigned int, ButtonMak);
|
||||
I_ReadOnlyProperty(unsigned int, ButtonMask);
|
||||
I_ReadOnlyProperty(osgGA::GUIEventAdapter::EventType, EventType);
|
||||
I_Property(int, Key);
|
||||
I_ReadOnlyProperty(unsigned int, ModKeyMask);
|
||||
I_Property(float, X);
|
||||
I_ReadOnlyProperty(float, Xmax);
|
||||
I_ReadOnlyProperty(float, Xmin);
|
||||
I_Property(float, Y);
|
||||
I_ReadOnlyProperty(float, Ymax);
|
||||
I_ReadOnlyProperty(float, Ymin);
|
||||
END_REFLECTOR
|
||||
|
@ -2,7 +2,7 @@ TOPDIR = ../../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
EventAdapter.cpp\
|
||||
Export.cpp\
|
||||
GraphicsContextImplementation.cpp\
|
||||
KeyboardMouseCallback.cpp\
|
||||
OsgCameraGroup.cpp\
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include <osgIntrospection/TypedMethodInfo>
|
||||
#include <osgIntrospection/Attributes>
|
||||
|
||||
#include <osg/Timer>
|
||||
#include <osgProducer/EventAdapter>
|
||||
#include <osgGA/EventQueue>
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
#include <osgProducer/KeyboardMouseCallback>
|
||||
|
||||
// Must undefine IN and OUT macros defined in Windows headers
|
||||
@ -21,7 +21,7 @@
|
||||
#undef OUT
|
||||
#endif
|
||||
|
||||
TYPE_NAME_ALIAS(std::vector< osg::ref_ptr< osgProducer::EventAdapter > >, osgProducer::KeyboardMouseCallback::EventQueue);
|
||||
TYPE_NAME_ALIAS(osgGA::EventQueue::Events, osgProducer::KeyboardMouseCallback::EventQueue);
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osgProducer::KeyboardMouseCallback)
|
||||
I_ConstructorWithDefaults3(IN, Producer::KeyboardMouse *, keyboardMouse, , IN, bool &, done, , IN, bool, escapeKeySetsDone, true);
|
||||
@ -40,38 +40,20 @@ BEGIN_OBJECT_REFLECTOR(osgProducer::KeyboardMouseCallback)
|
||||
I_Method0(void, shutdown);
|
||||
I_Method1(void, setEscapeSetDone, IN, bool, esc);
|
||||
I_Method0(bool, getEscapeSetDone);
|
||||
I_Method1(double, getEventQueue, IN, osgProducer::KeyboardMouseCallback::EventQueue &, queue);
|
||||
I_Method1(double, copyEventQueue, IN, osgProducer::KeyboardMouseCallback::EventQueue &, queue);
|
||||
I_Method1(double, setEventQueue, IN, osgProducer::KeyboardMouseCallback::EventQueue &, queue);
|
||||
I_Method1(double, appendEventQueue, IN, osgProducer::KeyboardMouseCallback::EventQueue &, queue);
|
||||
I_Method0(osgGA::EventQueue *, getEventQueue);
|
||||
I_Method1(bool, takeEventQueue, IN, osgProducer::KeyboardMouseCallback::EventQueue &, queue);
|
||||
I_Method1(bool, copyEventQueue, IN, osgProducer::KeyboardMouseCallback::EventQueue &, queue);
|
||||
I_Method1(void, setEventQueue, IN, osgProducer::KeyboardMouseCallback::EventQueue &, queue);
|
||||
I_Method1(void, appendEventQueue, IN, osgProducer::KeyboardMouseCallback::EventQueue &, queue);
|
||||
I_Method0(bool, done);
|
||||
I_Method0(float, mx);
|
||||
I_Method0(float, my);
|
||||
I_Method0(unsigned int, mbutton);
|
||||
I_Method1(void, setStartTick, IN, osg::Timer_t, tick);
|
||||
I_Method0(osg::Timer_t, getStartTick);
|
||||
I_Method0(double, getTime);
|
||||
I_Method0(Producer::KeyboardMouse *, getKeyboardMouse);
|
||||
I_Method0(const Producer::KeyboardMouse *, getKeyboardMouse);
|
||||
I_Method0(osgProducer::EventAdapter *, createEventAdapter);
|
||||
I_Method0(osgGA::GUIEventAdapter *, createEventAdapter);
|
||||
I_Method0(void, updateWindowSize);
|
||||
I_Property(bool, EscapeSetDone);
|
||||
I_WriteOnlyPropertyWithReturnType(osgProducer::KeyboardMouseCallback::EventQueue &, EventQueue, double);
|
||||
I_ReadOnlyProperty(osgGA::EventQueue *, EventQueue);
|
||||
I_ReadOnlyProperty(Producer::KeyboardMouse *, KeyboardMouse);
|
||||
I_Property(osg::Timer_t, StartTick);
|
||||
I_ReadOnlyProperty(double, Time);
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osgProducer::EventAdapter >)
|
||||
I_Constructor0();
|
||||
I_Constructor1(IN, osgProducer::EventAdapter *, t);
|
||||
I_Constructor1(IN, const osg::ref_ptr< osgProducer::EventAdapter > &, rp);
|
||||
I_Method0(bool, valid);
|
||||
I_Method0(osgProducer::EventAdapter *, get);
|
||||
I_Method0(const osgProducer::EventAdapter *, get);
|
||||
I_Method0(osgProducer::EventAdapter *, take);
|
||||
I_Method0(osgProducer::EventAdapter *, release);
|
||||
I_ReadOnlyProperty(osgProducer::EventAdapter *, );
|
||||
END_REFLECTOR
|
||||
|
||||
STD_VECTOR_REFLECTOR(std::vector< osg::ref_ptr< osgProducer::EventAdapter > >);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user