Added support for assigning GraphicsContext to individual GUIEventAdapter events,
and use of this within osgViewer::View to better track the sources of events.
This commit is contained in:
@@ -59,6 +59,10 @@ class OSGGA_EXPORT EventQueue : public osg::Referenced
|
||||
bool getUseFixedMouseInputRange() { return _useFixedMouseInputRange; }
|
||||
|
||||
|
||||
/** Set the graphics context associated with this event queue.*/
|
||||
void setGraphicsContext(osg::GraphicsContext* context) { getCurrentEventState()->setGraphicsContext(context); }
|
||||
|
||||
|
||||
/** Set the mouse input range.*/
|
||||
void setMouseInputRange(float xMin, float yMin, float xMax, float yMax) { getCurrentEventState()->setInputRange(xMin, yMin, xMax, yMax); }
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <osg/Object>
|
||||
#include <osg/Matrix>
|
||||
#include <osg/GraphicsContext>
|
||||
#include <osgGA/Export>
|
||||
|
||||
namespace osgGA{
|
||||
@@ -290,6 +291,9 @@ public:
|
||||
/** deprecated function for getting time of event. */
|
||||
double time() const { return _time; }
|
||||
|
||||
|
||||
void setGraphicsContext(osg::GraphicsContext* context) { _context = context; }
|
||||
const osg::GraphicsContext* getGraphicsContext() const { return _context.get(); }
|
||||
|
||||
|
||||
/** set window rectangle. */
|
||||
@@ -429,6 +433,7 @@ public:
|
||||
EventType _eventType;
|
||||
double _time;
|
||||
|
||||
osg::observer_ptr<osg::GraphicsContext> _context;
|
||||
int _windowX;
|
||||
int _windowY;
|
||||
int _windowWidth;
|
||||
|
||||
@@ -40,7 +40,7 @@ class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgG
|
||||
{
|
||||
public:
|
||||
|
||||
GraphicsWindow() { _eventQueue = new osgGA::EventQueue; }
|
||||
GraphicsWindow() { _eventQueue = new osgGA::EventQueue; _eventQueue->setGraphicsContext(this); }
|
||||
|
||||
virtual bool isSameKindAs(const Object* object) const { return dynamic_cast<const GraphicsWindow*>(object)!=0; }
|
||||
virtual const char* libraryName() const { return "osgViewer"; }
|
||||
|
||||
@@ -176,7 +176,7 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
|
||||
/** Get the camera which contains the pointer position x,y specified master cameras window/eye coords.
|
||||
* Also passes back the local window coords for the graphics context associated with the camera passed back. */
|
||||
const osg::Camera* getCameraContainingPosition(float x, float y, float& local_x, float& local_y) const;
|
||||
|
||||
|
||||
/** Compute intersections between a ray through the specified master cameras window/eye coords and a specified node.
|
||||
* Note, when a master cameras has slaves and no viewport itself its coordinate frame will be in clip space i.e. -1,-1 to 1,1,
|
||||
* while if its has a viewport the coordintates will be relative to its viewport dimensions.
|
||||
@@ -186,7 +186,7 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
|
||||
|
||||
/** Compute intersections between a ray through the specified master cameras window/eye coords and a specified nodePath's subgraph. */
|
||||
bool computeIntersections(float x,float y, osg::NodePath& nodePath, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask = 0xffffffff);
|
||||
|
||||
|
||||
|
||||
virtual void requestRedraw();
|
||||
virtual void requestContinuousUpdate(bool needed=true);
|
||||
|
||||
Reference in New Issue
Block a user