Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TPieSlice.cxx
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
3  * All rights reserved. *
4  * *
5  * For the licensing terms see $ROOTSYS/LICENSE. *
6  * For the list of contributors see $ROOTSYS/README/CREDITS. *
7  *************************************************************************/
8 
9 #include <TPieSlice.h>
10 
11 #include <Riostream.h>
12 #include <TError.h>
13 #include <TROOT.h>
14 #include <TVirtualPad.h>
15 #include <TArc.h>
16 #include <TMath.h>
17 #include <TStyle.h>
18 #include <TLatex.h>
19 #include <TPaveText.h>
20 #include <TH1.h>
21 
22 ClassImp(TPieSlice);
23 
24 /** \class TPieSlice
25 \ingroup BasicGraphics
26 
27 A slice of a piechart, see the TPie class.
28 
29 This class describe the property of single
30 */
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// This is the default constructor, used to create the standard.
34 
35 TPieSlice::TPieSlice() : TNamed(), TAttFill(), TAttLine()
36 {
37  fPie = 0;
38  fValue = 1;
39  fRadiusOffset = 0;
40  fIsActive = kFALSE;
41 }
42 
43 ////////////////////////////////////////////////////////////////////////////////
44 /// This constructor create a slice with a particular value.
45 
46 TPieSlice::TPieSlice(const char *name, const char *title,
47  TPie *pie, Double_t val) :
48  TNamed(name, title), TAttFill(), TAttLine()
49 {
50  fPie = pie;
51  fValue = val;
52  fRadiusOffset = 0;
53  fIsActive = kFALSE;
54 }
55 
56 ////////////////////////////////////////////////////////////////////////////////
57 /// Eval if the mouse is over the area associated with this slice.
58 
59 Int_t TPieSlice::DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/)
60 {
61  Int_t dist = 9999;
62 
63  if (fIsActive) {
64  dist = 0;
65  fIsActive = kFALSE;
66  gPad->SetCursor(kHand);
67  }
68 
69  return dist;
70 }
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 /// return the value of the offset in radial direction for this slice.
74 
75 Double_t TPieSlice::GetRadiusOffset()
76 {
77  return fRadiusOffset;
78 }
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 /// Return the value of this slice.
82 
83 Double_t TPieSlice::GetValue()
84 {
85  return fValue;
86 }
87 
88 ////////////////////////////////////////////////////////////////////////////////
89 /// Do nothing.
90 
91 void TPieSlice::SavePrimitive(std::ostream &/*out*/, Option_t * /*opts*/)
92 {
93 }
94 
95 ////////////////////////////////////////////////////////////////////////////////
96 /// Set the radial offset of this slice.
97 
98 void TPieSlice::SetRadiusOffset(Double_t val)
99 {
100  fRadiusOffset = val;
101  if (fRadiusOffset<.0) fRadiusOffset = .0;
102 }
103 
104 ////////////////////////////////////////////////////////////////////////////////
105 /// Set the value for this slice.
106 /// Negative values are changed with its absolute value.
107 
108 void TPieSlice::SetValue(Double_t val)
109 {
110  fValue = val;
111  if (fValue<.0) {
112  Warning("SetValue","Invalid negative value. Absolute value taken");
113  fValue *= -1;
114  }
115 
116  fPie->MakeSlices(kTRUE);
117 }