Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 #include "TObject.h"
15 #include <TNamed.h>
16 #include <TString.h>
17 #include <TAttText.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);
58  Int_t DistancetoSlice(Int_t,Int_t);
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; }
62  Double_t GetAngularOffset() { return fAngularOffset; }
63  Int_t GetEntryFillColor(Int_t);
64  Int_t GetEntryFillStyle(Int_t);
65  const char* GetEntryLabel(Int_t);
66  Int_t GetEntryLineColor(Int_t);
67  Int_t GetEntryLineStyle(Int_t);
68  Int_t GetEntryLineWidth(Int_t);
69  Double_t GetEntryRadiusOffset(Int_t);
70  Double_t GetEntryVal(Int_t);
71  const char *GetFractionFormat() { return fFractionFormat.Data(); }
72  Double_t GetHeight() { return fHeight; }
73  const char *GetLabelFormat() { return fLabelFormat.Data(); }
74  Float_t GetLabelsOffset() { return fLabelsOffset; }
75  TLegend *GetLegend();
76  Int_t GetEntries() { return fNvals; }
77  const char *GetPercentFormat() { return fPercentFormat.Data(); }
78  Double_t GetRadius() { return fRadius;}
79  TPieSlice *GetSlice(Int_t i);
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*
88  void SetAngularOffset(Double_t);
89  void SetCircle(Double_t x=.5, Double_t y=.5, Double_t rad=.4);
90  void SetEntryLabel(Int_t, const char *text="Slice");
91  void SetEntryLineColor(Int_t, Int_t);
92  void SetEntryLineStyle(Int_t, Int_t);
93  void SetEntryLineWidth(Int_t, Int_t);
94  void SetEntryFillColor(Int_t, Int_t);
95  void SetEntryFillStyle(Int_t, Int_t);
96  void SetEntryRadiusOffset(Int_t, Double_t);
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