Fixed crash when no CameraManipulator is assigned to the viewer

This commit is contained in:
Robert Osfield 2012-11-30 20:03:31 +00:00
parent d831f1b538
commit 3e32d9c8af
2 changed files with 29 additions and 18 deletions

View File

@ -402,19 +402,20 @@ bool ReaderWriterP3DXML::getKeyProperty(osgDB::XmlNode*cur, const char* token, i
{ {
std::istringstream iss(itr->second); std::istringstream iss(itr->second);
iss>>std::hex>>value; iss>>std::hex>>value;
OSG_NOTICE<<"ReaderWriterP3DXML::getKeyProperty() hex result = "<<value<<std::endl;
return true; return true;
} }
else if (itr->second.size()>1 && (itr->second[0]>='0' && itr->second[0]<='9')) else if (itr->second.size()>1 && (itr->second[0]>='0' && itr->second[0]<='9'))
{ {
std::istringstream iss(itr->second); std::istringstream iss(itr->second);
iss>>value; iss>>value;
OSG_NOTICE<<" numeric result = "<<value<<std::endl; OSG_NOTICE<<"ReaderWriterP3DXML::getKeyProperty() numeric result = "<<value<<std::endl;
return true; return true;
} }
else else
{ {
value = itr->second[0]; value = itr->second[0];
OSG_NOTICE<<" alphanumeric result = "<<value<<std::endl; OSG_NOTICE<<"ReaderWriterP3DXML::getKeyProperty() alphanumeric result = "<<value<<std::endl;
return true; return true;
} }
} }
@ -1533,6 +1534,10 @@ void ReaderWriterP3DXML::parseLayer(osgPresentation::SlideShowConstructor& const
constructor.keyEventOperation(osgPresentation::SlideShowConstructor::CURRENT_LAYER, key, osgPresentation::JUMP, jumpData); constructor.keyEventOperation(osgPresentation::SlideShowConstructor::CURRENT_LAYER, key, osgPresentation::JUMP, jumpData);
} }
else
{
OSG_NOTICE<<"key_to_jump failed."<<std::endl;
}
} }
else if (cur->name == "newline") else if (cur->name == "newline")

View File

@ -1244,9 +1244,12 @@ bool SlideEventHandler::selectSlide(int slideNum,int layerNum)
// refersh the viewer. // refersh the viewer.
//_viewer->getKeySwitchMatrixManipulator()->setMinimumDistance(0.001); //_viewer->getKeySwitchMatrixManipulator()->setMinimumDistance(0.001);
if (_viewer->getCameraManipulator())
{
_viewer->getCameraManipulator()->setNode(_slideSwitch.get()); _viewer->getCameraManipulator()->setNode(_slideSwitch.get());
_viewer->computeActiveCoordinateSystemNodePath(); _viewer->computeActiveCoordinateSystemNodePath();
}
// resetUpdateCallbacks(ALL_OBJECTS); // resetUpdateCallbacks(ALL_OBJECTS);
@ -1387,6 +1390,8 @@ bool SlideEventHandler::home(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAd
osg::Node* node = _viewer->getSceneData(); osg::Node* node = _viewer->getSceneData();
if (node) node->accept(fhpv); if (node) node->accept(fhpv);
if (_viewer->getCameraManipulator())
{
if (fhpv._homePosition.valid()) if (fhpv._homePosition.valid())
{ {
OSG_INFO<<"Doing home for stored home position."<<std::endl; OSG_INFO<<"Doing home for stored home position."<<std::endl;
@ -1402,6 +1407,7 @@ bool SlideEventHandler::home(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAd
_viewer->getCameraManipulator()->setAutoComputeHomePosition(true); _viewer->getCameraManipulator()->setAutoComputeHomePosition(true);
} }
_viewer->getCameraManipulator()->home(ea,aa); _viewer->getCameraManipulator()->home(ea,aa);
}
return true; return true;
} }