Added View::home() method and updated wrappers

This commit is contained in:
Robert Osfield 2007-06-07 09:58:49 +00:00
parent 1d7ba27e72
commit 51d489fb97
3 changed files with 53 additions and 11 deletions

View File

@ -66,26 +66,53 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
Scene* getScene() { return _scene.get(); }
const Scene* getScene() const { return _scene.get(); }
/** Set the scene graph that the View will use.*/
virtual void setSceneData(osg::Node* node);
/** Get the View's scene graph.*/
osg::Node* getSceneData() { return _scene.valid() ? _scene->getSceneData() : 0; }
/** Get the const View's scene graph.*/
const osg::Node* getSceneData() const { return _scene.valid() ? _scene->getSceneData() : 0; }
/* Set the EventQueue that View uses to intregrate external non window related events.*/
void setEventQueue(osgGA::EventQueue* eventQueue) { _eventQueue = eventQueue; }
/* Get the View's EventQueue.*/
osgGA::EventQueue* getEventQueue() { return _eventQueue.get(); }
/* Get the const View's EventQueue.*/
const osgGA::EventQueue* getEventQueue() const { return _eventQueue.get(); }
/** Set the CameraManipulator that moves the View's master Camera position in response to events.*/
void setCameraManipulator(osgGA::MatrixManipulator* manipulator);
/** Get the View's CameraManipulator.*/
osgGA::MatrixManipulator* getCameraManipulator() { return _cameraManipulator.get(); }
/** Get the const View's CameraManipulator.*/
const osgGA::MatrixManipulator* getCameraManipulator() const { return _cameraManipulator.get(); }
/** Set the view to the CameraManipulator's home position, if non is attached home() is does nothing.
* Note, to set the home position use getCamaraManipulator()->setHomePosition(...). */
void home();
typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlers;
/** Add an EventHandler that adds handling of events to the View.*/
void addEventHandler(osgGA::GUIEventHandler* eventHandler);
/** Get the View's list of EventHandlers.*/
EventHandlers& getEventHandlers() { return _eventHandlers; }
/** Get the const View's list of EventHandlers.*/
const EventHandlers& getEventHandlers() const { return _eventHandlers; }
/** Set the NodePath to any active CoordinateSystemNode present in the Scene.*/
/** Set the NodePath to any active CoordinateSystemNode present in the Scene.
* The CoordinateSystemNode path is used to help applications and CamaraManipualtors handle geocentric coordinates systems,
* such as known which way is the local up at any position on the a whole earth. */
void setCoordinateSystemNodePath(const osg::NodePath& nodePath);
/** Get the NodePath to any active CoordinateSystemNode present in the Scene.*/

View File

@ -183,6 +183,16 @@ void View::setCameraManipulator(osgGA::MatrixManipulator* manipulator)
}
}
void View::home()
{
if (_cameraManipulator.valid())
{
osg::ref_ptr<osgGA::GUIEventAdapter> dummyEvent = _eventQueue->createEvent();
_cameraManipulator->home(*dummyEvent, *this);
}
}
void View::addEventHandler(osgGA::GUIEventHandler* eventHandler)
{
_eventHandlers.push_back(eventHandler);

View File

@ -119,17 +119,17 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::View)
I_Method1(void, setSceneData, IN, osg::Node *, node,
Properties::VIRTUAL,
__void__setSceneData__osg_Node_P1,
"",
"Set the scene graph that the View will use. ",
"");
I_Method0(osg::Node *, getSceneData,
Properties::NON_VIRTUAL,
__osg_Node_P1__getSceneData,
"",
"Get the View's scene graph. ",
"");
I_Method0(const osg::Node *, getSceneData,
Properties::NON_VIRTUAL,
__C5_osg_Node_P1__getSceneData,
"",
"Get the const View's scene graph. ",
"");
I_Method1(void, setEventQueue, IN, osgGA::EventQueue *, eventQueue,
Properties::NON_VIRTUAL,
@ -149,38 +149,43 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::View)
I_Method1(void, setCameraManipulator, IN, osgGA::MatrixManipulator *, manipulator,
Properties::NON_VIRTUAL,
__void__setCameraManipulator__osgGA_MatrixManipulator_P1,
"",
"Set the CameraManipulator that moves the View's master Camera position in response to events. ",
"");
I_Method0(osgGA::MatrixManipulator *, getCameraManipulator,
Properties::NON_VIRTUAL,
__osgGA_MatrixManipulator_P1__getCameraManipulator,
"",
"Get the View's CameraManipulator. ",
"");
I_Method0(const osgGA::MatrixManipulator *, getCameraManipulator,
Properties::NON_VIRTUAL,
__C5_osgGA_MatrixManipulator_P1__getCameraManipulator,
"",
"Get the const View's CameraManipulator. ",
"");
I_Method0(void, home,
Properties::NON_VIRTUAL,
__void__home,
"Set the view to the CameraManipulator's home position, if non is attached home() is does nothing. ",
"Note, to set the home position use getCamaraManipulator()->setHomePosition(...). ");
I_Method1(void, addEventHandler, IN, osgGA::GUIEventHandler *, eventHandler,
Properties::NON_VIRTUAL,
__void__addEventHandler__osgGA_GUIEventHandler_P1,
"",
"Add an EventHandler that adds handling of events to the View. ",
"");
I_Method0(osgViewer::View::EventHandlers &, getEventHandlers,
Properties::NON_VIRTUAL,
__EventHandlers_R1__getEventHandlers,
"",
"Get the View's list of EventHandlers. ",
"");
I_Method0(const osgViewer::View::EventHandlers &, getEventHandlers,
Properties::NON_VIRTUAL,
__C5_EventHandlers_R1__getEventHandlers,
"",
"Get the const View's list of EventHandlers. ",
"");
I_Method1(void, setCoordinateSystemNodePath, IN, const osg::NodePath &, nodePath,
Properties::NON_VIRTUAL,
__void__setCoordinateSystemNodePath__C5_osg_NodePath_R1,
"Set the NodePath to any active CoordinateSystemNode present in the Scene. ",
"");
"The CoordinateSystemNode path is used to help applications and CamaraManipualtors handle geocentric coordinates systems, such as known which way is the local up at any position on the a whole earth. ");
I_Method0(osg::NodePath, getCoordinateSystemNodePath,
Properties::NON_VIRTUAL,
__osg_NodePath__getCoordinateSystemNodePath,