ROOT logo
// @(#)root/graf:$Id$
// Author: Guido Volpi, Olivier Couet  03/11/2006

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TPie
#define ROOT_TPie
#ifndef ROOT_TObject
#include "TObject.h"
#endif
#ifndef ROOT_TNamed
#include <TNamed.h>
#endif
#ifndef ROOT_TString
#include <TString.h>
#endif
#ifndef ROOT_TAttText
#include <TAttText.h>
#endif

class TH1;
class TPieSlice;
class TLegend;

class TPie : public TNamed , public TAttText {
private:
   void Init(Int_t np, Double_t ao, Double_t x, Double_t y, Double_t r);
   void DrawGhost();

   Float_t  fSum;             //!Sum for the slice values
   Float_t *fSlices;          //!Subdivisions of the slices
   TLegend *fLegend;          //!Legend for this piechart

protected:
   Double_t    fX;              // X coordinate of the pie centre
   Double_t    fY;              // Y coordinate of the pie centre
   Double_t    fRadius;         // Radius Pie radius
   Double_t    fAngularOffset;  // Offset angular offset for the first slice
   Float_t     fLabelsOffset;   // LabelsOffset offset of label
   TString     fLabelFormat;    // Format format of the slices' label
   TString     fValueFormat;    // Vform numeric format for the value
   TString     fFractionFormat; // Rform numeric format for the fraction of a slice
   TString     fPercentFormat;  // Pfrom numeric format for the percent of a slice
   Int_t       fNvals;          // Number of elements
   TPieSlice **fPieSlices;      //[fNvals] Slice array of this pie-chart
   Bool_t      fIs3D;           //! true if the pseudo-3d is enabled
   Double_t    fHeight;         // Pheight height of the slice in pixel
   Float_t     fAngle3D;        // The angle of the pseudo-3d view

public:
   TPie();
   TPie(const char *,const char *, Int_t);
   TPie(const char *,const char *, Int_t, Double_t *,Int_t *cols=0, const char *lbls[]=0);
   TPie(const char *,const char *, Int_t, Float_t *,Int_t *cols=0, const char *lbls[]=0);
   TPie(const TH1 *h);
   TPie(const TPie&);
   ~TPie();

   virtual Int_t  DistancetoPrimitive(Int_t px, Int_t py);
   Int_t          DistancetoSlice(Int_t,Int_t);
   virtual void   Draw(Option_t *option="l"); // *MENU*
   virtual void   ExecuteEvent(Int_t,Int_t,Int_t);
   Float_t        GetAngle3D() { return fAngle3D; }
   Double_t       GetAngularOffset() { return fAngularOffset; }
   Int_t          GetEntryFillColor(Int_t);
   Int_t          GetEntryFillStyle(Int_t);
   const char*    GetEntryLabel(Int_t);
   Int_t          GetEntryLineColor(Int_t);
   Int_t          GetEntryLineStyle(Int_t);
   Int_t          GetEntryLineWidth(Int_t);
   Double_t       GetEntryRadiusOffset(Int_t);
   Double_t       GetEntryVal(Int_t);
   const char    *GetFractionFormat() { return fFractionFormat.Data(); }
   Double_t       GetHeight() { return fHeight; }
   const char    *GetLabelFormat() { return fLabelFormat.Data(); }
   Float_t        GetLabelsOffset() { return fLabelsOffset; }
   TLegend       *GetLegend();
   Int_t          GetEntries() { return fNvals; }
   const char    *GetPercentFormat() { return fPercentFormat.Data(); }
   Double_t       GetRadius() { return fRadius;}
   TPieSlice     *GetSlice(Int_t i);
   const char    *GetValueFormat() { return fValueFormat.Data(); }
   Double_t       GetX() { return fX; }
   Double_t       GetY() { return fY; }
   TLegend       *MakeLegend(Double_t x1=.65,Double_t y1=.65,Double_t x2=.95, Double_t y2=.95, const char *leg_header="");
   void           MakeSlices(Bool_t force=kFALSE);
   virtual void   Paint(Option_t *);
   void           SavePrimitive(ostream &out, Option_t *opts="");
   void           SetAngle3D(Float_t val = 30.); // *MENU*
   void           SetAngularOffset(Double_t);
   void           SetCircle(Double_t x=.5, Double_t y=.5, Double_t rad=.4);
   void           SetEntryLabel(Int_t, const char *text="Slice");
   void           SetEntryLineColor(Int_t, Int_t);
   void           SetEntryLineStyle(Int_t, Int_t);
   void           SetEntryLineWidth(Int_t, Int_t);
   void           SetEntryFillColor(Int_t, Int_t);
   void           SetEntryFillStyle(Int_t, Int_t);
   void           SetEntryRadiusOffset(Int_t, Double_t);
   void           SetEntryVal(Int_t, Double_t);
   void           SetFillColors(Int_t*);
   void           SetFractionFormat(const char*); // *MENU*
   void           SetHeight(Double_t val=.08); // *MENU*
   void           SetLabelFormat(const char *); // *MENU*
   void           SetLabels(const char *[]);
   void           SetLabelsOffset(Float_t); // *MENU*
   void           SetPercentFormat(const char *); // *MENU*
   void           SetRadius(Double_t); // *MENU*
   void           SetValueFormat(const char *); // *MENU*
   void           SetX(Double_t); // *MENU*
   void           SetY(Double_t); // *MENU*
   void           SortSlices(Bool_t amode=kTRUE,Float_t merge_thresold=.0);

   ClassDef(TPie,1) //Pie chart graphics class
};

#endif // ROOT_TPie
 TPie.h:1
 TPie.h:2
 TPie.h:3
 TPie.h:4
 TPie.h:5
 TPie.h:6
 TPie.h:7
 TPie.h:8
 TPie.h:9
 TPie.h:10
 TPie.h:11
 TPie.h:12
 TPie.h:13
 TPie.h:14
 TPie.h:15
 TPie.h:16
 TPie.h:17
 TPie.h:18
 TPie.h:19
 TPie.h:20
 TPie.h:21
 TPie.h:22
 TPie.h:23
 TPie.h:24
 TPie.h:25
 TPie.h:26
 TPie.h:27
 TPie.h:28
 TPie.h:29
 TPie.h:30
 TPie.h:31
 TPie.h:32
 TPie.h:33
 TPie.h:34
 TPie.h:35
 TPie.h:36
 TPie.h:37
 TPie.h:38
 TPie.h:39
 TPie.h:40
 TPie.h:41
 TPie.h:42
 TPie.h:43
 TPie.h:44
 TPie.h:45
 TPie.h:46
 TPie.h:47
 TPie.h:48
 TPie.h:49
 TPie.h:50
 TPie.h:51
 TPie.h:52
 TPie.h:53
 TPie.h:54
 TPie.h:55
 TPie.h:56
 TPie.h:57
 TPie.h:58
 TPie.h:59
 TPie.h:60
 TPie.h:61
 TPie.h:62
 TPie.h:63
 TPie.h:64
 TPie.h:65
 TPie.h:66
 TPie.h:67
 TPie.h:68
 TPie.h:69
 TPie.h:70
 TPie.h:71
 TPie.h:72
 TPie.h:73
 TPie.h:74
 TPie.h:75
 TPie.h:76
 TPie.h:77
 TPie.h:78
 TPie.h:79
 TPie.h:80
 TPie.h:81
 TPie.h:82
 TPie.h:83
 TPie.h:84
 TPie.h:85
 TPie.h:86
 TPie.h:87
 TPie.h:88
 TPie.h:89
 TPie.h:90
 TPie.h:91
 TPie.h:92
 TPie.h:93
 TPie.h:94
 TPie.h:95
 TPie.h:96
 TPie.h:97
 TPie.h:98
 TPie.h:99
 TPie.h:100
 TPie.h:101
 TPie.h:102
 TPie.h:103
 TPie.h:104
 TPie.h:105
 TPie.h:106
 TPie.h:107
 TPie.h:108
 TPie.h:109
 TPie.h:110
 TPie.h:111
 TPie.h:112
 TPie.h:113
 TPie.h:114
 TPie.h:115
 TPie.h:116
 TPie.h:117
 TPie.h:118
 TPie.h:119
 TPie.h:120
 TPie.h:121
 TPie.h:122