TLatex


class description - source file - inheritance tree

class TLatex : public TText, public TAttLine


    protected:
FormSize Anal1(s_TextSpec spec, const Char_t* t, Int_t length) FormSize Analyse(Float_t x, Float_t y, s_TextSpec spec, const Char_t* t, Int_t length) Int_t CheckLatexSyntax(TString& text) void DrawLine(Float_t x1, Float_t y1, Float_t x2, Float_t y2, s_TextSpec spec) FormSize FirstParse(Float_t angle, Float_t size, const Char_t* text) FormSize Readfs() void Savefs(FormSize* fs) public:
TLatex TLatex(Coord_t x, Coord_t y, const Text_t* text) TLatex TLatex() TLatex TLatex(const TLatex& text) virtual void ~TLatex() TClass* Class() virtual void Copy(TObject& text) void DrawLatex(Float_t x, Float_t y, const Text_t* text) Float_t GetHeight() void GetTextExtent(UInt_t& w, UInt_t& h, const char* text) Float_t GetXsize() Float_t GetYsize() virtual TClass* IsA() const virtual void Paint(Option_t* option) void PaintLatex(Float_t x, Float_t y, Float_t angle, Float_t size, const char* text) virtual void SavePrimitive(ofstream& out, Option_t* option) void SetIndiceSize(Float_t factorSize) void SetLimitIndiceSize(Int_t limitFactorSize) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b)

Data Members

protected:
Float_t fFactorSize Relative size of subscripts and superscripts Float_t fFactorPos Relative position of subscripts and superscripts Int_t fLimitFactorSize lower bound for subscripts/superscripts size Char_t* fError ! error code Bool_t fShow is true during the second pass (Painting) s_FormSize* fTabSize ! array of values for the different zones Float_t fOriginSize Font size of the starting font Int_t fTabMax Maximum allocation for array fTabSize; Int_t fPos Current position in array fTabSize;

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(Float_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.

/*

*/


   ** 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
    you may delimit an expression with proportional brackets using #[]{ ... }

   ** 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.
   #alpha #beta #gamma #delta #epsilon #zeta #eta #theta #iota #kappa #lambda #mu
   #nu #xi #omicron #pi #varpi #rho #sigma #tau #upsilon #phi #varphi #chi #psi #omega
   #Gamma #Delta #Theta #Lambda #Xi #Pi #Sigma #Upsilon #Phi #Psi #Omega

   ** 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


/*

*/

   #dot  #ddot  #hat  #check  #acute  #grave

   ** 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/latex.C) produces the following picture:
  {
     gROOT->Reset();
     TCanvas c1("c1","Latex",600,700);
     TLatex l;
     l.SetTextAlign(12);
     l.SetTextSize(0.04);
     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/latex2.C) produces the following picture:
  {
     gROOT->Reset();
     TCanvas c1("c1","Latex",600,700);
     TLatex l;
     l.SetTextAlign(23);
     l.SetTextSize(0.1);
     l.DrawLatex(0.5,0.95,"e^{+}e^{-}#rightarrowZ^{0}#rightarrowI#bar{I}, q#bar{q}");
     l.DrawLatex(0.5,0.75,"|#vec{a}#bullet#vec{b}|=#Sigmaa^{i}_{jk}+b^{bj}_{i}");
     l.DrawLatex(0.5,0.5,"i(#partial_{#mu}#bar{#psi}#gamma^{#mu}+m#bar{#psi}=0#Leftrightarrow(#Box+m^{2})#psi=0");
     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}");
  }

/*

*/


______________________________________________________________________________

TLatex()
 default constructor

TLatex(Coord_t x, Coord_t y, const Text_t *text) :TText(x,y,text)
 normal constructor

~TLatex()

TLatex(const TLatex &text)

void Copy(TObject &obj)
*-*-*-*-*-*-*-*-*-*-*Copy this TLatex object to another TLatex*-*-*-*-*-*-*
*-*                  =========================================

FormSize Anal1(s_TextSpec spec, const Char_t* t, Int_t length)

FormSize Analyse(Float_t x, Float_t y, s_TextSpec 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.


void DrawLatex(Coord_t x, Coord_t y, const Text_t *text)
 Make a copy of this object with the new parameters
 And copy object attributes

void DrawLine(Float_t x1, Float_t y1, Float_t x2, Float_t y2, s_TextSpec spec)
 Draw a line in a Latex formula

void Paint(Option_t *)
 Paint

void PaintLatex(Float_t x, Float_t y, Float_t angle, Float_t size, const Char_t *text1)
 Main drawing function

Int_t CheckLatexSyntax(TString &text)
 Check if the Latex syntax is correct

FormSize FirstParse(Float_t angle, Float_t size, const Char_t *text)
 first parsing of the analyse sequence

Float_t GetHeight()
 return height of current font in pixels

Float_t GetXsize()
 return size of the formula along X in pad coordinates

Float_t GetYsize()
 return size of the formula along Y in pad coordinates

FormSize Readfs()
 read fs in fTabSize

void Savefs(FormSize *fs)
 Save fs values in array fTabSize

void SavePrimitive(ofstream &out, Option_t *)
 Save primitive as a C++ statement(s) on output stream out

void SetIndiceSize(Float_t factorSize)
 set relative size of subscripts and superscripts

void SetLimitIndiceSize(Int_t limitFactorSize)
 Set limit for text resizing of subscipts and superscripts

void GetTextExtent(UInt_t &w, UInt_t &h, const char *text)
 Return text extent for string text
  in w return total text width
  in h return text height



Inline Functions


            TClass* Class()
            TClass* IsA() const
               void ShowMembers(TMemberInspector& insp, char* parent)
               void Streamer(TBuffer& b)


Author: Nicolas Brun 07/08/98
Last update: 2.23/07 24/10/99 17.28.51 by Fons Rademakers
Copyright (c) 1995-1999, The ROOT System, All rights reserved. *


ROOT page - Class index - 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.