Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TH2Editor.cxx
Go to the documentation of this file.
1// @(#)root/ged:$Id$
2// Author: Carsten Hof 09/08/04
3// Authors mail: Carsten_Hof@web.de
4
5/*************************************************************************
6 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13
14/**\class TH2Editor
15 \ingroup ged
16
17Editor for changing TH2 histogram attributes, rebinning & fitting.
18For all possible draw options (there are a few which are not implementable
19in a graphical user interface) see THistPainter::Paint.
20
21These changes can be made via the TH2Editor:
22Style Tab:
23 'Line' : change Line attributes (color, thickness)
24 see TAttLineEditor
25 'Fill' : change Fill attributes (color, pattern)
26 see TAttFillEditor
27 'Title' : TextEntry: set the title of the histogram
28 'Histogram': change the draw options of the histogram
29 'Plot' : Radiobutton: draw a 2D or 3D plot of the histogram
30 according to the Plot dimension there will be
31 different drawing possibilities (ComboBoxes/
32 CheckBoxes)
332d Plot:
34 'Contour' : ComboBox: draw a contour plot (None, Cont0..4)
35 'Cont #' : TGNumberEntry: set the number of Contours
362d Plot checkboxes:
37 'Arrow' : arrow mode. Shows gradient between adjacent cells
38 'Col' : a box is drawn for each cell with a color scale
39 varying with contents
40 'Text' : Draw bin contents as text
41 'Box' : a box is drawn for each cell with surface
42 proportional to contents
43 'Scat' : Draw a scatter-plot (default)
44 'Palette' : the color palette is drawn
45
463d Plot:
47 'Type' : ComboBox: set histogram type Lego or Surface-Plot
48 draw(Lego, Lego1..4, Surf, Surf1..5)
49 see THistPainter::Paint
50 'Coords' : ComboBox: set the coordinate system (Cartesian, ..
51 Spheric) see THistPainter::Paint
52 'Cont #' : TGNumberEntry: set the number of Contours (for e.g.
53 Lego2 drawoption
543d Plot checkboxes:
55 'Errors' : draw errors in a cartesian lego plot
56 'Palette' : the color palette is drawn
57 'Front' : draw the front box of a cartesian lego plot
58 'Back' : draw the back box of a cartesian lego plot
59Available for a 3D lego plot:
60 'Bar' : change the bar attributes
61 'W' : change Bar Width
62 'O' : change Bar Offset
63Further Editor:
64 'Marker' : change the Marker attributes (color, appearance,
65 thickness) see TAttMarkerEditor
66
67
68Rebinning Tab:
69 This Tab has two different layouts. One is for a histogram which
70 is not drawn from an ntuple. The other one is available for a
71 histogram which is drawn from an ntuple. In this case the rebin
72 algorithm can create a rebinned histogram from the original data
73 i.e. the ntuple.
74 To see te differences do for example:
75 TFile f("hsimple.root");
76 hpxpy->Draw("Lego2"); // non ntuple histogram
77 ntuple->Draw("px:py","","Lego2"); // ntuple histogram
78Non ntuple histogram:
79 'Rebin': with the Sliders (one for the x, one for the y axis)
80 the number of bins (shown in the field below the
81 Slider) can be changed to any number which divides
82 the number of bins of the original histogram.
83 Pushing 'Apply' will delete the origin histogram and
84 replace it by the rebinned one on the screen.
85 Pushing 'Ignore' the origin histogram will be restored
86Histogram drawn from an ntuple:
87 'Rebin' with the sliders the number of bins can be enlarged by
88 a factor of 2,3,4,5 (moving to the right) or reduced
89 by a factor of 1/2, 1/3, 1/4, 1/5
90 'BinOffset': with the BinOffset slider the origin of the
91 histogram can be changed within one binwidth
92 Using this slider the effect of binning the data into
93 bins can be made visible => statistical fluctuations
94 'Axis Range': with the DoubleSlider it is possible to zoom into
95 the specified axis range. It is also possible to set
96 the upper and lower limit in fields below the slider
97 'Delayed drawing': all the Binning sliders can be set to delay
98 draw mode. Then the changes on the histogram are only
99 updated, when the Slider is released. This should be
100 activated if the redrawing of the histogram is too
101 time consuming. //
102*/
103
104
105#include "TH2Editor.h"
106#include "TGedEditor.h"
107#include "TGComboBox.h"
108#include "TGTextEntry.h"
109#include "TGLabel.h"
110#include "TVirtualPad.h"
111#include "TString.h"
112#include "TGButtonGroup.h"
113#include "TGNumberEntry.h"
114#include "TG3DLine.h"
115#include "TGDoubleSlider.h"
116#include "TGSlider.h"
117#include "TView.h"
118#include "TCanvas.h"
119#include "TGedPatternSelect.h"
120#include "TGColorSelect.h"
121#include "TColor.h"
122#include "TTreePlayer.h"
123#include "TSelectorDraw.h"
124#include "TGTab.h"
125#include "TGMsgBox.h"
126#include "TH2.h"
127#include "TROOT.h"
128#include "TVirtualX.h"
129
130
131
149
150////////////////////////////////////////////////////////////////////////////////
151/// Constructor of histogram attribute GUI.
152
154 Int_t height, UInt_t options, Pixel_t back)
155 : TGedFrame(p, width, height, options | kVerticalFrame, back),
156 fHist(0),
157 fBin(0),
158 fBinHist(0)
159{
160 MakeTitle("Title");
161
162 // Histogram title
163 fTitlePrec = 2;
164 fTitle = new TGTextEntry(this, new TGTextBuffer(50), kTH2_TITLE);
165 fTitle->Resize(135, fTitle->GetDefaultHeight());
166 fTitle->SetToolTipText("Enter the histogram title string");
167 AddFrame(fTitle, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
168
169
170 // 2D or 3D Plot?
171 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
172 fDimGroup = new TGHButtonGroup(f2,"Plot");
174 fDim->SetToolTipText("A 2-d plot of the histogram is dawn");
176 fDim0->SetToolTipText("A 3-d plot of the histogram is dawn");
177 fDimGroup->SetLayoutHints(fDimlh=new TGLayoutHints(kLHintsLeft ,-2,3,3,-7),fDim);
178 fDimGroup->SetLayoutHints(fDim0lh=new TGLayoutHints(kLHintsLeft ,16,-1,3,-7),fDim0);
179 fDimGroup->Show();
181 f2->AddFrame(fDimGroup, new TGLayoutHints(kLHintsTop, 4, 1, 0, 0));
182 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 2, 5));
183
184 // 2D Plot drawoptions
185 f6 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
186 AddFrame(f6, new TGLayoutHints(kLHintsTop, 3, 1, 4, 2));
187
188 TGCompositeFrame *f7 = new TGCompositeFrame(f6, 40, 20);
189 f6->AddFrame(f7, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
190
191 TGLabel *fAddLabel = new TGLabel(f7, "Contour:");
192 f7->AddFrame(fAddLabel, new TGLayoutHints(kLHintsLeft, 6, 4, 4, 4));
193
194 fColContLbl = new TGLabel(f7, "Cont #:");
195 f7->AddFrame(fColContLbl, new TGLayoutHints( kLHintsLeft, 6, 4, 4, 4));
196
197 fAddArr = new TGCheckButton(f7, "Arrow", kARROW_ONOFF);
198 fAddArr ->SetToolTipText("Shows gradient between adjacent cells");
199 f7->AddFrame(fAddArr, new TGLayoutHints(kLHintsLeft, 6, 1, 2, 0));
200
201 fAddCol = new TGCheckButton(f7, "Col", kCOL_ONOFF);
202 fAddCol ->SetToolTipText("A box is drawn for each cell with a color scale varying with contents");
203 f7->AddFrame(fAddCol, new TGLayoutHints(kLHintsLeft, 6, 1, 1, 0));
204
205 fAddText = new TGCheckButton(f7, "Text", kTEXT_ONOFF);
206 fAddText ->SetToolTipText("Draw bin contents as text");
207 f7->AddFrame(fAddText, new TGLayoutHints(kLHintsLeft, 6, 1, 1, 3));
208
210 f6->AddFrame(f8, new TGLayoutHints(kLHintsLeft, 5, 1, 0, 0));
211
213 f8->AddFrame(fContCombo, new TGLayoutHints(kLHintsLeft, 6, 1, 2, 1));
214 fContCombo->Resize(61, 20);
215 fContCombo->Associate(this);
216
217 fContLevels = new TGNumberEntry(f8, 20, 0, kCONT_LEVELS,
221 f8->AddFrame(fContLevels, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 1));
222 fContLevels->GetNumberEntry()->SetToolTipText("Set number of contours (1..99)");
223 fContLevels->Resize(60,20);
224
225 fAddBox = new TGCheckButton(f8, "Box", kBOX_ONOFF);
226 fAddBox ->SetToolTipText("A box is drawn for each cell with surface proportional to contents");
227 f8->AddFrame(fAddBox, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 0));
228
229 fAddScat = new TGCheckButton(f8, "Scat", kSCAT_ONOFF);
230 fAddScat ->SetToolTipText("Draw a scatter-plot");
231 f8->AddFrame(fAddScat, new TGLayoutHints(kLHintsLeft, 6, 1, 1, 0));
232
233 fAddPalette = new TGCheckButton(f8, "Palette", kPALETTE_ONOFF);
234 fAddPalette ->SetToolTipText("Add color palette beside the histogram");
235 f8->AddFrame(fAddPalette, new TGLayoutHints(kLHintsLeft, 6, 1, 1, 0));
236
237 f9 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
238 AddFrame(f9, new TGLayoutHints(kLHintsTop, 3, 1, 2, 0));
239
240 TGCompositeFrame *f10 = new TGCompositeFrame(f9, 40, 20);
241 f9->AddFrame(f10, new TGLayoutHints(kLHintsLeft, 0, 0, 3, 0));
242
243 TGLabel *fType = new TGLabel(f10, "Type:");
244 f10->AddFrame(fType, new TGLayoutHints(kLHintsNormal, 1, 1, 1, 1));
245
246 TGLabel *fCoords = new TGLabel(f10, "Coords:");
247 f10->AddFrame(fCoords, new TGLayoutHints(kLHintsLeft, 1, 1, 5, 1));
248
249 fColContLbl1 = new TGLabel(f10, "Cont #:");
250 f10->AddFrame(fColContLbl1, new TGLayoutHints( kLHintsLeft, 1, 1, 5, 3));
251
252 fAddFB = new TGCheckButton(f10, "Front", kFRONTBOX_ONOFF);
253 fAddFB ->SetToolTipText("Supress the drawing of the front box");
254 f10->AddFrame(fAddFB, new TGLayoutHints(kLHintsLeft, 0, 1, 6, 0));
255 fAddBB = new TGCheckButton(f10, "Back", kBACKBOX_ONOFF);
256 fAddBB ->SetToolTipText("Supress the drawing of the back box");
257 f10->AddFrame(fAddBB, new TGLayoutHints(kLHintsLeft, 0, 1, 3, 0));
258
259 TGCompositeFrame *f11 = new TGCompositeFrame(f9, 40, 20);
260 f9->AddFrame(f11, new TGLayoutHints(kLHintsLeft, 5, 1, 0, 0));
261
263 f11->AddFrame(fTypeCombo, new TGLayoutHints(kLHintsLeft, 0, 1, 2, 1));
264 fTypeCombo->Resize(80, 20);
265 fTypeCombo->Associate(this);
266
268 f11->AddFrame(fCoordsCombo, new TGLayoutHints(kLHintsLeft, 0, 1, 2, 1));
269 fCoordsCombo->Resize(80, 20);
270 fCoordsCombo->Associate(this);
271
272 fContLevels1 = new TGNumberEntry(f11, 20, 0, kCONT_LEVELS1,
276 fContLevels1->GetNumberEntry()->SetToolTipText("Set number of contours (1..99)");
277 fContLevels1->Resize(78,20);
278 f11->AddFrame(fContLevels1, new TGLayoutHints(kLHintsLeft, 0, 1, 2, 1));
279
280 fAddError = new TGCheckButton(f11, "Errors", kERROR_ONOFF);
281 fAddError ->SetToolTipText("Add color palette beside the histogram");
282 f11->AddFrame(fAddError, new TGLayoutHints(kLHintsLeft, 0, 1, 4, 0));
283 fAddPalette1 = new TGCheckButton(f11, "Palette", kPALETTE_ONOFF1);
284 fAddPalette1 ->SetToolTipText("Add color palette beside the histogram");
285 f11->AddFrame(fAddPalette1, new TGLayoutHints(kLHintsLeft, 0, 1, 3, 0));
286
287
288 // Bin bar settings
289 f12 = new TGCompositeFrame(this, 145, 10, kHorizontalFrame |
290 kFitWidth |
293 f12->AddFrame(new TGLabel(f12,"Bar"),
294 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
295 f12->AddFrame(new TGHorizontal3DLine(f12),
296 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
297 AddFrame(f12, new TGLayoutHints(kLHintsTop,0,0,6,4));
298
299 f13 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
300 TGLabel *fWidthLbl = new TGLabel(f13, "W:");
301 f13->AddFrame(fWidthLbl, new TGLayoutHints( kLHintsLeft, 1, 3, 4, 1));
302 fBarWidth = new TGNumberEntry(f13, 1.00, 6, kBAR_WIDTH,
306 fBarWidth->GetNumberEntry()->SetToolTipText("Set bar chart width");
307 fBarWidth->Resize(45,20);
308 f13->AddFrame(fBarWidth, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 1));
309
310 TGLabel *fOffsetLbl = new TGLabel(f13, "O:");
311 f13->AddFrame(fOffsetLbl, new TGLayoutHints(kLHintsLeft, 6,3, 4, 1));
312 fBarOffset = new TGNumberEntry(f13, 0.00, 5, kBAR_OFFSET,
316 fBarOffset->GetNumberEntry()->SetToolTipText("Set bar chart offset");
317 fBarOffset->Resize(50,20);
318 f13->AddFrame(fBarOffset, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 1));
319 AddFrame(f13, new TGLayoutHints(kLHintsTop, 1, 1, 0, 4));
320
321
322 // Set the color and pattern of the Frame (only for Cartesian 3D plot).
323 f38 = new TGCompositeFrame(this, 80, 20, kVerticalFrame);
325 kFitWidth |
328 f39->AddFrame(new TGLabel(f39,"Frame Fill"),
329 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
330 f39->AddFrame(new TGHorizontal3DLine(f39),
331 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
332 f38->AddFrame(f39, new TGLayoutHints(kLHintsTop,0,0,6,1));
333
335 fFrameColor = new TGColorSelect(f21, 0, kCOLOR);
336 f21->AddFrame(fFrameColor, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 0));
337 fFrameColor->Associate(f38);
339 f21->AddFrame(fFramePattern, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 0));
340 fFramePattern->Associate(f38);
341 f38->AddFrame(f21, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
343
344 fCutString = "";
345
346 CreateBinTab();
347
348 // add itself in the least of cleanups to be notified when attached histogram is deleted
349 gROOT->GetListOfCleanups()->Add(this);
350}
351
352////////////////////////////////////////////////////////////////////////////////
353/// Create the Binning tab.
354
356{
357 fBin = CreateEditorTabSubFrame("Binning");
358
359 // Editor for rebinning a histogram which does NOT derive from an Ntuple
361 TGCompositeFrame *title1 = new TGCompositeFrame(fBinXCont, 145, 10,
363 kFitWidth |
366 title1->AddFrame(new TGLabel(title1, "Rebin"),
367 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
368 title1->AddFrame(new TGHorizontal3DLine(title1),
369 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
370 fBinXCont->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
371
374 TGLabel *binSliderXLbl = new TGLabel(f22,"x:");
375 f22->AddFrame(binSliderXLbl,
376 new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 4,0, 4, 1));
377 fBinXSlider = new TGHSlider(f22, 100, kSlider1 | kScaleBoth);
378 fBinXSlider->Resize(107,20);
379 f22->AddFrame(fBinXSlider, new TGLayoutHints(kLHintsLeft, 2,0,0,3));
380 fBinXCont->AddFrame(f22, new TGLayoutHints(kLHintsTop, 3, 7, 3, 5));
381
384 TGLabel *binXLabel1 = new TGLabel(f23, "# of Bins:");
385 f23->AddFrame(binXLabel1, new TGLayoutHints(kLHintsLeft, 20, 1, 2, 1));
388 ((TGTextEntry*)fBinXNumberEntry)->SetToolTipText("Set the number of x axis bins in the rebinned histogram");
389 fBinXNumberEntry->Resize(57,20);
390 f23->AddFrame(fBinXNumberEntry, new TGLayoutHints(kLHintsRight, 8, 0, 0, 0));
391 fBinXCont->AddFrame(f23, new TGLayoutHints(kLHintsTop, 0, 7, 3, 4));
392
395 TGLabel *binSliderYLbl = new TGLabel(f37,"y:");
396 f37->AddFrame(binSliderYLbl,
397 new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 4,0, 4, 1));
398 fBinYSlider = new TGHSlider(f37, 100, kSlider1 | kScaleBoth);
399 fBinYSlider->Resize(107,20);
400 f37->AddFrame(fBinYSlider, new TGLayoutHints(kLHintsLeft, 1,0,0,3));
401 fBinXCont->AddFrame(f37, new TGLayoutHints(kLHintsTop, 3, 7, 3, 5));
402
405 TGLabel *binYLabel1 = new TGLabel(f36, "# of Bins:");
406 f36->AddFrame(binYLabel1, new TGLayoutHints(kLHintsLeft, 20, 1, 2, 1));
409 ((TGTextEntry*)fBinYNumberEntry)->SetToolTipText("Set the number of y axis bins in the rebinned histogram");
410 fBinYNumberEntry->Resize(57,20);
411 f36->AddFrame(fBinYNumberEntry, new TGLayoutHints(kLHintsRight, 8, 0, 0, 0));
412 fBinXCont->AddFrame(f36, new TGLayoutHints(kLHintsTop, 0, 7, 3, 4));
413
414 // Text buttons Apply & Ignore for rebinned histogram shown on the screen.
415 TGCompositeFrame *f24 = new TGCompositeFrame(fBinXCont, 118, 20,
418 fApply = new TGTextButton(f24, " &Apply ");
419 f24->AddFrame(fApply,
420 new TGLayoutHints(kLHintsExpandX | kLHintsLeft ,0, 3, 4, 4));
421 fCancel = new TGTextButton(f24, " &Ignore ");
422 f24->AddFrame(fCancel,
423 new TGLayoutHints(kLHintsExpandX | kLHintsLeft, 3, 0, 4, 4));
424 fBinXCont->AddFrame(f24, new TGLayoutHints(kLHintsTop, 20, 3, 3, 4));
425 fBin->AddFrame(fBinXCont,new TGLayoutHints(kLHintsTop));
426
427 // Widgets for rebinning a histogram which derives from an Ntuple
428
430 TGCompositeFrame *title2 = new TGCompositeFrame(fBinXCont1, 145, 10,
432 kFitWidth |
435 title2->AddFrame(new TGLabel(title2, "X-Axis"),
436 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
437 title2->AddFrame(new TGHorizontal3DLine(title2),
438 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
439 fBinXCont1->AddFrame(title2, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
440
443 fBinXSlider1 = new TGHSlider(f26, 100, kSlider1 | kScaleBoth);
444 fBinXSlider1->Resize(120,20);
445 fBinXSlider1->SetRange(1,9);
446 fBinXSlider1->SetScale(14);
447 fBinXSlider1->SetPosition(5);
448 f26->AddFrame(fBinXSlider1, new TGLayoutHints(kLHintsLeft, 2,0,0,0));
449 fBinXCont1->AddFrame(f26, new TGLayoutHints(kLHintsTop, 3, 7, 3, 0));
450
451 // Lettering of the Rebin Slider
454 TGLabel *l1 = new TGLabel(f27, "-5");
455 f27->AddFrame(l1, new TGLayoutHints(kLHintsLeft, 5, 1, -1, 0));
456 TGLabel *l2 = new TGLabel(f27, "-2");
457 f27->AddFrame(l2, new TGLayoutHints(kLHintsLeft, 31, 2, -1, 0));
458 TGLabel *l3 = new TGLabel(f27, "2");
459 f27->AddFrame(l3, new TGLayoutHints(kLHintsLeft, 21, 2, -1, 0));
460 TGLabel *l4 = new TGLabel(f27, "5");
461 f27->AddFrame(l4, new TGLayoutHints(kLHintsLeft, 36, 3, -1, 0));
462 fBinXCont1->AddFrame(f27, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
463
464 TGCompositeFrame *f28 = new TGCompositeFrame(fBinXCont1, 140, 20,
466 TGLabel *binXLabel2 = new TGLabel(f28, "# of Bins:");
467 f28->AddFrame(binXLabel2, new TGLayoutHints(kLHintsLeft, 8, 1, 4, 1));
468
471 ((TGTextEntry*)fBinXNumberEntry1)->SetToolTipText("Set the number of x axis bins in the rebinned histogram");
472 fBinXNumberEntry1->Resize(57,20);
474 new TGLayoutHints(kLHintsLeft, 21, 0, 2, 0));
475 fBinXCont1->AddFrame(f28, new TGLayoutHints(kLHintsTop, 0, 7, 2, 4));
476
479 TGLabel *xOffsetLbl = new TGLabel(f29, "BinOffset:");
480 f29->AddFrame(xOffsetLbl, new TGLayoutHints(kLHintsLeft, 7, 1, 2, 1));
485 0., 1.);
486 ((TGTextEntry*)fXOffsetNumberEntry)->SetToolTipText("Add an x-offset to the origin of the histogram");
487 fXOffsetNumberEntry->Resize(57,20);
489 new TGLayoutHints(kLHintsRight, 21, 0, 0, 0));
490 fBinXCont1->AddFrame(f29, new TGLayoutHints(kLHintsTop, 0, 7, 3, 1));
491
494 fXBinOffsetSld = new TGHSlider(f30, 100, kSlider1 | kScaleBoth);
495 fXBinOffsetSld->Resize(120,20);
497 fBinXCont1->AddFrame(f30, new TGLayoutHints(kLHintsTop, 3, 7, 3, 3));
498 fBin->AddFrame(fBinXCont1, new TGLayoutHints(kLHintsTop));
499
500 // Same for Y-Axis:
501 // Widgets for rebinning a histogram which derives from an Ntuple
502
504 TGCompositeFrame *title3 = new TGCompositeFrame(fBinYCont1, 145, 10,
506 kFitWidth |
509 title3->AddFrame(new TGLabel(title3, "Y-Axis"),
510 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
511 title3->AddFrame(new TGHorizontal3DLine(title3),
512 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
513 fBinYCont1->AddFrame(title3, new TGLayoutHints(kLHintsTop, 0, 0, 7, 0));
514
517 fBinYSlider1 = new TGHSlider(f31, 100, kSlider1 | kScaleBoth);
518 fBinYSlider1->Resize(120,20);
519 fBinYSlider1->SetRange(1,9);
520 fBinYSlider1->SetScale(14);
521 fBinYSlider1->SetPosition(5);
522 f31->AddFrame(fBinYSlider1, new TGLayoutHints(kLHintsLeft, 2,0,0,0));
523 fBinYCont1->AddFrame(f31, new TGLayoutHints(kLHintsTop, 3, 7, 3, 0));
524
525 // Lettering of the Rebin Slider
528 TGLabel *l5 = new TGLabel(f32, "-5");
529 f32->AddFrame(l5, new TGLayoutHints(kLHintsLeft, 5, 1, -1, 0));
530 TGLabel *l6 = new TGLabel(f32, "-2");
531 f32->AddFrame(l6, new TGLayoutHints(kLHintsLeft, 31, 2, -1, 0));
532 TGLabel *l7 = new TGLabel(f32, "2");
533 f32->AddFrame(l7, new TGLayoutHints(kLHintsLeft, 21, 2, -1, 0));
534 TGLabel *l8 = new TGLabel(f32, "5");
535 f32->AddFrame(l8, new TGLayoutHints(kLHintsLeft, 36, 3, -1, 0));
536 fBinYCont1->AddFrame(f32, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
537
538 TGCompositeFrame *f33 = new TGCompositeFrame(fBinYCont1, 140, 20,
540 TGLabel *binYLabel2 = new TGLabel(f33, "# of Bins:");
541 f33->AddFrame(binYLabel2, new TGLayoutHints(kLHintsLeft, 8, 1, 4, 1));
542
545 ((TGTextEntry*)fBinYNumberEntry1)->SetToolTipText("Set the number of Y axis bins in the rebinned histogram");
546 fBinYNumberEntry1->Resize(57,20);
548 new TGLayoutHints(kLHintsLeft, 21, 0, 2, 0));
549 fBinYCont1->AddFrame(f33, new TGLayoutHints(kLHintsTop, 0, 7, 2, 4));
550
553 TGLabel *yOffsetLbl = new TGLabel(f34, "BinOffset:");
554 f34->AddFrame(yOffsetLbl, new TGLayoutHints(kLHintsLeft, 7, 1, 2, 1));
559 0., 1.);
560 ((TGTextEntry*)fYOffsetNumberEntry)->SetToolTipText("Add an Y-offset to the origin of the histogram");
561 fYOffsetNumberEntry->Resize(57,20);
563 new TGLayoutHints(kLHintsRight, 21, 0, 0, 0));
564 fBinYCont1->AddFrame(f34, new TGLayoutHints(kLHintsTop, 0, 7, 3, 1));
565
568 fYBinOffsetSld = new TGHSlider(f35, 100, kSlider1 | kScaleBoth);
569 fYBinOffsetSld->Resize(120,20);
570 fYBinOffsetSld->Associate(f35);
572 fBinYCont1->AddFrame(f35, new TGLayoutHints(kLHintsTop, 3, 7, 3, 3));
573 fBin->AddFrame(fBinYCont1, new TGLayoutHints(kLHintsTop));
574
575 // Axis ranges
576 TGCompositeFrame *title4 = new TGCompositeFrame(fBin, 145, 10,
578 kFitWidth |
581 title4->AddFrame(new TGLabel(title4, "Axis Range"),
582 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
583 title4->AddFrame(new TGHorizontal3DLine(title4),
584 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
585 fBin->AddFrame(title4, new TGLayoutHints(kLHintsTop, 0, 0, 5, 0));
586
588 TGLabel *fSliderXLbl = new TGLabel(f14,"x:");
589 f14->AddFrame(fSliderXLbl,
590 new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 4,3, 2, 1));
591 fSliderX = new TGDoubleHSlider(f14, 1, 2);
592 fSliderX->Resize(119,20);
594 fBin->AddFrame(f14, new TGLayoutHints(kLHintsTop, 3, 7, 4, 1));
595
600 ((TGTextEntry*)fSldXMin)->SetToolTipText("Set the minimum value of the x-axis");
601 fSldXMin->Resize(57,20);
602 f17->AddFrame(fSldXMin, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
606 ((TGTextEntry*)fSldXMax)->SetToolTipText("Set the maximum value of the x-axis");
607 fSldXMax->Resize(57,20);
608 f17->AddFrame(fSldXMax, new TGLayoutHints(kLHintsLeft, 4, 0, 0, 0));
609 fBin->AddFrame(f17, new TGLayoutHints(kLHintsTop, 20, 3, 5, 0));
610
612 TGLabel *fSliderYLbl = new TGLabel(f15,"y:");
613 f15->AddFrame(fSliderYLbl,
614 new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 4,2, 4, 1));
615 fSliderY = new TGDoubleHSlider(f15, 1, 2);
616 fSliderY->Resize(119,20);
618 fBin->AddFrame(f15, new TGLayoutHints(kLHintsTop, 3, 7, 4, 1));
619
624 ((TGTextEntry*)fSldYMin)->SetToolTipText("Set the minimum value of the y-axis");
625 fSldYMin->Resize(57,20);
626 f18->AddFrame(fSldYMin, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
630 ((TGTextEntry*)fSldYMax)->SetToolTipText("Set the maximum value of the y-axis");
631 fSldYMax->Resize(57,20);
632 f18->AddFrame(fSldYMax, new TGLayoutHints(kLHintsLeft, 4, 0, 0, 0));
633 fBin->AddFrame(f18, new TGLayoutHints(kLHintsTop, 20, 3, 5, 0));
634
636 fDelaydraw = new TGCheckButton(f20, "Delayed drawing", kDELAYED_DRAWING);
637 fDelaydraw ->SetToolTipText("Draw the new axis range when the Slider is released");
638 f20->AddFrame(fDelaydraw, new TGLayoutHints(kLHintsLeft, 6, 1, 1, 0));
639 fBin->AddFrame(f20, new TGLayoutHints(kLHintsTop, 2, 1, 5, 3));
640
641 fXBinOffsetSld->SetRange(0,100);
642 fXBinOffsetSld->SetPosition(0);
643 fXOffsetNumberEntry->SetNumber(0.0000);
644
645 fYBinOffsetSld->SetRange(0,100);
646 fYBinOffsetSld->SetPosition(0);
647 fYOffsetNumberEntry->SetNumber(0.0000);
648
649 fCancel->SetState(kButtonDisabled);
650 fApply->SetState(kButtonDisabled);
651
652}
653
654////////////////////////////////////////////////////////////////////////////////
655/// Destructor.
656
658{
659 // remove itselef from the list of cleanups
660 gROOT->GetListOfCleanups()->Remove(this);
661
662 // children of TGButonGroup are not deleted
663 delete fDim;
664 delete fDim0;
665 delete fDimlh;
666 delete fDim0lh;
667
668 if (fBinHist) delete fBinHist;
669 fBinHist = 0;
670}
671
672////////////////////////////////////////////////////////////////////////////////
673/// Connect signals to slots.
674
676{
677 fTitle->Connect("TextChanged(const char *)", "TH2Editor", this, "DoTitle(const char *)");
678 fDimGroup->Connect("Clicked(Int_t)","TH2Editor",this,"DoHistView()");
679 fTypeCombo->Connect("Selected(Int_t)", "TH2Editor", this, "DoHistChanges()");
680 fCoordsCombo->Connect("Selected(Int_t)", "TH2Editor", this, "DoHistChanges()");
681 fContCombo->Connect("Selected(Int_t)", "TH2Editor", this, "DoHistChanges()");
682 fAddArr->Connect("Toggled(Bool_t)", "TH2Editor", this, "DoAddArr(Bool_t)");
683 fAddBox->Connect("Toggled(Bool_t)", "TH2Editor", this, "DoAddBox(Bool_t)");
684 fAddCol->Connect("Toggled(Bool_t)", "TH2Editor", this, "DoAddCol(Bool_t)");
685 fAddScat->Connect("Toggled(Bool_t)", "TH2Editor", this, "DoAddScat(Bool_t)");
686 fAddText->Connect("Toggled(Bool_t)", "TH2Editor", this, "DoAddText(Bool_t)");
687 fAddError->Connect("Toggled(Bool_t)", "TH2Editor", this, "DoAddError(Bool_t)");
688 fAddPalette->Connect("Toggled(Bool_t)", "TH2Editor", this, "DoAddPalette(Bool_t)");
689 fAddPalette1->Connect("Toggled(Bool_t)", "TH2Editor", this, "DoAddPalette(Bool_t)");
690 fAddFB->Connect("Toggled(Bool_t)", "TH2Editor", this, "DoAddFB()");
691 fAddBB->Connect("Toggled(Bool_t)", "TH2Editor", this, "DoAddBB()");
692 fContLevels->Connect("ValueSet(Long_t)", "TH2Editor", this, "DoContLevel()");
693 (fContLevels->GetNumberEntry())->Connect("ReturnPressed()", "TH2Editor",
694 this,"DoContLevel()");
695 fContLevels1->Connect("ValueSet(Long_t)", "TH2Editor", this, "DoContLevel1()");
696 (fContLevels1->GetNumberEntry())->Connect("ReturnPressed()", "TH2Editor",
697 this,"DoContLevel1()");
698 fBarWidth->Connect("ValueSet(Long_t)", "TH2Editor", this, "DoBarWidth()");
699 (fBarWidth->GetNumberEntry())->Connect("ReturnPressed()", "TH2Editor",
700 this, "DoBarWidth()");
701 fBarOffset->Connect("ValueSet(Long_t)", "TH2Editor", this, "DoBarOffset()");
702 (fBarOffset->GetNumberEntry())->Connect("ReturnPressed()", "TH2Editor",
703 this, "DoBarOffset()");
704 fBinXSlider->Connect("PositionChanged(Int_t)","TH2Editor",this, "DoBinMoved()");
705 fBinXSlider->Connect("Released()","TH2Editor",this, "DoBinReleased()");
706 fBinXSlider->Connect("Pressed()","TH2Editor",this, "DoBinPressed()");
707 fBinYSlider->Connect("PositionChanged(Int_t)","TH2Editor",this, "DoBinMoved()");
708 fBinYSlider->Connect("Released()","TH2Editor",this, "DoBinReleased()");
709 fBinYSlider->Connect("Pressed()","TH2Editor",this, "DoBinPressed()");
710 fBinXNumberEntry->Connect("ReturnPressed()", "TH2Editor", this, "DoBinLabel()");
711 fBinYNumberEntry->Connect("ReturnPressed()", "TH2Editor", this, "DoBinLabel()");
712 fApply->Connect("Clicked()", "TH2Editor", this, "DoApply()");
713 fCancel->Connect("Pressed()", "TH2Editor", this, "DoCancel()");
714 fBinXSlider1->Connect("Released()","TH2Editor",this, "DoBinReleased1()");
715 fBinXSlider1->Connect("PositionChanged(Int_t)","TH2Editor",this, "DoBinMoved1()");
716 fBinXNumberEntry1->Connect("ReturnPressed()", "TH2Editor", this, "DoBinLabel1()");
717 fXBinOffsetSld->Connect("PositionChanged(Int_t)","TH2Editor",this, "DoOffsetMoved()");
718 fXBinOffsetSld->Connect("Released()","TH2Editor",this, "DoOffsetReleased()");
719 fXBinOffsetSld->Connect("Pressed()","TH2Editor",this, "DoOffsetPressed()");
720 fXOffsetNumberEntry->Connect("ReturnPressed()", "TH2Editor", this, "DoBinOffset()");
721 fBinYSlider1->Connect("Released()","TH2Editor",this, "DoBinReleased1()");
722 fBinYSlider1->Connect("PositionChanged(Int_t)","TH2Editor",this, "DoBinMoved1()");
723 fBinYNumberEntry1->Connect("ReturnPressed()", "TH2Editor", this, "DoBinLabel1()");
724 fYBinOffsetSld->Connect("PositionChanged(Int_t)","TH2Editor",this,"DoOffsetMoved()");
725 fYBinOffsetSld->Connect("Released()","TH2Editor",this, "DoOffsetReleased()");
726 fYBinOffsetSld->Connect("Pressed()","TH2Editor",this, "DoOffsetPressed()");
727 fYOffsetNumberEntry->Connect("ReturnPressed()", "TH2Editor", this,"DoBinOffset()");
728 fSliderX->Connect("PositionChanged()","TH2Editor",this, "DoSliderXMoved()");
729 fSliderX->Connect("Pressed()","TH2Editor",this, "DoSliderXPressed()");
730 fSliderX->Connect("Released()","TH2Editor",this, "DoSliderXReleased()");
731 fSldXMin->Connect("ReturnPressed()", "TH2Editor", this, "DoXAxisRange()");
732 fSldXMax->Connect("ReturnPressed()", "TH2Editor", this, "DoXAxisRange()");
733 fSliderY->Connect("PositionChanged()","TH2Editor",this, "DoSliderYMoved()");
734 fSliderY->Connect("Pressed()","TH2Editor",this, "DoSliderYPressed()");
735 fSliderY->Connect("Released()","TH2Editor",this, "DoSliderYReleased()");
736 fSldYMin->Connect("ReturnPressed()", "TH2Editor", this, "DoYAxisRange()");
737 fSldYMax->Connect("ReturnPressed()", "TH2Editor", this, "DoYAxisRange()");
738 fFrameColor->Connect("ColorSelected(Pixel_t)", "TH2Editor", this, "DoFillColor(Pixel_t)");
739 fFramePattern->Connect("PatternSelected(Style_t)", "TH2Editor", this, "DoFillPattern(Style_t)");
740
741 fInit = kFALSE;
742}
743
744////////////////////////////////////////////////////////////////////////////////
745/// Check if object is able to configure with this editor.
746
748{
749 if (obj == 0 || !obj->InheritsFrom(TH2::Class()) ||
750 (!strcmp(((TH2 *)obj)->GetName(),"htemp") &&
751 ((TH2*)obj)->GetEntries() == 0)) { // htemp is an empty histogram
752 return kFALSE;
753 }
754 return kTRUE;
755}
756
757////////////////////////////////////////////////////////////////////////////////
758/// Pick up the values of current histogram attributes.
759
761{
763 if (fBinHist && (obj != fHist)) {
764 //we have probably moved to a different pad.
765 //let's restore the original histogram
766 if (fHist) {
767 fHist->Reset();
768 fHist->SetBins(fBinHist->GetXaxis()->GetNbins(),
769 fBinHist->GetXaxis()->GetXmin(),
770 fBinHist->GetXaxis()->GetXmax(),
771 fBinHist->GetYaxis()->GetNbins(),
772 fBinHist->GetYaxis()->GetXmin(),
773 fBinHist->GetYaxis()->GetXmax());
774 fHist->Add(fBinHist);
775 }
776 // delete in anycase fBinHist also when fHist is zero (i.e when it has been deleted)
777 delete fBinHist;
778 fBinHist = 0;
779 if (fGedEditor->GetPad()) {
780 fGedEditor->GetPad()->Modified();
781 fGedEditor->GetPad()->Update();
782 }
783 }
784
785 fHist = (TH2*) obj;
786
787 const char *text = fHist->GetTitle();
788 fTitle->SetText(text);
789 TString str = GetDrawOption();
791 str.ToUpper();
792
793 if (str == "") {
794 // default options = Scatter-Plot
795 ShowFrame(f6);
796 HideFrame(f9);
797 HideFrame(f12);
798 HideFrame(f13);
799 HideFrame(f38);
800 fDimGroup->SetButton(kDIM_SIMPLE, kTRUE);
801 fDimGroup->SetButton(kDIM_COMPLEX, kFALSE);
802 if (fTypeCombo->GetSelected()==-1) fTypeCombo->Select(kTYPE_LEGO);
803 if (fCoordsCombo->GetSelected()==-1) fCoordsCombo->Select(kCOORDS_CAR);
804 if (fContCombo->GetSelected()==-1) fContCombo->Select(kCONT_NONE);
805
806 fAddArr->SetState(kButtonUp);
807 fAddBox->SetState(kButtonUp);
808 fAddCol->SetState(kButtonUp);
809 fAddScat->SetState(kButtonDisabled);
810 fAddText->SetState(kButtonUp);
811 fAddError->SetState(kButtonUp);
812 fAddPalette->SetState(kButtonDisabled);
813 fAddPalette1->SetState(kButtonUp);
814 fAddFB->SetState(kButtonDown);
815 fAddBB->SetState(kButtonDown);
816 } else if (!str.Contains("LEGO") && !str.Contains("SURF")) {
817 ShowFrame(f6);
818 HideFrame(f9);
819 HideFrame(f12);
820 HideFrame(f13);
821 HideFrame(f38);
822 fDimGroup->SetButton(kDIM_SIMPLE, kTRUE);
823 fDimGroup->SetButton(kDIM_COMPLEX, kFALSE);
824 if (fTypeCombo->GetSelected()==-1) fTypeCombo->Select(kTYPE_LEGO);
825 if (fCoordsCombo->GetSelected()==-1) fCoordsCombo->Select(kCOORDS_CAR);
826 if (str.Contains("CONT")){
827 if (str.Contains("CONT1")) fContCombo->Select(kCONT_1);
828 else if (str.Contains("CONT2")) fContCombo->Select(kCONT_2);
829 else if (str.Contains("CONT3")) fContCombo->Select(kCONT_3);
830 else if (str.Contains("CONT4")) fContCombo->Select(kCONT_4);
831 else if (str.Contains("CONT0") || str.Contains("CONT"))
832 fContCombo->Select(kCONT_0);
833 } else fContCombo->Select(kCONT_NONE);
834
835 if (str.Contains("ARR")) fAddArr->SetState(kButtonDown);
836 else fAddArr->SetState(kButtonUp);
837 if (str.Contains("BOX")) fAddBox->SetState(kButtonDown);
838 else fAddBox->SetState(kButtonUp);
839 if (str.Contains("COL")) fAddCol->SetState(kButtonDown);
840 else fAddCol->SetState(kButtonUp);
841 if (str.Contains("SCAT")) {
842 if (str=="SCAT") fAddScat->SetState(kButtonDisabled);
843 else fAddScat->SetState(kButtonDown);
844 } else fAddScat->SetState(kButtonUp);
845 if (str.Contains("TEXT")) fAddText->SetState(kButtonDown);
846 else fAddText->SetState(kButtonUp);
847
848 fAddError->SetState(kButtonUp);
849 if (str.Contains("COL") || (str.Contains("CONT") &&
850 !str.Contains("CONT2") && !str.Contains("CONT3"))) {
851 if (str.Contains("Z")) fAddPalette->SetState(kButtonDown);
852 else fAddPalette->SetState(kButtonUp);
853 } else fAddPalette->SetState(kButtonDisabled);
854 fAddPalette1->SetState(kButtonUp);
855 fAddFB->SetState(kButtonDown);
856 fAddBB->SetState(kButtonDown);
857
858 } else if (str.Contains("LEGO") || str.Contains("SURF")) {
859 HideFrame(f6);
860 ShowFrame(f9);
861 ShowFrame(f12);
862 ShowFrame(f13);
863 ShowFrame(f38);
864 fDimGroup->SetButton(kDIM_COMPLEX, kTRUE);
865 fDimGroup->SetButton(kDIM_SIMPLE, kFALSE);
866 if (str.Contains("LEGO4")) fTypeCombo->Select(kTYPE_LEGO4);
867 else if (str.Contains("LEGO3")) fTypeCombo->Select(kTYPE_LEGO3);
868 else if (str.Contains("LEGO2")) fTypeCombo->Select(kTYPE_LEGO2);
869 else if (str.Contains("LEGO1")) fTypeCombo->Select(kTYPE_LEGO1);
870 else if (str.Contains("LEGO")) fTypeCombo->Select(kTYPE_LEGO);
871 else if (str.Contains("SURF5")) fTypeCombo->Select(kTYPE_SURF5);
872 else if (str.Contains("SURF4")) fTypeCombo->Select(kTYPE_SURF4);
873 else if (str.Contains("SURF3")) fTypeCombo->Select(kTYPE_SURF3);
874 else if (str.Contains("SURF2")) fTypeCombo->Select(kTYPE_SURF2);
875 else if (str.Contains("SURF1")) fTypeCombo->Select(kTYPE_SURF1);
876 else if (str.Contains("SURF")) fTypeCombo->Select(kTYPE_SURF);
877
878
879 if (str.Contains("CYL")) fCoordsCombo->Select(kCOORDS_CYL);
880 else if (str.Contains("POL")) fCoordsCombo->Select(kCOORDS_POL);
881 else if (str.Contains("SPH")) fCoordsCombo->Select(kCOORDS_SPH);
882 else if (str.Contains("PSR")) fCoordsCombo->Select(kCOORDS_PSR);
883 else fCoordsCombo->Select(kCOORDS_CAR); //default
884
885 if (fContCombo->GetSelected()==-1) fContCombo->Select(kCONT_NONE);
886 fAddArr->SetState(kButtonUp);
887 fAddBox->SetState(kButtonUp);
888 fAddCol->SetState(kButtonUp);
889 fAddScat->SetState(kButtonDisabled);
890 fAddText->SetState(kButtonUp);
891
892 if (fCoordsCombo->GetSelected()!=kCOORDS_CAR) {
893 if (fAddFB->GetState()!=kButtonDisabled)
894 fAddFB->SetState(kButtonDisabled);
895 if (fAddBB->GetState()!=kButtonDisabled)
896 fAddBB->SetState(kButtonDisabled);
897 if (fAddError->GetState()!=kButtonDisabled)
898 fAddError->SetState(kButtonDisabled);
899 } else {
900 if (str.Contains("FB")) fAddFB->SetState(kButtonUp);
901 else fAddFB->SetState(kButtonDown);
902 if (str.Contains("BB")) fAddBB->SetState(kButtonUp);
903 else fAddBB->SetState(kButtonDown);
904 if (str.Contains("E")){
905 TString dum = str;
906 if (str.Contains("LEGO"))
907 dum.Remove(strstr(dum.Data(),"LEGO")-dum.Data(),4);
908 if (str.Contains("TEXT"))
909 dum.Remove(strstr(dum.Data(),"TEXT")-dum.Data(),4);
910 if (dum.Contains("E")) fAddError->SetState(kButtonDown);
911 else fAddError->SetState(kButtonUp);
912 } else fAddError->SetState(kButtonUp);
913 }
914 if ((fTypeCombo->GetSelected()==kTYPE_LEGO) ||
915 (fTypeCombo->GetSelected()==kTYPE_LEGO1)||
916 (fTypeCombo->GetSelected()==kTYPE_LEGO3)||
917 (fTypeCombo->GetSelected()==kTYPE_LEGO4)||
918 (fTypeCombo->GetSelected()==kTYPE_SURF) ||
919 (fTypeCombo->GetSelected()==kTYPE_SURF4))
920 fAddPalette1->SetState(kButtonDisabled);
921 else if (str.Contains("Z")) fAddPalette1->SetState(kButtonDown);
922 else fAddPalette1->SetState(kButtonUp);
923 }
924
925 fBarWidth->SetNumber(fHist->GetBarWidth());
926 fBarOffset->SetNumber(fHist->GetBarOffset());
927
928 Int_t nx = fHist -> GetXaxis() -> GetNbins();
929 Int_t nxbinmin = fHist -> GetXaxis() -> GetFirst();
930 Int_t nxbinmax = fHist -> GetXaxis() -> GetLast();
931 fSliderX->SetRange(1,nx);
932 fSliderX->SetPosition((Double_t)nxbinmin,(Double_t)nxbinmax);
933 fSldXMin->SetNumber(fHist->GetXaxis()->GetBinLowEdge(nxbinmin));
934 fSldXMax->SetNumber(fHist->GetXaxis()->GetBinUpEdge(nxbinmax));
935
936 Int_t ny = fHist -> GetYaxis() -> GetNbins();
937 Int_t nybinmin = fHist -> GetYaxis() -> GetFirst();
938 Int_t nybinmax = fHist -> GetYaxis() -> GetLast();
939 fSliderY->SetRange(1,ny);
940 fSliderY->SetPosition((Double_t)nybinmin,(Double_t)nybinmax);
941 fSldYMin->SetNumber(fHist->GetYaxis()->GetBinLowEdge(nybinmin));
942 fSldYMax->SetNumber(fHist->GetYaxis()->GetBinUpEdge(nybinmax));
943
944 if (fDelaydraw->GetState()!=kButtonDown) fDelaydraw->SetState(kButtonUp);
945
946 if (str.Contains("COL") || fContCombo->GetSelected()!= kCONT_NONE)
947 fColContLbl->Enable() ;
948 else fColContLbl->Disable();
949
950 if (str.Contains("LEGO2") || str.Contains("SURF1") ||
951 str.Contains("SURF2") || str.Contains("SURF3") ||
952 str.Contains("SURF5")) fColContLbl1->Enable();
953 else fColContLbl1->Disable();
954
955 fContLevels->SetIntNumber(fHist->GetContour());
956 fContLevels1->SetIntNumber(fHist->GetContour());
957
958 fFrameColor->SetColor(TColor::Number2Pixel(fGedEditor->GetPad()->GetFrameFillColor()));
959 fFramePattern->SetPattern(fGedEditor->GetPad()->GetFrameFillStyle());
960
962
963
964 // Check if histogram is from ntupla/tree or not.
965 // If it is a standard histogram or a ntupla based histogram
966 // show a different frame in case of rebinning (fBinCont) with sliders and bin number entries
967 // connected to different methods.
968 // For example the entry field fBinXNumberEntry is connected to
969 // the method DoBinLabel in case of non-ntupla histograms which just call Th1::Rebin
970 // In csae of a tree based histogram the entry field fBinNumberEntry1 is used which is connected to
971 // TH1Editor::DoBinLabel1 which is re-filling the histograms with the cached values from the TTreePlayer.
972 // Since the actual number of histogram entry can be larger than the cache size of the TTreePlayer
973 // (see JIRA ROOT-5900 or http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=17107 )
974 // the GUI frame based on a non-tupla histogram is used when the number of entries of the histogram is
975 // not the same as the number of filled entries in the TTreePlayer object.
976
977 if (!player || player->GetHistogram()!=fHist ||
978 fHist->GetEntries() != player->GetNfill()) {
979 Int_t n1 = 0, n2 =0;
980 Int_t upx =0, upy =0;
981 if (fBinHist) n1 = fBinHist->GetXaxis()->GetNbins();
982 else n1 = nx;
983 if (fBinHist) n2 = fBinHist->GetYaxis()->GetNbins();
984 else n2 = ny;
985 fBin->HideFrame(fBinXCont1);
986 fBin->ShowFrame(fBinXCont);
987 fBin->HideFrame(fBinYCont1);
988 if (n1 < 1) n1 = 1;
989 if (n2 < 1) n2 = 1;
990 Int_t* divx = Dividers(n1);
991 Int_t* divy = Dividers(n2);
992 if (divx[0]-1 <= 1) upx = 2;
993 else upx = divx[0]-1;
994 fBinXSlider->SetRange(1,upx);
995 if (divy[0]-1 <= 1) upy = 2;
996 else upy = divy[0]-1;
997 fBinYSlider->SetRange(1,upy);
998 Int_t i = 1; Int_t j = 1;
999 if (fBinXSlider->GetMaxPosition()==2 && fBinXSlider->GetPosition()==2)
1000 fBinXSlider->SetPosition(2);
1001 else {
1002 while ( divx[i] != nx) i ++;
1003 fBinXSlider->SetPosition(divx[0] - i + 1);
1004 }
1005 if (fBinYSlider->GetMaxPosition()==2 && fBinYSlider->GetPosition()==2)
1006 fBinYSlider->SetPosition(2);
1007 else {
1008 while ( divy [j] != ny) j ++;
1009 fBinYSlider->SetPosition(divy[0] - j + 1);
1010 }
1012 fBinXNumberEntry->SetIntNumber(nx);
1014 fBinYNumberEntry->SetIntNumber(ny);
1015 delete [] divx;
1016 delete [] divy;
1017 }
1018 else if (player && fHist==player->GetHistogram() && fHist->GetEntries() == player->GetNfill()) {
1019 fBin->HideFrame(fBinXCont);
1020 fBin->ShowFrame(fBinXCont1);
1021 fBin->ShowFrame(fBinYCont1);
1022 fBinXSlider1->SetPosition(5);
1024 fBinXNumberEntry1->SetIntNumber(nxbinmax-nxbinmin+1);
1025 fBinYSlider1->SetPosition(5);
1027 fBinYNumberEntry1->SetIntNumber(nybinmax-nybinmin+1);
1028 }
1029
1031 fHist->GetXaxis()->GetBinWidth(1));
1033 fHist->GetYaxis()->GetBinWidth(1));
1034 if (!fGedEditor->GetTab()->IsEnabled(fGedEditor->GetTab()->GetCurrent())) fGedEditor->GetTab()->SetTab(0);
1035
1037 fGedEditor->GetTab()->SetEnabled(1, kTRUE);
1039
1040}
1041
1042////////////////////////////////////////////////////////////////////////////////
1043/// Slot connected to the histogram title setting.
1044
1045void TH2Editor::DoTitle(const char *text)
1046{
1047 if (fAvoidSignal) return;
1048 fHist->SetTitle(text);
1049 Update();
1050}
1051
1052////////////////////////////////////////////////////////////////////////////////
1053/// Slot connected to the 'Plot' button group.
1054
1056{
1057 if (gPad && gPad->GetVirtCanvas()) gPad->GetVirtCanvas()->SetCursor(kWatch);
1058 gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kWatch));
1059
1060 if (fDim->GetState() == kButtonDown)
1061 DoHistSimple();
1062 else
1063 DoHistComplex();
1064
1065 if (gPad && gPad->GetVirtCanvas()) gPad->GetVirtCanvas()->SetCursor(kPointer);
1066 gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kPointer));
1067}
1068
1069////////////////////////////////////////////////////////////////////////////////
1070/// Slot connected to the 2D-Plot radio button.
1071
1073{
1074 if (fAvoidSignal) return;
1075 TString str = "";
1076 ShowFrame(f6);
1077 HideFrame(f9);
1078 HideFrame(f12);
1079 HideFrame(f13);
1080 HideFrame(f38);
1081 if (fContCombo->GetSelected()==-1)
1082 fContCombo->Select(kCONT_NONE);
1083 if ((fContCombo->GetSelected()!= kCONT_NONE) &&
1084 fAddPalette->GetState()==kButtonDisabled)
1085 fAddPalette->SetState(kButtonUp);
1086
1088 if (str=="" || str=="SCAT" || str==fCutString) {
1089 fAddScat->SetState(kButtonDisabled);
1090 fAddPalette->SetState(kButtonDisabled);
1091 } else if (fAddScat->GetState()==kButtonDisabled)
1092 fAddScat->SetState(kButtonUp);
1093 if (str.Contains("COL") || fContCombo->GetSelected()!= kCONT_NONE)
1094 fColContLbl->Enable();
1095 else fColContLbl->Disable();
1096
1097 ((TGMainFrame*)GetMainFrame())->Layout();
1098
1099 TString ocut = fCutString;
1100 ocut.ToUpper();
1101 if (!str.Contains(fCutString) && !str.Contains(ocut))
1102 str+=fCutString;
1103 SetDrawOption(str);
1104 Update();
1105}
1106
1107////////////////////////////////////////////////////////////////////////////////
1108/// Slot connected to the 3D-Plot radio button.
1109
1111{
1112 if (fAvoidSignal) return;
1113 TString str = "";
1114 HideFrame(f6);
1115 ShowFrame(f9);
1116 ShowFrame(f38);
1117 if (GetHistTypeLabel().Contains("LEGO")) {
1118 ShowFrame(f12);
1119 ShowFrame(f13);
1120 } else {
1121 HideFrame(f12);
1122 HideFrame(f13);
1123 }
1124 if (fTypeCombo->GetSelected()==-1) fTypeCombo->Select(kTYPE_LEGO);
1125 if (fCoordsCombo->GetSelected()==-1) fCoordsCombo->Select(kCOORDS_CAR);
1126
1128
1129 if (str.Contains("LEGO2") || str.Contains("SURF1") ||
1130 str.Contains("SURF2") || str.Contains("SURF3") ||
1131 str.Contains("SURF5")) {
1132 fColContLbl1->Enable();
1133 if (fAddPalette1->GetState()==kButtonDisabled)
1134 fAddPalette1->SetState(kButtonUp);
1135 } else {
1136 fColContLbl1->Disable();
1137 fAddPalette1->SetState(kButtonDisabled);
1138 }
1139
1140 ((TGMainFrame*)GetMainFrame())->Layout();
1141
1142 TString ocut = fCutString;
1143 ocut.ToUpper();
1144 if (!str.Contains(fCutString) && !str.Contains(ocut))
1145 str+=fCutString;
1146 SetDrawOption(str);
1147 Update();
1148}
1149
1150////////////////////////////////////////////////////////////////////////////////
1151/// Slot connected to histogram type, coordinate system, contour combo box.
1152
1154{
1155 if (fAvoidSignal) return;
1156 TString str = "";
1157 if (fDim->GetState() == kButtonDown) {
1159 if ((fContCombo->GetSelected()!=kCONT_NONE &&
1160 fContCombo->GetSelected()!=kCONT_2 &&
1161 fContCombo->GetSelected()!=kCONT_3) || str.Contains("COL")) {
1162
1163 if (str.Contains("Z")) fAddPalette->SetState(kButtonDown);
1164 else fAddPalette->SetState(kButtonUp);
1165 } else fAddPalette->SetState(kButtonDisabled);
1166 if (str=="" || str=="SCAT" || str==fCutString) {
1167 fAddScat->SetState(kButtonDisabled);
1168 fAddPalette->SetState(kButtonDisabled);
1169 } else if (fAddScat->GetState()==kButtonDisabled)
1170 fAddScat->SetState(kButtonUp);
1172 if (str.Contains("COL") || fContCombo->GetSelected()!= kCONT_NONE)
1173 fColContLbl->Enable();
1174 else
1175 fColContLbl->Disable();
1176
1177 } else if (fDim0->GetState() == kButtonDown) {
1178 if (fCoordsCombo->GetSelected()!=kCOORDS_CAR) {
1179 if (fAddFB->GetState()!=kButtonDisabled)
1180 fAddFB->SetState(kButtonDisabled);
1181 if (fAddBB->GetState()!=kButtonDisabled)
1182 fAddBB->SetState(kButtonDisabled);
1183 if (fAddError->GetState()!=kButtonDisabled)
1184 fAddError->SetState(kButtonDisabled);
1185 } else {
1186 if (fAddFB->GetState()==kButtonDisabled)
1187 fAddFB->SetState(kButtonDown);
1188 if (fAddBB->GetState()==kButtonDisabled)
1189 fAddBB->SetState(kButtonDown);
1190 if (fAddError->GetState()==kButtonDisabled)
1191 fAddError->SetState(kButtonUp);
1192 }
1193 if ((fTypeCombo->GetSelected()==kTYPE_LEGO) ||
1194 (fTypeCombo->GetSelected()==kTYPE_LEGO1)||
1195 (fTypeCombo->GetSelected()==kTYPE_LEGO3)||
1196 (fTypeCombo->GetSelected()==kTYPE_LEGO4)||
1197 (fTypeCombo->GetSelected()==kTYPE_SURF) ||
1198 (fTypeCombo->GetSelected()==kTYPE_SURF4))
1199 fAddPalette1->SetState(kButtonDisabled);
1200 else if (fAddPalette1->GetState()==kButtonDisabled)
1201 fAddPalette1->SetState(kButtonUp);
1202 if (GetHistTypeLabel().Contains("LEGO")) {
1203 ShowFrame(f12);
1204 ShowFrame(f13);
1205 } else {
1206 HideFrame(f12);
1207 HideFrame(f13);
1208 }
1209 ((TGMainFrame*)GetMainFrame())->Layout();
1211 if (str.Contains("LEGO2") || str.Contains("SURF1") ||
1212 str.Contains("SURF2") || str.Contains("SURF3") ||
1213 str.Contains("SURF5"))
1214 fColContLbl1->Enable();
1215 else
1216 fColContLbl1->Disable() ;
1217 }
1218
1219 TString ocut = fCutString;
1220 ocut.ToUpper();
1221 if (!str.Contains(fCutString) && !str.Contains(ocut))
1222 str+=fCutString;
1223 SetDrawOption(str);
1224 Update();
1225}
1226
1227////////////////////////////////////////////////////////////////////////////////
1228/// Slot connected to the "Arrow draw option" check button.
1229
1231{
1232 if (fAvoidSignal) return;
1233 Bool_t make=kFALSE;
1234 TString str = GetDrawOption();
1235 str.ToUpper();
1236
1237 if (on) {
1238 if (!str.Contains("ARR")) {
1239 str += "ARR";
1240 if (fAddScat->GetState()==kButtonDisabled)
1241 fAddScat->SetState(kButtonUp);
1242 make=kTRUE;
1243 }
1244 } else if (fAddArr->GetState()==kButtonUp) {
1245 if (str.Contains("ARR")) {
1246 str.Remove(strstr(str.Data(),"ARR")-str.Data(),3);
1247 if (str=="" || str=="SCAT" || str==fCutString) {
1248 fAddScat->SetState(kButtonDisabled);
1249 fAddPalette->SetState(kButtonDisabled);
1250 }
1251 make=kTRUE;
1252 }
1253 }
1254 if (make) {
1255 DoHistChanges();
1256 }
1257}
1258
1259////////////////////////////////////////////////////////////////////////////////
1260/// Slot connected to the "Box draw option" check button.
1261
1263{
1264 if (fAvoidSignal) return;
1265 Bool_t make=kFALSE;
1266 TString str = GetDrawOption();
1267 str.ToUpper();
1268
1269 if (on) {
1270 if (!str.Contains("BOX")) {
1271 str += "BOX";
1272 if (fAddScat->GetState()==kButtonDisabled)
1273 fAddScat->SetState(kButtonUp);
1274 make=kTRUE;
1275 }
1276 } else if (fAddBox->GetState()==kButtonUp) {
1277 if (str.Contains("BOX")) {
1278 str.Remove(strstr(str.Data(),"BOX")-str.Data(),3);
1279 if (str=="" || str=="SCAT" || str==fCutString) {
1280 fAddScat->SetState(kButtonDisabled);
1281 fAddPalette->SetState(kButtonDisabled);
1282 }
1283 make=kTRUE;
1284 }
1285 }
1286 if (make) {
1287 DoHistChanges();
1288 }
1289}
1290
1291////////////////////////////////////////////////////////////////////////////////
1292/// Slot connected to the "Col draw option" check button.
1293
1295{
1296 if (fAvoidSignal) return;
1297 Bool_t make=kFALSE;
1298 TString str = GetDrawOption();
1299 str.ToUpper();
1300
1301 if (on) {
1302 if (!str.Contains("COL")) {
1303 str += "COL";
1304 fColContLbl->Enable() ;
1305 if (fAddScat->GetState()==kButtonDisabled)
1306 fAddScat->SetState(kButtonUp);
1307 if (fAddPalette->GetState()==kButtonDisabled)
1308 fAddPalette->SetState(kButtonUp);
1309 make=kTRUE;
1310 }
1311 } else if (fAddCol->GetState()==kButtonUp) {
1312 if (str.Contains("COL")) {
1313 str.Remove(strstr(str.Data(),"COL")-str.Data(),3);
1314 if (fAddBox->GetState()==kButtonDisabled)
1315 fAddBox->SetState(kButtonUp);
1316 if (fContCombo->GetSelected()==kCONT_NONE) {
1317 fAddPalette->SetState(kButtonDisabled);
1318 if (str.Contains("Z"))
1319 str.Remove(strstr(str.Data(),"Z")-str.Data(),1);
1320 }
1321 if (str=="" || str=="SCAT" || str==fCutString)
1322 fAddScat->SetState(kButtonDisabled);
1323 if (fContCombo->GetSelected()!= kCONT_NONE)
1324 fColContLbl->Enable() ;
1325 else fColContLbl->Disable();
1326 make=kTRUE;
1327 }
1328 }
1329 if (make) {
1330 DoHistChanges();
1331 }
1332}
1333
1334////////////////////////////////////////////////////////////////////////////////
1335/// Slot connected to the "Scat draw option" check button.
1336
1338{
1339 if (fAvoidSignal) return;
1340 Bool_t make=kFALSE;
1341 TString str = GetDrawOption();
1342 str.ToUpper();
1343
1344 if (on) {
1345 if (!str.Contains("SCAT")) {
1346 str += "SCAT";
1347 make=kTRUE;
1348 }
1349 } else if (fAddScat->GetState()==kButtonUp) {
1350 if (str.Contains("SCAT")) {
1351 str.Remove(strstr(str.Data(),"SCAT")-str.Data(),4);
1352 make=kTRUE;
1353 }
1354 }
1355 if (make) {
1356 DoHistChanges();
1357 }
1358}
1359
1360////////////////////////////////////////////////////////////////////////////////
1361/// Slot connected to the "Text draw option" check button.
1362
1364{
1365 if (fAvoidSignal) return;
1366 Bool_t make=kFALSE;
1367 TString str = GetDrawOption();
1368 str.ToUpper();
1369
1370 if (on) {
1371 if (!str.Contains("TEXT")) {
1372 str += "TEXT";
1373 if (fAddScat->GetState()==kButtonDisabled)
1374 fAddScat->SetState(kButtonUp);
1375 make=kTRUE;
1376 }
1377 } else if (fAddText->GetState()==kButtonUp) {
1378 if (str.Contains("TEXT")) {
1379 str.Remove(strstr(str.Data(),"TEXT")-str.Data(),4);
1380 if (str=="" || str=="SCAT" || str==fCutString)
1381 fAddScat->SetState(kButtonDisabled);
1382 make=kTRUE;
1383 }
1384 }
1385 if (make) {
1386 DoHistChanges();
1387 // next line is needed for marker editor refresh
1388 fGedEditor->GetCanvas()->Selected(fGedEditor->GetPad(), fHist, 1);
1389 }
1390}
1391
1392////////////////////////////////////////////////////////////////////////////////
1393/// Slot connected to the "Error" check button.
1394
1396{
1397 if (fAvoidSignal) return;
1398 Bool_t make=kFALSE;
1399 TString str = GetDrawOption();
1400 str.ToUpper();
1401
1402 TString dum = str;
1403 if (str.Contains("LEGO"))
1404 dum.Remove(strstr(dum.Data(),"LEGO")-dum.Data(),4);
1405 if (str.Contains("TEXT"))
1406 dum.Remove(strstr(dum.Data(),"TEXT")-dum.Data(),4);
1407 if (on) {
1408 if (!dum.Contains("E")) {
1409 str += "E";
1410 make=kTRUE;
1411 }
1412 } else if (fAddError->GetState() == kButtonUp) {
1413 if (str.Contains("E")) {
1414 if (fDim->GetState() == kButtonDown)
1416 else
1419 make=kTRUE;
1420 }
1421 }
1422 if (make) {
1423 DoHistChanges();
1424 }
1425}
1426
1427////////////////////////////////////////////////////////////////////////////////
1428/// Slot connected to the color palette check button.
1429
1431{
1432 if (fAvoidSignal) return;
1433 Bool_t make=kFALSE;
1434 TString str = GetDrawOption();
1435 str.ToUpper();
1436
1437 if (on) {
1438 if (!str.Contains("Z")) {
1439 str += "Z";
1440 make=kTRUE;
1441 }
1442 } else if (fAddPalette->GetState()==kButtonUp ||
1443 fAddPalette1->GetState()==kButtonUp) {
1444 if (str.Contains("Z")) {
1445 str.Remove(strstr(str.Data(),"Z")-str.Data(),1);
1446 make=kTRUE;
1447 }
1448 }
1449 if (make) {
1450 DoHistChanges();
1451 }
1452}
1453
1454////////////////////////////////////////////////////////////////////////////////
1455/// Slot connected to the "FB front-box draw option" check button.
1456
1458{
1459 if (fAvoidSignal) return;
1460 Bool_t make=kFALSE;
1461 TString str = GetDrawOption();
1462 str.ToUpper();
1463
1464 if (fAddFB->GetState()==kButtonDown) {
1465 if (str.Contains("FB")) {
1466 if (str.Contains("SURF") && !(str.Contains("1") ||
1467 str.Contains("2") || str.Contains("3") ||
1468 str.Contains("4") || str.Contains("5"))) {
1469 TString dum = str;
1470 dum.Remove(strstr(dum.Data(),"SURF")-dum.Data(),4);
1471 if (dum.Contains("FB"))
1472 dum.Remove(strstr(dum.Data(),"FB")-dum.Data(),2);
1473 str = "SURF" + dum;
1474 } else str.Remove(strstr(str.Data(),"FB")-str.Data(),2);
1475 make = kTRUE;
1476 }
1477 } else if (fAddFB->GetState()==kButtonUp){
1478 if (!str.Contains("FB")) {
1479 str += "FB";
1480 make=kTRUE;
1481 }
1482 }
1483 if (make) {
1484 DoHistChanges();
1485 }
1486}
1487
1488////////////////////////////////////////////////////////////////////////////////
1489/// Slot connected to the "BB back-box draw option" check button.
1490
1492{
1493 if (fAvoidSignal) return;
1494 Bool_t make=kFALSE;
1495 TString str = GetDrawOption();
1496 str.ToUpper();
1497
1498 if (fAddBB->GetState()==kButtonDown) {
1499 if (str.Contains("BB")) {
1500 if (str.Contains("FB")) {
1501 TString dum = str;
1502 dum.Remove(strstr(dum.Data(),"FB")-dum.Data(),2);
1503 dum.Remove(strstr(dum.Data(),"BB")-dum.Data(),2);
1504 str=dum+"FB";
1505 } else str.Remove(strstr(str.Data(),"BB")-str.Data(),2);
1506 make = kTRUE;
1507 }
1508 } else if (fAddBB->GetState()==kButtonUp){
1509 if (!str.Contains("BB")) {
1510 str += "BB";
1511 make=kTRUE;
1512 }
1513 }
1514 if (make) {
1515 DoHistChanges();
1516 }
1517}
1518
1519////////////////////////////////////////////////////////////////////////////////
1520/// Slot connected to the contour level number entry fContLevels.
1521
1523{
1524 if (fAvoidSignal) return;
1525 fHist->SetContour((Int_t)fContLevels->GetNumber());
1526 fContLevels1->SetNumber((Int_t)fContLevels->GetNumber());
1527 Update();
1528}
1529
1530////////////////////////////////////////////////////////////////////////////////
1531/// Slot connected to the contour level number entry fContLevels1.
1532
1534{
1535 if (fAvoidSignal) return;
1536 fHist->SetContour((Int_t)fContLevels1->GetNumber());
1537 fContLevels->SetNumber((Int_t)fContLevels1->GetNumber());
1538 Update();
1539}
1540
1541////////////////////////////////////////////////////////////////////////////////
1542/// Slot connected to the bar width of the bar chart.
1543
1545{
1546 if (fAvoidSignal) return;
1547 fHist->SetBarWidth(fBarWidth->GetNumber());
1548 Update();
1549}
1550
1551////////////////////////////////////////////////////////////////////////////////
1552/// Slot connected to the bar offset of the bar chart.
1553
1555{
1556 if (fAvoidSignal) return;
1557 fHist->SetBarOffset((Float_t)fBarOffset->GetNumber());
1558 Update();
1559}
1560
1561////////////////////////////////////////////////////////////////////////////////
1562/// Slot connected to the rebin slider in case of no ntuple histogram.
1563/// It updates some other widgets related to the rebin slider.
1564
1566{
1567 // Draw the rebinned histogram in case of the delay draw mode
1568 if (fAvoidSignal) return;
1569 if (fDelaydraw->GetState()==kButtonDown){
1570 if (!fBinHist) {
1571 fBinHist = (TH2*)fHist->Clone("BinHist");
1572 fBinHist->SetDirectory(0); // TH2Editor manages this histogram
1573 }
1574 Int_t nx = fBinHist->GetXaxis()->GetNbins();
1575 Int_t ny = fBinHist->GetYaxis()->GetNbins();
1576 Int_t numx = fBinXSlider->GetPosition();
1577 Int_t numy = fBinYSlider->GetPosition();
1578 Int_t* divx = Dividers(nx);
1579 Int_t* divy = Dividers(ny);
1580 if (divx[0]==2) fBinXSlider->SetPosition(2);
1581 if (divy[0]==2) fBinYSlider->SetPosition(2);
1582 if (divx[0]==2 && divy[0]==2) {
1583 delete [] divx;
1584 delete [] divy;
1585 return;
1586 }
1587 // delete the histogram which is on the screen
1588 fGedEditor->GetPad()->cd();
1589 fHist->Reset();
1590 fHist->SetBins(nx,fBinHist->GetXaxis()->GetXmin(),
1591 fBinHist->GetXaxis()->GetXmax(),
1592 ny,fBinHist->GetYaxis()->GetXmin(),
1593 fBinHist->GetYaxis()->GetXmax());
1594 fHist->Add(fBinHist);
1595 fHist->SetCanExtend(TH1::kNoAxis);
1596 fHist->Rebin2D(divx[numx], divy[numy]);
1597
1598 //fModel=fHist;
1599
1600 if (divx[0]!=2) {
1601 TAxis* xaxis = fHist->GetXaxis();
1602 Double_t xBinWidth = xaxis->GetBinWidth(1);
1603 xaxis->SetRangeUser(fSldXMin->GetNumber()+xBinWidth/2,
1604 fSldXMax->GetNumber()-xBinWidth/2);
1605 fSliderX->SetRange(1,(Int_t)nx/divx[numx]);
1606 fSliderX->SetPosition(xaxis->FindBin(fSldXMin->GetNumber()+xBinWidth/2),
1607 xaxis->FindBin(fSldXMax->GetNumber()-xBinWidth/2));
1608 // the axis range could be changed a little bit by the Rebin algorithm
1609 fSldXMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
1610 fSldXMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
1611 }
1612 if (divy[0]!=2) {
1613 TAxis* yaxis = fHist->GetYaxis();
1614 Double_t yBinWidth = yaxis->GetBinWidth(1);
1615 yaxis->SetRangeUser(fSldYMin->GetNumber()+yBinWidth/2,
1616 fSldYMax->GetNumber()-yBinWidth/2);
1617 fSliderY->SetRange(1,(Int_t)ny/divy[numy]);
1618 fSliderY->SetPosition(yaxis->FindBin(fSldYMin->GetNumber()+yBinWidth/2),
1619 yaxis->FindBin(fSldYMax->GetNumber()-yBinWidth/2));
1620 fSldYMin->SetNumber(yaxis->GetBinLowEdge(yaxis->GetFirst()));
1621 fSldYMax->SetNumber(yaxis->GetBinUpEdge(yaxis->GetLast()));
1622 }
1623 if (fCancel->GetState()==kButtonDisabled) fCancel->SetState(kButtonUp);
1624 if (fApply->GetState()==kButtonDisabled) fApply->SetState(kButtonUp);
1625 Update();
1626 delete [] divx;
1627 delete [] divy;
1628 }
1629// fGedEditor->GetPad()->GetCanvas()->Selected(fGedEditor->GetPad(), fHist, 0);
1630 // fModel = fHist;
1631 Refresh(fHist);
1632}
1633
1634////////////////////////////////////////////////////////////////////////////////
1635/// Slot connected to the rebin slider in case of no ntuple histogram.
1636
1638{
1639 if (fAvoidSignal) return;
1640 Int_t* divx = Dividers(fHist->GetXaxis()->GetNbins());
1641 Int_t* divy = Dividers(fHist->GetYaxis()->GetNbins());
1642 if (divx[0]==2 && divy[0]==2 && !fBinHist)
1643 new TGMsgBox(fClient->GetDefaultRoot(), this->GetMainFrame(),
1644 "TH2Editor", "It is not possible to rebin the histogram",
1646 // calling the MessageBox again does NOT work!*/
1647 delete [] divx;
1648 delete [] divy;
1649}
1650
1651////////////////////////////////////////////////////////////////////////////////
1652/// Slot connected to the rebin sliders in case of no ntuple histogram
1653/// does the rebinning of the selected histogram.
1654
1656{
1657 // create a clone in the background, when the slider is moved for 1st time
1658 if (fAvoidSignal) return;
1659 if (!fBinHist /*&& fDelaydraw->GetState()!=kButtonDown*/) {
1660 Int_t* divx = Dividers(fHist->GetXaxis()->GetNbins());
1661 Int_t* divy = Dividers(fHist->GetYaxis()->GetNbins());
1662 // if there is nothing to rebin:
1663 if (divx[0]==2 && divy[0]==2) {
1664 delete [] divx;
1665 delete [] divy;
1666 return;
1667 }
1668 fBinHist = (TH2*)fHist->Clone("BinHist");
1669 fBinHist->SetDirectory(0); // TH2Editor manages this histogram
1670 delete [] divx;
1671 delete [] divy;
1672 }
1673 // if the slider already has been moved and the clone is saved
1674 Int_t nx = fBinHist->GetXaxis()->GetNbins();
1675 Int_t ny = fBinHist->GetYaxis()->GetNbins();
1676 Int_t numx = fBinXSlider->GetPosition();
1677 Int_t numy = fBinYSlider->GetPosition();
1678 if (nx < 1 || ny < 1) return;
1679 Int_t* divx = Dividers(nx);
1680 Int_t* divy = Dividers(ny);
1681 if (divx[0]==2) {
1682 fBinXSlider->SetPosition(2);
1683 numx=1;
1684 }
1685 if (divy[0]==2) {
1686 fBinYSlider->SetPosition(2);
1687 numy=1;
1688 }
1689 Int_t maxx = (Int_t)nx/divx[numx];
1690 Int_t maxy = (Int_t)ny/divy[numy];
1691 if (maxx==1) maxx=2;
1692 if (maxy==1) maxy=2;
1693 if (fDelaydraw->GetState()==kButtonUp){
1694 // delete the histogram which is on the screen
1695 fGedEditor->GetPad()->cd();
1696 fHist->Reset();
1697 fHist->SetBins(nx,fBinHist->GetXaxis()->GetXmin(),
1698 fBinHist->GetXaxis()->GetXmax(),
1699 ny,fBinHist->GetYaxis()->GetXmin(),
1700 fBinHist->GetYaxis()->GetXmax());
1701 fHist->Add(fBinHist);
1702 fHist->SetCanExtend(TH1::kNoAxis);
1703 fHist->Rebin2D(divx[numx], divy[numy]);
1704 //fModel=fHist;
1705 if (divx[0]!=2) {
1706 TAxis* xaxis = fHist->GetXaxis();
1707 Double_t xBinWidth = xaxis->GetBinWidth(1);
1708 // if the user has zoomed into a special area the range will be reset:
1709 xaxis->SetRangeUser(fSldXMin->GetNumber()+xBinWidth/2,
1710 fSldXMax->GetNumber()-xBinWidth/2);
1711 fSliderX->SetRange(1,maxx);
1712 fSliderX->SetPosition(xaxis->FindBin(fSldXMin->GetNumber()+xBinWidth/2),
1713 xaxis->FindBin(fSldXMax->GetNumber()-xBinWidth/2));
1714 // the axis range could be changed a little bit by the Rebin algorithm
1715 fSldXMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
1716 fSldXMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
1717 fClient->NeedRedraw(fBinXSlider,kTRUE);
1718 }
1719 if (divy[0]!=2) {
1720 TAxis* yaxis = fHist->GetYaxis();
1721 Double_t yBinWidth = yaxis->GetBinWidth(1);
1722 yaxis->SetRangeUser(fSldYMin->GetNumber()+yBinWidth/2,
1723 fSldYMax->GetNumber()-yBinWidth/2);
1724 fSliderY->SetRange(1,maxy);
1725 fSliderY->SetPosition(yaxis->FindBin(fSldYMin->GetNumber()+yBinWidth/2),
1726 yaxis->FindBin(fSldYMax->GetNumber()-yBinWidth/2));
1727 fSldYMin->SetNumber(yaxis->GetBinLowEdge(yaxis->GetFirst()));
1728 fSldYMax->SetNumber(yaxis->GetBinUpEdge(yaxis->GetLast()));
1729 fClient->NeedRedraw(fBinYSlider,kTRUE);
1730 }
1731 Update();
1732 }
1733 // set the according NumberEntries
1734 if (fCancel->GetState()==kButtonDisabled)
1735 fCancel->SetState(kButtonUp);
1736 if (fApply->GetState()==kButtonDisabled)
1737 fApply->SetState(kButtonUp);
1738 fBinXNumberEntry->SetNumber(maxx);
1739 fBinYNumberEntry->SetNumber(maxy);
1740 delete [] divx;
1741 delete [] divy;
1742}
1743
1744////////////////////////////////////////////////////////////////////////////////
1745/// Slot connected to the Bin Number Entry for the Rebin.
1746
1748{
1749 if (fAvoidSignal) return;
1750 Int_t i;
1751 Int_t numx = (Int_t)(fBinXNumberEntry->GetNumber());
1752 Int_t numy = (Int_t)(fBinYNumberEntry->GetNumber());
1753 Int_t nx = 0;
1754 if (fBinHist) nx = fBinHist->GetXaxis()->GetNbins();
1755 else nx = fHist->GetXaxis()->GetNbins();
1756 Int_t ny = 0;
1757 if (fBinHist) ny = fBinHist->GetYaxis()->GetNbins();
1758 else ny = fHist->GetYaxis()->GetNbins();
1759 if (nx < 2 || ny < 2) return;
1760 // Get the divider of nx/ny which is closest to numx/numy
1761 Int_t *divx = Dividers(nx);
1762 Int_t *divy = Dividers(ny);
1763 Int_t diff = std::abs(numx - divx[1]);
1764 Int_t c = 1; Int_t d = 1;
1765 for (i = 2; i <= divx[0]; i++) {
1766 if ((std::abs(numx - divx[i])) < diff) {
1767 c = i;
1768 diff = std::abs(numx - divx[i]);
1769 }
1770 }
1771 diff = std::abs(numy - divy[1]);
1772 for (i = 2; i <= divy[0]; i++) {
1773 if ((std::abs(numy - divy[i])) < diff) {
1774 d = i;
1775 diff = std::abs(numy - divy[i]);
1776 }
1777 }
1778 if (divx[c]!= fHist->GetXaxis()->GetNbins() ||
1779 divy[d]!= fHist->GetYaxis()->GetNbins()) {
1780 fBinXNumberEntry->SetNumber(divx[c]);
1781 fBinXSlider->SetPosition(divx[0] - c +1);
1782 fBinYNumberEntry->SetNumber(divy[d]);
1783 fBinYSlider->SetPosition(divy[0] - d +1);
1784 if (fDelaydraw->GetState()==kButtonUp) DoBinMoved();
1785 else DoBinReleased();
1786 }
1787// fGedEditor->GetPad()->GetCanvas()->Selected(fGedEditor->GetPad(), fHist, 0);
1788// fModel = fHist;
1789 Refresh(fHist);
1790 delete [] divx;
1791 delete [] divy;
1792}
1793
1794////////////////////////////////////////////////////////////////////////////////
1795/// Slot connected to the Apply Button in the Rebinned histogram Window.
1796
1798{
1799 Int_t ret = 0;
1800 new TGMsgBox(fClient->GetDefaultRoot(), this->GetMainFrame(),
1801 "TH2 Editor", "Replace origin histogram with rebinned one?",
1803 if (ret==1) {
1804 if (fBinHist) {
1805 delete fBinHist;
1806 fBinHist = 0;
1807 }
1808 Int_t nx = fHist->GetXaxis()->GetNbins();
1809 Int_t ny = fHist->GetYaxis()->GetNbins();
1810 Int_t *divx = Dividers(nx);
1811 Int_t *divy = Dividers(ny);
1812 Int_t upx = 0, upy = 0;
1813 if (divx[0]-1 <= 1) upx = 2;
1814 else upx = divx[0]-1;
1815 if (divy[0]-1 <= 1) upy = 2;
1816 else upy = divy[0]-1;
1817 fBinXSlider->SetRange(1,upx);
1818 fBinYSlider->SetRange(1,upy);
1819 if (fBinXSlider->GetMaxPosition()==2 && divx[0]==2 )
1820 fBinXSlider->SetPosition(2);
1821 else fBinXSlider->SetPosition(1);
1822 if (fBinYSlider->GetMaxPosition()==2 && divy[0]==2 )
1823 fBinYSlider->SetPosition(2);
1824 else fBinYSlider->SetPosition(1);
1825 fCancel->SetState(kButtonDisabled);
1826 fApply->SetState(kButtonDisabled);
1827 Update();
1828 delete [] divx;
1829 delete [] divy;
1830 } else if (ret==2) DoCancel();
1831}
1832
1833////////////////////////////////////////////////////////////////////////////////
1834/// Slot connected to the Cancel Button in the Rebinned histogram Window.
1835
1837{
1838 if (fBinHist) {
1839 fGedEditor->GetPad()->cd();
1840 fHist->Reset();
1841 fHist->SetBins(fBinHist->GetXaxis()->GetNbins(),
1842 fBinHist->GetXaxis()->GetXmin(),
1843 fBinHist->GetXaxis()->GetXmax(),
1844 fBinHist->GetYaxis()->GetNbins(),
1845 fBinHist->GetYaxis()->GetXmin(),
1846 fBinHist->GetYaxis()->GetXmax());
1847 fHist->Add(fBinHist);
1848 fHist->GetXaxis()->SetRange(fBinHist->GetXaxis()->GetFirst(),
1849 fBinHist->GetXaxis()->GetLast());
1850 fHist->GetYaxis()->SetRange(fBinHist->GetYaxis()->GetFirst(),
1851 fBinHist->GetYaxis()->GetLast());
1852
1853 delete fBinHist;
1854 fBinHist = 0;
1855
1856 fCancel->SetState(kButtonDisabled);
1857 fApply->SetState(kButtonDisabled);
1858 Int_t* divx = Dividers(fHist->GetXaxis()->GetNbins());
1859 Int_t* divy = Dividers(fHist->GetYaxis()->GetNbins());
1860 if (divx[0]!=2) fBinXSlider->SetPosition(1);
1861 if (divy[0]!=2) fBinYSlider->SetPosition(1);
1862 // Consigning the new Histogram to all other Editors
1863// fGedEditor->GetPad()->GetCanvas()->Selected(fGedEditor->GetPad(), fHist, 0);
1864 Update();
1865 // fModel = fHist;
1866 Refresh(fHist);
1867 delete [] divx;
1868 delete [] divy;
1869 }
1870}
1871
1872
1873////////////////////////////////////////////////////////////////////////////////
1874/// Slot connected to the BinNumber Slider in case of a 'ntuple histogram'.
1875/// It does the rebin.
1876
1878{
1879 if (fAvoidSignal) return;
1880 Double_t oldXOffset = fXOffsetNumberEntry->GetNumber();
1881 Int_t xnumber = fBinXSlider1->GetPosition();
1882 Double_t oldYOffset = fYOffsetNumberEntry->GetNumber();
1883 Int_t ynumber = fBinYSlider1->GetPosition();
1884 if (xnumber==5 && ynumber==5) return;
1885 Int_t xfact = 0;
1886 Int_t yfact = 0;
1887 Int_t xBinNumber = 0;
1888 Int_t yBinNumber = 0;
1889 TAxis* xaxis = fHist->GetXaxis();
1890 TAxis* yaxis = fHist->GetYaxis();
1891 //"compute" the scaling factor:
1892 if (xnumber >= 5) xfact = xnumber - 4;
1893 else xfact = xnumber - 6;
1894 if (ynumber >= 5) yfact = ynumber - 4;
1895 else yfact = ynumber - 6;
1897 if (!player) return;
1898 Int_t nx = xaxis->GetNbins();
1899 Int_t ny = yaxis->GetNbins();
1900 Int_t firstx = xaxis->GetFirst();
1901 Int_t lastx = xaxis->GetLast();
1902 Int_t firsty = yaxis->GetFirst();
1903 Int_t lasty = yaxis->GetLast();
1904 Double_t minx = xaxis->GetBinLowEdge(1); // overall min in user coords
1905 Double_t maxx = xaxis->GetBinUpEdge(nx); // overall max in user coords
1906 Double_t miny = yaxis->GetBinLowEdge(1); // overall min in user coords
1907 Double_t maxy = yaxis->GetBinUpEdge(ny); // overall max in user coords
1908 Double_t rminx = xaxis->GetBinLowEdge(firstx); // recent min in user coords
1909 Double_t rmaxx = xaxis->GetBinUpEdge(lastx); // recent max in user coords
1910 Double_t rminy = yaxis->GetBinLowEdge(firsty); // recent min in user coords
1911 Double_t rmaxy = yaxis->GetBinUpEdge(lasty); // recent max in user coords
1912
1913 ((TH2*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
1914 ((TH2*)player->GetHistogram())->Reset();
1915
1916 // Get new Number of bins
1917 if (xfact > 0) xBinNumber = xfact*nx;
1918 if (xfact < 0) xBinNumber = (Int_t) ((-1)*nx/xfact+0.5);
1919 if (xBinNumber < 1) xBinNumber = 1;
1920 if (xBinNumber > 1000) xBinNumber= 1000;
1921 if (yfact > 0) yBinNumber = yfact*ny;
1922 if (yfact < 0) yBinNumber = (Int_t) ((-1)*ny/yfact+0.5);
1923 if (yBinNumber < 1) yBinNumber = 1;
1924 if (yBinNumber > 1000) yBinNumber= 1000;
1925 Double_t xOffset = 1.*fXBinOffsetSld->GetPosition()/100*((maxx-minx)/xBinNumber);
1926 Double_t yOffset = 1.*fYBinOffsetSld->GetPosition()/100*((maxy-miny)/yBinNumber);
1927 // create new histogram - the main job is done by sel->TakeAction()
1928
1929 ((TH2*)player->GetHistogram())->SetBins(xBinNumber, minx-oldXOffset+xOffset,
1930 maxx-oldXOffset+xOffset,
1931 yBinNumber, miny-oldYOffset+yOffset,
1932 maxy-oldYOffset+yOffset);
1933 TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
1934 if (!sel) return;
1935 sel->TakeAction();
1936
1937 // Restore and set all the attributes which were changed by TakeAction()
1939 fSliderX->SetRange(1,xBinNumber);
1940 fSliderY->SetRange(1,yBinNumber);
1941 Double_t xBinWidth = xaxis->GetBinWidth(1);
1942 Double_t yBinWidth = yaxis->GetBinWidth(1);
1943 fSliderX->SetPosition(xaxis->FindBin(rminx+xBinWidth/2),
1944 xaxis->FindBin(rmaxx-xBinWidth/2));
1945 fSliderY->SetPosition(yaxis->FindBin(rminy+yBinWidth/2),
1946 yaxis->FindBin(rmaxy-yBinWidth/2));
1947 xOffset = 1.*fXBinOffsetSld->GetPosition()/100*xBinWidth; // nessesary ??
1948 yOffset = 1.*fYBinOffsetSld->GetPosition()/100*yBinWidth; // nessesary ??
1949
1950 // SetRange in BinNumbers along x and y!
1951 xaxis->SetRange(xaxis->FindBin(rminx+xBinWidth/2),
1952 xaxis->FindBin(rmaxx-xBinWidth/2));
1953 yaxis->SetRange(yaxis->FindBin(rminy+yBinWidth/2),
1954 yaxis->FindBin(rmaxy-yBinWidth/2));
1955 fSldXMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
1956 fSldXMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
1957 fSldYMin->SetNumber(yaxis->GetBinLowEdge(yaxis->GetFirst()));
1958 fSldYMax->SetNumber(yaxis->GetBinUpEdge(yaxis->GetLast()));
1959 fBinXNumberEntry1->SetNumber(xaxis->GetLast() - xaxis->GetFirst()+1);
1960 fBinYNumberEntry1->SetNumber(yaxis->GetLast() - yaxis->GetFirst()+1);
1961 fBinXSlider1->SetPosition(5);
1962 fBinYSlider1->SetPosition(5);
1963 fXOffsetNumberEntry->SetNumber(xOffset);
1964 fYOffsetNumberEntry->SetNumber(yOffset);
1966 xaxis->GetBinWidth(1));
1968 yaxis->GetBinWidth(1));
1969 fClient->NeedRedraw(fBinXSlider1, kTRUE);
1970 // when you 2-clicks on a slider, sometimes it gets caught on wrong position! (2 or -2)
1971 fClient->NeedRedraw(fBinYSlider1, kTRUE);
1972 // when you 2-clicks on a slider, sometimes it gets caught on wrong position! (2 or -2)
1973 Update();
1974}
1975
1976////////////////////////////////////////////////////////////////////////////////
1977/// Slot connected to the rebin slider in case of an ntuple histogram.
1978/// Updates the BinNumberEntryField during the BinSlider movement.
1979
1981{
1982 if (fAvoidSignal) return;
1983 TAxis* xaxis = fHist->GetXaxis();
1984 TAxis* yaxis = fHist->GetYaxis();
1985 Int_t firstx = xaxis->GetFirst();
1986 Int_t lastx = xaxis->GetLast();
1987 Int_t firsty = yaxis->GetFirst();
1988 Int_t lasty = yaxis->GetLast();
1989 Int_t xnumber = fBinXSlider1->GetPosition();
1990 Int_t ynumber = fBinYSlider1->GetPosition();
1991 Int_t numx = lastx-firstx+1;
1992 Int_t numy = lasty-firsty+1;
1993 Int_t xfact = 0;
1994 Int_t yfact = 0;
1995 Int_t xBinNumber = 0;
1996 Int_t yBinNumber = 0;
1997 if (xnumber >= 5) xfact = xnumber - 4;
1998 else xfact = xnumber - 6;
1999 if (xfact > 0) xBinNumber = xfact*numx;
2000 if (xfact < 0) xBinNumber = (Int_t) ((-1)*numx/xfact+0.5);
2001 if (xBinNumber < 1) xBinNumber = 1;
2002 if (xBinNumber > 1000) xBinNumber= 1000;
2003 if (fBinXNumberEntry1->GetNumber()!=xBinNumber)
2004 fBinXNumberEntry1->SetIntNumber(xBinNumber);
2005
2006 if (ynumber >= 5) yfact = ynumber - 4;
2007 else yfact = ynumber - 6;
2008 if (yfact > 0) yBinNumber = yfact*numy;
2009 if (yfact < 0) yBinNumber = (Int_t) ((-1)*numy/yfact+0.5);
2010 if (yBinNumber < 1) yBinNumber = 1;
2011 if (yBinNumber > 1000) yBinNumber= 1000;
2012 if (fBinYNumberEntry1->GetNumber()!=yBinNumber)
2013 fBinYNumberEntry1->SetIntNumber(yBinNumber);
2014}
2015
2016////////////////////////////////////////////////////////////////////////////////
2017/// Slot connected to the Bin Number Entry for the Rebin.
2018
2020{
2021 if (fAvoidSignal) return;
2022 Double_t oldXOffset = fXOffsetNumberEntry->GetNumber();
2023 Int_t numx = (Int_t)fBinXNumberEntry1->GetNumber();
2024 Double_t oldYOffset = fYOffsetNumberEntry->GetNumber();
2025 Int_t numy = (Int_t)fBinYNumberEntry1->GetNumber();
2026 TAxis* xaxis = fHist->GetXaxis();
2027 TAxis* yaxis = fHist->GetYaxis();
2029 if (!player) return;
2030 Int_t firstx = xaxis->GetFirst();
2031 Int_t lastx = xaxis->GetLast();
2032 Int_t firsty = yaxis->GetFirst();
2033 Int_t lasty = yaxis->GetLast();
2034 Int_t nx = xaxis->GetNbins();
2035 Int_t ny = yaxis->GetNbins();
2036 Double_t minx = xaxis->GetBinLowEdge(1); // overall min in user coords
2037 Double_t maxx = xaxis->GetBinUpEdge(nx); // overall max in user coords
2038 Double_t miny = yaxis->GetBinLowEdge(1); // overall min in user coords
2039 Double_t maxy = yaxis->GetBinUpEdge(ny); // overall max in user coords
2040 Double_t rminx = xaxis->GetBinLowEdge(firstx); // recent min in user coords
2041 Double_t rmaxx = xaxis->GetBinUpEdge(lastx); // recent max in user coords
2042 Double_t rminy = yaxis->GetBinLowEdge(firsty); // recent min in user coords
2043 Double_t rmaxy = yaxis->GetBinUpEdge(lasty); // recent max in user coords
2044
2045 ((TH2*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
2046 ((TH2*)player->GetHistogram())->Reset();
2047
2048 // Calculate the new number of bins in the complete range
2049 Int_t xBinNumber = (Int_t) ((maxx-minx)/(rmaxx - rminx)*numx + 0.5);
2050 if (xBinNumber < 1) xBinNumber = 1;
2051 if (xBinNumber > 1000) xBinNumber= 1000;
2052 Double_t xOffset = 1.*(fXBinOffsetSld->GetPosition())/100*(maxx-minx)/xBinNumber;
2053 Int_t yBinNumber = (Int_t) ((maxy-miny)/(rmaxy - rminy)*numy + 0.5);
2054 if (yBinNumber < 1) yBinNumber = 1;
2055 if (yBinNumber > 1000) yBinNumber= 1000;
2056 Double_t yOffset = 1.*(fYBinOffsetSld->GetPosition())/100*(maxy-miny)/yBinNumber;
2057 // create new histogram - the main job is done by sel->TakeAction()
2058 ((TH2*)player->GetHistogram())->SetBins(xBinNumber, minx-oldXOffset+xOffset,
2059 maxx-oldXOffset+xOffset,
2060 yBinNumber, miny-oldYOffset+yOffset,
2061 maxy-oldYOffset+yOffset);
2062 TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
2063 if (!sel) return;
2064 sel->TakeAction();
2065
2066 // Restore and set all the attributes which were changed by TakeAction()
2068 fSliderX->SetRange(1,xBinNumber);
2069 fSliderY->SetRange(1,yBinNumber);
2070 Double_t xBinWidth = xaxis->GetBinWidth(1);
2071 Double_t yBinWidth = yaxis->GetBinWidth(1);
2072 fSliderX->SetPosition(xaxis->FindBin(rminx+xBinWidth/2),
2073 xaxis->FindBin(rmaxx-xBinWidth/2));
2074 fSliderY->SetPosition(yaxis->FindBin(rminy+yBinWidth/2),
2075 yaxis->FindBin(rmaxy-yBinWidth/2));
2076 xOffset = 1.*fXBinOffsetSld->GetPosition()/100*xBinWidth; //nesessary ??
2077 yOffset = 1.*fYBinOffsetSld->GetPosition()/100*yBinWidth; //nesessary ??
2078
2079 // SetRange in BinNumbers along x and y!
2080 xaxis->SetRange(xaxis->FindBin(rminx+xBinWidth/2),
2081 xaxis->FindBin(rmaxx-xBinWidth/2));
2082 yaxis->SetRange(yaxis->FindBin(rminy+yBinWidth/2),
2083 yaxis->FindBin(rmaxy-yBinWidth/2));
2084 fSldXMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
2085 fSldXMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
2086 fSldYMin->SetNumber(yaxis->GetBinLowEdge(yaxis->GetFirst()));
2087 fSldYMax->SetNumber(yaxis->GetBinUpEdge(yaxis->GetLast()));
2088 fXOffsetNumberEntry->SetNumber(xOffset);
2090 fYOffsetNumberEntry->SetNumber(yOffset);
2092 Update();
2093}
2094
2095////////////////////////////////////////////////////////////////////////////////
2096/// Slot connected to the OffSetSlider. It saves the OldBinOffset
2097/// (nessesary for delay draw mode).
2098
2100{
2101 if (fAvoidSignal) return;
2102 fOldXOffset = fXOffsetNumberEntry->GetNumber();
2103 fOldYOffset = fYOffsetNumberEntry->GetNumber();
2104}
2105
2106////////////////////////////////////////////////////////////////////////////////
2107/// Slot connected to the OffSetSlider that
2108/// changes the origin of the histogram inbetween a binwidth;
2109/// rebin the histogram with the new Offset given by the slider.
2110/// problem: histogram with variable binwidth??
2111
2113{
2114 if (fAvoidSignal) return;
2115 if (fDelaydraw->GetState()==kButtonDown){
2116 Int_t numx = (Int_t)fXBinOffsetSld->GetPosition();
2117 Int_t numy = (Int_t)fYBinOffsetSld->GetPosition();
2118 TAxis* xaxis = fHist->GetXaxis();
2119 TAxis* yaxis = fHist->GetYaxis();
2120 Double_t xBinWidth = xaxis->GetBinWidth(1);
2121 Double_t yBinWidth = yaxis->GetBinWidth(1);
2122 Double_t xOffset = 1.*numx/100*xBinWidth;
2123 Double_t yOffset = 1.*numy/100*yBinWidth;
2124 Double_t oldXOffset = fOldXOffset;
2125 Double_t oldYOffset = fOldYOffset;
2126 Int_t nx = xaxis->GetNbins();
2127 Int_t ny = yaxis->GetNbins();
2128
2130 if (!player) return;
2131
2132 Int_t firstx = xaxis->GetFirst();
2133 Int_t lastx = xaxis->GetLast();
2134 Int_t firsty = yaxis->GetFirst();
2135 Int_t lasty = yaxis->GetLast();
2136 Double_t minx = xaxis->GetBinLowEdge(1); // overall min in user coords
2137 Double_t maxx = xaxis->GetBinUpEdge(nx); // overall max in user coords
2138 Double_t miny = yaxis->GetBinLowEdge(1); // overall min in user coords
2139 Double_t maxy = yaxis->GetBinUpEdge(ny); // overall max in user coords
2140 Double_t rminx = xaxis->GetBinLowEdge(firstx); // recent min in user coords
2141 Double_t rmaxx = xaxis->GetBinUpEdge(lastx); // recent max in user coords
2142 Double_t rminy = yaxis->GetBinLowEdge(firsty); // recent min in user coords
2143 Double_t rmaxy = yaxis->GetBinUpEdge(lasty); // recent max in user coords
2144
2145 ((TH2*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
2146 ((TH2*)player->GetHistogram())->Reset();
2147
2148 ((TH2*)player->GetHistogram())->SetBins(nx, minx-oldXOffset+xOffset,
2149 maxx-oldXOffset+xOffset,
2150 ny, miny-oldYOffset+yOffset,
2151 maxy-oldYOffset+yOffset);
2152 TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
2153 if (!sel) return;
2154 sel->TakeAction();
2155
2156 // Restore all the attributes which were changed by TakeAction()
2158
2159 // SetRange in BinNumbers along x and y!
2160 xaxis->SetRange(xaxis->FindBin(rminx+xOffset-oldXOffset+xBinWidth/2),
2161 xaxis->FindBin(rmaxx+xOffset-oldXOffset-xBinWidth/2));
2162 yaxis->SetRange(yaxis->FindBin(rminy+yOffset-oldYOffset+yBinWidth/2),
2163 yaxis->FindBin(rmaxy+yOffset-oldYOffset-yBinWidth/2));
2164 fSldXMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
2165 fSldXMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
2166 fSldYMin->SetNumber(yaxis->GetBinLowEdge(yaxis->GetFirst()));
2167 fSldYMax->SetNumber(yaxis->GetBinUpEdge(yaxis->GetLast()));
2168 fXOffsetNumberEntry->SetNumber(xOffset);
2169 fYOffsetNumberEntry->SetNumber(yOffset);
2170 Update();
2171 }
2172}
2173
2174////////////////////////////////////////////////////////////////////////////////
2175/// Slot connected to the OffSetSlider.
2176/// It changes the origin of the histogram inbetween a binwidth;
2177/// rebin the histogram with the new offset given by the slider.
2178/// problem: histogram with variable binwidth??
2179
2181{
2182 if (fAvoidSignal) return;
2183 Int_t numx = (Int_t)fXBinOffsetSld->GetPosition();
2184 Int_t numy = (Int_t)fYBinOffsetSld->GetPosition();
2185 TAxis* xaxis = fHist->GetXaxis();
2186 TAxis* yaxis = fHist->GetYaxis();
2187 Double_t xBinWidth = xaxis->GetBinWidth(1);
2188 Double_t yBinWidth = yaxis->GetBinWidth(1);
2189 Double_t xOffset = 1.*numx/100*xBinWidth;
2190 Double_t yOffset = 1.*numy/100*yBinWidth;
2191 if (fDelaydraw->GetState()==kButtonUp){
2192 Double_t oldXOffset = fXOffsetNumberEntry->GetNumber();
2193 Double_t oldYOffset = fYOffsetNumberEntry->GetNumber();
2194 Int_t nx = xaxis->GetNbins();
2195 Int_t ny = yaxis->GetNbins();
2196
2198 if (!player) return;
2199
2200 Int_t firstx = xaxis->GetFirst();
2201 Int_t lastx = xaxis->GetLast();
2202 Int_t firsty = yaxis->GetFirst();
2203 Int_t lasty = yaxis->GetLast();
2204 Double_t minx = xaxis->GetBinLowEdge(1); // overall min in user coords
2205 Double_t maxx = xaxis->GetBinUpEdge(nx); // overall max in user coords
2206 Double_t miny = yaxis->GetBinLowEdge(1); // overall min in user coords
2207 Double_t maxy = yaxis->GetBinUpEdge(ny); // overall max in user coords
2208 Double_t rminx = xaxis->GetBinLowEdge(firstx); // recent min in user coords
2209 Double_t rmaxx = xaxis->GetBinUpEdge(lastx); // recent max in user coords
2210 Double_t rminy = yaxis->GetBinLowEdge(firsty); // recent min in user coords
2211 Double_t rmaxy = yaxis->GetBinUpEdge(lasty); // recent max in user coords
2212
2213 ((TH2*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
2214 ((TH2*)player->GetHistogram())->Reset();
2215
2216 ((TH2*)player->GetHistogram())->SetBins(nx,minx-oldXOffset+xOffset,
2217 maxx-oldXOffset+xOffset,
2218 ny, miny-oldYOffset+yOffset,
2219 maxy-oldYOffset+yOffset);
2220 TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
2221 if (!sel) return;
2222 sel->TakeAction();
2223
2224 // Restore all the attributes which were changed by TakeAction()
2226
2227 // SetRange in BinNumbers along x and y!
2228 xaxis->SetRange(xaxis->FindBin(rminx+xOffset-oldXOffset+xBinWidth/2),
2229 xaxis->FindBin(rmaxx+xOffset-oldXOffset-xBinWidth/2));
2230 yaxis->SetRange(yaxis->FindBin(rminy+yOffset-oldYOffset+yBinWidth/2),
2231 yaxis->FindBin(rmaxy+yOffset-oldYOffset-yBinWidth/2));
2232 fSldXMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
2233 fSldXMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
2234 fSldYMin->SetNumber(yaxis->GetBinLowEdge(yaxis->GetFirst()));
2235 fSldYMax->SetNumber(yaxis->GetBinUpEdge(yaxis->GetLast()));
2236 fClient->NeedRedraw(fXBinOffsetSld, kTRUE);
2237 fClient->NeedRedraw(fYBinOffsetSld, kTRUE);
2238 Update();
2239 }
2240 fXOffsetNumberEntry->SetNumber(xOffset);
2241 fYOffsetNumberEntry->SetNumber(yOffset);
2242 fClient->NeedRedraw(fXOffsetNumberEntry, kTRUE);
2243 fClient->NeedRedraw(fYOffsetNumberEntry, kTRUE);
2244}
2245
2246////////////////////////////////////////////////////////////////////////////////
2247/// Slot connected to the OffSetNumberEntry, related to the OffSetSlider
2248/// changes the origin of the histogram inbetween a binwidth.
2249
2251{
2252 if (fAvoidSignal) return;
2253 TAxis* xaxis = fHist->GetXaxis();
2254 TAxis* yaxis = fHist->GetYaxis();
2255 Double_t xBinWidth = xaxis->GetBinWidth(1);
2256 Double_t yBinWidth = yaxis->GetBinWidth(1);
2257 Double_t xOffset = fXOffsetNumberEntry->GetNumber();
2258 Double_t oldXOffset = 1.*fXBinOffsetSld->GetPosition()/100*xBinWidth;
2259 Double_t yOffset = fYOffsetNumberEntry->GetNumber();
2260 Double_t oldYOffset = 1.*fYBinOffsetSld->GetPosition()/100*yBinWidth;
2261 Int_t nx = xaxis->GetNbins();
2262 Int_t ny = yaxis->GetNbins();
2264 if (!player) return;
2265 Int_t firstx = xaxis->GetFirst();
2266 Int_t lastx = xaxis->GetLast();
2267 Int_t firsty = yaxis->GetFirst();
2268 Int_t lasty = yaxis->GetLast();
2269 Double_t minx = xaxis->GetBinLowEdge(1); // overall min in user coords
2270 Double_t maxx = xaxis->GetBinUpEdge(nx); // overall max in user coords
2271 Double_t miny = yaxis->GetBinLowEdge(1); // overall min in user coords
2272 Double_t maxy = yaxis->GetBinUpEdge(ny); // overall max in user coords
2273 Double_t rminx = xaxis->GetBinLowEdge(firstx); // recent min in user coords
2274 Double_t rmaxx = xaxis->GetBinUpEdge(lastx); // recent max in user coords
2275 Double_t rminy = yaxis->GetBinLowEdge(firsty); // recent min in user coords
2276 Double_t rmaxy = yaxis->GetBinUpEdge(lasty); // recent max in user coords
2277
2278 ((TH2*)player->GetHistogram())->SetCanExtend(TH1::kNoAxis);
2279 ((TH2*)player->GetHistogram())->Reset();
2280
2281 ((TH2*)player->GetHistogram())->SetBins(nx,minx+xOffset-oldXOffset,
2282 maxx+xOffset-oldXOffset,
2283 ny,miny+yOffset-oldYOffset,
2284 maxy+yOffset-oldYOffset);
2285 TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
2286 if (!sel) return;
2287 sel->TakeAction();
2288
2289 // Restore all the attributes which were changed by TakeAction()
2291
2292 // SetRange in BinNumbers along x and y!
2293 xaxis->SetRange(xaxis->FindBin(rminx+xOffset-oldXOffset+xBinWidth/2),
2294 xaxis->FindBin(rmaxx+xOffset-oldXOffset-xBinWidth/2));
2295 yaxis->SetRange(yaxis->FindBin(rminy+yOffset-oldYOffset+yBinWidth/2),
2296 yaxis->FindBin(rmaxy+yOffset-oldYOffset-yBinWidth/2));
2297 fSldXMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
2298 fSldXMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
2299 fXBinOffsetSld->SetPosition((Int_t)(xOffset/xBinWidth*100));
2300 fSldYMin->SetNumber(yaxis->GetBinLowEdge(yaxis->GetFirst()));
2301 fSldYMax->SetNumber(yaxis->GetBinUpEdge(yaxis->GetLast()));
2302 fYBinOffsetSld->SetPosition((Int_t)(yOffset/yBinWidth*100));
2303 Update();
2304}
2305
2306////////////////////////////////////////////////////////////////////////////////
2307/// Slot connected to the x-Slider that redraws the histogram
2308/// with the new slider range.
2309
2311{
2312 if (fAvoidSignal) return;
2313 TAxis* xaxis = fHist->GetXaxis();
2314 if (fDelaydraw->GetState()==kButtonDown && fDim->GetState()==kButtonDown) {
2315 // 2D plot
2316 Int_t px1,py1,px2,py2;
2317 Float_t ymin,ymax,xleft,xright;
2318 xleft = xaxis->GetBinLowEdge((Int_t)((fSliderX->GetMinPosition())+0.5));
2319 xright = xaxis->GetBinUpEdge((Int_t)((fSliderX->GetMaxPosition())+0.5));
2320 ymin = fGedEditor->GetPad()->GetUymin();
2321 ymax = fGedEditor->GetPad()->GetUymax();
2322 px1 = fGedEditor->GetPad()->XtoAbsPixel(xleft);
2323 py1 = fGedEditor->GetPad()->YtoAbsPixel(ymin);
2324 px2 = fGedEditor->GetPad()->XtoAbsPixel(xright);
2325 py2 = fGedEditor->GetPad()->YtoAbsPixel(ymax);
2326 if (fGedEditor->GetPad()->GetCanvas())
2327 fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kTRUE);
2328 fGedEditor->GetPad()->cd();
2329 fGedEditor->GetPad()->SetLineWidth(1);
2330 fGedEditor->GetPad()->SetLineColor(2);
2332 gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
2333 fPx1old = px1;
2334 fPy1old = py1;
2335 fPx2old = px2 ;
2336 fPy2old = py2;
2337 gVirtualX->Update(0);
2338 fSldXMin->SetNumber(xleft);
2339 fSldXMax->SetNumber(xright);
2340 } else if (fDelaydraw->GetState()==kButtonDown &&
2341 fDim0->GetState()==kButtonDown &&
2342 fCoordsCombo->GetSelected()==kCOORDS_CAR) {
2343 // 3D plot
2344 Float_t p1[3], p2[3], p3[3], p4[3], p5[3], p6[3], p7[3], p8[3];
2345 if (fGedEditor->GetPad()->GetCanvas())
2346 fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kTRUE);
2347 fGedEditor->GetPad()->cd();
2348 TView *fView = fGedEditor->GetPad()->GetView();
2349 if (!fView) return;
2350 Double_t *rmin = fView->GetRmin();
2351 if (!rmin) return;
2352 Double_t *rmax = fView->GetRmax();
2353 if (!rmax) return;
2354 p1[0] = p4[0] = p5[0] = p8[0] =
2355 xaxis->GetBinLowEdge((Int_t)((fSliderX->GetMinPosition())+0.5));
2356 p2[0] = p3[0] = p6[0] = p7[0] =
2357 xaxis->GetBinUpEdge((Int_t)((fSliderX->GetMaxPosition())+0.5));
2358 p1[1] = p2[1] = p3[1] = p4[1] = rmin[1];
2359 p5[1] = p6[1] = p7[1] = p8[1] = rmax[1];
2360 p1[2] = p2[2] = p5[2] = p6[2] = rmin[2];
2361 p3[2] = p4[2] = p7[2] = p8[2] = rmax[2];
2362 fGedEditor->GetPad()->SetLineWidth(1);
2363 fGedEditor->GetPad()->SetLineColor(2);
2366 PaintBox3D(p2, p3, p7, p6);
2367 PaintBox3D(p1, p4, p8, p5);
2368 for (Int_t i = 0; i<3; i++){
2369 fP1oldx[i] = p1[i];
2370 fP2oldx[i] = p2[i];
2371 fP3oldx[i] = p3[i];
2372 fP4oldx[i] = p4[i];
2373 fP5oldx[i] = p5[i];
2374 fP6oldx[i] = p6[i];
2375 fP7oldx[i] = p7[i];
2376 fP8oldx[i] = p8[i];
2377 }
2378 fSldXMin->SetNumber(p1[0]);
2379 fSldXMax->SetNumber(p2[0]);
2380 } else if (fDelaydraw->GetState()==kButtonDown &&
2381 fDim0->GetState()==kButtonDown) {
2382 fSldXMin->SetNumber(xaxis->GetBinLowEdge((Int_t)((fSliderX->GetMinPosition())+0.5)));
2383 fSldXMax->SetNumber(xaxis->GetBinUpEdge((Int_t)((fSliderX->GetMaxPosition())+0.5)));
2384 } else {
2385 fHist->GetXaxis()->SetRange((Int_t)((fSliderX->GetMinPosition())+0.5),
2386 (Int_t)((fSliderX->GetMaxPosition())+0.5));
2387 fSldXMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
2388 fSldXMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
2389 fClient->NeedRedraw(fSliderX,kTRUE);
2390 Update();
2391 }
2392 fClient->NeedRedraw(fSldXMin,kTRUE);
2393 fClient->NeedRedraw(fSldXMax,kTRUE);
2394}
2395
2396////////////////////////////////////////////////////////////////////////////////
2397/// Slot connected to the x axis range slider that initialises
2398/// the "virtual" box which is drawn in delay draw mode.
2399
2401{
2402 if (fAvoidSignal) return;
2403 TAxis* xaxis = fHist->GetXaxis();
2404 Float_t ymin,ymax,xleft,xright;
2405 if (fDelaydraw->GetState()==kButtonDown && fDim->GetState()==kButtonDown) {
2406 // 2D Plot
2407 if (!fGedEditor->GetPad()) return;
2408 fGedEditor->GetPad()->cd();
2409 if (fGedEditor->GetPad()->GetCanvas())
2410 fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kFALSE);
2411 fGedEditor->GetPad()->SetLineWidth(1);
2412 fGedEditor->GetPad()->SetLineColor(2);
2413 xleft = xaxis->GetBinLowEdge((Int_t)((fSliderX->GetMinPosition())+0.5));
2414 xright = xaxis->GetBinUpEdge((Int_t)((fSliderX->GetMaxPosition())+0.5));
2415 ymin = fGedEditor->GetPad()->GetUymin();
2416 ymax = fGedEditor->GetPad()->GetUymax();
2417 fPx1old = fGedEditor->GetPad()->XtoAbsPixel(xleft);
2418 fPy1old = fGedEditor->GetPad()->YtoAbsPixel(ymin);
2419 fPx2old = fGedEditor->GetPad()->XtoAbsPixel(xright);
2420 fPy2old = fGedEditor->GetPad()->YtoAbsPixel(ymax);
2422 } else if (fDelaydraw->GetState()==kButtonDown &&
2423 fDim0->GetState()==kButtonDown &&
2424 fCoordsCombo->GetSelected()==kCOORDS_CAR) {
2425 // 3D plot
2426 if (!fGedEditor->GetPad()) return;
2427 fGedEditor->GetPad()->cd();
2428 TView *fView = fGedEditor->GetPad()->GetView();
2429 if (!fView) return;
2430 Double_t *rmin = fView->GetRmin();
2431 if (!rmin) return;
2432 Double_t *rmax = fView->GetRmax();
2433 if (!rmax) return;
2434 fP1oldx[0] = fP4oldx[0] = fP5oldx[0] = fP8oldx[0] =
2435 xaxis->GetBinLowEdge((Int_t)((fSliderX->GetMinPosition())+0.5));
2436 fP2oldx[0] = fP3oldx[0] = fP6oldx[0] = fP7oldx[0] =
2437 xaxis->GetBinUpEdge((Int_t)((fSliderX->GetMaxPosition())+0.5));
2438 fP1oldx[1] = fP2oldx[1] = fP3oldx[1] = fP4oldx[1] = rmin[1];
2439 fP5oldx[1] = fP6oldx[1] = fP7oldx[1] = fP8oldx[1] = rmax[1];
2440 fP1oldx[2] = fP2oldx[2] = fP5oldx[2] = fP6oldx[2] = rmin[2];
2441 fP3oldx[2] = fP4oldx[2] = fP7oldx[2] = fP8oldx[2] = rmax[2];
2442 if (fGedEditor->GetPad()->GetCanvas())
2443 fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kTRUE);
2444 fGedEditor->GetPad()->SetLineWidth(1);
2445 fGedEditor->GetPad()->SetLineColor(2);
2448 }
2449}
2450
2451////////////////////////////////////////////////////////////////////////////////
2452/// Slot connected to the x-axis slider finalizing values after
2453/// the slider movement.
2454
2456{
2457 if (fAvoidSignal) return;
2458 if (fDelaydraw->GetState()==kButtonDown) {
2459 fHist->GetXaxis()->SetRange((Int_t)((fSliderX->GetMinPosition())+0.5),
2460 (Int_t)((fSliderX->GetMaxPosition())+0.5));
2461 fSldXMin->SetNumber(fHist->GetXaxis()->GetBinLowEdge(fHist->GetXaxis()->GetFirst()));
2462 fSldXMax->SetNumber(fHist->GetXaxis()->GetBinUpEdge(fHist->GetXaxis()->GetLast()));
2463 Update();
2464 }
2466 if (player) if (player->GetHistogram() == fHist) {
2467 Int_t last = fHist->GetXaxis()->GetLast();
2468 Int_t first = fHist->GetXaxis()->GetFirst();
2469 fBinXNumberEntry1->SetIntNumber(last-first+1);
2470 Update();
2471 }
2472}
2473
2474////////////////////////////////////////////////////////////////////////////////
2475/// Slot connected to the Max/Min number entry fields showing x-axis range.
2476
2478{
2479 TAxis* xaxis = fHist->GetXaxis();
2480 Int_t nx = xaxis->GetNbins();
2481 Double_t width = xaxis->GetBinWidth(1);
2482 if ((fSldXMin->GetNumber()+width/2) < (xaxis->GetBinLowEdge(1)))
2483 fSldXMin->SetNumber(xaxis->GetBinLowEdge(1));
2484 if ((fSldXMax->GetNumber()-width/2) > (xaxis->GetBinUpEdge(nx)))
2485 fSldXMax->SetNumber(xaxis->GetBinUpEdge(nx));
2486 xaxis->SetRangeUser(fSldXMin->GetNumber()+width/2,
2487 fSldXMax->GetNumber()-width/2);
2488 Int_t nxbinmin = xaxis->GetFirst();
2489 Int_t nxbinmax = xaxis->GetLast();
2490 fSliderX->SetPosition((Double_t)(nxbinmin),(Double_t)(nxbinmax));
2491 Update();
2492}
2493
2494////////////////////////////////////////////////////////////////////////////////
2495/// Slot connected to the x-slider for redrawing the
2496/// histogram with the new slider Range (immediately).
2497
2499{
2500 if (fAvoidSignal) return;
2501 TAxis* yaxis = fHist->GetYaxis();
2502 if (fDelaydraw->GetState()==kButtonDown && fDim->GetState()==kButtonDown) {
2503 Int_t px1,py1,px2,py2;
2504 Float_t xmin,xmax,ybottom,ytop;
2505 ybottom = yaxis->GetBinLowEdge((Int_t)((fSliderY->GetMinPosition())+0.5));
2506 ytop = yaxis->GetBinUpEdge((Int_t)((fSliderY->GetMaxPosition())+0.5));
2507 xmin = fGedEditor->GetPad()->GetUxmin();
2508 xmax = fGedEditor->GetPad()->GetUxmax();
2509 px1 = fGedEditor->GetPad()->XtoAbsPixel(xmin);
2510 py1 = fGedEditor->GetPad()->YtoAbsPixel(ybottom);
2511 px2 = fGedEditor->GetPad()->XtoAbsPixel(xmax);
2512 py2 = fGedEditor->GetPad()->YtoAbsPixel(ytop);
2513 if (fGedEditor->GetPad()->GetCanvas())
2514 fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kTRUE);
2515 fGedEditor->GetPad()->cd();
2516 fGedEditor->GetPad()->SetLineWidth(1);
2517 fGedEditor->GetPad()->SetLineColor(2);
2519 gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
2520 fPx1old = px1;
2521 fPy1old = py1;
2522 fPx2old = px2 ;
2523 fPy2old = py2;
2524 gVirtualX->Update(0);
2525 fSldYMin->SetNumber(ybottom);
2526 fSldYMax->SetNumber(ytop);
2527 } else if (fDelaydraw->GetState()==kButtonDown &&
2528 fDim0->GetState()==kButtonDown &&
2529 fCoordsCombo->GetSelected()==kCOORDS_CAR) {
2530 // 3D plot
2531 Float_t p1[3], p2[3], p3[3], p4[3], p5[3], p6[3], p7[3], p8[3];
2532 if (fGedEditor->GetPad()->GetCanvas())
2533 fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kTRUE);
2534 fGedEditor->GetPad()->cd();
2535 TView *fView = fGedEditor->GetPad()->GetView();
2536 if (!fView) return;
2537 Double_t *rmin = fView->GetRmin();
2538 if (!rmin) return;
2539 Double_t *rmax = fView->GetRmax();
2540 if (!rmax) return;
2541 p1[0] = p2[0] = p3[0] = p4[0] = rmin[0];
2542 p5[0] = p6[0] = p7[0] = p8[0] = rmax[0];
2543 p1[1] = p4[1] = p5[1] = p8[1] =
2544 yaxis->GetBinLowEdge((Int_t)((fSliderY->GetMinPosition())+0.5));
2545 p2[1] = p3[1] = p6[1] = p7[1] =
2546 yaxis->GetBinUpEdge((Int_t)((fSliderY->GetMaxPosition())+0.5));
2547 p1[2] = p2[2] = p5[2] = p6[2] = rmin[2];
2548 p3[2] = p4[2] = p7[2] = p8[2] = rmax[2];
2549 fGedEditor->GetPad()->SetLineWidth(1);
2550 fGedEditor->GetPad()->SetLineColor(2);
2553 PaintBox3D(p2, p3, p7, p6);
2554 PaintBox3D(p1, p4, p8, p5);
2555 for (Int_t i = 0; i<3; i++) {
2556 fP1oldy[i] = p1[i];
2557 fP2oldy[i] = p2[i];
2558 fP3oldy[i] = p3[i];
2559 fP4oldy[i] = p4[i];
2560 fP5oldy[i] = p5[i];
2561 fP6oldy[i] = p6[i];
2562 fP7oldy[i] = p7[i];
2563 fP8oldy[i] = p8[i];
2564 }
2565 fSldYMin->SetNumber(p1[1]);
2566 fSldYMax->SetNumber(p2[1]);
2567 } else if (fDelaydraw->GetState()==kButtonDown &&
2568 fDim0->GetState()==kButtonDown) {
2569 fSldYMin->SetNumber(yaxis->GetBinLowEdge((Int_t)((fSliderY->GetMinPosition())+0.5)));
2570 fSldYMax->SetNumber(yaxis->GetBinUpEdge((Int_t)((fSliderY->GetMaxPosition())+0.5)));
2571 } else {
2572 yaxis->SetRange((Int_t)((fSliderY->GetMinPosition())+0.5),
2573 (Int_t)((fSliderY->GetMaxPosition())+0.5));
2574 fSldYMin->SetNumber(yaxis->GetBinLowEdge(yaxis->GetFirst()));
2575 fSldYMax->SetNumber(yaxis->GetBinUpEdge(yaxis->GetLast()));
2576 fClient->NeedRedraw(fSliderY,kTRUE);
2577 Update();
2578 }
2579 fClient->NeedRedraw(fSldYMin,kTRUE);
2580 fClient->NeedRedraw(fSldYMax,kTRUE);
2581}
2582
2583////////////////////////////////////////////////////////////////////////////////
2584/// Slot connected to y-axis slider which initialises
2585/// the "virtual" box which is drawn in delay draw mode.
2586
2588{
2589 if (fAvoidSignal) return;
2590 TAxis* yaxis = fHist->GetYaxis();
2591 Float_t xmin,xmax,ytop,ybottom;
2592 if (fDelaydraw->GetState()==kButtonDown && fDim->GetState()==kButtonDown) {
2593 // 2D plot:
2594 if (!fGedEditor->GetPad()) return;
2595 fGedEditor->GetPad()->cd();
2596 if (fGedEditor->GetPad()->GetCanvas())
2597 fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kFALSE);
2598 fGedEditor->GetPad()->SetLineWidth(1);
2599 fGedEditor->GetPad()->SetLineColor(2);
2600 ybottom = yaxis->GetBinLowEdge((Int_t)((fSliderY->GetMinPosition())+0.5));
2601 ytop = yaxis->GetBinUpEdge((Int_t)((fSliderY->GetMaxPosition())+0.5));
2602 xmin = fGedEditor->GetPad()->GetUxmin();
2603 xmax = fGedEditor->GetPad()->GetUxmax();
2604 fPx1old = fGedEditor->GetPad()->XtoAbsPixel(xmin);
2605 fPy1old = fGedEditor->GetPad()->YtoAbsPixel(ybottom);
2606 fPx2old = fGedEditor->GetPad()->XtoAbsPixel(xmax);
2607 fPy2old = fGedEditor->GetPad()->YtoAbsPixel(ytop);
2609 } else if (fDelaydraw->GetState()==kButtonDown &&
2610 fDim0->GetState()==kButtonDown &&
2611 fCoordsCombo->GetSelected()==kCOORDS_CAR) {
2612 // 3D plot
2613 if (!fGedEditor->GetPad()) return;
2614 fGedEditor->GetPad()->cd();
2615 TView *fView = fGedEditor->GetPad()->GetView();
2616 if (!fView) return;
2617 Double_t *rmin = fView->GetRmin();
2618 if (!rmin) return;
2619 Double_t *rmax = fView->GetRmax();
2620 if (!rmax) return;
2621 fP1oldy[0] = fP2oldy[0] = fP3oldy[0] = fP4oldy[0] = rmin[0];
2622 fP5oldy[0] = fP6oldy[0] = fP7oldy[0] = fP8oldy[0] = rmax[0];
2623 fP1oldy[1] = fP4oldy[1] = fP5oldy[1] = fP8oldy[1] =
2624 yaxis->GetBinLowEdge((Int_t)((fSliderY->GetMinPosition())+0.5));
2625 fP2oldy[1] = fP3oldy[1] = fP6oldy[1] = fP7oldy[1] =
2626 yaxis->GetBinUpEdge((Int_t)((fSliderY->GetMaxPosition())+0.5));
2627 fP1oldy[2] = fP2oldy[2] = fP5oldy[2] = fP6oldy[2] = rmin[2];
2628 fP3oldy[2] = fP4oldy[2] = fP7oldy[2] = fP8oldy[2] = rmax[2];
2629 if (fGedEditor->GetPad()->GetCanvas())
2630 fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kTRUE);
2631 fGedEditor->GetPad()->SetLineWidth(1);
2632 fGedEditor->GetPad()->SetLineColor(2);
2635 }
2636}
2637
2638////////////////////////////////////////////////////////////////////////////////
2639/// Slot connected to the y-axis slider finalizing values after
2640/// the slider movement.
2641
2643{
2644 if (fAvoidSignal) return;
2645 if (fDelaydraw->GetState()==kButtonDown) {
2646 fHist->GetYaxis()->SetRange((Int_t)((fSliderY->GetMinPosition())+0.5),
2647 (Int_t)((fSliderY->GetMaxPosition())+0.5));
2648 fSldYMin->SetNumber(fHist->GetYaxis()->GetBinLowEdge(fHist->GetYaxis()->GetFirst()));
2649 fSldYMax->SetNumber(fHist->GetYaxis()->GetBinUpEdge(fHist->GetYaxis()->GetLast()));
2650 Update();
2651 }
2652
2654 if (player) if (player->GetHistogram() == fHist) {
2655 Int_t last = fHist->GetYaxis()->GetLast();
2656 Int_t first = fHist->GetYaxis()->GetFirst();
2657 fBinYNumberEntry1->SetIntNumber(last-first+1);
2658 Update();
2659 }
2660}
2661
2662////////////////////////////////////////////////////////////////////////////////
2663/// Slot connected to the Max/Min number entry fields showing y-axis range.
2664
2666{
2667 if (fAvoidSignal) return;
2668 TAxis* yaxis = fHist->GetYaxis();
2669 Int_t ny = yaxis->GetNbins();
2670 Double_t width = yaxis->GetBinWidth(1);
2671
2672 if ((fSldYMin->GetNumber()+width/2) < (yaxis->GetBinLowEdge(1)))
2673 fSldYMin->SetNumber(yaxis->GetBinLowEdge(1));
2674 if ((fSldYMax->GetNumber()-width/2) > (yaxis->GetBinUpEdge(ny)))
2675 fSldYMax->SetNumber(yaxis->GetBinUpEdge(ny));
2676
2677 yaxis->SetRangeUser(fSldYMin->GetNumber()+width/2,
2678 fSldYMax->GetNumber()-width/2);
2679 Int_t nybinmin = yaxis -> GetFirst();
2680 Int_t nybinmax = yaxis -> GetLast();
2681 fSliderY->SetPosition((Double_t)(nybinmin),(Double_t)(nybinmax));
2682 Update();
2683}
2684
2685////////////////////////////////////////////////////////////////////////////////
2686/// Slot connected to the fill area color.
2687
2689{
2690 if (fAvoidSignal || !fGedEditor->GetPad()) return;
2691 fGedEditor->GetPad()->cd();
2692 fGedEditor->GetPad()->SetFrameFillColor(TColor::GetColor(color));
2693 Update();
2694}
2695
2696////////////////////////////////////////////////////////////////////////////////
2697/// Slot connected to the fill area pattern.
2698
2700{
2701 if (fAvoidSignal || !fGedEditor->GetPad()) return;
2702 fGedEditor->GetPad()->cd();
2703 fGedEditor->GetPad()->SetFrameFillStyle(pattern);
2704 Update();
2705}
2706
2707////////////////////////////////////////////////////////////////////////////////
2708/// Return the immediate histogram type (HIST, LEGO1-4, SURF1-5).
2709
2711{
2712 TString s="";
2713 switch (fTypeCombo->GetSelected()){
2714 case (-1) : {s = ""; break;}
2715 case (kTYPE_LEGO ): {s = "LEGO"; break;}
2716 case (kTYPE_LEGO1): {s = "LEGO1"; break;}
2717 case (kTYPE_LEGO2): {s = "LEGO2"; break;}
2718 case (kTYPE_LEGO3): {s = "LEGO3"; break;}
2719 case (kTYPE_LEGO4): {s = "LEGO4"; break;}
2720 case (kTYPE_SURF ): {s = "SURF"; break;}
2721 case (kTYPE_SURF1): {s = "SURF1"; break;}
2722 case (kTYPE_SURF2): {s = "SURF2"; break;}
2723 case (kTYPE_SURF3): {s = "SURF3"; break;}
2724 case (kTYPE_SURF4): {s = "SURF4"; break;}
2725 case (kTYPE_SURF5): {s = "SURF5"; break;}
2726 default: break;
2727 }
2728 return s;
2729}
2730
2731////////////////////////////////////////////////////////////////////////////////
2732/// Return the immediate coordinate system of the histogram.
2733/// (POL, CYL, SPH,PSR)
2734
2736{
2737 TString s="";
2738 switch (fCoordsCombo->GetSelected()){
2739 case (-1) : {s = ""; break;}
2740 case (kCOORDS_CAR): {s = ""; break;}
2741 case (kCOORDS_POL): {s = "POL"; break;}
2742 case (kCOORDS_CYL): {s = "CYL"; break;}
2743 case (kCOORDS_SPH): {s = "SPH"; break;}
2744 case (kCOORDS_PSR): {s = "PSR"; break;}
2745 default: break;
2746 }
2747 return s;
2748}
2749
2750////////////////////////////////////////////////////////////////////////////////
2751/// Returns histogram contour option (None,Cont0..5).
2752
2754{
2755 TString s="";
2756 switch (fContCombo->GetSelected()){
2757 case (-1) : {s = ""; break;}
2758 case (kCONT_NONE) : {s = ""; break;}
2759 case (kCONT_0) : {s = "CONT0"; break;}
2760 case (kCONT_1) : {s = "CONT1"; break;}
2761 case (kCONT_2) : {s = "CONT2"; break;}
2762 case (kCONT_3) : {s = "CONT3"; break;}
2763 case (kCONT_4) : {s = "CONT4"; break;}
2764 default: break;
2765 }
2766 return s;
2767}
2768
2769////////////////////////////////////////////////////////////////////////////////
2770/// Return histogram additive options (Arr,Box,Col,Scat,Col,Text,E,Z,FB,BB).
2771
2773{
2774 TString s="";
2775 if (fDim->GetState()==kButtonDown) {
2776 if (fAddArr->GetState()==kButtonDown) s+="ARR";
2777 if (fAddBox->GetState()==kButtonDown) s+="BOX";
2778 if (fAddCol->GetState()==kButtonDown) s+="COL";
2779 if (fAddScat->GetState()==kButtonDown) s+="SCAT";
2780 if (fAddText->GetState()==kButtonDown) s+="TEXT";
2781 if (fAddPalette->GetState()==kButtonDown) s+="Z";
2782 } else if (fDim0->GetState()==kButtonDown){
2783 if (fAddPalette1->GetState()==kButtonDown) s+="Z";
2784 if (fAddError->GetState()==kButtonDown) s+="E";
2785 if (fAddFB->GetState()==kButtonUp) s+="FB";
2786 if (fAddBB->GetState()==kButtonUp) s+="BB";
2787 }
2788 return s;
2789}
2790
2791////////////////////////////////////////////////////////////////////////////////
2792/// Return draw option string related to graphical cut in use.
2793
2795{
2796 TString cutopt = " ";
2797 TString opt = GetDrawOption();
2798 Int_t scut = opt.First('[');
2799 if (scut != -1) {
2800 Int_t ecut = opt.First(']');
2801 cutopt += opt(scut,ecut);
2802 }
2803 return cutopt;
2804}
2805
2806////////////////////////////////////////////////////////////////////////////////
2807/// Create histogram type combo box.
2808
2810{
2811 TGComboBox *c = new TGComboBox(parent, id);
2812
2813 c->AddEntry("Lego" , kTYPE_LEGO);
2814 c->AddEntry("Lego1", kTYPE_LEGO1);
2815 c->AddEntry("Lego2", kTYPE_LEGO2);
2816 c->AddEntry("Lego3", kTYPE_LEGO3);
2817 c->AddEntry("Lego4", kTYPE_LEGO4);
2818 c->AddEntry("Surf" , kTYPE_SURF);
2819 c->AddEntry("Surf1", kTYPE_SURF1);
2820 c->AddEntry("Surf2", kTYPE_SURF2);
2821 c->AddEntry("Surf3", kTYPE_SURF3);
2822 c->AddEntry("Surf4", kTYPE_SURF4);
2823 c->AddEntry("Surf5", kTYPE_SURF5);
2824
2825 return c;
2826}
2827
2828////////////////////////////////////////////////////////////////////////////////
2829/// Create coordinate system combo box.
2830
2832{
2833 TGComboBox *c = new TGComboBox(parent, id);
2834
2835 c->AddEntry("Cartesian", kCOORDS_CAR);
2836 c->AddEntry("Cylindric", kCOORDS_CYL);
2837 c->AddEntry("Polar", kCOORDS_POL);
2838 c->AddEntry("Rapidity", kCOORDS_PSR);
2839 c->AddEntry("Spheric", kCOORDS_SPH);
2840 TGListBox* lb = c->GetListBox();
2841 lb->Resize(lb->GetWidth(), 83);
2842
2843 return c;
2844}
2845
2846////////////////////////////////////////////////////////////////////////////////
2847/// Create contour combo box.
2848
2850{
2851 TGComboBox *c = new TGComboBox(parent, id);
2852
2853 c->AddEntry("None" , kCONT_NONE);
2854 c->AddEntry("Cont0", kCONT_0);
2855 c->AddEntry("Cont1", kCONT_1);
2856 c->AddEntry("Cont2", kCONT_2);
2857 c->AddEntry("Cont3", kCONT_3);
2858 c->AddEntry("Cont4", kCONT_4);
2859
2860 return c;
2861}
2862
2863////////////////////////////////////////////////////////////////////////////////
2864/// Paint a square in 3D.
2865
2867{
2868 fGedEditor->GetPad()->PaintLine3D(p1, p2);
2869 fGedEditor->GetPad()->PaintLine3D(p2, p3);
2870 fGedEditor->GetPad()->PaintLine3D(p3, p4);
2871 fGedEditor->GetPad()->PaintLine3D(p4, p1);
2872}
2873////////////////////////////////////////////////////////////////////////////////
2874/// Give an array of dividers of n (without the trivial divider n))
2875/// in the first entry the number of dividers is saved.
2876
2878{
2879 Int_t* div;
2880 if (n <= 0) {
2881 div = new Int_t[1];
2882 div[0]=0;
2883 } else if (n == 1) {
2884 div = new Int_t[2];
2885 div[0]=div[1]=1;
2886 } else {
2887 div = new Int_t[(Int_t) n/2+2];
2888 div[0]=0;
2889 div[1]=1;
2890
2891 Int_t num = 1;
2892 for (Int_t i=2; i <= n/2; i++) {
2893 if (n % i == 0) {
2894 num++;
2895 div[num] = i;
2896 }
2897 }
2898 num++;
2899 div[num]=n;
2900 div[0] = num;
2901 }
2902 return div;
2903}
2904
2905////////////////////////////////////////////////////////////////////////////////
2906/// Skip TH1Editor in building list of editors.
2907
2909{
2910 fGedEditor->ActivateEditors(TH1::Class()->GetListOfBases(), kTRUE);
2911}
2912
2913////////////////////////////////////////////////////////////////////////////////
2914/// If the contained histogram obj is deleted we must set its pointer to zero
2915
2917{
2918 if (obj == fHist) {
2919 fHist = 0;
2920 }
2921}
2922
@ 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
@ kWatch
Definition GuiTypes.h:376
@ kPointer
Definition GuiTypes.h:376
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
#define d(i)
Definition RSha256.hxx:102
#define c(i)
Definition RSha256.hxx:101
char * ret
Definition Rotated.cxx:221
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
short Style_t
Style number (short).
Definition RtypesCore.h:96
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kPATTERN
@ kCOLOR
@ 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
@ kLHintsNormal
Definition TGLayout.h:32
@ 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
@ kTYPE_SURF2
@ kTYPE_SURF5
@ kCOORDS_PSR
@ kTYPE_SURF
@ kTYPE_LEGO
@ kTYPE_SURF3
@ kTYPE_LEGO2
@ kTYPE_SURF1
@ kCOORDS_CAR
@ kDIM_COMPLEX
@ kCOORDS_POL
@ kTYPE_SURF4
@ kCOORD_TYPE
@ kBAR_OFFSET
@ kCOORDS_SPH
@ kCOORDS_CYL
@ kDELAYED_DRAWING
@ kTYPE_LEGO1
@ kHIST_TYPE
@ kDIM_SIMPLE
@ kBAR_WIDTH
ETH2Wid
@ kSLIDERX_MAX
@ kBINYSLIDER
@ kSLIDERX_MIN
@ kBACKBOX_ONOFF
@ kCONT_1
@ kERROR_ONOFF
@ kYBINOFFSET
@ kPALETTE_ONOFF1
@ kTYPE_LEGO3
@ kCONT_4
@ kCONT_TYPE
@ kARROW_ONOFF
@ kCONT_LEVELS1
@ kTYPE_LEGO4
@ kCONT_2
@ kSLIDERY_MAX
@ kPALETTE_ONOFF
@ kCONT_0
@ kBINXSLIDER1
@ kCONT_NONE
@ kBOX_ONOFF
@ kSLIDERY_MIN
@ kBINXSLIDER
@ kCONT_LEVELS
@ kBINYSLIDER1
@ kCOL_ONOFF
@ kFRONTBOX_ONOFF
@ kSCAT_ONOFF
@ kTEXT_ONOFF
@ kXBINOFFSET
@ kTH2_TITLE
@ kCONT_3
float xmin
float ymin
float xmax
float ymax
#define gROOT
Definition TROOT.h:417
#define gPad
#define gVirtualX
Definition TVirtualX.h:375
Class to manage histogram axis.
Definition TAxis.h:32
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Definition TAxis.cxx:293
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition TAxis.cxx:522
Int_t GetLast() const
Return last bin on the axis i.e.
Definition TAxis.cxx:473
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
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
static Int_t GetColor(const char *hexcolor)
static ULong_t Number2Pixel(Int_t ci)
Selects different options.
Definition TGButton.h:264
Like a checkbutton but instead of the check mark there is color area with a little down arrow.
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 void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
TGCompositeFrame(const TGCompositeFrame &)=delete
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1196
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1182
Dragging the slider will generate the event:
TGFrame(const TGFrame &)=delete
Bool_t Contains(Int_t x, Int_t y) const
Definition TGFrame.h:240
UInt_t GetWidth() const
Definition TGFrame.h:226
Organizes TGButton widgets in a group with one horizontal row.
Concrete class for horizontal slider.
Definition TGSlider.h:119
A horizontal 3D line is a line that typically separates a toolbar from the menubar.
Definition TG3DLine.h:18
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
A listbox is a box, possibly with scrollbar, containing entries.
Definition TGListBox.h:221
void Resize(UInt_t w, UInt_t h) override
Resize the listbox widget.
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:399
TGNumberEntry is a number entry input widget with up/down buttons.
@ 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
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
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:150
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
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'.
TGedFrame(const TGedFrame &)=delete
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
is a button with pattern area with a little down arrow.
static TClass * Class()
@ kNoAxis
NOTE: Must always be 0 !!!
Definition TH1.h:122
TGNumberEntryField * fSldXMin
Contains the minimum value of the x-Axis.
Definition TH2Editor.h:90
TGCheckButton * fAddArr
CheckBox connected to Arr-Option.
Definition TH2Editor.h:60
TGNumberEntryField * fYOffsetNumberEntry
Shows the offset to the y origin of the histogram.
Definition TH2Editor.h:87
virtual void DoOffsetPressed()
Slot connected to the OffSetSlider.
TGNumberEntry * fContLevels1
Set number of contour levels.
Definition TH2Editor.h:68
virtual void DoBarWidth()
Slot connected to the bar width of the bar chart.
TGCompositeFrame * f9
Frame that contains the 3D CheckBox DrawOptions.
Definition TH2Editor.h:53
Float_t fP4oldy[3]
Definition TH2Editor.h:130
virtual void DoBinReleased()
Slot connected to the rebin slider in case of no ntuple histogram.
TGCheckButton * fAddBB
Draw back box (or not).
Definition TH2Editor.h:65
TGNumberEntryField * fXOffsetNumberEntry
Shows the offset to the x origin of the histogram.
Definition TH2Editor.h:81
Float_t fP3oldx[3]
Definition TH2Editor.h:121
Float_t fP5oldy[3]
Definition TH2Editor.h:131
TGCheckButton * fAddFB
Draw front box (or not).
Definition TH2Editor.h:64
TGCompositeFrame * fBinXCont
Contains the rebin widgets for case 1.
Definition TH2Editor.h:71
virtual void DoBinPressed()
Slot connected to the rebin slider in case of no ntuple histogram.
TGDoubleHSlider * fSliderY
Slider to set y-axis range.
Definition TH2Editor.h:92
void CreateBinTab()
Create the Binning tab.
TH2 * fBinHist
Definition TH2Editor.h:135
TGTextButton * fApply
Apply-Button to accept the rebinned histogram.
Definition TH2Editor.h:76
TGCompositeFrame * f6
Frame that contains the 2D CheckBox DrawOptions.
Definition TH2Editor.h:52
virtual void DoAddError(Bool_t on)
Slot connected to the "Error" check button.
virtual void DoAddArr(Bool_t on)
Slot connected to the "Arrow draw option" check button.
TGCheckButton * fAddError
CheckBox connected to error bars.
Definition TH2Editor.h:57
TGHSlider * fBinYSlider1
Slider to set y rebinning integer value.
Definition TH2Editor.h:85
Float_t fP8oldy[3]
Definition TH2Editor.h:134
TGNumberEntryField * fBinXNumberEntry1
Label which shows the rebinned x bin number.
Definition TH2Editor.h:80
virtual void DoAddBB()
Slot connected to the "BB back-box draw option" check button.
TGCheckButton * fAddPalette1
CheckBox connected to Z option (3D).
Definition TH2Editor.h:59
TGCompositeFrame * f38
Frame that contains the Frame Fill widgets.
Definition TH2Editor.h:56
virtual void DoFillPattern(Style_t)
Slot connected to the fill area pattern.
Float_t fP2oldx[3]
Definition TH2Editor.h:120
TGDoubleHSlider * fSliderX
Slider to set x-axis range.
Definition TH2Editor.h:89
virtual void DoApply()
Slot connected to the Apply Button in the Rebinned histogram Window.
TGNumberEntryField * fBinYNumberEntry
Label which shows the rebinned bin number.
Definition TH2Editor.h:75
TGHSlider * fBinYSlider
Slider to set rebinning y integer value.
Definition TH2Editor.h:74
Double_t fOldXOffset
Definition TH2Editor.h:136
TGHSlider * fYBinOffsetSld
Add an y-offset to the origin of the histogram.
Definition TH2Editor.h:88
TGNumberEntryField * fBinXNumberEntry
Label which shows the rebinned bin number.
Definition TH2Editor.h:73
Float_t fP7oldx[3]
Definition TH2Editor.h:125
virtual void DoSliderYPressed()
Slot connected to y-axis slider which initialises the "virtual" box which is drawn in delay draw mode...
TGCheckButton * fAddPalette
CheckBox connected to Z option (2D).
Definition TH2Editor.h:58
TGCompositeFrame * fBinXCont1
Contains the X Rebin Widgets for case 2.
Definition TH2Editor.h:78
Float_t fP1oldx[3]
Definition TH2Editor.h:119
TString fCutString
Contais info about graphical cuts (if any).
Definition TH2Editor.h:98
virtual void DoOffsetMoved()
Slot connected to the OffSetSlider.
void PaintBox3D(Float_t *p1, Float_t *p2, Float_t *p3, Float_t *p4)
Paint a square in 3D.
TGRadioButton * fDim
2D-Plot RadioButton
Definition TH2Editor.h:48
TGNumberEntry * fBarWidth
Set bar width of histogram.
Definition TH2Editor.h:69
TGNumberEntryField * fSldYMin
Contains the minimum value of the y-Axis.
Definition TH2Editor.h:93
virtual void DoYAxisRange()
Slot connected to the Max/Min number entry fields showing y-axis range.
virtual void DoContLevel()
Slot connected to the contour level number entry fContLevels.
virtual void DoContLevel1()
Slot connected to the contour level number entry fContLevels1.
TGHSlider * fBinXSlider
Slider to set rebinning x integer value.
Definition TH2Editor.h:72
TGHSlider * fXBinOffsetSld
Add an x-offset to the origin of the histogram.
Definition TH2Editor.h:82
void RecursiveRemove(TObject *obj) override
If the contained histogram obj is deleted we must set its pointer to zero.
virtual void DoAddPalette(Bool_t on)
Slot connected to the color palette check button.
TGRadioButton * fDim0
3D-Plot RadioButton
Definition TH2Editor.h:49
virtual void DoHistChanges()
Slot connected to histogram type, coordinate system, contour combo box.
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGLayoutHints * fDimlh
layout hints for 2D-Plot RadioButton
Definition TH2Editor.h:50
TGCheckButton * fAddScat
CheckBox connected to Scat-Option.
Definition TH2Editor.h:62
virtual void DoBinLabel1()
Slot connected to the Bin Number Entry for the Rebin.
Int_t fTitlePrec
font precision level
Definition TH2Editor.h:46
TGLabel * fColContLbl
No. of Contours Label 1.
Definition TH2Editor.h:44
TGNumberEntry * fContLevels
Set number of contour levels.
Definition TH2Editor.h:67
TString GetHistTypeLabel()
Return the immediate histogram type (HIST, LEGO1-4, SURF1-5).
TGedPatternSelect * fFramePattern
Select the Frame Pattern Style.
Definition TH2Editor.h:97
TGCheckButton * fDelaydraw
Delayed drawing of the new axis range.
Definition TH2Editor.h:95
void SetModel(TObject *obj) override
Pick up the values of current histogram attributes.
TGHSlider * fBinXSlider1
Slider to set x rebinning integer value.
Definition TH2Editor.h:79
Float_t fP2oldy[3]
Definition TH2Editor.h:128
Float_t fP8oldx[3]
Definition TH2Editor.h:126
static TGComboBox * BuildHistCoordsComboBox(TGFrame *parent, Int_t id)
Create coordinate system combo box.
TGLayoutHints * fDim0lh
layout hints for 3D-Plot RadioButton
Definition TH2Editor.h:51
virtual void DoAddScat(Bool_t on)
Slot connected to the "Scat draw option" check button.
virtual void DoSliderXReleased()
Slot connected to the x-axis slider finalizing values after the slider movement.
TGCheckButton * fAddCol
CheckBox connected to Col-Option.
Definition TH2Editor.h:63
virtual void DoSliderXPressed()
Slot connected to the x axis range slider that initialises the "virtual" box which is drawn in delay ...
TGCheckButton * fAddBox
CheckBox connected to Box-Option.
Definition TH2Editor.h:61
virtual void DoAddText(Bool_t on)
Slot connected to the "Text draw option" check button.
TH2 * fHist
histogram object
Definition TH2Editor.h:37
TH2Editor(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.
virtual void DoHistView()
Slot connected to the 'Plot' button group.
Bool_t AcceptModel(TObject *model) override
Check if object is able to configure with this editor.
virtual void DoXAxisRange()
Slot connected to the Max/Min number entry fields showing x-axis range.
Float_t fP6oldx[3]
Definition TH2Editor.h:124
TGCheckButton * fAddText
Draw bin contents as text.
Definition TH2Editor.h:66
TString GetCutOptionString()
Return draw option string related to graphical cut in use.
Int_t * Dividers(Int_t n)
Give an array of dividers of n (without the trivial divider n)) in the first entry the number of divi...
TString GetHistContLabel()
Returns histogram contour option (None,Cont0..5).
virtual void DoBinReleased1()
Slot connected to the BinNumber Slider in case of a 'ntuple histogram'.
TGColorSelect * fFrameColor
Select the Frame Color.
Definition TH2Editor.h:96
TString GetHistCoordsLabel()
Return the immediate coordinate system of the histogram.
Int_t fPx1old
Definition TH2Editor.h:115
virtual void DoSliderYMoved()
Slot connected to the x-slider for redrawing the histogram with the new slider Range (immediately).
virtual void DoBinLabel()
Slot connected to the Bin Number Entry for the Rebin.
TGTextButton * fCancel
Cancel-Button to reprobate the rebinned histogram.
Definition TH2Editor.h:77
TGCompositeFrame * fBin
Contains the Binning Widgets.
Definition TH2Editor.h:38
TGNumberEntryField * fSldYMax
Contains the maximum value of the y-Axis.
Definition TH2Editor.h:94
Double_t fOldYOffset
Definition TH2Editor.h:137
~TH2Editor() override
Destructor.
TGCompositeFrame * f13
Frame that contains the Bar Width/Offset NumberEntries.
Definition TH2Editor.h:55
TGNumberEntryField * fSldXMax
Contains the maximum value of the x-Axis.
Definition TH2Editor.h:91
virtual void DoBinMoved1()
Slot connected to the rebin slider in case of an ntuple histogram.
virtual void DoTitle(const char *text)
Slot connected to the histogram title setting.
Float_t fP5oldx[3]
Definition TH2Editor.h:123
Float_t fP4oldx[3]
Definition TH2Editor.h:122
TGComboBox * fContCombo
Contour selecting combo box.
Definition TH2Editor.h:43
Int_t fPy2old
Definition TH2Editor.h:118
Int_t fPy1old
Definition TH2Editor.h:116
TGTextEntry * fTitle
histogram title input field
Definition TH2Editor.h:40
virtual void DoAddCol(Bool_t on)
Slot connected to the "Col draw option" check button.
virtual void DoBarOffset()
Slot connected to the bar offset of the bar chart.
virtual void DoOffsetReleased()
Slot connected to the OffSetSlider that changes the origin of the histogram inbetween a binwidth; reb...
virtual void DoBinOffset()
Slot connected to the OffSetNumberEntry, related to the OffSetSlider changes the origin of the histog...
TGLabel * fColContLbl1
No. of Contours Label 2.
Definition TH2Editor.h:45
static TGComboBox * BuildHistTypeComboBox(TGFrame *parent, Int_t id)
Create histogram type combo box.
Float_t fP3oldy[3]
Definition TH2Editor.h:129
void ActivateBaseClassEditors(TClass *cl) override
Skip TH1Editor in building list of editors.
Float_t fP1oldy[3]
Definition TH2Editor.h:127
static TGComboBox * BuildHistContComboBox(TGFrame *parent, Int_t id)
Create contour combo box.
TGNumberEntry * fBarOffset
Set bar offset of histogram.
Definition TH2Editor.h:70
TGComboBox * fCoordsCombo
Coordinate System combo box.
Definition TH2Editor.h:42
virtual void DoCancel()
Slot connected to the Cancel Button in the Rebinned histogram Window.
Float_t fP7oldy[3]
Definition TH2Editor.h:133
Int_t fPx2old
Definition TH2Editor.h:117
TGCompositeFrame * fBinYCont1
Contains the Y Rebin Widgets for case 2.
Definition TH2Editor.h:84
Float_t fP6oldy[3]
Definition TH2Editor.h:132
virtual void DoSliderYReleased()
Slot connected to the y-axis slider finalizing values after the slider movement.
TGHButtonGroup * fDimGroup
Radiobuttongroup to change 2D <-> 3D-Plot.
Definition TH2Editor.h:47
virtual void DoBinMoved()
Slot connected to the rebin sliders in case of no ntuple histogram does the rebinning of the selected...
virtual void DoAddFB()
Slot connected to the "FB front-box draw option" check button.
TString GetHistAdditiveLabel()
Return histogram additive options (Arr,Box,Col,Scat,Col,Text,E,Z,FB,BB).
TGNumberEntryField * fBinYNumberEntry1
Label which shows the rebinned y bin number.
Definition TH2Editor.h:86
TGComboBox * fTypeCombo
histogram type combo box
Definition TH2Editor.h:41
virtual void DoHistSimple()
Slot connected to the 2D-Plot radio button.
virtual void DoFillColor(Pixel_t)
Slot connected to the fill area color.
virtual void DoAddBox(Bool_t on)
Slot connected to the "Box draw option" check button.
virtual void DoHistComplex()
Slot connected to the 3D-Plot radio button.
virtual void DoSliderXMoved()
Slot connected to the x-Slider that redraws the histogram with the new slider range.
TGCompositeFrame * f12
Frame that contains the Bar-Title.
Definition TH2Editor.h:54
Service class for 2-D histogram classes.
Definition TH2.h:30
static TClass * Class()
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:549
A specialized TSelector for TTree::Draw.
virtual void TakeAction()
Execute action for object obj fNfill times.
Basic string class.
Definition TString.h:138
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition TString.cxx:545
const char * Data() const
Definition TString.h:384
void ToUpper()
Change string to upper case.
Definition TString.cxx:1202
TString & Remove(Ssiz_t pos)
Definition TString.h:694
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:641
Implement some of the functionality of the class TTree requiring access to extra libraries (Histogram...
Definition TTreePlayer.h:37
TH1 * GetHistogram() const override
Definition TTreePlayer.h:75
Int_t GetNfill() const override
Definition TTreePlayer.h:78
TSelector * GetSelector() const override
Definition TTreePlayer.h:82
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).
TText * text
const Int_t n
Definition legend1.C:16