EMAN2
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
EMAN::EMFTGL Class Reference

EMFTGL is an interface for rendering fonts in EMAN2 using FTGL. More...

#include <emftgl.h>

Collaboration diagram for EMAN::EMFTGL:
Collaboration graph
[legend]

Classes

class  EMFTGLFontInstance
 A class for encapsulatiing a particular instance of an FTFont (pointer) Each FTFont is characterised by 5 parameters, them being the font mode, the font file name, the face size, whether or not display lists are being used, and depth (which is redundant, except when the font mode is EXTRUDE). More...
 
class  EMFTGLManager
 A class for managing multiple instances of EMFTGLFontInstances, in particular for caching them, for constructing news ones if they don't exist, and for returning appropriate instances. More...
 

Public Types

enum  FontMode {
  EXTRUDE , PIXMAP , TEXTURE , BITMAP ,
  OUTLINE , POLYGON
}
 FontModes correspond to the different FTFont types - this correspondence is EXTRUDE - FTGLExtrdFont, PIXMAP - FTGLPixmapFont TEXTURE - FTGLTextureFont, BITMAP - FTGLBitmapFont OUTLINE - FTGLOutlineFont, POLYGON - FTGLPolygonFont. More...
 

Public Member Functions

 EMFTGL ()
 Constructor is OS dependent - it attempts to reference an Operating System specific fonts file by default. More...
 
 ~EMFTGL ()
 Destructor. More...
 
void render_string (const string &message)
 Render string performs OpenGL rendering of the string using the current state variables of this class. More...
 
vector< float > bounding_box (const string &message)
 Obtains the bounding box of the given message, as would be rendered using the current state variables of this class. More...
 
void set_font_file_name (const string &file_name)
 Set the font file name - should be a .ttf file. More...
 
void set_face_size (const unsigned int size)
 Set the face size of the rendered text. More...
 
void set_depth (const unsigned int d)
 Set the depth of the rendered text - only useful if this->mode = EXTRUDE. More...
 
void set_using_display_lists (const bool b)
 Set whether or not the font render should be using display lists. More...
 
void set_font_mode (const FontMode m)
 Set the font mode. More...
 
string get_font_file_name ()
 Get the name of the current font file in use. More...
 
unsigned int get_face_size ()
 Get the currently used face size. More...
 
unsigned int get_depth ()
 Get the currently used depth. More...
 
bool get_using_display_lists ()
 Get whether or not font renderer is currently using display lists. More...
 
FontMode get_font_mode ()
 Get the current font mode. More...
 

Private Attributes

string font_file_name
 Disallow copy construction. More...
 
unsigned int face_size
 
unsigned int depth
 
bool use_display_lists
 
FontMode mode
 
EMFTGLManager fm
 

Detailed Description

EMFTGL is an interface for rendering fonts in EMAN2 using FTGL.

The EMFTGL has an instance of an EMFTGLFontManager which caches FTFonts. Internally, everytime the EMFTGL is asked to render or obtain bounding boxes, it asks its EMFTGLFontManager for an FTFont pointer usng the the current state of all member variables. The EMFTGLFontManager may already have the correct FTFont, or it may have to construct it (and store it for later use, if necessary).

The EMFTGL class is defined in terms of 5 things, them being the font size, whether or not display lists are being used (in FTGL), the font file itself (a .ttf file), the mode of font rendering (TEXTURE, BITMAP etc), and the depth (which is only applicable when the font mode is EXTRUDE in terms of FTGL). These five parameter act as an index when asking the EMFTGLFontManager for the FTFont

The EMFTGLFontManager is intentionally not static - this is because in EMAN2 it is possible to be rendering accross multiple OpenGL contexts. When the EMFTGL destructor is called the associated EMFTGLFontsManager is destroyed all with all of its previously stored FTFont pointers.

Author
David Woolford
Date
July 2008

Definition at line 71 of file emftgl.h.

Member Enumeration Documentation

◆ FontMode

FontModes correspond to the different FTFont types - this correspondence is EXTRUDE - FTGLExtrdFont, PIXMAP - FTGLPixmapFont TEXTURE - FTGLTextureFont, BITMAP - FTGLBitmapFont OUTLINE - FTGLOutlineFont, POLYGON - FTGLPolygonFont.

Enumerator
EXTRUDE 
PIXMAP 
TEXTURE 
BITMAP 
OUTLINE 
POLYGON 

Definition at line 98 of file emftgl.h.

98 {
99 EXTRUDE,
100 PIXMAP,
101 TEXTURE,
102 BITMAP,
103 OUTLINE,
104 POLYGON
105 };

Constructor & Destructor Documentation

◆ EMFTGL()

EMAN::EMFTGL::EMFTGL ( )
inline

Constructor is OS dependent - it attempts to reference an Operating System specific fonts file by default.

Definition at line 83 of file emftgl.h.

83: font_file_name("/usr/share/fonts/dejavu/DejaVuSerif.ttf"), face_size(32), depth(32), use_display_lists(true), mode(TEXTURE) {};
unsigned int depth
Definition: emftgl.h:167
FontMode mode
Definition: emftgl.h:170
string font_file_name
Disallow copy construction.
Definition: emftgl.h:165
bool use_display_lists
Definition: emftgl.h:168
unsigned int face_size
Definition: emftgl.h:166

◆ ~EMFTGL()

EMAN::EMFTGL::~EMFTGL ( )
inline

Destructor.

Definition at line 90 of file emftgl.h.

90{};

Member Function Documentation

◆ bounding_box()

vector< float > EMAN::EMFTGL::bounding_box ( const string &  message)

Obtains the bounding box of the given message, as would be rendered using the current state variables of this class.

Parameters
messagethe string that will be used to calculate the bounding box
Returns
a vector of length 6 containing the values [x1,y1,z1,x2,y2,z2] which define the 2 points of the bounding box extremes

◆ get_depth()

unsigned int EMAN::EMFTGL::get_depth ( )
inline

Get the currently used depth.

Definition at line 149 of file emftgl.h.

149{ return depth; }

References depth.

◆ get_face_size()

unsigned int EMAN::EMFTGL::get_face_size ( )
inline

Get the currently used face size.

Definition at line 146 of file emftgl.h.

146{return face_size; }

References face_size.

◆ get_font_file_name()

string EMAN::EMFTGL::get_font_file_name ( )
inline

Get the name of the current font file in use.

Definition at line 143 of file emftgl.h.

143{ return font_file_name; }

References font_file_name.

◆ get_font_mode()

FontMode EMAN::EMFTGL::get_font_mode ( )
inline

Get the current font mode.

Definition at line 155 of file emftgl.h.

155{ return mode; }

References mode.

◆ get_using_display_lists()

bool EMAN::EMFTGL::get_using_display_lists ( )
inline

Get whether or not font renderer is currently using display lists.

Definition at line 152 of file emftgl.h.

152{ return use_display_lists; }

References use_display_lists.

◆ render_string()

void EMAN::EMFTGL::render_string ( const string &  message)

Render string performs OpenGL rendering of the string using the current state variables of this class.

Parameters
messagethe string to render

◆ set_depth()

void EMAN::EMFTGL::set_depth ( const unsigned int  d)
inline

Set the depth of the rendered text - only useful if this->mode = EXTRUDE.

Definition at line 132 of file emftgl.h.

132{ depth = d; }

References depth.

◆ set_face_size()

void EMAN::EMFTGL::set_face_size ( const unsigned int  size)
inline

Set the face size of the rendered text.

Parameters
sizethe face size of the rendered text

Definition at line 128 of file emftgl.h.

128{ face_size = size; }

References face_size.

◆ set_font_file_name()

void EMAN::EMFTGL::set_font_file_name ( const string &  file_name)
inline

Set the font file name - should be a .ttf file.

Parameters
file_namethe font file name - should be a .ttf file

Definition at line 123 of file emftgl.h.

123{ font_file_name = file_name; }

References font_file_name.

◆ set_font_mode()

void EMAN::EMFTGL::set_font_mode ( const FontMode  m)
inline

Set the font mode.

Definition at line 140 of file emftgl.h.

140{ mode = m; }

References mode.

◆ set_using_display_lists()

void EMAN::EMFTGL::set_using_display_lists ( const bool  b)
inline

Set whether or not the font render should be using display lists.

Definition at line 136 of file emftgl.h.

136{ use_display_lists = b; }

References use_display_lists.

Member Data Documentation

◆ depth

unsigned int EMAN::EMFTGL::depth
private

Definition at line 167 of file emftgl.h.

Referenced by get_depth(), and set_depth().

◆ face_size

unsigned int EMAN::EMFTGL::face_size
private

Definition at line 166 of file emftgl.h.

Referenced by get_face_size(), and set_face_size().

◆ fm

EMFTGLManager EMAN::EMFTGL::fm
private

Definition at line 234 of file emftgl.h.

◆ font_file_name

string EMAN::EMFTGL::font_file_name
private

Disallow copy construction.

Disallow Assignment

Definition at line 165 of file emftgl.h.

Referenced by get_font_file_name(), and set_font_file_name().

◆ mode

FontMode EMAN::EMFTGL::mode
private

Definition at line 170 of file emftgl.h.

Referenced by get_font_mode(), and set_font_mode().

◆ use_display_lists

bool EMAN::EMFTGL::use_display_lists
private

Definition at line 168 of file emftgl.h.

Referenced by get_using_display_lists(), and set_using_display_lists().


The documentation for this class was generated from the following file: