Cleaned up CompositeViewer interface and added event traversal of views
This commit is contained in:
@@ -249,6 +249,7 @@ int main( int argc, char **argv )
|
||||
|
||||
}
|
||||
|
||||
// view three
|
||||
{
|
||||
osgViewer::View* view = new osgViewer::View;
|
||||
viewer.addView(view);
|
||||
@@ -267,5 +268,6 @@ int main( int argc, char **argv )
|
||||
while (arguments.read("-g")) { viewer.setThreadingModel(osgViewer::CompositeViewer::ThreadPerContext); }
|
||||
while (arguments.read("-c")) { viewer.setThreadingModel(osgViewer::CompositeViewer::ThreadPerCamera); }
|
||||
|
||||
return viewer.run();
|
||||
// run the viewer's main frame loop
|
||||
return viewer.run();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace osgViewer {
|
||||
// WARNING ** Under development do not use, yet :-)
|
||||
|
||||
/** CompsiteViewer holds a or more views to a one more scenes.*/
|
||||
class OSGVIEWER_EXPORT CompositeViewer : public osg::Referenced, public osgGA::GUIActionAdapter
|
||||
class OSGVIEWER_EXPORT CompositeViewer : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -144,25 +144,6 @@ class OSGVIEWER_EXPORT CompositeViewer : public osg::Referenced, public osgGA::G
|
||||
void startThreading();
|
||||
void setUpRenderingSupport();
|
||||
|
||||
/** 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.
|
||||
* Mouse events handled by the view will automatically be attached into the master camera window/clip coords so can be passed
|
||||
* directly on to the computeIntersections method. */
|
||||
bool computeIntersections(float x,float y, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask = 0xffffffff);
|
||||
|
||||
/** 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);
|
||||
virtual void requestWarpPointer(float x,float y);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ CompositeViewer::CompositeViewer():
|
||||
setEventQueue(new osgGA::EventQueue);
|
||||
|
||||
_eventVisitor = new osgGA::EventVisitor;
|
||||
_eventVisitor->setActionAdapter(this);
|
||||
}
|
||||
|
||||
CompositeViewer::~CompositeViewer()
|
||||
@@ -962,6 +961,8 @@ void CompositeViewer::eventTraversal()
|
||||
++veitr)
|
||||
{
|
||||
View* view = veitr->first;
|
||||
_eventVisitor->setActionAdapter(view);
|
||||
|
||||
for(osgGA::EventQueue::Events::iterator itr = veitr->second.begin();
|
||||
itr != veitr->second.end();
|
||||
++itr)
|
||||
@@ -984,30 +985,33 @@ void CompositeViewer::eventTraversal()
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (_eventVisitor.valid() && _scene.valid())
|
||||
if (_eventVisitor.valid())
|
||||
{
|
||||
_eventVisitor->setFrameStamp(getFrameStamp());
|
||||
_eventVisitor->setTraversalNumber(getFrameStamp()->getFrameNumber());
|
||||
|
||||
for(osgGA::EventQueue::Events::iterator itr = events.begin();
|
||||
itr != events.end();
|
||||
++itr)
|
||||
for(ViewEventsMap::iterator veitr = viewEventsMap.begin();
|
||||
veitr != viewEventsMap.end();
|
||||
++veitr)
|
||||
{
|
||||
osgGA::GUIEventAdapter* event = itr->get();
|
||||
View* view = veitr->first;
|
||||
for(osgGA::EventQueue::Events::iterator itr = veitr->second.begin();
|
||||
itr != veitr->second.end();
|
||||
++itr)
|
||||
{
|
||||
osgGA::GUIEventAdapter* event = itr->get();
|
||||
|
||||
bool handled = false;
|
||||
bool handled = false;
|
||||
|
||||
_eventVisitor->reset();
|
||||
_eventVisitor->addEvent( event );
|
||||
_eventVisitor->reset();
|
||||
_eventVisitor->addEvent( event );
|
||||
|
||||
getSceneData()->accept(*_eventVisitor);
|
||||
view->getSceneData()->accept(*_eventVisitor);
|
||||
|
||||
if (_eventVisitor->getEventHandled()) handled = true;
|
||||
if (_eventVisitor->getEventHandled()) handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void CompositeViewer::updateTraversal()
|
||||
@@ -1112,16 +1116,3 @@ void CompositeViewer::renderingTraversals()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CompositeViewer::requestRedraw()
|
||||
{
|
||||
}
|
||||
|
||||
void CompositeViewer::requestContinuousUpdate(bool)
|
||||
{
|
||||
}
|
||||
|
||||
void CompositeViewer::requestWarpPointer(float x,float y)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"CompositeViewer::requestWarpPointer("<<x<<","<<y<<")"<<std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user