OpenFrames
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
OpenFrames::WindowProxy Class Reference

Defines an interface that can draw a scene onto any window. More...

#include <WindowProxy.hpp>

Inheritance diagram for OpenFrames::WindowProxy:

Public Types

enum  AnimationState {
  IDLE = 0, INITIALIZING, ANIMATING, PAUSED,
  FAILED, SUCCESS
}
 
typedef std::vector< osg::ref_ptr< RenderRectangle > > RenderList
 

Public Member Functions

 WindowProxy (int x, int y, unsigned int width, unsigned int height, unsigned int nrow, unsigned int ncol, bool embedded=false, bool useVR=false)
 
virtual void cancelCleanup ()
 
void setWindowName (const std::string &name)
 
unsigned int getWindowWidth () const
 
unsigned int getWindowHeight () const
 
bool isEmbedded () const
 
void keyPress (int key)
 
void keyRelease (int key)
 
void mouseMotion (float x, float y)
 
void buttonPress (float x, float y, unsigned int button)
 
void buttonRelease (float x, float y, unsigned int button)
 
void resizeWindow (int x, int y, unsigned int width, unsigned int height)
 
void setupGrid (unsigned int width, unsigned int height)
 
void shutdown ()
 
void setTime (double time)
 
double getTime () const
 
void setTimeRange (double tMin, double tMax)
 Control allowable time range; computed simulation time will always obey this.
 
void getTimeRange (double &tMin, double &tMax) const
 
void pauseTime (bool pause)
 
bool isTimePaused () const
 
void setTimeScale (double tscale)
 
double getTimeScale () const
 
bool synchronizeTime (WindowProxy *winproxy)
 
WindowProxygetTimeSyncWindow () const
 
void pauseAnimation (bool pause)
 
AnimationState getAnimationState () const
 Get the current animation state.
 
bool isAnimating () const
 Determine whether WindowProxy is in its animation loop.
 
bool doneAnimating () const
 Determine whether WindowProxy is done animating.
 
void resetAnimationState ()
 If animation is done, then reset the animation state.
 
void setDesiredFramerate (const double &fps)
 
double getDesiredFramerate ()
 
double getFramerate ()
 
osgViewer::CompositeViewer * getViewer () const
 
void setGridSize (unsigned int row, unsigned int col)
 
unsigned int getNumRows () const
 
unsigned int getNumCols () const
 
void setScene (FrameManager *fm, unsigned int row, unsigned int col)
 
FrameManagergetScene (unsigned int row, unsigned int col)
 
RenderRectanglegetGridPosition (unsigned int row, unsigned int col)
 
void setMakeCurrentFunction (void(*fcn)(unsigned int *winID, bool *success))
 
void setUpdateContextFunction (void(*fcn)(unsigned int *winID, bool *success))
 
void setSwapBuffersFunction (void(*fcn)(unsigned int *winID))
 
void setKeyPressCallback (void(*fcn)(KEYPRESS_SIG))
 
void setMouseMotionCallback (void(*fcn)(MOUSEMOTION_SIG))
 
void setButtonPressCallback (void(*fcn)(BUTTON_SIG))
 
void setButtonReleaseCallback (void(*fcn)(BUTTON_SIG))
 
void setVREventCallback (void(*fcn)(VR_SIG))
 
void setID (unsigned int id)
 
unsigned int getID () const
 
bool getUseVR ()
 
const OpenVRDevicegetOpenVRDevice () const
 
void setWorldUnitsPerMeter (double worldUnitsPerMeter)
 
double getWorldUnitsPerMeter ()
 
void setWorldUnitsPerMeterLimits (const double &minWorldUnitsPerMeter, const double &maxWorldUnitsPerMeter)
 
void getWorldUnitsPerMeterLimits (double &minWorldUnitsPerMeter, double &maxWorldUnitsPerMeter)
 
void setUserHeight (const double &height)
 
virtual void run ()
 
void printInfo ()
 
void captureWindow ()
 
void setWindowCaptureFile (const std::string &fname, const std::string &fext)
 
void setWindowCaptureKey (int key)
 

Protected Types

typedef std::set< FrameManager * > SceneSet
 

Protected Member Functions

bool setupWindow ()
 
void collectScenes ()
 
void frame ()
 

Protected Attributes

unsigned int _winID
 
unsigned int _nRow
 
unsigned int _nCol
 
bool _isEmbedded
 
RenderList _renderList
 
SceneSet _scenes
 
osg::ref_ptr< osgViewer::CompositeViewer > _viewer
 
osg::ref_ptr< osgViewer::GraphicsWindow > _window
 
osg::ref_ptr< EmbeddedGraphics_embeddedGraphics
 
osg::ref_ptr< WindowEventHandler_eventHandler
 
osg::ref_ptr< osgViewer::StatsHandler > _statsHandler
 
osg::ref_ptr< osgViewer::ScreenCaptureHandler > _screenCaptureHandler
 
FramerateLimiter _frameThrottle
 
AnimationState _animationState
 
bool _pauseAnimation
 
bool _timePaused
 
osg::Timer_t _Tref
 
double _currTime
 
double _offsetTime
 
double _timeScale
 
double _minTime
 
double _maxTime
 
osg::observer_ptr< WindowProxy_timeSyncWinProxy
 
bool _useVR
 
osg::ref_ptr< OpenVRDevice_ovrDevice
 
osg::ref_ptr< VRTextureBuffer_vrTextureBuffer
 

Detailed Description

Defines an interface that can draw a scene onto any window.

This class defines an interface that can draw a scene onto any window, regardless of how that window is created or managed. This allows the scene to be drawn on a window created by (for example) a GUI management API such as gtk or Winteracter. Drawing is thread-safe and special consideration is given for OpenGL implementations that only allow one current context for all threads.

Member Enumeration Documentation

◆ AnimationState

The state of this WindowProxy's animation loop

Member Function Documentation

◆ captureWindow()

void OpenFrames::WindowProxy::captureWindow ( )

Capture a screenshot of this window.

◆ getDesiredFramerate()

double OpenFrames::WindowProxy::getDesiredFramerate ( )
inline

Get the desired framerate at which animation should occur.

◆ getFramerate()

double OpenFrames::WindowProxy::getFramerate ( )
inline

Get the actual animation framerate. This is an instantaneous value.

◆ getGridPosition()

RenderRectangle* OpenFrames::WindowProxy::getGridPosition ( unsigned int  row,
unsigned int  col 
)

Get the RenderRectangle used for the given grid position

◆ getOpenVRDevice()

const OpenVRDevice* OpenFrames::WindowProxy::getOpenVRDevice ( ) const
inline

Get the OpenVRDevice object that manages VR rendering

◆ getUseVR()

bool OpenFrames::WindowProxy::getUseVR ( )
inline

Get whether VR rendering is enabled

◆ keyPress()

void OpenFrames::WindowProxy::keyPress ( int  key)

These functions should be called when keyboard/mouse input is recieved from your own Window Manager, or if you want to simulate user input to the WindowProxy. Note that x and y coordinates should be in the range [0, width] and [0, height] respectively, representing the extents of the window.

◆ pauseAnimation()

void OpenFrames::WindowProxy::pauseAnimation ( bool  pause)

Animation loop control (animation means process events, update objects, and render scene) Set the desired animation pause state. If currently animating, then return after actual animation state matches the desired animation state. Otherwise return immediately. NOTE: pauseAnimation should never be called from the render thread, which includes user-defined callback functions.

◆ printInfo()

void OpenFrames::WindowProxy::printInfo ( )

Print info about this window to std::cout.

◆ run()

virtual void OpenFrames::WindowProxy::run ( )
virtual

Inherited from OpenThreads::Thread. Called on thread launch.

◆ setDesiredFramerate()

void OpenFrames::WindowProxy::setDesiredFramerate ( const double &  fps)
inline

Set the desired framerate at which animation should occur.

◆ setGridSize()

void OpenFrames::WindowProxy::setGridSize ( unsigned int  row,
unsigned int  col 
)

Set the render grid's dimensions.

◆ setID()

void OpenFrames::WindowProxy::setID ( unsigned int  id)
inline

Set the window id that will be passed into all user-defined callback functions.

◆ setKeyPressCallback()

void OpenFrames::WindowProxy::setKeyPressCallback ( void(*)(KEYPRESS_SIG fcn)
inline

Set callback functions for events

◆ setMakeCurrentFunction()

void OpenFrames::WindowProxy::setMakeCurrentFunction ( void(*)(unsigned int *winID, bool *success)  fcn)

Callback function for making the OpenGL context current

◆ setSwapBuffersFunction()

void OpenFrames::WindowProxy::setSwapBuffersFunction ( void(*)(unsigned int *winID)  fcn)

Callback function for swapping the front/back buffers

◆ setTime()

void OpenFrames::WindowProxy::setTime ( double  time)

Time control

◆ setUpdateContextFunction()

void OpenFrames::WindowProxy::setUpdateContextFunction ( void(*)(unsigned int *winID, bool *success)  fcn)

Callback function to update the OpenGL context. Called whenever a renderer or geometry-changing event is handled. e.g. on OSX/Cocoa this is required on each resize event

◆ setupGrid()

void OpenFrames::WindowProxy::setupGrid ( unsigned int  width,
unsigned int  height 
)

Resize each RenderRectangle grid with the specified dimensions

◆ setUserHeight()

void OpenFrames::WindowProxy::setUserHeight ( const double &  height)
inline

Set the user height in VR

◆ setWindowCaptureFile()

void OpenFrames::WindowProxy::setWindowCaptureFile ( const std::string &  fname,
const std::string &  fext 
)

Set the screenshot filename and image type. The filename will be sequentially numbered with each successive screenshot. Image types can be anything supported by OSG: jpg, png, bmp, tiff, etc.

◆ setWindowCaptureKey()

void OpenFrames::WindowProxy::setWindowCaptureKey ( int  key)
inline

Set the key that triggers a screenshot. Set key to 0 (zero) to disable keypress-based screenshots

◆ setWindowName()

void OpenFrames::WindowProxy::setWindowName ( const std::string &  name)

Set the window's name Only applies to non-embedded windows. For embedded windows, the window name should be set via the API used to create the window (Qt, wxWidgets, etc.)

◆ setWorldUnitsPerMeter()

void OpenFrames::WindowProxy::setWorldUnitsPerMeter ( double  worldUnitsPerMeter)
inline

Set the ratio of WorldUnits to Meters used for VR rendering

◆ setWorldUnitsPerMeterLimits()

void OpenFrames::WindowProxy::setWorldUnitsPerMeterLimits ( const double &  minWorldUnitsPerMeter,
const double &  maxWorldUnitsPerMeter 
)
inline

Set the limits of the WorldUntis/Meter ratio

◆ shutdown()

void OpenFrames::WindowProxy::shutdown ( )
inline

Shut down the WindowProxy entirely.

◆ synchronizeTime()

bool OpenFrames::WindowProxy::synchronizeTime ( WindowProxy winproxy)

Synchronize time with another WindowProxy This causes all time control to be forwarded to the other WindowProxy Inputs: NULL or this: Stop synchronizing time Otherwise: Synchronize with specified WindowProxy Return: true: success, synchronized with input false: circular dependency detected, synchronization unchanged

Member Data Documentation

◆ _animationState

AnimationState OpenFrames::WindowProxy::_animationState
protected

Time control variables

◆ _embeddedGraphics

osg::ref_ptr<EmbeddedGraphics> OpenFrames::WindowProxy::_embeddedGraphics
protected

The EmbeddedGraphics object allows rendering onto a user-provided OpenGL window

◆ _eventHandler

osg::ref_ptr<WindowEventHandler> OpenFrames::WindowProxy::_eventHandler
protected

The WindowEventHandler handles user events that occur in the window

◆ _screenCaptureHandler

osg::ref_ptr<osgViewer::ScreenCaptureHandler> OpenFrames::WindowProxy::_screenCaptureHandler
protected

The ScreenCaptureHandler takes a screenshot of this window

◆ _statsHandler

osg::ref_ptr<osgViewer::StatsHandler> OpenFrames::WindowProxy::_statsHandler
protected

The StatsHandler displays fps and other rendering statistics

◆ _viewer

osg::ref_ptr<osgViewer::CompositeViewer> OpenFrames::WindowProxy::_viewer
protected

The CompositeViewer handles drawing several scenes onto a single drawing surface (a window)

◆ _window

osg::ref_ptr<osgViewer::GraphicsWindow> OpenFrames::WindowProxy::_window
protected

The GraphicsWindow is the actual window that is drawn onto

◆ _winID

unsigned int OpenFrames::WindowProxy::_winID
protected

ID of this window. This will be used to identify this window to all user-defined callback functions


The documentation for this class was generated from the following file: