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));
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:");
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
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
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
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
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
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");
434 f26->AddFrame(fOffsetNumberEntry,
435 new TGLayoutHints(kLHintsRight, 21, 0, 0, 0));
436 fBinCont1->AddFrame(f26, new TGLayoutHints(kLHintsTop, 0, 7, 3, 1));
437
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
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
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);
467 f14->AddFrame(fSlider, new TGLayoutHints(kLHintsLeft));
468 sldCont->AddFrame(f14, new TGLayoutHints(kLHintsTop, 3, 7, 4, 1));
469
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));
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
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));
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
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);
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
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);
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);
789 if (dum.Contains("E")) fErrorCombo->Select(kERRORS_SIMPLE);
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;
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);
870 }
871
872 fSlider->SetRange(1,nx);
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")) {
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);
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 fGedEditor->GetPad()->FeedbackMode(kTRUE);
1483 fGedEditor->GetPad()->cd();
1485 static Int_t px1,py1,px2,py2;
1486 static Float_t ymin,ymax,xleft,xright;
1489 ymin = fGedEditor->GetPad()->GetUymin();
1490 ymax = fGedEditor->GetPad()->GetUymax();
1491 px1 = fGedEditor->GetPad()->XtoAbsPixel(xleft);
1492 py1 = fGedEditor->GetPad()->YtoAbsPixel(ymin);
1493 px2 = fGedEditor->GetPad()->XtoAbsPixel(xright);
1494 py2 = fGedEditor->GetPad()->YtoAbsPixel(ymax);
1495 fGedEditor->GetPad()->FeedbackMode(kTRUE);
1496 fGedEditor->GetPad()->SetLineWidth(1);
1497 fGedEditor->GetPad()->SetLineColor(2);
1498 fGedEditor->GetPad()->SetLineWidth(1);
1499 fGedEditor->GetPad()->SetLineColor(2);
1500 fGedEditor->GetPad()->cd();
1502 gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
1503 fPx1old = px1;
1504 fPy1old = py1;
1505 fPx2old = px2 ;
1506 fPy2old = py2;
1507 gVirtualX->Update(0);
1510 } else if (fDelaydraw->GetState() == kButtonDown &&
1511 fDim0->GetState() == kButtonDown &&
1513 static Float_t p1[3], p2[3], p3[3], p4[3], p5[3], p6[3], p7[3], p8[3];
1514 TView *fView = fGedEditor->GetPad()->GetView();
1515 if (!fView) return;
1516 Double_t *rmin = fView->GetRmin();
1517 if (!rmin) return;
1518 Double_t *rmax = fView->GetRmax();
1519 if (!rmax) return;
1520 p1[0] = p4[0] = p5[0] = p8[0] =
1522 p2[0] = p3[0] = p6[0] = p7[0] =
1524 p1[1] = p2[1] = p3[1] = p4[1] = rmin[1];
1525 p5[1] = p6[1] = p7[1] = p8[1] = rmax[1];
1526 p1[2] = p2[2] = p5[2] = p6[2] = rmin[2];
1527 p3[2] = p4[2] = p7[2] = p8[2] = rmax[2];
1528 fGedEditor->GetPad()->SetLineWidth(1);
1529 fGedEditor->GetPad()->SetLineColor(2);
1532 PaintBox3D(p2, p3, p7, p6);
1533 PaintBox3D(p1, p4, p8, p5);
1534 for (Int_t i = 0; i<3; i++){
1535 fP1old[i] = p1[i];
1536 fP2old[i] = p2[i];
1537 fP3old[i] = p3[i];
1538 fP4old[i] = p4[i];
1539 fP5old[i] = p5[i];
1540 fP6old[i] = p6[i];
1541 fP7old[i] = p7[i];
1542 fP8old[i] = p8[i];
1543 }
1544 fSldMin->SetNumber(p1[0]);
1545 fSldMax->SetNumber(p2[0]);
1546 } else if (fDelaydraw->GetState() == kButtonDown &&
1547 fDim0->GetState() == kButtonDown) {
1550 } else {
1552 (Int_t)((fSlider->GetMaxPosition())+0.5));
1556 Update();
1557 }
1559 if (player && player->GetHistogram() == fHist) {
1560 Int_t last = fHist->GetXaxis()->GetLast();
1561 Int_t first = fHist->GetXaxis()->GetFirst();
1562 fBinNumberEntry1->SetIntNumber(last-first+1);
1563 // How to redraw the NumberEntry without calling Update??
1564 // Update kills the "virtual" painted box in Delayed draw mode
1566 // fGedEditor->GetTab()->Layout();
1567 }
1570}
1571
1572////////////////////////////////////////////////////////////////////////////////
1573/// Slot connected to the x-axis Range slider for initialising the
1574/// values of the slider movement.
1575
1577{
1578 if (fAvoidSignal) return;
1579 fGedEditor->GetPad()->FeedbackMode(kTRUE);
1580 fGedEditor->GetPad()->cd();
1581 static Float_t ymin,ymax,xleft,xright;
1582 Int_t sldmin = (Int_t)((fSlider->GetMinPosition())+0.5);
1583 Int_t sldmax = (Int_t)((fSlider->GetMaxPosition())+0.5);
1584 if (fDelaydraw->GetState() == kButtonDown &&
1586 fGedEditor->GetPad()->FeedbackMode(kTRUE);
1587 fGedEditor->GetPad()->SetLineWidth(1);
1588 fGedEditor->GetPad()->SetLineColor(2);
1591 ymin = fGedEditor->GetPad()->GetUymin();
1592 ymax = fGedEditor->GetPad()->GetUymax();
1593 fPx1old = fGedEditor->GetPad()->XtoAbsPixel(xleft);
1594 fPy1old = fGedEditor->GetPad()->YtoAbsPixel(ymin);
1595 fPx2old = fGedEditor->GetPad()->XtoAbsPixel(xright);
1596 fPy2old = fGedEditor->GetPad()->YtoAbsPixel(ymax);
1598 } else if (fDelaydraw->GetState() == kButtonDown &&
1599 fDim0->GetState() == kButtonDown &&
1601 TView *fView = fGedEditor->GetPad()->GetView();
1602 if (!fView) return;
1603 Double_t *rmin = fView->GetRmin();
1604 if (!rmin) return;
1605 Double_t *rmax = fView->GetRmax();
1606 if (!rmax) return;
1607 fP1old[0] = fP4old[0] = fP5old[0] = fP8old[0] =
1609 fP2old[0] = fP3old[0] = fP6old[0] = fP7old[0] =
1611 fP1old[1] = fP2old[1] = fP3old[1] = fP4old[1] = rmin[1];
1612 fP5old[1] = fP6old[1] = fP7old[1] = fP8old[1] = rmax[1];
1613 fP1old[2] = fP2old[2] = fP5old[2] = fP6old[2] = rmin[2];
1614 fP3old[2] = fP4old[2] = fP7old[2] = fP8old[2] = rmax[2];
1615 fGedEditor->GetPad()->FeedbackMode(kTRUE);
1616 fGedEditor->GetPad()->SetLineWidth(1);
1617 fGedEditor->GetPad()->SetLineColor(2);
1620 }
1621 Update();
1622}
1623
1624////////////////////////////////////////////////////////////////////////////////
1625/// Slot connected to the x-axis Range slider for finalizing the
1626/// values of the slider movement.
1627
1629{
1630 if (fAvoidSignal) return;
1633 (Int_t)((fSlider->GetMaxPosition())+0.5));
1636 Update();
1637 }
1639 if (player) if (player->GetHistogram() == fHist) {
1640 Int_t last = fHist->GetXaxis()->GetLast();
1641 Int_t first = fHist->GetXaxis()->GetFirst();
1642 fBinNumberEntry1->SetIntNumber(last-first+1);
1643 Update();
1644 }
1645}
1646
1647////////////////////////////////////////////////////////////////////////////////
1648/// Slot connected to the number entry fields containing the Max/Min
1649/// value of the x-axis.
1650
1652{
1653 if (fAvoidSignal) return;
1654 Int_t nx = fHist->GetXaxis()->GetNbins();
1658 if ((fSldMin->GetNumber()+width/2) < (lowLimit))
1660 if ((fSldMax->GetNumber()-width/2) > (upLimit))
1662// Set the histogram range and the axis range slider
1664 fSldMax->GetNumber()-width/2);
1668 Update();
1669}
1670
1671////////////////////////////////////////////////////////////////////////////////
1672/// Slot connected to the rebin slider in case of a not ntuple histogram
1673/// Updates some other widgets which are related to the rebin slider.
1674
1676{
1677 // draw the rebinned histogram in case of delay draw mode
1678 if (fAvoidSignal) return;
1680 if (!fBinHist) {
1681 fBinHist = (TH1*)fHist->Clone("BinHist");
1682 // we will manage this histogram
1684 }
1687 Int_t* divx = Dividers(nx);
1688 if (divx[0]==2) fBinSlider->SetPosition(2);
1689 if (divx[0]==2) {
1690 delete [] divx;
1691 return;
1692 }
1693 // delete the histogram which is on the screen
1694 fGedEditor->GetPad()->cd();
1695 fHist->Reset();
1697 fBinHist->GetXaxis()->GetXmax());
1698 fHist->Add(fBinHist);
1700 fHist->Rebin(divx[numx]);
1701 // fModel=fHist;
1702 if (divx[0]!=2) {
1703 TAxis* xaxis = fHist->GetXaxis();
1704 Double_t xBinWidth = xaxis->GetBinWidth(1);
1705 xaxis->SetRangeUser(fSldMin->GetNumber()+xBinWidth/2,
1709 xaxis->FindBin(fSldMax->GetNumber()-xBinWidth/2));
1710 // the x-axis range could be changed a little bit by Rebin algorithm
1711 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
1712 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
1713 }
1718 Update();
1719 delete [] divx;
1720 }
1721// fGedEditor->GetPad()->GetCanvas()->Selected(fGedEditor->GetPad(), fHist, 0);
1722 // fModel = fHist;
1723 Refresh(fHist);
1724}
1725
1726////////////////////////////////////////////////////////////////////////////////
1727/// Slot connected to the rebin slider in case of a not ntuple histogram
1728/// (does the Rebinning of the histogram).
1729
1731{
1732 // create a clone in the background, when the slider is moved for
1733 // the first time
1734 if (fAvoidSignal) return;
1735 if (!fBinHist /*&& fDelaydraw->GetState()!=kButtonDown*/) {
1737 if (divx[0]==2) {
1738 delete [] divx;
1739 return;
1740 }
1741 fBinHist = (TH1*)fHist->Clone("BinHist");
1742 // the TH1Editor class manage this histogram
1744 delete [] divx;
1745 }
1746 // if the slider already has been moved and the clone is saved
1748 Int_t* divx = Dividers(nx);
1749 if (divx[0]==2) {
1751 delete [] divx;
1752 return;
1753 }
1754 Int_t maxx = (Int_t)nx/divx[numx];
1755 if (maxx==1) maxx=2;
1756 if (fDelaydraw->GetState() == kButtonUp) {
1757 fGedEditor->GetPad()->cd();
1758 fHist->Reset();
1760 fBinHist->GetXaxis()->GetXmax());
1761 fHist->Add(fBinHist);
1763 fHist->Rebin(divx[numx]);
1764 //fModel=fHist;
1765 TAxis* xaxis = fHist->GetXaxis();
1766 Double_t xBinWidth = xaxis->GetBinWidth(1);
1767 xaxis->SetRangeUser(fSldMin->GetNumber()+xBinWidth/2,
1769 fSlider->SetRange(1,maxx);
1771 xaxis->FindBin(fSldMax->GetNumber()-xBinWidth/2));
1772 // the axis range could be changed a little bit by the Rebin algorithm
1773 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
1774 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
1776 Update();
1777 }
1784 delete [] divx;
1785}
1786
1787////////////////////////////////////////////////////////////////////////////////
1788/// Slot connected to the rebin slider in case of a not ntuple histogram.
1789
1791{
1792 if (fAvoidSignal) return;
1794 if (d[0]==2 && !fBinHist) {
1795 new TGMsgBox(fClient->GetDefaultRoot(), this->GetMainFrame(),
1796 "TH1 Editor", "It is not possible to rebin the histogram",
1798 gVirtualX->GrabPointer(fBinSlider->GetId(),0,0,0);
1799 }
1800 delete [] d;
1801 // calling the MessageBox again does NOT work!*/
1802}
1803
1804////////////////////////////////////////////////////////////////////////////////
1805/// Slot connected to the BinNumber Slider in case of a ntuple histogram
1806/// (does the Rebinning of the histogram).
1807
1809{
1810 if (fAvoidSignal) return;
1812 Int_t number = fBinSlider1->GetPosition();
1813 if (number==5) return;
1814 Int_t fact = 0;
1815 Int_t binNumber = 0;
1816 TAxis* xaxis = fHist->GetXaxis();
1817 // "compute" the scaling factor:
1818 if (number > 5) fact = number - 4;
1819 else fact = number - 6;
1821 if (!player) return;
1822 Int_t first = xaxis->GetFirst();
1823 Int_t last = xaxis->GetLast();
1824 Int_t nx = xaxis->GetNbins();
1825 Double_t min = xaxis->GetBinLowEdge(1); // overall min in user coords
1826 Double_t max = xaxis->GetBinUpEdge(nx); // overall max in user coords
1827 Double_t rmin = xaxis->GetBinLowEdge(first); // recent min in user coords
1828 Double_t rmax = xaxis->GetBinUpEdge(last); // recent max in user coords
1829
1830 ((TH1*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
1831 ((TH1*)player->GetHistogram())->Reset();
1832
1833 // get new Number of bins
1834 if (fact > 0) binNumber = fact*nx;
1835 if (fact < 0) binNumber = (Int_t) ((-1)*nx/fact+0.5);
1836 if (binNumber < 1) binNumber = 1;
1837 if (binNumber > 10000) binNumber= 10000;
1838 Double_t newOffset = 1.*fBinOffsetSld->GetPosition()/100*((max-min)/binNumber);
1839 // create new histogram - the main job is done by sel->TakeAction()
1840 ((TH1*)player->GetHistogram())->SetBins(binNumber,
1841 min-oldOffset+newOffset,
1842 max-oldOffset+newOffset);
1843 TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
1844 if (!sel) return;
1845 sel->TakeAction();
1846
1847 // restore and set all the attributes which were changed by TakeAction()
1849 fSlider->SetRange(1,binNumber);
1850 Double_t binWidth = fHist->GetXaxis()->GetBinWidth(1);
1851 fSlider->SetPosition(xaxis->FindBin(rmin), xaxis->FindBin(rmax));
1852 Double_t offset = 1.*fBinOffsetSld->GetPosition()/100*binWidth;
1853 xaxis->SetRange(xaxis->FindBin(rmin+binWidth/2),
1854 xaxis->FindBin(rmax-binWidth/2)); // SetRange in binNumbers!
1855 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
1856 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
1857 fBinNumberEntry1->SetNumber(xaxis->GetLast() - xaxis->GetFirst() + 1);
1861 xaxis->GetBinWidth(1));
1863 Update();
1864}
1865
1866////////////////////////////////////////////////////////////////////////////////
1867/// Slot connected to the rebin slider in case of an ntuple histogram.
1868/// It updates the BinNumberEntryField during the BinSlider movement.
1869
1871{
1872 if (fAvoidSignal) return;
1873 TAxis* xaxis = fHist->GetXaxis();
1874 Int_t first = xaxis->GetFirst();
1875 Int_t last = xaxis->GetLast();
1876 Int_t number = fBinSlider1->GetPosition();
1877 Int_t n = last -first+1;
1878 Int_t fact = 0;
1879 Int_t binNumber = 0;
1880 if (number >= 5) fact = number - 4;
1881 else fact = number - 6;
1882 if (fact > 0) binNumber = fact*n;
1883 if (fact < 0) binNumber = (Int_t) ((-1)*n/fact+0.5);
1884 if (binNumber < 1) binNumber = 1;
1885 if (binNumber > 10000) binNumber= 10000;
1886 fBinNumberEntry1->SetIntNumber(binNumber);
1887// Update();
1888}
1889
1890////////////////////////////////////////////////////////////////////////////////
1891/// Slot connected to the Bin number entry of the Rebinning tab.
1892
1894{
1895 if (fAvoidSignal) return;
1897 Int_t nx = 0;
1898 if (fBinHist) nx = fBinHist->GetXaxis()->GetNbins();
1899 else nx = fHist->GetXaxis()->GetNbins();
1900 if (nx < 2) return;
1901 Int_t *div = Dividers(nx);
1902 Int_t diff = std::abs(num - div[1]);
1903 Int_t c = 1;
1904 for (Int_t i = 2; i <= div[0]; i++) {
1905 if ((std::abs(num - div[i])) < diff) {
1906 c = i;
1907 diff = std::abs(num - div[i]);
1908 }
1909 }
1911 fBinSlider->SetPosition(div[0] - c +1);
1912 if (fDelaydraw->GetState()==kButtonUp) DoBinMoved(div[0] - c +1);
1913 else DoBinReleased();
1914// fGedEditor->GetPad()->GetCanvas()->Selected(fGedEditor->GetPad(), fHist, 0);
1915 // fModel = fHist;
1916 Refresh(fHist);
1917 delete [] div;
1918}
1919
1920////////////////////////////////////////////////////////////////////////////////
1921/// Slot connected to the Bin number entry of the Rebinning tab.
1922
1924{
1925 if (fAvoidSignal) return;
1928 TAxis* xaxis = fHist->GetXaxis();
1930 if (!player) return;
1931 Int_t first = xaxis->GetFirst();
1932 Int_t last = xaxis->GetLast();
1933 Int_t nx = xaxis->GetNbins();
1934 Double_t min = xaxis->GetBinLowEdge(1); // overall min in user coords
1935 Double_t max = xaxis->GetBinUpEdge(nx); // overall max in user coords
1936 Double_t rmin = xaxis->GetBinLowEdge(first); // recent min in user coords
1937 Double_t rmax = xaxis->GetBinUpEdge(last); // recent max in user coords
1938
1939 ((TH1*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
1940 ((TH1*)player->GetHistogram())->Reset();
1941
1942// Calculate the new number of bins in the complete range
1943 Int_t binNumber = (Int_t) ((max-min)/(rmax - rmin)*num + 0.5);
1944 if (binNumber < 1) binNumber = 1;
1945 if (binNumber > 10000) binNumber = 10000;
1946 Double_t offset = 1.*(fBinOffsetSld->GetPosition())/100*(max-min)/binNumber;
1947// create new histogram - the main job is done by sel->TakeAction()
1948 ((TH1*)player->GetHistogram())->SetBins(binNumber,
1949 min-oldOffset+offset,
1950 max-oldOffset+offset);
1951 TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
1952 if (!sel) return;
1953 sel->TakeAction();
1954
1955// Restore and set all the attributes which were changed by TakeAction()
1957 fSlider->SetRange(1,binNumber);
1958 Double_t binWidth = xaxis->GetBinWidth(1);
1959 fSlider->SetPosition(xaxis->FindBin(rmin), xaxis->FindBin(rmax));
1960 offset = 1.*fBinOffsetSld->GetPosition()/100*binWidth;
1961 xaxis->SetRange(xaxis->FindBin(rmin+binWidth/2),
1962 xaxis->FindBin(rmax-binWidth/2)); // SetRange in binNumbers!
1963 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
1964 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
1967 Update();
1968}
1969
1970////////////////////////////////////////////////////////////////////////////////
1971/// Slot connected to the OffSetSlider that saves the OldBinOffset
1972/// (nessesary for delay draw mode).
1973
1979
1980////////////////////////////////////////////////////////////////////////////////
1981/// Slot connected to the OffSetSlider.
1982/// It changes the origin of the histogram inbetween a binwidth and
1983/// rebin the histogram with the new Offset given by the Slider.
1984
1986{
1987 // !!problem: histogram with variable binwidth??
1988 // computes the new histogram in "delay draw" mode
1989
1990 if (fAvoidSignal) return;
1993 TAxis* xaxis = fHist->GetXaxis();
1994 Double_t binWidth = xaxis->GetBinWidth(1);
1995 Double_t offset = 1.*num/100*binWidth;
1997 Int_t nx = xaxis->GetNbins();
1999 if (!player) return;
2000 Int_t first = xaxis->GetFirst();
2001 Int_t last = xaxis->GetLast();
2002 Double_t min = xaxis->GetBinLowEdge(1); // overall min in user coords
2003 Double_t max = xaxis->GetBinUpEdge(nx); // overall max in user coords
2004 Double_t rmin = xaxis->GetBinLowEdge(first); // recent min in user coords
2005 Double_t rmax = xaxis->GetBinUpEdge(last); // recent max in user coords
2006
2007 ((TH1*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
2008 ((TH1*)player->GetHistogram())->Reset();
2009
2010 ((TH1*)player->GetHistogram())->SetBins(nx,
2011 min+offset-oldOffset,
2012 max+offset-oldOffset);
2013 TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
2014 if (!sel) return;
2015 sel->TakeAction();
2016
2017 // Restore all the attributes which were changed by TakeAction()
2019 xaxis->SetRange(xaxis->FindBin(rmin+offset-oldOffset+binWidth/2),
2020 xaxis->FindBin(rmax+offset-oldOffset-binWidth/2)); // in binNumbers!
2021 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
2022 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
2024 Update();
2025 }
2026}
2027
2028////////////////////////////////////////////////////////////////////////////////
2029/// Slot connected to the OffSetSlider.
2030/// It changes the origin of the histogram inbetween a binwidth and
2031/// rebin the histogram with the new offset given by the Slider.
2032
2034{
2035 // !!histogram with variable binwidth??
2036 // !!only works for histograms with fixed binwidth
2037
2038 if (fAvoidSignal) return;
2039 TAxis* xaxis = fHist->GetXaxis();
2040 Double_t binWidth = xaxis->GetBinWidth(1);
2041 Double_t offset = 1.*num/100*binWidth;
2042 if (fDelaydraw->GetState()==kButtonUp) {
2044 Int_t nx = xaxis->GetNbins();
2046 if (!player) return;
2047 Int_t first = xaxis->GetFirst();
2048 Int_t last = xaxis->GetLast();
2049 Double_t min = xaxis->GetBinLowEdge(1); // overall min in user coords
2050 Double_t max = xaxis->GetBinUpEdge(nx); // overall max in user coords
2051 Double_t rmin = xaxis->GetBinLowEdge(first); // recent min in user coords
2052 Double_t rmax = xaxis->GetBinUpEdge(last); // recent max in user coords
2053
2054 ((TH1*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
2055 ((TH1*)player->GetHistogram())->Reset();
2056
2057 ((TH1*)player->GetHistogram())->SetBins(nx,
2058 min+offset-oldOffset,
2059 max+offset-oldOffset);
2060 TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
2061 if (!sel) return;
2062 sel->TakeAction();
2063
2064 // Restore all the attributes which were changed by TakeAction()
2066 xaxis->SetRange(xaxis->FindBin(rmin+offset-oldOffset+binWidth/2),
2067 xaxis->FindBin(rmax+offset-oldOffset-binWidth/2)); // in binNumbers!
2068 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
2069 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
2071 }
2074 Update();
2075}
2076
2077////////////////////////////////////////////////////////////////////////////////
2078/// Slot connected to the OffSetNumberEntry which is related to the
2079/// OffSetSlider changes the origin of the histogram inbetween a binwidth.
2080
2082{
2083 if (fAvoidSignal) return;
2084 TAxis* xaxis = fHist->GetXaxis();
2085 Double_t binWidth = xaxis->GetBinWidth(1);
2087 Double_t oldOffset = 1.*fBinOffsetSld->GetPosition()/100*binWidth;
2088 Int_t nx = xaxis->GetNbins();
2090 if (!player) return;
2091 Int_t first = xaxis->GetFirst();
2092 Int_t last = xaxis->GetLast();
2093 Double_t min = xaxis->GetBinLowEdge(1); // overall min in user coords
2094 Double_t max = xaxis->GetBinUpEdge(nx); // overall max in user coords
2095 Double_t rmin = xaxis->GetBinLowEdge(first); // recent min in user coords
2096 Double_t rmax = xaxis->GetBinUpEdge(last); // recent max in user coords
2097
2098 ((TH1*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
2099 ((TH1*)player->GetHistogram())->Reset();
2100
2101 ((TH1*)player->GetHistogram())->SetBins(nx,
2102 min+offset-oldOffset,
2103 max+offset-oldOffset);
2104 TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
2105 if (!sel) return;
2106 sel->TakeAction();
2107
2108 // Restore all the attributes which were changed by TakeAction()
2110 xaxis->SetRange(xaxis->FindBin(rmin+offset-oldOffset+binWidth/2),
2111 xaxis->FindBin(rmax+offset-oldOffset-binWidth/2)); // in binNumbers!
2112 fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
2113 fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
2114 fBinOffsetSld->SetPosition((Int_t)(offset/binWidth*100));
2115 Update();
2116}
2117
2118////////////////////////////////////////////////////////////////////////////////
2119/// Slot connected to the Apply button of the Binning tab.
2120
2122{
2123 Int_t ret = 0;
2124 new TGMsgBox(fClient->GetDefaultRoot(), this->GetMainFrame(),
2125 "TH1 Editor", "Replace origin histogram with rebinned one?",
2127 if (ret==1) {
2128 if (fBinHist) {
2129 delete fBinHist;
2130 fBinHist = 0;
2131 }
2132 Int_t nx = fHist->GetXaxis()->GetNbins();
2133 Int_t *div = Dividers(nx);
2134 Int_t up = 0;
2135 if (div[0]-1 <= 1) up = 2;
2136 else up = div[0]-1;
2138 if (fBinSlider->GetMaxPosition()==2 && div[0]==2 )
2140 else
2144 Update();
2145 delete [] div;
2146 } else if (ret==2) DoCancel();
2147}
2148
2149////////////////////////////////////////////////////////////////////////////////
2150/// Slot connected to the Cancel button of the Binning tab.
2151
2153{
2154 if (fBinHist) {
2155 fGedEditor->GetPad()->cd();
2156 fHist->Reset();
2159 fBinHist->GetXaxis()->GetXmax());
2160 fHist->Add(fBinHist);
2162 fBinHist->GetXaxis()->GetLast());
2163 delete fBinHist;
2164 fBinHist = 0;
2168 if (divx[0]!=2) fBinSlider->SetPosition(1);
2169 // Consigning the new Histogram to all other Editors
2170// fGedEditor->GetPad()->GetCanvas()->Selected(fGedEditor->GetPad(), fHist, 0);
2171 Update();
2172 //fModel = fHist;
2173 Refresh(fHist);
2174 delete [] divx;
2175 }
2176}
2177
2178////////////////////////////////////////////////////////////////////////////////
2179/// Returns the selected histogram type (HIST, LEGO1-2, SURF1-5).
2180
2182{
2183 TString s="";
2184 switch (fTypeCombo->GetSelected()){
2185 case (-1) : {s = "LEGO"; break;}
2186 case (kTYPE_LEGO ): {s = "LEGO"; break;}
2187 case (kTYPE_LEGO1): {s = "LEGO1"; break;}
2188 case (kTYPE_LEGO2): {s = "LEGO2"; break;}
2189 case (kTYPE_SURF ): {s = "SURF"; break;}
2190 case (kTYPE_SURF1): {s = "SURF1"; break;}
2191 case (kTYPE_SURF2): {s = "SURF2"; break;}
2192 case (kTYPE_SURF3): {s = "SURF3"; break;}
2193 case (kTYPE_SURF4): {s = "SURF4"; break;}
2194 case (kTYPE_SURF5): {s = "SURF5"; break;}
2195 default: break;
2196 }
2197
2198 return s;
2199}
2200
2201////////////////////////////////////////////////////////////////////////////////
2202/// Return the selected coordinate system of the histogram (POL,CYL,SPH,PSR).
2203
2205{
2206 TString s="";
2207 if (fDim->GetState()!=kButtonDown) {
2208 switch (fCoordsCombo->GetSelected()){
2209 case (-1) : {s = "POL"; break;}
2210 case (kCOORDS_CAR): {s = ""; break;}
2211 case (kCOORDS_POL): {s = "POL"; break;}
2212 case (kCOORDS_CYL): {s = "CYL"; break;}
2213 case (kCOORDS_SPH): {s = "SPH"; break;}
2214 case (kCOORDS_PSR): {s = "PSR"; break;}
2215 default: break;
2216 }
2217 }
2218
2219 return s;
2220}
2221
2222////////////////////////////////////////////////////////////////////////////////
2223/// Return the selected error type (E,E1-5).
2224
2226{
2227 TString s="";
2228 switch (fErrorCombo->GetSelected()){
2229 case (-1) : {s = ""; break;}
2230 case (kERRORS_NO) : {s = ""; break;}
2231 case (kERRORS_SIMPLE) : {s = "E"; break;}
2232 case (kERRORS_EDGES) : {s = "E1"; break;}
2233 case (kERRORS_REC) : {s = "E2"; break;}
2234 case (kERRORS_FILL) : {s = "E3"; break;}
2235 case (kERRORS_CONTOUR): {s = "E4"; break;}
2236 default: break;
2237 }
2238
2239 return s;
2240}
2241
2242////////////////////////////////////////////////////////////////////////////////
2243/// Return the selected shape of the histogram (C, L, LF2).
2244
2246{
2247 TString s="";
2248 switch (fAddCombo->GetSelected()){
2249 case (-1) : {s = "" ; break;}
2250 case (kADD_NONE) : {s = "" ; break;}
2251 case (kADD_SMOOTH): {s = "C"; break;}
2252 case (kADD_SIMPLE): {s = "L"; break;}
2253 case (kADD_FILL) : {s = "LF2"; break;}
2254 default : break;
2255 }
2256 if (fAddMarker->GetState()==kButtonDown) s += "P";
2257 if (fAddB->GetState()==kButtonDown) s += "B";
2258 if (fAddBar->GetState()==kButtonDown){
2259 if (fMakeHBar->GetState()==kButtonDown) s+="H";
2260 switch (fPercentCombo->GetSelected()){
2261 case (kPER_0) : { s += "BAR" ; break;}
2262 case (kPER_10): { s += "BAR1"; break;}
2263 case (kPER_20): { s += "BAR2"; break;}
2264 case (kPER_30): { s += "BAR3"; break;}
2265 case (kPER_40): { s += "BAR4"; break;}
2266 }
2267 }
2268
2269 return s;
2270}
2271
2272////////////////////////////////////////////////////////////////////////////////
2273/// Create histogram type combo box.
2274
2276{
2277 TGComboBox *c = new TGComboBox(parent, id);
2278
2279 c->AddEntry("Lego" , kTYPE_LEGO);
2280 c->AddEntry("Lego1", kTYPE_LEGO1);
2281 c->AddEntry("Lego2", kTYPE_LEGO2);
2282 c->AddEntry("Surf" , kTYPE_SURF);
2283 c->AddEntry("Surf1", kTYPE_SURF1);
2284 c->AddEntry("Surf2", kTYPE_SURF2);
2285 c->AddEntry("Surf3", kTYPE_SURF3);
2286 c->AddEntry("Surf4", kTYPE_SURF4);
2287 c->AddEntry("Surf5", kTYPE_SURF5);
2288
2289 return c;
2290}
2291
2292////////////////////////////////////////////////////////////////////////////////
2293/// Create coordinate system type combo box.
2294
2296{
2297 TGComboBox *c = new TGComboBox(parent, id);
2298
2299 c->AddEntry("Cartesian", kCOORDS_CAR);
2300 c->AddEntry("Cylindric", kCOORDS_CYL);
2301 c->AddEntry("Polar", kCOORDS_POL);
2302 c->AddEntry("Rapidity", kCOORDS_PSR);
2303 c->AddEntry("Spheric", kCOORDS_SPH);
2304 TGListBox* lb = c->GetListBox();
2305 lb->Resize(lb->GetWidth(), 83);
2306
2307 return c;
2308}
2309
2310////////////////////////////////////////////////////////////////////////////////
2311/// Create error type combo box.
2312
2314{
2315 TGComboBox *c = new TGComboBox(parent, id);
2316
2317 c->AddEntry("No Errors", kERRORS_NO);
2318 c->AddEntry("Simple", kERRORS_SIMPLE);
2319 c->AddEntry("Edges", kERRORS_EDGES);
2320 c->AddEntry("Rectangles",kERRORS_REC);
2321 c->AddEntry("Fill", kERRORS_FILL);
2322 c->AddEntry("Contour", kERRORS_CONTOUR);
2323
2324 return c;
2325}
2326
2327////////////////////////////////////////////////////////////////////////////////
2328/// Create Line/Bar combo box.
2329
2331{
2332 TGComboBox *c = new TGComboBox(parent, id);
2333
2334 c->AddEntry("No Line", kADD_NONE);
2335 c->AddEntry("Simple Line", kADD_SIMPLE);
2336 c->AddEntry("Smooth Line", kADD_SMOOTH);
2337 c->AddEntry("Fill Area",kADD_FILL);
2338 TGListBox* lb = c->GetListBox();
2339 lb->Resize(lb->GetWidth(), 76);
2340 return c;
2341}
2342
2343////////////////////////////////////////////////////////////////////////////////
2344/// Create Percentage combo box for bar option.
2345
2347{
2348 TGComboBox *c = new TGComboBox(parent, id);
2349
2350 c->AddEntry(" 0 %", kPER_0);
2351 c->AddEntry("10 %", kPER_10);
2352 c->AddEntry("20 %", kPER_20);
2353 c->AddEntry("30 %", kPER_30);
2354 c->AddEntry("40 %", kPER_40);
2355 TGListBox* lb = c->GetListBox();
2356 lb->Resize(lb->GetWidth(), 83);
2357
2358 return c;
2359}
2360
2361////////////////////////////////////////////////////////////////////////////////
2362/// Change the error combo box entry.
2363
2365{
2366 switch (i){
2367 case 0: {
2368 if (((TGLBContainer*)((TGListBox*)fErrorCombo->GetListBox())->GetContainer())->GetPos(kERRORS_EDGES)!=-1)
2373 lb->Resize(lb->GetWidth(),36);
2374 break;
2375 }
2376 case 1: {
2377 if (((TGLBContainer*)((TGListBox*)fErrorCombo->GetListBox())->GetContainer())->GetPos(kERRORS_EDGES)==-1) {
2379 fErrorCombo->AddEntry("Rectangles",kERRORS_REC);
2383 lb->Resize(lb->GetWidth(),100);
2384 }
2385 break;
2386 }
2387 }
2388}
2389
2390 ///////////////////////////////////////////////////////////////////////////////
2391 /// Paint a 3D box.
2392
2394{
2395 fGedEditor->GetPad()->FeedbackMode(kTRUE);
2396 fGedEditor->GetPad()->SetLineWidth(1);
2397 fGedEditor->GetPad()->SetLineColor(2);
2398 fGedEditor->GetPad()->cd();
2399 fGedEditor->GetPad()->PaintLine3D(p1, p2);
2400 fGedEditor->GetPad()->PaintLine3D(p2, p3);
2401 fGedEditor->GetPad()->PaintLine3D(p3, p4);
2402 fGedEditor->GetPad()->PaintLine3D(p4, p1);
2403}
2404
2405////////////////////////////////////////////////////////////////////////////////
2406/// Return an array of dividers of n (without the trivial divider n).
2407/// The number of dividers is saved in the first entry.
2408
2410{
2411 Int_t* div;
2412 if (n <= 0) {
2413 div = new Int_t[1];
2414 div[0]=0;
2415 } else if (n == 1) {
2416 div = new Int_t[2];
2417 div[0]=div[1]=1;
2418 } else {
2419 div = new Int_t[(Int_t) n/2+2];
2420 div[0]=0;
2421 div[1]=1;
2422
2423 Int_t num = 1;
2424 for (Int_t i=2; i <= n/2; i++) {
2425 if (n % i == 0) {
2426 num++;
2427 div[num] = i;
2428 }
2429 }
2430 num++;
2431 div[num]=n;
2432 div[0] = num;
2433// for (Int_t a=0; a <= div[0]; a++) printf("div[%d] = %d\n", a , div[a]);
2434 }
2435 return div;
2436}
2437
2438////////////////////////////////////////////////////////////////////////////////
2439/// If the contained histogram obj is deleted we must set its pointer to zero
2440
2442{
2443 if (obj == fHist) {
2444 fHist = 0;
2445 }
2446}
@ 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
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ 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:379
Class to manage histogram axis.
Definition TAxis.h:32
Double_t GetXmax() const
Definition TAxis.h:142
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition TAxis.cxx:522
Int_t GetLast() const
Return last bin on the axis i.e.
Definition TAxis.cxx:473
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:1090
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis using bin numbers.
Definition TAxis.cxx:1061
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
Definition TAxis.cxx:546
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition TAxis.cxx:532
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition TAxis.cxx:462
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:439
virtual EButtonState GetState() const
Definition TGButton.h:112
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:229
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:1110
TGCompositeFrame(const TGCompositeFrame &)=delete
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1250
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1197
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1036
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1183
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:598
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
Bool_t Contains(Int_t x, Int_t y) const
Definition TGFrame.h:240
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
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:107
virtual void SetRange(Int_t min, Int_t max)
Set slider range.
Definition TGSlider.cxx:96
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:150
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
Float_t fP6old[3]
Definition TH1Editor.h:110
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).
Int_t fPy1old
Definition TH1Editor.h:98
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
Float_t fP3old[3]
Definition TH1Editor.h:107
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
Float_t fP5old[3]
Definition TH1Editor.h:109
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.
Int_t fPx1old
Definition TH1Editor.h:97
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:114
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
Float_t fP8old[3]
Definition TH1Editor.h:112
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
Float_t fP1old[3]
Definition TH1Editor.h:105
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
Int_t fPx2old
Definition TH1Editor.h:99
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
Float_t fP2old[3]
Definition TH1Editor.h:106
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:113
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
virtual void PaintBox3D(Float_t *p1, Float_t *p2, Float_t *p3, Float_t *p4)
Paint a 3D box.
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.
Float_t fP7old[3]
Definition TH1Editor.h:111
Int_t fPy2old
Definition TH1Editor.h:100
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.
Float_t fP4old[3]
Definition TH1Editor.h:108
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:109
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:612
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6932
virtual Float_t GetBarWidth() const
Definition TH1.h:501
virtual Float_t GetBarOffset() const
Definition TH1.h:500
static TClass * Class()
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
Definition TH1.cxx:7324
TAxis * GetXaxis()
Definition TH1.h:571
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
@ kNoAxis
NOTE: Must always be 0 !!!
Definition TH1.h:122
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
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:613
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
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
See TView3D.
Definition TView.h:25
virtual Double_t * GetRmax()=0
virtual Double_t * GetRmin()=0
static TVirtualTreePlayer * GetCurrentPlayer()
Static function: return the current player (if any)
leg AddEntry(h1,"Histogram filled with random numbers","f")
const Int_t n
Definition legend1.C:16