38
38
#include <gal/common/graphics_abstraction_layer.h>
39
39
#include <math/vector2d.h>
41
typedef std::deque<POINTS> Glyph;
42
typedef std::deque<Glyph> GlyphList;
41
typedef std::deque<POINTS2D> Glyph;
42
typedef std::deque<Glyph> GlyphList;
44
/// Horizontal justification types
44
45
enum HorizontalJustify
46
HORIZONTAL_JUSTIFY_LEFT = -1, HORIZONTAL_JUSTIFY_CENTER = 0, HORIZONTAL_JUSTIFY_RIGHT = 1
47
HORIZONTAL_JUSTIFY_LEFT = -1, ///< Left justified
48
HORIZONTAL_JUSTIFY_CENTER = 0, ///< Centered
49
HORIZONTAL_JUSTIFY_RIGHT = 1 ///< Right justified
52
/// Vertical justification types
50
53
enum VerticalJustify
52
VERTICAL_JUSTIFY_TOP = -1, VERTICAL_JUSTIFY_CENTER = 0, VERTICAL_JUSTIFY_BOTTOM = 1
55
VERTICAL_JUSTIFY_TOP = -1, ///< Top justified
56
VERTICAL_JUSTIFY_CENTER = 0, ///< Centered
57
VERTICAL_JUSTIFY_BOTTOM = 1 ///< Bottom justified
61
* @brief Class STROKE_FONT implements stroke font drawing.
63
* A stroke font is composed of lines.
63
virtual ~STROKE_FONT();
65
74
// TODO Load font from a text file
67
//! @brief Load the new stroke font
68
//! @param newStrokeFont Pointer to the font data
69
//! @param newStrokeFontSize Size of the font data
77
* @brief Load the new stroke font.
79
* @param aNewStrokeFont is the pointer to the font data.
80
* @param aNewStrokeFontSize is the size of the font data.
81
* @return True, if the font was successfully loaded, else false.
70
83
bool LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNewStrokeFontSize );
72
//! @brief Draw a string
73
//! @param text The text to be drawn
74
//! @param position Text position in world coordinates
75
//! @param rotationAngle Text rotation angle
76
void Draw( std::string aText, POINT aPosition, double aRotationAngle );
86
* @brief Draw a string.
88
* @param aText is the text to be drawn.
89
* @param aPosition is the text position in world coordinates.
90
* @param aRotationAngle is the text rotation angle.
92
void Draw( std::string aText, POINT2D aPosition, double aRotationAngle );
78
//! @brief Set the Graphics Abstraction Layer
79
//! @param gal Pointer to the Graphics Abstraction Layer to draw the text
95
* @brief Set the Graphics Abstraction Layer.
97
* @param aGal is the pointer to the Graphics Abstraction Layer to draw the text.
80
99
void SetGraphicsAbstractionLayer( GRAPHICS_ABSTRACTION_LAYER* aGal );
82
//! @brief Set the scale factor of the font for the glyph size
83
//! @param scaleFactor The scale factor
102
* @brief Set the scale factor of the font for the glyph size.
104
* @param aScaleFactor is the scale factor of the font.
84
106
void SetScaleFactor( const double aScaleFactor );
86
//! @brief Set the glyph size
87
//! @param glyphSize The glyph size
88
void SetGlyphSize( VECTOR2D aGlyphSize );
90
void SetHorizontalJustify( HorizontalJustify aHorizontalJustify );
91
void SetVerticalJustify( VerticalJustify aVerticalJustify );
109
* @brief Set the glyph size.
111
* @param aGlyphSize is the glyph size.
113
inline void SetGlyphSize( VECTOR2D aGlyphSize )
115
glyphSize = aGlyphSize;
119
* @brief Set the horizontal justify for text drawing.
121
* @param aHorizontalJustify is the horizontal justify value.
123
inline void SetHorizontalJustify( HorizontalJustify aHorizontalJustify )
125
horizontalJustify = aHorizontalJustify;
129
* @brief Set the vertical justify for text drawing.
131
* @param aVerticalJustify is the vertical justify value.
133
inline void SetVerticalJustify( VerticalJustify aVerticalJustify )
135
verticalJustify = aVerticalJustify;
95
std::deque<BoundingBox> m_glyphBoundingBoxes;
97
GRAPHICS_ABSTRACTION_LAYER* m_gal;
101
VECTOR2D m_glyphSize;
102
HorizontalJustify m_horizontalJustify;
103
VerticalJustify m_verticalJustify;
105
BoundingBox computeBoundingBox( Glyph aGlyph, VECTOR2D aGlyphBoundingX );
139
GRAPHICS_ABSTRACTION_LAYER* graphics; ///< Pointer to the GAL
141
GlyphList glyphs; ///< Glyph list
142
std::deque<BOUNDING_BOX> glyphBoundingBoxes; ///< Bounding boxes of the glyphs
143
double scaleFactor; ///< Scale factor for the glyph
144
VECTOR2D glyphSize; ///< Size of the glyphs
145
HorizontalJustify horizontalJustify; ///< Horizontal justification
146
VerticalJustify verticalJustify; ///< Vertical justification
149
* @brief Compute the bounding box of a given glyph.
151
* @param aGlyph is the glyph.
152
* @param aGlyphBoundingX is the x-component of the bounding box size.
153
* @return is the complete bounding box size.
155
BOUNDING_BOX computeBoundingBox( Glyph aGlyph, VECTOR2D aGlyphBoundingX );
158
* @brief Compute the size of a given text.
160
* @param aText is the text string.
161
* @return is the text size.
106
163
VECTOR2D computeTextSize( std::string aText );