Added sendPointerEvent and sendKeyEvent virtual methods to osg::Image to
facilitate the subclassing of Image providing interactive behaviours so as used in the vnc interactive VncImage class. osgViewer::InteractiveImageHandler provides an event handler that convertes osgGA mouse and keyboard events into the coordinate frame of an image based on ray intersection with geometry in the associated subgraph. Changed the ordering of events processing in Viewer and CompositeViewer to allow scene graph event handlers to take precidence over viewer event handlers and camera manipulators
This commit is contained in:
@@ -309,6 +309,14 @@ class OSG_EXPORT Image : public Object
|
||||
|
||||
virtual void update(NodeVisitor* nv) {}
|
||||
|
||||
|
||||
/** method for sending pointer events to images that are acting as front ends to interactive surfaces such as a vnc or browser window.*/
|
||||
virtual void sendPointerEvent(int x, int y, int buttonMask) {};
|
||||
|
||||
/** method for sending key events to images that are acting as front ends to interactive surfaces such as a vnc or browser window.*/
|
||||
virtual void sendKeyEvent(int key, bool keyDown) {};
|
||||
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~Image();
|
||||
|
||||
@@ -362,6 +362,28 @@ class OSGVIEWER_EXPORT ScreenCaptureHandler : public osgGA::GUIEventHandler
|
||||
void addCallbackToViewer(osgViewer::ViewerBase& viewer);
|
||||
};
|
||||
|
||||
/** InteractiveImage is an event handler that computes the mouse coordinates in an images coordinate frame
|
||||
* and then passes keyboard and mouse events to it. This event handler is useful for vnc or browser
|
||||
* surfaces in the 3D scene.*/
|
||||
class OSGVIEWER_EXPORT InteractiveImageHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
InteractiveImageHandler(osg::Image* image):
|
||||
_image(image) {}
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~InteractiveImageHandler() {}
|
||||
|
||||
bool mousePosition(osgViewer::View* view, osg::NodeVisitor* nv, const osgGA::GUIEventAdapter& ea, int& x, int &y) const;
|
||||
|
||||
osg::observer_ptr<osg::Image> _image;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user