From 9d68e135675afbaca3bf09c7541128f87d8d470a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 11 Mar 2016 19:41:22 +0000 Subject: [PATCH] Added support for invoked an editor defined by P3D_EDITOR or EDITOR env vars when user press 'U' in Present3D. This feature makes it easier to editor an presentation that is already running in Present3D, once the edits are done pressing 'u' in Present3D then loads the file again. --- src/osgPlugins/p3d/ReaderWriterP3D.cpp | 5 +++++ src/osgPresentation/SlideEventHandler.cpp | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/osgPlugins/p3d/ReaderWriterP3D.cpp b/src/osgPlugins/p3d/ReaderWriterP3D.cpp index adfa265c7..9a15d4af2 100644 --- a/src/osgPlugins/p3d/ReaderWriterP3D.cpp +++ b/src/osgPlugins/p3d/ReaderWriterP3D.cpp @@ -2956,6 +2956,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterP3DXML::readNode(const std::string& local_opt->getDatabasePathList().push_front(osgDB::getFilePath(fileName)); local_opt->setFindFileCallback(new MyFindFileCallback); local_opt->setPluginStringData("filename",file); + local_opt->setPluginStringData("fullpath",fileName); osgDB::XmlNode::Input input; input.open(fileName); @@ -2980,6 +2981,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterP3DXML::readNode(std::istream& fin, osgDB::ReaderWriter::ReadResult ReaderWriterP3DXML::readNode(osgDB::XmlNode::Input& input, osgDB::ReaderWriter::Options* options) const { std::string fileName = options ? options->getPluginStringData("filename") : std::string(); + std::string fullpath = options ? options->getPluginStringData("fullpath") : std::string(); std::string extension = osgDB::getFileExtension(fileName); std::string fileNameSansExtension = osgDB::getNameLessExtension(fileName); std::string nestedExtension = osgDB::getFileExtension(fileNameSansExtension); @@ -3085,6 +3087,9 @@ osgDB::ReaderWriter::ReadResult ReaderWriterP3DXML::readNode(osgDB::XmlNode::Inp if (presentation_node.valid()) { + presentation_node->setUserValue("filename",fileName); + presentation_node->setUserValue("fullpath",fullpath); + if (!options || options->getPluginStringData("P3D_EVENTHANDLER")!="none") { // if (!readOnlyHoldingPage && !readOnlyMainPresentation) diff --git a/src/osgPresentation/SlideEventHandler.cpp b/src/osgPresentation/SlideEventHandler.cpp index b6ac0eb46..0702eafd4 100644 --- a/src/osgPresentation/SlideEventHandler.cpp +++ b/src/osgPresentation/SlideEventHandler.cpp @@ -907,6 +907,10 @@ void SlideEventHandler::set(osg::Node* model) FindNamedSwitchVisitor findPresentation("Presentation"); model->accept(findPresentation); + std::string fullpath; + model->getUserValue("fullpath", fullpath); + if (!fullpath.empty()) setUserValue("fullpath", fullpath); + if (findPresentation._switch) { OSG_INFO<<"Presentation '"<getName()<<"'"<