GL Studio SCECpp Runtime Library
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GlsInputManager Class Reference

#include <gls_input_manager.h>

Classes

struct  InitParameters
 
struct  Viewport
 

Public Member Functions

GlsBool HandleEvent (GlsEvent &event)
 
void UpdateViewport (const Viewport &viewport)
 
void UpdateProjectionMatrix (const GlsMatrixAffineD::GLMatrixAffineF &projMatrix)
 
void UpdateModelMatrix (const GlsMatrixAffineD::GLMatrixAffineF &modelMatrix)
 
void ProjectPoint (const GlsVector3D &p, const GlsMatrixAffineD::GLMatrixAffineF &drawMatrix, GlsVector2D &projected) const
 

Static Public Member Functions

static void Initialize (InitParameters &initParameters)
 
static GlsInputManagerGetInputManager (void)
 

Protected Member Functions

 GlsInputManager (InitParameters &initParameters)
 
virtual ~GlsInputManager ()
 

Protected Attributes

Viewport _viewport
 
GlsMatrixAffineD::GLMatrixAffineF _projMatrix
 
GlsMatrixAffineD::GLMatrixAffineF _modelMatrix
 
GlsDisplayObject_topLevelObject
 
GlsDisplayObject_focusObject
 
GlsDisplayObject_dragObject
 
GlsBool _invalidatePickCache
 

Detailed Description

This class manages user input.

Invariant
GLMatrixAffineFIsValid( _projMatrix ) GLMatrixAffineFIsValid( _modelMatrix )

Constructor & Destructor Documentation

GlsInputManager::GlsInputManager ( InitParameters initParameters)
protected

Constructor - create an instance

Parameters
initParametersinitialization parameters
Precondition
initParameters.IsValid()
Postcondition
instance created
virtual GlsInputManager::~GlsInputManager ( )
protectedvirtual

Destructor - shall never be called

Precondition
none
Postcondition
none

Member Function Documentation

static GlsInputManager& GlsInputManager::GetInputManager ( void  )
static

Get the singleton GlsInputManager instance

Returns
the singleton GlsInputManager instance
Precondition
singleton instance must exist ( must have called Initialize() )
Postcondition
none
GlsBool GlsInputManager::HandleEvent ( GlsEvent event)

Handle the given event

Parameters
eventevent in question
Returns
GLS_TRUE if event was handled else GLS_FALSE
Precondition
event.IsValid()
Postcondition
event is handled if return value is GLS_TRUE
static void GlsInputManager::Initialize ( InitParameters initParameters)
static

Initialize (and create) the singleton GlsInputManager instance. Can only be called once

Parameters
initParametersinitialization parameters
Precondition
singleton must not already exist, initParameters.IsValid()
Postcondition
GlsInputManager singleton instance is created and initialized
void GlsInputManager::ProjectPoint ( const GlsVector3D p,
const GlsMatrixAffineD::GLMatrixAffineF drawMatrix,
GlsVector2D projected 
) const

Project the given point into screen coordinates using the given GL draw matrix and the current projection matrix and viewport

Parameters
ppoint in question
drawMatrixGL draw matrix
projected[out] receives projected point in screen coordinates
Precondition
p.IsValid(), GLMatrixAffineFIsValid( drawMatrix )
Postcondition
projected contains p projected into screen space
void GlsInputManager::UpdateModelMatrix ( const GlsMatrixAffineD::GLMatrixAffineF modelMatrix)

Update the input manager with the current top level GL model matrix. Call if/when top level GL model matrix changes from initial model matrix given to Initialize() call.

Parameters
modelMatrixupdated model matrix
Precondition
GLMatrixAffineFIsValid( modelMatrix )
Postcondition
model matrix is updated
void GlsInputManager::UpdateProjectionMatrix ( const GlsMatrixAffineD::GLMatrixAffineF projMatrix)

Update the input manager with the current GL projection matrix. Call if/when GL projection matrix changes from initial projection matrix given to Initialize() call.

Parameters
projMatrixupdated projection matrix
Precondition
GLMatrixAffineFIsValid( projMatrix )
Postcondition
projection matrix is updated
void GlsInputManager::UpdateViewport ( const Viewport viewport)

Update the input manager with the current GL viewport. Call if/when GL viewport changes from initial viewport given to Initialize() call.

Parameters
viewportupdated GL viewport
Precondition
none
Postcondition
view port is updated

Member Data Documentation

GlsDisplayObject* GlsInputManager::_dragObject
protected

current object for dragging else GLS_NULL

GlsDisplayObject* GlsInputManager::_focusObject
protected

current object with focus else GLS_NULL

GlsBool GlsInputManager::_invalidatePickCache
protected

GLS_TRUE if pick cache of top level component needs to be invalidated before the next pick can occur

GlsMatrixAffineD::GLMatrixAffineF GlsInputManager::_modelMatrix
protected

current GL model matrix

GlsMatrixAffineD::GLMatrixAffineF GlsInputManager::_projMatrix
protected

current GL projection matrix

GlsDisplayObject& GlsInputManager::_topLevelObject
protected

top level object receiving input

Viewport GlsInputManager::_viewport
protected

current GL display viewport