Further work on CompositeViewer
This commit is contained in:
parent
0b40a6fc82
commit
1ee2af9f41
@ -3,6 +3,7 @@
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgGA/TrackballManipulator>
|
||||
#include <osgGA/FlightManipulator>
|
||||
#include <osgGA/AnimationPathManipulator>
|
||||
#include <iostream>
|
||||
|
||||
@ -251,9 +252,15 @@ int main( int argc, char **argv )
|
||||
while (arguments.read("-1")) { singleWindowMultipleCameras(viewer); }
|
||||
while (arguments.read("-2")) { multipleWindowMultipleCameras(viewer); }
|
||||
|
||||
|
||||
#if 0
|
||||
if (apm.valid()) viewer.setCameraManipulator(apm.get());
|
||||
else viewer.setCameraManipulator( new osgGA::TrackballManipulator() );
|
||||
#else
|
||||
|
||||
viewer.setCameraManipulator( new osgGA::FlightManipulator() );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
|
@ -98,9 +98,11 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
|
||||
public:
|
||||
|
||||
void assignSceneDataToCameras();
|
||||
void init();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
virtual ~View();
|
||||
|
||||
osg::ref_ptr<osgViewer::Scene> _scene;
|
||||
|
@ -129,7 +129,6 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
|
||||
|
||||
protected:
|
||||
|
||||
void init();
|
||||
void checkWindowStatus();
|
||||
|
||||
bool _firstFrame;
|
||||
|
@ -44,7 +44,7 @@ CompositeViewer::CompositeViewer():
|
||||
|
||||
CompositeViewer::~CompositeViewer()
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"CompositeViewer::~CompositeViewer()"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"CompositeViewer::~CompositeViewer()"<<std::endl;
|
||||
|
||||
stopThreading();
|
||||
|
||||
@ -74,7 +74,7 @@ CompositeViewer::~CompositeViewer()
|
||||
(*citr)->close();
|
||||
}
|
||||
|
||||
osg::notify(osg::NOTICE)<<"finish CompositeViewer::~CompsiteViewer()"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"finished CompositeViewer::~CompsiteViewer()"<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
@ -415,7 +415,7 @@ void CompositeViewer::init()
|
||||
itr != _views.end();
|
||||
++itr)
|
||||
{
|
||||
// (*itr)->init();
|
||||
(*itr)->init();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,19 @@ View::~View()
|
||||
// osg::notify(osg::NOTICE)<<"Destructing osgViewer::View"<<std::endl;
|
||||
}
|
||||
|
||||
void View::init()
|
||||
{
|
||||
osg::notify(osg::INFO)<<"View::init()"<<std::endl;
|
||||
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> initEvent = _eventQueue->createEvent();
|
||||
initEvent->setEventType(osgGA::GUIEventAdapter::FRAME);
|
||||
|
||||
if (_cameraManipulator.valid())
|
||||
{
|
||||
_cameraManipulator->init(*initEvent, *this);
|
||||
}
|
||||
}
|
||||
|
||||
void View::setSceneData(osg::Node* node)
|
||||
{
|
||||
_scene = new osgViewer::Scene;
|
||||
@ -312,8 +325,7 @@ void View::requestContinuousUpdate(bool)
|
||||
|
||||
void View::requestWarpPointer(float x,float y)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"View::requestWarpPointer("<<x<<","<<y<<")"<<std::endl;
|
||||
|
||||
osg::notify(osg::INFO)<<"View::requestWarpPointer("<<x<<","<<y<<")"<<std::endl;
|
||||
|
||||
float local_x, local_y;
|
||||
const osg::Camera* camera = getCameraContainingPosition(x, y, local_x, local_y);
|
||||
@ -333,7 +345,7 @@ void View::requestWarpPointer(float x,float y)
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"View::requestWarpPointer failed no camera containing pointer"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"View::requestWarpPointer failed no camera containing pointer"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,6 +366,8 @@ const osg::Camera* View::getCameraContainingPosition(float x, float y, float& lo
|
||||
const osgGA::GUIEventAdapter* eventState = getEventQueue()->getCurrentEventState();
|
||||
bool view_invert_y = eventState->getMouseYOrientation()==osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS;
|
||||
|
||||
osg::notify(osg::INFO)<<"View::getCameraContainingPosition("<<x<<","<<y<<",..,..) view_invert_y="<<view_invert_y<<std::endl;
|
||||
|
||||
double epsilon = 0.5;
|
||||
|
||||
if (_camera->getGraphicsContext() && _camera->getViewport())
|
||||
@ -362,12 +376,6 @@ const osg::Camera* View::getCameraContainingPosition(float x, float y, float& lo
|
||||
|
||||
osg::Vec2d new_coord(x, y);
|
||||
|
||||
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(_camera->getGraphicsContext());
|
||||
if (gw && gw->getEventQueue()->getCurrentEventState()->getMouseYOrientation()==osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS)
|
||||
{
|
||||
new_coord.y() = gw->getTraits()->height - new_coord.y();
|
||||
}
|
||||
|
||||
if (viewport &&
|
||||
new_coord.x() >= (viewport->x()-epsilon) && new_coord.y() >= (viewport->y()-epsilon) &&
|
||||
new_coord.x() < (viewport->x()+viewport->width()-1.0+epsilon) && new_coord.y() <= (viewport->y()+viewport->height()-1.0+epsilon) )
|
||||
|
@ -392,20 +392,6 @@ void Viewer::checkWindowStatus()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Viewer::init()
|
||||
{
|
||||
osg::notify(osg::INFO)<<"Viewer::init()"<<std::endl;
|
||||
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> initEvent = _eventQueue->createEvent();
|
||||
initEvent->setEventType(osgGA::GUIEventAdapter::FRAME);
|
||||
|
||||
if (_cameraManipulator.valid())
|
||||
{
|
||||
_cameraManipulator->init(*initEvent, *this);
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::getContexts(Contexts& contexts, bool onlyValid)
|
||||
{
|
||||
typedef std::set<osg::GraphicsContext*> ContextSet;
|
||||
|
Loading…
Reference in New Issue
Block a user