Logo ROOT   6.12/07
Reference Guide
TPaveStatsEditor.cxx
Go to the documentation of this file.
1 // @(#)root/ged:$Id$
2 // Author: Ilka Antcheva
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TPaveStatsEditor //
15 // //
16 // Implements GUI for editing attributes of TPaveStats objects. // //
17 // all text attributes //
18 // The following statistics option settings can be set: //
19 // name, mean, RMS, overflow, underflow, integral of bins, //
20 // Fit parameters that can be set are: Values/Names, Probability, //
21 // Errors, Chisquare //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 //Begin_Html
25 /*
26 <img src="gif/TPaveStatsEditor.gif">
27 */
28 //End_Html
29 
30 #include "TPaveStatsEditor.h"
31 #include "TGButton.h"
32 #include "TPaveStats.h"
33 
35 
51 };
52 
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 /// Constructor of TPaveStats GUI.
56 
58  UInt_t options, Pixel_t back) :
59  TGedFrame(p, width, height, options | kVerticalFrame, back)
60 {
61  fPaveStats = 0;
62 
63  MakeTitle("Stat Options");
64 
66  TGCompositeFrame *f2 = new TGCompositeFrame(f1, 40, 20, kVerticalFrame);
67  f1->AddFrame(f2, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
68 
69  fHistoName = new TGCheckButton(f2, "Name", kSTAT_NAME);
70  fHistoName->SetToolTipText("Print the histogram name");
71  f2->AddFrame(fHistoName, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
72  fOverflow = new TGCheckButton(f2, "Overflow", kSTAT_OVER);
73  fOverflow->SetToolTipText("Print the number of overflows");
74  f2->AddFrame(fOverflow, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
75  fUnderflow = new TGCheckButton(f2, "Underflow", kSTAT_UNDER);
76  fUnderflow->SetToolTipText("Print the number of underflows");
77  f2->AddFrame(fUnderflow, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
78  fSkewness = new TGCheckButton(f2, "Skewness", kSTAT_SKEWNESS);
79  fSkewness->SetToolTipText("Print the skewness");
80  f2->AddFrame(fSkewness, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
81  fKurtosis = new TGCheckButton(f2, "Kurtosis", kSTAT_KURTOSIS);
82  fKurtosis->SetToolTipText("Print the kurtosis");
83  f2->AddFrame(fKurtosis, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
84 
85  TGCompositeFrame *f3 = new TGCompositeFrame(f1, 40, 20, kVerticalFrame);
86  fEntries = new TGCheckButton(f3, "Entries", kSTAT_ENTRIES);
87  fEntries->SetToolTipText("Print the number of entries");
88  f3->AddFrame(fEntries, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
89  fMean = new TGCheckButton(f3, "Mean", kSTAT_MEAN);
90  fMean->SetToolTipText("Print the mean value");
91  f3->AddFrame(fMean, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
92  fRMS = new TGCheckButton(f3, "RMS", kSTAT_RMS);
93  fRMS->SetToolTipText("Print root-mean-square (RMS)");
94  f3->AddFrame(fRMS, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
95  fIntegral = new TGCheckButton(f3, "Integral", kSTAT_INTEGRAL);
96  fIntegral->SetToolTipText("Print the integral of bins");
97  f3->AddFrame(fIntegral, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
98  fStatsErrors = new TGCheckButton(f3, "Errors", kSTAT_ERR);
99  fStatsErrors->SetToolTipText("Print the errors");
100  f3->AddFrame(fStatsErrors, new TGLayoutHints(kLHintsTop, 1, 1, 0, 5));
101  f1->AddFrame(f3, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
102 
103  AddFrame(f1, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
104 
105  MakeTitle("Fit Options");
106 
107  TGCompositeFrame *f4 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
108  TGCompositeFrame *f5 = new TGCompositeFrame(f4, 40, 20, kVerticalFrame);
109  f4->AddFrame(f5, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
110 
111  fNameValues = new TGCheckButton(f5, "Values", kFIT_NAME);
112  fNameValues->SetToolTipText("Print the parameter name and value");
113  f5->AddFrame(fNameValues, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
114  fProbability = new TGCheckButton(f5, "Probability", kFIT_PROB);
115  fProbability->SetToolTipText("Print probability");
116  f5->AddFrame(fProbability, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
117 
118  TGCompositeFrame *f6 = new TGCompositeFrame(f4, 40, 20, kVerticalFrame);
119  fErrors = new TGCheckButton(f6, "Errors", kFIT_ERR);
120  fErrors->SetToolTipText("Print the errors");
121  f6->AddFrame(fErrors, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
122  fChisquare = new TGCheckButton(f6, "Chi", kFIT_CHI);
123  fChisquare->SetToolTipText("Print Chisquare");
124  f6->AddFrame(fChisquare, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
125  f4->AddFrame(f6, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
126 
127  AddFrame(f4, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
128 }
129 
130 ////////////////////////////////////////////////////////////////////////////////
131 /// Destructor of fill editor.
132 
134 {
135 }
136 
137 ////////////////////////////////////////////////////////////////////////////////
138 /// Connect signals to slots.
139 
141 {
142  // about stat options
143  fHistoName->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
144  fEntries->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
145  fOverflow->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
146  fMean->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
147  fUnderflow->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
148  fRMS->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
149  fIntegral->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
150  fSkewness->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
151  fKurtosis->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
152  fStatsErrors->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
153 
154  // about fit options
155  fNameValues->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoFitOptions()");
156  fErrors->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoFitOptions()");
157  fErrors->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"SetValuesON(Bool_t");
158  fProbability->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoFitOptions()");
159  fChisquare->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoFitOptions()");
160 
161  fInit = kFALSE;
162 }
163 
164 ////////////////////////////////////////////////////////////////////////////////
165 /// Set GUI widgets according to the used TPaveStats attributes.
166 
168 {
169  fPaveStats = (TPaveStats *)obj;
171 
172  Int_t stat = fPaveStats->GetOptStat();
173 
174  if (stat % 10) fHistoName->SetState(kButtonDown);
176 
177  if (stat/10 % 10) fEntries->SetState(kButtonDown);
178  else fEntries->SetState(kButtonUp);
179 
180  if (stat/100 % 10) fMean->SetState(kButtonDown);
181  else fMean->SetState(kButtonUp);
182 
183  if (stat/1000 % 10) fRMS->SetState(kButtonDown);
184  else fRMS->SetState(kButtonUp);
185 
186  if (stat/10000 % 10) fUnderflow->SetState(kButtonDown);
188 
189  if (stat/100000 % 10) fOverflow->SetState(kButtonDown);
191 
192  if (stat/1000000 % 10) fIntegral->SetState(kButtonDown);
194 
195  if (stat/10000000 % 10) fSkewness->SetState(kButtonDown);
197 
198  if (stat/100000000 % 10) fKurtosis->SetState(kButtonDown);
200 
201  Int_t fit = fPaveStats->GetOptFit();
202  if (fit % 10) fNameValues->SetState(kButtonDown);
204 
205  if (fit/10 % 10) {
208  } else {
210  }
211 
212  if (fit/100 % 10) fChisquare->SetState(kButtonDown);
214 
215  if (fit/1000 % 10) fProbability->SetState(kButtonDown);
217 
219 
221 }
222 
223 ////////////////////////////////////////////////////////////////////////////////
224 /// Slot connected to the stat options.
225 
227 {
228  if (fAvoidSignal) return;
229  Int_t stat = 0;
230  if (fHistoName->GetState() == kButtonDown) stat +=1;
231  if (fEntries->GetState() == kButtonDown) stat +=10;
232  if (fMean->GetState() == kButtonDown) stat +=100;
233  if (fRMS->GetState() == kButtonDown) stat +=1000;
234  if (fUnderflow->GetState() == kButtonDown) stat +=10000;
235  if (fOverflow->GetState() == kButtonDown) stat +=100000;
236  if (fIntegral->GetState() == kButtonDown) stat +=1000000;
237  if (fSkewness->GetState() == kButtonDown) stat +=10000000;
238  if (fKurtosis->GetState() == kButtonDown) stat +=100000000;
239  if (fStatsErrors->GetState() == kButtonDown) {
240  if (fMean->GetState() == kButtonDown) stat +=100;
241  if (fRMS->GetState() == kButtonDown) stat +=1000;
242  if (fSkewness->GetState() == kButtonDown) stat +=10000000;
243  if (fKurtosis->GetState() == kButtonDown) stat +=100000000;
244  }
245 
246  if (!stat) {
247  stat = 1;
249  }
250  if (stat == 1) stat = 1000000001;
251  fPaveStats->SetOptStat(stat);
252  Update();
253 }
254 
255 ////////////////////////////////////////////////////////////////////////////////
256 /// Slot connected to the fit options.
257 
259 {
260  if (fAvoidSignal) return;
261  Int_t fit = 0;
262  if (fNameValues->GetState() == kButtonDown) fit +=1;
263  if (fErrors->GetState() == kButtonDown) fit +=10;
264  if (fChisquare->GetState() == kButtonDown) fit +=100;
265  if (fProbability->GetState() == kButtonDown) fit +=1000;
266 
267  if (fit == 1) fit = 10001;
268  fPaveStats->SetOptFit(fit);
269  Update();
270 }
271 
272 ////////////////////////////////////////////////////////////////////////////////
273 /// Slot connected to the selection of the button 'Errors':
274 /// check button Values should be selected if Errors is selected.
275 
277 {
278  if (fAvoidSignal) return;
279  if (on == kTRUE) fNameValues->SetState(kButtonDown);
280 }
TGCheckButton * fMean
void SetOptFit(Int_t fit=1)
Set the fit option.
Definition: TPaveStats.cxx:294
TGCheckButton * fStatsErrors
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGCheckButton * fIntegral
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGCheckButton * fChisquare
The histogram statistics painter class.
Definition: TPaveStats.h:18
TPaveStatsEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of TPaveStats GUI.
TGCheckButton * fProbability
TGCheckButton * fSkewness
Int_t GetOptFit() const
Return the fit option.
Definition: TPaveStats.cxx:257
TGCheckButton * fErrors
Bool_t fAvoidSignal
Definition: TGedFrame.h:56
ULong_t Pixel_t
Definition: GuiTypes.h:39
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
TGCompositeFrame(const TGCompositeFrame &)
TPaveStats * fPaveStats
virtual EButtonState GetState() const
Definition: TGButton.h:112
virtual void SetModel(TObject *obj)
Set GUI widgets according to the used TPaveStats attributes.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
Definition: TQObject.cxx:867
TGCheckButton * fEntries
virtual void DoStatOptions()
Slot connected to the stat options.
virtual ~TPaveStatsEditor()
Destructor of fill editor.
TGCheckButton * fHistoName
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void SetValuesON(Bool_t on)
Slot connected to the selection of the button &#39;Errors&#39;: check button Values should be selected if Err...
const Bool_t kFALSE
Definition: RtypesCore.h:88
#define ClassImp(name)
Definition: Rtypes.h:359
TGCheckButton * fUnderflow
Int_t GetOptStat() const
Return the stat option.
Definition: TPaveStats.cxx:266
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
Mother of all ROOT objects.
Definition: TObject.h:37
TGCheckButton * fNameValues
Bool_t fInit
Definition: TGedFrame.h:53
EPaveStatsWid
TGCheckButton * fKurtosis
TF1 * f1
Definition: legend1.C:11
TGCheckButton * fRMS
virtual void DoFitOptions()
Slot connected to the fit options.
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1200
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
TGCheckButton * fOverflow
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
void SetOptStat(Int_t stat=1)
Set the stat option.
Definition: TPaveStats.cxx:303