14 #ifndef OSGVIEWER_VIEWERBASE
15 #define OSGVIEWER_VIEWERBASE 1
19 #include <osgUtil/UpdateVisitor>
20 #include <osgUtil/IncrementalCompileOperation>
22 #include <osgGA/EventVisitor>
23 #include <osgGA/EventQueue>
25 #include <osgViewer/Scene>
26 #include <osgViewer/GraphicsWindow>
30 #define USE_REFERENCE_TIME DBL_MAX
44 virtual void setViewerStats(
osg::Stats* stats) = 0;
50 virtual const osg::Stats* getViewerStats()
const = 0;
54 virtual bool readConfiguration(
const std::string& filename) = 0;
57 virtual bool isRealized()
const = 0;
60 virtual void realize() = 0;
66 ThreadPerContext = CullDrawThreadPerContext,
69 ThreadPerCamera = CullThreadPerCameraDrawThreadPerContext,
74 virtual void setThreadingModel(ThreadingModel threadingModel);
80 virtual ThreadingModel suggestBestThreadingModel();
83 virtual void setUpThreading();
89 virtual void stopThreading();
92 virtual void startThreading();
105 void setEndBarrierPosition(BarrierPosition bp);
124 bool done()
const {
return _done; }
226 virtual bool checkNeedToDoFrame() = 0;
229 virtual bool checkEvents() = 0;
237 virtual void eventTraversal() = 0;
239 virtual void updateTraversal() = 0;
241 virtual void renderingTraversals();
244 virtual void getCameras(Cameras& cameras,
bool onlyActive=
true) = 0;
246 typedef std::vector<osg::GraphicsContext*>
Contexts;
247 virtual void getContexts(Contexts& contexts,
bool onlyValid=
true) = 0;
249 typedef std::vector<osgViewer::GraphicsWindow*>
Windows;
250 virtual void getWindows(Windows& windows,
bool onlyValid=
true);
252 typedef std::vector<OpenThreads::Thread*>
Threads;
253 virtual void getAllThreads(Threads& threads,
bool onlyActive=
true) = 0;
256 virtual void getOperationThreads(OperationThreads& threads,
bool onlyActive=
true) = 0;
258 typedef std::vector<osgViewer::Scene*>
Scenes;
259 virtual void getScenes(Scenes& scenes,
bool onlyValid=
true) = 0;
261 typedef std::vector<osgViewer::View*>
Views;
262 virtual void getViews(Views& views,
bool onlyValid=
true) = 0;
265 void checkWindowStatus();
271 void checkWindowStatus(
const Contexts& contexts);
273 virtual double elapsedTime() = 0;
282 void viewerBaseInit();
288 if (_currentContext==gc)
return;
297 if (_currentContext.valid() && _currentContext->valid())
299 _currentContext->releaseContext();
304 virtual void viewerInit() = 0;
void setUpdateOperations(osg::OperationQueue *operations)
osgGA::EventVisitor * getEventVisitor()
osg::ref_ptr< osg::EndOfDynamicDrawBlock > _endDynamicDrawBlock
std::vector< osgViewer::Scene * > Scenes
const osg::OperationQueue * getUpdateOperations() const
double getRunMaxFrameRate() const
void setEventVisitor(osgGA::EventVisitor *eventVisitor)
FrameScheme _runFrameScheme
bool getQuitEventSetsDone() const
osg::ref_ptr< osgUtil::UpdateVisitor > _updateVisitor
void setReleaseContextAtEndOfFrameHint(bool hint)
#define USE_REFERENCE_TIME
void setKeyEventSetsDone(int key)
BarrierPosition getEndBarrierPosition() const
osgUtil::IncrementalCompileOperation * getIncrementalCompileOperation()
void setRealizeOperation(osg::Operation *op)
osg::OperationQueue * getUpdateOperations()
osg::BarrierOperation::PreBlockOp getEndBarrierOperation() const
std::vector< osg::Camera * > Cameras
std::vector< osg::OperationThread * > OperationThreads
bool _releaseContextAtEndOfFrameHint
ThreadingModel getThreadingModel() const
osg::ref_ptr< osgUtil::IncrementalCompileOperation > _incrementalCompileOperation
bool _requestContinousUpdate
const osgUtil::UpdateVisitor * getUpdateVisitor() const
virtual bool valid() const =0
osg::ref_ptr< osgGA::EventVisitor > _eventVisitor
void setQuitEventSetsDone(bool flag)
std::vector< osgViewer::View * > Views
ThreadingModel _threadingModel
bool getReleaseContextAtEndOfFrameHint() const
std::vector< osg::GraphicsContext * > Contexts
int getKeyEventSetsDone() const
osg::ref_ptr< osg::BarrierOperation > _endRenderingDispatchBarrier
std::vector< OpenThreads::Thread * > Threads
bool areThreadsRunning() const
void makeCurrent(osg::GraphicsContext *gc)
FrameScheme getRunFrameScheme() const
osg::Operation * getRealizeOperation()
osg::ref_ptr< osg::BarrierOperation > _startRenderingBarrier
osg::ref_ptr< osg::Operation > _realizeOperation
void setUpdateVisitor(osgUtil::UpdateVisitor *updateVisitor)
std::vector< osgViewer::GraphicsWindow * > Windows
BarrierPosition _endBarrierPosition
osg::ref_ptr< osg::OperationQueue > _updateOperations
void setRunFrameScheme(FrameScheme fs)
osg::BarrierOperation::PreBlockOp _endBarrierOperation
osgUtil::UpdateVisitor * getUpdateVisitor()
osg::observer_ptr< osg::GraphicsContext > _currentContext
void setRunMaxFrameRate(double frameRate)
const osgGA::EventVisitor * getEventVisitor() const