library: libGed #include "TH1Editor.h"

# TH1Editor

class description - source file - inheritance tree (.pdf)

## class TH1Editor : public TGedFrame

| Inheritance Chart:
`TObject`
| <- | `TGObject`
| <- | `TGWindow`
`TQObject`
| <- | `TGFrame`
| <- | `TGCompositeFrame`
`TGWidget`
| <- | `TGedFrame`
| <- | `TH1Editor` |

        private:

             void ChangeErrorCombo(Int_t i)
             void CreateBinTab()
             void CreateFitTab()
          TString GetHistAddLabel()
          TString GetHistCoordsLabel()
          TString GetHistErrorLabel()
          TString GetHistTypeLabel()

        protected:

          static TGComboBox* BuildHistAddComboBox(TGFrame* parent, Int_t id)
          static TGComboBox* BuildHistCoordsComboBox(TGFrame* parent, Int_t id)
          static TGComboBox* BuildHistErrorComboBox(TGFrame* parent, Int_t id)
          static TGComboBox* BuildHistTypeComboBox(TGFrame* parent, Int_t id)
          static TGComboBox* BuildPercentComboBox(TGFrame* parent, Int_t id)
                virtual void ConnectSignals2Slots()

        public:

                          TH1Editor(const TGWindow* p, Int_t id, Int_t width = 140, Int_t height = 30, UInt_t options = kChildFrame, Pixel_t back = GetDefaultFrameBackground())
                          TH1Editor(const TH1Editor&)
                  virtual ~TH1Editor()
           static TClass* Class()
                   Int_t* Dividers(Int_t n)
             virtual void DoAddB(Bool_t)
             virtual void DoAddBar(Bool_t)
             virtual void DoAddMarker(Bool_t on)
             virtual void DoAddSimple(Bool_t on)
             virtual void DoApply()
             virtual void DoAxisRange()
             virtual void DoBarOffset()
             virtual void DoBarWidth()
             virtual void DoBinLabel()
             virtual void DoBinLabel1()
             virtual void DoBinMoved(Int_t number)
             virtual void DoBinMoved1()
             virtual void DoBinOffset()
             virtual void DoBinPressed()
             virtual void DoBinReleased()
             virtual void DoBinReleased1()
             virtual void DoCancel()
             virtual void DoHBar(Bool_t on)
             virtual void DoHistChanges()
             virtual void DoHistComplex()
             virtual void DoHistSimple()
             virtual void DoOffsetMoved(Int_t num)
             virtual void DoOffsetPressed()
             virtual void DoOffsetReleased()
             virtual void DoPercent()
             virtual void DoSliderMoved()
             virtual void DoSliderPressed()
             virtual void DoSliderReleased()
             virtual void DoTitle(const char* text)
          virtual TClass* IsA() const
             virtual void PaintBox3D(Float_t* p1, Float_t* p2, Float_t* p3, Float_t* p4)
             virtual void SetModel(TVirtualPad* pad, TObject* obj, Int_t event)
             virtual void ShowMembers(TMemberInspector& insp, char* parent)
             virtual void Streamer(TBuffer& b)
                     void StreamerNVirtual(TBuffer& b)

### Data Members

        private:

            Bool_t fMake         Veto Variable
            Bool_t fMakeB        avoid execution of Bar Slots
             Int_t fPx1old
             Int_t fPy1old
             Int_t fPx2old
             Int_t fPy2old
           Float_t fP1NDCold[3]
           Float_t fP2NDCold[3]
           Float_t fP3NDCold[3]
           Float_t fP4NDCold[3]
           Float_t fP1old[3]
           Float_t fP2old[3]
           Float_t fP3old[3]
           Float_t fP4old[3]
           Float_t fP5old[3]
           Float_t fP6old[3]
           Float_t fP7old[3]
           Float_t fP8old[3]
              TH1* fBinHist      Cloned histogram for rebin
          Double_t fOldOffset    save the old offset of the histogram

        protected:

                         TH1* fHist               histogram object
                       TGTab* fTab                Pointer to the Tab Parent
            TGCompositeFrame* fBin                Contains the Binning Widgets
            TGCompositeFrame* fFit                Contains the Fitting Widgets
            TGCompositeFrame* fStyle              Contains the Style Widgets
            TGCompositeFrame* fBinContainer       Container for fBin
            TGCompositeFrame* fFitContainer       Container for fFit
                        Int_t fTitlePrec          font precision level
                 TGTextEntry* fTitle              histogram title input field
              TGHButtonGroup* fDimGroup           Radiobuttongroup to change 2D <-> 3D-Plot
               TGRadioButton* fDim                2D-Plot RadioButton
               TGRadioButton* fDim0               3D-Plot RadioButton
                  TGComboBox* fTypeCombo          histogram type combo box
                  TGComboBox* fCoordsCombo        Coordinate System combo box
                  TGComboBox* fErrorCombo         Error combo box
               TGCheckButton* fHistOnOff          Draw a simple histogram with default options
               TGCheckButton* fAddMarker          Draw a Marker on top of each bin
               TGCheckButton* fAddB               Draw a Bar Chart
               TGCheckButton* fAddBar             Bar Option
               TGCheckButton* fAdd                Activate more Options
               TGCheckButton* fMakeHBar           Draw Horizontal Bar Chart
               TGCheckButton* fAddSimple          Draw a simple histogram  (==HIST draw option)
               TGNumberEntry* fBarWidth           Change the Bar Width
               TGNumberEntry* fBarOffset          Change the Bar Offset
                  TGComboBox* fAddCombo           Add Lines, Bars, Fill
                  TGComboBox* fPercentCombo       Percentage of the Bar which is drawn in a different color
            TGCompositeFrame* f3                  Contains Histogram Type
            TGCompositeFrame* f4                  Contains Histogram Coordinate Type
            TGCompositeFrame* f6                  Contains the Add-ComboBox (Style)
            TGCompositeFrame* f7                  Contains the Marker OnOff CheckBox
            TGCompositeFrame* f8                  Contains the Bar Chart CheckBox
            TGCompositeFrame* f9                  Contains the Bar Option CheckBox
            TGCompositeFrame* f10                 Contains the Bar Option Title
            TGCompositeFrame* f11                 Contains the Bar Width/Offset NumberEntries
            TGCompositeFrame* f12                 Contains fPercentCombo, fMakeHBar
            TGCompositeFrame* f15                 Contains outer line CheckBox
            TGCompositeFrame* fBinCont            Contains the Rebin Widgets for case 1
            TGCompositeFrame* fBinCont1           Contains the Rebin Widgets for case 2
                   TGHSlider* fBinSlider          Slider to set rebinning integer value
                   TGHSlider* fBinSlider1         Slider to set rebinning integer value for ntuple histogram
          TGNumberEntryField* fBinNumberEntry     Label which shows the rebinned bin number
          TGNumberEntryField* fBinNumberEntry1    Label which shows the rebinned bin number for ntuple histogram
                   TGHSlider* fBinOffsetSld       Add an offset to the origin of the histogram
          TGNumberEntryField* fOffsetNumberEntry  Shows the offset to the origin of the histogram
             TGDoubleHSlider* fSlider             Slider to set x-axis range
          TGNumberEntryField* fSldMin             Contains the minimum value of the x-Axis
          TGNumberEntryField* fSldMax             Contains the maximum value of the x-Axis
               TGCheckButton* fDelaydraw          Delayed drawing of the new axis range
                TGTextButton* fApply              Apply-Button to accept the rebinned histogram
                TGTextButton* fCancel             Cancel-Button to reprobate the rebinned histogram

## Class Description

      TH1Editor
      Editor for changing TH1 histogram attributes, rebinning & fitting.
      For all possible draw options (there are a few which are not imple-
      mentable in graphical user interface) see THistPainter::Paint in
      root/histpainter/THistPainter.cxx

/* */

/* */

      These changes can be made via the TH1Editor:
        Style Tab:
          'Line'     : change Line attributes (color, thickness)
                       see TAttLineEditor
          'Fill'     : change Fill attributes (color, pattern)
                       see TAttFillEditor
    	'Title'    : TextEntry: set the title of the histogram
          'Histogram': change the draw options of the histogram
              'Plot' : Radiobutton: draw a 2D or 3D plot of the histogram
                       according to the Plot dimension there will be
                       different drawing possibilities (ComboBoxes/
                       CheckBoxes)
        2d Plot:
          'Error'   : ComboBox: add different error bars to the histogram
                      (no errors, simple, ...,  see THistPainter::Paint
          'Add'     : ComboBox: further things which can be added to the
                      histogram (None, simple/smooth line, fill area
          'Simple Drawing': CheckBox: draw a simple histogram without
                      errors (= "HIST" drawoption). In combination with
                      some other draw options an outer line is drawn on
                      top of the histogram
          'Show markers': CheckBox: draw a marker on to of each bin (="P"
                      drawoption)
          'Draw bar chart': CheckBox: draw a bar chart (="B" drawoption)
                      change the Fill Color with Fill in the Style Tab
                      => will show Bar menue in the Style Tab
          'Bar option': CheckBox: draw a bar chart (="BAR" drawoption)
                      => will show Bar menue in the Style Tab
        3d Plot:
          'Type'    : ComboBox: set histogram type Lego-Plot or Surface
                      draw(Lego, Lego1.2, Surf, Surf1..5)
                      see THistPainter::Paint
          'Coords'  : ComboBox: set the coordinate system (Cartesian, ..
                      Spheric) see THistPainter::Paint
          'Error'   : see 2D plot
          'Bar'     : change the bar attributes
                'W' : change Bar Width
                'O' : change Bar Offset
          'Percentage': specifies the percentage of the bar which is drawn
                        brighter and darker (10% == BAR1 drawoption)
          'Horizontal Bar': draw a horizontal bar chart

          'Marker'   : change the Marker attributes (color, appearance,
                       thickness) see TAttMarkerEditor

/* */

          This Tab has two different layouts. One is for a histogram which
          is not drawn from an ntuple. The other one is available for a
          histogram which is drawn from an ntuple. In this case the rebin
          algorithm can create a rebinned histogram from the original data
          i.e. the ntuple.
          To see te differences do:
             TFile f("hsimhe differences do:
             TFile f("hsimple.root");
             hpx->Draw("BAR1);         // non ntuple histogram
             ntuple->Draw("px");       // ntuple histogram
        Non ntuple histogram:
           'Rebin': with the Slider the number of bins (shown in the field
                    below the Slider) can be changed to any number which
                    divides the number of bins of the original histogram.
                    Pushing 'Apply' will delete the origin histogram and
                    replace it by the rebinned one on the screen
                    Pushing 'Ignore' the origin histogram will be restored
        Histogram drawn from an ntuple:
           'Rebin'  with the slider the number of bins can be enlarged by
                    a factor of 2,3,4,5 (moving to the right) or reduced
                    by a factor of 1/2, 1/3, 1/4, 1/5
           'BinOffset': with the BinOffset slider the origin of the
                    histogram can be changed within one binwidth
                    Using this slider the effect of binning the data into
                    bins can be made visible => statistical fluctuations
           'Axis Range': with the DoubleSlider it is possible to zoom into
                    the specified axis range. It is also possible to set
                    the upper and lower limit in fields below the slider
           'Delayed drawing': all the Binning sliders can set to delay
                    draw mode. Then the changes on the histogram are only
                    updated, when the Slider is released. This should be
                    activated if the redrawing of the histogram is too
                    time consuming.

/* */

/* */

TH1Editor(const TGWindow *p, Int_t id, Int_t width, Int_t height, UInt_t options, Pixel_t back) : TGedFrame(p, id, width, height, options | kVerticalFrame, back)

     Constructor of histogram attribute GUI.

~TH1Editor()

     Destructor of TH1 editor.

void ConnectSignals2Slots()

     Connect signals to slots.

void SetModel(TVirtualPad* pad, TObject* obj, Int_t)

     Pick up the used values of histogram attributes.

void DoTitle(const char *text)

     Slot connected to the title of the histogram .

void DoAddMarker(Bool_t on)

     Slot connected to the marker add checkbox .

void DoAddB(Bool_t on)

     Slot connected to the bar add checkbox .

void DoAddBar(Bool_t on)

     Slot connected to the bar add checkbox .

void DoAddSimple(Bool_t on)

     Slot connected to fAddSimple CheckBox
     draws a simple histogram without errors (== HIST draw option)
     in combination with some other drawoptions it draws an additional line on top of the bins

void DoHistSimple()

     Slot connected to the simple histogram radiobutton

void DoHistComplex()

     Slot connected to the complex histogram radiobutton

void DoHistChanges()

     Slot connected to the histogram type, the coordinate type, the error type
     and the AddCombobox

void DoBarWidth()

     Slot connected to the Bar Width of the Bar Chart

void DoBarOffset()

     Slot connected to the Bar Offset of the Bar Chart

void DoPercent()

     Slot connected percentage of ???

void DoHBar(Bool_t on)

     Slot connected to the Horizontal Bar CheckButton

void DoSliderMoved()

     Slot connected to the x-Slider
     Redraws the Histogram with the new Slider Range

void DoSliderPressed()

     Slot connected to the x-axis Range slider
     Initialising the values for the Slider Movement

void DoSliderReleased()

     Slot connected to the x-axis Range slider
     Finalizing the values from the Slider Movement

void DoAxisRange()

     Slot connected to the TextNumberEntryFields which contain the Max/Min value of the x-axis

void DoBinReleased()

     Slot connected to the rebin slider in case of a not ntuple histogram
     Updates some other widgets which are related to the rebin slider

void DoBinMoved(Int_t numx)

     Slot connected to the rebin slider in case of a not ntuple histogram
     does the Rebinning of the Histogram

void DoBinPressed()

     Slot connected to the rebin slider in case of a not ntuple histogram
     to avoid stupid things

void DoBinReleased1()

     Slot connected to the BinNumber Slider in case of a 'Ntuple histogram'
     Does the Rebin

void DoBinMoved1()

     Slot connected to the rebin slider in case of an ntuple histogram
     Updates the BinNumberEntryField during the BinSlider movement

void DoBinLabel()

     Slot connected to the Bin Number Entry for the Rebin

void DoBinLabel1()

     Slot connected to the Bin Number Entry for the Rebin

void DoOffsetPressed()

     Slot connected to the OffSetSlider
     saves the OldBinOffset
     nessesary for delay draw mode

void DoOffsetReleased()

     Slot connected to the OffSetSlider
     changes the origin of the histogram inbetween a binwidth
     Rebin the histogram with the new Offset given by the Slider
     problem: histogram with variable binwidth??
     computes the new histogram in "delay draw" mode

void DoOffsetMoved(Int_t num)

     Slot connected to the OffSetSlider
     changes the origin of the histogram inbetween a binwidth
     Rebin the histogram with the new Offset given by the Slider
     histogram with variable binwidth??
     only working for histograms with fixed binwidth

void DoBinOffset()

     Slot connected to the OffSetNumberEntry which is related to the OffSetSlider
     changes the origin of the histogram inbetween a binwidth

void DoApply()

     Slot connected to the Apply Button

void DoCancel()

     Slot connected to the Cancel Button in the Rebinned histogram Window

TString GetHistTypeLabel()

     Returns the immediate histogram type (HIST, LEGO1-2, SURF1-5)

TString GetHistCoordsLabel()

     Returns the immediate coordinate system of the histogram (POL, CYL, SPH,PSR)

TString GetHistErrorLabel()

     Returns the immediate error type (E,E1-5)

TString GetHistAddLabel()

     Returns the immediate shape of the histogram (C, L, LF2)

TGComboBox* BuildHistTypeComboBox(TGFrame* parent, Int_t id)

     Create histogram type combo box.

TGComboBox* BuildHistCoordsComboBox(TGFrame* parent, Int_t id)

     Create histogram coordinate system type combo box.

TGComboBox* BuildHistErrorComboBox(TGFrame* parent, Int_t id)

     Create histogram error type combo box.

TGComboBox* BuildHistAddComboBox(TGFrame* parent, Int_t id)

     Create histogram Line/Bar adding combo box.

TGComboBox* BuildPercentComboBox(TGFrame* parent, Int_t id)

     Create Percentage Combo Box for Bar Option

void ChangeErrorCombo(Int_t i)

     Changes the display of the error combobox

void PaintBox3D(Float_t *p1, Float_t *p2,Float_t *p3, Float_t *p4)

     Paints a square in 3

Int_t* Dividers(Int_t n)

     gives an array of the dividers of n (without the trivial divider n))
     in the first entry the number of dividers is saved.

void CreateBinTab()

     Creates the BinTab

void CreateFitTab()

     Creates the Fit Tab

### Inline Functions

                TClass* Class()
                TClass* IsA() const
                   void ShowMembers(TMemberInspector& insp, char* parent)
                   void Streamer(TBuffer& b)
                   void StreamerNVirtual(TBuffer& b)
              TH1Editor TH1Editor(const TH1Editor&)

Author: Carsten Hof 16/08/04
Last update: root/ged:$Name: TH1Editor.cxx
Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *