14#ifndef OSGVIEWER_VIEWERBASE
15#define OSGVIEWER_VIEWERBASE 1
30#define USE_REFERENCE_TIME DBL_MAX
266 typedef std::vector<osg::GraphicsContext*>
Contexts;
269 typedef std::vector<osgViewer::GraphicsWindow*>
Windows;
272 typedef std::vector<OpenThreads::Thread*>
Threads;
278 typedef std::vector<osgViewer::Scene*>
Scenes;
281 typedef std::vector<osgViewer::View*>
Views;
#define USE_REFERENCE_TIME
Definition ViewerBase:30
The osgViewer library provides high level viewer functionality designed to make it easier to write a ...
Definition ApplicationUsage:26
Class which encapsulates the frame number, reference time and calendar time of specific frame,...
Definition FrameStamp:35
Base class for providing Windowing API agnostic access to creating and managing graphics context.
Definition GraphicsContext:30
virtual bool valid() const =0
Return whether a valid and usable GraphicsContext has been created.
bool makeCurrent()
Make this graphics context current.
PreBlockOp
Definition GraphicsThread:70
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Smart pointer for observed objects, that automatically set pointers to them to null when they are del...
Definition observer_ptr:39
Base class for implementing graphics operations.
Definition OperationThread:51
Definition OperationThread:91
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Basic EventVisitor implementation for animating a scene.
Definition EventVisitor:42
Definition IncrementalCompileOperation:56
Basic UpdateVisitor implementation for animating a scene.
Definition UpdateVisitor:38
View holds a single view on a scene, this view may be composed of one or more slave cameras.
Definition View:76
osg::ref_ptr< osgGA::EventVisitor > _eventVisitor
Definition ViewerBase:355
osg::BarrierOperation::PreBlockOp _endBarrierOperation
Definition ViewerBase:349
osg::Operation * getCleanUpOperation()
Get the graphics operation to call before the viewers graphics contexts close.
Definition ViewerBase:215
void makeCurrent(osg::GraphicsContext *gc)
Definition ViewerBase:310
FrameScheme getRunFrameScheme() const
Definition ViewerBase:233
virtual void startThreading()
Start any threads required by the viewer.
const osg::OperationQueue * getUpdateOperations() const
Get the const Update OperationQueue.
Definition ViewerBase:196
bool _requestRedraw
Definition ViewerBase:341
const OpenThreads::Affinity & getProcessorAffinity() const
Definition ViewerBase:75
virtual bool readConfiguration(const std::string &filename)=0
read the viewer configuration from a configuration file.
bool getUseConfigureAffinity() const
get whether the setUpThreading() method should call configureAffinity() to set up up the processor af...
Definition ViewerBase:67
virtual void getAllThreads(Threads &threads, bool onlyActive=true)=0
ThreadingModel
Definition ViewerBase:78
@ AutomaticSelection
Definition ViewerBase:85
@ CullThreadPerCameraDrawThreadPerContext
Definition ViewerBase:83
@ CullDrawThreadPerContext
Definition ViewerBase:80
@ SingleThreaded
Definition ViewerBase:79
@ ThreadPerCamera
Definition ViewerBase:84
@ ThreadPerContext
Definition ViewerBase:81
@ DrawThreadPerContext
Definition ViewerBase:82
void setDone(bool done)
Set the done flag to signal the viewer's work is done and should exit the frame loop.
Definition ViewerBase:136
virtual void getCameras(Cameras &cameras, bool onlyActive=true)=0
osg::ref_ptr< osg::Operation > _cleanUpOperation
Definition ViewerBase:361
OpenThreads::Affinity & getProcessorAffinity()
Definition ViewerBase:74
virtual bool isRealized() const =0
Get whether at least of one of this viewers windows are realized.
ThreadingModel getThreadingModel() const
Get the threading model the rendering traversals will use.
Definition ViewerBase:92
void setUpdateOperations(osg::OperationQueue *operations)
Set the Update OperationQueue.
Definition ViewerBase:190
void setCleanUpOperation(osg::Operation *op)
Set the graphics operation to call before the viewers graphics contexts close.
Definition ViewerBase:212
osg::ref_ptr< osg::BarrierOperation > _endRenderingDispatchBarrier
Definition ViewerBase:352
virtual void configureAffinity()
analyse the viewer configuration and select an appropriate Affinity for main thread,...
void setUseConfigureAffinity(bool flag)
Set whether the setUpThreading() method should call configureAffinity() to set up up the processor af...
Definition ViewerBase:64
void checkWindowStatus()
Check to see if any windows are still open.
std::vector< OpenThreads::Thread * > Threads
Definition ViewerBase:272
OpenThreads::Affinity _affinity
Definition ViewerBase:337
osg::observer_ptr< osg::GraphicsContext > _currentContext
Definition ViewerBase:364
virtual void getViews(Views &views, bool onlyValid=true)=0
virtual osg::Stats * getViewerStats()=0
Get the Viewers Stats object.
osg::ref_ptr< osg::EndOfDynamicDrawBlock > _endDynamicDrawBlock
Definition ViewerBase:353
virtual void setViewerStats(osg::Stats *stats)=0
Set the Stats object used to collect various frame related timing and scene graph stats.
osg::ref_ptr< osgUtil::UpdateVisitor > _updateVisitor
Definition ViewerBase:358
virtual int run()
Execute a main frame loop.
virtual void stopThreading()
Stop any threads being run by viewer.
virtual void updateTraversal()=0
virtual void getWindows(Windows &windows, bool onlyValid=true)
bool getQuitEventSetsDone() const
Definition ViewerBase:163
void setRealizeOperation(osg::Operation *op)
Set the graphics operation to call on realization of the viewers graphics windows.
Definition ViewerBase:206
bool _useConfigureAffinity
Definition ViewerBase:336
virtual ThreadingModel suggestBestThreadingModel()
Let the viewer suggest the best threading model for the viewers camera/window setup and the hardware ...
BarrierPosition
Definition ViewerBase:110
@ AfterSwapBuffers
Definition ViewerBase:112
@ BeforeSwapBuffers
Definition ViewerBase:111
void setQuitEventSetsDone(bool flag)
if the flag is true, the viewer set its done flag when a QUIT_APPLICATION is received,...
Definition ViewerBase:160
std::vector< osg::OperationThread * > OperationThreads
Definition ViewerBase:275
virtual void viewerInit()=0
osg::Operation * getRealizeOperation()
Get the graphics operation to call on realization of the viewers graphics windows.
Definition ViewerBase:209
int _keyEventSetsDone
Definition ViewerBase:332
void setRunFrameScheme(FrameScheme fs)
Definition ViewerBase:232
void addUpdateOperation(osg::Operation *operation)
Add an update operation.
osg::ref_ptr< osg::BarrierOperation > _startRenderingBarrier
Definition ViewerBase:351
osg::OperationQueue * getUpdateOperations()
Get the Update OperationQueue.
Definition ViewerBase:193
virtual void realize()=0
set up windows and associated threads.
virtual void getOperationThreads(OperationThreads &threads, bool onlyActive=true)=0
virtual void eventTraversal()=0
std::vector< osgViewer::View * > Views
Definition ViewerBase:281
osg::ref_ptr< osgUtil::IncrementalCompileOperation > _incrementalCompileOperation
Definition ViewerBase:362
void checkWindowStatus(const Contexts &contexts)
Check to see if windows are still open using the list of contexts given as a parameter.
virtual osg::FrameStamp * getViewerFrameStamp()=0
void setIncrementalCompileOperation(osgUtil::IncrementalCompileOperation *ico)
Set the incremental compile operation.
double getRunMaxFrameRate() const
Definition ViewerBase:236
bool _firstFrame
Definition ViewerBase:330
virtual void renderingTraversals()
virtual void frame(double simulationTime=USE_REFERENCE_TIME)
Render a complete new frame.
osgUtil::IncrementalCompileOperation * getIncrementalCompileOperation()
Get the incremental compile operation.
Definition ViewerBase:223
void setRunMaxFrameRate(double frameRate)
Definition ViewerBase:235
bool done() const
Return true if viewer's work is done and should exit the frame loop.
Definition ViewerBase:139
osgUtil::UpdateVisitor * getUpdateVisitor()
Get the UpdateVisitor.
Definition ViewerBase:183
void setEndBarrierPosition(BarrierPosition bp)
Set the position of the end barrier.
std::vector< osg::Camera * > Cameras
Definition ViewerBase:263
void setReleaseContextAtEndOfFrameHint(bool hint)
Hint to tell the renderingTraversals() method whether to call releaseContext() on the last context th...
Definition ViewerBase:173
BarrierPosition getEndBarrierPosition() const
Get the end barrier position.
Definition ViewerBase:123
virtual void setUpThreading()
Set up the threading and processor affinity as per the viewers threading model.
bool getRequestContinousUpdate() const
Definition ViewerBase:302
virtual void getScenes(Scenes &scenes, bool onlyValid=true)=0
virtual void setProcessorAffinity(const OpenThreads::Affinity &affinity)
Set the processor affinity of main thread.
Definition ViewerBase:73
virtual void setThreadingModel(ThreadingModel threadingModel)
Set the threading model the rendering traversals will use.
bool _done
Definition ViewerBase:331
int getKeyEventSetsDone() const
get the key event that the viewer checks on each frame to see if the viewer's done flag.
Definition ViewerBase:157
const osgGA::EventVisitor * getEventVisitor() const
Get the const EventVisitor.
Definition ViewerBase:148
std::vector< osg::GraphicsContext * > Contexts
Definition ViewerBase:266
bool _requestContinousUpdate
Definition ViewerBase:342
virtual const osg::Stats * getViewerStats() const =0
Get the Viewers Stats object.
ThreadingModel _threadingModel
Definition ViewerBase:338
void setEndBarrierOperation(osg::BarrierOperation::PreBlockOp op)
Set the end barrier operation.
BarrierPosition _endBarrierPosition
Definition ViewerBase:348
osgGA::EventVisitor * getEventVisitor()
Get the EventVisitor.
Definition ViewerBase:145
bool _releaseContextAtEndOfFrameHint
Definition ViewerBase:334
ViewerBase(const ViewerBase &vb)
FrameScheme
Definition ViewerBase:227
@ ON_DEMAND
Definition ViewerBase:228
@ CONTINUOUS
Definition ViewerBase:229
std::vector< osgViewer::Scene * > Scenes
Definition ViewerBase:278
void setKeyEventSetsDone(int key)
Set the key event that the viewer checks on each frame to see if the viewer's done flag should be set...
Definition ViewerBase:154
bool _threadsRunning
Definition ViewerBase:339
void releaseContext()
Definition ViewerBase:319
void removeUpdateOperation(osg::Operation *operation)
Remove an update operation.
double _runMaxFrameRate
Definition ViewerBase:345
virtual bool checkNeedToDoFrame()=0
check to see if the new frame is required, called by run(..) when FrameScheme is set to ON_DEMAND.
osg::ref_ptr< osg::Operation > _realizeOperation
Definition ViewerBase:360
virtual void getContexts(Contexts &contexts, bool onlyValid=true)=0
virtual double elapsedTime()=0
bool _quitEventSetsDone
Definition ViewerBase:333
bool getRequestRedraw() const
Definition ViewerBase:300
bool getReleaseContextAtEndOfFrameHint() const
Hint to tell the renderingTraversals() method whether to call releaseContext().
Definition ViewerBase:176
const osgUtil::UpdateVisitor * getUpdateVisitor() const
Get the const UpdateVisitor.
Definition ViewerBase:186
virtual bool checkEvents()=0
check to see if events have been received, return true if events are now available.
osg::ref_ptr< osg::OperationQueue > _updateOperations
Definition ViewerBase:357
bool areThreadsRunning() const
Return true if viewer threads are running.
Definition ViewerBase:101
virtual void getUsage(osg::ApplicationUsage &usage) const =0
Get the keyboard and mouse usage of this viewer.
std::vector< osgViewer::GraphicsWindow * > Windows
Definition ViewerBase:269
osg::BarrierOperation::PreBlockOp getEndBarrierOperation() const
Get the end barrier operation.
Definition ViewerBase:132
virtual void advance(double simulationTime=USE_REFERENCE_TIME)=0
FrameScheme _runFrameScheme
Definition ViewerBase:344
void setEventVisitor(osgGA::EventVisitor *eventVisitor)
Set the EventVisitor.
Definition ViewerBase:142
void setUpdateVisitor(osgUtil::UpdateVisitor *updateVisitor)
Set the UpdateVisitor.
Definition ViewerBase:180
#define OSGVIEWER_EXPORT
Definition Export:40