00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGLFontManager
00013 #define ROOT_TGLFontManager
00014
00015 #include "TObjArray.h"
00016 #include <list>
00017 #include <vector>
00018 #include <map>
00019
00020 class FTFont;
00021 class TGLFontManager;
00022
00023 class TGLFont
00024 {
00025 public:
00026 enum EMode
00027 {
00028 kUndef = -1,
00029 kBitmap, kPixmap,
00030 kTexture, kOutline, kPolygon, kExtrude
00031 };
00032
00033 enum ETextAlignH_e { kLeft, kRight, kCenterH };
00034 enum ETextAlignV_e { kBottom, kTop, kCenterV };
00035
00036 private:
00037 TGLFont& operator=(const TGLFont& o);
00038
00039 FTFont *fFont;
00040 TGLFontManager *fManager;
00041
00042 Float_t fDepth;
00043
00044 protected:
00045 Int_t fSize;
00046 Int_t fFile;
00047 EMode fMode;
00048
00049 mutable Int_t fTrashCount;
00050 public:
00051 TGLFont();
00052 TGLFont(Int_t size, Int_t font, EMode mode, FTFont *f=0, TGLFontManager *mng=0);
00053 TGLFont(const TGLFont& o);
00054 virtual ~TGLFont();
00055
00056 void CopyAttributes(const TGLFont &o);
00057
00058 Int_t GetSize() const { return fSize;}
00059 Int_t GetFile() const { return fFile;}
00060 EMode GetMode() const { return fMode;}
00061
00062 Int_t GetTrashCount() const { return fTrashCount; }
00063 void SetTrashCount(Int_t c) const { fTrashCount = c; }
00064 Int_t IncTrashCount() const { return ++fTrashCount; }
00065
00066 void SetFont(FTFont *f) { fFont =f;}
00067 const FTFont* GetFont() const { return fFont; }
00068 void SetManager(TGLFontManager *mng) { fManager = mng; }
00069 const TGLFontManager* GetManager() const { return fManager; }
00070
00071 Float_t GetDepth() const { return fDepth; }
00072 void SetDepth(Float_t d) { fDepth = d; }
00073
00074
00075 Float_t GetAscent() const;
00076 Float_t GetDescent() const;
00077 Float_t GetLineHeight() const;
00078 void MeasureBaseLineParams(Float_t& ascent, Float_t& descent, Float_t& line_height,
00079 const char* txt="Xj") const;
00080
00081 void BBox(const char* txt,
00082 Float_t& llx, Float_t& lly, Float_t& llz,
00083 Float_t& urx, Float_t& ury, Float_t& urz) const;
00084
00085 void Render(const char* txt, Double_t x, Double_t y, Double_t angle, Double_t mgn) const;
00086 void Render(const TString &txt) const;
00087 void Render(const TString &txt, Float_t x, Float_t y, Float_t z, ETextAlignH_e alignH, ETextAlignV_e alignV) const;
00088
00089
00090 virtual void PreRender(Bool_t autoLight=kTRUE, Bool_t lightOn=kFALSE) const;
00091 virtual void PostRender() const;
00092
00093 Bool_t operator< (const TGLFont& o) const
00094 {
00095 if (fSize == o.fSize)
00096 {
00097 if(fFile == o.fFile)
00098 {
00099 return fMode < o.fMode;
00100 }
00101 return fFile < o.fFile;
00102 }
00103 return fSize < o.fSize;
00104 }
00105
00106 ClassDef(TGLFont, 0);
00107 };
00108
00109
00110
00111
00112 class TGLFontManager
00113 {
00114 public:
00115 typedef std::vector<Int_t> FontSizeVec_t;
00116
00117 private:
00118 TGLFontManager(const TGLFontManager&);
00119 TGLFontManager& operator=(const TGLFontManager&);
00120
00121 protected:
00122 typedef std::map<TGLFont, Int_t> FontMap_t;
00123 typedef std::map<TGLFont, Int_t>::iterator FontMap_i;
00124
00125 typedef std::list<const TGLFont*> FontList_t;
00126 typedef std::list<const TGLFont*>::iterator FontList_i;
00127 typedef std::list<const TGLFont*>::const_iterator FontList_ci;
00128
00129 FontMap_t fFontMap;
00130 FontList_t fFontTrash;
00131
00132 static TObjArray fgFontFileArray;
00133 static FontSizeVec_t fgFontSizeArray;
00134 static Bool_t fgStaticInitDone;
00135 static void InitStatics();
00136
00137 public:
00138 TGLFontManager() : fFontMap(), fFontTrash() {}
00139 virtual ~TGLFontManager();
00140
00141 void RegisterFont(Int_t size, Int_t file, TGLFont::EMode mode, TGLFont& out);
00142 void RegisterFont(Int_t size, const char* name, TGLFont::EMode mode, TGLFont& out);
00143 void ReleaseFont(TGLFont& font);
00144
00145 static TObjArray* GetFontFileArray();
00146 static FontSizeVec_t* GetFontSizeArray();
00147
00148 static Int_t GetFontSize(Int_t ds);
00149 static Int_t GetFontSize(Int_t ds, Int_t min, Int_t max);
00150 static const char* GetFontNameFromId(Int_t);
00151
00152 void ClearFontTrash();
00153
00154 ClassDef(TGLFontManager, 0);
00155 };
00156
00157 #endif