GL Studio Safety Critical Embedded C++ Runtime Library
GlsText::UnderlineStrikeThruRenderer Class Reference

#include <gls_text.h>

Classes

struct  LineSegment
 

Public Member Functions

 UnderlineStrikeThruRenderer (const GlsUInt32 numLineSegments, const GlsFloat32 cellWidth, const GlsFloat32 cellHeight, const GlsBool shadow, const GlsFloat32 shadowDistance, const GlsColor &shadowColor, const GlsFloat32 underlineOffset, const GlsFloat32 underlineSize)
 
void SetShadowColor (const GlsColor &shadowColor)
 
void Reset (void)
 
void PreProcessCharacter (const GlsText::CharAttribute &charAttribute, const GlsFloat32 cellX, const GlsFloat32 charY)
 
void PostProcessCharacter (const GlsText::CharAttribute &charAttribute, const GlsFloat32 cellX, const GlsFloat32 charY, const GlsBool endOfLine)
 
void RenderLineSegments (GlsStateManager &gl) const
 
GlsBool IsUpToDate (void) const
 

Protected Member Functions

void DrawScalableLine (GlsStateManager &gl, const GlsFloat32 x1, const GlsFloat32 y1, const GlsFloat32 x2, const GlsFloat32 y2) const
 
 ~UnderlineStrikeThruRenderer ()
 

Protected Attributes

const GlsFloat32 _cellWidth
 
const GlsFloat32 _cellHeight
 
const GlsBool _shadow
 
const GlsFloat32 _shadowDistance
 
GlsColor _shadowColor
 
const GlsFloat32 _underlineOffset
 
const GlsFloat32 _underlineSize
 
GlsFloat32 _underlineX1
 
GlsFloat32 _underlineX2
 
GlsFloat32 _underlineY
 
GlsFloat32 _underlineScale
 
GlsColor _underlineColor
 
GlsBool _underlineOn
 
GlsFloat32 _strikeX1
 
GlsFloat32 _strikeX2
 
GlsFloat32 _strikeY
 
GlsFloat32 _strikeScale
 
GlsColor _strikeColor
 
GlsBool _strikeOn
 
const GlsUInt32 _maxNumLineSegments
 
GlsUInt32 _numLineSegments
 
LineSegment *const _lineSegments
 
GlsBool _isUpToDate
 

Detailed Description

Helper class for processing underline and strike-thru when drawing text

Invariant
GlsFloatIsValid( _cellWidth ), GlsFloatIsValid( _cellHeight ), GlsFloatIsValid( _shadowDistance ), _shadowColor.IsValid(), GlsFloatIsValid( _underlineOffset ), GlsFloatIsValid( _underlineSize ), GlsFloatIsValid( _underlineX1 ), GlsFloatIsValid( _underlineX2 ), GlsFloatIsValid( _underlineY ), GlsFloatIsValid( _underlineScale ), _underlineColor.IsValid(), GlsFloatIsValid( _strikeX1 ), GlsFloatIsValid( _strikeX2 ), GlsFloatIsValid( _strikeY ), GlsFloatIsValid( _strikeScale ), _strikeColor.IsValid(), _maxNumLineSegments > 0u, _numLineSegments <= _maxNumLineSegments, GLS_NULL != _lineSegments, each element in the _lineSegments array is valid

Constructor & Destructor Documentation

GlsText::UnderlineStrikeThruRenderer::UnderlineStrikeThruRenderer ( const GlsUInt32  numLineSegments,
const GlsFloat32  cellWidth,
const GlsFloat32  cellHeight,
const GlsBool  shadow,
const GlsFloat32  shadowDistance,
const GlsColor shadowColor,
const GlsFloat32  underlineOffset,
const GlsFloat32  underlineSize 
)

Constructor - create an instance

Parameters
numLineSegmentsnumber of line segments supported by renderer (>0)
cellWidthwidth of a character cell
cellHeightheight of a character cell
shadowGLS_TRUE if text has shadow enabled else GLS_FALSE
shadowDistancedistance for shadow
shadowColorcolor of shadow
underlineOffsetoffset of underline
underlineSizesize of underline
Precondition
numLineSegments > 0, GlsFloatIsValid() for all floating point arguments, shadowColor.IsValid()
Postcondition
instance created
GlsText::UnderlineStrikeThruRenderer::~UnderlineStrikeThruRenderer ( )
protected

Destructor - shall never be called

Precondition
none
Postcondition
none

Member Function Documentation

void GlsText::UnderlineStrikeThruRenderer::DrawScalableLine ( GlsStateManager gl,
const GlsFloat32  x1,
const GlsFloat32  y1,
const GlsFloat32  x2,
const GlsFloat32  y2 
) const
protected

Draw a line by rendering a filled polygon with a line around it so that the thickness of the line can be varied and antialiasing occurs if enabled

Parameters
glGL state manager to draw into
x1x coord of first corner of the line poly
y1y coord of first corner of the line poly
x2x coord of opposite corner of the line poly
y2y coord of opposite corner of the line poly
Precondition
GlsFloatIsValid( x1 ), GlsFloatIsValid( y1 ), GlsFloatIsValid( x2 ), GlsFloatIsValid( y2 )
Postcondition
line is drawn to OpenGL
GlsBool GlsText::UnderlineStrikeThruRenderer::IsUpToDate ( void  ) const

Determine if the line segments in the renderer are up to date

Precondition
none
Postcondition
none
Returns
GLS_TRUE if the line segments are up to date, GLS_FALSE if the line segments need to be recomputed
void GlsText::UnderlineStrikeThruRenderer::PostProcessCharacter ( const GlsText::CharAttribute charAttribute,
const GlsFloat32  cellX,
const GlsFloat32  charY,
const GlsBool  endOfLine 
)

Post Process the given character attributes

Parameters
charAttributecharacter attribute in question
cellXx coord of character cell one past the given character
charYy coord of character
endOfLineGLS_TRUE if character is the end of the current line else GLS_FALSE
Precondition
charAttribute.IsValid(), GlsFloatIsValid( cellX ), GlsFloatIsValid( charY ), IsUpToDate() == GLS_FALSE
Postcondition
given character attribute is postprocessed for underline / strikethru processing, if endOfLine then IsUpToDate() == GLS_TRUE
void GlsText::UnderlineStrikeThruRenderer::PreProcessCharacter ( const GlsText::CharAttribute charAttribute,
const GlsFloat32  cellX,
const GlsFloat32  charY 
)

Pre Process the given character attribute

Parameters
charAttributecharacter attribute in question
cellXx coord of character
charYy coord of character
Precondition
charAttribute.IsValid(), GlsFloatIsValid( cellX ), GlsFloatIsValid( charY ), IsUpToDate() == GLS_FALSE
Postcondition
given character attribute is preprocessed for underline / strikethru processing
void GlsText::UnderlineStrikeThruRenderer::RenderLineSegments ( GlsStateManager gl) const

Render the line segments for the underline / strikethru

Parameters
glOpenGL state manager to render into
Precondition
none
Postcondition
line segments are rendered to GL
void GlsText::UnderlineStrikeThruRenderer::Reset ( void  )

Invalidate all line segments in the renderer

Precondition
none
Postcondition
all line segments are invalidated, IsUpToDate() == GLS_FALSE
void GlsText::UnderlineStrikeThruRenderer::SetShadowColor ( const GlsColor shadowColor)

Set the shadow color associated with the renderer

Parameters
shadowColornew shadow color
Precondition
shadowColor.IsValid()
Postcondition
renderer has new shadow color

Member Data Documentation

const GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_cellHeight
protected

height of one character cell

const GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_cellWidth
protected

width of one character cell

GlsBool GlsText::UnderlineStrikeThruRenderer::_isUpToDate
protected

GLS_TRUE if _lineSegments is up to date, else GLS_FALSE if the line segments need to be recomputed

LineSegment* const GlsText::UnderlineStrikeThruRenderer::_lineSegments
protected

array of line segments to render ( _maxNumLineSegments number of elements )

const GlsUInt32 GlsText::UnderlineStrikeThruRenderer::_maxNumLineSegments
protected

maximum number of line segments the renderer can hold

GlsUInt32 GlsText::UnderlineStrikeThruRenderer::_numLineSegments
protected

current number of line segments in the _lineSegments array ( <= _maxNumLineSegments )

const GlsBool GlsText::UnderlineStrikeThruRenderer::_shadow
protected

GLS_TRUE if shadowing is enabled else GLS_FALSE

GlsColor GlsText::UnderlineStrikeThruRenderer::_shadowColor
protected

color of shadow

const GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_shadowDistance
protected

distance of shadow line segment from primary line segment

GlsColor GlsText::UnderlineStrikeThruRenderer::_strikeColor
protected

color of next strikethru line segment

GlsBool GlsText::UnderlineStrikeThruRenderer::_strikeOn
protected

GLS_TRUE if strikethru is currently on when processing characters

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_strikeScale
protected

character scaling applied to the next strikethru line segment

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_strikeX1
protected

starting x coord for next strikethru line segment

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_strikeX2
protected

ending x x coord for next strikethru line segment

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_strikeY
protected

y coord for next strikethru line segment

GlsColor GlsText::UnderlineStrikeThruRenderer::_underlineColor
protected

color of next underline line segment

const GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_underlineOffset
protected

offset of underline line segment

GlsBool GlsText::UnderlineStrikeThruRenderer::_underlineOn
protected

GLS_TRUE if underlining is currently on when processing characters

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_underlineScale
protected

character scaling applied to the next underline line segment

const GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_underlineSize
protected

size of underline segment

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_underlineX1
protected

starting x coord for next underline line segment

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_underlineX2
protected

ending x x coord for next underline line segment

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_underlineY
protected

y coord for next underline line segment