Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::TextFaceFactory Class Reference

#include <OSGTextFaceFactory.h>

List of all members.

Public Member Functions

 ~TextFaceFactory ()
TextVectorFacecreateVectorFace (const std::string &family, TextFace::Style style=TextFace::STYLE_PLAIN)
TextPixmapFacecreatePixmapFace (const std::string &family, TextFace::Style style=TextFace::STYLE_PLAIN, UInt32 size=32)
TextTXFFacecreateTXFFace (const std::string &family, TextFace::Style style=TextFace::STYLE_PLAIN, const TextTXFParam &param=TextTXFParam())
void clearCache ()
void getFontFamilies (std::vector< std::string > &families) const

Static Public Member Functions

static TextFaceFactorythe ()

Private Types

typedef std::multimap< std::string,
TextVectorFace * > 
VectorFaceMap
typedef std::multimap< std::string,
TextPixmapFace * > 
PixmapFaceMap
typedef std::multimap< std::string,
TextTXFFace * > 
TXFFaceMap

Private Member Functions

 TextFaceFactory ()
 TextFaceFactory (const TextFaceFactory &)
const TextFaceFactoryoperator= (const TextFaceFactory &)

Private Attributes

TextBackend_backend
VectorFaceMap _vectorFaceMap
PixmapFaceMap _pixmapFaceMap
TXFFaceMap _txfFaceMap

Static Private Attributes

static TextFaceFactory _the


Detailed Description

A singleton used to create new faces. The TextFaceFactory keeps a cache of all currently created faces. When creating a new face, the factory first searches in the cache if the face already exists. If yes, it returns that face. If no, it creates a new face, adds it to the cache, and returns it. Usually you do not use the TextFaceFactory singleton directly, instead you use the create method of the TextFace classes.
Author:
Patrick Dähne

Definition at line 78 of file OSGTextFaceFactory.h.


Member Typedef Documentation

typedef std::multimap<std::string, TextVectorFace*> osg::TextFaceFactory::VectorFaceMap [private]
 

Defines the map that contains the vector faces

Definition at line 153 of file OSGTextFaceFactory.h.

typedef std::multimap<std::string, TextPixmapFace*> osg::TextFaceFactory::PixmapFaceMap [private]
 

Defines the map that contains the pixmap faces

Definition at line 159 of file OSGTextFaceFactory.h.

typedef std::multimap<std::string, TextTXFFace*> osg::TextFaceFactory::TXFFaceMap [private]
 

Defines the map that contains the TXF faces

Definition at line 165 of file OSGTextFaceFactory.h.


Constructor & Destructor Documentation

osg::TextFaceFactory::~TextFaceFactory  ) 
 

Destroys the TextFaceFactory object.

Definition at line 96 of file OSGTextFaceFactory.cpp.

References _backend, and clearCache().

00097 {
00098     clearCache();
00099     delete _backend;
00100 }

osg::TextFaceFactory::TextFaceFactory  )  [private]
 

Default Constructor

Definition at line 76 of file OSGTextFaceFactory.cpp.

References _backend.

00077 : _backend(), _vectorFaceMap(), _pixmapFaceMap(), _txfFaceMap()
00078 {
00079 #if defined(_WIN32)
00080     _backend = new TextWIN32Backend();
00081 #elif defined(__APPLE__)
00082     _backend = new TextMacBackend();
00083     //_backend = new TextFT2Backend();
00084 #elif defined(FT2_LIB)
00085     _backend = new TextFT2Backend();
00086 #else
00087     _backend = 0;
00088 #endif
00089 }

osg::TextFaceFactory::TextFaceFactory const TextFaceFactory  )  [private]
 

Copy constructor (not implemented!)


Member Function Documentation

TextVectorFace* osg::TextFaceFactory::createVectorFace const std::string &  family,
TextFace::Style  style = TextFace::STYLE_PLAIN
 

Tries to create a vector face.

Parameters:
family The font family of the face (Arial, Courier etc.)
style The style of the face (bold, italic etc.)
Returns:
The vector face object or 0 in case of an error.

Referenced by osg::TextVectorFace::create().

TextPixmapFace* osg::TextFaceFactory::createPixmapFace const std::string &  family,
TextFace::Style  style = TextFace::STYLE_PLAIN,
UInt32  size = 32
 

Tries to create a pixmap face.

Parameters:
family The font family of the face (Arial, Courier etc.)
style The style of the face (bold, italic etc.)
size The size of the pixmap font in pixels.
Returns:
The pixmap face object or 0 in case of an error.

Referenced by osg::TextPixmapFace::create().

TextTXFFace* osg::TextFaceFactory::createTXFFace const std::string &  family,
TextFace::Style  style = TextFace::STYLE_PLAIN,
const TextTXFParam param = TextTXFParam()
 

Tries to create a TXF face.

Parameters:
family The font family of the face (Arial, Courier etc.)
style The style of the face (bold, italic etc.)
param Parameters that affect the creation of the TXF face.
Returns:
The TXF face object or 0 in case of an error.

void osg::TextFaceFactory::clearCache  ) 
 

Removes all faces from the face cache.

Definition at line 196 of file OSGTextFaceFactory.cpp.

References _pixmapFaceMap, _txfFaceMap, _vectorFaceMap, and osg::subRefP().

Referenced by ~TextFaceFactory().

00197 {
00198     // Vector faces
00199     VectorFaceMap::iterator vIt;
00200     for (vIt = _vectorFaceMap.begin(); vIt != _vectorFaceMap.end(); ++vIt)
00201     {
00202         assert(vIt->second != 0);
00203         subRefP(vIt->second);
00204     }
00205     _vectorFaceMap.clear();
00206 
00207     // Pixmap faces
00208     PixmapFaceMap::iterator pIt;
00209     for (pIt = _pixmapFaceMap.begin(); pIt != _pixmapFaceMap.end(); ++pIt)
00210     {
00211         assert(pIt->second != 0);
00212         subRefP(pIt->second);
00213     }
00214     _pixmapFaceMap.clear();
00215 
00216     // TXF faces
00217     TXFFaceMap::iterator tIt;
00218     for (tIt = _txfFaceMap.begin(); tIt != _txfFaceMap.end(); ++tIt)
00219     {
00220         assert(tIt->second != 0);
00221         subRefP(tIt->second);
00222     }
00223     _txfFaceMap.clear();
00224 }

void osg::TextFaceFactory::getFontFamilies std::vector< std::string > &  families  )  const
 

Returns the names of all font families available.

Parameters:
families A vector that gets filled with the names of all font families.

TextFaceFactory & osg::TextFaceFactory::the  )  [inline, static]
 

Returns the single instance of the FaceFactory singleton.

Returns:
The single instance.

Definition at line 43 of file OSGTextFaceFactory.inl.

References _the.

Referenced by osg::TextVectorFace::create(), and osg::TextPixmapFace::create().

00043 { return _the; } 

const TextFaceFactory& osg::TextFaceFactory::operator= const TextFaceFactory  )  [private]
 

Copy operator (not implemented!)


Member Data Documentation

TextFaceFactory osg::TextFaceFactory::_the [static, private]
 

The single instance of the TextFaceFactory singleton

Definition at line 69 of file OSGTextFaceFactory.cpp.

Referenced by the().

TextBackend* osg::TextFaceFactory::_backend [private]
 

The backend that creates all faces

Definition at line 150 of file OSGTextFaceFactory.h.

Referenced by TextFaceFactory(), and ~TextFaceFactory().

VectorFaceMap osg::TextFaceFactory::_vectorFaceMap [private]
 

The map of vector faces currently instantiated (face cache)

Definition at line 156 of file OSGTextFaceFactory.h.

Referenced by clearCache().

PixmapFaceMap osg::TextFaceFactory::_pixmapFaceMap [private]
 

The map of pixmap faces currently instanciated (face cache)

Definition at line 162 of file OSGTextFaceFactory.h.

Referenced by clearCache().

TXFFaceMap osg::TextFaceFactory::_txfFaceMap [private]
 

The map of TXF faces currently instantiated (face cache)

Definition at line 168 of file OSGTextFaceFactory.h.

Referenced by clearCache().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 04:23:02 2005 for OpenSG by  doxygen 1.4.3