Logo ROOT  
Reference Guide
TPie.h
Go to the documentation of this file.
1 // @(#)root/graf:$Id$
2 // Author: Guido Volpi, Olivier Couet 03/11/2006
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TPie
13 #define ROOT_TPie
14 
15 #include <TNamed.h>
16 #include <TAttText.h>
17 #include <TString.h>
18 
19 class TH1;
20 class TPieSlice;
21 class TLegend;
22 
23 class TPie : public TNamed , public TAttText {
24 private:
25  void Init(Int_t np, Double_t ao, Double_t x, Double_t y, Double_t r);
26  void DrawGhost();
27 
28  Float_t fSum; ///<!Sum for the slice values
29  Float_t *fSlices; ///<!Subdivisions of the slices
30  TLegend *fLegend; ///<!Legend for this piechart
31 
32 protected:
33  Double_t fX; ///< X coordinate of the pie centre
34  Double_t fY; ///< Y coordinate of the pie centre
35  Double_t fRadius; ///< Radius Pie radius
36  Double_t fAngularOffset; ///< Offset angular offset for the first slice
37  Float_t fLabelsOffset; ///< LabelsOffset offset of label
38  TString fLabelFormat; ///< Format format of the slices' label
39  TString fValueFormat; ///< Vform numeric format for the value
40  TString fFractionFormat; ///< Rform numeric format for the fraction of a slice
41  TString fPercentFormat; ///< Pfrom numeric format for the percent of a slice
42  Int_t fNvals; ///< Number of elements
43  TPieSlice **fPieSlices; ///<[fNvals] Slice array of this pie-chart
44  Bool_t fIs3D; ///<! true if the pseudo-3d is enabled
45  Double_t fHeight; ///< Height of the slice in pixel
46  Float_t fAngle3D; ///< The angle of the pseudo-3d view
47 
48 public:
49  TPie();
50  TPie(const char *,const char *, Int_t);
51  TPie(const char *,const char *, Int_t, Double_t *,Int_t *cols=0, const char *lbls[]=0);
52  TPie(const char *,const char *, Int_t, Float_t *,Int_t *cols=0, const char *lbls[]=0);
53  TPie(const TH1 *h);
54  TPie(const TPie&);
55  ~TPie();
56 
57  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
59  virtual void Draw(Option_t *option="l"); // *MENU*
60  virtual void ExecuteEvent(Int_t,Int_t,Int_t);
61  Float_t GetAngle3D() { return fAngle3D; }
65  const char* GetEntryLabel(Int_t);
71  const char *GetFractionFormat() { return fFractionFormat.Data(); }
72  Double_t GetHeight() { return fHeight; }
73  const char *GetLabelFormat() { return fLabelFormat.Data(); }
75  TLegend *GetLegend();
76  Int_t GetEntries() { return fNvals; }
77  const char *GetPercentFormat() { return fPercentFormat.Data(); }
78  Double_t GetRadius() { return fRadius;}
80  const char *GetValueFormat() { return fValueFormat.Data(); }
81  Double_t GetX() { return fX; }
82  Double_t GetY() { return fY; }
83  TLegend *MakeLegend(Double_t x1=.65,Double_t y1=.65,Double_t x2=.95, Double_t y2=.95, const char *leg_header="");
84  void MakeSlices(Bool_t force=kFALSE);
85  virtual void Paint(Option_t *);
86  void SavePrimitive(std::ostream &out, Option_t *opts="");
87  void SetAngle3D(Float_t val = 30.); // *MENU*
89  void SetCircle(Double_t x=.5, Double_t y=.5, Double_t rad=.4);
90  void SetEntryLabel(Int_t, const char *text="Slice");
97  void SetEntryVal(Int_t, Double_t);
98  void SetFillColors(Int_t*);
99  void SetFractionFormat(const char*); // *MENU*
100  void SetHeight(Double_t val=.08); // *MENU*
101  void SetLabelFormat(const char *); // *MENU*
102  void SetLabels(const char *[]);
103  void SetLabelsOffset(Float_t); // *MENU*
104  void SetPercentFormat(const char *); // *MENU*
105  void SetRadius(Double_t); // *MENU*
106  void SetValueFormat(const char *); // *MENU*
107  void SetX(Double_t); // *MENU*
108  void SetY(Double_t); // *MENU*
109  void SortSlices(Bool_t amode=kTRUE,Float_t merge_thresold=.0);
110 
111  ClassDef(TPie,1) //Pie chart graphics class
112 };
113 
114 #endif // ROOT_TPie
TPie::GetY
Double_t GetY()
Definition: TPie.h:82
TPie::fIs3D
Bool_t fIs3D
! true if the pseudo-3d is enabled
Definition: TPie.h:44
TAttText
Definition: TAttText.h:18
TPie::SetY
void SetY(Double_t)
Set Y value.
Definition: TPie.cxx:1399
TPie::SetX
void SetX(Double_t)
Set X value.
Definition: TPie.cxx:1391
TPie::SortSlices
void SortSlices(Bool_t amode=kTRUE, Float_t merge_thresold=.0)
This method, mainly intended for internal use, ordered the slices according their values.
Definition: TPie.cxx:1443
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TPie::fValueFormat
TString fValueFormat
Vform numeric format for the value.
Definition: TPie.h:39
TPie::SetLabels
void SetLabels(const char *[])
Set the labels for all the slices.
Definition: TPie.cxx:1344
TPie::SetCircle
void SetCircle(Double_t x=.5, Double_t y=.5, Double_t rad=.4)
Set the coordinates of the circle that describe the pie:
Definition: TPie.cxx:1210
TPie::ExecuteEvent
virtual void ExecuteEvent(Int_t, Int_t, Int_t)
Execute the mouse events.
Definition: TPie.cxx:395
TPie::GetFractionFormat
const char * GetFractionFormat()
Definition: TPie.h:71
TString::Data
const char * Data() const
Definition: TString.h:369
TAttText.h
TPie::SetRadius
void SetRadius(Double_t)
Set the pie chart's radius' value.
Definition: TPie.cxx:1369
r
ROOT::R::TRInterface & r
Definition: Object.C:4
TPie::TPie
TPie()
Default constructor.
Definition: TPie.cxx:63
TPie::fPieSlices
TPieSlice ** fPieSlices
[fNvals] Slice array of this pie-chart
Definition: TPie.h:43
TNamed.h
TPie::SetFillColors
void SetFillColors(Int_t *)
Set the fill colors for all the TPie's slices.
Definition: TPie.cxx:1288
TPie::MakeLegend
TLegend * MakeLegend(Double_t x1=.65, Double_t y1=.65, Double_t x2=.95, Double_t y2=.95, const char *leg_header="")
This method create a legend that explains the contents of the slice for this pie-chart.
Definition: TPie.cxx:770
TPie::SetLabelsOffset
void SetLabelsOffset(Float_t)
Set the distance between the label end the external line of the TPie.
Definition: TPie.cxx:1353
TPie::fAngle3D
Float_t fAngle3D
The angle of the pseudo-3d view.
Definition: TPie.h:46
Float_t
float Float_t
Definition: RtypesCore.h:57
TPie::fAngularOffset
Double_t fAngularOffset
Offset angular offset for the first slice.
Definition: TPie.h:36
Int_t
int Int_t
Definition: RtypesCore.h:45
TPie::SetLabelFormat
void SetLabelFormat(const char *)
This method is used to customize the label format.
Definition: TPie.cxx:1316
TPie::fLabelFormat
TString fLabelFormat
Format format of the slices' label.
Definition: TPie.h:38
TPie::SetEntryFillColor
void SetEntryFillColor(Int_t, Int_t)
Set the color for the slice "i".
Definition: TPie.cxx:1254
x
Double_t x[n]
Definition: legend1.C:17
TPie
Definition: TPie.h:23
TPie::GetLegend
TLegend * GetLegend()
If created before by Paint option or by MakeLegend method return the pointer to the legend,...
Definition: TPie.cxx:705
TPie::SetEntryLineColor
void SetEntryLineColor(Int_t, Int_t)
Set the color for the slice's outline. "i" is the slice number.
Definition: TPie.cxx:1230
TPie::fX
Double_t fX
X coordinate of the pie centre.
Definition: TPie.h:33
TPie::GetPercentFormat
const char * GetPercentFormat()
Definition: TPie.h:77
TString
Definition: TString.h:136
TPie::Init
void Init(Int_t np, Double_t ao, Double_t x, Double_t y, Double_t r)
Common initialization for all constructors.
Definition: TPie.cxx:723
TPie::fHeight
Double_t fHeight
Height of the slice in pixel.
Definition: TPie.h:45
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
text
TText * text
Definition: entrylist_figure1.C:10
TString.h
TPie::SetEntryLineStyle
void SetEntryLineStyle(Int_t, Int_t)
Set the style for the slice's outline. "i" is the slice number.
Definition: TPie.cxx:1238
TPie::GetHeight
Double_t GetHeight()
Definition: TPie.h:72
TPie::Draw
virtual void Draw(Option_t *option="l")
Draw the pie chart.
Definition: TPie.cxx:276
bool
TPie::SetEntryLineWidth
void SetEntryLineWidth(Int_t, Int_t)
Set the width of the slice's outline. "i" is the slice number.
Definition: TPie.cxx:1246
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
TPie::GetLabelsOffset
Float_t GetLabelsOffset()
Definition: TPie.h:74
TPie::GetEntryLineWidth
Int_t GetEntryLineWidth(Int_t)
Return the line width used to outline thi "i" slice.
Definition: TPie.cxx:680
TPie::SetValueFormat
void SetValueFormat(const char *)
Set the numeric format the slices' values.
Definition: TPie.cxx:1383
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TPie::SetPercentFormat
void SetPercentFormat(const char *)
Set the numeric format for the percent value of a slice, default: %3.1f.
Definition: TPie.cxx:1361
TPie::GetLabelFormat
const char * GetLabelFormat()
Definition: TPie.h:73
TPie::MakeSlices
void MakeSlices(Bool_t force=kFALSE)
Make the slices.
Definition: TPie.cxx:1408
TPie::SetEntryLabel
void SetEntryLabel(Int_t, const char *text="Slice")
Set slice number "i" label.
Definition: TPie.cxx:1221
TPie::DrawGhost
void DrawGhost()
This method is for internal use.
Definition: TPie.cxx:299
h
#define h(i)
Definition: RSha256.hxx:124
TPie::fFractionFormat
TString fFractionFormat
Rform numeric format for the fraction of a slice.
Definition: TPie.h:40
TNamed
Definition: TNamed.h:29
TPieSlice
Definition: TPieSlice.h:18
TPie::GetX
Double_t GetX()
Definition: TPie.h:81
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TPie::fSlices
Float_t * fSlices
!Subdivisions of the slices
Definition: TPie.h:29
TPie::GetEntryFillColor
Int_t GetEntryFillColor(Int_t)
Return the color of the slice number "i".
Definition: TPie.cxx:648
TPie::SavePrimitive
void SavePrimitive(std::ostream &out, Option_t *opts="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TPie.cxx:1125
TPie::fNvals
Int_t fNvals
Number of elements.
Definition: TPie.h:42
TPie::GetValueFormat
const char * GetValueFormat()
Definition: TPie.h:80
y
Double_t y[n]
Definition: legend1.C:17
TGeant4Unit::rad
static constexpr double rad
Definition: TGeant4SystemOfUnits.h:148
TPie::GetSlice
TPieSlice * GetSlice(Int_t i)
Return the reference to the slice of index 'id'.
Definition: TPie.cxx:714
TPie::GetEntryLineColor
Int_t GetEntryLineColor(Int_t)
Return the line color used to outline thi "i" slice.
Definition: TPie.cxx:664
TPie::SetEntryFillStyle
void SetEntryFillStyle(Int_t, Int_t)
Set the fill style for the "i" slice.
Definition: TPie.cxx:1262
TPie::fLegend
TLegend * fLegend
!Legend for this piechart
Definition: TPie.h:30
TPie::fRadius
Double_t fRadius
Radius Pie radius.
Definition: TPie.h:35
Double_t
double Double_t
Definition: RtypesCore.h:59
TPie::SetAngularOffset
void SetAngularOffset(Double_t)
Set the global angular offset for slices in degree [0,360].
Definition: TPie.cxx:1193
TPie::fSum
Float_t fSum
!Sum for the slice values
Definition: TPie.h:28
TPie::SetEntryVal
void SetEntryVal(Int_t, Double_t)
Set the value of a slice.
Definition: TPie.cxx:1278
TPie::GetEntryLineStyle
Int_t GetEntryLineStyle(Int_t)
Return the style used to outline thi "i" slice.
Definition: TPie.cxx:672
TPie::Paint
virtual void Paint(Option_t *)
Paint a Pie chart in a canvas.
Definition: TPie.cxx:804
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TH1
Definition: TH1.h:57
TPie::GetEntryFillStyle
Int_t GetEntryFillStyle(Int_t)
Return the style use to fill the slice number "i".
Definition: TPie.cxx:656
TPie::GetEntryRadiusOffset
Double_t GetEntryRadiusOffset(Int_t)
Return the radial offset's value for the slice number "i".
Definition: TPie.cxx:688
TPie::fPercentFormat
TString fPercentFormat
Pfrom numeric format for the percent of a slice.
Definition: TPie.h:41
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
TPie::SetAngle3D
void SetAngle3D(Float_t val=30.)
Set the value of for the pseudo 3D view angle, in degree.
Definition: TPie.cxx:1180
TPie::GetRadius
Double_t GetRadius()
Definition: TPie.h:78
TPie::GetEntryLabel
const char * GetEntryLabel(Int_t)
Returns the label of the entry number "i".
Definition: TPie.cxx:640
TLegend
Definition: TLegend.h:23
TPie::fY
Double_t fY
Y coordinate of the pie centre.
Definition: TPie.h:34
TPie::GetEntryVal
Double_t GetEntryVal(Int_t)
Return the value associated with the slice number "i".
Definition: TPie.cxx:696
TPie::SetEntryRadiusOffset
void SetEntryRadiusOffset(Int_t, Double_t)
Set the distance, in the direction of the radius of the slice.
Definition: TPie.cxx:1270
TPie::GetAngle3D
Float_t GetAngle3D()
Definition: TPie.h:61
TPie::SetHeight
void SetHeight(Double_t val=.08)
Set the height, in pixel, for the piechart if is drawn using the pseudo-3d mode.
Definition: TPie.cxx:1300
TPie::DistancetoSlice
Int_t DistancetoSlice(Int_t, Int_t)
Returns the slice number at the pixel position (px,py).
Definition: TPie.cxx:190
TPie::SetFractionFormat
void SetFractionFormat(const char *)
Set numeric format in the label, is used if the label format there is the modifier frac,...
Definition: TPie.cxx:1336
TPie::GetEntries
Int_t GetEntries()
Definition: TPie.h:76
TPie::fLabelsOffset
Float_t fLabelsOffset
LabelsOffset offset of label.
Definition: TPie.h:37
TPie::GetAngularOffset
Double_t GetAngularOffset()
Definition: TPie.h:62
int
TPie::~TPie
~TPie()
Destructor.
Definition: TPie.cxx:156
TPie::DistancetoPrimitive
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Evaluate the distance to the chart in gPad.
Definition: TPie.cxx:170