Added support for naming slides and layers with slide_name and layer_name properties respectively.
Added support for creating events based on key presses using a <key_to_run> and <key_to_jump> tags.
This commit is contained in:
@@ -27,9 +27,9 @@ class OSGPRESENTATION_EXPORT PickEventHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
PickEventHandler(osgPresentation::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 osgPresentation::KeyPosition& keyPos, bool relativeJump=true, int slideNum=0, int layerNum=0);
|
||||
PickEventHandler(osgPresentation::Operation operation, const JumpData& jumpData=JumpData());
|
||||
PickEventHandler(const std::string& str, osgPresentation::Operation operation, const JumpData& jumpData=JumpData());
|
||||
PickEventHandler(const osgPresentation::KeyPosition& keyPos, const JumpData& jumpData=JumpData());
|
||||
|
||||
void setOperation(osgPresentation::Operation operation) { _operation = operation; }
|
||||
osgPresentation::Operation getOperation() const { return _operation; }
|
||||
@@ -40,15 +40,9 @@ class OSGPRESENTATION_EXPORT PickEventHandler : public osgGA::GUIEventHandler
|
||||
void setKeyPosition(const osgPresentation::KeyPosition& keyPos) { _keyPos = keyPos; }
|
||||
const osgPresentation::KeyPosition& getKeyPosition() const { return _keyPos; }
|
||||
|
||||
void setRelativeJump(int slideDelta, int layerDelta);
|
||||
void setAbsoluteJump(int slideNum, int 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; }
|
||||
|
||||
void setJumpData(const JumpData& jumpData) { _jumpData = jumpData; }
|
||||
const JumpData& getJumpData() const { return _jumpData; }
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv);
|
||||
|
||||
virtual void accept(osgGA::GUIEventHandlerVisitor& v);
|
||||
@@ -61,9 +55,7 @@ class OSGPRESENTATION_EXPORT PickEventHandler : public osgGA::GUIEventHandler
|
||||
osgPresentation::KeyPosition _keyPos;
|
||||
osgPresentation::Operation _operation;
|
||||
|
||||
bool _relativeJump;
|
||||
int _slideNum;
|
||||
int _layerNum;
|
||||
JumpData _jumpData;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
namespace osgPresentation
|
||||
{
|
||||
|
||||
// forward declare
|
||||
class SlideEventHandler;
|
||||
|
||||
/// Operations related to click to run/load/key events.
|
||||
enum Operation
|
||||
{
|
||||
@@ -35,6 +38,60 @@ enum Operation
|
||||
JUMP
|
||||
};
|
||||
|
||||
struct JumpData
|
||||
{
|
||||
JumpData():
|
||||
relativeJump(false),
|
||||
slideNum(0),
|
||||
layerNum(0) {}
|
||||
|
||||
JumpData(bool in_relativeJump, int in_slideNum, int in_layerNum):
|
||||
relativeJump(in_relativeJump),
|
||||
slideNum(in_slideNum),
|
||||
layerNum(in_layerNum) {}
|
||||
|
||||
JumpData(const std::string& in_slideName, const std::string& in_layerName):
|
||||
relativeJump(false),
|
||||
slideNum(-1),
|
||||
layerNum(-1),
|
||||
slideName(in_slideName),
|
||||
layerName(in_layerName) {}
|
||||
|
||||
JumpData(const JumpData& rhs):
|
||||
relativeJump(rhs.relativeJump),
|
||||
slideNum(rhs.slideNum),
|
||||
layerNum(rhs.layerNum),
|
||||
slideName(rhs.slideName),
|
||||
layerName(rhs.layerName) {}
|
||||
|
||||
JumpData& operator = (const JumpData& rhs)
|
||||
{
|
||||
if (&rhs==this) return *this;
|
||||
relativeJump = rhs.relativeJump;
|
||||
slideNum = rhs.slideNum;
|
||||
layerNum = rhs.layerNum;
|
||||
slideName = rhs.slideName;
|
||||
layerName = rhs.layerName;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool requiresJump() const
|
||||
{
|
||||
if (!slideName.empty() || !layerName.empty()) return true;
|
||||
return relativeJump ? (slideNum!=0 || layerNum!=0) : true;
|
||||
}
|
||||
|
||||
bool jump(SlideEventHandler* seh) const;
|
||||
|
||||
bool relativeJump;
|
||||
int slideNum;
|
||||
int layerNum;
|
||||
|
||||
std::string slideName;
|
||||
std::string layerName;
|
||||
};
|
||||
|
||||
|
||||
struct HomePosition : public virtual osg::Referenced
|
||||
{
|
||||
HomePosition() {}
|
||||
@@ -76,8 +133,8 @@ struct LayerCallback : public virtual osg::Referenced
|
||||
|
||||
struct OSGPRESENTATION_EXPORT 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) {}
|
||||
LayerAttributes():_duration(0) {}
|
||||
LayerAttributes(double in_duration):_duration(in_duration) {}
|
||||
|
||||
void setDuration(double duration) { _duration = duration; }
|
||||
double getDuration() const { return _duration; }
|
||||
@@ -95,26 +152,13 @@ struct OSGPRESENTATION_EXPORT LayerAttributes : public virtual osg::Referenced
|
||||
|
||||
void addRunString(const std::string& runString) { _runStrings.push_back(runString); }
|
||||
|
||||
void setJump(bool relativeJump, int slideNum, int layerNum)
|
||||
{
|
||||
_relativeJump = relativeJump;
|
||||
_slideNum = slideNum;
|
||||
_layerNum = layerNum;
|
||||
}
|
||||
void setJump(const JumpData& jumpData) { _jumpData = jumpData; }
|
||||
const JumpData& getJumpData() const { return _jumpData; }
|
||||
|
||||
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;
|
||||
double _duration;
|
||||
Keys _keys;
|
||||
RunStrings _runStrings;
|
||||
JumpData _jumpData;
|
||||
|
||||
void addEnterCallback(LayerCallback* lc) { _enterLayerCallbacks.push_back(lc); }
|
||||
void addLeaveCallback(LayerCallback* lc) { _leaveLayerCallbacks.push_back(lc); }
|
||||
@@ -144,9 +188,6 @@ struct dereference_less
|
||||
}
|
||||
};
|
||||
|
||||
// forward declare
|
||||
class SlideEventHandler;
|
||||
|
||||
struct ObjectOperator : public osg::Referenced
|
||||
{
|
||||
inline bool operator < (const ObjectOperator& rhs) const { return ptr() < rhs.ptr(); }
|
||||
@@ -282,6 +323,8 @@ public:
|
||||
|
||||
osgViewer::Viewer* getViewer() { return _viewer.get(); }
|
||||
|
||||
osg::Switch* getPresentationSwitch() { return _presentationSwitch.get(); }
|
||||
|
||||
enum WhichPosition
|
||||
{
|
||||
FIRST_POSITION = 0,
|
||||
@@ -296,6 +339,9 @@ public:
|
||||
int getActiveSlide() const { return _activeSlide; }
|
||||
int getActiveLayer() const { return _activeLayer; }
|
||||
|
||||
osg::Switch* getSlide(int slideNum);
|
||||
osg::Node* getLayer(int slideNum, int layerNum);
|
||||
|
||||
bool selectSlide(int slideNum,int layerNum=FIRST_POSITION);
|
||||
bool selectLayer(int layerNum);
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ public:
|
||||
enum CoordinateFrame { SLIDE, MODEL };
|
||||
|
||||
|
||||
|
||||
LayerAttributes* getOrCreateLayerAttributes(osg::Node* node);
|
||||
|
||||
void setDuration(osg::Node* node,double duration)
|
||||
@@ -96,9 +97,9 @@ public:
|
||||
getOrCreateLayerAttributes(node)->addRunString(runString);
|
||||
}
|
||||
|
||||
void setJump(osg::Node* node, bool relativeJump, int slideNum, int layerNum)
|
||||
void setJump(osg::Node* node, const JumpData& jumpData)
|
||||
{
|
||||
getOrCreateLayerAttributes(node)->setJump(relativeJump, slideNum, layerNum);
|
||||
getOrCreateLayerAttributes(node)->setJump(jumpData);
|
||||
}
|
||||
|
||||
void addPresentationKey(const KeyPosition& kp)
|
||||
@@ -125,10 +126,10 @@ public:
|
||||
if (_slide.valid()) addRunString(_slide.get(),runString);
|
||||
}
|
||||
|
||||
void setSlideJump(bool relativeJump, int switchNum, int layerNum)
|
||||
void setSlideJump(const JumpData& jumpData)
|
||||
{
|
||||
if (!_slide) addSlide();
|
||||
if (_slide.valid()) setJump(_slide.get(),relativeJump, switchNum, layerNum);
|
||||
if (_slide.valid()) setJump(_slide.get(),jumpData);
|
||||
}
|
||||
|
||||
void addLayerKey(const KeyPosition& kp)
|
||||
@@ -144,10 +145,10 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void setLayerJump(bool relativeJump, int switchNum, int layerNum)
|
||||
void setLayerJump(const JumpData& jumpData)
|
||||
{
|
||||
if (!_currentLayer) addLayer();
|
||||
if (_currentLayer.valid()) setJump(_currentLayer.get(),relativeJump, switchNum, layerNum);
|
||||
if (_currentLayer.valid()) setJump(_currentLayer.get(),jumpData);
|
||||
}
|
||||
|
||||
|
||||
@@ -334,7 +335,6 @@ public:
|
||||
osg::Vec4 color;
|
||||
};
|
||||
|
||||
|
||||
SlideShowConstructor(osgDB::Options* options);
|
||||
|
||||
void createPresentation();
|
||||
@@ -404,9 +404,21 @@ public:
|
||||
PositionData& getModelPositionDataDefault() { return _modelPositionDataDefault; }
|
||||
|
||||
|
||||
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 layerClickEventOperation(const KeyPosition& keyPos, bool relativeJump=true, int slideNum=0, int layerNum=0);
|
||||
enum PresentationContext {
|
||||
CURRENT_PRESENTATION,
|
||||
CURRENT_SLIDE,
|
||||
CURRENT_LAYER
|
||||
};
|
||||
|
||||
void addEventHandler(PresentationContext presentationContext, osg::ref_ptr<osgGA::GUIEventHandler> handler);
|
||||
|
||||
void keyToDoOperation(PresentationContext presentationContext, int key, Operation operation, const JumpData& jumpData=JumpData());
|
||||
void keyToDoOperation(PresentationContext presentationContext, int key, const std::string& command, Operation operation, const JumpData& jumpData=JumpData());
|
||||
void keyEventOperation(PresentationContext presentationContext, int key, const KeyPosition& keyPos, const JumpData& jumpData=JumpData());
|
||||
|
||||
void layerClickToDoOperation(Operation operation, const JumpData& jumpData=JumpData());
|
||||
void layerClickToDoOperation(const std::string& command, Operation operation, const JumpData& jumpData=JumpData());
|
||||
void layerClickEventOperation(const KeyPosition& keyPos, const JumpData& jumpData=JumpData());
|
||||
|
||||
void addToCurrentLayer(osg::Node* subgraph);
|
||||
|
||||
@@ -540,7 +552,9 @@ protected:
|
||||
osg::ref_ptr<FilePathData> _filePathData;
|
||||
|
||||
osg::ref_ptr<osg::Group> _layerToApplyEventCallbackTo;
|
||||
osg::ref_ptr<osgGA::GUIEventHandler> _currentEventCallbackToApply;
|
||||
|
||||
typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlerList;
|
||||
EventHandlerList _currentEventCallbacksToApply;
|
||||
|
||||
|
||||
std::string findFileAndRecordPath(const std::string& filename);
|
||||
|
||||
Reference in New Issue
Block a user