TPie.h

Go to the documentation of this file.
00001 // @(#)root/graf:$Id: TPie.h 22086 2008-02-11 13:51:10Z couet $
00002 // Author: Guido Volpi, Olivier Couet  03/11/2006
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TPie
00013 #define ROOT_TPie
00014 #ifndef ROOT_TObject
00015 #include "TObject.h"
00016 #endif
00017 #ifndef ROOT_TNamed
00018 #include <TNamed.h>
00019 #endif
00020 #ifndef ROOT_TString
00021 #include <TString.h>
00022 #endif
00023 #ifndef ROOT_TAttText
00024 #include <TAttText.h>
00025 #endif
00026 
00027 class TH1;
00028 class TPieSlice;
00029 class TLegend;
00030 
00031 class TPie : public TNamed , public TAttText {
00032 private:
00033    void Init(Int_t np, Double_t ao, Double_t x, Double_t y, Double_t r);
00034    void DrawGhost();
00035 
00036    Float_t  fSum;             //!Sum for the slice values
00037    Float_t *fSlices;          //!Subdivisions of the slices
00038    TLegend *fLegend;          //!Legend for this piechart
00039 
00040 protected:
00041    Double_t    fX;              // X coordinate of the pie centre
00042    Double_t    fY;              // Y coordinate of the pie centre
00043    Double_t    fRadius;         // Radius Pie radius
00044    Double_t    fAngularOffset;  // Offset angular offset for the first slice
00045    Float_t     fLabelsOffset;   // LabelsOffset offset of label
00046    TString     fLabelFormat;    // Format format of the slices' label
00047    TString     fValueFormat;    // Vform numeric format for the value
00048    TString     fFractionFormat; // Rform numeric format for the fraction of a slice
00049    TString     fPercentFormat;  // Pfrom numeric format for the percent of a slice
00050    Int_t       fNvals;          // Number of elements
00051    TPieSlice **fPieSlices;      //[fNvals] Slice array of this pie-chart
00052    Bool_t      fIs3D;           //! true if the pseudo-3d is enabled
00053    Double_t    fHeight;         // Pheight height of the slice in pixel
00054    Float_t     fAngle3D;        // The angle of the pseudo-3d view
00055 
00056 public:
00057    TPie();
00058    TPie(const char *,const char *, Int_t);
00059    TPie(const char *,const char *, Int_t, Double_t *,Int_t *cols=0, const char *lbls[]=0);
00060    TPie(const char *,const char *, Int_t, Float_t *,Int_t *cols=0, const char *lbls[]=0);
00061    TPie(const TH1 *h);
00062    TPie(const TPie&);
00063    ~TPie();
00064 
00065    virtual Int_t  DistancetoPrimitive(Int_t px, Int_t py);
00066    Int_t          DistancetoSlice(Int_t,Int_t);
00067    virtual void   Draw(Option_t *option="l"); // *MENU*
00068    virtual void   ExecuteEvent(Int_t,Int_t,Int_t);
00069    Float_t        GetAngle3D() { return fAngle3D; }
00070    Double_t       GetAngularOffset() { return fAngularOffset; }
00071    Int_t          GetEntryFillColor(Int_t);
00072    Int_t          GetEntryFillStyle(Int_t);
00073    const char*    GetEntryLabel(Int_t);
00074    Int_t          GetEntryLineColor(Int_t);
00075    Int_t          GetEntryLineStyle(Int_t);
00076    Int_t          GetEntryLineWidth(Int_t);
00077    Double_t       GetEntryRadiusOffset(Int_t);
00078    Double_t       GetEntryVal(Int_t);
00079    const char    *GetFractionFormat() { return fFractionFormat.Data(); }
00080    Double_t       GetHeight() { return fHeight; }
00081    const char    *GetLabelFormat() { return fLabelFormat.Data(); }
00082    Float_t        GetLabelsOffset() { return fLabelsOffset; }
00083    TLegend       *GetLegend();
00084    Int_t          GetEntries() { return fNvals; }
00085    const char    *GetPercentFormat() { return fPercentFormat.Data(); }
00086    Double_t       GetRadius() { return fRadius;}
00087    TPieSlice     *GetSlice(Int_t i);
00088    const char    *GetValueFormat() { return fValueFormat.Data(); }
00089    Double_t       GetX() { return fX; }
00090    Double_t       GetY() { return fY; }
00091    TLegend       *MakeLegend(Double_t x1=.65,Double_t y1=.65,Double_t x2=.95, Double_t y2=.95, const char *leg_header="");
00092    void           MakeSlices(Bool_t force=kFALSE);
00093    virtual void   Paint(Option_t *);
00094    void           SavePrimitive(ostream &out, Option_t *opts="");
00095    void           SetAngle3D(Float_t val = 30.); // *MENU*
00096    void           SetAngularOffset(Double_t);
00097    void           SetCircle(Double_t x=.5, Double_t y=.5, Double_t rad=.4);
00098    void           SetEntryLabel(Int_t, const char *text="Slice");
00099    void           SetEntryLineColor(Int_t, Int_t);
00100    void           SetEntryLineStyle(Int_t, Int_t);
00101    void           SetEntryLineWidth(Int_t, Int_t);
00102    void           SetEntryFillColor(Int_t, Int_t);
00103    void           SetEntryFillStyle(Int_t, Int_t);
00104    void           SetEntryRadiusOffset(Int_t, Double_t);
00105    void           SetEntryVal(Int_t, Double_t);
00106    void           SetFillColors(Int_t*);
00107    void           SetFractionFormat(const char*); // *MENU*
00108    void           SetHeight(Double_t val=.08); // *MENU*
00109    void           SetLabelFormat(const char *); // *MENU*
00110    void           SetLabels(const char *[]);
00111    void           SetLabelsOffset(Float_t); // *MENU*
00112    void           SetPercentFormat(const char *); // *MENU*
00113    void           SetRadius(Double_t); // *MENU*
00114    void           SetValueFormat(const char *); // *MENU*
00115    void           SetX(Double_t); // *MENU*
00116    void           SetY(Double_t); // *MENU*
00117    void           SortSlices(Bool_t amode=kTRUE,Float_t merge_thresold=.0);
00118 
00119    ClassDef(TPie,1) //Pie chart graphics class
00120 };
00121 
00122 #endif // ROOT_TPie

Generated on Tue Jul 5 14:14:10 2011 for ROOT_528-00b_version by  doxygen 1.5.1