Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TH1Editor.cxx
Go to the documentation of this file.
1// @(#)root/ged:$Id$
2// Author: Carsten Hof 16/08/04
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, 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 TH1Editor
14 \ingroup ged
15
16Editor for changing TH1 histogram attributes, rebinning & fitting.
17For all possible draw options (there are a few which are not implementable
18in graphical user interface) see THistPainter::Paint
19
20 These changes can be made via the TH1Editor:
21 Style Tab:
22 'Line' : change Line attributes (color, thickness)
23 see TAttLineEditor
24 'Fill' : change Fill attributes (color, pattern)
25 see TAttFillEditor
26 'Title' : TextEntry: set the title of the histogram
27 'Histogram': change the draw options of the histogram
28 'Plot' : Radiobutton: draw a 2D or 3D plot of the histogram
29 according to the Plot dimension there will be
30 different drawing possibilities (ComboBoxes/
31 CheckBoxes)
32 2d Plot:
33 'Error' : ComboBox: add different error bars to the histogram
34 (no errors, simple, ..., see THistPainter::Paint
35 'Add' : ComboBox: further things which can be added to the
36 histogram (None, simple/smooth line, fill area
37 'Simple Drawing': CheckBox: draw a simple histogram without
38 errors (= "HIST" drawoption). In combination with
39 some other draw options an outer line is drawn on
40 top of the histogram
41 'Show markers': CheckBox: draw a marker on to of each bin (="P"
42 drawoption)
43 'Draw bar chart': CheckBox: draw a bar chart (="B" drawoption)
44 change the Fill Color with Fill in the Style Tab
45 => will show Bar menue in the Style Tab
46 'Bar option': CheckBox: draw a bar chart (="BAR" drawoption)
47 => will show Bar menue in the Style Tab
48 3d Plot:
49 'Type' : ComboBox: set histogram type Lego-Plot or Surface
50 draw(Lego, Lego1.2, Surf, Surf1..5)
51 see THistPainter::Paint
52 'Coords' : ComboBox: set the coordinate system (Cartesian, ..
53 Spheric) see THistPainter::Paint
54 'Error' : see 2D plot
55 'Bar' : change the bar attributes
56 'W' : change Bar Width
57 'O' : change Bar Offset
58 'Percentage': specifies the percentage of the bar which is drawn
59 brighter and darker (10% == BAR1 drawoption)
60 'Horizontal Bar': draw a horizontal bar chart
61
62 'Marker' : change the Marker attributes (color, appearance,
63 thickness) see TAttMarkerEditor
64
65 This Tab has two different layouts. One is for a histogram which
66 is not drawn from an ntuple. The other one is available for a
67 histogram which is drawn from an ntuple. In this case the rebin
68 algorithm can create a rebinned histogram from the original data
69 i.e. the ntuple.
70 To see te differences do:
71 TFile f("hsimple.root");
72 hpx->Draw("BAR1"); // non ntuple histogram
73 ntuple->Draw("px"); // ntuple histogram
74 Non ntuple histogram:
75 'Rebin': with the Slider the number of bins (shown in the field
76 below the Slider) can be changed to any number which
77 divides the number of bins of the original histogram.
78 Pushing 'Apply' will delete the origin histogram and
79 replace it by the rebinned one on the screen
80 Pushing 'Ignore' the origin histogram will be restored
81 Histogram drawn from an ntuple:
82 'Rebin' with the slider the number of bins can be enlarged by
83 a factor of 2,3,4,5 (moving to the right) or reduced
84 by a factor of 1/2, 1/3, 1/4, 1/5
85 'BinOffset': with the BinOffset slider the origin of the
86 histogram can be changed within one binwidth
87 Using this slider the effect of binning the data into
88 bins can be made visible => statistical fluctuations
89 'Axis Range': with the DoubleSlider it is possible to zoom into
90 the specified axis range. It is also possible to set
91 the upper and lower limit in fields below the slider
92 'Delayed drawing': all the Binning sliders can set to delay
93 draw mode. Then the changes on the histogram are only
94 updated, when the Slider is released. This should be
95 activated if the redrawing of the histogram is too
96 time consuming. //
97
98*/
99
100
101
102#include "TH1Editor.h"
103#include "TH1.h"
104#include "TGedEditor.h"
105#include "TGComboBox.h"
106#include "TGTextEntry.h"
107#include "TGLabel.h"
108#include "TVirtualPad.h"
109#include "TString.h"
110#include "TGButtonGroup.h"
111#include "TGNumberEntry.h"
112#include "TG3DLine.h"
113#include "TGDoubleSlider.h"
114#include "TGSlider.h"
115#include "TView.h"
116#include "TTreePlayer.h"
117#include "TSelectorDraw.h"
118#include "TGMsgBox.h"
119#include "TGTab.h"
120#include "TROOT.h"
121#include "TVirtualX.h"
122
123#include <cstdlib>
124
125
143
144
145////////////////////////////////////////////////////////////////////////////////
146/// Constructor of histogram attribute GUI.
147
149 Int_t height, UInt_t options, Pixel_t back)
150 : TGedFrame(p, width, height, options | kVerticalFrame, back),
151 fHist(0),
152 fSameOpt(kFALSE),
153 fBin(0),
154 fBinHist(0)
155{
156 // TextEntry for changing the title of the histogram
157 MakeTitle("Title");
158 fTitlePrec = 2;
159 fTitle = new TGTextEntry(this, new TGTextBuffer(50), kTH1_TITLE);
161 fTitle->SetToolTipText("Enter the histogram title string");
162 AddFrame(fTitle, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
163
164 // Histogram draw options
165 TGCompositeFrame *fHistLbl = new TGCompositeFrame(this, 145, 10,
167 kFitWidth |
170 fHistLbl->AddFrame(new TGLabel(fHistLbl,"Histogram"),
171 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
172 fHistLbl->AddFrame(new TGHorizontal3DLine(fHistLbl),
173 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 0));
174 AddFrame(fHistLbl, new TGLayoutHints(kLHintsTop,0,0,2,0));
175
176 // TGButtonGroup to change: 2D plot <-> 3D plot
177 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
178 fDimGroup = new TGHButtonGroup(f2,"Plot");
181 fDim->SetToolTipText("A 2-d plot of the histogram is dawn");
183 fDim0->SetToolTipText("A 3-d plot of the histogram is dawn");
186 fDimGroup->Show();
188 f2->AddFrame(fDimGroup, new TGLayoutHints(kLHintsTop, 4, 1, 0, 0));
189 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 2, 8));
190
191 // Set the type of histogram (Lego0..2, Surf0..5) for 3D plot
192 f3 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
193 AddFrame(f3, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
194
195 TGCompositeFrame *f3a = new TGCompositeFrame(f3, 40, 20);
196 f3->AddFrame(f3a, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
197 TGLabel *fType = new TGLabel(f3a, "Add: ");
198 f3a->AddFrame(fType, new TGLayoutHints(kLHintsLeft, 6, 1, 4, 4));
199 TGLabel *fCoords = new TGLabel(f3a, "Coords:");
200 f3a->AddFrame(fCoords, new TGLayoutHints(kLHintsLeft, 6, 1, 4, 1));
201
202 TGCompositeFrame *f3b = new TGCompositeFrame(f3, 40, 20);
203 f3->AddFrame(f3b, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
205 f3b->AddFrame(fTypeCombo, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 1));
206 fTypeCombo->Resize(80, 20);
207 fTypeCombo->Associate(this);
208 //Set the coordinate system (Cartesian, Spheric, ...)
210 f3b->AddFrame(fCoordsCombo, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 1));
211 fCoordsCombo->Resize(80, 20);
212 fCoordsCombo->Associate(this);
213
214 // Set the Error (No error, error1..5)
215 TGCompositeFrame *f5 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
216 AddFrame(f5, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
217
218 TGCompositeFrame *f5a = new TGCompositeFrame(f5, 40, 20);
219 f5->AddFrame(f5a, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
220 TGLabel *fError = new TGLabel(f5a, "Error:");
221 f5a->AddFrame(fError, new TGLayoutHints(kLHintsLeft, 6, 2, 4, 1));
222
223 TGCompositeFrame *f5b = new TGCompositeFrame(f5, 40, 20);
224 f5->AddFrame(f5b, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
226 f5b->AddFrame(fErrorCombo, new TGLayoutHints(kLHintsLeft, 15, 1, 2, 1));
227 fErrorCombo->Resize(80, 20);
228 fErrorCombo->Associate(this);
229
230 // Further draw options: Smooth/Simple Line, Fill Area for 2D plot
231 f6 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
232 AddFrame(f6, new TGLayoutHints(kLHintsTop, 1, 1, 0, 3));
233
234 TGCompositeFrame *f6a = new TGCompositeFrame(f6, 40, 20);
235 f6->AddFrame(f6a, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
236 TGLabel *fAddLabel = new TGLabel(f6a, "Style:");
237 f6a->AddFrame(fAddLabel, new TGLayoutHints(kLHintsLeft, 6, 2, 4, 1));
238
239 TGCompositeFrame *f6b = new TGCompositeFrame(f6, 40, 20);
240 f6->AddFrame(f6b, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
242 f6b->AddFrame(fAddCombo, new TGLayoutHints(kLHintsLeft, 15, 1, 2, 1));
243 fAddCombo->Resize(80, 20);
244 fAddCombo->Associate(this);
245
246 // option related to HIST: some changes needed here!
247 // because of inconsistencies
248 f15 = new TGCompositeFrame(this, 80, 20, kVerticalFrame);
249 fAddSimple = new TGCheckButton(f15, "Simple Drawing", kADD_LINE);
250 fAddSimple ->SetToolTipText("A simple histogram without errors is drawn (draw option: Hist)");
251 f15->AddFrame(fAddSimple, new TGLayoutHints(kLHintsLeft, 6, 1, 1, 0));
252 AddFrame(f15, new TGLayoutHints(kLHintsTop, 1, 1, 0, -1));
253
254 // Show Marker Checkbox: draw marker (or not)
255 f7 = new TGCompositeFrame(this, 80, 20, kVerticalFrame);
256 fAddMarker = new TGCheckButton(f7, "Show markers", kMARKER_ONOFF);
257 fAddMarker ->SetToolTipText("Make marker visible/invisible");
258 f7->AddFrame(fAddMarker, new TGLayoutHints(kLHintsLeft, 6, 1, 1, 0));
259 AddFrame(f7, new TGLayoutHints(kLHintsTop, 1, 1, 2, 0));
260
261 // Bar Chart Checkbox: draw with option B
262 f8 = new TGCompositeFrame(this, 80, 20, kVerticalFrame);
263 fAddB = new TGCheckButton(f8, "Draw bar chart", kB_ONOFF);
264 fAddB ->SetToolTipText("Draw a bar chart");
265 f8->AddFrame(fAddB, new TGLayoutHints(kLHintsLeft, 6, 1, 1, 0));
266 AddFrame(f8, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
267
268 // Bar CheckBox: draw with option BAR +option selected by
269 // fPercentCombo (0..4) e.g. BAR2
270 f9 = new TGCompositeFrame(this, 80, 20, kVerticalFrame);
271 fAddBar = new TGCheckButton(f9, "Bar option", kBAR_ONOFF);
272 fAddBar ->SetToolTipText("Draw bar chart with bar-option");
273 f9->AddFrame(fAddBar, new TGLayoutHints(kLHintsLeft, 6, 1, 1, 0));
274 AddFrame(f9, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
275
276 // Bar Menu => appears when the BAR checkbox is set
277 f10 = new TGCompositeFrame(this, 145, 10, kHorizontalFrame |
278 kFitWidth |
281 f10->AddFrame(new TGLabel(f10,"Bar"),
282 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
284 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
285 AddFrame(f10, new TGLayoutHints(kLHintsTop,0,0,6,4));
286
287 // NumberEntry to change the Bar Width
288 f11 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
289 TGLabel *fWidthLbl = new TGLabel(f11, "W:");
290 f11->AddFrame(fWidthLbl, new TGLayoutHints(kLHintsLeft, 1, 3, 4, 1));
291 fBarWidth = new TGNumberEntry(f11, 1.00, 6, kBAR_WIDTH,
295 fBarWidth->GetNumberEntry()->SetToolTipText("Set bin bar width");
296 fBarWidth->Resize(45,20);
297 f11->AddFrame(fBarWidth, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 1));
298
299 // NumberEntry to change the Bar OFfset
300 TGLabel *foffsetLbl = new TGLabel(f11, "O:");
301 f11->AddFrame(foffsetLbl, new TGLayoutHints(kLHintsLeft, 6,3, 4, 1));
302 fBarOffset = new TGNumberEntry(f11, 0.00, 5, kBAR_OFFSET,
306 fBarOffset->GetNumberEntry()->SetToolTipText("Set bin bar offset");
307 fBarOffset->Resize(50,20);
308 f11->AddFrame(fBarOffset, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 1));
309 AddFrame(f11, new TGLayoutHints(kLHintsTop, 1, 1, 0, 4));
310
311 // ComboBox which specifies the width of the Bar which should be drawn
312 // in another color i.e. specifies the number in BAR option e.g. BAR2
313 f12 = new TGCompositeFrame(this, 80, 20, kVerticalFrame);
315 TGLabel *percentLabel = new TGLabel(f13, "Percentage:");
316 f13->AddFrame(percentLabel, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 1));
318 fPercentCombo->Resize(51, 20);
320 f13->AddFrame(fPercentCombo, new TGLayoutHints(kLHintsLeft, 14, 1, 2, 1));
321 f12->AddFrame(f13,new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
322
323 // CHeckBox for horizontal drawing of the Histogram
324 fMakeHBar = new TGCheckButton(f12, "Horizontal Bar", kBAR_H);
325 fMakeHBar ->SetToolTipText("Draw a horizontal bar chart with hBar-Option");
326 f12->AddFrame(fMakeHBar, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 0));
327 AddFrame(f12, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
328
329 CreateBinTab();
330
331 // add itself in the least of cleanups to be notified when attached histogram is deleted
332 gROOT->GetListOfCleanups()->Add(this);
333}
334
335////////////////////////////////////////////////////////////////////////////////
336/// Create binning tab.
337
339{
340 fBin = CreateEditorTabSubFrame("Binning");
341
342 TGCompositeFrame *title1 = new TGCompositeFrame(fBin, 145, 10,
344 kFitWidth |
347 title1->AddFrame(new TGLabel(title1, "Rebin"),
348 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
349 title1->AddFrame(new TGHorizontal3DLine(title1),
350 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
351 fBin->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
352
353 // Widgets for rebinning a histogram which does NOT derive from a ntuple
355 TGCompositeFrame *f18 = new TGCompositeFrame(fBinCont, 80, 20,
357 fBinSlider = new TGHSlider(f18, 100, kSlider1 | kScaleBoth);
358 fBinSlider->Resize(107,20);
359 f18->AddFrame(fBinSlider, new TGLayoutHints(kLHintsLeft, 3,0,0,3));
360 fBinCont->AddFrame(f18, new TGLayoutHints(kLHintsTop, 15, 7, 3, 5));
361
362 TGCompositeFrame *f20 = new TGCompositeFrame(fBinCont, 80, 20,
364 TGLabel *binLabel1 = new TGLabel(f20, "# of Bins:");
365 f20->AddFrame(binLabel1, new TGLayoutHints(kLHintsLeft, 7, 1, 2, 1));
368 ((TGTextEntry*)fBinNumberEntry)->SetToolTipText("Set the number of bins in the rebinned histogram");
369 fBinNumberEntry->Resize(57,20);
370 f20->AddFrame(fBinNumberEntry, new TGLayoutHints(kLHintsRight, 21, 0, 0, 0));
371 fBinCont->AddFrame(f20, new TGLayoutHints(kLHintsTop, 0, 7, 3, 4));
372
373 // Text buttons to Apply or Delete the rebinned histogram
374 TGCompositeFrame *f23 = new TGCompositeFrame(fBinCont, 118, 20,
377 fApply = new TGTextButton(f23, " &Apply ");
378 f23->AddFrame(fApply,
379 new TGLayoutHints(kLHintsExpandX | kLHintsLeft , 0, 3, 4, 4));
380 fCancel = new TGTextButton(f23, " &Ignore ");
381 f23->AddFrame(fCancel,
382 new TGLayoutHints(kLHintsExpandX | kLHintsLeft, 3, 0, 4, 4));
383 fBinCont->AddFrame(f23, new TGLayoutHints(kLHintsTop, 20, 3, 3, 4));
385
386 // Widgets for rebinning a histogram which derives from a ntuple
390 fBinSlider1 = new TGHSlider(f21, 100, kSlider1 | kScaleBoth);
391 fBinSlider1->Resize(107,20);
392 fBinSlider1->SetRange(1,9);
395 f21->AddFrame(fBinSlider1, new TGLayoutHints(kLHintsLeft, 3,0,0,3));
396 fBinCont1->AddFrame(f21, new TGLayoutHints(kLHintsTop, 15, 7, 5, 0));
397
398 // Lettering of the Rebin Slider
401 TGLabel *l1 = new TGLabel(f24, "-5");
402 f24->AddFrame(l1, new TGLayoutHints(kLHintsLeft, 18, 1, -1, 0));
403 TGLabel *l2 = new TGLabel(f24, "-2");
404 f24->AddFrame(l2, new TGLayoutHints(kLHintsLeft, 26, 2, -1, 0));
405 TGLabel *l3 = new TGLabel(f24, "2");
406 f24->AddFrame(l3, new TGLayoutHints(kLHintsLeft, 17, 2, -1, 0));
407 TGLabel *l4 = new TGLabel(f24, "5");
408 f24->AddFrame(l4, new TGLayoutHints(kLHintsLeft, 32, 3, -1, 0));
409 fBinCont1->AddFrame(f24, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
410
411 TGCompositeFrame *f22 = new TGCompositeFrame(fBinCont1, 140, 20,
413 TGLabel *binLabel2 = new TGLabel(f22, "# of Bins:");
414 f22->AddFrame(binLabel2, new TGLayoutHints(kLHintsLeft, 7, 1, 4, 1));
415
418 ((TGTextEntry*)fBinNumberEntry1)->SetToolTipText("Set the number of bins in the rebinned histogram");
419 fBinNumberEntry1->Resize(57,20);
420 f22->AddFrame(fBinNumberEntry1, new TGLayoutHints(kLHintsLeft, 21, 0, 2, 0));
421 fBinCont1->AddFrame(f22, new TGLayoutHints(kLHintsTop, 0, 7, 2, 4));
422
425 TGLabel *offsetLbl = new TGLabel(f26, "BinOffset:");
426 f26->AddFrame(offsetLbl, new TGLayoutHints(kLHintsLeft, 6, 1, 2, 1));
431 0., 1.);
432 ((TGTextEntry*)fOffsetNumberEntry)->SetToolTipText("Add an offset to the origin of the histogram");
435 new TGLayoutHints(kLHintsRight, 21, 0, 0, 0));
436 fBinCont1->AddFrame(f26, new TGLayoutHints(kLHintsTop, 0, 7, 3, 1));
437
440 fBinOffsetSld = new TGHSlider(f25, 100, kSlider1 | kScaleBoth);
441 fBinOffsetSld->Resize(107,20);
442 f25->AddFrame(fBinOffsetSld, new TGLayoutHints(kLHintsLeft, 15,0,0,2));
443 fBinCont1->AddFrame(f25, new TGLayoutHints(kLHintsTop, 3, 7, 3, 3));
445
446 // Sliders for axis range
447 TGCompositeFrame *sldCont = new TGCompositeFrame(fBin, 80, 20,
449 TGCompositeFrame *title2 = new TGCompositeFrame(sldCont, 145, 10,
451 kFitWidth |
454 title2->AddFrame(new TGLabel(title2, "Axis Range"),
455 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
456 title2->AddFrame(new TGHorizontal3DLine(title2),
457 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
458 sldCont->AddFrame(title2, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
459
460 TGCompositeFrame *f14 = new TGCompositeFrame(sldCont, 80, 20,
462 TGLabel *fSliderLbl = new TGLabel(f14,"x:");
463 f14->AddFrame(fSliderLbl,
464 new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 4,4, 4, 1));
465 fSlider = new TGDoubleHSlider(f14, 1, 2);
466 fSlider->Resize(118,20);
468 sldCont->AddFrame(f14, new TGLayoutHints(kLHintsTop, 3, 7, 4, 1));
469
470 TGCompositeFrame *f16 = new TGCompositeFrame(sldCont, 80, 20,
472 fSldMin = new TGNumberEntryField(f16, kSLIDER_MIN, 0.0,
475 ((TGTextEntry*)fSldMin)->SetToolTipText("Set the minimum value of the x-axis");
476 fSldMin->Resize(57,20);
477 f16->AddFrame(fSldMin, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
478 fSldMax = new TGNumberEntryField(f16, kSLIDER_MAX, 0.0,
481 ((TGTextEntry*)fSldMax)->SetToolTipText("Set the maximum value of the x-axis");
482 fSldMax->Resize(57,20);
483 f16->AddFrame(fSldMax, new TGLayoutHints(kLHintsLeft, 4, 0, 0, 0));
484 sldCont->AddFrame(f16, new TGLayoutHints(kLHintsTop, 20, 3, 5, 0));
485
486 TGCompositeFrame *f17 = new TGCompositeFrame(sldCont, 80, 20, kVerticalFrame);
487 fDelaydraw = new TGCheckButton(f17, "Delayed drawing", kDELAYED_DRAWING);
488 fDelaydraw ->SetToolTipText("Draw the new histogram only when any Slider is released");
489 f17->AddFrame(fDelaydraw, new TGLayoutHints(kLHintsLeft, 6, 1, 2, 0));
490 sldCont->AddFrame(f17, new TGLayoutHints(kLHintsTop, 1, 1, 5, 0));
491 fBin->AddFrame(sldCont, new TGLayoutHints(kLHintsTop));
492
493 // to avoid jumping from DoAddBar to DoAddB and vice versa
495 // to avoid calling SetDrawoption after every change
496 fMake=kTRUE;
497
498 fBinHist = 0; // used to save a copy of the histogram
499
500 // (when not drawn from an ntuple)
501 fBinOffsetSld->SetRange(0,100);
506
507} // end bin tab
508
509////////////////////////////////////////////////////////////////////////////////
510/// Destructor of TH1 editor.
511
513{
514 // remove itselef from the list of cleanups
515 gROOT->GetListOfCleanups()->Remove(this);
516
517 // children of TGButonGroup are not deleted
518 delete fDim;
519 delete fDim0;
520 delete fDimlh;
521 delete fDim0lh;
522
523 if (fBinHist) delete fBinHist;
524 fBinHist = 0;
525}
526
527////////////////////////////////////////////////////////////////////////////////
528/// Connect signals to slots.
529
531{
532 //widgets for draw options
533 fAddB->Connect("Toggled(Bool_t)", "TH1Editor", this, "DoAddB(Bool_t)");
534 fAddBar->Connect("Toggled(Bool_t)", "TH1Editor", this, "DoAddBar(Bool_t)");
535 fTitle->Connect("TextChanged(const char *)", "TH1Editor", this, "DoTitle(const char *)");
536 fTypeCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoHistChanges()");
537 fCoordsCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoHistChanges()");
538 fErrorCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoHistChanges()");
539 fAddCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoHistChanges()");
540 fAddMarker->Connect("Toggled(Bool_t)", "TH1Editor", this, "DoAddMarker(Bool_t)");
541 fAddSimple->Connect("Toggled(Bool_t)", "TH1Editor", this, "DoAddSimple(Bool_t)");
542
543 //change 2D <-> 3D plot
544 fDimGroup->Connect("Clicked(Int_t)","TH1Editor",this,"DoHistView()");
545
546 // change Bar Width/Offset, the second connection is needed to have the ability to confirm the value also with enter
547 fBarWidth->Connect("ValueSet(Long_t)", "TH1Editor", this, "DoBarWidth()");
548 (fBarWidth->GetNumberEntry())->Connect("ReturnPressed()", "TH1Editor", this, "DoBarWidth()");
549 fBarOffset->Connect("ValueSet(Long_t)", "TH1Editor", this, "DoBarOffset()");
550 (fBarOffset->GetNumberEntry())->Connect("ReturnPressed()", "TH1Editor", this, "DoBarOffset()");
551 fPercentCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoPercent()");
552 fMakeHBar-> Connect("Toggled(Bool_t)","TH1Editor",this,"DoHBar(Bool_t))");
553
554 // Connections for rebinning are created - i.e. slider is
555 // connected to the slots that perform the rebinning in the
556 // case of a histogram not derived from an ntuple.
557 fBinSlider->Connect("PositionChanged(Int_t)","TH1Editor",this, "DoBinMoved(Int_t)");
558 fBinSlider->Connect("Released()","TH1Editor",this, "DoBinReleased()");
559 fBinSlider->Connect("Pressed()","TH1Editor",this, "DoBinPressed()");
560 // numberEntry which shows/sets the actual number of bins
561 fBinNumberEntry->Connect("ReturnPressed()", "TH1Editor", this, "DoBinLabel()");
562 // Buttons to accept/reject the rebinned histogram
563 fApply->Connect("Clicked()", "TH1Editor", this, "DoApply()");
564 fCancel->Connect("Pressed()", "TH1Editor", this, "DoCancel()");
565 // in case of a histogram which is derived from an ntuple these slots are used
566 fBinSlider1->Connect("Released()","TH1Editor",this, "DoBinReleased1()");
567 fBinSlider1->Connect("PositionChanged(Int_t)","TH1Editor",this, "DoBinMoved1()");
568 fBinNumberEntry1->Connect("ReturnPressed()", "TH1Editor", this, "DoBinLabel1()");
569 // slider/slots to change the offset of the histogram
570 fBinOffsetSld->Connect("PositionChanged(Int_t)", "TH1Editor", this,"DoOffsetMoved(Int_t)");
571 fBinOffsetSld->Connect("Released()", "TH1Editor", this, "DoOffsetReleased()");
572 fBinOffsetSld->Connect("Pressed()", "TH1Editor", this, "DoOffsetPressed()");
573 fOffsetNumberEntry->Connect("ReturnPressed()", "TH1Editor", this, "DoBinOffset()");
574 // slider/slots to set the visible axisrange
575 fSlider->Connect("PositionChanged()","TH1Editor", this,"DoSliderMoved()");
576 fSlider->Connect("Pressed()","TH1Editor", this, "DoSliderPressed()");
577 fSlider->Connect("Released()","TH1Editor", this, "DoSliderReleased()");
578 fSldMin->Connect("ReturnPressed()", "TH1Editor", this, "DoAxisRange()");
579 fSldMax->Connect("ReturnPressed()", "TH1Editor", this, "DoAxisRange()");
580 fInit = kFALSE;
581}
582
583////////////////////////////////////////////////////////////////////////////////
584/// Check if object is able to configure with this editor.
585
587{
588 if (obj == 0 || !obj->InheritsFrom(TH1::Class()) ||
589 ((TH1*)obj)->GetDimension()!=1 ||
590 ((TH1*)obj)->GetEntries() == 0
591 /*|| obj->InheritsFrom("TH2") || obj->InheritsFrom("TProfile")*/) {
592 return kFALSE;
593 }
594 return kTRUE;
595}
596
597////////////////////////////////////////////////////////////////////////////////
598/// Pick up current values of histogram attributes.
599
601{
602
603 if (fBinHist && (obj != fHist)) {
604 //we have probably moved to a different pad.
605 //let's restore the original histogram
606 if (fHist) {
607 fHist->Reset();
612 }
613 // delete in anycase fBinHist also when fHist is zero (i.e when it has been deleted)
614 delete fBinHist; fBinHist = 0;
615 }
616
617 fHist = (TH1*)obj;
619
620 const char *text = fHist->GetTitle();
622
624 TString str = GetDrawOption();
625 str.ToUpper();
626 if (str.Contains("SAME"))
627 fSameOpt = kTRUE;
628 else
630 Bool_t errorset = kFALSE;
631 // if no draw option is specified: (default options)
632 if (str.IsNull() || str=="" ) {
635 HideFrame(f3); // Hiding the histogram type combo box
636 ShowFrame(f6);
637 ShowFrame(f7);
638 ShowFrame(f8);
639 ShowFrame(f9);
640 HideFrame(f10);
641 HideFrame(f11);
642 HideFrame(f12);
643 ShowFrame(f15);
646 errorset=kTRUE;
653 // in case of a 2D plot:
654 } else if (!str.Contains("LEGO") && !str.Contains("SURF")){
657 HideFrame(f3); // Hiding the histogram type combo box
658 ShowFrame(f7);
659 ShowFrame(f8);
660 ShowFrame(f9);
661 ShowFrame(f15);
663 // initialising fAddCombo
664 if (str.Contains("C")) {
665 if (str.Contains("CYL")) {
666 TString dum = str;
667 dum.Remove(strstr(dum.Data(),"CYL")-dum.Data(),3);
668 if (dum.Contains("C")) fAddCombo->Select(kADD_SMOOTH);
670 }
671 else if (str.Contains("LF2")) fAddCombo->Select(kADD_FILL);
672 else if (str.Contains("L")){
673 TString dum = str;
674 if (str.Contains("CYL")) {
675 dum.Remove(strstr(dum.Data(),"CYL")-dum.Data(),3);
676 if (dum.Contains("L")) fAddCombo->Select(kADD_SIMPLE);
677 }
678 if (str.Contains("POL")) {
679 dum.Remove(strstr(dum.Data(),"POL")-dum.Data(),3);
680 if (dum.Contains("L")) fAddCombo->Select(kADD_SIMPLE);
682 } else fAddCombo->Select(kADD_NONE);
683
686 else if (str.Contains("HIST")) {
687 if (str=="HIST") fAddSimple->SetState(kButtonDisabled);
690
691 if (str.Contains("B")) {
692 TString dum = str;
693 if (str.Contains("BAR")) {
696 ShowFrame(f10);
697 ShowFrame(f11);
698 ShowFrame(f12);
699 } else {
703 ShowFrame(f10);
704 ShowFrame(f11);
705 HideFrame(f12);
706 }
707 } else {
710 HideFrame(f10);
711 HideFrame(f11);
712 HideFrame(f12);
713 }
714 if (str.Contains("P") ) {
717 } else if (!str.Contains("BAR")) fAddMarker->SetState(kButtonUp);
719
720 // in case of a 3D plot
721 } else if (str.Contains("LEGO") || str.Contains("SURF")){
724 TGListBox* lb;
726 // set Coordinate ComboBox
727 if (str.Contains("SURF")){
728 // surf cannot be combined with spheric and cartesian coordinates
729 // i.e. remove them from the combobox
732 lb = fCoordsCombo->GetListBox();
733 lb->Resize(lb->GetWidth(), 49);
734 } else {
735 // surf cannot be combined with spheric and cartesian coordinates
736 // if surf was selected before here the removed items were added the combobox again
737 if (((TGLBContainer*)((TGListBox*)fCoordsCombo->GetListBox())->GetContainer())->GetPos(kCOORDS_SPH)==-1)
738 fCoordsCombo->AddEntry("Spheric", kCOORDS_SPH);
739 if (((TGLBContainer*)((TGListBox*)fCoordsCombo->GetListBox())->GetContainer())->GetPos(kCOORDS_CAR)==-1) {
740 fCoordsCombo->AddEntry("Cartesian", kCOORDS_CAR);
741 lb = fCoordsCombo->GetListBox();
742 lb->Resize(lb->GetWidth(), 83);
743 }
744 }
745 // initialising the Type Combobox
746 if (str.Contains("LEGO2")) fTypeCombo->Select(kTYPE_LEGO2);
747 else if (str.Contains("LEGO1")) fTypeCombo->Select(kTYPE_LEGO1);
748 else if (str.Contains("LEGO")) fTypeCombo->Select(kTYPE_LEGO);
749 else if (str.Contains("SURF5")) fTypeCombo->Select(kTYPE_SURF5);
750 else if (str.Contains("SURF4")) fTypeCombo->Select(kTYPE_SURF4);
751 else if (str.Contains("SURF3")) fTypeCombo->Select(kTYPE_SURF3);
752 else if (str.Contains("SURF2")) fTypeCombo->Select(kTYPE_SURF2);
753 else if (str.Contains("SURF1")) fTypeCombo->Select(kTYPE_SURF1);
754 else if (str.Contains("SURF")) fTypeCombo->Select(kTYPE_SURF);
755
756 if (str.Contains("CYL")) fCoordsCombo->Select(kCOORDS_CYL);
757 else if (str.Contains("POL")) fCoordsCombo->Select(kCOORDS_POL);
758 else if (str.Contains("SPH")) fCoordsCombo->Select(kCOORDS_SPH);
759 else if (str.Contains("PSR")) fCoordsCombo->Select(kCOORDS_PSR);
760 else fCoordsCombo->Select(kCOORDS_CAR); //default
761
762 HideFrame(f6);
763 HideFrame(f7);
764 HideFrame(f8);
765 HideFrame(f9);
766 HideFrame(f15);
767 if (str.Contains("LEGO")) {
768 ShowFrame(f10);
769 ShowFrame(f11);
770 HideFrame(f12);
771 } else {
772 HideFrame(f10);
773 HideFrame(f11);
774 HideFrame(f12);
775 }
778 }
779
780 if (!errorset) {
781 if (str.Contains("E1")) fErrorCombo->Select(kERRORS_EDGES);
782 else if (str.Contains("E2")) fErrorCombo->Select(kERRORS_REC);
783 else if (str.Contains("E3")) fErrorCombo->Select(kERRORS_FILL);
784 else if (str.Contains("E4")) fErrorCombo->Select(kERRORS_CONTOUR);
785 else if (str.Contains("E")) {
786 if (str.Contains("LEGO")) {
787 TString dum=str;
788 dum.Remove(strstr(dum.Data(),"LEGO")-dum.Data(),4);
791 } else fErrorCombo->Select(kERRORS_NO); //default
792 }
793
795 HideFrame(f7);
796 HideFrame(f8);
797 }
798 if (str.Contains("BAR") || ((fAddBar->GetState()==kButtonDown) &&
799 (fDim->GetState()==kButtonDown))) {
800 ShowFrame(f10);
801 ShowFrame(f11);
802 ShowFrame(f12);
805 if (str.Contains("HBAR")) fMakeHBar->SetState(kButtonDown);
807
808 if (str.Contains("BAR4")) fPercentCombo->Select(kPER_40);
809 else if (str.Contains("BAR3")) fPercentCombo->Select(kPER_30);
810 else if (str.Contains("BAR2")) fPercentCombo->Select(kPER_20);
811 else if (str.Contains("BAR1")) fPercentCombo->Select(kPER_10);
813 }
814
815 Int_t nx = fHist -> GetXaxis() -> GetNbins();
816 Int_t nxbinmin = fHist -> GetXaxis() -> GetFirst();
817 Int_t nxbinmax = fHist -> GetXaxis() -> GetLast();
818
820
822
823 // Check if histogram is from ntupla/tree or not.
824 // If it is a standard histogram or a ntupla based histogram
825 // show a different frame in case of rebinning (fBinCont) with sliders and bin number entries
826 // connected to different methods.
827 // For example the entry field fBinNumberEntry is connected to
828 // the method DoBinLabel in case of non-ntupla histograms which just call Th1::Rebin
829 // In csae of a tree based histogram the entry field fBinNumberEntry1 is used which is connected to
830 // TH1Editor::DoBinLabel1 which is re-filling the histograms with the cached values from the TTreePlayer.
831 // Since the actual number of histogram entry can be larger than the cache size of the TTreePlayer
832 // (see JIRA ROOT-5900 or http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=17107 )
833 // the GUI frame based on a non-tupla histogram is used when the number of entries of the histogram is
834 // not the same as the number of filled entries in the TTreePlayer object.
835
836 if (!player || player->GetHistogram()!=fHist ||
837 fHist->GetEntries() != player->GetNfill()) {
838
839 Int_t n = 0;
840 if (fBinHist) n = fBinHist->GetXaxis()->GetNbins();
841 else n = nx;
842 if (n < 1) n = 1;
845 Int_t* div = Dividers(n);
846 Int_t up = 0;
847 if (div[0]-1 <= 1) up = 2;
848 else up = div[0]-1;
849 fBinSlider->SetRange(1,up);
850 Int_t i = 1;
853 else {
854 while ( div[i] != nx) i ++;
855 fBinSlider->SetPosition(div[0] - i + 1);
856 }
859 delete [] div;
860 }
861 else if (player && fHist==player->GetHistogram() && fHist->GetEntries() == player->GetNfill()) {
862 // in case of a ntupla/tree based histogram with number of entries not exceeding the TTreePlayer cache
865 fBinSlider->SetRange(0,1);
869 fBinNumberEntry1->SetIntNumber(nxbinmax-nxbinmin+1);
870 }
871
872 fSlider->SetRange(1,nx);
873 fSlider->SetPosition((Double_t)nxbinmin,(Double_t)nxbinmax);
874
877
879 fHist->GetXaxis()->GetBinWidth(1));
880
882 fMake=kTRUE;
885}
886
887////////////////////////////////////////////////////////////////////////////////
888/// Slot connected to the histogram title setting.
889
890void TH1Editor::DoTitle(const char *text)
891{
892 if (fAvoidSignal) return;
894 Update();
895}
896
897////////////////////////////////////////////////////////////////////////////////
898/// Slot connected to the show markers check box.
899
901{
902 if (fAvoidSignal) return;
903 TString str = GetDrawOption();
904 str.ToUpper();
905 if (str.Contains("SAME"))
906 fSameOpt = kTRUE;
907 else
909 TString dum = str;
910
911 if (dum.Contains("POL")) dum.Remove(strstr(dum.Data(),"POL")-dum.Data(),3);
912 if (dum.Contains("SPH")) dum.Remove(strstr(dum.Data(),"SPH")-dum.Data(),3);
913 if (dum.Contains("PSR")) dum.Remove(strstr(dum.Data(),"PSR")-dum.Data(),3);
914 if (on) {
915 if (!dum.Contains("P")) str += "P";
917 if (str.Contains("HIST"))
918 str.Remove(strstr(str.Data(),"HIST")-str.Data(),4);
919 } else if (fAddMarker->GetState()==kButtonUp) {
920 if (str.Contains("POL") || str.Contains("SPH")) {
921 while (dum.Contains("P"))
922 dum.Remove(strstr(dum.Data(),"P")-dum.Data(),1);
923 if (str.Contains("POL")) str = dum + "POL";
924 if (str.Contains("SPH")) str = dum + "SPH";
925 if (str.Contains("PSR")) str = dum + "PSR";
926 } else if (str.Contains("P")) str.Remove(str.First("P"),1);
927 if ((str=="HIST") || (str=="") ||
928 (fAddB->GetState()==kButtonDown) ||
931 else if (str.Contains("HIST"))
933 else
935 }
936 if (fMake) {
937 if (fSameOpt) str += "SAME";
938 SetDrawOption(str);
939 Update();
940 }
941}
942
943////////////////////////////////////////////////////////////////////////////////
944/// Slot connected to the bar Add check box.
945
947{
948 if (fAvoidSignal) return;
949 TString str = GetDrawOption();
950 str.ToUpper();
951 if (str.Contains("SAME"))
952 fSameOpt = kTRUE;
953 else
955 if (fMakeB) {
957 if (on) {
958 if (!str.Contains("B")) str += "B";
959 ShowFrame(f10);
960 ShowFrame(f11);
961 HideFrame(f12);
966 } else if (fAddB->GetState()==kButtonUp) {
967 while (str.Contains("B"))
968 str.Remove(str.First("B"),1);
969 HideFrame(f10);
970 HideFrame(f11);
971 HideFrame(f12);
974 !(str=="" || str=="HIST" ||
977 }
978 if (fSameOpt) str += "SAME";
979 if (fMake) SetDrawOption(str);
980 Update();
981
983 }
984}
985
986////////////////////////////////////////////////////////////////////////////////
987/// Slot connected to the bar Add check box.
988
990{
991 if (fAvoidSignal) return;
993 TString str = GetDrawOption();
994 str.ToUpper();
995 if (str.Contains("SAME"))
996 fSameOpt = kTRUE;
997 else
999 if (fMakeB) {
1000 fMakeB=kFALSE;
1001 Int_t o = 0;
1002 if (str.Contains("HBAR")) o=1;
1003 if (str.Contains("BAR4"))
1004 str.Remove(strstr(str.Data(),"BAR4")-str.Data()-o,4+o);
1005 else if (str.Contains("BAR3"))
1006 str.Remove(strstr(str.Data(),"BAR3")-str.Data()-o,4+o);
1007 else if (str.Contains("BAR2"))
1008 str.Remove(strstr(str.Data(),"BAR2")-str.Data()-o,4+o);
1009 else if (str.Contains("BAR1"))
1010 str.Remove(strstr(str.Data(),"BAR1")-str.Data()-o,4+o);
1011 else if (str.Contains("BAR0"))
1012 str.Remove(strstr(str.Data(),"BAR0")-str.Data()-o,4+o);
1013 else if (str.Contains("BAR"))
1014 str.Remove(strstr(str.Data(),"BAR")-str.Data()-o,3+o);
1015 if (on) {
1016 if ((fAddMarker->GetState()==kButtonDown) &&
1020 else if ((fAddMarker->GetState()!=kButtonDown) &&
1022 if (str.Contains("HIST"))
1024 else if (fAddCombo->GetSelected()!=kADD_NONE)
1026 else
1028 }
1029 switch (fPercentCombo->GetSelected()){
1030 case(-1): {
1031 str += "BAR";
1033 break;
1034 }
1035 case(kPER_0): {
1036 str += "BAR";
1037 break;
1038 }
1039 case(kPER_10): {
1040 str += "BAR1";
1041 break;
1042 }
1043 case(kPER_20): {
1044 str += "BAR2";
1045 break;
1046 }
1047 case(kPER_30): {
1048 str += "BAR3";
1049 break;
1050 }
1051 case(kPER_40): {
1052 str += "BAR4";
1053 break;
1054 }
1055 }
1056 ShowFrame(f10);
1057 ShowFrame(f11);
1058 ShowFrame(f12);
1060 str.Insert(strstr(str.Data(),"BAR")-str.Data(),"H");
1064 } else if (fAddBar->GetState()==kButtonUp) {
1065 HideFrame(f10);
1066 HideFrame(f11);
1067 HideFrame(f12);
1071 if (str=="" || str=="HIST" || fAddCombo->GetSelected() != kADD_NONE ||
1072 ((fAddMarker->GetState() == kButtonDown) &&
1075 }
1076 if (fSameOpt) str += "SAME";
1077 if (fMake) SetDrawOption(str);
1078 Update();
1080 fMakeB=kTRUE;
1081 }
1082 fAddMarker->Connect("Toggled(Bool_t)", "TH1Editor", this, "DoAddMarker(Bool_t)");
1083}
1084
1085////////////////////////////////////////////////////////////////////////////////
1086/// Slot connected to fAddSimple check box for drawing a simple histogram
1087/// without errors (== HIST draw option) in combination with some other
1088/// draw options. It draws an additional line on the top of the bins.
1089
1091{
1092 if (fAvoidSignal) return;
1094 // Bool_t make=kFALSE;
1095 fMake = kFALSE;
1096 TString str = GetDrawOption();
1097 str.ToUpper();
1098 if (str.Contains("SAME"))
1099 fSameOpt = kTRUE;
1100 else
1101 fSameOpt = kFALSE;
1102 if (on) {
1103 if (!str.Contains("HIST")) {
1104 str += "HIST";
1106 fMake=kTRUE;
1107 }
1108 } else if (fAddSimple->GetState()==kButtonUp) {
1109 if (str.Contains("HIST")) {
1110 str.Remove(strstr(str.Data(),"HIST")-str.Data(),4);
1112 fMake=kTRUE;
1113 }
1114 }
1115 if (fSameOpt) str += "SAME";
1116 if (fMake) SetDrawOption(str);
1117 fAddMarker->Connect("Toggled(Bool_t)", "TH1Editor", this, "DoAddMarker(Bool_t)");
1118 Update();
1119}
1120
1121////////////////////////////////////////////////////////////////////////////////
1122/// Slot connected to the 'Plot' button group.
1123
1125{
1126 if (gPad && gPad->GetVirtCanvas())
1127 gPad->GetVirtCanvas()->SetCursor(kWatch);
1128 gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kWatch));
1129
1130 if (fDim->GetState() == kButtonDown)
1131 DoHistSimple();
1132 else
1133 DoHistComplex();
1134
1135 if (gPad && gPad->GetVirtCanvas())
1136 gPad->GetVirtCanvas()->SetCursor(kPointer);
1137 gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kPointer));
1138}
1139
1140////////////////////////////////////////////////////////////////////////////////
1141/// Slot connected to the 2D radio button.
1142
1144{
1145 if (fAvoidSignal) return;
1146 if (fDim->GetState()==kButtonDown){
1147 TString str ="";
1148 fMake=kFALSE;
1149 TGListBox* lb;
1150 HideFrame(f3);
1151 ShowFrame(f6);
1152 ShowFrame(f9);
1153 ShowFrame(f15);
1155 if ((fAddBar->GetState() != kButtonDown ||
1159 else if ((fAddSimple->GetState()==kButtonDisabled) &&
1162 else if (fAddSimple->GetState()!=kButtonUp)
1167
1169 ShowFrame(f7);
1170 ShowFrame(f8);
1171 } else {
1172 HideFrame(f7);
1173 HideFrame(f8);
1176 }
1177
1178 if ((fAddB->GetState() == kButtonDisabled)) {
1179 if (fAddBar->GetState()==kButtonDown) {
1180 ShowFrame(f10);
1181 ShowFrame(f11);
1182 ShowFrame(f12);
1183 } else {
1184 HideFrame(f10);
1185 HideFrame(f11);
1186 HideFrame(f12);
1187 }
1188 }
1189 if (fAddBar->GetState() == kButtonDisabled){
1190 ShowFrame(f10);
1191 ShowFrame(f11);
1192 HideFrame(f12);
1193 }
1194 if ((fAddBar->GetState() == kButtonUp) &&
1195 (fAddB->GetState() == kButtonUp)) {
1196 HideFrame(f10);
1197 HideFrame(f11);
1198 HideFrame(f12);
1199 }
1203 lb = fAddCombo->GetListBox();
1204 lb->Resize(lb->GetWidth(),19);
1207 fAddCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoHistChanges()");
1208 } else {
1209 if (((TGLBContainer*)((TGListBox*)fAddCombo->GetListBox())->GetContainer())->GetPos(kADD_SIMPLE)==-1)
1210 ((TGListBox*)fAddCombo->GetListBox())->AddEntry("Simple Line", kADD_SIMPLE);
1211 if (((TGLBContainer*)((TGListBox*)fAddCombo->GetListBox())->GetContainer())->GetPos(kADD_SMOOTH)==-1)
1212 ((TGListBox*)fAddCombo->GetListBox())->AddEntry("Smooth Line", kADD_SMOOTH);
1213 if (((TGLBContainer*)((TGListBox*)fAddCombo->GetListBox())->GetContainer())->GetPos(kADD_FILL)==-1) {
1214 ((TGListBox*)fAddCombo->GetListBox())->AddEntry("Fill Area",kADD_FILL);
1215 lb = fAddCombo->GetListBox();
1216 lb->Resize(lb->GetWidth(),76);
1217 }
1218 }
1219 if (fAddSimple->GetState()==kButtonDown) str+="HIST";
1221 if (fSameOpt) str += "SAME";
1222 SetDrawOption(str);
1223 Update();
1224 //fGedEditor->GetTab()->Layout();
1226 fMake=kTRUE;
1227 }
1228}
1229
1230////////////////////////////////////////////////////////////////////////////////
1231/// Slot connected to the 3D radio button.
1232
1234{
1235 if (fAvoidSignal) return;
1236 if (fDim0->GetState()==kButtonDown) {
1237 TString str ="";
1238 fMake=kFALSE;
1239 ShowFrame(f3);
1240 HideFrame(f6);
1241 HideFrame(f7);
1242 HideFrame(f8);
1243 HideFrame(f9);
1244 HideFrame(f15);
1246 if (fTypeCombo->GetSelected()==-1 && fCoordsCombo->GetSelected()==-1) {
1247 str = "LEGO"+GetHistErrorLabel();
1250 } else if (fTypeCombo->GetSelected()==-1){
1251 str = "LEGO"+GetHistErrorLabel();
1253 } else if (fCoordsCombo->GetSelected()==-1) {
1256 } else {
1258 }
1259 if (str.Contains("LEGO")) {
1260 ShowFrame(f10);
1261 ShowFrame(f11);
1262 HideFrame(f12);
1263 } else {
1264 HideFrame(f10);
1265 HideFrame(f11);
1266 HideFrame(f12);
1267 }
1268 if (fSameOpt) str += "SAME";
1269 SetDrawOption(str);
1270 Update();
1272 fGedEditor->GetTab()->Layout();
1273 fMake=kTRUE;
1274 }
1275}
1276
1277////////////////////////////////////////////////////////////////////////////////
1278/// Slot connected to the histogram type, the coordinate type, the error type
1279/// and the Add combo box.
1280
1282{
1283 if (fAvoidSignal) return;
1284 fMakeB= kFALSE;
1285 TGListBox* lb;
1286 if (GetHistTypeLabel().Contains("SURF")) {
1292 lb = fCoordsCombo->GetListBox();
1293 lb->Resize(lb->GetWidth(), 49);
1294 } else {
1295 if (((TGLBContainer*)((TGListBox*)fCoordsCombo->GetListBox())->GetContainer())->GetPos(kCOORDS_SPH)==-1)
1296 ((TGListBox*)fCoordsCombo->GetListBox())->AddEntrySort("Spheric", kCOORDS_SPH);
1297 if (((TGLBContainer*)((TGListBox*)fCoordsCombo->GetListBox())->GetContainer())->GetPos(kCOORDS_CAR)==-1) {
1298 ((TGListBox*)fCoordsCombo->GetListBox())->AddEntrySort("Cartesian", kCOORDS_CAR);
1299 lb = fCoordsCombo->GetListBox();
1300 lb->Resize(lb->GetWidth(), 83);
1301 }
1302 }
1303 if (fDim->GetState()!=kButtonUp){
1305 HideFrame(f7);
1306 HideFrame(f8);
1307 ShowFrame(f9);
1315 lb = fAddCombo->GetListBox();
1316 lb->Resize(lb->GetWidth(),19);
1319 fAddCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoHistChanges()");
1320 if (fAddBar->GetState()==kButtonDown) {
1321 ShowFrame(f10);
1322 ShowFrame(f11);
1323 ShowFrame(f12);
1324 } else {
1325 HideFrame(f10);
1326 HideFrame(f11);
1327 HideFrame(f12);
1328 }
1329 } else {
1330 Bool_t on = fMake;
1331 fMake=kFALSE;
1332 ShowFrame(f7);
1333 ShowFrame(f8);
1334 ShowFrame(f9);
1337 if (fAddBar->GetState() != kButtonDown &&
1340 if (((TGLBContainer*)((TGListBox*)fAddCombo->GetListBox())->GetContainer())->GetPos(kADD_SIMPLE)==-1)
1341 ((TGListBox*)fAddCombo->GetListBox())->AddEntry("Simple Line", kADD_SIMPLE);
1342 if (((TGLBContainer*)((TGListBox*)fAddCombo->GetListBox())->GetContainer())->GetPos(kADD_SMOOTH)==-1)
1343 ((TGListBox*)fAddCombo->GetListBox())->AddEntry("Smooth Line", kADD_SMOOTH);
1344 if (((TGLBContainer*)((TGListBox*)fAddCombo->GetListBox())->GetContainer())->GetPos(kADD_FILL)==-1) {
1345 ((TGListBox*)fAddCombo->GetListBox())->AddEntry("Fill Area",kADD_FILL);
1346 lb = fAddCombo->GetListBox();
1347 lb->Resize(lb->GetWidth(),76);
1348 }
1349 fMake=on;
1350 }
1353 } else {
1356 else if (fAddSimple->GetState()==kButtonDisabled)
1358 }
1359 } else if (fDim0->GetState()==kButtonDown) {
1360 if (GetHistTypeLabel().Contains("LEGO")) {
1361 ShowFrame(f10);
1362 ShowFrame(f11);
1363 HideFrame(f12);
1364 } else {
1365 HideFrame(f10);
1366 HideFrame(f11);
1367 HideFrame(f12);
1368 }
1369 }
1370 if (fMake) {
1371 TString str = "";
1372 if (fDim->GetState()==kButtonDown)
1374 else if (fDim0->GetState()==kButtonDown)
1377 str += "HIST";
1378 if (fSameOpt)
1379 str += "SAME";
1380 SetDrawOption(str);
1381 if (str=="" || str=="HIST") fAddSimple->SetState(kButtonDisabled);
1382 Update();
1383 }
1385 // fGedEditor->GetTab()->Layout();
1386 fMakeB=kTRUE;
1387}
1388
1389////////////////////////////////////////////////////////////////////////////////
1390/// Slot connected to the Bar Width of the Bar Charts.
1391
1393{
1394 if (fAvoidSignal) return;
1396 Update();
1397}
1398
1399////////////////////////////////////////////////////////////////////////////////
1400/// Slot connected to the Bar Offset of the Bar Charts.
1401
1403{
1404 if (fAvoidSignal) return;
1407 Update();
1408}
1409
1410////////////////////////////////////////////////////////////////////////////////
1411/// Slot connected to the bar percentage settings.
1412
1414{
1415 if (fAvoidSignal) return;
1416 TString str = GetDrawOption();
1417 str.ToUpper();
1418 if (str.Contains("SAME"))
1419 fSameOpt = kTRUE;
1420 else
1421 fSameOpt = kFALSE;
1422 Int_t o = 0;
1423 if (str.Contains("HBAR")) o=1;
1424 if (str.Contains("BAR4"))
1425 str.Remove(strstr(str.Data(),"BAR4")-str.Data()-1,4+o);
1426 else if (str.Contains("BAR3"))
1427 str.Remove(strstr(str.Data(),"BAR3")-str.Data()-o,4+o);
1428 else if (str.Contains("BAR2"))
1429 str.Remove(strstr(str.Data(),"BAR2")-str.Data()-o,4+o);
1430 else if (str.Contains("BAR1"))
1431 str.Remove(strstr(str.Data(),"BAR1")-str.Data()-o,4+o);
1432 else if (str.Contains("BAR0"))
1433 str.Remove(strstr(str.Data(),"BAR0")-str.Data()-o,4+o);
1434 else if (str.Contains("BAR"))
1435 str.Remove(strstr(str.Data(),"BAR")-str.Data()-o,3+o);
1436
1437 if (fMakeHBar->GetState()==kButtonDown) str+="H";
1438 switch (fPercentCombo->GetSelected()){
1439 case (kPER_0) :{ str += "BAR"; break;}
1440 case (kPER_10):{ str += "BAR1"; break;}
1441 case (kPER_20):{ str += "BAR2"; break;}
1442 case (kPER_30):{ str += "BAR3"; break;}
1443 case (kPER_40):{ str += "BAR4"; break;}
1444 }
1445 if (fSameOpt) str += "SAME";
1446 if (fMake) SetDrawOption(str);
1447 Update();
1448}
1449
1450////////////////////////////////////////////////////////////////////////////////
1451/// Slot connected to the Horizontal Bar check button.
1452
1454{
1455 if (fAvoidSignal) return;
1456 TString str = GetDrawOption();
1457 str.ToUpper();
1458 if (str.Contains("SAME"))
1459 fSameOpt = kTRUE;
1460 else
1461 fSameOpt = kFALSE;
1462 if (on) {
1463 if (!str.Contains("HBAR"))
1464 str.Insert(strstr(str.Data(),"BAR")-str.Data(),"H");
1465 }
1466 else if (fMakeHBar->GetState()==kButtonUp) {
1467 if (str.Contains("HBAR"))
1468 str.Remove(strstr(str.Data(),"BAR")-str.Data()-1,1);
1469 }
1470 if (fSameOpt) str += "SAME";
1471 if (fMake) SetDrawOption(str);
1472 Update();
1473}
1474
1475////////////////////////////////////////////////////////////////////////////////
1476/// Slot connected to the x-Slider for redrawing of the histogram
1477/// according to the new Slider range.
1478
1480{
1481 if (fAvoidSignal) return;
1482 auto pad = fGedEditor->GetPad();
1483 if (!pad)
1484 return;
1485
1486 auto xaxis = fHist->GetXaxis();
1487 Double_t xleft = xaxis->GetBinLowEdge((Int_t)((fSlider->GetMinPosition())+0.5));
1488 Double_t xright = xaxis->GetBinUpEdge((Int_t)((fSlider->GetMaxPosition())+0.5));
1489
1491 Double_t ymin = pad->GetUymin();
1492 Double_t ymax = pad->GetUymax();
1493 TAttLine{2, 1, 1}.ModifyOn(*pad);
1494 pad->PaintBox(xleft, ymin, xright, ymax, "ilslider_th1");
1495 pad->UpdateAsync();
1496 fSldMin->SetNumber(xleft);
1497 fSldMax->SetNumber(xright);
1498 } else if (fDelaydraw->GetState() == kButtonDown &&
1499 fDim0->GetState() == kButtonDown &&
1501 auto view = pad->GetView();
1502 if (!view) return;
1503
1504 Double_t rmin[3], rmax[3];
1505 view->GetRange(rmin, rmax);
1506
1507 Double_t ymin = rmin[1];
1508 Double_t ymax = rmax[1];
1509 Double_t zmin = rmin[2];
1510 Double_t zmax = rmax[2];
1511
1512 Double_t xx[5], yy[5];
1513 auto add_point = [view, &xx, &yy](int i, double x, double y, double z) {
1514 Double_t vvv[3] = {x, y, z};
1515 Double_t uu[3];
1516 view->WCtoNDC(vvv, uu);
1517 xx[i] = uu[0];
1518 yy[i] = uu[1];
1519 };
1520
1521 TAttLine{2, 1, 1}.ModifyOn(*pad);
1522 add_point(0, xleft, ymin, zmin);
1523 add_point(1, xleft, ymax, zmin);
1524 add_point(2, xleft, ymax, zmax);
1525 add_point(3, xleft, ymin, zmax);
1526 add_point(4, xleft, ymin, zmin);
1527 pad->PaintPolyLine(5, xx, yy, "islider1_th1");
1528 add_point(0, xright, ymin, zmin);
1529 add_point(1, xright, ymax, zmin);
1530 add_point(2, xright, ymax, zmax);
1531 add_point(3, xright, ymin, zmax);
1532 add_point(4, xright, ymin, zmin);
1533 pad->PaintPolyLine(5, xx, yy, "islider2_th1");
1534 pad->UpdateAsync();
1535 fSldMin->SetNumber(xleft);
1536 fSldMax->SetNumber(xright);
1537 } else if (fDelaydraw->GetState() == kButtonDown &&
1538 fDim0->GetState() == kButtonDown) {
1539 fSldMin->SetNumber(xleft);
1540 fSldMax->SetNumber(xright);
1541 } else {
1543 (Int_t)((fSlider->GetMaxPosition())+0.5));
1544 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
1545 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
1547 Update();
1548 }
1550 if (player && player->GetHistogram() == fHist) {
1551 Int_t last = xaxis->GetLast();
1552 Int_t first = xaxis->GetFirst();
1553 fBinNumberEntry1->SetIntNumber(last-first+1);
1554 // How to redraw the NumberEntry without calling Update??
1555 // Update kills the "virtual" painted box in Delayed draw mode
1557 // fGedEditor->GetTab()->Layout();
1558 }
1561}
1562
1563////////////////////////////////////////////////////////////////////////////////
1564/// Slot connected to the x-axis Range slider for initialising the
1565/// values of the slider movement.
1566
1568{
1569 DoSliderMoved();
1570 Update();
1571}
1572
1573////////////////////////////////////////////////////////////////////////////////
1574/// Slot connected to the x-axis Range slider for finalizing the
1575/// values of the slider movement.
1576
1578{
1579 if (fAvoidSignal) return;
1582 (Int_t)((fSlider->GetMaxPosition())+0.5));
1585 Update();
1586 }
1588 if (player) if (player->GetHistogram() == fHist) {
1589 Int_t last = fHist->GetXaxis()->GetLast();
1590 Int_t first = fHist->GetXaxis()->GetFirst();
1591 fBinNumberEntry1->SetIntNumber(last-first+1);
1592 Update();
1593 }
1594}
1595
1596////////////////////////////////////////////////////////////////////////////////
1597/// Slot connected to the number entry fields containing the Max/Min
1598/// value of the x-axis.
1599
1601{
1602 if (fAvoidSignal) return;
1603 Int_t nx = fHist->GetXaxis()->GetNbins();
1605 Double_t lowLimit = fHist->GetXaxis()->GetBinLowEdge(1);
1606 Double_t upLimit = fHist->GetXaxis()->GetBinUpEdge(nx);
1607 if ((fSldMin->GetNumber()+width/2) < (lowLimit))
1608 fSldMin->SetNumber(lowLimit);
1609 if ((fSldMax->GetNumber()-width/2) > (upLimit))
1610 fSldMax->SetNumber(upLimit);
1611// Set the histogram range and the axis range slider
1613 fSldMax->GetNumber()-width/2);
1614 Int_t nxbinmin = fHist->GetXaxis()->GetFirst();
1615 Int_t nxbinmax = fHist->GetXaxis()->GetLast();
1616 fSlider->SetPosition((Double_t)(nxbinmin),(Double_t)(nxbinmax));
1617 Update();
1618}
1619
1620////////////////////////////////////////////////////////////////////////////////
1621/// Slot connected to the rebin slider in case of a not ntuple histogram
1622/// Updates some other widgets which are related to the rebin slider.
1623
1625{
1626 // draw the rebinned histogram in case of delay draw mode
1627 if (fAvoidSignal) return;
1629 if (!fBinHist) {
1630 fBinHist = (TH1*)fHist->Clone("BinHist");
1631 // we will manage this histogram
1633 }
1634 Int_t nx = fBinHist->GetXaxis()->GetNbins();
1635 Int_t numx = fBinSlider->GetPosition();
1636 Int_t* divx = Dividers(nx);
1637 if (divx[0]==2) fBinSlider->SetPosition(2);
1638 if (divx[0]==2) {
1639 delete [] divx;
1640 return;
1641 }
1642 // delete the histogram which is on the screen
1643 fGedEditor->GetPad()->cd();
1644 fHist->Reset();
1646 fBinHist->GetXaxis()->GetXmax());
1647 fHist->Add(fBinHist);
1649 fHist->Rebin(divx[numx]);
1650 // fModel=fHist;
1651 if (divx[0]!=2) {
1652 TAxis* xaxis = fHist->GetXaxis();
1653 Double_t xBinWidth = xaxis->GetBinWidth(1);
1654 xaxis->SetRangeUser(fSldMin->GetNumber()+xBinWidth/2,
1655 fSldMax->GetNumber()-xBinWidth/2);
1656 fSlider->SetRange(1,(Int_t)nx/divx[numx]);
1657 fSlider->SetPosition(xaxis->FindBin(fSldMin->GetNumber()+xBinWidth/2),
1658 xaxis->FindBin(fSldMax->GetNumber()-xBinWidth/2));
1659 // the x-axis range could be changed a little bit by Rebin algorithm
1660 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
1661 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
1662 }
1667 Update();
1668 delete [] divx;
1669 }
1670// fGedEditor->GetPad()->GetCanvas()->Selected(fGedEditor->GetPad(), fHist, 0);
1671 // fModel = fHist;
1672 Refresh(fHist);
1673}
1674
1675////////////////////////////////////////////////////////////////////////////////
1676/// Slot connected to the rebin slider in case of a not ntuple histogram
1677/// (does the Rebinning of the histogram).
1678
1680{
1681 // create a clone in the background, when the slider is moved for
1682 // the first time
1683 if (fAvoidSignal) return;
1684 if (!fBinHist /*&& fDelaydraw->GetState()!=kButtonDown*/) {
1685 Int_t* divx = Dividers(fHist->GetXaxis()->GetNbins());
1686 if (divx[0]==2) {
1687 delete [] divx;
1688 return;
1689 }
1690 fBinHist = (TH1*)fHist->Clone("BinHist");
1691 // the TH1Editor class manage this histogram
1693 delete [] divx;
1694 }
1695 // if the slider already has been moved and the clone is saved
1696 Int_t nx = fBinHist->GetXaxis()->GetNbins();
1697 Int_t* divx = Dividers(nx);
1698 if (divx[0]==2) {
1700 delete [] divx;
1701 return;
1702 }
1703 Int_t maxx = (Int_t)nx/divx[numx];
1704 if (maxx==1) maxx=2;
1705 if (fDelaydraw->GetState() == kButtonUp) {
1706 fGedEditor->GetPad()->cd();
1707 fHist->Reset();
1709 fBinHist->GetXaxis()->GetXmax());
1710 fHist->Add(fBinHist);
1712 fHist->Rebin(divx[numx]);
1713 //fModel=fHist;
1714 TAxis* xaxis = fHist->GetXaxis();
1715 Double_t xBinWidth = xaxis->GetBinWidth(1);
1716 xaxis->SetRangeUser(fSldMin->GetNumber()+xBinWidth/2,
1717 fSldMax->GetNumber()-xBinWidth/2);
1718 fSlider->SetRange(1,maxx);
1719 fSlider->SetPosition(xaxis->FindBin(fSldMin->GetNumber()+xBinWidth/2),
1720 xaxis->FindBin(fSldMax->GetNumber()-xBinWidth/2));
1721 // the axis range could be changed a little bit by the Rebin algorithm
1722 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
1723 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
1725 Update();
1726 }
1731 if (fBinNumberEntry->GetNumber()!=maxx)
1733 delete [] divx;
1734}
1735
1736////////////////////////////////////////////////////////////////////////////////
1737/// Slot connected to the rebin slider in case of a not ntuple histogram.
1738
1740{
1741 if (fAvoidSignal) return;
1743 if (d[0]==2 && !fBinHist) {
1745 "TH1 Editor", "It is not possible to rebin the histogram",
1747 gVirtualX->GrabPointer(fBinSlider->GetId(),0,0,0);
1748 }
1749 delete [] d;
1750 // calling the MessageBox again does NOT work!*/
1751}
1752
1753////////////////////////////////////////////////////////////////////////////////
1754/// Slot connected to the BinNumber Slider in case of a ntuple histogram
1755/// (does the Rebinning of the histogram).
1756
1758{
1759 if (fAvoidSignal) return;
1760 Double_t oldOffset = fOffsetNumberEntry->GetNumber();
1761 Int_t number = fBinSlider1->GetPosition();
1762 if (number==5) return;
1763 Int_t fact = 0;
1764 Int_t binNumber = 0;
1765 TAxis* xaxis = fHist->GetXaxis();
1766 // "compute" the scaling factor:
1767 if (number > 5) fact = number - 4;
1768 else fact = number - 6;
1770 if (!player) return;
1771 Int_t first = xaxis->GetFirst();
1772 Int_t last = xaxis->GetLast();
1773 Int_t nx = xaxis->GetNbins();
1774 Double_t min = xaxis->GetBinLowEdge(1); // overall min in user coords
1775 Double_t max = xaxis->GetBinUpEdge(nx); // overall max in user coords
1776 Double_t rmin = xaxis->GetBinLowEdge(first); // recent min in user coords
1777 Double_t rmax = xaxis->GetBinUpEdge(last); // recent max in user coords
1778
1779 ((TH1*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
1780 ((TH1*)player->GetHistogram())->Reset();
1781
1782 // get new Number of bins
1783 if (fact > 0) binNumber = fact*nx;
1784 if (fact < 0) binNumber = (Int_t) ((-1)*nx/fact+0.5);
1785 if (binNumber < 1) binNumber = 1;
1786 if (binNumber > 10000) binNumber= 10000;
1787 Double_t newOffset = 1.*fBinOffsetSld->GetPosition()/100*((max-min)/binNumber);
1788 // create new histogram - the main job is done by sel->TakeAction()
1789 ((TH1*)player->GetHistogram())->SetBins(binNumber,
1790 min-oldOffset+newOffset,
1791 max-oldOffset+newOffset);
1793 if (!sel) return;
1794 sel->TakeAction();
1795
1796 // restore and set all the attributes which were changed by TakeAction()
1798 fSlider->SetRange(1,binNumber);
1799 Double_t binWidth = fHist->GetXaxis()->GetBinWidth(1);
1800 fSlider->SetPosition(xaxis->FindBin(rmin), xaxis->FindBin(rmax));
1801 Double_t offset = 1.*fBinOffsetSld->GetPosition()/100*binWidth;
1802 xaxis->SetRange(xaxis->FindBin(rmin+binWidth/2),
1803 xaxis->FindBin(rmax-binWidth/2)); // SetRange in binNumbers!
1804 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
1805 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
1806 fBinNumberEntry1->SetNumber(xaxis->GetLast() - xaxis->GetFirst() + 1);
1810 xaxis->GetBinWidth(1));
1812 Update();
1813}
1814
1815////////////////////////////////////////////////////////////////////////////////
1816/// Slot connected to the rebin slider in case of an ntuple histogram.
1817/// It updates the BinNumberEntryField during the BinSlider movement.
1818
1820{
1821 if (fAvoidSignal) return;
1822 TAxis* xaxis = fHist->GetXaxis();
1823 Int_t first = xaxis->GetFirst();
1824 Int_t last = xaxis->GetLast();
1825 Int_t number = fBinSlider1->GetPosition();
1826 Int_t n = last -first+1;
1827 Int_t fact = 0;
1828 Int_t binNumber = 0;
1829 if (number >= 5) fact = number - 4;
1830 else fact = number - 6;
1831 if (fact > 0) binNumber = fact*n;
1832 if (fact < 0) binNumber = (Int_t) ((-1)*n/fact+0.5);
1833 if (binNumber < 1) binNumber = 1;
1834 if (binNumber > 10000) binNumber= 10000;
1835 fBinNumberEntry1->SetIntNumber(binNumber);
1836// Update();
1837}
1838
1839////////////////////////////////////////////////////////////////////////////////
1840/// Slot connected to the Bin number entry of the Rebinning tab.
1841
1843{
1844 if (fAvoidSignal) return;
1846 Int_t nx = 0;
1847 if (fBinHist) nx = fBinHist->GetXaxis()->GetNbins();
1848 else nx = fHist->GetXaxis()->GetNbins();
1849 if (nx < 2) return;
1850 Int_t *div = Dividers(nx);
1851 Int_t diff = std::abs(num - div[1]);
1852 Int_t c = 1;
1853 for (Int_t i = 2; i <= div[0]; i++) {
1854 if ((std::abs(num - div[i])) < diff) {
1855 c = i;
1856 diff = std::abs(num - div[i]);
1857 }
1858 }
1860 fBinSlider->SetPosition(div[0] - c +1);
1861 if (fDelaydraw->GetState()==kButtonUp) DoBinMoved(div[0] - c +1);
1862 else DoBinReleased();
1863// fGedEditor->GetPad()->GetCanvas()->Selected(fGedEditor->GetPad(), fHist, 0);
1864 // fModel = fHist;
1865 Refresh(fHist);
1866 delete [] div;
1867}
1868
1869////////////////////////////////////////////////////////////////////////////////
1870/// Slot connected to the Bin number entry of the Rebinning tab.
1871
1873{
1874 if (fAvoidSignal) return;
1875 Double_t oldOffset = fOffsetNumberEntry->GetNumber();
1877 TAxis* xaxis = fHist->GetXaxis();
1879 if (!player) return;
1880 Int_t first = xaxis->GetFirst();
1881 Int_t last = xaxis->GetLast();
1882 Int_t nx = xaxis->GetNbins();
1883 Double_t min = xaxis->GetBinLowEdge(1); // overall min in user coords
1884 Double_t max = xaxis->GetBinUpEdge(nx); // overall max in user coords
1885 Double_t rmin = xaxis->GetBinLowEdge(first); // recent min in user coords
1886 Double_t rmax = xaxis->GetBinUpEdge(last); // recent max in user coords
1887
1888 ((TH1*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
1889 ((TH1*)player->GetHistogram())->Reset();
1890
1891// Calculate the new number of bins in the complete range
1892 Int_t binNumber = (Int_t) ((max-min)/(rmax - rmin)*num + 0.5);
1893 if (binNumber < 1) binNumber = 1;
1894 if (binNumber > 10000) binNumber = 10000;
1895 Double_t offset = 1.*(fBinOffsetSld->GetPosition())/100*(max-min)/binNumber;
1896// create new histogram - the main job is done by sel->TakeAction()
1897 ((TH1*)player->GetHistogram())->SetBins(binNumber,
1898 min-oldOffset+offset,
1899 max-oldOffset+offset);
1901 if (!sel) return;
1902 sel->TakeAction();
1903
1904// Restore and set all the attributes which were changed by TakeAction()
1906 fSlider->SetRange(1,binNumber);
1907 Double_t binWidth = xaxis->GetBinWidth(1);
1908 fSlider->SetPosition(xaxis->FindBin(rmin), xaxis->FindBin(rmax));
1909 offset = 1.*fBinOffsetSld->GetPosition()/100*binWidth;
1910 xaxis->SetRange(xaxis->FindBin(rmin+binWidth/2),
1911 xaxis->FindBin(rmax-binWidth/2)); // SetRange in binNumbers!
1912 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
1913 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
1916 Update();
1917}
1918
1919////////////////////////////////////////////////////////////////////////////////
1920/// Slot connected to the OffSetSlider that saves the OldBinOffset
1921/// (nessesary for delay draw mode).
1922
1928
1929////////////////////////////////////////////////////////////////////////////////
1930/// Slot connected to the OffSetSlider.
1931/// It changes the origin of the histogram inbetween a binwidth and
1932/// rebin the histogram with the new Offset given by the Slider.
1933
1935{
1936 // !!problem: histogram with variable binwidth??
1937 // computes the new histogram in "delay draw" mode
1938
1939 if (fAvoidSignal) return;
1942 TAxis* xaxis = fHist->GetXaxis();
1943 Double_t binWidth = xaxis->GetBinWidth(1);
1944 Double_t offset = 1.*num/100*binWidth;
1945 Double_t oldOffset = fOldOffset;
1946 Int_t nx = xaxis->GetNbins();
1948 if (!player) return;
1949 Int_t first = xaxis->GetFirst();
1950 Int_t last = xaxis->GetLast();
1951 Double_t min = xaxis->GetBinLowEdge(1); // overall min in user coords
1952 Double_t max = xaxis->GetBinUpEdge(nx); // overall max in user coords
1953 Double_t rmin = xaxis->GetBinLowEdge(first); // recent min in user coords
1954 Double_t rmax = xaxis->GetBinUpEdge(last); // recent max in user coords
1955
1956 ((TH1*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
1957 ((TH1*)player->GetHistogram())->Reset();
1958
1959 ((TH1*)player->GetHistogram())->SetBins(nx,
1960 min+offset-oldOffset,
1961 max+offset-oldOffset);
1963 if (!sel) return;
1964 sel->TakeAction();
1965
1966 // Restore all the attributes which were changed by TakeAction()
1968 xaxis->SetRange(xaxis->FindBin(rmin+offset-oldOffset+binWidth/2),
1969 xaxis->FindBin(rmax+offset-oldOffset-binWidth/2)); // in binNumbers!
1970 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
1971 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
1973 Update();
1974 }
1975}
1976
1977////////////////////////////////////////////////////////////////////////////////
1978/// Slot connected to the OffSetSlider.
1979/// It changes the origin of the histogram inbetween a binwidth and
1980/// rebin the histogram with the new offset given by the Slider.
1981
1983{
1984 // !!histogram with variable binwidth??
1985 // !!only works for histograms with fixed binwidth
1986
1987 if (fAvoidSignal) return;
1988 TAxis* xaxis = fHist->GetXaxis();
1989 Double_t binWidth = xaxis->GetBinWidth(1);
1990 Double_t offset = 1.*num/100*binWidth;
1991 if (fDelaydraw->GetState()==kButtonUp) {
1992 Double_t oldOffset = fOffsetNumberEntry->GetNumber();
1993 Int_t nx = xaxis->GetNbins();
1995 if (!player) return;
1996 Int_t first = xaxis->GetFirst();
1997 Int_t last = xaxis->GetLast();
1998 Double_t min = xaxis->GetBinLowEdge(1); // overall min in user coords
1999 Double_t max = xaxis->GetBinUpEdge(nx); // overall max in user coords
2000 Double_t rmin = xaxis->GetBinLowEdge(first); // recent min in user coords
2001 Double_t rmax = xaxis->GetBinUpEdge(last); // recent max in user coords
2002
2003 ((TH1*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
2004 ((TH1*)player->GetHistogram())->Reset();
2005
2006 ((TH1*)player->GetHistogram())->SetBins(nx,
2007 min+offset-oldOffset,
2008 max+offset-oldOffset);
2010 if (!sel) return;
2011 sel->TakeAction();
2012
2013 // Restore all the attributes which were changed by TakeAction()
2015 xaxis->SetRange(xaxis->FindBin(rmin+offset-oldOffset+binWidth/2),
2016 xaxis->FindBin(rmax+offset-oldOffset-binWidth/2)); // in binNumbers!
2017 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
2018 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
2020 }
2023 Update();
2024}
2025
2026////////////////////////////////////////////////////////////////////////////////
2027/// Slot connected to the OffSetNumberEntry which is related to the
2028/// OffSetSlider changes the origin of the histogram inbetween a binwidth.
2029
2031{
2032 if (fAvoidSignal) return;
2033 TAxis* xaxis = fHist->GetXaxis();
2034 Double_t binWidth = xaxis->GetBinWidth(1);
2036 Double_t oldOffset = 1.*fBinOffsetSld->GetPosition()/100*binWidth;
2037 Int_t nx = xaxis->GetNbins();
2039 if (!player) return;
2040 Int_t first = xaxis->GetFirst();
2041 Int_t last = xaxis->GetLast();
2042 Double_t min = xaxis->GetBinLowEdge(1); // overall min in user coords
2043 Double_t max = xaxis->GetBinUpEdge(nx); // overall max in user coords
2044 Double_t rmin = xaxis->GetBinLowEdge(first); // recent min in user coords
2045 Double_t rmax = xaxis->GetBinUpEdge(last); // recent max in user coords
2046
2047 ((TH1*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
2048 ((TH1*)player->GetHistogram())->Reset();
2049
2050 ((TH1*)player->GetHistogram())->SetBins(nx,
2051 min+offset-oldOffset,
2052 max+offset-oldOffset);
2054 if (!sel) return;
2055 sel->TakeAction();
2056
2057 // Restore all the attributes which were changed by TakeAction()
2059 xaxis->SetRange(xaxis->FindBin(rmin+offset-oldOffset+binWidth/2),
2060 xaxis->FindBin(rmax+offset-oldOffset-binWidth/2)); // in binNumbers!
2061 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
2062 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
2063 fBinOffsetSld->SetPosition((Int_t)(offset/binWidth*100));
2064 Update();
2065}
2066
2067////////////////////////////////////////////////////////////////////////////////
2068/// Slot connected to the Apply button of the Binning tab.
2069
2071{
2072 Int_t ret = 0;
2074 "TH1 Editor", "Replace origin histogram with rebinned one?",
2076 if (ret==1) {
2077 if (fBinHist) {
2078 delete fBinHist;
2079 fBinHist = 0;
2080 }
2081 Int_t nx = fHist->GetXaxis()->GetNbins();
2082 Int_t *div = Dividers(nx);
2083 Int_t up = 0;
2084 if (div[0]-1 <= 1) up = 2;
2085 else up = div[0]-1;
2086 fBinSlider->SetRange(1,up);
2087 if (fBinSlider->GetMaxPosition()==2 && div[0]==2 )
2089 else
2093 Update();
2094 delete [] div;
2095 } else if (ret==2) DoCancel();
2096}
2097
2098////////////////////////////////////////////////////////////////////////////////
2099/// Slot connected to the Cancel button of the Binning tab.
2100
2102{
2103 if (fBinHist) {
2104 fGedEditor->GetPad()->cd();
2105 fHist->Reset();
2108 fBinHist->GetXaxis()->GetXmax());
2109 fHist->Add(fBinHist);
2111 fBinHist->GetXaxis()->GetLast());
2112 delete fBinHist;
2113 fBinHist = 0;
2116 Int_t* divx = Dividers(fHist->GetXaxis()->GetNbins());
2117 if (divx[0]!=2) fBinSlider->SetPosition(1);
2118 // Consigning the new Histogram to all other Editors
2119// fGedEditor->GetPad()->GetCanvas()->Selected(fGedEditor->GetPad(), fHist, 0);
2120 Update();
2121 //fModel = fHist;
2122 Refresh(fHist);
2123 delete [] divx;
2124 }
2125}
2126
2127////////////////////////////////////////////////////////////////////////////////
2128/// Returns the selected histogram type (HIST, LEGO1-2, SURF1-5).
2129
2131{
2132 TString s="";
2133 switch (fTypeCombo->GetSelected()){
2134 case (-1) : {s = "LEGO"; break;}
2135 case (kTYPE_LEGO ): {s = "LEGO"; break;}
2136 case (kTYPE_LEGO1): {s = "LEGO1"; break;}
2137 case (kTYPE_LEGO2): {s = "LEGO2"; break;}
2138 case (kTYPE_SURF ): {s = "SURF"; break;}
2139 case (kTYPE_SURF1): {s = "SURF1"; break;}
2140 case (kTYPE_SURF2): {s = "SURF2"; break;}
2141 case (kTYPE_SURF3): {s = "SURF3"; break;}
2142 case (kTYPE_SURF4): {s = "SURF4"; break;}
2143 case (kTYPE_SURF5): {s = "SURF5"; break;}
2144 default: break;
2145 }
2146
2147 return s;
2148}
2149
2150////////////////////////////////////////////////////////////////////////////////
2151/// Return the selected coordinate system of the histogram (POL,CYL,SPH,PSR).
2152
2154{
2155 TString s="";
2156 if (fDim->GetState()!=kButtonDown) {
2157 switch (fCoordsCombo->GetSelected()){
2158 case (-1) : {s = "POL"; break;}
2159 case (kCOORDS_CAR): {s = ""; break;}
2160 case (kCOORDS_POL): {s = "POL"; break;}
2161 case (kCOORDS_CYL): {s = "CYL"; break;}
2162 case (kCOORDS_SPH): {s = "SPH"; break;}
2163 case (kCOORDS_PSR): {s = "PSR"; break;}
2164 default: break;
2165 }
2166 }
2167
2168 return s;
2169}
2170
2171////////////////////////////////////////////////////////////////////////////////
2172/// Return the selected error type (E,E1-5).
2173
2175{
2176 TString s="";
2177 switch (fErrorCombo->GetSelected()){
2178 case (-1) : {s = ""; break;}
2179 case (kERRORS_NO) : {s = ""; break;}
2180 case (kERRORS_SIMPLE) : {s = "E"; break;}
2181 case (kERRORS_EDGES) : {s = "E1"; break;}
2182 case (kERRORS_REC) : {s = "E2"; break;}
2183 case (kERRORS_FILL) : {s = "E3"; break;}
2184 case (kERRORS_CONTOUR): {s = "E4"; break;}
2185 default: break;
2186 }
2187
2188 return s;
2189}
2190
2191////////////////////////////////////////////////////////////////////////////////
2192/// Return the selected shape of the histogram (C, L, LF2).
2193
2195{
2196 TString s="";
2197 switch (fAddCombo->GetSelected()){
2198 case (-1) : {s = "" ; break;}
2199 case (kADD_NONE) : {s = "" ; break;}
2200 case (kADD_SMOOTH): {s = "C"; break;}
2201 case (kADD_SIMPLE): {s = "L"; break;}
2202 case (kADD_FILL) : {s = "LF2"; break;}
2203 default : break;
2204 }
2205 if (fAddMarker->GetState()==kButtonDown) s += "P";
2206 if (fAddB->GetState()==kButtonDown) s += "B";
2207 if (fAddBar->GetState()==kButtonDown){
2208 if (fMakeHBar->GetState()==kButtonDown) s+="H";
2209 switch (fPercentCombo->GetSelected()){
2210 case (kPER_0) : { s += "BAR" ; break;}
2211 case (kPER_10): { s += "BAR1"; break;}
2212 case (kPER_20): { s += "BAR2"; break;}
2213 case (kPER_30): { s += "BAR3"; break;}
2214 case (kPER_40): { s += "BAR4"; break;}
2215 }
2216 }
2217
2218 return s;
2219}
2220
2221////////////////////////////////////////////////////////////////////////////////
2222/// Create histogram type combo box.
2223
2225{
2226 TGComboBox *c = new TGComboBox(parent, id);
2227
2228 c->AddEntry("Lego" , kTYPE_LEGO);
2229 c->AddEntry("Lego1", kTYPE_LEGO1);
2230 c->AddEntry("Lego2", kTYPE_LEGO2);
2231 c->AddEntry("Surf" , kTYPE_SURF);
2232 c->AddEntry("Surf1", kTYPE_SURF1);
2233 c->AddEntry("Surf2", kTYPE_SURF2);
2234 c->AddEntry("Surf3", kTYPE_SURF3);
2235 c->AddEntry("Surf4", kTYPE_SURF4);
2236 c->AddEntry("Surf5", kTYPE_SURF5);
2237
2238 return c;
2239}
2240
2241////////////////////////////////////////////////////////////////////////////////
2242/// Create coordinate system type combo box.
2243
2245{
2246 TGComboBox *c = new TGComboBox(parent, id);
2247
2248 c->AddEntry("Cartesian", kCOORDS_CAR);
2249 c->AddEntry("Cylindric", kCOORDS_CYL);
2250 c->AddEntry("Polar", kCOORDS_POL);
2251 c->AddEntry("Rapidity", kCOORDS_PSR);
2252 c->AddEntry("Spheric", kCOORDS_SPH);
2253 TGListBox* lb = c->GetListBox();
2254 lb->Resize(lb->GetWidth(), 83);
2255
2256 return c;
2257}
2258
2259////////////////////////////////////////////////////////////////////////////////
2260/// Create error type combo box.
2261
2263{
2264 TGComboBox *c = new TGComboBox(parent, id);
2265
2266 c->AddEntry("No Errors", kERRORS_NO);
2267 c->AddEntry("Simple", kERRORS_SIMPLE);
2268 c->AddEntry("Edges", kERRORS_EDGES);
2269 c->AddEntry("Rectangles",kERRORS_REC);
2270 c->AddEntry("Fill", kERRORS_FILL);
2271 c->AddEntry("Contour", kERRORS_CONTOUR);
2272
2273 return c;
2274}
2275
2276////////////////////////////////////////////////////////////////////////////////
2277/// Create Line/Bar combo box.
2278
2280{
2281 TGComboBox *c = new TGComboBox(parent, id);
2282
2283 c->AddEntry("No Line", kADD_NONE);
2284 c->AddEntry("Simple Line", kADD_SIMPLE);
2285 c->AddEntry("Smooth Line", kADD_SMOOTH);
2286 c->AddEntry("Fill Area",kADD_FILL);
2287 TGListBox* lb = c->GetListBox();
2288 lb->Resize(lb->GetWidth(), 76);
2289 return c;
2290}
2291
2292////////////////////////////////////////////////////////////////////////////////
2293/// Create Percentage combo box for bar option.
2294
2296{
2297 TGComboBox *c = new TGComboBox(parent, id);
2298
2299 c->AddEntry(" 0 %", kPER_0);
2300 c->AddEntry("10 %", kPER_10);
2301 c->AddEntry("20 %", kPER_20);
2302 c->AddEntry("30 %", kPER_30);
2303 c->AddEntry("40 %", kPER_40);
2304 TGListBox* lb = c->GetListBox();
2305 lb->Resize(lb->GetWidth(), 83);
2306
2307 return c;
2308}
2309
2310////////////////////////////////////////////////////////////////////////////////
2311/// Change the error combo box entry.
2312
2314{
2315 switch (i){
2316 case 0: {
2317 if (((TGLBContainer*)((TGListBox*)fErrorCombo->GetListBox())->GetContainer())->GetPos(kERRORS_EDGES)!=-1)
2322 lb->Resize(lb->GetWidth(),36);
2323 break;
2324 }
2325 case 1: {
2326 if (((TGLBContainer*)((TGListBox*)fErrorCombo->GetListBox())->GetContainer())->GetPos(kERRORS_EDGES)==-1) {
2328 fErrorCombo->AddEntry("Rectangles",kERRORS_REC);
2332 lb->Resize(lb->GetWidth(),100);
2333 }
2334 break;
2335 }
2336 }
2337}
2338
2339
2340////////////////////////////////////////////////////////////////////////////////
2341/// Return an array of dividers of n (without the trivial divider n).
2342/// The number of dividers is saved in the first entry.
2343
2345{
2346 Int_t* div;
2347 if (n <= 0) {
2348 div = new Int_t[1];
2349 div[0]=0;
2350 } else if (n == 1) {
2351 div = new Int_t[2];
2352 div[0]=div[1]=1;
2353 } else {
2354 div = new Int_t[(Int_t) n/2+2];
2355 div[0]=0;
2356 div[1]=1;
2357
2358 Int_t num = 1;
2359 for (Int_t i=2; i <= n/2; i++) {
2360 if (n % i == 0) {
2361 num++;
2362 div[num] = i;
2363 }
2364 }
2365 num++;
2366 div[num]=n;
2367 div[0] = num;
2368// for (Int_t a=0; a <= div[0]; a++) printf("div[%d] = %d\n", a , div[a]);
2369 }
2370 return div;
2371}
2372
2373////////////////////////////////////////////////////////////////////////////////
2374/// If the contained histogram obj is deleted we must set its pointer to zero
2375
2377{
2378 if (obj == fHist) {
2379 fHist = 0;
2380 }
2381}
@ kWatch
Definition GuiTypes.h:376
@ kPointer
Definition GuiTypes.h:376
@ kChildFrame
Definition GuiTypes.h:380
@ kVerticalFrame
Definition GuiTypes.h:382
@ kFixedWidth
Definition GuiTypes.h:388
@ kFitWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:383
@ kOwnBackground
Definition GuiTypes.h:392
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
#define d(i)
Definition RSha256.hxx:102
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
@ kButtonDown
Definition TGButton.h:54
@ kButtonDisabled
Definition TGButton.h:56
@ kButtonUp
Definition TGButton.h:53
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
@ kMBNo
Definition TGMsgBox.h:32
@ kMBYes
Definition TGMsgBox.h:31
@ kMBOk
Definition TGMsgBox.h:33
@ kMBIconExclamation
Definition TGMsgBox.h:24
@ kMBIconQuestion
Definition TGMsgBox.h:23
@ kScaleBoth
Definition TGSlider.h:36
@ kSlider1
Definition TGSlider.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t sel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
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
Option_t Option_t TPoint TPoint const char text
@ kMARKER_ONOFF
ETH1Wid
@ kTYPE_SURF2
@ kADD_TYPE
@ kTH1_TITLE
@ kPER_40
@ kPER_10
@ kADD_NONE
@ kERROR_TYPE
@ kTYPE_HIST
@ kERRORS_EDGES
@ kTYPE_SURF5
@ kADD_FILL
@ kSLIDER_MIN
@ kCOORDS_PSR
@ kTYPE_SURF
@ kTYPE_LEGO
@ kERRORS_REC
@ kTYPE_SURF3
@ kMARKER_ONOFF
@ kTYPE_LEGO2
@ kBAR_H
@ kBAR_ONOFF
@ kTYPE_SURF1
@ kCOORDS_CAR
@ kERRORS_NO
@ kADD_SMOOTH
@ kDIM_COMPLEX
@ kBINSLIDER1
@ kCOORDS_POL
@ kTYPE_SURF4
@ kPER_30
@ kCOORD_TYPE
@ kBAR_OFFSET
@ kCOORDS_SPH
@ kCOORDS_CYL
@ kB_ONOFF
@ kSLIDER_MAX
@ kDELAYED_DRAWING
@ kADD_SIMPLE
@ kADD_LINE
@ kBINSLIDER
@ kPERCENT_TYPE
@ kADD_BAR
@ kTYPE_LEGO1
@ kERRORS_CONTOUR
@ kHIST_TYPE
@ kDIM_SIMPLE
@ kPER_0
@ kBINOFFSET
@ kERRORS_FILL
@ kERRORS_SIMPLE
@ kBAR_WIDTH
@ kPER_20
float ymin
float ymax
#define gROOT
Definition TROOT.h:417
#define gPad
#define gVirtualX
Definition TVirtualX.h:391
Line Attributes class.
Definition TAttLine.h:21
virtual void ModifyOn(TVirtualPad &pad)
Change current line attributes on specified pad.
Definition TAttLine.cxx:255
Class to manage histogram axis.
Definition TAxis.h:32
Double_t GetXmax() const
Definition TAxis.h:142
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Definition TAxis.cxx:293
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition TAxis.cxx:529
Int_t GetLast() const
Return last bin on the axis i.e.
Definition TAxis.cxx:480
Double_t GetXmin() const
Definition TAxis.h:141
Int_t GetNbins() const
Definition TAxis.h:127
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
Set the viewing range for the axis from ufirst to ulast (in user coordinates, that is,...
Definition TAxis.cxx:1097
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis using bin numbers.
Definition TAxis.cxx:1068
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
Definition TAxis.cxx:553
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition TAxis.cxx:539
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition TAxis.cxx:469
virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button=nullptr)
Set layout hints for the specified button or if button=0 for all buttons.
virtual void SetRadioButtonExclusive(Bool_t flag=kTRUE)
If enable is kTRUE, this button group will treat radio buttons as mutually exclusive,...
virtual void Show()
Show group of buttons.
virtual void SetButton(Int_t id, Bool_t down=kTRUE)
Sets the button with id to be on/down, and if this is an exclusive group, all other button in the gro...
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:440
virtual EButtonState GetState() const
Definition TGButton.h:112
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:230
Selects different options.
Definition TGButton.h:264
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set check button state.
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:234
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:381
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual Int_t GetSelected() const
Definition TGComboBox.h:114
virtual void AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:86
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
Definition TGComboBox.h:105
virtual void RemoveEntry(Int_t id=-1)
Remove entry. If id == -1, the currently selected entry is removed.
virtual TGListBox * GetListBox() const
Definition TGComboBox.h:110
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
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:1111
TGCompositeFrame(const TGCompositeFrame &)=delete
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1251
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1198
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1037
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1184
Dragging the slider will generate the event:
virtual Float_t GetMaxPosition() const
virtual Float_t GetMinPosition() const
virtual void SetRange(Float_t min, Float_t max)
virtual void SetPosition(Float_t min, Float_t max)
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:599
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
Bool_t Contains(Int_t x, Int_t y) const
Definition TGFrame.h:240
UInt_t GetWidth() const
Definition TGFrame.h:226
Organizes TGButton widgets in a group with one horizontal row.
Concrete class for horizontal slider.
Definition TGSlider.h:119
void Resize(UInt_t w, UInt_t h) override
Resize the frame.
Definition TGSlider.h:138
A horizontal 3D line is a line that typically separates a toolbar from the menubar.
Definition TG3DLine.h:18
A Composite frame that contains a list of TGLBEnties.
Definition TGListBox.h:163
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
A listbox is a box, possibly with scrollbar, containing entries.
Definition TGListBox.h:221
void Resize(UInt_t w, UInt_t h) override
Resize the listbox widget.
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:399
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
Set the numeric value (floating point representation).
virtual Double_t GetNumber() const
Get the numeric value (floating point representation).
virtual void SetIntNumber(Long_t val, Bool_t emit=kTRUE)
Set the numeric value (integer representation).
virtual void SetLimits(ELimit limits=kNELNoLimits, Double_t min=0, Double_t max=1)
Set the numerical limits.
TGNumberEntry is a number entry input widget with up/down buttons.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
virtual Double_t GetNumber() const
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
@ kNEANonNegative
Non-negative number.
@ kNEAAnyNumber
Attributes of number entry field.
@ kNESInteger
Style of number entry field.
@ kNESRealFour
Fixed fraction real, four digit.
@ kNESRealTwo
Fixed fraction real, two digit.
@ kNELLimitMinMax
Both lower and upper limits.
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
Selects different options.
Definition TGButton.h:321
virtual Int_t GetMaxPosition() const
Definition TGSlider.h:79
virtual Int_t GetPosition() const
Definition TGSlider.h:77
virtual void SetPosition(Int_t pos)
Set slider position.
Definition TGSlider.cxx:108
virtual void SetRange(Int_t min, Int_t max)
Set slider range.
Definition TGSlider.cxx:97
virtual void SetScale(Int_t scale)
Definition TGSlider.h:74
virtual void SetEnabled(Int_t tabIndex, Bool_t on=kTRUE)
Enable or disable tab.
Definition TGTab.cxx:467
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line.
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:153
TGTab * GetTab() const
Definition TGedEditor.h:73
virtual TVirtualPad * GetPad() const
Definition TGedEditor.h:78
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
TGedEditor * fGedEditor
manager of this frame
Definition TGedFrame.h:48
virtual TGVerticalFrame * CreateEditorTabSubFrame(const char *name)
Create a vertical frame to be used by 'owner' in extra tab 'name'.
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
void SetDrawOption(Option_t *option="") override
Set drawing option for object.
virtual void Refresh(TObject *model)
Refresh the GUI info about the object attributes.
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:71
Option_t * GetDrawOption() const override
Get draw options of the selected object.
Definition TGedFrame.cxx:79
Bool_t fAvoidSignal
flag for executing slots
Definition TGedFrame.h:50
static TGComboBox * BuildHistAddComboBox(TGFrame *parent, Int_t id)
Create Line/Bar combo box.
TGNumberEntryField * fSldMin
Contains the minimum value of the x-Axis.
Definition TH1Editor.h:78
virtual void DoHistChanges()
Slot connected to the histogram type, the coordinate type, the error type and the Add combo box.
virtual void DoBinReleased1()
Slot connected to the BinNumber Slider in case of a ntuple histogram (does the Rebinning of the histo...
TGTextButton * fApply
Apply-Button to accept the rebinned histogram.
Definition TH1Editor.h:81
TGHSlider * fBinOffsetSld
Add an offset to the origin of the histogram.
Definition TH1Editor.h:75
~TH1Editor() override
Destructor of TH1 editor.
TGNumberEntryField * fBinNumberEntry
Label which shows the rebinned bin number.
Definition TH1Editor.h:73
TGCompositeFrame * fBinCont
Contains the Rebin Widgets for case 1.
Definition TH1Editor.h:69
TGCheckButton * fAddSimple
Draw a simple histogram (==HIST draw option)
Definition TH1Editor.h:55
TH1 * fHist
histogram object
Definition TH1Editor.h:36
TGCheckButton * fAddMarker
Draw a Marker on top of each bin.
Definition TH1Editor.h:50
Bool_t fMakeB
Definition TH1Editor.h:96
TString GetHistTypeLabel()
Returns the selected histogram type (HIST, LEGO1-2, SURF1-5).
virtual void DoOffsetMoved(Int_t num)
Slot connected to the OffSetSlider.
void ChangeErrorCombo(Int_t i)
Change the error combo box entry.
TGNumberEntry * fBarWidth
Change the Bar Width.
Definition TH1Editor.h:56
TGHSlider * fBinSlider1
Slider to set rebinning integer value for ntuple histogram.
Definition TH1Editor.h:72
TGNumberEntryField * fSldMax
Contains the maximum value of the x-Axis.
Definition TH1Editor.h:79
TGDoubleHSlider * fSlider
Slider to set x-axis range.
Definition TH1Editor.h:77
TGCompositeFrame * f11
Contains the Bar Width/Offset NumberEntries.
Definition TH1Editor.h:66
virtual void DoHBar(Bool_t on)
Slot connected to the Horizontal Bar check button.
virtual void DoBinMoved(Int_t number)
Slot connected to the rebin slider in case of a not ntuple histogram (does the Rebinning of the histo...
static TGComboBox * BuildPercentComboBox(TGFrame *parent, Int_t id)
Create Percentage combo box for bar option.
TGHButtonGroup * fDimGroup
Radiobuttongroup to change 2D <-> 3D-Plot.
Definition TH1Editor.h:41
TGCheckButton * fAddB
Draw a Bar Chart.
Definition TH1Editor.h:51
virtual void DoAddMarker(Bool_t on)
Slot connected to the show markers check box.
static TGComboBox * BuildHistErrorComboBox(TGFrame *parent, Int_t id)
Create error type combo box.
Bool_t fMake
Definition TH1Editor.h:95
TH1Editor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of histogram attribute GUI.
TGComboBox * fErrorCombo
Error combo box.
Definition TH1Editor.h:48
Double_t fOldOffset
Definition TH1Editor.h:98
TGCheckButton * fDelaydraw
Delayed drawing of the new axis range.
Definition TH1Editor.h:80
virtual void DoAxisRange()
Slot connected to the number entry fields containing the Max/Min value of the x-axis.
virtual void DoHistView()
Slot connected to the 'Plot' button group.
TGCheckButton * fMakeHBar
Draw Horizontal Bar Chart.
Definition TH1Editor.h:54
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGCompositeFrame * f6
Contains the Add-ComboBox (Style)
Definition TH1Editor.h:61
TGNumberEntryField * fOffsetNumberEntry
Shows the offset to the origin of the histogram.
Definition TH1Editor.h:76
TGCompositeFrame * fBinCont1
Contains the Rebin Widgets for case 2.
Definition TH1Editor.h:70
TGRadioButton * fDim0
3D-Plot RadioButton
Definition TH1Editor.h:43
TGCompositeFrame * f12
Contains fPercentCombo, fMakeHBar.
Definition TH1Editor.h:67
virtual void DoApply()
Slot connected to the Apply button of the Binning tab.
Int_t * Dividers(Int_t n)
Return an array of dividers of n (without the trivial divider n).
TGComboBox * fPercentCombo
Percentage of the Bar which is drawn in a different color.
Definition TH1Editor.h:59
TGTextButton * fCancel
Cancel-Button to reprobate the rebinned histogram.
Definition TH1Editor.h:82
virtual void DoCancel()
Slot connected to the Cancel button of the Binning tab.
TGHSlider * fBinSlider
Slider to set rebinning integer value.
Definition TH1Editor.h:71
TGRadioButton * fDim
2D-Plot RadioButton
Definition TH1Editor.h:42
Int_t fTitlePrec
font precision level
Definition TH1Editor.h:39
TGCheckButton * fAddBar
Bar Option.
Definition TH1Editor.h:52
virtual void DoHistComplex()
Slot connected to the 3D radio button.
virtual void DoSliderReleased()
Slot connected to the x-axis Range slider for finalizing the values of the slider movement.
Bool_t fSameOpt
flag for option "same"
Definition TH1Editor.h:37
virtual void DoAddB(Bool_t)
Slot connected to the bar Add check box.
TGCompositeFrame * f3
Contains Histogram Type.
Definition TH1Editor.h:60
virtual void DoHistSimple()
Slot connected to the 2D radio button.
virtual void DoBinReleased()
Slot connected to the rebin slider in case of a not ntuple histogram Updates some other widgets which...
TGComboBox * fTypeCombo
histogram type combo box
Definition TH1Editor.h:46
TGComboBox * fCoordsCombo
Coordinate System combo box.
Definition TH1Editor.h:47
TGTextEntry * fTitle
histogram title input field
Definition TH1Editor.h:40
TString GetHistAddLabel()
Return the selected shape of the histogram (C, L, LF2).
TGLayoutHints * fDim0lh
layout hints for 3D-Plot RadioButton
Definition TH1Editor.h:45
virtual void DoBinPressed()
Slot connected to the rebin slider in case of a not ntuple histogram.
virtual void DoAddSimple(Bool_t on)
Slot connected to fAddSimple check box for drawing a simple histogram without errors (== HIST draw op...
virtual void DoPercent()
Slot connected to the bar percentage settings.
TH1 * fBinHist
Definition TH1Editor.h:97
virtual void DoBarOffset()
Slot connected to the Bar Offset of the Bar Charts.
void CreateBinTab()
Create binning tab.
virtual void DoBarWidth()
Slot connected to the Bar Width of the Bar Charts.
void SetModel(TObject *obj) override
Pick up current values of histogram attributes.
virtual void DoAddBar(Bool_t)
Slot connected to the bar Add check box.
TGNumberEntryField * fBinNumberEntry1
Label which shows the rebinned bin number for ntuple histogram.
Definition TH1Editor.h:74
TString GetHistErrorLabel()
Return the selected error type (E,E1-5).
virtual void DoBinLabel()
Slot connected to the Bin number entry of the Rebinning tab.
TGLayoutHints * fDimlh
layout hints for 2D-Plot RadioButton
Definition TH1Editor.h:44
TGCompositeFrame * f15
Contains outer line CheckBox.
Definition TH1Editor.h:68
static TGComboBox * BuildHistCoordsComboBox(TGFrame *parent, Int_t id)
Create coordinate system type combo box.
TGNumberEntry * fBarOffset
Change the Bar Offset.
Definition TH1Editor.h:57
TGCompositeFrame * f9
Contains the Bar Option CheckBox.
Definition TH1Editor.h:64
virtual void DoOffsetReleased()
Slot connected to the OffSetSlider.
static TGComboBox * BuildHistTypeComboBox(TGFrame *parent, Int_t id)
Create histogram type combo box.
TGCompositeFrame * f7
Contains the Marker OnOff CheckBox.
Definition TH1Editor.h:62
TGCompositeFrame * f8
Contains the Bar Chart CheckBox.
Definition TH1Editor.h:63
Bool_t AcceptModel(TObject *model) override
Check if object is able to configure with this editor.
TGCompositeFrame * fBin
Contains the Binning Widgets.
Definition TH1Editor.h:38
virtual void DoBinLabel1()
Slot connected to the Bin number entry of the Rebinning tab.
TGComboBox * fAddCombo
Add Lines, Bars, Fill.
Definition TH1Editor.h:58
TGCompositeFrame * f10
Contains the Bar Option Title.
Definition TH1Editor.h:65
virtual void DoSliderMoved()
Slot connected to the x-Slider for redrawing of the histogram according to the new Slider range.
virtual void DoBinOffset()
Slot connected to the OffSetNumberEntry which is related to the OffSetSlider changes the origin of th...
virtual void DoOffsetPressed()
Slot connected to the OffSetSlider that saves the OldBinOffset (nessesary for delay draw mode).
virtual void DoTitle(const char *text)
Slot connected to the histogram title setting.
TString GetHistCoordsLabel()
Return the selected coordinate system of the histogram (POL,CYL,SPH,PSR).
void RecursiveRemove(TObject *obj) override
If the contained histogram obj is deleted we must set its pointer to zero.
virtual void DoBinMoved1()
Slot connected to the rebin slider in case of an ntuple histogram.
virtual void DoSliderPressed()
Slot connected to the x-axis Range slider for initialising the values of the slider movement.
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:126
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
Definition TH1.cxx:9170
virtual void SetBarOffset(Float_t offset=0.25)
Set the bar offset as fraction of the bin width for drawing mode "B".
Definition TH1.h:642
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6932
virtual Float_t GetBarWidth() const
Definition TH1.h:531
virtual Float_t GetBarOffset() const
Definition TH1.h:530
static TClass * Class()
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
Definition TH1.cxx:7324
TAxis * GetXaxis()
Definition TH1.h:601
virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="")
Performs the operation: this = this + c1*f1 if errors are defined (see TH1::Sumw2),...
Definition TH1.cxx:852
virtual Double_t GetEntries() const
Return the current number of entries.
Definition TH1.cxx:4574
virtual TH1 * Rebin(Int_t ngroup=2, const char *newname="", const Double_t *xbins=nullptr)
Rebin this histogram.
Definition TH1.cxx:6486
virtual UInt_t SetCanExtend(UInt_t extendBitMask)
Make the histogram axes extendable / not extendable according to the bit mask returns the previous bi...
Definition TH1.cxx:6860
@ kNoAxis
NOTE: Must always be 0 !!!
Definition TH1.h:139
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
Definition TH1.cxx:2882
virtual void SetBins(Int_t nx, Double_t xmin, Double_t xmax)
Redefine x axis parameters.
Definition TH1.cxx:9000
virtual void SetBarWidth(Float_t width=0.5)
Set the width of bars as fraction of the bin width for drawing mode "B".
Definition TH1.h:643
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
Mother of all ROOT objects.
Definition TObject.h:42
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:548
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
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
Disconnects signal of this object from slot of receiver.
A specialized TSelector for TTree::Draw.
Basic string class.
Definition TString.h:137
const char * Data() const
Definition TString.h:385
TString & Remove(Ssiz_t pos)
Definition TString.h:695
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:642
Implement some of the functionality of the class TTree requiring access to extra libraries (Histogram...
Definition TTreePlayer.h:37
TH1 * GetHistogram() const override
Definition TTreePlayer.h:75
Int_t GetNfill() const override
Definition TTreePlayer.h:78
TSelector * GetSelector() const override
Definition TTreePlayer.h:82
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
static TVirtualTreePlayer * GetCurrentPlayer()
Static function: return the current player (if any)
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
leg AddEntry(h1,"Histogram filled with random numbers","f")
const Int_t n
Definition legend1.C:16