Reorganised placement of classes associated with scene graph.

Warning clean up.
This commit is contained in:
Robert Osfield 2009-04-28 14:03:02 +00:00
parent 6399de2897
commit 54c3204524
11 changed files with 275 additions and 248 deletions

View File

@ -82,7 +82,7 @@ std::string ExportHTML::createFileName(const std::string& basename, unsigned int
else return createString(basename,'_', page, ext); else return createString(basename,'_', page, ext);
} }
bool ExportHTML::write(SlideEventHandler* seh, osgViewer::Viewer& viewer, const std::string& filename) bool ExportHTML::write(osgPresentation::SlideEventHandler* seh, osgViewer::Viewer& viewer, const std::string& filename)
{ {
std::string image_basename; std::string image_basename;
std::string image_ext; std::string image_ext;
@ -179,7 +179,7 @@ bool ExportHTML::write(SlideEventHandler* seh, osgViewer::Viewer& viewer, const
} }
// wait for all cull and draw threads to complete. // wait for all cull and draw threads to complete.
seh->selectSlide(i, SlideEventHandler::LAST_POSITION); seh->selectSlide(i, osgPresentation::SlideEventHandler::LAST_POSITION);
// fire off the cull and draw traversals of the scene. // fire off the cull and draw traversals of the scene.
viewer.frame(); viewer.frame();

View File

@ -19,7 +19,7 @@
class ExportHTML class ExportHTML
{ {
public: public:
static bool write(SlideEventHandler* seh, osgViewer::Viewer& viewer, const std::string& filename); static bool write(osgPresentation::SlideEventHandler* seh, osgViewer::Viewer& viewer, const std::string& filename);
static std::string createFileName(const std::string& basename, unsigned int page, const std::string& ext); static std::string createFileName(const std::string& basename, unsigned int page, const std::string& ext);
}; };

View File

@ -17,7 +17,9 @@
#include <osg/Notify> #include <osg/Notify>
#include <osgDB/FileUtils> #include <osgDB/FileUtils>
PickEventHandler::PickEventHandler(SlideShowConstructor::Operation operation,bool relativeJump, int slideNum, int layerNum): using namespace osgPresentation;
PickEventHandler::PickEventHandler(osgPresentation::Operation operation,bool relativeJump, int slideNum, int layerNum):
_operation(operation), _operation(operation),
_relativeJump(relativeJump), _relativeJump(relativeJump),
_slideNum(slideNum), _slideNum(slideNum),
@ -25,7 +27,7 @@ PickEventHandler::PickEventHandler(SlideShowConstructor::Operation operation,boo
{ {
} }
PickEventHandler::PickEventHandler(const std::string& str, SlideShowConstructor::Operation operation,bool relativeJump, int slideNum, int layerNum): PickEventHandler::PickEventHandler(const std::string& str, osgPresentation::Operation operation,bool relativeJump, int slideNum, int layerNum):
_command(str), _command(str),
_operation(operation), _operation(operation),
_relativeJump(relativeJump), _relativeJump(relativeJump),
@ -34,9 +36,9 @@ PickEventHandler::PickEventHandler(const std::string& str, SlideShowConstructor:
{ {
} }
PickEventHandler::PickEventHandler(const SlideShowConstructor::KeyPosition& keyPos,bool relativeJump, int slideNum, int layerNum): PickEventHandler::PickEventHandler(const osgPresentation::KeyPosition& keyPos,bool relativeJump, int slideNum, int layerNum):
_keyPos(keyPos), _keyPos(keyPos),
_operation(SlideShowConstructor::EVENT), _operation(osgPresentation::EVENT),
_relativeJump(relativeJump), _relativeJump(relativeJump),
_slideNum(slideNum), _slideNum(slideNum),
_layerNum(layerNum) _layerNum(layerNum)
@ -114,13 +116,12 @@ void PickEventHandler::doOperation()
{ {
switch(_operation) switch(_operation)
{ {
case(SlideShowConstructor::RUN): case(osgPresentation::RUN):
{ {
osg::notify(osg::NOTICE)<<"Run "<<_command<<std::endl; osg::notify(osg::NOTICE)<<"Run "<<_command<<std::endl;
osgDB::FilePathList& paths = osgDB::getDataFilePathList();
#if 0 #if 0
osgDB::FilePathList& paths = osgDB::getDataFilePathList();
if (!paths.empty()) if (!paths.empty())
{ {
#ifdef _WIN32 #ifdef _WIN32
@ -164,17 +165,22 @@ void PickEventHandler::doOperation()
break; break;
} }
case(SlideShowConstructor::LOAD): case(osgPresentation::LOAD):
{ {
osg::notify(osg::NOTICE)<<"Load "<<_command<<std::endl; osg::notify(osg::NOTICE)<<"Load "<<_command<<std::endl;
break; break;
} }
case(SlideShowConstructor::EVENT): case(osgPresentation::EVENT):
{ {
osg::notify(osg::INFO)<<"Event "<<_keyPos._key<<" "<<_keyPos._x<<" "<<_keyPos._y<<std::endl; osg::notify(osg::INFO)<<"Event "<<_keyPos._key<<" "<<_keyPos._x<<" "<<_keyPos._y<<std::endl;
if (SlideEventHandler::instance()) SlideEventHandler::instance()->dispatchEvent(_keyPos); if (SlideEventHandler::instance()) SlideEventHandler::instance()->dispatchEvent(_keyPos);
break; break;
} }
case(osgPresentation::JUMP):
{
osg::notify(osg::NOTICE)<<"Requires jump "<<std::endl;
break;
}
} }
if (requiresJump()) if (requiresJump())

View File

@ -18,24 +18,27 @@
#include <osgGA/GUIEventHandler> #include <osgGA/GUIEventHandler>
#include "SlideShowConstructor.h" #include "SlideEventHandler.h"
namespace osgPresentation
{
class PickEventHandler : public osgGA::GUIEventHandler class PickEventHandler : public osgGA::GUIEventHandler
{ {
public: public:
PickEventHandler(SlideShowConstructor::Operation operation, bool relativeJump=true, int slideNum=0, int layerNum=0); PickEventHandler(osgPresentation::Operation operation, bool relativeJump=true, int slideNum=0, int layerNum=0);
PickEventHandler(const std::string& str, SlideShowConstructor::Operation operation, bool relativeJump=true, int slideNum=0, int layerNum=0); PickEventHandler(const std::string& str, osgPresentation::Operation operation, bool relativeJump=true, int slideNum=0, int layerNum=0);
PickEventHandler(const SlideShowConstructor::KeyPosition& keyPos, bool relativeJump=true, int slideNum=0, int layerNum=0); PickEventHandler(const osgPresentation::KeyPosition& keyPos, bool relativeJump=true, int slideNum=0, int layerNum=0);
void setOperation(SlideShowConstructor::Operation operation) { _operation = operation; } void setOperation(osgPresentation::Operation operation) { _operation = operation; }
SlideShowConstructor::Operation getOperation() const { return _operation; } osgPresentation::Operation getOperation() const { return _operation; }
void setCommand(const std::string& str) { _command = str; } void setCommand(const std::string& str) { _command = str; }
const std::string& getCommand() const { return _command; } const std::string& getCommand() const { return _command; }
void setKeyPosition(const SlideShowConstructor::KeyPosition& keyPos) { _keyPos = keyPos; } void setKeyPosition(const osgPresentation::KeyPosition& keyPos) { _keyPos = keyPos; }
const SlideShowConstructor::KeyPosition& getKeyPosition() const { return _keyPos; } const osgPresentation::KeyPosition& getKeyPosition() const { return _keyPos; }
void setRelativeJump(int slideDelta, int layerDelta); void setRelativeJump(int slideDelta, int layerDelta);
void setAbsoluteJump(int slideNum, int layerNum); void setAbsoluteJump(int slideNum, int layerNum);
@ -55,12 +58,14 @@ class PickEventHandler : public osgGA::GUIEventHandler
void doOperation(); void doOperation();
std::string _command; std::string _command;
SlideShowConstructor::KeyPosition _keyPos; osgPresentation::KeyPosition _keyPos;
SlideShowConstructor::Operation _operation; osgPresentation::Operation _operation;
bool _relativeJump; bool _relativeJump;
int _slideNum; int _slideNum;
int _layerNum; int _layerNum;
}; };
}
#endif #endif

View File

@ -75,7 +75,7 @@ bool p3d::readEnvVars(osg::ArgumentParser& arguments)
{ {
bool readVars = false; bool readVars = false;
for(unsigned int i=1; i<arguments.argc(); ++i) for(int i=1; i<arguments.argc(); ++i)
{ {
if (!arguments.isOption(i)) if (!arguments.isOption(i))
{ {

View File

@ -112,22 +112,22 @@ public:
virtual ReadResult readNode(const std::string& fileName, virtual ReadResult readNode(const std::string& fileName,
const osgDB::ReaderWriter::Options* options) const; const osgDB::ReaderWriter::Options* options) const;
void parseModel(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const; void parseModel(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const;
void parseVolume(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const; void parseVolume(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const;
void parseStereoPair(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const; void parseStereoPair(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const;
void parseLayer(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const; void parseLayer(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const;
void parseBullets(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur, bool inheritPreviousLayers, bool defineAsBaseLayer) const; void parseBullets(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur, bool inheritPreviousLayers, bool defineAsBaseLayer) const;
void parseText(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur, bool inheritPreviousLayers, bool defineAsBaseLayer) const; void parseText(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur, bool inheritPreviousLayers, bool defineAsBaseLayer) const;
void parsePage (SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const; void parsePage (osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const;
void parseSlide (SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur, bool parseTitles=true, bool parseLayers=true) const; void parseSlide (osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur, bool parseTitles=true, bool parseLayers=true) const;
void parsePdfDocument (SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const; void parsePdfDocument (osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const;
osg::Vec4 mapStringToColor(const std::string& str) const osg::Vec4 mapStringToColor(const std::string& str) const
{ {
@ -175,14 +175,14 @@ public:
bool getProperty(xmlNodePtr cur, const char* token, osgText::Text::Layout& value) const; bool getProperty(xmlNodePtr cur, const char* token, osgText::Text::Layout& value) const;
bool getProperty(xmlNodePtr cur, const char* token, osgText::Text::AlignmentType& value) const; bool getProperty(xmlNodePtr cur, const char* token, osgText::Text::AlignmentType& value) const;
bool getProperties(xmlNodePtr cur, SlideShowConstructor::PositionData& value) const; bool getProperties(xmlNodePtr cur, osgPresentation::SlideShowConstructor::PositionData& value) const;
bool getProperties(xmlNodePtr cur, SlideShowConstructor::FontData& value) const; bool getProperties(xmlNodePtr cur, osgPresentation::SlideShowConstructor::FontData& value) const;
bool getProperties(xmlNodePtr cur, SlideShowConstructor::ModelData& value) const; bool getProperties(xmlNodePtr cur, osgPresentation::SlideShowConstructor::ModelData& value) const;
bool getProperties(xmlNodePtr cur, SlideShowConstructor::ImageData& value) const; bool getProperties(xmlNodePtr cur, osgPresentation::SlideShowConstructor::ImageData& value) const;
bool getJumpProperties(xmlNodePtr cur, bool& relativeJump, int& slideNum, int& layerNum) const; bool getJumpProperties(xmlNodePtr cur, bool& relativeJump, int& slideNum, int& layerNum) const;
bool getKeyPositionInner(xmlDocPtr doc, xmlNodePtr cur, SlideShowConstructor::KeyPosition& keyPosition) const; bool getKeyPositionInner(xmlDocPtr doc, xmlNodePtr cur, osgPresentation::KeyPosition& keyPosition) const;
bool getKeyPosition(xmlDocPtr doc, xmlNodePtr cur, SlideShowConstructor::KeyPosition& keyPosition) const; bool getKeyPosition(xmlDocPtr doc, xmlNodePtr cur, osgPresentation::KeyPosition& keyPosition) const;
typedef std::map<std::string,osg::Vec4> ColorMap; typedef std::map<std::string,osg::Vec4> ColorMap;
typedef std::map<std::string,osgText::Text::Layout> LayoutMap; typedef std::map<std::string,osgText::Text::Layout> LayoutMap;
@ -444,7 +444,7 @@ bool ReaderWriterP3DXML::getProperty(xmlNodePtr cur, const char* token, osgText:
return success; return success;
} }
bool ReaderWriterP3DXML::getProperties(xmlNodePtr cur, SlideShowConstructor::PositionData& value) const bool ReaderWriterP3DXML::getProperties(xmlNodePtr cur, osgPresentation::SlideShowConstructor::PositionData& value) const
{ {
bool propertiesRead=false; bool propertiesRead=false;
@ -461,14 +461,14 @@ bool ReaderWriterP3DXML::getProperties(xmlNodePtr cur, SlideShowConstructor::Pos
{ {
propertiesRead = true; propertiesRead = true;
if (str=="model") value.frame = SlideShowConstructor::MODEL; if (str=="model") value.frame = osgPresentation::SlideShowConstructor::MODEL;
else if (str=="slide") value.frame = SlideShowConstructor::SLIDE; else if (str=="slide") value.frame = osgPresentation::SlideShowConstructor::SLIDE;
else osg::notify(_notifyLevel)<<"Parser error - coordinate_frame=\""<<str<<"\" unrecongonized value"<<std::endl; else osg::notify(_notifyLevel)<<"Parser error - coordinate_frame=\""<<str<<"\" unrecongonized value"<<std::endl;
osg::notify(_notifyLevel)<<"read coordinate_frame "<< ((value.frame==SlideShowConstructor::MODEL) ? "SlideShowConstructor::MODEL" : "SlideShowConstructor::SLIDE")<<std::endl; osg::notify(_notifyLevel)<<"read coordinate_frame "<< ((value.frame==osgPresentation::SlideShowConstructor::MODEL) ? "osgPresentation::SlideShowConstructor::MODEL" : "osgPresentation::SlideShowConstructor::SLIDE")<<std::endl;
} }
if (value.frame==SlideShowConstructor::SLIDE) if (value.frame==osgPresentation::SlideShowConstructor::SLIDE)
{ {
if (getProperty(cur, "position", str)) if (getProperty(cur, "position", str))
@ -491,7 +491,7 @@ bool ReaderWriterP3DXML::getProperties(xmlNodePtr cur, SlideShowConstructor::Pos
else osg::notify(_notifyLevel)<<"Read position="<<value.position<<std::endl; else osg::notify(_notifyLevel)<<"Read position="<<value.position<<std::endl;
} }
} }
else // value.frame==SlideShowConstructor::MODEL else // value.frame==osgPresentation::SlideShowConstructor::MODEL
{ {
if (getProperty(cur, "position", str)) if (getProperty(cur, "position", str))
@ -686,7 +686,7 @@ bool ReaderWriterP3DXML::getProperties(xmlNodePtr cur, SlideShowConstructor::Pos
return propertiesRead; return propertiesRead;
} }
bool ReaderWriterP3DXML::getProperties(xmlNodePtr cur, SlideShowConstructor::FontData& value) const bool ReaderWriterP3DXML::getProperties(xmlNodePtr cur, osgPresentation::SlideShowConstructor::FontData& value) const
{ {
bool propertiesRead=false; bool propertiesRead=false;
@ -721,7 +721,7 @@ bool ReaderWriterP3DXML::getProperties(xmlNodePtr cur, SlideShowConstructor::Fon
return propertiesRead; return propertiesRead;
} }
bool ReaderWriterP3DXML::getProperties(xmlNodePtr cur, SlideShowConstructor::ModelData& value) const bool ReaderWriterP3DXML::getProperties(xmlNodePtr cur, osgPresentation::SlideShowConstructor::ModelData& value) const
{ {
bool propertiesRead=false; bool propertiesRead=false;
@ -736,7 +736,7 @@ bool ReaderWriterP3DXML::getProperties(xmlNodePtr cur, SlideShowConstructor::Mod
return propertiesRead; return propertiesRead;
} }
bool ReaderWriterP3DXML::getProperties(xmlNodePtr cur, SlideShowConstructor::ImageData& value) const bool ReaderWriterP3DXML::getProperties(xmlNodePtr cur, osgPresentation::SlideShowConstructor::ImageData& value) const
{ {
bool propertiesRead=false; bool propertiesRead=false;
@ -839,13 +839,13 @@ bool ReaderWriterP3DXML::getJumpProperties(xmlNodePtr cur, bool& relativeJump, i
return propertyRead; return propertyRead;
} }
void ReaderWriterP3DXML::parseModel(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const void ReaderWriterP3DXML::parseModel(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const
{ {
SlideShowConstructor::PositionData positionData = constructor.getModelPositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getModelPositionData();
bool positionRead = getProperties(cur,positionData); bool positionRead = getProperties(cur,positionData);
SlideShowConstructor::ModelData modelData;// = constructor.getModelData(); osgPresentation::SlideShowConstructor::ModelData modelData;// = constructor.getModelData();
getProperties(cur,modelData); getProperties(cur,modelData);
std::string filename; std::string filename;
@ -862,10 +862,10 @@ void ReaderWriterP3DXML::parseModel(SlideShowConstructor& constructor, xmlDocPtr
} }
void ReaderWriterP3DXML::parseVolume(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const void ReaderWriterP3DXML::parseVolume(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const
{ {
SlideShowConstructor::PositionData positionData = constructor.getModelPositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getModelPositionData();
bool positionRead = getProperties(cur,positionData); bool positionRead = getProperties(cur,positionData);
std::string filename; std::string filename;
@ -880,16 +880,16 @@ void ReaderWriterP3DXML::parseVolume(SlideShowConstructor& constructor, xmlDocPt
} }
} }
void ReaderWriterP3DXML::parseStereoPair(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const void ReaderWriterP3DXML::parseStereoPair(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const
{ {
std::string filenameLeft; std::string filenameLeft;
std::string filenameRight; std::string filenameRight;
SlideShowConstructor::PositionData positionData = constructor.getImagePositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getImagePositionData();
bool positionRead = getProperties(cur,positionData); bool positionRead = getProperties(cur,positionData);
SlideShowConstructor::ImageData imageDataLeft;// = constructor.getImageData(); osgPresentation::SlideShowConstructor::ImageData imageDataLeft;// = constructor.getImageData();
SlideShowConstructor::ImageData imageDataRight;// = constructor.getImageData(); osgPresentation::SlideShowConstructor::ImageData imageDataRight;// = constructor.getImageData();
xmlChar *key; xmlChar *key;
cur = cur->xmlChildrenNode; cur = cur->xmlChildrenNode;
@ -925,7 +925,7 @@ void ReaderWriterP3DXML::parseStereoPair(SlideShowConstructor& constructor, xmlD
} }
bool ReaderWriterP3DXML::getKeyPosition(xmlDocPtr doc, xmlNodePtr cur, SlideShowConstructor::KeyPosition& keyPosition) const bool ReaderWriterP3DXML::getKeyPosition(xmlDocPtr doc, xmlNodePtr cur, osgPresentation::KeyPosition& keyPosition) const
{ {
if ((!xmlStrcmp(cur->name, (const xmlChar *)"key"))) if ((!xmlStrcmp(cur->name, (const xmlChar *)"key")))
{ {
@ -941,7 +941,7 @@ bool ReaderWriterP3DXML::getKeyPosition(xmlDocPtr doc, xmlNodePtr cur, SlideShow
return false; return false;
} }
bool ReaderWriterP3DXML::getKeyPositionInner(xmlDocPtr doc, xmlNodePtr cur, SlideShowConstructor::KeyPosition& keyPosition) const bool ReaderWriterP3DXML::getKeyPositionInner(xmlDocPtr doc, xmlNodePtr cur, osgPresentation::KeyPosition& keyPosition) const
{ {
// x in range -1 to 1, from left to right // x in range -1 to 1, from left to right
float x = FLT_MAX; float x = FLT_MAX;
@ -995,10 +995,10 @@ bool ReaderWriterP3DXML::getKeyPositionInner(xmlDocPtr doc, xmlNodePtr cur, Slid
void ReaderWriterP3DXML::parseLayer(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const void ReaderWriterP3DXML::parseLayer(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const
{ {
// create a keyPosition just in case we need it. // create a keyPosition just in case we need it.
SlideShowConstructor::KeyPosition keyPosition; osgPresentation::KeyPosition keyPosition;
osg::notify(osg::INFO)<<std::endl<<"parseLayer"<<std::endl; osg::notify(osg::INFO)<<std::endl<<"parseLayer"<<std::endl;
@ -1043,7 +1043,7 @@ void ReaderWriterP3DXML::parseLayer(SlideShowConstructor& constructor, xmlDocPtr
if (key) if (key)
{ {
osg::notify(osg::INFO)<<"click_to_run ["<<(const char*)key<<"]"<<std::endl; osg::notify(osg::INFO)<<"click_to_run ["<<(const char*)key<<"]"<<std::endl;
constructor.layerClickToDoOperation((const char*)key,SlideShowConstructor::RUN, relativeJump, slideNum, layerNum); constructor.layerClickToDoOperation((const char*)key,osgPresentation::RUN, relativeJump, slideNum, layerNum);
} }
xmlFree(key); xmlFree(key);
} }
@ -1058,7 +1058,7 @@ void ReaderWriterP3DXML::parseLayer(SlideShowConstructor& constructor, xmlDocPtr
if (key) if (key)
{ {
osg::notify(osg::INFO)<<"click_to_load ["<<(const char*)key<<"]"<<std::endl; osg::notify(osg::INFO)<<"click_to_load ["<<(const char*)key<<"]"<<std::endl;
constructor.layerClickToDoOperation((const char*)key,SlideShowConstructor::LOAD, relativeJump, slideNum, layerNum); constructor.layerClickToDoOperation((const char*)key,osgPresentation::LOAD, relativeJump, slideNum, layerNum);
} }
xmlFree(key); xmlFree(key);
} }
@ -1084,7 +1084,7 @@ void ReaderWriterP3DXML::parseLayer(SlideShowConstructor& constructor, xmlDocPtr
int layerNum = 0; int layerNum = 0;
getJumpProperties(cur, relativeJump, slideNum, layerNum); getJumpProperties(cur, relativeJump, slideNum, layerNum);
constructor.layerClickEventOperation(SlideShowConstructor::JUMP, relativeJump, slideNum, layerNum); constructor.layerClickEventOperation(osgPresentation::JUMP, relativeJump, slideNum, layerNum);
} }
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"newline"))) else if ((!xmlStrcmp(cur->name, (const xmlChar *)"newline")))
@ -1109,10 +1109,10 @@ void ReaderWriterP3DXML::parseLayer(SlideShowConstructor& constructor, xmlDocPtr
if (key) if (key)
{ {
osg::notify(osg::INFO)<<"bullet ["<<(const char*)key<<"]"<<std::endl; osg::notify(osg::INFO)<<"bullet ["<<(const char*)key<<"]"<<std::endl;
SlideShowConstructor::PositionData positionData = constructor.getTextPositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getTextPositionData();
bool positionRead = getProperties(cur,positionData); bool positionRead = getProperties(cur,positionData);
SlideShowConstructor::FontData fontData = constructor.getTextFontData(); osgPresentation::SlideShowConstructor::FontData fontData = constructor.getTextFontData();
bool fontRead = getProperties(cur,fontData); bool fontRead = getProperties(cur,fontData);
constructor.addBullet((const char*)key, constructor.addBullet((const char*)key,
@ -1126,10 +1126,10 @@ void ReaderWriterP3DXML::parseLayer(SlideShowConstructor& constructor, xmlDocPtr
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if (key) if (key)
{ {
SlideShowConstructor::PositionData positionData = constructor.getTextPositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getTextPositionData();
bool positionRead = getProperties(cur,positionData); bool positionRead = getProperties(cur,positionData);
SlideShowConstructor::FontData fontData = constructor.getTextFontData(); osgPresentation::SlideShowConstructor::FontData fontData = constructor.getTextFontData();
bool fontRead = getProperties(cur,fontData); bool fontRead = getProperties(cur,fontData);
constructor.addParagraph((const char*)key, constructor.addParagraph((const char*)key,
@ -1144,10 +1144,10 @@ void ReaderWriterP3DXML::parseLayer(SlideShowConstructor& constructor, xmlDocPtr
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if (key) if (key)
{ {
SlideShowConstructor::PositionData positionData = constructor.getImagePositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getImagePositionData();
bool positionRead = getProperties(cur,positionData); bool positionRead = getProperties(cur,positionData);
SlideShowConstructor::ImageData imageData;// = constructor.getImageData(); osgPresentation::SlideShowConstructor::ImageData imageData;// = constructor.getImageData();
getProperties(cur,imageData); getProperties(cur,imageData);
constructor.addImage((const char*)key, constructor.addImage((const char*)key,
@ -1161,10 +1161,10 @@ void ReaderWriterP3DXML::parseLayer(SlideShowConstructor& constructor, xmlDocPtr
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if (key) if (key)
{ {
SlideShowConstructor::PositionData positionData = constructor.getImagePositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getImagePositionData();
bool positionRead = getProperties(cur,positionData); bool positionRead = getProperties(cur,positionData);
SlideShowConstructor::ImageData imageData;// = constructor.getImageData(); osgPresentation::SlideShowConstructor::ImageData imageData;// = constructor.getImageData();
getProperties(cur,imageData); getProperties(cur,imageData);
constructor.addVNC((const char*)key, constructor.addVNC((const char*)key,
@ -1178,10 +1178,10 @@ void ReaderWriterP3DXML::parseLayer(SlideShowConstructor& constructor, xmlDocPtr
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if (key) if (key)
{ {
SlideShowConstructor::PositionData positionData = constructor.getImagePositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getImagePositionData();
bool positionRead = getProperties(cur,positionData); bool positionRead = getProperties(cur,positionData);
SlideShowConstructor::ImageData imageData;// = constructor.getImageData(); osgPresentation::SlideShowConstructor::ImageData imageData;// = constructor.getImageData();
getProperties(cur,imageData); getProperties(cur,imageData);
constructor.addBrowser((const char*)key, constructor.addBrowser((const char*)key,
@ -1195,10 +1195,10 @@ void ReaderWriterP3DXML::parseLayer(SlideShowConstructor& constructor, xmlDocPtr
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if (key) if (key)
{ {
SlideShowConstructor::PositionData positionData = constructor.getImagePositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getImagePositionData();
bool positionRead = getProperties(cur,positionData); bool positionRead = getProperties(cur,positionData);
SlideShowConstructor::ImageData imageData;// = constructor.getImageData(); osgPresentation::SlideShowConstructor::ImageData imageData;// = constructor.getImageData();
getProperties(cur,imageData); getProperties(cur,imageData);
constructor.addPDF((const char*)key, constructor.addPDF((const char*)key,
@ -1238,7 +1238,7 @@ void ReaderWriterP3DXML::parseLayer(SlideShowConstructor& constructor, xmlDocPtr
} }
void ReaderWriterP3DXML::parseBullets(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur, bool inheritPreviousLayers, bool defineAsBaseLayer) const void ReaderWriterP3DXML::parseBullets(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur, bool inheritPreviousLayers, bool defineAsBaseLayer) const
{ {
xmlChar *key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); xmlChar *key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if (key) if (key)
@ -1246,10 +1246,10 @@ void ReaderWriterP3DXML::parseBullets(SlideShowConstructor& constructor, xmlDocP
constructor.addLayer(inheritPreviousLayers, defineAsBaseLayer); constructor.addLayer(inheritPreviousLayers, defineAsBaseLayer);
osg::notify(osg::INFO)<<"bullets ["<<(const char*)key<<"]"<<std::endl; osg::notify(osg::INFO)<<"bullets ["<<(const char*)key<<"]"<<std::endl;
SlideShowConstructor::PositionData positionData = constructor.getTextPositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getTextPositionData();
bool positionRead = getProperties(cur,positionData); bool positionRead = getProperties(cur,positionData);
SlideShowConstructor::FontData fontData = constructor.getTextFontData(); osgPresentation::SlideShowConstructor::FontData fontData = constructor.getTextFontData();
bool fontRead = getProperties(cur,fontData); bool fontRead = getProperties(cur,fontData);
constructor.addBullet((const char*)key, constructor.addBullet((const char*)key,
@ -1260,7 +1260,7 @@ void ReaderWriterP3DXML::parseBullets(SlideShowConstructor& constructor, xmlDocP
} }
void ReaderWriterP3DXML::parseText(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur, bool inheritPreviousLayers, bool defineAsBaseLayer) const void ReaderWriterP3DXML::parseText(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur, bool inheritPreviousLayers, bool defineAsBaseLayer) const
{ {
xmlChar *key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); xmlChar *key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if (key) if (key)
@ -1268,10 +1268,10 @@ void ReaderWriterP3DXML::parseText(SlideShowConstructor& constructor, xmlDocPtr
constructor.addLayer(inheritPreviousLayers, defineAsBaseLayer); constructor.addLayer(inheritPreviousLayers, defineAsBaseLayer);
osg::notify(osg::INFO)<<"text ["<<(const char*)key<<"]"<<std::endl; osg::notify(osg::INFO)<<"text ["<<(const char*)key<<"]"<<std::endl;
SlideShowConstructor::PositionData positionData = constructor.getTextPositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getTextPositionData();
bool positionRead = getProperties(cur,positionData); bool positionRead = getProperties(cur,positionData);
SlideShowConstructor::FontData fontData = constructor.getTextFontData(); osgPresentation::SlideShowConstructor::FontData fontData = constructor.getTextFontData();
bool fontRead = getProperties(cur,fontData); bool fontRead = getProperties(cur,fontData);
constructor.addParagraph((const char*)key, constructor.addParagraph((const char*)key,
@ -1281,7 +1281,7 @@ void ReaderWriterP3DXML::parseText(SlideShowConstructor& constructor, xmlDocPtr
xmlFree(key); xmlFree(key);
} }
void ReaderWriterP3DXML::parsePage(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const void ReaderWriterP3DXML::parsePage(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const
{ {
xmlChar *key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); xmlChar *key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if (key) if (key)
@ -1313,10 +1313,10 @@ void ReaderWriterP3DXML::parsePage(SlideShowConstructor& constructor, xmlDocPtr
constructor.addLayer(true,false); constructor.addLayer(true,false);
SlideShowConstructor::PositionData positionData = constructor.getTextPositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getTextPositionData();
bool positionRead = getProperties(cur,positionData); bool positionRead = getProperties(cur,positionData);
SlideShowConstructor::FontData fontData = constructor.getTextFontData(); osgPresentation::SlideShowConstructor::FontData fontData = constructor.getTextFontData();
bool fontRead = getProperties(cur,fontData); bool fontRead = getProperties(cur,fontData);
constructor.addParagraph((const char*)key, constructor.addParagraph((const char*)key,
@ -1326,7 +1326,7 @@ void ReaderWriterP3DXML::parsePage(SlideShowConstructor& constructor, xmlDocPtr
xmlFree(key); xmlFree(key);
} }
void ReaderWriterP3DXML::parsePdfDocument(SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const void ReaderWriterP3DXML::parsePdfDocument(osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur) const
{ {
xmlChar *key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); xmlChar *key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if (key) if (key)
@ -1359,10 +1359,10 @@ void ReaderWriterP3DXML::parsePdfDocument(SlideShowConstructor& constructor, xml
constructor.addLayer(true,false); constructor.addLayer(true,false);
SlideShowConstructor::PositionData positionData = constructor.getImagePositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getImagePositionData();
bool positionRead = getProperties(cur,positionData); getProperties(cur,positionData);
SlideShowConstructor::ImageData imageData;// = constructor.getImageData(); osgPresentation::SlideShowConstructor::ImageData imageData;// = constructor.getImageData();
imageData.page = 0; imageData.page = 0;
getProperties(cur,imageData); getProperties(cur,imageData);
@ -1410,14 +1410,14 @@ void ReaderWriterP3DXML::parsePdfDocument(SlideShowConstructor& constructor, xml
xmlFree(key); xmlFree(key);
} }
void ReaderWriterP3DXML::parseSlide (SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur, bool parseTitles, bool parseLayers) const void ReaderWriterP3DXML::parseSlide (osgPresentation::SlideShowConstructor& constructor, xmlDocPtr doc, xmlNodePtr cur, bool parseTitles, bool parseLayers) const
{ {
osg::Vec4 previous_bgcolor = constructor.getBackgroundColor(); osg::Vec4 previous_bgcolor = constructor.getBackgroundColor();
osg::Vec4 previous_textcolor = constructor.getTextColor(); osg::Vec4 previous_textcolor = constructor.getTextColor();
// create a keyPosition just in case we need it. // create a keyPosition just in case we need it.
SlideShowConstructor::KeyPosition keyPosition; osgPresentation::KeyPosition keyPosition;
xmlChar *key; xmlChar *key;
cur = cur->xmlChildrenNode; cur = cur->xmlChildrenNode;
@ -1431,10 +1431,10 @@ void ReaderWriterP3DXML::parseSlide (SlideShowConstructor& constructor, xmlDocPt
if (key) if (key)
{ {
SlideShowConstructor::PositionData positionData = constructor.getTitlePositionData(); osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getTitlePositionData();
bool positionRead = getProperties(cur,positionData); bool positionRead = getProperties(cur,positionData);
SlideShowConstructor::FontData fontData = constructor.getTitleFontData(); osgPresentation::SlideShowConstructor::FontData fontData = constructor.getTitleFontData();
bool fontRead = getProperties(cur,fontData); bool fontRead = getProperties(cur,fontData);
constructor.setSlideTitle((const char*)key, constructor.setSlideTitle((const char*)key,
@ -1533,7 +1533,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterP3DXML::readNode(const std::string&
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
// create a keyPosition just in case we need it. // create a keyPosition just in case we need it.
SlideShowConstructor::KeyPosition keyPosition; osgPresentation::KeyPosition keyPosition;
xmlDocPtr doc; xmlDocPtr doc;
xmlNodePtr cur; xmlNodePtr cur;
@ -1559,7 +1559,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterP3DXML::readNode(const std::string&
return ReadResult::FILE_NOT_HANDLED; return ReadResult::FILE_NOT_HANDLED;
} }
SlideShowConstructor constructor; osgPresentation::SlideShowConstructor constructor;
osgDB::FilePathList previousPaths = osgDB::getDataFilePathList(); osgDB::FilePathList previousPaths = osgDB::getDataFilePathList();

View File

@ -29,11 +29,35 @@
#include <iostream> #include <iostream>
using namespace osgPresentation;
static osg::observer_ptr<SlideEventHandler> s_seh; static osg::observer_ptr<SlideEventHandler> s_seh;
SlideEventHandler* SlideEventHandler::instance() { return s_seh.get(); } SlideEventHandler* SlideEventHandler::instance() { return s_seh.get(); }
void LayerAttributes::callEnterCallbacks(osg::Node* node)
{
osg::notify(osg::INFO)<<"LayerAttributes::callEnterCallbacks("<<node<<")"<<std::endl;
for(LayerCallbacks::iterator itr = _enterLayerCallbacks.begin();
itr != _enterLayerCallbacks.end();
++itr)
{
(*(*itr))(node);
}
}
void LayerAttributes::callLeaveCallbacks(osg::Node* node)
{
osg::notify(osg::INFO)<<"LayerAttributes::callLeaveCallbacks("<<node<<")"<<std::endl;
for(LayerCallbacks::iterator itr = _leaveLayerCallbacks.begin();
itr != _leaveLayerCallbacks.end();
++itr)
{
(*(*itr))(node);
}
}
struct ImageStreamOperator : public ObjectOperator struct ImageStreamOperator : public ObjectOperator
{ {
ImageStreamOperator(osg::ImageStream* imageStream): ImageStreamOperator(osg::ImageStream* imageStream):
@ -159,7 +183,7 @@ struct CallbackOperator : public ObjectOperator
struct LayerAttributesOperator : public ObjectOperator struct LayerAttributesOperator : public ObjectOperator
{ {
LayerAttributesOperator(osg::Node* node, SlideShowConstructor::LayerAttributes* la): LayerAttributesOperator(osg::Node* node, LayerAttributes* la):
_node(node), _node(node),
_layerAttribute(la) _layerAttribute(la)
{ {
@ -175,7 +199,7 @@ struct LayerAttributesOperator : public ObjectOperator
{ {
osg::notify(osg::INFO)<<"applyKeys {"<<std::endl; osg::notify(osg::INFO)<<"applyKeys {"<<std::endl;
for(SlideShowConstructor::LayerAttributes::Keys::iterator itr = _layerAttribute->_keys.begin(); for(LayerAttributes::Keys::iterator itr = _layerAttribute->_keys.begin();
itr != _layerAttribute->_keys.end(); itr != _layerAttribute->_keys.end();
++itr) ++itr)
{ {
@ -186,7 +210,7 @@ struct LayerAttributesOperator : public ObjectOperator
} }
if (!_layerAttribute->_runStrings.empty()) if (!_layerAttribute->_runStrings.empty())
{ {
for(SlideShowConstructor::LayerAttributes::RunStrings::iterator itr = _layerAttribute->_runStrings.begin(); for(LayerAttributes::RunStrings::iterator itr = _layerAttribute->_runStrings.begin();
itr != _layerAttribute->_runStrings.end(); itr != _layerAttribute->_runStrings.end();
++itr) ++itr)
{ {
@ -232,7 +256,7 @@ struct LayerAttributesOperator : public ObjectOperator
osg::ref_ptr<osg::Node> _node; osg::ref_ptr<osg::Node> _node;
osg::ref_ptr<SlideShowConstructor::LayerAttributes> _layerAttribute; osg::ref_ptr<LayerAttributes> _layerAttribute;
}; };
@ -252,7 +276,7 @@ public:
_operatorList.insert(new CallbackOperator(&node, node.getUpdateCallback())); _operatorList.insert(new CallbackOperator(&node, node.getUpdateCallback()));
} }
SlideShowConstructor::LayerAttributes* la = dynamic_cast<SlideShowConstructor::LayerAttributes*>(node.getUserData()); LayerAttributes* la = dynamic_cast<LayerAttributes*>(node.getUserData());
if (la) if (la)
{ {
_operatorList.insert(new LayerAttributesOperator(&node, la)); _operatorList.insert(new LayerAttributesOperator(&node, la));
@ -409,7 +433,7 @@ public:
void apply(osg::Node& node) void apply(osg::Node& node)
{ {
SlideShowConstructor::HomePosition* homePosition = dynamic_cast<SlideShowConstructor::HomePosition*>(node.getUserData()); HomePosition* homePosition = dynamic_cast<HomePosition*>(node.getUserData());
if (homePosition) if (homePosition)
{ {
_homePosition = homePosition; _homePosition = homePosition;
@ -418,7 +442,7 @@ public:
traverse(node); traverse(node);
} }
osg::ref_ptr<SlideShowConstructor::HomePosition> _homePosition; osg::ref_ptr<HomePosition> _homePosition;
}; };
@ -457,7 +481,7 @@ public:
void apply(osg::Node& node) void apply(osg::Node& node)
{ {
SlideShowConstructor::FilePathData* fdd = dynamic_cast<SlideShowConstructor::FilePathData*>(node.getUserData()); FilePathData* fdd = dynamic_cast<FilePathData*>(node.getUserData());
if (fdd) if (fdd)
{ {
osg::notify(osg::INFO)<<"Recorded FilePathData"<<std::endl; osg::notify(osg::INFO)<<"Recorded FilePathData"<<std::endl;
@ -645,7 +669,7 @@ SlideEventHandler::SlideEventHandler(osgViewer::Viewer* viewer):
double SlideEventHandler::getDuration(const osg::Node* node) const double SlideEventHandler::getDuration(const osg::Node* node) const
{ {
const SlideShowConstructor::LayerAttributes* la = dynamic_cast<const SlideShowConstructor::LayerAttributes*>(node->getUserData()); const LayerAttributes* la = dynamic_cast<const LayerAttributes*>(node->getUserData());
return la ? la->_duration : -1.0; return la ? la->_duration : -1.0;
} }
@ -1091,7 +1115,7 @@ bool SlideEventHandler::previousLayerOrSlide()
bool SlideEventHandler::nextSlide() bool SlideEventHandler::nextSlide()
{ {
SlideShowConstructor::LayerAttributes* la = _slideSwitch.valid() ? dynamic_cast<SlideShowConstructor::LayerAttributes*>(_slideSwitch->getUserData()) : 0; LayerAttributes* la = _slideSwitch.valid() ? dynamic_cast<LayerAttributes*>(_slideSwitch->getUserData()) : 0;
if (la && la->requiresJump()) if (la && la->requiresJump())
{ {
if (la->getRelativeJump()) if (la->getRelativeJump())
@ -1135,7 +1159,7 @@ bool SlideEventHandler::previousSlide()
bool SlideEventHandler::nextLayer() bool SlideEventHandler::nextLayer()
{ {
SlideShowConstructor::LayerAttributes* la = (_slideSwitch.valid() && _activeLayer>=0) ? dynamic_cast<SlideShowConstructor::LayerAttributes*>(_slideSwitch->getChild(_activeLayer)->getUserData()) : 0; LayerAttributes* la = (_slideSwitch.valid() && _activeLayer>=0) ? dynamic_cast<LayerAttributes*>(_slideSwitch->getChild(_activeLayer)->getUserData()) : 0;
if (la) if (la)
{ {
la->callLeaveCallbacks(_slideSwitch->getChild(_activeLayer)); la->callLeaveCallbacks(_slideSwitch->getChild(_activeLayer));
@ -1265,7 +1289,7 @@ void SlideEventHandler::releaseSlide(unsigned int slideNum)
_presentationSwitch->getChild(slideNum)->accept(globjVisitor); _presentationSwitch->getChild(slideNum)->accept(globjVisitor);
} }
void SlideEventHandler::dispatchEvent(const SlideShowConstructor::KeyPosition& keyPosition) void SlideEventHandler::dispatchEvent(const KeyPosition& keyPosition)
{ {
osg::notify(osg::INFO)<<" keyPosition._key "<<keyPosition._key<<" "<<keyPosition._x<<" "<<keyPosition._y<<std::endl; osg::notify(osg::INFO)<<" keyPosition._key "<<keyPosition._key<<" "<<keyPosition._x<<" "<<keyPosition._y<<std::endl;

View File

@ -20,7 +20,117 @@
#include <osgViewer/Viewer> #include <osgViewer/Viewer>
#include "CompileSlideCallback.h" #include "CompileSlideCallback.h"
#include "SlideShowConstructor.h"
namespace osgPresentation
{
/// Operations related to click to run/load/key events.
enum Operation
{
RUN,
LOAD,
EVENT,
JUMP
};
struct HomePosition : public virtual osg::Referenced
{
HomePosition() {}
HomePosition(const osg::Vec3& in_eye, const osg::Vec3& in_center, const osg::Vec3& in_up):
eye(in_eye),
center(in_center),
up(in_up) {}
osg::Vec3 eye;
osg::Vec3 center;
osg::Vec3 up;
};
struct KeyPosition
{
KeyPosition(unsigned int key=0, float x=FLT_MAX, float y=FLT_MAX):
_key((osgGA::GUIEventAdapter::KeySymbol)key),
_x(x),
_y(y) {}
void set(unsigned int key=0, float x=FLT_MAX, float y=FLT_MAX)
{
_key = (osgGA::GUIEventAdapter::KeySymbol)key;
_x = x;
_y = y;
}
osgGA::GUIEventAdapter::KeySymbol _key;
float _x;
float _y;
};
struct LayerCallback : public virtual osg::Referenced
{
virtual void operator() (osg::Node* node) const = 0;
};
struct LayerAttributes : public virtual osg::Referenced
{
LayerAttributes():_duration(0),_relativeJump(true),_slideNum(0),_layerNum(0) {}
LayerAttributes(double in_duration):_duration(in_duration),_relativeJump(true),_slideNum(0),_layerNum(0) {}
void setDuration(double duration) { _duration = duration; }
double getDuration() const { return _duration; }
typedef std::vector<KeyPosition> Keys;
typedef std::vector<std::string> RunStrings;
void setKeys(const Keys& keys) { _keys = keys; }
const Keys& getKeys() const { return _keys; }
void addKey(const KeyPosition& kp) { _keys.push_back(kp); }
void setRunStrings(const RunStrings& runStrings) { _runStrings = runStrings; }
const RunStrings& getRunStrings() const { return _runStrings; }
void addRunString(const std::string& runString) { _runStrings.push_back(runString); }
void setJump(bool relativeJump, int slideNum, int layerNum)
{
_relativeJump = relativeJump;
_slideNum = slideNum;
_layerNum = layerNum;
}
bool getRelativeJump() const { return _relativeJump; }
int getSlideNum() const { return _slideNum; }
int getLayerNum() const { return _layerNum; }
bool requiresJump() const { return _relativeJump ? (_slideNum!=0 || _layerNum!=0) : true; }
double _duration;
Keys _keys;
RunStrings _runStrings;
bool _relativeJump;
int _slideNum;
int _layerNum;
void addEnterCallback(LayerCallback* lc) { _enterLayerCallbacks.push_back(lc); }
void addLeaveCallback(LayerCallback* lc) { _leaveLayerCallbacks.push_back(lc); }
void callEnterCallbacks(osg::Node* node);
void callLeaveCallbacks(osg::Node* node);
typedef std::list< osg::ref_ptr<LayerCallback> > LayerCallbacks;
LayerCallbacks _enterLayerCallbacks;
LayerCallbacks _leaveLayerCallbacks;
};
struct FilePathData : public virtual osg::Referenced
{
FilePathData(const osgDB::FilePathList& fpl):filePathList(fpl) {}
osgDB::FilePathList filePathList;
};
struct dereference_less struct dereference_less
@ -104,7 +214,7 @@ public:
enum WhichPosition enum WhichPosition
{ {
FIRST_POSITION = 0, FIRST_POSITION = 0,
LAST_POSITION = 0xffffffff, LAST_POSITION = 0xffffffff
}; };
void compileSlide(unsigned int slideNum); void compileSlide(unsigned int slideNum);
@ -148,7 +258,7 @@ public:
void setLoopPresentation(bool loop) { _loopPresentation = loop; } void setLoopPresentation(bool loop) { _loopPresentation = loop; }
bool getLoopPresentation() const { return _loopPresentation; } bool getLoopPresentation() const { return _loopPresentation; }
void dispatchEvent(const SlideShowConstructor::KeyPosition& keyPosition); void dispatchEvent(const KeyPosition& keyPosition);
enum ObjectMask enum ObjectMask
{ {
@ -212,4 +322,6 @@ protected:
}; };
}
#endif #endif

View File

@ -50,6 +50,8 @@
#include "AnimationMaterial.h" #include "AnimationMaterial.h"
#include "PickEventHandler.h" #include "PickEventHandler.h"
using namespace osgPresentation;
class SetToTransparentBin : public osg::NodeVisitor class SetToTransparentBin : public osg::NodeVisitor
{ {
public: public:
@ -84,28 +86,6 @@ public:
} }
}; };
void SlideShowConstructor::LayerAttributes::callEnterCallbacks(osg::Node* node)
{
osg::notify(osg::INFO)<<"SlideShowConstructor::LayerAttributes::callEnterCallbacks("<<node<<")"<<std::endl;
for(LayerCallbacks::iterator itr = _enterLayerCallbacks.begin();
itr != _enterLayerCallbacks.end();
++itr)
{
(*(*itr))(node);
}
}
void SlideShowConstructor::LayerAttributes::callLeaveCallbacks(osg::Node* node)
{
osg::notify(osg::INFO)<<"SlideShowConstructor::LayerAttributes::callLeaveCallbacks("<<node<<")"<<std::endl;
for(LayerCallbacks::iterator itr = _leaveLayerCallbacks.begin();
itr != _leaveLayerCallbacks.end();
++itr)
{
(*(*itr))(node);
}
}
SlideShowConstructor::SlideShowConstructor() SlideShowConstructor::SlideShowConstructor()
{ {
_slideDistance = osg::DisplaySettings::instance()->getScreenDistance(); _slideDistance = osg::DisplaySettings::instance()->getScreenDistance();
@ -208,7 +188,7 @@ void SlideShowConstructor::createPresentation()
if (_autoSteppingActive) _root->addDescription("auto"); if (_autoSteppingActive) _root->addDescription("auto");
} }
SlideShowConstructor::LayerAttributes* SlideShowConstructor::getOrCreateLayerAttributes(osg::Node* node) LayerAttributes* SlideShowConstructor::getOrCreateLayerAttributes(osg::Node* node)
{ {
LayerAttributes* la = dynamic_cast<LayerAttributes*>(node->getUserData()); LayerAttributes* la = dynamic_cast<LayerAttributes*>(node->getUserData());
if (!la) if (!la)
@ -294,7 +274,7 @@ void SlideShowConstructor::selectSlide(int slideNum)
{ {
addSlide(); addSlide();
} }
else if (slideNum>=_presentationSwitch->getNumChildren()) else if (slideNum>=static_cast<int>(_presentationSwitch->getNumChildren()))
{ {
addSlide(); addSlide();
} }
@ -435,7 +415,7 @@ void SlideShowConstructor::selectLayer(int layerNum)
addSlide(); addSlide();
addLayer(); addLayer();
} }
else if (layerNum>=0 && layerNum<_slide->getNumChildren() && _slide->getChild(layerNum)->asGroup()) else if (layerNum>=0 && layerNum<static_cast<int>(_slide->getNumChildren()) && _slide->getChild(layerNum)->asGroup())
{ {
_currentLayer = _slide->getChild(layerNum)->asGroup(); _currentLayer = _slide->getChild(layerNum)->asGroup();
_previousLayer = _currentLayer; _previousLayer = _currentLayer;
@ -516,7 +496,7 @@ void SlideShowConstructor::layerClickToDoOperation(const std::string& command, O
} }
void SlideShowConstructor::layerClickEventOperation(const SlideShowConstructor::KeyPosition& keyPos, bool relativeJump, int slideNum, int layerNum) void SlideShowConstructor::layerClickEventOperation(const KeyPosition& keyPos, bool relativeJump, int slideNum, int layerNum)
{ {
if (!_currentLayer) addLayer(); if (!_currentLayer) addLayer();
@ -1075,7 +1055,7 @@ void SlideShowConstructor::addPDF(const std::string& filename, const PositionDat
addInteractiveImage(filename, positionData, imageData); addInteractiveImage(filename, positionData, imageData);
} }
class SetPageCallback: public SlideShowConstructor::LayerCallback class SetPageCallback: public LayerCallback
{ {
public: public:
SetPageCallback(osgWidget::PdfImage* pdfImage, int pageNum): SetPageCallback(osgWidget::PdfImage* pdfImage, int pageNum):
@ -1444,7 +1424,7 @@ void SlideShowConstructor::addModel(osg::Node* subgraph, const PositionData& pos
void SlideShowConstructor::addVolume(const std::string& filename, const PositionData& positionData) void SlideShowConstructor::addVolume(const std::string& filename, const PositionData& positionData)
{ {
osg::Object::DataVariance defaultMatrixDataVariance = osg::Object::DYNAMIC; // STATIC // osg::Object::DataVariance defaultMatrixDataVariance = osg::Object::DYNAMIC; // STATIC
std::string foundFile = filename; std::string foundFile = filename;

View File

@ -26,6 +26,10 @@
#include <osgDB/FileUtils> #include <osgDB/FileUtils>
#include "AnimationMaterial.h" #include "AnimationMaterial.h"
#include "SlideEventHandler.h"
namespace osgPresentation
{
class SlideShowConstructor class SlideShowConstructor
{ {
@ -34,98 +38,6 @@ public:
enum CoordinateFrame { SLIDE, MODEL }; enum CoordinateFrame { SLIDE, MODEL };
struct HomePosition : public virtual osg::Referenced
{
HomePosition() {}
HomePosition(const osg::Vec3& in_eye, const osg::Vec3& in_center, const osg::Vec3& in_up):
eye(in_eye),
center(in_center),
up(in_up) {}
osg::Vec3 eye;
osg::Vec3 center;
osg::Vec3 up;
};
struct KeyPosition
{
KeyPosition(unsigned int key=0, float x=FLT_MAX, float y=FLT_MAX):
_key((osgGA::GUIEventAdapter::KeySymbol)key),
_x(x),
_y(y) {}
void set(unsigned int key=0, float x=FLT_MAX, float y=FLT_MAX)
{
_key = (osgGA::GUIEventAdapter::KeySymbol)key;
_x = x;
_y = y;
}
osgGA::GUIEventAdapter::KeySymbol _key;
float _x;
float _y;
};
struct LayerCallback : public virtual osg::Referenced
{
virtual void operator() (osg::Node* node) const = 0;
};
struct LayerAttributes : public virtual osg::Referenced
{
LayerAttributes():_duration(0),_relativeJump(true),_slideNum(0),_layerNum(0) {}
LayerAttributes(double in_duration):_duration(in_duration),_relativeJump(true),_slideNum(0),_layerNum(0) {}
void setDuration(double duration) { _duration = duration; }
double getDuration() const { return _duration; }
typedef std::vector<KeyPosition> Keys;
typedef std::vector<std::string> RunStrings;
void setKeys(const Keys& keys) { _keys = keys; }
const Keys& getKeys() const { return _keys; }
void addKey(const KeyPosition& kp) { _keys.push_back(kp); }
void setRunStrings(const RunStrings& runStrings) { _runStrings = runStrings; }
const RunStrings& getRunStrings() const { return _runStrings; }
void addRunString(const std::string& runString) { _runStrings.push_back(runString); }
void setJump(bool relativeJump, int slideNum, int layerNum)
{
_relativeJump = relativeJump;
_slideNum = slideNum;
_layerNum = layerNum;
}
bool getRelativeJump() const { return _relativeJump; }
int getSlideNum() const { return _slideNum; }
int getLayerNum() const { return _layerNum; }
bool requiresJump() const { return _relativeJump ? (_slideNum!=0 || _layerNum!=0) : true; }
double _duration;
Keys _keys;
RunStrings _runStrings;
bool _relativeJump;
int _slideNum;
int _layerNum;
void addEnterCallback(LayerCallback* lc) { _enterLayerCallbacks.push_back(lc); }
void addLeaveCallback(LayerCallback* lc) { _leaveLayerCallbacks.push_back(lc); }
void callEnterCallbacks(osg::Node* node);
void callLeaveCallbacks(osg::Node* node);
typedef std::list< osg::ref_ptr<LayerCallback> > LayerCallbacks;
LayerCallbacks _enterLayerCallbacks;
LayerCallbacks _leaveLayerCallbacks;
};
LayerAttributes* getOrCreateLayerAttributes(osg::Node* node); LayerAttributes* getOrCreateLayerAttributes(osg::Node* node);
@ -198,12 +110,6 @@ public:
if (_currentLayer.valid()) setJump(_currentLayer.get(),relativeJump, switchNum, layerNum); if (_currentLayer.valid()) setJump(_currentLayer.get(),relativeJump, switchNum, layerNum);
} }
struct FilePathData : public virtual osg::Referenced
{
FilePathData(const osgDB::FilePathList& fpl):filePathList(fpl) {}
osgDB::FilePathList filePathList;
};
struct PositionData struct PositionData
@ -320,14 +226,6 @@ public:
osg::Vec4 color; osg::Vec4 color;
}; };
/// Operations related to click to run/load/key events.
enum Operation
{
RUN,
LOAD,
EVENT,
JUMP
};
SlideShowConstructor(); SlideShowConstructor();
@ -399,7 +297,7 @@ public:
void layerClickToDoOperation(Operation operation, bool relativeJump=true, int slideNum=0, int layerNum=0); void layerClickToDoOperation(Operation operation, bool relativeJump=true, int slideNum=0, int layerNum=0);
void layerClickToDoOperation(const std::string& command, Operation operation, bool relativeJump=true, int slideNum=0, int layerNum=0); void layerClickToDoOperation(const std::string& command, Operation operation, bool relativeJump=true, int slideNum=0, int layerNum=0);
void layerClickEventOperation(const SlideShowConstructor::KeyPosition& keyPos, bool relativeJump=true, int slideNum=0, int layerNum=0); void layerClickEventOperation(const KeyPosition& keyPos, bool relativeJump=true, int slideNum=0, int layerNum=0);
void addBullet(const std::string& bullet, PositionData& positionData, FontData& fontData); void addBullet(const std::string& bullet, PositionData& positionData, FontData& fontData);
@ -515,4 +413,6 @@ protected:
}; };
}
#endif #endif

View File

@ -59,7 +59,7 @@ static const char* s_version = "1.3";
void setViewer(osgViewer::Viewer& viewer, float width, float height, float distance) void setViewer(osgViewer::Viewer& viewer, float width, float height, float distance)
{ {
double vfov = osg::RadiansToDegrees(atan2(height/2.0f,distance)*2.0); double vfov = osg::RadiansToDegrees(atan2(height/2.0f,distance)*2.0);
double hfov = osg::RadiansToDegrees(atan2(width/2.0f,distance)*2.0); // double hfov = osg::RadiansToDegrees(atan2(width/2.0f,distance)*2.0);
viewer.getCamera()->setProjectionMatrixAsPerspective( vfov, width/height, 0.1, 1000.0); viewer.getCamera()->setProjectionMatrixAsPerspective( vfov, width/height, 0.1, 1000.0);
} }
@ -160,7 +160,7 @@ enum P3DApplicationType
{ {
VIEWER, VIEWER,
MASTER, MASTER,
SLAVE, SLAVE
}; };
@ -321,7 +321,7 @@ int main( int argc, char **argv )
while (arguments.read("--loop")) loopPresentation = true; while (arguments.read("--loop")) loopPresentation = true;
// register the slide event handler - which moves the presentation from slide to slide, layer to layer. // register the slide event handler - which moves the presentation from slide to slide, layer to layer.
SlideEventHandler* seh = new SlideEventHandler(&viewer); osgPresentation::SlideEventHandler* seh = new osgPresentation::SlideEventHandler(&viewer);
viewer.addEventHandler(seh); viewer.addEventHandler(seh);
seh->setAutoSteppingActive(autoSteppingActive); seh->setAutoSteppingActive(autoSteppingActive);