Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TH1Editor.h
Go to the documentation of this file.
1 // @(#)root/ged:$Id$
2 // Author: Carsten Hof 16/08/04
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TH1Editor
13 #define ROOT_TH1Editor
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TH1Editor //
18 // //
19 // Editor changing histogram attributes (Type, Coords, Error, Style) //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 #include "TGedFrame.h"
24 
25 
26 class TH1;
27 class TGComboBox;
28 class TGNumberEntry;
29 class TGCheckButton;
30 class TGButtonGroup;
31 class TGHButtonGroup;
32 class TString;
33 class TGRadioButton;
34 class TGDoubleHSlider;
35 class TGHSlider;
36 class TGTextEntry;
37 class TGNumberEntryField;
38 class TGTextButton;
39 
40 class TH1Editor : public TGedFrame {
41 
42 protected:
43  TH1 *fHist; // histogram object
44  Bool_t fSameOpt; // flag for option "same"
45  TGCompositeFrame *fBin; // Contains the Binning Widgets
46  Int_t fTitlePrec; // font precision level
47  TGTextEntry *fTitle; // histogram title input field
48  TGHButtonGroup *fDimGroup; // Radiobuttongroup to change 2D <-> 3D-Plot
49  TGRadioButton *fDim; // 2D-Plot RadioButton
50  TGRadioButton *fDim0; // 3D-Plot RadioButton
51  TGLayoutHints *fDimlh; // layout hints for 2D-Plot RadioButton
52  TGLayoutHints *fDim0lh; // layout hints for 3D-Plot RadioButton
53  TGComboBox *fTypeCombo; // histogram type combo box
54  TGComboBox *fCoordsCombo; // Coordinate System combo box
55  TGComboBox *fErrorCombo; // Error combo box
56  TGCheckButton *fHistOnOff; // Draw a simple histogram with default options
57  TGCheckButton *fAddMarker; // Draw a Marker on top of each bin
58  TGCheckButton *fAddB; // Draw a Bar Chart
59  TGCheckButton *fAddBar; // Bar Option
60  TGCheckButton *fAdd; // Activate more Options
61  TGCheckButton *fMakeHBar; // Draw Horizontal Bar Chart
62  TGCheckButton *fAddSimple; // Draw a simple histogram (==HIST draw option)
63  TGNumberEntry *fBarWidth; // Change the Bar Width
64  TGNumberEntry *fBarOffset; // Change the Bar Offset
65  TGComboBox *fAddCombo; // Add Lines, Bars, Fill
66  TGComboBox *fPercentCombo; // Percentage of the Bar which is drawn in a different color
67  TGCompositeFrame *f3; // Contains Histogram Type
68  TGCompositeFrame *f6; // Contains the Add-ComboBox (Style)
69  TGCompositeFrame *f7; // Contains the Marker OnOff CheckBox
70  TGCompositeFrame *f8; // Contains the Bar Chart CheckBox
71  TGCompositeFrame *f9; // Contains the Bar Option CheckBox
72  TGCompositeFrame *f10; // Contains the Bar Option Title
73  TGCompositeFrame *f11; // Contains the Bar Width/Offset NumberEntries
74  TGCompositeFrame *f12; // Contains fPercentCombo, fMakeHBar
75  TGCompositeFrame *f15; // Contains outer line CheckBox
76  TGCompositeFrame *fBinCont; // Contains the Rebin Widgets for case 1
77  TGCompositeFrame *fBinCont1; // Contains the Rebin Widgets for case 2
78  TGHSlider *fBinSlider; // Slider to set rebinning integer value
79  TGHSlider *fBinSlider1; // Slider to set rebinning integer value for ntuple histogram
80  TGNumberEntryField *fBinNumberEntry; // Label which shows the rebinned bin number
81  TGNumberEntryField *fBinNumberEntry1; // Label which shows the rebinned bin number for ntuple histogram
82  TGHSlider *fBinOffsetSld; // Add an offset to the origin of the histogram
83  TGNumberEntryField *fOffsetNumberEntry;// Shows the offset to the origin of the histogram
84  TGDoubleHSlider *fSlider; // Slider to set x-axis range
85  TGNumberEntryField *fSldMin; // Contains the minimum value of the x-Axis
86  TGNumberEntryField *fSldMax; // Contains the maximum value of the x-Axis
87  TGCheckButton *fDelaydraw; // Delayed drawing of the new axis range
88  TGTextButton *fApply; // Apply-Button to accept the rebinned histogram
89  TGTextButton *fCancel; // Cancel-Button to reprobate the rebinned histogram
90 
91  static TGComboBox *BuildHistTypeComboBox(TGFrame *parent, Int_t id); // builts the Type ComboBox
92  static TGComboBox *BuildHistCoordsComboBox(TGFrame *parent, Int_t id); // builts the Coordinate ComboBox
93  static TGComboBox *BuildHistErrorComboBox(TGFrame *parent, Int_t id); // builts the Error ComboBox
94  static TGComboBox *BuildHistAddComboBox(TGFrame *parent, Int_t id); // builts the Add ComboBox
95  static TGComboBox *BuildPercentComboBox(TGFrame *parent, Int_t id); // builts the ComboBox for setting the Bar options bar1,..., bar4
96 
97  virtual void ConnectSignals2Slots(); // connect the signals to the slots
98  void CreateBinTab(); // Creates the Bin Tab (part of the SetGedEditor)
99 
100 
101 private:
102  Bool_t fMake; // Veto Variable
103  Bool_t fMakeB; // avoid execution of Bar Slots
104  Int_t fPx1old, // save the coordinates of the "virtual box" in delay draw mode (2D Plot)
105  fPy1old,
106  fPx2old,
107  fPy2old;
108  Float_t fP1NDCold[3], // save the coordinates of the "virtual box" in delay draw mode
109  fP2NDCold[3],
110  fP3NDCold[3],
111  fP4NDCold[3];
112  Float_t fP1old[3], // save the coordinates of the "virtual box" in delay draw mode (3D plot)
113  fP2old[3],
114  fP3old[3],
115  fP4old[3],
116  fP5old[3],
117  fP6old[3],
118  fP7old[3],
119  fP8old[3];
120  TH1 *fBinHist; // Cloned histogram for rebin
121  Double_t fOldOffset; // save the old offset of the histogram
122 
123  TString GetHistTypeLabel(); // Get the Histogram Type = String which contains the Histogram Draw Option
124  TString GetHistCoordsLabel(); // Get the histogram coordinate system (CYL, SPH, PSR, ..)
125  TString GetHistErrorLabel(); // Get the histogram Error type (E1, .., E4)
126  TString GetHistAddLabel(); // Get the histogram addon (smooth line, simple line, ..)
127  void ChangeErrorCombo(Int_t i);
128 
129 
130 public:
131  TH1Editor(const TGWindow *p = 0,
132  Int_t width = 140, Int_t height = 30,
133  UInt_t options = kChildFrame,
134  Pixel_t back = GetDefaultFrameBackground());
135  virtual ~TH1Editor();
136 
137  virtual Bool_t AcceptModel(TObject* model);
138  virtual void SetModel(TObject* obj);
139 
140  virtual void DoTitle(const char *text);
141  virtual void DoAddMarker(Bool_t on);
142  virtual void DoAddBar(Bool_t);
143  virtual void DoAddB(Bool_t);
144  virtual void DoAddSimple(Bool_t on);
145  virtual void DoHistSimple();
146  virtual void DoHistComplex();
147  virtual void DoHistChanges();
148  virtual void DoHistView();
149  virtual void DoBarOffset();
150  virtual void DoBarWidth();
151  virtual void DoPercent();
152  virtual void DoHBar(Bool_t on);
153  virtual void DoSliderMoved();
154  virtual void DoSliderPressed();
155  virtual void DoSliderReleased();
156  virtual void DoAxisRange();
157  virtual void DoBinMoved(Int_t number);
158  virtual void DoBinReleased();
159  virtual void DoBinPressed();
160  virtual void DoBinLabel();
161  virtual void DoBinReleased1();
162  virtual void DoBinMoved1();
163  virtual void DoBinLabel1();
164  virtual void DoOffsetMoved(Int_t num);
165  virtual void DoOffsetReleased();
166  virtual void DoOffsetPressed();
167  virtual void DoBinOffset();
168  virtual void DoApply();
169  virtual void DoCancel();
170  virtual void PaintBox3D(Float_t *p1, Float_t *p2,Float_t *p3, Float_t *p4);
171  Int_t* Dividers(Int_t n);
172  virtual void RecursiveRemove(TObject* obj);
173 
174 
175  ClassDef(TH1Editor,0) // TH1 editor
176 };
177 
178 #endif