Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File 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]
List of all members.

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.
 ~EMFTGL ()
 Destructor.
void render_string (const string &message)
 Render string performs OpenGL rendering of the string using the current state variables of this class.
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.
void set_font_file_name (const string &file_name)
 Set the font file name - should be a .ttf file.
void set_face_size (const unsigned int size)
 Set the face size of the rendered text.
void set_depth (const unsigned int d)
 Set the depth of the rendered text - only useful if this->mode = EXTRUDE.
void set_using_display_lists (const bool b)
 Set whether or not the font render should be using display lists.
void set_font_mode (const FontMode m)
 Set the font mode.
string get_font_file_name ()
 Get the name of the current font file in use.
unsigned int get_face_size ()
 Get the currently used face size.
unsigned int get_depth ()
 Get the currently used depth.
bool get_using_display_lists ()
 Get whether or not font renderer is currently using display lists.
FontMode get_font_mode ()
 Get the current font mode.

Private Attributes

string font_file_name
 Disallow Assignment.
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 81 of file emftgl.h.


Member Enumeration Documentation

enum EMAN::EMFTGL::FontMode
 

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

Enumeration values:
EXTRUDE 
PIXMAP 
TEXTURE 
BITMAP 
OUTLINE 
POLYGON 

Definition at line 108 of file emftgl.h.

00108                               {
00109                         EXTRUDE,
00110                         PIXMAP,
00111                         TEXTURE,
00112                         BITMAP,
00113                         OUTLINE,
00114                         POLYGON
00115                 };


Constructor & Destructor Documentation

EMAN::EMFTGL::EMFTGL  )  [inline]
 

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

Definition at line 93 of file emftgl.h.

00093 : font_file_name("/usr/share/fonts/dejavu/DejaVuSerif.ttf"), face_size(32), depth(32), use_display_lists(true), mode(TEXTURE) {};

EMAN::EMFTGL::~EMFTGL  )  [inline]
 

Destructor.

Definition at line 100 of file emftgl.h.

00100 {};


Member Function Documentation

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:
message the 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

unsigned int EMAN::EMFTGL::get_depth  )  [inline]
 

Get the currently used depth.

Definition at line 159 of file emftgl.h.

00159 { return depth; }

unsigned int EMAN::EMFTGL::get_face_size  )  [inline]
 

Get the currently used face size.

Definition at line 156 of file emftgl.h.

00156 {return face_size; }

string EMAN::EMFTGL::get_font_file_name  )  [inline]
 

Get the name of the current font file in use.

Definition at line 153 of file emftgl.h.

00153 { return font_file_name; }

FontMode EMAN::EMFTGL::get_font_mode  )  [inline]
 

Get the current font mode.

Definition at line 165 of file emftgl.h.

00165 { return mode; }

bool EMAN::EMFTGL::get_using_display_lists  )  [inline]
 

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

Definition at line 162 of file emftgl.h.

00162 { return use_display_lists; }

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:
message the string to render

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 142 of file emftgl.h.

00142 { depth = d; }

void EMAN::EMFTGL::set_face_size const unsigned int  size  )  [inline]
 

Set the face size of the rendered text.

Parameters:
size the face size of the rendered text

Definition at line 138 of file emftgl.h.

00138 { face_size = size; }

void EMAN::EMFTGL::set_font_file_name const string &  file_name  )  [inline]
 

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

Parameters:
file_name the font file name - should be a .ttf file

Definition at line 133 of file emftgl.h.

00133 { font_file_name = file_name; }

void EMAN::EMFTGL::set_font_mode const FontMode  m  )  [inline]
 

Set the font mode.

Definition at line 150 of file emftgl.h.

00150 { mode = m; }

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 146 of file emftgl.h.

00146 { use_display_lists = b; }


Member Data Documentation

unsigned int EMAN::EMFTGL::depth [private]
 

Definition at line 177 of file emftgl.h.

unsigned int EMAN::EMFTGL::face_size [private]
 

Definition at line 176 of file emftgl.h.

EMFTGLManager EMAN::EMFTGL::fm [private]
 

Definition at line 244 of file emftgl.h.

string EMAN::EMFTGL::font_file_name [private]
 

Disallow Assignment.

Definition at line 175 of file emftgl.h.

FontMode EMAN::EMFTGL::mode [private]
 

Definition at line 180 of file emftgl.h.

bool EMAN::EMFTGL::use_display_lists [private]
 

Definition at line 178 of file emftgl.h.


The documentation for this class was generated from the following file:
Generated on Tue Jun 11 13:42:00 2013 for EMAN2 by  doxygen 1.3.9.1