Warning, file /include/root/TGLFontManager.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGLFontManager
0013 #define ROOT_TGLFontManager
0014
0015 #include "TObjArray.h"
0016 #include <list>
0017 #include <vector>
0018 #include <map>
0019
0020 class FTFont;
0021 class TGLFontManager;
0022
0023 class TGLFont
0024 {
0025 public:
0026 enum EMode
0027 {
0028 kUndef = -1,
0029 kBitmap, kPixmap,
0030 kTexture, kOutline, kPolygon, kExtrude
0031 };
0032
0033 enum ETextAlignH_e { kLeft, kRight, kCenterH };
0034 enum ETextAlignV_e { kBottom, kTop, kCenterV };
0035
0036 private:
0037 TGLFont& operator=(const TGLFont&) = delete;
0038
0039 FTFont *fFont;
0040 TGLFontManager *fManager;
0041
0042 Float_t fDepth;
0043
0044 template<class Char>
0045 void RenderHelper(const Char *txt, Double_t x, Double_t y, Double_t angle, Double_t ) const;
0046
0047 protected:
0048 Int_t fSize;
0049 Int_t fFile;
0050 EMode fMode;
0051
0052 mutable Int_t fTrashCount;
0053 public:
0054 TGLFont();
0055 TGLFont(Int_t size, Int_t font, EMode mode, FTFont *f = nullptr, TGLFontManager *mng = nullptr);
0056 TGLFont(const TGLFont &o);
0057 virtual ~TGLFont();
0058
0059 void CopyAttributes(const TGLFont &o);
0060
0061 Int_t GetSize() const { return fSize;}
0062 Int_t GetFile() const { return fFile;}
0063 EMode GetMode() const { return fMode;}
0064
0065 Int_t GetTrashCount() const { return fTrashCount; }
0066 void SetTrashCount(Int_t c) const { fTrashCount = c; }
0067 Int_t IncTrashCount() const { return ++fTrashCount; }
0068
0069 void SetFont(FTFont *f) { fFont =f;}
0070 const FTFont* GetFont() const { return fFont; }
0071 void SetManager(TGLFontManager *mng) { fManager = mng; }
0072 const TGLFontManager* GetManager() const { return fManager; }
0073
0074 Float_t GetDepth() const { return fDepth; }
0075 void SetDepth(Float_t d) { fDepth = d; }
0076
0077
0078 Float_t GetAscent() const;
0079 Float_t GetDescent() const;
0080 Float_t GetLineHeight() const;
0081 void MeasureBaseLineParams(Float_t& ascent, Float_t& descent, Float_t& line_height,
0082 const char* txt="Xj") const;
0083
0084 void BBox(const char* txt,
0085 Float_t& llx, Float_t& lly, Float_t& llz,
0086 Float_t& urx, Float_t& ury, Float_t& urz) const;
0087 void BBox(const wchar_t* txt,
0088 Float_t& llx, Float_t& lly, Float_t& llz,
0089 Float_t& urx, Float_t& ury, Float_t& urz) const;
0090
0091 void Render(const char* txt, Double_t x, Double_t y, Double_t angle, Double_t mgn) const;
0092 void Render(const wchar_t* txt, Double_t x, Double_t y, Double_t angle, Double_t mgn) const;
0093 void Render(const TString &txt) const;
0094 void Render(const TString &txt, Float_t x, Float_t y, Float_t z, ETextAlignH_e alignH, ETextAlignV_e alignV) const;
0095
0096
0097 virtual void PreRender(Bool_t autoLight=kTRUE, Bool_t lightOn=kFALSE) const;
0098 virtual void PostRender() const;
0099
0100 Bool_t operator< (const TGLFont& o) const
0101 {
0102 if (fSize == o.fSize)
0103 {
0104 if(fFile == o.fFile)
0105 {
0106 return fMode < o.fMode;
0107 }
0108 return fFile < o.fFile;
0109 }
0110 return fSize < o.fSize;
0111 }
0112
0113 ClassDef(TGLFont, 0);
0114 };
0115
0116
0117
0118
0119 class TGLFontManager
0120 {
0121 public:
0122 typedef std::vector<Int_t> FontSizeVec_t;
0123
0124 private:
0125 TGLFontManager(const TGLFontManager&) = delete;
0126 TGLFontManager& operator=(const TGLFontManager&) = delete;
0127
0128 protected:
0129 typedef std::map<TGLFont, Int_t> FontMap_t;
0130 typedef std::map<TGLFont, Int_t>::iterator FontMap_i;
0131
0132 typedef std::list<const TGLFont*> FontList_t;
0133 typedef std::list<const TGLFont*>::iterator FontList_i;
0134 typedef std::list<const TGLFont*>::const_iterator FontList_ci;
0135
0136 FontMap_t fFontMap;
0137 FontList_t fFontTrash;
0138
0139 static TObjArray fgFontFileArray;
0140
0141 static Int_t fgExtendedFontStart;
0142
0143 static FontSizeVec_t fgFontSizeArray;
0144 static Bool_t fgStaticInitDone;
0145 static void InitStatics();
0146
0147 public:
0148 TGLFontManager() : fFontMap(), fFontTrash() {}
0149 virtual ~TGLFontManager();
0150
0151 void RegisterFont(Int_t size, Int_t file, TGLFont::EMode mode, TGLFont& out);
0152 void RegisterFont(Int_t size, const char* name, TGLFont::EMode mode, TGLFont& out);
0153 void ReleaseFont(TGLFont& font);
0154
0155 static TObjArray* GetFontFileArray();
0156 static FontSizeVec_t* GetFontSizeArray();
0157
0158 static Int_t GetExtendedFontStartIndex();
0159 static Int_t GetFontSize(Int_t ds);
0160 static Int_t GetFontSize(Int_t ds, Int_t min, Int_t max);
0161 static const char* GetFontNameFromId(Int_t);
0162
0163 void ClearFontTrash();
0164
0165 ClassDef(TGLFontManager, 0);
0166 };
0167
0168 #endif
0169