2006-11-27 22:52:07 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OSGVIEWER_CompositeViewer
|
|
|
|
#define OSGVIEWER_CompositeViewer 1
|
|
|
|
|
2007-06-06 18:57:02 +08:00
|
|
|
#include <osg/ArgumentParser>
|
2007-08-10 18:52:35 +08:00
|
|
|
#include <osgUtil/UpdateVisitor>
|
2006-11-27 22:52:07 +08:00
|
|
|
#include <osgViewer/GraphicsWindow>
|
|
|
|
#include <osgViewer/View>
|
|
|
|
|
|
|
|
namespace osgViewer {
|
|
|
|
|
|
|
|
/** CompsiteViewer holds a or more views to a one more scenes.*/
|
2010-02-20 02:56:21 +08:00
|
|
|
class OSGVIEWER_EXPORT CompositeViewer : public ViewerBase
|
2006-11-27 22:52:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
CompositeViewer();
|
2007-06-06 18:57:02 +08:00
|
|
|
|
2007-08-11 18:28:14 +08:00
|
|
|
CompositeViewer(const CompositeViewer&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
|
|
|
|
2007-06-06 18:57:02 +08:00
|
|
|
CompositeViewer(osg::ArgumentParser& arguments);
|
2007-08-11 18:28:14 +08:00
|
|
|
|
2007-09-21 21:30:33 +08:00
|
|
|
META_Object(osgViewer,CompositeViewer);
|
2007-06-06 18:57:02 +08:00
|
|
|
|
2006-11-27 22:52:07 +08:00
|
|
|
virtual ~CompositeViewer();
|
|
|
|
|
2007-09-21 21:30:33 +08:00
|
|
|
/** read the viewer configuration from a configuration file.*/
|
|
|
|
bool readConfiguration(const std::string& filename);
|
|
|
|
|
2009-01-27 21:23:20 +08:00
|
|
|
|
|
|
|
/** Set the Stats object used for collect various frame related timing and scene graph stats.*/
|
|
|
|
virtual void setViewerStats(osg::Stats* stats) { _stats = stats; }
|
|
|
|
|
|
|
|
/** Get the Viewers Stats object.*/
|
|
|
|
virtual osg::Stats* getViewerStats() { return _stats.get(); }
|
|
|
|
|
|
|
|
/** Get the Viewers Stats object.*/
|
|
|
|
virtual const osg::Stats* getViewerStats() const { return _stats.get(); }
|
|
|
|
|
|
|
|
|
2006-11-29 04:35:31 +08:00
|
|
|
void addView(osgViewer::View* view);
|
2007-05-12 03:25:44 +08:00
|
|
|
void removeView(osgViewer::View* view);
|
2006-11-29 04:35:31 +08:00
|
|
|
|
|
|
|
osgViewer::View* getView(unsigned i) { return _views[i].get(); }
|
|
|
|
const osgViewer::View* getView(unsigned i) const { return _views[i].get(); }
|
|
|
|
|
|
|
|
unsigned int getNumViews() const { return _views.size(); }
|
2006-11-27 22:52:07 +08:00
|
|
|
|
2007-01-16 16:56:33 +08:00
|
|
|
|
|
|
|
/** Get whether at least of one of this viewers windows are realized.*/
|
2007-09-30 00:46:08 +08:00
|
|
|
virtual bool isRealized() const;
|
2007-01-16 16:56:33 +08:00
|
|
|
|
|
|
|
/** set up windows and associated threads.*/
|
2007-09-30 00:46:08 +08:00
|
|
|
virtual void realize();
|
2007-01-16 16:56:33 +08:00
|
|
|
|
2007-09-30 00:46:08 +08:00
|
|
|
virtual void setStartTick(osg::Timer_t tick);
|
2007-01-16 16:56:33 +08:00
|
|
|
|
|
|
|
void setReferenceTime(double time=0.0);
|
|
|
|
|
|
|
|
osg::FrameStamp* getFrameStamp() { return _frameStamp.get(); }
|
|
|
|
const osg::FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
|
|
|
|
|
2007-10-03 05:23:58 +08:00
|
|
|
virtual double elapsedTime();
|
2009-04-25 00:20:50 +08:00
|
|
|
|
2007-10-03 05:23:58 +08:00
|
|
|
virtual osg::FrameStamp* getViewerFrameStamp() { return getFrameStamp(); }
|
2009-04-25 00:20:50 +08:00
|
|
|
|
2007-09-30 00:46:08 +08:00
|
|
|
|
2007-01-16 16:56:33 +08:00
|
|
|
/** Execute a main frame loop.
|
2007-12-11 01:30:18 +08:00
|
|
|
* Equivalent to while (!viewer.done()) viewer.frame();
|
2007-01-16 16:56:33 +08:00
|
|
|
* Also calls realize() if the viewer is not already realized,
|
|
|
|
* and installs trackball manipulator if one is not already assigned.
|
|
|
|
*/
|
|
|
|
virtual int run();
|
|
|
|
|
2009-04-25 00:20:50 +08:00
|
|
|
/** check to see if the new frame is required, called by run(..) when FrameScheme is set to ON_DEMAND.*/
|
|
|
|
virtual bool checkNeedToDoFrame();
|
|
|
|
|
2007-01-25 20:02:51 +08:00
|
|
|
virtual void advance(double simulationTime=USE_REFERENCE_TIME);
|
2007-01-16 16:56:33 +08:00
|
|
|
|
|
|
|
virtual void eventTraversal();
|
|
|
|
|
|
|
|
virtual void updateTraversal();
|
2009-04-25 00:20:50 +08:00
|
|
|
|
|
|
|
|
2007-01-16 16:56:33 +08:00
|
|
|
void setCameraWithFocus(osg::Camera* camera);
|
|
|
|
osg::Camera* getCameraWithFocus() { return _cameraWithFocus.get(); }
|
|
|
|
const osg::Camera* getCameraWithFocus() const { return _cameraWithFocus.get(); }
|
2009-04-25 00:20:50 +08:00
|
|
|
|
2007-01-16 16:56:33 +08:00
|
|
|
osgViewer::View* getViewWithFocus() { return _viewWithFocus.get(); }
|
|
|
|
const osgViewer::View* getViewWithFocus() const { return _viewWithFocus.get(); }
|
|
|
|
|
2007-09-30 00:46:08 +08:00
|
|
|
virtual void getCameras(Cameras& cameras, bool onlyActive=true);
|
2007-01-16 16:56:33 +08:00
|
|
|
|
2007-09-30 00:46:08 +08:00
|
|
|
virtual void getContexts(Contexts& contexts, bool onlyValid=true);
|
2007-01-16 16:56:33 +08:00
|
|
|
|
2007-09-30 00:46:08 +08:00
|
|
|
virtual void getAllThreads(Threads& threads, bool onlyActive=true);
|
2007-01-29 01:11:21 +08:00
|
|
|
|
2007-09-30 00:46:08 +08:00
|
|
|
virtual void getOperationThreads(OperationThreads& threads, bool onlyActive=true);
|
2007-01-29 01:11:21 +08:00
|
|
|
|
2007-09-30 00:46:08 +08:00
|
|
|
virtual void getScenes(Scenes& scenes, bool onlyValid=true);
|
2007-01-29 01:11:21 +08:00
|
|
|
|
2007-09-30 19:37:00 +08:00
|
|
|
virtual void getViews(Views& views, bool onlyValid=true);
|
|
|
|
|
2007-09-30 00:46:08 +08:00
|
|
|
|
|
|
|
/** Get the keyboard and mouse usage of this viewer.*/
|
|
|
|
virtual void getUsage(osg::ApplicationUsage& usage) const;
|
2006-11-27 22:52:07 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2007-06-06 18:57:02 +08:00
|
|
|
void constructorInit();
|
|
|
|
|
2007-10-03 05:23:58 +08:00
|
|
|
virtual void viewerInit();
|
2007-09-30 19:37:00 +08:00
|
|
|
|
|
|
|
typedef std::vector< osg::ref_ptr<osgViewer::View> > RefViews;
|
|
|
|
RefViews _views;
|
2006-11-27 22:52:07 +08:00
|
|
|
|
2007-01-16 16:56:33 +08:00
|
|
|
bool _firstFrame;
|
|
|
|
|
2009-01-27 21:23:20 +08:00
|
|
|
osg::ref_ptr<osg::Stats> _stats;
|
|
|
|
|
2007-01-16 16:56:33 +08:00
|
|
|
osg::Timer_t _startTick;
|
|
|
|
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
|
|
|
|
|
|
|
osg::observer_ptr<osg::Camera> _cameraWithFocus;
|
|
|
|
osg::observer_ptr<osgViewer::View> _viewWithFocus;
|
|
|
|
|
2006-11-27 22:52:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|