GL Studio Safety Critical Embedded C++ Runtime Library
GlsDisplayObjectArray Class Reference

#include <gls_display_object_array.h>

Classes

struct  InitParameters
 

Public Member Functions

 GlsDisplayObjectArray (InitParameters &initParameters)
 
virtual ~GlsDisplayObjectArray ()
 
void Draw (GlsStateManager &gl, const GlsFloat64 time)
 
void Calculate (const GlsFloat64 time)
 
GlsDisplayObjectPickChildrenTest (const GlsVector2D &windowCoord, GlsInputManager &inputManager, const GlsMatrixAffineD::GLMatrixAffineF &parentDrawMatrix)
 
void SetChildrenAlphaMode (const GlsAlphaMode alphaMode)
 
void SetChildrenFillColor (const GlsColor &fillColor)
 
void SetChildrenLineColor (const GlsColor &lineColor)
 
void SetChildrenLineWidth (const GlsFloat32 lineWidth)
 
void SetChildrenPolygonMode (const GlsPolygonMode polygonMode)
 
void SetChildrenParent (GlsDisplayObject *const parent)
 
void InvalidateChildrenPickCache (void)
 
GlsUInt32 GetSize (void) const
 
GlsDisplayObjectGetObject (const GlsUInt32 index)
 

Protected Attributes

GlsPointerArray _objects
 
GlsBool _needCalculate
 

Detailed Description

This class encapsulates an array of display objects and allows operations to be performed on all of the entries in the array

Invariant
_objects.Invariant(), there are no null pointers in the array, the invariant holds for all objects in the array

Constructor & Destructor Documentation

GlsDisplayObjectArray::GlsDisplayObjectArray ( InitParameters initParameters)

Constructor - create an instance

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

Destructor - shall never be called

Precondition
none
Postcondition
none

Member Function Documentation

void GlsDisplayObjectArray::Calculate ( const GlsFloat64  time)

Provides a mechanism for performing regular calculations, separate from drawing.

Parameters
timeThe elaspsed time in seconds since program start
Precondition
time >= 0.0
Postcondition
calculations (if any) completed for all objects in array
void GlsDisplayObjectArray::Draw ( GlsStateManager gl,
const GlsFloat64  time 
)

Draws the objects in the array.

Parameters
glGL State manager for OpenGL into which object is drawn
timethe elaspsed time in seconds since program start
Precondition
time >= 0.0
Postcondition
contained objects are drawn to OpenGL if visible and not blinked off
GlsDisplayObject& GlsDisplayObjectArray::GetObject ( const GlsUInt32  index)

get a ref to the display object at the given index

Parameters
indexindex of desired object ( index < _objects.GetSize() )
Returns
ref to display object at given index
Precondition
index < _objects.GetSize()
Postcondition
none
GlsUInt32 GlsDisplayObjectArray::GetSize ( void  ) const

Get the number of display objects in the array

Returns
number of display objects in the array
Precondition
none
Postcondition
none
void GlsDisplayObjectArray::InvalidateChildrenPickCache ( void  )

Invalidate cached picking screen coordinates for contained objects

Precondition
none
Postcondition
cached screen picking coordinates are marked invalid for children
GlsDisplayObject* GlsDisplayObjectArray::PickChildrenTest ( const GlsVector2D windowCoord,
GlsInputManager inputManager,
const GlsMatrixAffineD::GLMatrixAffineF parentDrawMatrix 
)

Perform a pick test of the given point in window coordinates against the contained objects

Parameters
windowCoordpoint in question
inputManagerinput manager managing input for this object
parentDrawMatrixdraw matrix used when rendering parent object
Returns
object that is picked by given window coordinate else GLS_NULL
Precondition
windowCoord.IsValid(), GLMatrixAffineFIsValid( parentDrawMatrix )
Postcondition
none
void GlsDisplayObjectArray::SetChildrenAlphaMode ( const GlsAlphaMode  alphaMode)

Set the alpha mode of the contained objects

Parameters
alphaModedesired alpha mode
Precondition
GlsAlphaModeIsValid( alphaMode )
Postcondition
contained objects have new alpha mode
void GlsDisplayObjectArray::SetChildrenFillColor ( const GlsColor fillColor)

Set the fill color of the contained objects

Parameters
fillColordesired fill color
Precondition
fillColor.IsValid()
Postcondition
contained objects have new fill color
void GlsDisplayObjectArray::SetChildrenLineColor ( const GlsColor lineColor)

Set the line color of the contained objects

Parameters
lineColordesired line color
Precondition
lineColor.IsValid()
Postcondition
contained objects have new line color
void GlsDisplayObjectArray::SetChildrenLineWidth ( const GlsFloat32  lineWidth)

Set the line width of the contained objects

Parameters
lineWidthnew line width, GlsRenderObject::LINE_WIDTH_MIN <= lineWidth <= GlsRenderObject::LINE_WIDTH_MAX
Precondition
GlsLineWidthIsValid( lineWidth )
Postcondition
contained objects have new line width
void GlsDisplayObjectArray::SetChildrenParent ( GlsDisplayObject *const  parent)

Set the parent of the contained objects

Parameters
parentparent of contained objects
Precondition
parent != GLS_NULL
Postcondition
contained objects have new parent
void GlsDisplayObjectArray::SetChildrenPolygonMode ( const GlsPolygonMode  polygonMode)

Set the polygon mode of the contained objects

Parameters
polygonModenew polygon mode
Precondition
GlsPolygonModeIsValid( polygonMode )
Postcondition
contained objects have new polygon mode

Member Data Documentation

GlsBool GlsDisplayObjectArray::_needCalculate
protected

GLS_TRUE if any of the objects needs its Calculate() method called, else GLS_FALSE

GlsPointerArray GlsDisplayObjectArray::_objects
protected

array of display object pointers