Logo ROOT   6.10/09
Reference Guide
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 
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 
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 
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 
76 {
77  return fRadiusOffset;
78 }
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 /// Return the value of this slice.
82 
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 
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 
109 {
110  fValue = val;
111  if (fValue<.0) {
112  Warning("SetValue","Invalid negative value. Absolute value taken");
113  fValue *= -1;
114  }
115 
117 }
TPie * fPie
The TPie object that contain this slice.
Definition: TPieSlice.h:24
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
void MakeSlices(Bool_t force=kFALSE)
Make the slices.
Definition: TPie.cxx:1407
const char Option_t
Definition: RtypesCore.h:62
void SavePrimitive(std::ostream &out, Option_t *opts="")
Do nothing.
Definition: TPieSlice.cxx:91
int Int_t
Definition: RtypesCore.h:41
Fill Area Attributes class.
Definition: TAttFill.h:19
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
A slice of a piechart, see the TPie class.
Definition: TPieSlice.h:18
void SetRadiusOffset(Double_t)
Set the radial offset of this slice.
Definition: TPieSlice.cxx:98
Bool_t fIsActive
! True if is the slice under the mouse pointer
Definition: TPieSlice.h:21
Double_t fValue
value value of this slice
Definition: TPieSlice.h:25
PyObject * fValue
virtual Int_t DistancetoPrimitive(Int_t, Int_t)
Eval if the mouse is over the area associated with this slice.
Definition: TPieSlice.cxx:59
void SetValue(Double_t)
Set the value for this slice.
Definition: TPieSlice.cxx:108
const Bool_t kFALSE
Definition: RtypesCore.h:92
#define ClassImp(name)
Definition: Rtypes.h:336
double Double_t
Definition: RtypesCore.h:55
TPieSlice()
This is the default constructor, used to create the standard.
Definition: TPieSlice.cxx:35
Double_t GetValue()
Return the value of this slice.
Definition: TPieSlice.cxx:83
Draw a Pie Chart,.
Definition: TPie.h:23
Double_t fRadiusOffset
offset from the center of the pie
Definition: TPieSlice.h:26
Double_t GetRadiusOffset()
return the value of the offset in radial direction for this slice.
Definition: TPieSlice.cxx:75
#define gPad
Definition: TVirtualPad.h:284
const Bool_t kTRUE
Definition: RtypesCore.h:91
Line Attributes class.
Definition: TAttLine.h:18
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:859