Added help support for display help on screen to osgProducer::Viewer.
This commit is contained in:
@@ -34,6 +34,13 @@ class SG_EXPORT ApplicationUsage
|
||||
|
||||
typedef std::map<std::string,std::string> UsageMap;
|
||||
|
||||
|
||||
void setApplicatonName(const std::string& name) { _applicationName = name; }
|
||||
const std::string& getApplicatonName() const { return _applicationName; }
|
||||
|
||||
void setDescription(const std::string& desc) { _description = desc; }
|
||||
const std::string& getDescription() const { return _description; }
|
||||
|
||||
enum Type
|
||||
{
|
||||
COMMAND_LINE_OPTION,
|
||||
@@ -63,13 +70,16 @@ class SG_EXPORT ApplicationUsage
|
||||
const UsageMap& getKeyboardMouseBindings() const { return _keyboardMouse; }
|
||||
|
||||
|
||||
void getFormatedString(std::string& str, const UsageMap& um,unsigned int widthOfOutput=80);
|
||||
|
||||
void write(std::ostream& output,const UsageMap& um,unsigned int widthOfOutput=80);
|
||||
|
||||
void write(std::ostream& output,unsigned int widthOfOutput=80);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
std::string _applicationName;
|
||||
std::string _description;
|
||||
std::string _commandLineUsage;
|
||||
UsageMap _commandLineOptions;
|
||||
UsageMap _environmentalVariables;
|
||||
|
||||
@@ -27,6 +27,13 @@ class SG_EXPORT Viewport : public StateAttribute
|
||||
|
||||
|
||||
Viewport();
|
||||
|
||||
Viewport(int x,int y,int width,int height):
|
||||
_x(x),
|
||||
_y(y),
|
||||
_width(width),
|
||||
_height(height) {}
|
||||
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
Viewport(const Viewport& vp,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
|
||||
@@ -35,6 +35,9 @@ class OSGGA_EXPORT CameraManipulator : public GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
virtual const char* className() { return "CameraManipulator"; }
|
||||
|
||||
/** Attach a camera to the manipulator to be used for specifying view.*/
|
||||
virtual void setCamera(osg::Camera*);
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ class OSGGA_EXPORT DriveManipulator : public CameraManipulator
|
||||
|
||||
DriveManipulator();
|
||||
|
||||
virtual ~DriveManipulator();
|
||||
|
||||
virtual const char* className() { return "Drive"; }
|
||||
|
||||
virtual void setNode(osg::Node*);
|
||||
@@ -52,6 +50,8 @@ class OSGGA_EXPORT DriveManipulator : public CameraManipulator
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~DriveManipulator();
|
||||
|
||||
/** Reset the internal GUIEvent stack.*/
|
||||
void flushMouseEventStack();
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ class OSGGA_EXPORT FlightManipulator : public CameraManipulator
|
||||
public:
|
||||
|
||||
FlightManipulator();
|
||||
virtual ~FlightManipulator();
|
||||
|
||||
virtual const char* className() { return "Flight"; }
|
||||
|
||||
@@ -59,6 +58,8 @@ class OSGGA_EXPORT FlightManipulator : public CameraManipulator
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~FlightManipulator();
|
||||
|
||||
/** Reset the internal GUIEvent stack.*/
|
||||
void flushMouseEventStack();
|
||||
/** Add the current mouse GUIEvent to internal stack.*/
|
||||
|
||||
@@ -23,7 +23,6 @@ class OSGGA_EXPORT TrackballManipulator : public CameraManipulator
|
||||
public:
|
||||
|
||||
TrackballManipulator();
|
||||
virtual ~TrackballManipulator();
|
||||
|
||||
virtual const char* className() { return "Trackball"; }
|
||||
|
||||
@@ -54,6 +53,8 @@ class OSGGA_EXPORT TrackballManipulator : public CameraManipulator
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~TrackballManipulator();
|
||||
|
||||
/** Reset the internal GUIEvent stack.*/
|
||||
void flushMouseEventStack();
|
||||
/** Add the current mouse GUIEvent to internal stack.*/
|
||||
|
||||
@@ -44,7 +44,12 @@ class FrameStatsHandler : public Producer::CameraGroup::StatsHandler, public Pro
|
||||
{
|
||||
if (!camera.getInstrumentationMode()) return;
|
||||
|
||||
glViewport( 0, 0, 1280, 1024 );
|
||||
int x,y;
|
||||
unsigned int width,height;
|
||||
camera.getProjectionRect(x,y,width,height);
|
||||
|
||||
glViewport( x, y, width, height );
|
||||
|
||||
// Set up the Orthographic view
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glPushMatrix();
|
||||
|
||||
@@ -119,7 +119,7 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
|
||||
class OSGPRODUCER_EXPORT RealizeCallback : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
virtual void operator()( const Producer::RenderSurface & rs, OsgCameraGroup* cg, OsgSceneHandler* sh) = 0;
|
||||
virtual void operator()( OsgCameraGroup& cg, OsgSceneHandler& sh, const Producer::RenderSurface & rs) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~RealizeCallback() {}
|
||||
@@ -133,9 +133,6 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
|
||||
|
||||
/** Get the const realize callback.*/
|
||||
const RealizeCallback* getRealizeCallback() const { return _realizeCallback.get(); }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void advance();
|
||||
|
||||
@@ -30,12 +30,54 @@ class OSGPRODUCER_EXPORT OsgSceneHandler : public Producer::Camera::SceneHandler
|
||||
|
||||
/// override the init method to force it be run one at a time.
|
||||
virtual void init();
|
||||
|
||||
|
||||
class Callback : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
virtual ~Callback() {}
|
||||
virtual void operator()(OsgSceneHandler&, const Producer::Camera &) = 0;
|
||||
};
|
||||
|
||||
virtual void clear(Producer::Camera& camera)
|
||||
{
|
||||
if (_clearCallback.valid()) (*_clearCallback)(*this,camera);
|
||||
else clearImplementation(camera);
|
||||
}
|
||||
|
||||
virtual void clear(Producer::Camera& camera);
|
||||
virtual void clearImplementation(Producer::Camera& camera);
|
||||
|
||||
void setClearCallback(Callback* callback) { _clearCallback = callback; }
|
||||
Callback* getClearCallback() { return _clearCallback.get(); }
|
||||
const Callback* getClearCallback() const { return _clearCallback.get(); }
|
||||
|
||||
|
||||
virtual void cull(Producer::Camera& camera)
|
||||
{
|
||||
if (_cullCallback.valid()) (*_cullCallback)(*this,camera);
|
||||
else cullImplementation(camera);
|
||||
}
|
||||
|
||||
virtual void cullImplementation(Producer::Camera& camera);
|
||||
|
||||
void setCullCallback(Callback* callback) { _cullCallback = callback; }
|
||||
Callback* getCullCallback() { return _cullCallback.get(); }
|
||||
const Callback* getCullCallback() const { return _cullCallback.get(); }
|
||||
|
||||
|
||||
virtual void draw(Producer::Camera& camera)
|
||||
{
|
||||
if (_drawCallback.valid()) (*_drawCallback)(*this,camera);
|
||||
else drawImplementation(camera);
|
||||
}
|
||||
|
||||
virtual void drawImplementation(Producer::Camera& camera);
|
||||
|
||||
void setDrawCallback(Callback* callback) { _drawCallback = callback; }
|
||||
Callback* getDrawCallback() { return _drawCallback.get(); }
|
||||
const Callback* getDrawCallback() const { return _drawCallback.get(); }
|
||||
|
||||
virtual void cull(Producer::Camera& camera);
|
||||
|
||||
virtual void draw(Producer::Camera& camera);
|
||||
|
||||
void setContextID( int id );
|
||||
|
||||
@@ -43,8 +85,13 @@ class OSGPRODUCER_EXPORT OsgSceneHandler : public Producer::Camera::SceneHandler
|
||||
|
||||
virtual ~OsgSceneHandler() {}
|
||||
|
||||
|
||||
osg::ref_ptr<osg::RefMatrix> mm;
|
||||
osg::ref_ptr<osg::RefMatrix> pm;
|
||||
|
||||
osg::ref_ptr<Callback> _clearCallback;
|
||||
osg::ref_ptr<Callback> _cullCallback;
|
||||
osg::ref_ptr<Callback> _drawCallback;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class ViewerEventHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
ViewerEventHandler(osgProducer::OsgCameraGroup* cg);
|
||||
ViewerEventHandler(OsgCameraGroup* cg);
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa);
|
||||
|
||||
@@ -31,12 +31,25 @@ class ViewerEventHandler : public osgGA::GUIEventHandler
|
||||
|
||||
/** Get the keyboard and mouse usage of this manipulator.*/
|
||||
virtual void getUsage(osg::ApplicationUsage& usage) const;
|
||||
|
||||
OsgCameraGroup* getOsgCameraGroup() { return _cg; }
|
||||
const OsgCameraGroup* getOsgCameraGroup() const { return _cg; }
|
||||
|
||||
|
||||
void setWriteNodeFileName(const std::string& filename) { _writeNodeFileName = filename; }
|
||||
const std::string& getWriteNodeFileName() const { return _writeNodeFileName; }
|
||||
|
||||
|
||||
void setDisplayHelp(bool displayHelp) { _displayHelp = displayHelp; }
|
||||
bool getDisplayHelp() const { return _displayHelp; }
|
||||
|
||||
protected:
|
||||
|
||||
osgProducer::OsgCameraGroup* _cg;
|
||||
|
||||
std::string _writeNodeFileName;
|
||||
|
||||
bool _displayHelp;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user