00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ROOT_TLatex
00012 #define ROOT_TLatex
00013
00014 #ifndef ROOT_Riosfwd
00015 #include "Riosfwd.h"
00016 #endif
00017 #ifndef ROOT_TText
00018 #include "TText.h"
00019 #endif
00020 #ifndef ROOT_TAttLine
00021 #include "TAttLine.h"
00022 #endif
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 struct FormSize_t {
00034 Double_t fWidth, fOver, fUnder;
00035 };
00036
00037 struct TextSpec_t {
00038 Double_t fAngle,fSize;
00039 Int_t fColor,fFont;
00040 };
00041
00042
00043 class TLatexFormSize {
00044 private:
00045 Double_t fWidth, fOver, fUnder;
00046 public:
00047 TLatexFormSize() : fWidth(0), fOver(0),fUnder(0) { }
00048 TLatexFormSize(Double_t x, Double_t y1, Double_t y2) : fWidth(x), fOver(y1), fUnder(y2) { }
00049 virtual ~TLatexFormSize() {}
00050 TLatexFormSize(const TLatexFormSize& form)
00051 : fWidth(form.fWidth), fOver(form.fOver), fUnder(form.fUnder) { }
00052
00053
00054 TLatexFormSize operator+(TLatexFormSize f)
00055 { return TLatexFormSize(f.Width()+fWidth,TMath::Max(f.Over(),fOver),TMath::Max(f.Under(),fUnder)); }
00056 void operator+=(TLatexFormSize f)
00057 { fWidth += f.Width(); fOver = TMath::Max(fOver,f.Over()); fUnder = TMath::Max(fUnder,f.Under()); }
00058
00059 inline void Set(Double_t x, Double_t y1, Double_t y2) { fWidth=x; fOver=y1; fUnder=y2; }
00060 TLatexFormSize AddOver(TLatexFormSize f)
00061 { return TLatexFormSize(f.Width()+fWidth,f.Height()+fOver,fUnder); }
00062 TLatexFormSize AddUnder(TLatexFormSize f)
00063 { return TLatexFormSize(f.Width()+fWidth,fOver,f.Height()+fUnder); }
00064 TLatexFormSize AddOver(TLatexFormSize f1, TLatexFormSize f2)
00065 { return TLatexFormSize(fWidth+TMath::Max(f1.Width(),f2.Width()),fOver+f1.Over(),fUnder+f2.Under()); }
00066
00067
00068 inline Double_t Width() const { return fWidth; }
00069 inline Double_t Over() const { return fOver; }
00070 inline Double_t Under() const { return fUnder; }
00071 inline Double_t Height() const { return fOver+fUnder; }
00072 };
00073
00074 class TLatex : public TText, public TAttLine {
00075
00076 protected:
00077 Double_t fFactorSize;
00078 Double_t fFactorPos;
00079 Int_t fLimitFactorSize;
00080 const Char_t *fError;
00081 Bool_t fShow;
00082 FormSize_t *fTabSize;
00083 Double_t fOriginSize;
00084 Int_t fTabMax;
00085 Int_t fPos;
00086 Bool_t fItalic;
00087
00088 TLatex& operator=(const TLatex&);
00089
00090
00091 TLatexFormSize Analyse(Double_t x, Double_t y, TextSpec_t spec, const Char_t* t,Int_t length);
00092 TLatexFormSize Anal1(TextSpec_t spec, const Char_t* t,Int_t length);
00093
00094 void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, TextSpec_t spec);
00095 void DrawCircle(Double_t x1, Double_t y1, Double_t r, TextSpec_t spec);
00096 void DrawParenthesis(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, TextSpec_t spec);
00097
00098 TLatexFormSize FirstParse(Double_t angle, Double_t size, const Char_t *text);
00099
00100 void Savefs(TLatexFormSize *fs);
00101 TLatexFormSize Readfs();
00102
00103 Int_t CheckLatexSyntax(TString &text) ;
00104
00105 public:
00106
00107 enum { kTextNDC = BIT(14) };
00108
00109 TLatex();
00110 TLatex(Double_t x, Double_t y, const char *text);
00111 TLatex(const TLatex &text);
00112 virtual ~TLatex();
00113 void Copy(TObject &text) const;
00114
00115 TLatex *DrawLatex(Double_t x, Double_t y, const char *text);
00116 Double_t GetHeight() const;
00117 Double_t GetXsize();
00118 Double_t GetYsize();
00119 void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle = kFALSE);
00120 virtual void Paint(Option_t *option="");
00121 virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text);
00122
00123 virtual void SavePrimitive(ostream &out, Option_t *option = "");
00124 virtual void SetIndiceSize(Double_t factorSize);
00125 virtual void SetLimitIndiceSize(Int_t limitFactorSize);
00126
00127 ClassDef(TLatex,2)
00128 };
00129
00130 #endif