library: libGraf
#include "TLatex.h"


class description - header file - source file
viewCVS header - viewCVS source

class TLatex: public TText, public TAttLine

Inheritance Inherited Members Includes Libraries
Class Charts

Function Members (Methods)

Display options:
Show inherited
Show non-public
TLatex(const TLatex& text)
TLatex(Double_t x, Double_t y, const char* text)
voidTObject::AbstractMethod(const char* method) const
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTNamed::Clear(Option_t* option = "")
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
virtual voidCopy(TObject& text) const
virtual voidTObject::Delete(Option_t* option = "")
Int_tTAttLine::DistancetoLine(Int_t px, Int_t py, Double_t xp1, Double_t yp1, Double_t xp2, Double_t yp2)
virtual Int_tTText::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() const
virtual TObject*TObject::DrawClone(Option_t* option = "") const
TLatex*DrawLatex(Double_t x, Double_t y, const char* text)
virtual TText*TText::DrawText(Double_t x, Double_t y, const char* text)
virtual TText*TText::DrawTextNDC(Double_t x, Double_t y, const char* text)
virtual voidTObject::Dump() const
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTText::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual voidTNamed::FillBuffer(char*& buffer)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual voidGetBoundingBox(UInt_t& w, UInt_t& h)
virtual voidTText::GetControlBox(Int_t x, Int_t y, Double_t theta, Int_t* cBoxX, Int_t* cBoxY)
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
Double_tGetHeight() const
virtual const char*TObject::GetIconName() const
virtual Color_tTAttLine::GetLineColor() const
virtual Style_tTAttLine::GetLineStyle() const
virtual Width_tTAttLine::GetLineWidth() const
virtual const char*TNamed::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual Short_tTAttText::GetTextAlign() const
virtual Float_tTAttText::GetTextAngle() const
virtual voidTText::GetTextAscentDescent(UInt_t& a, UInt_t& d, const char* text) const
virtual Color_tTAttText::GetTextColor() const
virtual voidTText::GetTextExtent(UInt_t& w, UInt_t& h, const char* text) const
virtual Font_tTAttText::GetTextFont() const
virtual Float_tTAttText::GetTextSize() const
virtual const char*TNamed::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
Double_tTText::GetX() const
Double_tTText::GetY() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTNamed::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() const
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTNamed::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTText::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual voidTAttText::Modify()
virtual Bool_tTObject::Notify()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
virtual voidPaint(Option_t* option = "")
virtual voidTText::PaintControlBox(Int_t x, Int_t y, Double_t theta)
virtual voidPaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char* text)
virtual voidTText::PaintText(Double_t x, Double_t y, const char* text)
virtual voidTText::PaintTextNDC(Double_t u, Double_t v, const char* text)
virtual voidTObject::Pop()
virtual voidTText::Print(Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
virtual voidTAttLine::ResetAttLine(Option_t* option = "")
virtual voidTAttText::ResetAttText(Option_t* toption = "")
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") const
virtual voidTAttLine::SaveLineAttributes(ostream& out, const char* name, Int_t coldef = 1, Int_t stydef = 1, Int_t widdef = 1)
virtual voidSavePrimitive(ostream& out, Option_t* option = "")
virtual voidTAttText::SaveTextAttributes(ostream& out, const char* name, Int_t alidef = 12, Float_t angdef = 0, Int_t coldef = 1, Int_t fondef = 61, Float_t sizdef = 1)
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")
static voidTObject::SetDtorOnly(void* obj)
virtual voidSetIndiceSize(Double_t factorSize)
virtual voidSetLimitIndiceSize(Int_t limitFactorSize)
virtual voidTAttLine::SetLineAttributes()
virtual voidTAttLine::SetLineColor(Color_t lcolor)
virtual voidTAttLine::SetLineStyle(Style_t lstyle)
virtual voidTAttLine::SetLineWidth(Width_t lwidth)
virtual voidTNamed::SetName(const char* name)
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
virtual voidTText::SetNDC(Bool_t isNDC = kTRUE)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTText::SetText(Double_t x, Double_t y, const char* text)
virtual voidTAttText::SetTextAlign(Short_t align = 11)
virtual voidTAttText::SetTextAngle(Float_t tangle = 0)
virtual voidTAttText::SetTextAttributes()
virtual voidTAttText::SetTextColor(Color_t tcolor = 1)
virtual voidTAttText::SetTextFont(Font_t tfont = 62)
virtual voidTAttText::SetTextSize(Float_t tsize = 1)
virtual voidTAttText::SetTextSizePixels(Int_t npixels)
virtual voidTNamed::SetTitle(const char* title = "")
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidTText::SetX(Double_t x)
virtual voidTText::SetY(Double_t y)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual Int_tTNamed::Sizeof() const
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = "0", Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = "0", Int_t option = 0, Int_t bufsize = 0) const
TLatexFormSizeAnal1(TextSpec_t spec, const Char_t* t, Int_t length)
TLatexFormSizeAnalyse(Double_t x, Double_t y, TextSpec_t spec, const Char_t* t, Int_t length)
Int_tCheckLatexSyntax(TString& text)
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidDrawCircle(Double_t x1, Double_t y1, Double_t r, TextSpec_t spec)
voidDrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, TextSpec_t spec)
voidDrawParenthesis(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, TextSpec_t spec)
TLatexFormSizeFirstParse(Double_t angle, Double_t size, const Char_t* text)
TLatex&operator=(const TLatex&)
voidSavefs(TLatexFormSize* fs)

Data Members

enum { kTextNDC
enum TText::[unnamed] { kTextNDC
enum TObject::EStatusBits { kCanDelete
enum TObject::[unnamed] { kIsOnHeap
Double_tfFactorSize!Relative size of subscripts and superscripts
Double_tfFactorPos!Relative position of subscripts and superscripts
Int_tfLimitFactorSizelower bound for subscripts/superscripts size
const Char_t*fError!error code
Bool_tfShow!is true during the second pass (Painting)
FormSize_t*fTabSize!array of values for the different zones
Double_tfOriginSizeFont size of the starting font
Int_tfTabMax!Maximum allocation for array fTabSize;
Int_tfPos!Current position in array fTabSize;
Double_tTText::fXX position of text (left,center,etc..)
Double_tTText::fYY position of text (left,center,etc..)
TStringTNamed::fNameobject identifier
TStringTNamed::fTitleobject title
Float_tTAttText::fTextAngleText angle
Float_tTAttText::fTextSizeText size
Short_tTAttText::fTextAlignText alignment
Color_tTAttText::fTextColorText color index
Font_tTAttText::fTextFontText font number
Color_tTAttLine::fLineColorline color
Style_tTAttLine::fLineStyleline style
Width_tTAttLine::fLineWidthline width

Class Description

   TLatex : to draw Mathematical Formula

   This class has been implemented by 
Nicolas Brun

   TLatex's purpose is to write mathematical equations
   The syntax is very similar to the Latex one :

   ** Subscripts and Superscripts
   Subscripts and superscripts are made with the _ and ^ commands.  These commands
   can be combined to make complicated subscript and superscript expressions.
   You may choose how to display subscripts and superscripts using the 2 functions
   SetindiceSize(Double_t) and SetLimitindiceSize(Int_t).
/*p */

   ** Fractions
   Fractions denoted by the / symbol are made in the obvious way.
   The #frac command is used for large fractions in displayed formula; it has
   two arguments: the numerator and the denominator.
/* */

   ** splitting a line in two lines
   A text can be split in two lines via the command #splitline
   For example #splitline{"21 April 2003}{14:02:30}

   ** Roots
   The #sqrt command produces the square root of its argument; it has an optional
   first argument for other roots.
   ex: #sqrt{10}  #sqrt[3]{10}

   ** Mathematical Symbols
   TLatex can make dozens of special mathematical symbols. A few of them, such as
   + and > , are produced by typing the corresponding keyboard character.  Others
   are obtained with the commands in the following table :
/* */
    #Box       draw a square
    #perp      draw the perpendicular symbol
    #odot      draw odot
    #hbar      draw h-bar (Planck constant divided by 2*Pi)
    #parallel  draw the parallel symbol

   ** Delimiters
   You can produce 4 kinds of proportional delimiters.
   #[]{....} or "a la" Latex #left[.....#right] : big square brackets
   #{}{....} or              #left{.....#right} : big curly brackets
   #||{....} or              #left|.....#right| : big absolute value symbol
   #(){....} or              #left(.....#right) : big parenthesis

   ** Greek Letters
   The command to produce a lowercase Greek letter is obtained by adding a # to
   the name of the letter. For an uppercase Greek letter, just capitalize the first
   letter of the command name. Some letter have two representations. The name of the
   second one (the "variation") starts with "var".
   #alpha #beta #chi #delta #varepsilon #phi #gamma #eta #iota #varphi #kappa #lambda
   #mu #nu #omicron #pi #theta #rho #sigma #tau #upsilon #varomega #omega #xi #psi #zeta
   #Alpha #Beta #Chi #Delta #Epsilon #Phi #Gamma #Eta #Iota #vartheta
   #Kappa #Lambda #Mu #Nu #Omicron #Pi #Theta #Rho #Sigma #Tau
   #Upsilon #varsigma #Omega #Xi #Psi #Zeta #varUpsilon #epsilon
/* */

   ** Putting One Thing Above Another
   Symbols in a formula are sometimes placed on above another. TLatex provides
   special commands for doing this.

   ** Accents
    #hat{a} = hat
    #check  = inversed hat
    #acute  = acute
    #grave  = agrave
    #dot    = derivative
    #ddot   = double derivative
    #tilde  = tilde

    #slash special sign. Draw a slash on top of the text between brackets
   for example #slash{E}_{T}  generates "Missing ET"

/* */
   #dot  #ddot  #hat  #check  #acute  #grave  #tilde

   ** Changing Style in Math Mode
   You can change the font and the text color at any moment using :
   #font[font-number]{...} and #color[color-number]{...}

   ** Example1
     The following macro (tutorials/graphics/latex.C) produces the following picture:
     TCanvas c1("c1","Latex",600,700);
     TLatex l;
     l.DrawLatex(0.1,0.8,"1)   C(x) = d #sqrt{#frac{2}{#lambdaD}}  #int^{x}_{0}cos(#frac{#pi}{2}t^{2})dt");
     l.DrawLatex(0.1,0.6,"2)   C(x) = d #sqrt{#frac{2}{#lambdaD}}  #int^{x}cos(#frac{#pi}{2}t^{2})dt");
     l.DrawLatex(0.1,0.4,"3)   R = |A|^{2} = #frac{1}{2}(#[]{#frac{1}{2}+C(V)}^{2}+#[]{#frac{1}{2}+S(V)}^{2})");
     l.DrawLatex(0.1,0.2,"4)   F(t) = #sum_{i=-#infty}^{#infty}A(i)cos#[]{#frac{i}{t+i}}");
/* */

   ** Example2
     The following macro (tutorials/graphics/latex2.C) produces the following picture:
     TCanvas c1("c1","Latex",600,700);
     TLatex l;
     l.DrawLatex(0.5,0.95,"e^{+}e^{-}#rightarrowZ^{0}#rightarrowI#bar{I}, q#bar{q}");
     l.DrawLatex(0.5,0.3,"L_{em}=eJ^{#mu}_{em}A_{#mu} , J^{#mu}_{em}=#bar{I}#gamma_{#mu}I , M^{j}_{i}=#SigmaA_{#alpha}#tau^{#alphaj}_{i}");
/* */

   ** Example3
     The following macro (tutorials/graphics/latex3.C) produces the following picture:
   TCanvas c1("c1");
   TPaveText pt(.1,.5,.9,.9);
   pt.AddText("#frac{2s}{#pi#alpha^{2}}  #frac{d#sigma}{dcos#theta} (e^{+}e^{-} #rightarrow f#bar{f} ) = ");
   pt.AddText("#left| #frac{1}{1 - #Delta#alpha} #right|^{2} (1+cos^{2}#theta");
   pt.AddText("+ 4 Re #left{ #frac{2}{1 - #Delta#alpha} #chi(s) #[]{#hat{g}_{#nu}^{e}#hat{g}_{#nu}^{f}
    (1 + cos^{2}#theta) + 2 #hat{g}_{a}^{e}#hat{g}_{a}^{f} cos#theta) } #right}");
   pt.SetLabel("Born equation");
/* */

   ** Alignment rules
  The TText alignment rules apply to the TLatex objects with one exception
  concerning the vertical alignment:
  If the vertical alignment = 1 , subscripts are not taken into account
  if the vertical alignment = 0 , the text is aligned to the box surrounding
                                  the full text with sub and superscripts
  This is illustrated in the following example:

  TCanvas c1("c1","c1",600,500);
  const char *longstring = "K_{S}... K^{*0}... #frac{2s}{#pi#alpha^{2}}
 #frac{d#sigma}{dcos#theta} (e^{+}e^{-} #rightarrow f#bar{f} ) =
 #left| #frac{1}{1 - #Delta#alpha} #right|^{2} (1+cos^{2}#theta)";

  TLatex latex;
  latex.SetTextAlign(13);  //align at top

  latex.SetTextAlign(12);  //centered

  latex.SetTextAlign(11);  //default bottom alignment

  latex.SetTextAlign(10);  //special bottom alignment

/* */
 Default constructor.
TLatex(Double_t x, Double_t y, const char *text)
 Normal constructor.
TLatex(const TLatex &text)
 Copy constructor.
TLatex& operator=(const TLatex& lt)
assignment operator
void Copy(TObject &obj)
 Copy this TLatex object to another TLatex.
TLatexFormSize Anal1(TextSpec_t spec, const Char_t* t, Int_t length)
 Analyse function.
TLatexFormSize Analyse(Double_t x, Double_t y, TextSpec_t spec, const Char_t* t, Int_t length)
  Analyse and paint the TLatex formula

  It is called twice : first for calculating the size of
  each portion of the formula, then to paint the formula.
  When analyse finds an operator or separator, it calls
  itself recursively to analyse the arguments of the operator.
  when the argument is an atom (normal text), it calculates
  the size of it and return it as the result.
  for example : if the operator #frac{arg1}{arg2} is found :
  Analyse(arg1) return the size of arg1 (width, up, down)
  Analyse(arg2) return the size of arg2
  now, we know the size of #frac{arg1}{arg2}  :
  width = max(width_arg1, width_arg2)
  up = up_arg1 + down_arg1
  down = up_arg2 + down_arg2
  so, when the user wants to paint a fraction at position (x,y),
  the rect used for the formula is : (x,y-up,x+width,y+down)

 return size of zone occupied by the text/formula
 t : chain to be analyzed
 length : number of chars in t.
TLatex * DrawLatex(Double_t x, Double_t y, const char *text)
 Make a copy of this object with the new parameters
 And copy object attributes
void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, TextSpec_t spec)
 Draw a line in a Latex formula
void DrawCircle(Double_t x1, Double_t y1, Double_t r, TextSpec_t spec )
 Draw an arc of ellipse in a Latex formula (right or left parenthesis)
void DrawParenthesis(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, TextSpec_t spec )
 Draw an arc of ellipse in a Latex formula (right or left parenthesis)
void Paint(Option_t *)
void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const Char_t *text1)
 Main drawing function

 Warning: Unlike most others "XYZ::PaintXYZ" methods, PaintLatex modifies
          the TLatex data members.
Int_t CheckLatexSyntax(TString &text)
 Check if the Latex syntax is correct
TLatexFormSize FirstParse(Double_t angle, Double_t size, const Char_t *text)
 First parsing of the analyse sequence
Double_t GetHeight()
 Return height of current pad in pixels
Double_t GetXsize()
 Return size of the formula along X in pad coordinates
void GetBoundingBox(UInt_t &w, UInt_t &h)
 Return text size in pixels
Double_t GetYsize()
 Return size of the formula along Y in pad coordinates
TLatexFormSize Readfs()
 Read fs in fTabSize
void Savefs(TLatexFormSize *fs)
 Save fs values in array fTabSize
void SavePrimitive(ostream &out, Option_t * /*= ""*/)
 Save primitive as a C++ statement(s) on output stream out
void SetIndiceSize(Double_t factorSize)
 Set relative size of subscripts and superscripts
void SetLimitIndiceSize(Int_t limitFactorSize)
 Set limit for text resizing of subscipts and superscripts

Author: Nicolas Brun 07/08/98
Last update: root/graf:$Name: $:$Id: TLatex.cxx,v 1.63 2006/12/12 13:54:35 couet Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *

ROOT page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.