GL Studio Safety Critical Embedded C++ Runtime Library
GlsComponentBase Class Referenceabstract

#include <gls_component_base.h>

+ Inheritance diagram for GlsComponentBase:

Classes

struct  InitParameters
 

Public Member Functions

virtual void Initialize (void)=0
 
void SetClipPlanes (const GlsVector3D &lowerFarLeft, const GlsVector3D &upperNearRight)
 
virtual void Draw (GlsStateManager &gl, const GlsFloat64 time)
 
virtual void Calculate (const GlsFloat64 time)
 
virtual GlsDisplayObjectPickTest (const GlsVector2D &windowCoord, GlsInputManager &inputManager, const GlsMatrixAffineD::GLMatrixAffineF &parentDrawMatrix)
 
virtual void SetChildrenAlphaMode (const GlsAlphaMode alphaMode)
 
virtual void SetChildrenFillColor (const GlsColor &fillColor)
 
virtual void SetChildrenLineColor (const GlsColor &lineColor)
 
virtual void SetChildrenLineWidth (const GlsFloat32 lineWidth)
 
virtual void SetChildrenPolygonMode (const GlsPolygonMode polygonMode)
 
- Public Member Functions inherited from GlsDisplayObject
GlsDisplayObjectHandleEvent (GlsEvent &event)
 
ObjectType GetObjectType (void) const
 
void SetBlinking (const GlsBool blinking)
 
void SetBlinkRate (const GlsFloat32 blinkRate)
 
void SetDynamicRotation (const GlsVector3D &dynamicRotation)
 
void SetDynamicScale (const GlsVector3D &dynamicScale)
 
void SetDynamicTranslation (const GlsVector3D &dynamicTranslation)
 
void SetVisibility (const GlsBool visible)
 
void SetParent (GlsDisplayObject *const parent)
 
void SetPickMode (const PickMode pickMode)
 
GlsBool NeedCalculate (void) const
 
void InvalidatePickCache (void)
 

Protected Types

enum  {
  CLIP_PLANE_LEFT = 0u, CLIP_PLANE_RIGHT, CLIP_PLANE_TOP, CLIP_PLANE_BOTTOM,
  CLIP_PLANE_FRONT, CLIP_PLANE_BACK, NUM_CLIP_PLANES
}
 
enum  {
  PLANE_EQN_COEFF_A = 0u, PLANE_EQN_COEFF_B, PLANE_EQN_COEFF_C, PLANE_EQN_COEFF_D,
  NUM_PLANE_COEFF
}
 

Protected Member Functions

 GlsComponentBase (const InitParameters &initParameters, GlsEventDispatcher *const eventDispatcher)
 
void ActivateClipPlanes (void) const
 
void DeactivateClipPlanes (void) const
 
virtual GlsDisplayObjectArrayGetObjects (void)=0
 
virtual ~GlsComponentBase ()
 
- Protected Member Functions inherited from GlsCompositeObject
 GlsCompositeObject (const InitParameters &initParameters, GlsEventDispatcher *const eventDispatcher)
 
virtual ~GlsCompositeObject ()
 
- Protected Member Functions inherited from GlsDisplayObject
 GlsDisplayObject (const InitParameters &initParameters, const ObjectType objectType, GlsEventDispatcher *const eventDispatcher)
 
virtual ~GlsDisplayObject ()
 
GlsBool CalcDrawMatrix (const GlsMatrixAffineD *const additionalTransform, const GlsBool includeLocation)
 
virtual void CalcWindowPickRegion (GlsInputManager &inputManager, const GlsMatrixAffineD::GLMatrixAffineF &parentDrawMatrix)
 
GlsBool IsBlinkedOff (const GlsFloat64 time) const
 

Protected Attributes

GlsMatrixAffineD _componentTransformMatrix
 
GlsBool _clippingEnabled
 
GLdouble _clipPlanes [NUM_CLIP_PLANES][NUM_PLANE_COEFF]
 
- Protected Attributes inherited from GlsDisplayObject
const GlsMatrixAffineD _dcsMatrix
 
const GlsMatrixAffineD _dcsMatrixInverse
 
const GlsBool _dcsMatrixIsIdentity
 
const GlsVector3D _location
 
const GlsBool _needCalculate
 
const ObjectType _objectType
 
const PickRegion _pickRegion
 
GlsEventDispatcher *const _eventDispatcher
 
const GlsVector3D _rotationPoint
 
GlsBool _blinking
 
GlsFloat32 _blinkRate
 
GlsMatrixAffineD::GLMatrixAffineF _drawMatrix
 
GlsVector3D _dynamicRotation
 
GlsVector3D _dynamicScale
 
GlsBool _dynamicScaleIsUnity
 
GlsVector3D _dynamicTranslation
 
GlsBool _needCalcDrawMatrix
 
GlsBool _visible
 
PickMode _pickMode
 
GlsBool _windowPickRegionValid
 
GlsVector2D _windowPickLowerLeft
 
GlsVector2D _windowPickUpperRight
 
GlsVector2D _windowPickUpperLeft
 
GlsVector2D _windowPickLowerRight
 
GlsMatrixAffineD::GLMatrixAffineF _pickMatrix
 
GlsDisplayObject_parent
 

Additional Inherited Members

- Public Types inherited from GlsDisplayObject
enum  ObjectType { OBJECT_TYPE_COMPOSITE, OBJECT_TYPE_RENDERABLE }
 
enum  PickMode { PICK_MODE_NEVER, PICK_MODE_FIRST, PICK_MODE_ALWAYS }
 

Detailed Description

This class serves as an abstract base class for all user derived display components.

Invariant
base class invariant holds, _componentTransformMatrix invariant holds, _clipPlanes array has valid elements

Member Enumeration Documentation

anonymous enum
protected

desribes available clip planes

Enumerator
CLIP_PLANE_LEFT 
CLIP_PLANE_RIGHT 
CLIP_PLANE_TOP 
CLIP_PLANE_BOTTOM 
CLIP_PLANE_FRONT 
CLIP_PLANE_BACK 
NUM_CLIP_PLANES 
anonymous enum
protected

describes clip plane eqn coefficients

Enumerator
PLANE_EQN_COEFF_A 
PLANE_EQN_COEFF_B 
PLANE_EQN_COEFF_C 
PLANE_EQN_COEFF_D 
NUM_PLANE_COEFF 

Constructor & Destructor Documentation

GlsComponentBase::GlsComponentBase ( const InitParameters initParameters,
GlsEventDispatcher *const  eventDispatcher 
)
protected

Constructor - create an instance, can only be called by a derived class

Parameters
initParametersinitialization parameters
eventDispatcherevent dispatcher for this object else GLS_NULL
Precondition
initParameters.IsValid()
Postcondition
instance created
virtual GlsComponentBase::~GlsComponentBase ( )
protectedvirtual

Destructor - shall never be called

Precondition
none
Postcondition
none

Member Function Documentation

void GlsComponentBase::ActivateClipPlanes ( void  ) const
protected

Activate the GL clip planes described by _clipPlanes

Precondition
none of the GL clip planes are activated
Postcondition
GL clip planes described _clipPlanes are activated
virtual void GlsComponentBase::Calculate ( const GlsFloat64  time)
virtual

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 contained objects

Reimplemented from GlsDisplayObject.

void GlsComponentBase::DeactivateClipPlanes ( void  ) const
protected

Deactivate the GL clip planes

Precondition
none
Postcondition
GL clip planes are deactivated
virtual void GlsComponentBase::Draw ( GlsStateManager gl,
const GlsFloat64  time 
)
virtual

Draws the component

Parameters
glGL State manager for OpenGL into which object is drawn
timethe elaspsed time in seconds since program start
Precondition
time >= 0.0
Postcondition
component drawn to OpenGL if visible and not blinked off

Implements GlsDisplayObject.

virtual GlsDisplayObjectArray& GlsComponentBase::GetObjects ( void  )
protectedpure virtual

Get the object array that contains all of the objects in the component

Returns
the object array that contains all of the objects in the component
Precondition
none
Postcondition
none
virtual void GlsComponentBase::Initialize ( void  )
pure virtual

Called after objects in the component are created. This allows a derived class to have custom initialization code.

Precondition
none
Postcondition
custom initialization (if any) is complete
virtual GlsDisplayObject* GlsComponentBase::PickTest ( const GlsVector2D windowCoord,
GlsInputManager inputManager,
const GlsMatrixAffineD::GLMatrixAffineF parentDrawMatrix 
)
virtual

Perform a pick test of the given point in window coordinates against this object

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

Reimplemented from GlsDisplayObject.

virtual void GlsComponentBase::SetChildrenAlphaMode ( const GlsAlphaMode  alphaMode)
virtual

Set the alpha mode of the contained objects

Parameters
alphaModedesired alpha mode
Precondition
GlsAlphaModeIsValid( alphaMode )
Postcondition
contained objects have new alpha mode

Implements GlsCompositeObject.

virtual void GlsComponentBase::SetChildrenFillColor ( const GlsColor fillColor)
virtual

Set the fill color of the contained objects

Parameters
fillColordesired fill color
Precondition
fillColor.IsValid()
Postcondition
contained objects have new fill color

Implements GlsCompositeObject.

virtual void GlsComponentBase::SetChildrenLineColor ( const GlsColor lineColor)
virtual

Set the line color of the contained objects

Parameters
lineColordesired line color
Precondition
lineColor.IsValid()
Postcondition
contained objects have new line color

Implements GlsCompositeObject.

virtual void GlsComponentBase::SetChildrenLineWidth ( const GlsFloat32  lineWidth)
virtual

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

Implements GlsCompositeObject.

virtual void GlsComponentBase::SetChildrenPolygonMode ( const GlsPolygonMode  polygonMode)
virtual

Set the polygon mode of the contained objects

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

Implements GlsCompositeObject.

void GlsComponentBase::SetClipPlanes ( const GlsVector3D lowerFarLeft,
const GlsVector3D upperNearRight 
)

Enable and configure the six clipping planes ( left, right, top, bottom, front, back ) against which the component will be clipped when rendered. The clipping planes are defined by the 3D box described by the given points.

Parameters
lowerFarLeftlower far left side point of 3D box describing clip planes
upperNearRightupper near right side point of 3D box describing clip planes
Precondition
lowerFarLeft.IsValid(), upperNearRight.IsValid(), no child of this component can have its clip planes enabled
Postcondition
the component will be clipped against the clip planes described by the given points when drawn

Member Data Documentation

GlsBool GlsComponentBase::_clippingEnabled
protected

GLS_TRUE if clipping is enabled when drawing else GLS_FALSE

GLdouble GlsComponentBase::_clipPlanes[NUM_CLIP_PLANES][NUM_PLANE_COEFF]
protected

plane equation coefficients for each plane

GlsMatrixAffineD GlsComponentBase::_componentTransformMatrix
protected

The static transformation from the internal component coordinates to the parent's coordinate system. the rotation, and scaling that the parent did to this component, including translation for _location