224 const char *header,
Option_t *option)
225 :
TPave(
x1,y1,
x2,y2,4,option),
TAttText(12,0,1,
gStyle->GetLegendFont(),0)
228 if ( header && strlen(header) > 0) {
258 :
TPave(w,
h,w,
h,4,option),
TAttText(12,0,1,
gStyle->GetLegendFont(),0)
261 if ( header && strlen(header) > 0) {
289 ((
TLegend&)legend).Copy(*
this);
299 TAttText::operator=(lg);
332 const char *lab = label;
334 if (obj && (!label || strlen(label)==0)) lab = obj->
GetTitle();
356 Error(
"AddEntry",
"need to create a canvas first");
365 TList *lop =
gPad->GetListOfPrimitives();
369 while( (o=next()) ) {
384 return AddEntry( obj, label, option );
415 if ( !entry )
return;
434 if ( !entry )
return;
435 gROOT->SetSelectedPrimitive( entry );
445 if ( !entry )
return;
446 gROOT->SetSelectedPrimitive( entry );
456 if ( !entry )
return;
457 gROOT->SetSelectedPrimitive( entry );
467 if ( !entry )
return;
468 gROOT->SetSelectedPrimitive( entry );
479 Error(
"GetEntry",
"need to create a canvas first");
484 if ( nRows == 0 )
return 0;
492 if (nColumns > 0) xspace = (
fX2 -
fX1)/nColumns;
495 if (xspace > 0.) ix = (
Int_t)(xmouse/xspace)+1;
496 if (ix > nColumns) ix = nColumns;
500 if (iy > nRows) iy = nRows;
536 Error(
"InsertEntry",
"need to create a canvas first");
566 Warning(
"Paint",
"Legend too large to be automatically placed; a default position is used");
587 if ( nEntries == 0 )
return 0;
606 Warning(
"TLegend::SetNColumns",
"illegal value nColumns = %d; keeping fNColumns = %d", nColumns,
fNColumns);
618 if ( nRows == 0 )
return;
644 if ( textsize == 0 ) {
649 Double_t maxentrywidth = 0, maxentryheight = 0;
658 if (tfont%10 == 3) --tfont;
661 if ( entrytex.
GetYsize() > maxentryheight ) {
662 maxentryheight = entrytex.
GetYsize();
667 if ( entrytex.
GetXsize() > maxentrywidth ) {
668 maxentrywidth = entrytex.
GetXsize();
671 if ( entrytex.
GetXsize() > columnWidths[iColumn] ) {
672 columnWidths[iColumn] = entrytex.
GetXsize();
678 for(
int i=0; i<
fNColumns; i++) tmpMaxWidth += columnWidths[i];
679 if ( tmpMaxWidth > maxentrywidth) maxentrywidth = tmpMaxWidth;
703 if (autosize && tfont%10 == 3) --tfont;
709 if ( entrytex.
GetXsize() > columnWidths[iColumn] ) {
710 columnWidths[iColumn] = entrytex.
GetXsize();
716 double totalWidth = 0.0;
717 for(
int i=0; i<
fNColumns; i++) totalWidth += columnWidths[i];
719 else totalWidth /= (1.0 -
fMargin);
721 columnWidths[i] = columnWidths[i]/totalWidth*(
x2-
x1) + margin;
732 if(iColumn == 0) ytext -= yspace;
747 if (autosize && tfont%10 == 3) --tfont;
760 if ( opt.
Contains(
"h") ) entrymargin = margin/10.;
763 x2 =
x1 + columnWidths[iColumn];
767 if (halign == 1)
x =
x1 + entrymargin;
768 if (halign == 2)
x = 0.5*( (
x1+entrymargin) +
x2 );
769 if (halign == 3)
x =
x2 - entrymargin/10.;
779 if (tfont%10 == 3) tsizepad = (
gPad->AbsPixeltoY(0) -
gPad->AbsPixeltoY(textsize))/(
gPad->GetY2() -
gPad->GetY1());
780 if (yspace2 < tsizepad) {
790 entry->TAttText::Copy(entrytex);
815 if (eobjopt.
Contains(
"z")) endcaps = 0;
816 if (eobjopt.
Contains(
">")) endcaps = 2;
817 if (eobjopt.
Contains(
"|>")) endcaps = 3;
829 entry->TAttFill::Modify();
832 yf[0] = ysym - yspace*0.35;
836 yf[2] = ysym + yspace*0.35;
839 for (
Int_t i=0;i<4;i++) {
840 xf[i] =
gPad->GetX1() + xf[i]*(
gPad->GetX2()-
gPad->GetX1());
841 yf[i] =
gPad->GetY1() + yf[i]*(
gPad->GetY2()-
gPad->GetY1());
843 gPad->PaintFillArea(4,xf,yf);
849 TMarker entrymarker( xsym, ysym, 0 );
856 entry->TAttMarker::Copy(entrymarker);
868 TLine entryline( xsym - boxw, ysym, xsym + boxw, ysym );
870 entry->TAttLine::Copy(entryline);
876 if ( boxwidth > margin ) boxwidth = margin;
878 entryline.
PaintLineNDC( xsym - boxw, ysym + yspace*0.35,
879 xsym + boxw, ysym + yspace*0.35);
880 entryline.
PaintLineNDC( xsym - boxw, ysym - yspace*0.35,
881 xsym + boxw, ysym - yspace*0.35);
882 entryline.
PaintLineNDC( xsym + boxw, ysym - yspace*0.35,
883 xsym + boxw, ysym + yspace*0.35);
884 entryline.
PaintLineNDC( xsym - boxw, ysym - yspace*0.35,
885 xsym - boxw, ysym + yspace*0.35);
891 xsym, ysym + yspace*0.30);
894 TLine entryline1(xsym, ysym + sy, xsym, ysym + yspace*0.30);
896 entry->TAttLine::Copy(entryline1);
898 TLine entryline2(xsym, ysym - sy, xsym, ysym - yspace*0.30);
900 entry->TAttLine::Copy(entryline2);
905 TLine entrytop1(xsym-barw, ysym + yspace*0.30, xsym+barw, ysym + yspace*0.30);
907 entry->TAttLine::Copy(entrytop1);
909 TLine entrytop2(xsym-barw, ysym - yspace*0.30, xsym+barw, ysym - yspace*0.30);
911 entry->TAttLine::Copy(entrytop2);
913 }
else if (endcaps == 2) {
914 Double_t xe1[3] = {xsym-barw, xsym ,xsym+barw};
915 Double_t ye1[3] = {ysym+yspace*0.20, ysym + yspace*0.30 ,ysym+yspace*0.20};
918 entry->TAttLine::Copy(ple1);
920 Double_t xe2[3] = {xsym-barw, xsym ,xsym+barw};
921 Double_t ye2[3] = {ysym-yspace*0.20, ysym - yspace*0.30 ,ysym-yspace*0.20};
924 entry->TAttLine::Copy(ple2);
925 }
else if (endcaps == 3) {
926 Double_t xe1[3] = {xsym-barw, xsym ,xsym+barw};
927 Double_t ye1[3] = {ysym+yspace*0.20, ysym + yspace*0.30 ,ysym+yspace*0.20};
928 Double_t xe2[3] = {xsym-barw, xsym ,xsym+barw};
929 Double_t ye2[3] = {ysym-yspace*0.20, ysym - yspace*0.30 ,ysym-yspace*0.20};
930 for (
Int_t i=0;i<3;i++) {
931 xe1[i] =
gPad->GetX1() + xe1[i]*(
gPad->GetX2()-
gPad->GetX1());
932 ye1[i] =
gPad->GetY1() + ye1[i]*(
gPad->GetY2()-
gPad->GetY1());
933 xe2[i] =
gPad->GetX1() + xe2[i]*(
gPad->GetX2()-
gPad->GetX1());
934 ye2[i] =
gPad->GetY1() + ye2[i]*(
gPad->GetY2()-
gPad->GetY1());
956 TLine entryline(xsym, ysym - yspace*0.30,
957 xsym, ysym + yspace*0.30);
959 entry->TAttLine::Copy(entryline);
963 TLine entryline1(xsym, ysym + sy, xsym, ysym + yspace*0.30);
965 entry->TAttLine::Copy(entryline1);
967 TLine entryline2(xsym, ysym - sy, xsym, ysym - yspace*0.30);
969 entry->TAttLine::Copy(entryline2);
974 TLine entrytop1(xsym-barw, ysym + yspace*0.30, xsym+barw, ysym + yspace*0.30);
976 entry->TAttLine::Copy(entrytop1);
978 TLine entrytop2(xsym-barw, ysym - yspace*0.30, xsym+barw, ysym - yspace*0.30);
980 entry->TAttLine::Copy(entrytop2);
982 }
else if (endcaps == 2) {
983 Double_t xe1[3] = {xsym-barw, xsym ,xsym+barw};
984 Double_t ye1[3] = {ysym+yspace*0.20, ysym + yspace*0.30 ,ysym+yspace*0.20};
987 entry->TAttLine::Copy(ple1);
989 Double_t xe2[3] = {xsym-barw, xsym ,xsym+barw};
990 Double_t ye2[3] = {ysym-yspace*0.20, ysym - yspace*0.30 ,ysym-yspace*0.20};
993 entry->TAttLine::Copy(ple2);
995 }
else if (endcaps == 3) {
996 Double_t xe1[3] = {xsym-barw, xsym ,xsym+barw};
997 Double_t ye1[3] = {ysym+yspace*0.20, ysym + yspace*0.30 ,ysym+yspace*0.20};
998 Double_t xe2[3] = {xsym-barw, xsym ,xsym+barw};
999 Double_t ye2[3] = {ysym-yspace*0.20, ysym - yspace*0.30 ,ysym-yspace*0.20};
1000 for (
Int_t i=0;i<3;i++) {
1001 xe1[i] =
gPad->GetX1() + xe1[i]*(
gPad->GetX2()-
gPad->GetX1());
1002 ye1[i] =
gPad->GetY1() + ye1[i]*(
gPad->GetY2()-
gPad->GetY1());
1003 xe2[i] =
gPad->GetX1() + xe2[i]*(
gPad->GetX2()-
gPad->GetX1());
1004 ye2[i] =
gPad->GetY1() + ye2[i]*(
gPad->GetY2()-
gPad->GetY1());
1021 delete [] columnWidths;
1052 out <<
" " << std::endl;
1054 if (
gROOT->ClassSaved( TLegend::Class() ) ) {
1057 out <<
" TLegend *";
1062 <<
"NULL" <<
"," <<quote<<
fOption <<quote<<
");" << std::endl;
1064 out<<
" leg->SetBorderSize("<<
fBorderSize<<
");"<<std::endl;
1074 out <<
" leg->Draw();"<<std::endl;
1083 if ( entry ) entry->
SetLabel( label );
1092 if ( entry ) entry->
SetOption( option );
1107 opt =
first->GetOption();
1110 first->SetLabel(header);
1114 else first->SetTextAlign(0);
1122 else first->SetTextAlign(0);
1123 first->SetTextAngle(0);
1124 first->SetTextColor(0);
1126 first->SetTextSize(0);
static const double x2[5]
static const double x1[5]
R__EXTERN TStyle * gStyle
Fill Area Attributes class.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillAttributes()
Invoke the DialogCanvas Fill attributes.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
virtual Color_t GetLineColor() const
Return the line color.
virtual void SetLineAttributes()
Invoke the DialogCanvas Line attributes.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual Style_t GetMarkerStyle() const
Return the marker style.
virtual Size_t GetMarkerSize() const
Return the marker size.
virtual void SetMarkerAttributes()
Invoke the DialogCanvas Marker attributes.
virtual Float_t GetTextSize() const
Return the text size.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual Short_t GetTextAlign() const
Return the text alignment.
virtual Font_t GetTextFont() const
Return the text font.
virtual Color_t GetTextColor() const
Return the text color.
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
virtual Float_t GetTextAngle() const
Return the text angle.
virtual void SetTextAttributes()
Invoke the DialogCanvas Text attributes.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
virtual void SaveTextAttributes(std::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)
Save text attributes as C++ statement(s) on output stream out.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
void Copy(TAttText &atttext) const
Copy this text attributes to a new TAttText.
Double_t fX1
X of 1st point.
Double_t fY2
Y of 2nd point.
Double_t fX2
X of 2nd point.
Double_t fY1
Y of 1st point.
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
The Histogram stack class.
To draw Mathematical Formula.
Double_t GetXsize()
Return size of the formula along X in pad coordinates.
Double_t GetYsize()
Return size of the formula along Y in pad coordinates.
virtual void Paint(Option_t *option="")
Paint.
Storage class for one entry of a TLegend.
virtual TObject * GetObject() const
virtual void SetLabel(const char *label="")
virtual void SetOption(Option_t *option="lpf")
virtual void SaveEntry(std::ostream &out, const char *name)
Save this TLegendEntry as C++ statements on output stream out to be used with the SaveAs ....
virtual const char * GetLabel() const
virtual void SetObject(TObject *obj)
(re)set the obj pointed to by this entry
virtual Option_t * GetOption() const
This class displays a legend box (TPaveText) containing several legend entries.
virtual void Clear(Option_t *option="")
Clear all entries in this legend, including the header.
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
void SetNColumns(Int_t nColumns)
Set the number of columns for the legend.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save this legend as C++ statements on output stream out to be used with the SaveAs ....
virtual void SetHeader(const char *header="", Option_t *option="")
Sets the header, which is the "title" that appears at the top of the legend.
virtual void DeleteEntry()
Delete entry at the mouse position.
TLegendEntry * GetEntry() const
Get entry pointed to by the mouse.
Float_t fEntrySeparation
Separation between entries, as a fraction of The space allocated to one entry.
virtual void EditEntryAttMarker()
Edit the marker attributes for the entry pointed by the mouse.
virtual void RecursiveRemove(TObject *obj)
Reset the legend entries pointing to "obj".
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
virtual void Copy(TObject &obj) const
Copy this legend into "obj".
virtual void EditEntryAttText()
Edit the text attributes for the entry pointed by the mouse.
Int_t GetNColumns() const
Float_t fMargin
Fraction of total width used for symbol.
Int_t GetNRows() const
Get the number of rows.
TList * fPrimitives
List of TLegendEntries.
virtual ~TLegend()
Default destructor.
Int_t fNColumns
Number of columns in the legend.
Float_t fColumnSeparation
Separation between columns, as a fraction of The space allowed to one column.
virtual void Paint(Option_t *option="")
Paint this legend with its current attributes.
TLegend()
Default constructor.
virtual void EditEntryAttLine()
Edit the line attributes for the entry pointed by the mouse.
virtual void SetEntryOption(Option_t *option)
Edit the option of the entry pointed to by the mouse.
TLegend & operator=(const TLegend &)
Assignment operator.
virtual void SetEntryLabel(const char *label)
Edit the label of the entry pointed to by the mouse.
virtual void Print(Option_t *option="") const
Dump this TLegend and its contents.
virtual void PaintPrimitives()
Paint the entries (list of primitives) for this legend.
virtual void EditEntryAttFill()
Edit the fill attributes for the entry pointed by the mouse.
virtual const char * GetHeader() const
Returns the header, which is the title that appears at the top of the legend.
virtual void InsertEntry(const char *objectName="", const char *label="", Option_t *option="lpf")
Add a new entry before the entry at the mouse position.
virtual void PaintLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2)
Draw this line with new coordinates in NDC.
@ kLineNDC
Use NDC coordinates.
virtual void Paint(Option_t *option="")
Paint this line with its current attributes.
TObject * Next()
Return next object in the list. Returns 0 when no more objects in list.
virtual void Add(TObject *obj)
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual void AddFirst(TObject *obj)
Add object at the beginning of the list.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
virtual void AddBefore(const TObject *before, TObject *obj)
Insert object before object before in the list.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
virtual void Paint(Option_t *option="")
Paint this marker with its current attributes.
A TMultiGraph is a collection of TGraph (or derived) objects.
Mother of all ROOT objects.
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual const char * GetTitle() const
Returns title of object.
A TBox with a bordersize and a shadow option.
virtual void Print(Option_t *option="") const
Dump this pave with its attributes.
Double_t GetY2NDC() const
Int_t GetBorderSize() const
TPave & operator=(const TPave &src)
Assignment operator.
virtual void ConvertNDCtoPad()
Convert pave coordinates from NDC to Pad coordinates.
Double_t GetX2NDC() const
Int_t fBorderSize
window box bordersize in pixels
Double_t fX2NDC
X2 point in NDC coordinates.
Double_t GetY1NDC() const
virtual void SetBorderSize(Int_t bordersize=4)
TString fOption
Pave style.
Double_t fY2NDC
Y2 point in NDC coordinates.
void Copy(TObject &pave) const
Copy this pave to pave.
Double_t fX1NDC
X1 point in NDC coordinates.
Double_t fY1NDC
Y1 point in NDC coordinates.
Double_t GetX1NDC() const
virtual void PaintPave(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Int_t bordersize=4, Option_t *option="br")
Draw this pave with new coordinates.
Defined by an array on N points in a 2-D space.
virtual void Paint(Option_t *option="")
Paint this polyline with its current attributes.
void ToLower()
Change string to lower-case.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Width_t GetLegendBorderSize() const
Double_t GetLegendTextSize() const
Float_t GetEndErrorSize() const
Style_t GetLegendFont() const
Color_t GetLegendFillColor() const
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Double_t Ceil(Double_t x)
Short_t Min(Short_t a, Short_t b)