library: libGraf #include "TLatex.h" |
TLatex() | |
TLatex(const TLatex& text) | |
TLatex(Double_t x, Double_t y, const char* text) | |
virtual | ~TLatex() |
void | TObject::AbstractMethod(const char* method) const |
virtual void | TObject::AppendPad(Option_t* option = "") |
virtual void | TObject::Browse(TBrowser* b) |
static TClass* | Class() |
virtual const char* | TObject::ClassName() const |
virtual void | TNamed::Clear(Option_t* option = "") |
virtual TObject* | TNamed::Clone(const char* newname = "") const |
virtual Int_t | TNamed::Compare(const TObject* obj) const |
virtual void | Copy(TObject& text) const |
virtual void | TObject::Delete(Option_t* option = "") |
Int_t | TAttLine::DistancetoLine(Int_t px, Int_t py, Double_t xp1, Double_t yp1, Double_t xp2, Double_t yp2) |
virtual Int_t | TText::DistancetoPrimitive(Int_t px, Int_t py) |
virtual void | TObject::Draw(Option_t* option = "") |
virtual void | TObject::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 void | TObject::Dump() const |
virtual void | TObject::Error(const char* method, const char* msgfmt) const |
virtual void | TObject::Execute(const char* method, const char* params, Int_t* error = 0) |
virtual void | TObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0) |
virtual void | TText::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
virtual void | TObject::Fatal(const char* method, const char* msgfmt) const |
virtual void | TNamed::FillBuffer(char*& buffer) |
virtual TObject* | TObject::FindObject(const char* name) const |
virtual TObject* | TObject::FindObject(const TObject* obj) const |
virtual void | GetBoundingBox(UInt_t& w, UInt_t& h) |
virtual void | TText::GetControlBox(Int_t x, Int_t y, Double_t theta, Int_t* cBoxX, Int_t* cBoxY) |
virtual Option_t* | TObject::GetDrawOption() const |
static Long_t | TObject::GetDtorOnly() |
Double_t | GetHeight() const |
virtual const char* | TObject::GetIconName() const |
virtual Color_t | TAttLine::GetLineColor() const |
virtual Style_t | TAttLine::GetLineStyle() const |
virtual Width_t | TAttLine::GetLineWidth() const |
virtual const char* | TNamed::GetName() const |
virtual char* | TObject::GetObjectInfo(Int_t px, Int_t py) const |
static Bool_t | TObject::GetObjectStat() |
virtual Option_t* | TObject::GetOption() const |
virtual Short_t | TAttText::GetTextAlign() const |
virtual Float_t | TAttText::GetTextAngle() const |
virtual void | TText::GetTextAscentDescent(UInt_t& a, UInt_t& d, const char* text) const |
virtual Color_t | TAttText::GetTextColor() const |
virtual void | TText::GetTextExtent(UInt_t& w, UInt_t& h, const char* text) const |
virtual Font_t | TAttText::GetTextFont() const |
virtual Float_t | TAttText::GetTextSize() const |
virtual const char* | TNamed::GetTitle() const |
virtual UInt_t | TObject::GetUniqueID() const |
Double_t | TText::GetX() const |
Double_t | GetXsize() |
Double_t | TText::GetY() const |
Double_t | GetYsize() |
virtual Bool_t | TObject::HandleTimer(TTimer* timer) |
virtual ULong_t | TNamed::Hash() const |
virtual void | TObject::Info(const char* method, const char* msgfmt) const |
virtual Bool_t | TObject::InheritsFrom(const char* classname) const |
virtual Bool_t | TObject::InheritsFrom(const TClass* cl) const |
virtual void | TObject::Inspect() const |
void | TObject::InvertBit(UInt_t f) |
virtual TClass* | IsA() const |
virtual Bool_t | TObject::IsEqual(const TObject* obj) const |
virtual Bool_t | TObject::IsFolder() const |
Bool_t | TObject::IsOnHeap() const |
virtual Bool_t | TNamed::IsSortable() const |
Bool_t | TObject::IsZombie() const |
virtual void | TText::ls(Option_t* option = "") const |
void | TObject::MayNotUse(const char* method) const |
virtual void | TAttText::Modify() |
virtual Bool_t | TObject::Notify() |
static void | TObject::operator delete(void* ptr) |
static void | TObject::operator delete(void* ptr, void* vp) |
static void | TObject::operator delete[](void* ptr) |
static void | TObject::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 void | Paint(Option_t* option = "") |
virtual void | TText::PaintControlBox(Int_t x, Int_t y, Double_t theta) |
virtual void | PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char* text) |
virtual void | TText::PaintText(Double_t x, Double_t y, const char* text) |
virtual void | TText::PaintTextNDC(Double_t u, Double_t v, const char* text) |
virtual void | TObject::Pop() |
virtual void | TText::Print(Option_t* option = "") const |
virtual Int_t | TObject::Read(const char* name) |
virtual void | TObject::RecursiveRemove(TObject* obj) |
virtual void | TAttLine::ResetAttLine(Option_t* option = "") |
virtual void | TAttText::ResetAttText(Option_t* toption = "") |
void | TObject::ResetBit(UInt_t f) |
virtual void | TObject::SaveAs(const char* filename = "", Option_t* option = "") const |
virtual void | TAttLine::SaveLineAttributes(ostream& out, const char* name, Int_t coldef = 1, Int_t stydef = 1, Int_t widdef = 1) |
virtual void | SavePrimitive(ostream& out, Option_t* option = "") |
virtual void | TAttText::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) |
void | TObject::SetBit(UInt_t f) |
void | TObject::SetBit(UInt_t f, Bool_t set) |
virtual void | TObject::SetDrawOption(Option_t* option = "") |
static void | TObject::SetDtorOnly(void* obj) |
virtual void | SetIndiceSize(Double_t factorSize) |
virtual void | SetLimitIndiceSize(Int_t limitFactorSize) |
virtual void | TAttLine::SetLineAttributes() |
virtual void | TAttLine::SetLineColor(Color_t lcolor) |
virtual void | TAttLine::SetLineStyle(Style_t lstyle) |
virtual void | TAttLine::SetLineWidth(Width_t lwidth) |
virtual void | TNamed::SetName(const char* name) |
virtual void | TNamed::SetNameTitle(const char* name, const char* title) |
virtual void | TText::SetNDC(Bool_t isNDC = kTRUE) |
static void | TObject::SetObjectStat(Bool_t stat) |
virtual void | TText::SetText(Double_t x, Double_t y, const char* text) |
virtual void | TAttText::SetTextAlign(Short_t align = 11) |
virtual void | TAttText::SetTextAngle(Float_t tangle = 0) |
virtual void | TAttText::SetTextAttributes() |
virtual void | TAttText::SetTextColor(Color_t tcolor = 1) |
virtual void | TAttText::SetTextFont(Font_t tfont = 62) |
virtual void | TAttText::SetTextSize(Float_t tsize = 1) |
virtual void | TAttText::SetTextSizePixels(Int_t npixels) |
virtual void | TNamed::SetTitle(const char* title = "") |
virtual void | TObject::SetUniqueID(UInt_t uid) |
virtual void | TText::SetX(Double_t x) |
virtual void | TText::SetY(Double_t y) |
virtual void | ShowMembers(TMemberInspector& insp, char* parent) |
virtual Int_t | TNamed::Sizeof() const |
virtual void | Streamer(TBuffer& b) |
void | StreamerNVirtual(TBuffer& b) |
virtual void | TObject::SysError(const char* method, const char* msgfmt) const |
Bool_t | TObject::TestBit(UInt_t f) const |
Int_t | TObject::TestBits(UInt_t f) const |
virtual void | TObject::UseCurrentStyle() |
virtual void | TObject::Warning(const char* method, const char* msgfmt) const |
virtual Int_t | TObject::Write(const char* name = "0", Int_t option = 0, Int_t bufsize = 0) |
virtual Int_t | TObject::Write(const char* name = "0", Int_t option = 0, Int_t bufsize = 0) const |
TLatexFormSize | Anal1(TextSpec_t spec, const Char_t* t, Int_t length) |
TLatexFormSize | Analyse(Double_t x, Double_t y, TextSpec_t spec, const Char_t* t, Int_t length) |
Int_t | CheckLatexSyntax(TString& text) |
virtual void | TObject::DoError(int level, const char* location, const char* fmt, va_list va) const |
void | DrawCircle(Double_t x1, Double_t y1, Double_t r, TextSpec_t spec) |
void | DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, TextSpec_t spec) |
void | DrawParenthesis(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, TextSpec_t spec) |
TLatexFormSize | FirstParse(Double_t angle, Double_t size, const Char_t* text) |
void | TObject::MakeZombie() |
TLatex& | operator=(const TLatex&) |
TLatexFormSize | Readfs() |
void | Savefs(TLatexFormSize* fs) |
enum { | kTextNDC | |
}; | ||
enum TText::[unnamed] { | kTextNDC | |
}; | ||
enum TObject::EStatusBits { | kCanDelete | |
kMustCleanup | ||
kObjInCanvas | ||
kIsReferenced | ||
kHasUUID | ||
kCannotPick | ||
kNoContextMenu | ||
kInvalidObject | ||
}; | ||
enum TObject::[unnamed] { | kIsOnHeap | |
kNotDeleted | ||
kZombie | ||
kBitMask | ||
kSingleKey | ||
kOverwrite | ||
kWriteDelete | ||
}; |
Double_t | fFactorSize | !Relative size of subscripts and superscripts |
Double_t | fFactorPos | !Relative position of subscripts and superscripts |
Int_t | fLimitFactorSize | lower bound for subscripts/superscripts size |
const Char_t* | fError | !error code |
Bool_t | fShow | !is true during the second pass (Painting) |
FormSize_t* | fTabSize | !array of values for the different zones |
Double_t | fOriginSize | Font size of the starting font |
Int_t | fTabMax | !Maximum allocation for array fTabSize; |
Int_t | fPos | !Current position in array fTabSize; |
Double_t | TText::fX | X position of text (left,center,etc..) |
Double_t | TText::fY | Y position of text (left,center,etc..) |
TString | TNamed::fName | object identifier |
TString | TNamed::fTitle | object title |
Float_t | TAttText::fTextAngle | Text angle |
Float_t | TAttText::fTextSize | Text size |
Short_t | TAttText::fTextAlign | Text alignment |
Color_t | TAttText::fTextColor | Text color index |
Font_t | TAttText::fTextFont | Text font number |
Color_t | TAttLine::fLineColor | line color |
Style_t | TAttLine::fLineStyle | line style |
Width_t | TAttLine::fLineWidth | line width |
TLatex : to draw Mathematical Formula This class has been implemented byNicolas 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: { 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/graphics/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}"); }/* */
** Example3 ----------- The following macro (tutorials/graphics/latex3.C) produces the following picture: { gROOT->Reset(); 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"); pt.Draw(); }/* */
** 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: { gROOT->Reset(); TCanvas c1("c1","c1",600,500); c1.SetGrid(); c1.DrawFrame(0,0,1,1); 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.SetTextSize(0.033); latex.SetTextAlign(13); //align at top latex.DrawLatex(.2,.9,"K_{S}"); latex.DrawLatex(.3,.9,"K^{*0}"); latex.DrawLatex(.2,.8,longstring); latex.SetTextAlign(12); //centered latex.DrawLatex(.2,.6,"K_{S}"); latex.DrawLatex(.3,.6,"K^{*0}"); latex.DrawLatex(.2,.5,longstring); latex.SetTextAlign(11); //default bottom alignment latex.DrawLatex(.2,.4,"K_{S}"); latex.DrawLatex(.3,.4,"K^{*0}"); latex.DrawLatex(.2,.3,longstring); latex.SetTextAlign(10); //special bottom alignment latex.DrawLatex(.2,.2,"K_{S}"); latex.DrawLatex(.3,.2,"K^{*0}"); latex.DrawLatex(.2,.1,longstring); latex.SetTextAlign(12); latex->SetTextFont(72); latex->DrawLatex(.1,.80,"13"); latex->DrawLatex(.1,.55,"12"); latex->DrawLatex(.1,.35,"11"); latex->DrawLatex(.1,.18,"10"); }/* */
______________________________________________________________________________
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.
Make a copy of this object with the new parameters And copy object attributes
Draw a line in a Latex formula
Draw an arc of ellipse in a Latex formula (right or left parenthesis)
Draw an arc of ellipse in a Latex formula (right or left parenthesis)
Main drawing function Warning: Unlike most others "XYZ::PaintXYZ" methods, PaintLatex modifies the TLatex data members.
First parsing of the analyse sequence
Save primitive as a C++ statement(s) on output stream out
Set limit for text resizing of subscipts and superscripts