TLatex.h

Go to the documentation of this file.
00001 // @(#)root/graf:$Id: TLatex.h 33468 2010-05-11 14:09:36Z couet $
00002 // Author: Nicolas Brun   07/08/98
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
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 // TLatex                                                               //
00027 //                                                                      //
00028 // The Latex-style text processor class                                 //
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 // compute size of a portion of a formula
00043 class TLatexFormSize {
00044 private:
00045       Double_t fWidth, fOver, fUnder;
00046 public:
00047       TLatexFormSize() : fWidth(0), fOver(0),fUnder(0) { } // constructeur par defaut
00048       TLatexFormSize(Double_t x, Double_t y1, Double_t y2) : fWidth(x), fOver(y1), fUnder(y2) { } // constructeur
00049       virtual ~TLatexFormSize() {} //destructeur
00050       TLatexFormSize(const TLatexFormSize& form) 
00051          : fWidth(form.fWidth), fOver(form.fOver), fUnder(form.fUnder) { }
00052       
00053       // definition of operators + and +=
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       // return members
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;      //!Relative size of subscripts and superscripts
00078       Double_t      fFactorPos;       //!Relative position of subscripts and superscripts
00079       Int_t         fLimitFactorSize; // lower bound for subscripts/superscripts size
00080       const Char_t *fError;           //!error code
00081       Bool_t        fShow;            //!is true during the second pass (Painting)
00082       FormSize_t   *fTabSize;         //!array of values for the different zones
00083       Double_t      fOriginSize;      // Font size of the starting font
00084       Int_t         fTabMax;          //!Maximum allocation for array fTabSize;
00085       Int_t         fPos;             //!Current position in array fTabSize;
00086       Bool_t        fItalic;          //!Currently inside #it operator
00087 
00088       TLatex& operator=(const TLatex&); 
00089 
00090       //Text analysis and painting
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       // TLatex status bits
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)  //The Latex-style text processor class
00128 };
00129 
00130 #endif

Generated on Tue Jul 5 14:14:09 2011 for ROOT_528-00b_version by  doxygen 1.5.1