207 const char *header,
Option_t *option)
208 :TPave(x1,y1,x2,y2,4,option), TAttText(12,0,1,
gStyle->GetLegendFont(),0)
211 if ( header && strlen(header) > 0) {
239 ((
TLegend&)legend).Copy(*
this);
282 const char *lab = label;
284 if (obj && (!label || strlen(label)==0)) lab = obj->
GetTitle();
306 Error(
"AddEntry",
"need to create a canvas first");
315 TList *lop =
gPad->GetListOfPrimitives();
319 while( (o=
next()) ) {
334 return AddEntry( obj, label, option );
365 if ( !entry )
return;
384 if ( !entry )
return;
385 gROOT->SetSelectedPrimitive( entry );
395 if ( !entry )
return;
396 gROOT->SetSelectedPrimitive( entry );
406 if ( !entry )
return;
407 gROOT->SetSelectedPrimitive( entry );
417 if ( !entry )
return;
418 gROOT->SetSelectedPrimitive( entry );
429 Error(
"GetEntry",
"need to create a canvas first");
434 if ( nRows == 0 )
return 0;
442 if (nColumns > 0) xspace = (
fX2 -
fX1)/nColumns;
445 if (xspace > 0.) ix = (
Int_t)(xmouse/xspace)+1;
446 if (ix > nColumns) ix = nColumns;
450 if (iy > nRows) iy = nRows;
486 Error(
"InsertEntry",
"need to create a canvas first");
522 if ( nEntries == 0 )
return 0;
541 Warning(
"TLegend::SetNColumns",
"illegal value nColumns = %d; keeping fNColumns = %d", nColumns,
fNColumns);
553 if ( nRows == 0 )
return;
579 if ( textsize == 0 ) {
584 Double_t maxentrywidth = 0, maxentryheight = 0;
593 if (tfont%10 == 3) --tfont;
594 entrytex.SetTextFont(tfont);
595 entrytex.SetTextSize(textsize);
596 if ( entrytex.GetYsize() > maxentryheight ) {
597 maxentryheight = entrytex.GetYsize();
602 if ( entrytex.GetXsize() > maxentrywidth ) {
603 maxentrywidth = entrytex.GetXsize();
606 if ( entrytex.GetXsize() > columnWidths[iColumn] ) {
607 columnWidths[iColumn] = entrytex.GetXsize();
613 for(
int i=0; i<
fNColumns; i++) tmpMaxWidth += columnWidths[i];
614 if ( tmpMaxWidth > maxentrywidth) maxentrywidth = tmpMaxWidth;
638 if (autosize && tfont%10 == 3) --tfont;
639 entrytex.SetTextFont(tfont);
640 if(entry->
GetTextSize() == 0) entrytex.SetTextSize(textsize);
644 if ( entrytex.GetXsize() > columnWidths[iColumn] ) {
645 columnWidths[iColumn] = entrytex.GetXsize();
651 double totalWidth = 0.0;
652 for(
int i=0; i<
fNColumns; i++) totalWidth += columnWidths[i];
654 else totalWidth /= (1.0 -
fMargin);
656 columnWidths[i] = columnWidths[i]/totalWidth*(x2-
x1) + margin;
667 if(iColumn == 0) ytext -= yspace;
682 if (autosize && tfont%10 == 3) --tfont;
695 if ( opt.
Contains(
"h") ) entrymargin = margin/10.;
698 x2 = x1 + columnWidths[iColumn];
702 if (halign == 1) x = x1 + entrymargin;
703 if (halign == 2) x = 0.5*( (x1+entrymargin) + x2 );
704 if (halign == 3) x = x2 - entrymargin/10.;
714 if (tfont%10 == 3) tsizepad = (
gPad->AbsPixeltoY(0) -
gPad->AbsPixeltoY(textsize))/(
gPad->GetY2() -
gPad->GetY1());
715 if (yspace2 < tsizepad) {
725 entry->TAttText::Copy(entrytex);
749 entry->TAttFill::Modify();
752 yf[0] = ysym - yspace*0.35;
756 yf[2] = ysym + yspace*0.35;
759 for (
Int_t i=0;i<4;i++) {
760 xf[i] =
gPad->GetX1() + xf[i]*(
gPad->GetX2()-
gPad->GetX1());
761 yf[i] =
gPad->GetY1() + yf[i]*(
gPad->GetY2()-
gPad->GetY1());
763 gPad->PaintFillArea(4,xf,yf);
774 TLine entryline( xsym - boxw, ysym, xsym + boxw, ysym );
776 entry->TAttLine::Copy(entryline);
782 if ( boxwidth > margin ) boxwidth = margin;
784 entryline.
PaintLineNDC( xsym - boxw, ysym + yspace*0.35,
785 xsym + boxw, ysym + yspace*0.35);
786 entryline.
PaintLineNDC( xsym - boxw, ysym - yspace*0.35,
787 xsym + boxw, ysym - yspace*0.35);
788 entryline.
PaintLineNDC( xsym + boxw, ysym - yspace*0.35,
789 xsym + boxw, ysym + yspace*0.35);
790 entryline.
PaintLineNDC( xsym - boxw, ysym - yspace*0.35,
791 xsym - boxw, ysym + yspace*0.35);
796 xsym, ysym + yspace*0.30);
807 TLine entryline(xsym, ysym - yspace*0.30,
808 xsym, ysym + yspace*0.30);
810 entry->TAttLine::Copy(entryline);
821 TMarker entrymarker( xsym, ysym, 0 );
823 entry->TAttMarker::Copy(entrymarker);
829 delete [] columnWidths;
860 out <<
" " << std::endl;
870 <<
"NULL" <<
"," <<quote<<
fOption <<quote<<
");" << std::endl;
872 out<<
" leg->SetBorderSize("<<
fBorderSize<<
");"<<std::endl;
882 out <<
" leg->Draw();"<<std::endl;
891 if ( entry ) entry->
SetLabel( label );
virtual void Clear(Option_t *option="")
Clear all entries in this legend, including the header.
TBox & operator=(const TBox &)
Assignment operator.
Int_t GetNRows() const
Get the number of rows.
virtual void Copy(TObject &obj) const
Copy this legend into "obj".
virtual void SetLineAttributes()
Invoke the DialogCanvas Line attributes.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual Float_t GetTextAngle() const
virtual void SetFillAttributes()
Invoke the DialogCanvas Fill attributes.
This class displays a legend box (TPaveText) containing several legend entries.
The Histogram stack class.
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
virtual Font_t GetTextFont() const
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
void Copy(TAttText &atttext) const
Copy this text attributes to a new TAttText.
virtual void EditEntryAttFill()
Edit the fill attributes for the entry pointed by the mouse.
R__EXTERN TStyle * gStyle
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
Int_t GetBorderSize() const
Int_t GetNColumns() const
TLegend & operator=(const TLegend &)
Assignment operator.
virtual void EditEntryAttText()
Edit the text attributes for the entry pointed by the mouse.
TLegendEntry * GetEntry() const
Get entry pointed to by the mouse.
A TMultiGraph is a collection of TGraph (or derived) objects.
virtual void AddFirst(TObject *obj)
Add object at the beginning of the list.
virtual Float_t GetTextSize() const
Double_t GetX1NDC() const
Storage class for one entry of a TLegend.
virtual void SetTextAttributes()
Invoke the DialogCanvas Text attributes.
virtual void EditEntryAttMarker()
Edit the marker attributes for the entry pointed by the mouse.
Double_t GetY1NDC() const
virtual void SetMarkerAttributes()
Invoke the DialogCanvas Marker attributes.
Short_t Min(Short_t a, Short_t b)
void ToLower()
Change string to lower-case.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
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 ...
void Copy(TObject &pave) const
Copy this pave to pave.
TObject * Next()
Return next object in the list. Returns 0 when no more objects in list.
Color_t GetLegendFillColor() const
virtual void DeleteEntry()
Delete entry at the mouse position.
virtual void SetEntryLabel(const char *label)
Edit the label of the entry pointed to by the mouse.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual void ConvertNDCtoPad()
Convert pave coordinates from NDC to Pad coordinates.
virtual void SetTextFont(Font_t tfont=62)
static const double x2[5]
virtual void PaintLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2)
Draw this line with new coordinates in NDC.
virtual Short_t GetTextAlign() const
virtual void SetObject(TObject *obj)
(re)set the obj pointed to by this entry
Fill Area Attributes class.
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 void InsertEntry(const char *objectName="", const char *label="", Option_t *option="lpf")
Add a new entry before the entry at the mouse position.
To draw Mathematical Formula.
virtual Color_t GetTextColor() const
Double_t GetY2NDC() const
virtual void Paint(Option_t *option="")
Paint this line with its current attributes.
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Double_t GetLegendTextSize() const
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 Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void SetTextAlign(Short_t align=11)
virtual void SetLabel(const char *label="")
virtual void Paint(Option_t *option="")
Paint this marker with its current attributes.
virtual void EditEntryAttLine()
Edit the line attributes for the entry pointed by the mouse.
void SetNColumns(Int_t nColumns)
Set the number of columns for the legend.
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 SetFillColor(Color_t fcolor)
Float_t fColumnSeparation
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual void SetTextAngle(Float_t tangle=0)
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 void SetOption(Option_t *option="lpf")
Double_t fX1
tool tip associated with box
virtual const char * GetHeader() const
Returns the header, which is the title that appears at the top of the legend.
virtual void AddBefore(const TObject *before, TObject *obj)
Insert object before object before in the list.
virtual TObject * GetObject() const
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
virtual Int_t GetSize() const
static const double x1[5]
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
virtual void Print(Option_t *option="") const
Dump this pave with its attributes.
Double_t GetX2NDC() const
virtual void RecursiveRemove(TObject *obj)
Reset the legend entries pointing to "obj".
virtual Option_t * GetOption() const
Width_t GetLegendBorderSize() const
Binding & operator=(OUT(*fun)(void))
Mother of all ROOT objects.
virtual ~TLegend()
Default destructor.
virtual void Add(TObject *obj)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual void SetHeader(const char *header="")
Sets the header, which is the "title" that appears at the top of the legend.
Double_t Ceil(Double_t x)
virtual void SetTextColor(Color_t tcolor=1)
virtual void Paint(Option_t *option="")
Paint this legend with its current attributes.
virtual const char * GetLabel() const
virtual void Print(Option_t *option="") const
Dump this TLegend and its contents.
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.
virtual void SetTextSize(Float_t tsize=1)
virtual const char * GetTitle() const
Returns title of object.
Style_t GetLegendFont() const
virtual void SetBorderSize(Int_t bordersize=4)
virtual void PaintPrimitives()
Paint the entries (list of primitives) for this legend.
virtual void SetEntryOption(Option_t *option)
Edit the option of the entry pointed to by the mouse.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.