TPieSlice.cxx

Go to the documentation of this file.
00001 /*************************************************************************
00002  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00003  * All rights reserved.                                                  *
00004  *                                                                       *
00005  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00006  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00007  *************************************************************************/
00008 
00009 #include <TPieSlice.h>
00010 
00011 #include <Riostream.h>
00012 #include <TError.h>
00013 #include <TROOT.h>
00014 #include <TVirtualPad.h>
00015 #include <TArc.h>
00016 #include <TMath.h>
00017 #include <TStyle.h>
00018 #include <TLatex.h>
00019 #include <TPaveText.h>
00020 #include <TH1.h>
00021 
00022 ClassImp(TPieSlice)
00023 
00024 
00025 //______________________________________________________________________________
00026 //
00027 // A slice of a piechart, see the TPie class.
00028 //
00029 // This class describe the property of single
00030 //
00031 
00032 
00033 //______________________________________________________________________________
00034 TPieSlice::TPieSlice() : TNamed(), TAttFill(), TAttLine()
00035 {
00036    // This is the default constructor, used to create the standard.
00037 
00038    fPie = 0;
00039    fValue = 1;
00040    fRadiusOffset = 0;
00041    fIsActive = kFALSE;
00042 }
00043 
00044 
00045 //______________________________________________________________________________
00046 TPieSlice::TPieSlice(const char *name, const char *title,
00047                      TPie *pie, Double_t val) :
00048                      TNamed(name, title), TAttFill(), TAttLine()
00049 {
00050    // This constructor create a slice with a particular value.
00051 
00052    fPie = pie;
00053    fValue = val;
00054    fRadiusOffset = 0;
00055    fIsActive = kFALSE;
00056 }
00057 
00058 
00059 //______________________________________________________________________________
00060 Int_t TPieSlice::DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/)
00061 {
00062    // Eval if the mouse is over the area associated with this slice.
00063 
00064    Int_t dist = 9999;
00065 
00066    if (fIsActive) {
00067       dist = 0;
00068       fIsActive = kFALSE;
00069       gPad->SetCursor(kHand);
00070    }
00071 
00072    return dist;
00073 }
00074 
00075 
00076 //______________________________________________________________________________
00077 Double_t TPieSlice::GetRadiusOffset()
00078 {
00079    // return the value of the offset in radial direction for this slice.
00080 
00081    return fRadiusOffset;
00082 }
00083 
00084 
00085 //______________________________________________________________________________
00086 Double_t TPieSlice::GetValue()
00087 {
00088    // Return the value of this slice.
00089 
00090    return fValue;
00091 }
00092 
00093 
00094 //______________________________________________________________________________
00095 void TPieSlice::SavePrimitive(ostream &/*out*/, Option_t * /*opts*/)
00096 {
00097    // Do nothing.
00098 }
00099 
00100 
00101 //______________________________________________________________________________
00102 void TPieSlice::SetRadiusOffset(Double_t val)
00103 {
00104    // Set the radial offset of this slice.
00105 
00106    fRadiusOffset = val;
00107    if (fRadiusOffset<.0) fRadiusOffset = .0;
00108 }
00109 
00110 
00111 //______________________________________________________________________________
00112 void TPieSlice::SetValue(Double_t val)
00113 {
00114    // Set the value for this slice.
00115    // Negative values are changed with its absolute value.
00116 
00117    fValue = val;
00118    if (fValue<.0) {
00119       Warning("SetValue","Invalid negative value. Absolute value taken");
00120       fValue *= -1;
00121    }
00122 
00123    fPie->MakeSlices(kTRUE);
00124 }

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