GL Studio Safety Critical Embedded C++ Runtime Library
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
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

◆ UnderlineStrikeThruRenderer()

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

◆ ~UnderlineStrikeThruRenderer()

GlsText::UnderlineStrikeThruRenderer::~UnderlineStrikeThruRenderer ( )
protected

Destructor - shall never be called

Precondition
none
Postcondition
none

Member Function Documentation

◆ DrawScalableLine()

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

◆ IsUpToDate()

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

◆ PostProcessCharacter()

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

◆ PreProcessCharacter()

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

◆ RenderLineSegments()

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

◆ Reset()

void GlsText::UnderlineStrikeThruRenderer::Reset ( void  )

Invalidate all line segments in the renderer

Precondition
none
Postcondition
all line segments are invalidated, IsUpToDate() == GLS_FALSE

◆ SetShadowColor()

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

◆ _cellHeight

const GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_cellHeight
protected

height of one character cell

◆ _cellWidth

const GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_cellWidth
protected

width of one character cell

◆ _isUpToDate

GlsBool GlsText::UnderlineStrikeThruRenderer::_isUpToDate
protected

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

◆ _lineSegments

LineSegment* const GlsText::UnderlineStrikeThruRenderer::_lineSegments
protected

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

◆ _maxNumLineSegments

const GlsUInt32 GlsText::UnderlineStrikeThruRenderer::_maxNumLineSegments
protected

maximum number of line segments the renderer can hold

◆ _numLineSegments

GlsUInt32 GlsText::UnderlineStrikeThruRenderer::_numLineSegments
protected

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

◆ _shadow

const GlsBool GlsText::UnderlineStrikeThruRenderer::_shadow
protected

GLS_TRUE if shadowing is enabled else GLS_FALSE

◆ _shadowColor

GlsColor GlsText::UnderlineStrikeThruRenderer::_shadowColor
protected

color of shadow

◆ _shadowDistance

const GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_shadowDistance
protected

distance of shadow line segment from primary line segment

◆ _strikeColor

GlsColor GlsText::UnderlineStrikeThruRenderer::_strikeColor
protected

color of next strikethru line segment

◆ _strikeOn

GlsBool GlsText::UnderlineStrikeThruRenderer::_strikeOn
protected

GLS_TRUE if strikethru is currently on when processing characters

◆ _strikeScale

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_strikeScale
protected

character scaling applied to the next strikethru line segment

◆ _strikeX1

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_strikeX1
protected

starting x coord for next strikethru line segment

◆ _strikeX2

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_strikeX2
protected

ending x x coord for next strikethru line segment

◆ _strikeY

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_strikeY
protected

y coord for next strikethru line segment

◆ _underlineColor

GlsColor GlsText::UnderlineStrikeThruRenderer::_underlineColor
protected

color of next underline line segment

◆ _underlineOffset

const GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_underlineOffset
protected

offset of underline line segment

◆ _underlineOn

GlsBool GlsText::UnderlineStrikeThruRenderer::_underlineOn
protected

GLS_TRUE if underlining is currently on when processing characters

◆ _underlineScale

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_underlineScale
protected

character scaling applied to the next underline line segment

◆ _underlineSize

const GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_underlineSize
protected

size of underline segment

◆ _underlineX1

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_underlineX1
protected

starting x coord for next underline line segment

◆ _underlineX2

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_underlineX2
protected

ending x x coord for next underline line segment

◆ _underlineY

GlsFloat32 GlsText::UnderlineStrikeThruRenderer::_underlineY
protected

y coord for next underline line segment