Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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/** \class TPaveStatsEditor
14 \ingroup ged
15
16Implements 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
25
26#include "TPaveStatsEditor.h"
27#include "TGButton.h"
28#include "TPaveStats.h"
29
30
47
48
49////////////////////////////////////////////////////////////////////////////////
50/// Constructor of TPaveStats GUI.
51
53 UInt_t options, Pixel_t back) :
54 TGedFrame(p, width, height, options | kVerticalFrame, back)
55{
56 fPaveStats = 0;
57
58 MakeTitle("Stat Options");
59
62 f1->AddFrame(f2, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
63
64 fHistoName = new TGCheckButton(f2, "Name", kSTAT_NAME);
65 fHistoName->SetToolTipText("Print the histogram name");
66 f2->AddFrame(fHistoName, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
67 fOverflow = new TGCheckButton(f2, "Overflow", kSTAT_OVER);
68 fOverflow->SetToolTipText("Print the number of overflows");
69 f2->AddFrame(fOverflow, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
70 fUnderflow = new TGCheckButton(f2, "Underflow", kSTAT_UNDER);
71 fUnderflow->SetToolTipText("Print the number of underflows");
72 f2->AddFrame(fUnderflow, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
73 fSkewness = new TGCheckButton(f2, "Skewness", kSTAT_SKEWNESS);
74 fSkewness->SetToolTipText("Print the skewness");
75 f2->AddFrame(fSkewness, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
76 fKurtosis = new TGCheckButton(f2, "Kurtosis", kSTAT_KURTOSIS);
77 fKurtosis->SetToolTipText("Print the kurtosis");
78 f2->AddFrame(fKurtosis, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
79
81 fEntries = new TGCheckButton(f3, "Entries", kSTAT_ENTRIES);
82 fEntries->SetToolTipText("Print the number of entries");
83 f3->AddFrame(fEntries, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
84 fMean = new TGCheckButton(f3, "Mean", kSTAT_MEAN);
85 fMean->SetToolTipText("Print the mean value");
86 f3->AddFrame(fMean, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
87 fRMS = new TGCheckButton(f3, "RMS", kSTAT_RMS);
88 fRMS->SetToolTipText("Print root-mean-square (RMS)");
89 f3->AddFrame(fRMS, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
90 fIntegral = new TGCheckButton(f3, "Integral", kSTAT_INTEGRAL);
91 fIntegral->SetToolTipText("Print the integral of bins");
92 f3->AddFrame(fIntegral, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
93 fStatsErrors = new TGCheckButton(f3, "Errors", kSTAT_ERR);
94 fStatsErrors->SetToolTipText("Print the errors");
95 f3->AddFrame(fStatsErrors, new TGLayoutHints(kLHintsTop, 1, 1, 0, 5));
96 f1->AddFrame(f3, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
97
98 AddFrame(f1, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
99
100 MakeTitle("Fit Options");
101
102 TGCompositeFrame *f4 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
103 TGCompositeFrame *f5 = new TGCompositeFrame(f4, 40, 20, kVerticalFrame);
104 f4->AddFrame(f5, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
105
106 fNameValues = new TGCheckButton(f5, "Values", kFIT_NAME);
107 fNameValues->SetToolTipText("Print the parameter name and value");
108 f5->AddFrame(fNameValues, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
109 fProbability = new TGCheckButton(f5, "Probability", kFIT_PROB);
110 fProbability->SetToolTipText("Print probability");
111 f5->AddFrame(fProbability, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
112
113 TGCompositeFrame *f6 = new TGCompositeFrame(f4, 40, 20, kVerticalFrame);
114 fErrors = new TGCheckButton(f6, "Errors", kFIT_ERR);
115 fErrors->SetToolTipText("Print the errors");
116 f6->AddFrame(fErrors, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
117 fChisquare = new TGCheckButton(f6, "Chi", kFIT_CHI);
118 fChisquare->SetToolTipText("Print Chisquare");
119 f6->AddFrame(fChisquare, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
120 f4->AddFrame(f6, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
121
122 AddFrame(f4, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
123}
124
125////////////////////////////////////////////////////////////////////////////////
126/// Destructor of fill editor.
127
131
132////////////////////////////////////////////////////////////////////////////////
133/// Connect signals to slots.
134
136{
137 // about stat options
138 fHistoName->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
139 fEntries->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
140 fOverflow->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
141 fMean->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
142 fUnderflow->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
143 fRMS->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
144 fIntegral->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
145 fSkewness->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
146 fKurtosis->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
147 fStatsErrors->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
148
149 // about fit options
150 fNameValues->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoFitOptions()");
151 fErrors->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoFitOptions()");
152 fErrors->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"SetValuesON(Bool_t");
153 fProbability->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoFitOptions()");
154 fChisquare->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoFitOptions()");
155
156 fInit = kFALSE;
157}
158
159////////////////////////////////////////////////////////////////////////////////
160/// Set GUI widgets according to the used TPaveStats attributes.
161
163{
164 fPaveStats = (TPaveStats *)obj;
166
167 Int_t stat = fPaveStats->GetOptStat();
168
169 if (stat % 10) fHistoName->SetState(kButtonDown);
171
172 if (stat/10 % 10) fEntries->SetState(kButtonDown);
174
175 if (stat/100 % 10) fMean->SetState(kButtonDown);
176 else fMean->SetState(kButtonUp);
177
178 if (stat/1000 % 10) fRMS->SetState(kButtonDown);
179 else fRMS->SetState(kButtonUp);
180
181 if (stat/10000 % 10) fUnderflow->SetState(kButtonDown);
183
184 if (stat/100000 % 10) fOverflow->SetState(kButtonDown);
186
187 if (stat/1000000 % 10) fIntegral->SetState(kButtonDown);
189
190 if (stat/10000000 % 10) fSkewness->SetState(kButtonDown);
192
193 if (stat/100000000 % 10) fKurtosis->SetState(kButtonDown);
195
196 Int_t fit = fPaveStats->GetOptFit();
197 if (fit % 10) fNameValues->SetState(kButtonDown);
199
200 if (fit/10 % 10) {
203 } else {
205 }
206
207 if (fit/100 % 10) fChisquare->SetState(kButtonDown);
209
210 if (fit/1000 % 10) fProbability->SetState(kButtonDown);
212
214
216}
217
218////////////////////////////////////////////////////////////////////////////////
219/// Slot connected to the stat options.
220
222{
223 if (fAvoidSignal) return;
224 Int_t stat = 0;
225 if (fHistoName->GetState() == kButtonDown) stat +=1;
226 if (fEntries->GetState() == kButtonDown) stat +=10;
227 if (fMean->GetState() == kButtonDown) stat +=100;
228 if (fRMS->GetState() == kButtonDown) stat +=1000;
229 if (fUnderflow->GetState() == kButtonDown) stat +=10000;
230 if (fOverflow->GetState() == kButtonDown) stat +=100000;
231 if (fIntegral->GetState() == kButtonDown) stat +=1000000;
232 if (fSkewness->GetState() == kButtonDown) stat +=10000000;
233 if (fKurtosis->GetState() == kButtonDown) stat +=100000000;
235 if (fMean->GetState() == kButtonDown) stat +=100;
236 if (fRMS->GetState() == kButtonDown) stat +=1000;
237 if (fSkewness->GetState() == kButtonDown) stat +=10000000;
238 if (fKurtosis->GetState() == kButtonDown) stat +=100000000;
239 }
240
241 if (!stat) {
242 stat = 1;
244 }
245 if (stat == 1) stat = 1000000001;
246 fPaveStats->SetOptStat(stat);
247 Update();
248}
249
250////////////////////////////////////////////////////////////////////////////////
251/// Slot connected to the fit options.
252
254{
255 if (fAvoidSignal) return;
256 Int_t fit = 0;
257 if (fNameValues->GetState() == kButtonDown) fit +=1;
258 if (fErrors->GetState() == kButtonDown) fit +=10;
259 if (fChisquare->GetState() == kButtonDown) fit +=100;
260 if (fProbability->GetState() == kButtonDown) fit +=1000;
261
262 if (fit == 1) fit = 10001;
263 fPaveStats->SetOptFit(fit);
264 Update();
265}
266
267////////////////////////////////////////////////////////////////////////////////
268/// Slot connected to the selection of the button 'Errors':
269/// check button Values should be selected if Errors is selected.
270
@ kVerticalFrame
Definition GuiTypes.h:381
@ kHorizontalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
@ kLHintsTop
Definition TGLayout.h:27
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
EPaveStatsWid
@ kSTAT_OVER
@ kSTAT_ENTRIES
@ kFIT_NAME
@ kFIT_ERR
@ kSTAT_MEAN
@ kSTAT_INTEGRAL
@ kSTAT_KURTOSIS
@ kSTAT_ERR
@ kFIT_CHI
@ kSTAT_NAME
@ kSTAT_RMS
@ kSTAT_UNDER
@ kSTAT_SKEWNESS
@ kFIT_PROB
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:439
virtual EButtonState GetState() const
Definition TGButton.h:112
Selects different options.
Definition TGButton.h:264
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set check button state.
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
TGCompositeFrame(const TGCompositeFrame &)=delete
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
ROOT GUI Window base class.
Definition TGWindow.h:23
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:94
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:71
Bool_t fAvoidSignal
flag for executing slots
Definition TGedFrame.h:50
Mother of all ROOT objects.
Definition TObject.h:41
TGCheckButton * fUnderflow
underflow number check box
~TPaveStatsEditor() override
Destructor of fill editor.
virtual void DoStatOptions()
Slot connected to the stat options.
TGCheckButton * fRMS
RMS check box.
TGCheckButton * fNameValues
parameters' name/values check box
virtual void DoFitOptions()
Slot connected to the fit options.
virtual void SetValuesON(Bool_t on)
Slot connected to the selection of the button 'Errors': check button Values should be selected if Err...
TGCheckButton * fErrors
error check box
TPaveStats * fPaveStats
TPaveStats object.
TGCheckButton * fStatsErrors
statistics error check box
TGCheckButton * fIntegral
integral of bins check box
void SetModel(TObject *obj) override
Set GUI widgets according to the used TPaveStats attributes.
TGCheckButton * fChisquare
Chisquare check box.
TGCheckButton * fOverflow
overflow number check box
TGCheckButton * fMean
mean value check box
TPaveStatsEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of TPaveStats GUI.
TGCheckButton * fEntries
entries' number check box
TGCheckButton * fProbability
probability check box
TGCheckButton * fSkewness
skewness check box
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGCheckButton * fKurtosis
kurtosis check box
TGCheckButton * fHistoName
histo name check box
The histogram statistics painter class.
Definition TPaveStats.h:18
Int_t GetOptStat() const
Return the stat option.
void SetOptStat(Int_t stat=1)
Set the stat option.
Int_t GetOptFit() const
Return the fit option.
void SetOptFit(Int_t fit=1)
Set the fit option.
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:865
TF1 * f1
Definition legend1.C:11