library: libGed #include "TH2Editor.h"

# TH2Editor

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

## class TH2Editor : public TGedFrame

| Inheritance Chart:

`TObject`

<-

`TGObject`

<-

`TGWindow`

`TQObject`

<-

`TGFrame`

<-

`TGCompositeFrame`

`TGWidget`

<-

`TGedFrame`

<-

`TH2Editor`

        private:

          TString GetHistAdditiveLabel()
          TString GetHistContLabel()
          TString GetHistCoordsLabel()
          TString GetHistTypeLabel()
             void PaintBox3D(Float_t* p1, Float_t* p2, Float_t* p3, Float_t* p4)

        protected:

          static TGComboBox* BuildHistContComboBox(TGFrame* parent, Int_t id)
          static TGComboBox* BuildHistCoordsComboBox(TGFrame* parent, Int_t id)
          static TGComboBox* BuildHistTypeComboBox(TGFrame* parent, Int_t id)
                virtual void ConnectSignals2Slots()

        public:

                          TH2Editor(const TGWindow* p, Int_t id, Int_t width = 140, Int_t height = 30, UInt_t options = kChildFrame, Pixel_t back = GetDefaultFrameBackground())
                          TH2Editor(const TH2Editor&)
                  virtual ~TH2Editor()
           static TClass* Class()
                   Int_t* Dividers(Int_t n)
             virtual void DoAddArr(Bool_t on)
             virtual void DoAddBB()
             virtual void DoAddBox(Bool_t on)
             virtual void DoAddCol(Bool_t on)
             virtual void DoAddError(Bool_t on)
             virtual void DoAddFB()
             virtual void DoAddPalette(Bool_t on)
             virtual void DoAddScat(Bool_t on)
             virtual void DoAddText(Bool_t on)
             virtual void DoApply()
             virtual void DoBarOffset()
             virtual void DoBarWidth()
             virtual void DoBinLabel()
             virtual void DoBinLabel1()
             virtual void DoBinMoved()
             virtual void DoBinMoved1()
             virtual void DoBinOffset()
             virtual void DoBinPressed()
             virtual void DoBinReleased()
             virtual void DoBinReleased1()
             virtual void DoCancel()
             virtual void DoContLevel()
             virtual void DoContLevel1()
             virtual void DoFillColor(Pixel_t)
             virtual void DoFillPattern(Style_t)
             virtual void DoHistChanges()
             virtual void DoHistComplex()
             virtual void DoHistSimple()
             virtual void DoOffsetMoved()
             virtual void DoOffsetPressed()
             virtual void DoOffsetReleased()
             virtual void DoSliderXMoved()
             virtual void DoSliderXPressed()
             virtual void DoSliderXReleased()
             virtual void DoSliderYMoved()
             virtual void DoSliderYPressed()
             virtual void DoSliderYReleased()
             virtual void DoTitle(const char* text)
             virtual void DoXAxisRange()
             virtual void DoYAxisRange()
          virtual TClass* IsA() const
             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:

             Int_t fPx1old
             Int_t fPy1old
             Int_t fPx2old
             Int_t fPy2old
           Float_t fP1oldx[3]
           Float_t fP2oldx[3]
           Float_t fP3oldx[3]
           Float_t fP4oldx[3]
           Float_t fP5oldx[3]
           Float_t fP6oldx[3]
           Float_t fP7oldx[3]
           Float_t fP8oldx[3]
           Float_t fP1oldy[3]
           Float_t fP2oldy[3]
           Float_t fP3oldy[3]
           Float_t fP4oldy[3]
           Float_t fP5oldy[3]
           Float_t fP6oldy[3]
           Float_t fP7oldy[3]
           Float_t fP8oldy[3]
              TH2* fBinHist     Cloned histogram for rebin
          Double_t fOldXOffset  saves the old x offset of the histogram
          Double_t fOldYOffset  saves the old y offset of the histogram

        protected:

                         TH2* fHist                histogram object
                       TGTab* fTab                 Pointer to the Tab Parent
            TGCompositeFrame* fBin                 Contains the Binning Widgets
            TGCompositeFrame* fFit                 Contains the Fitting Widgets
            TGCompositeFrame* fBinContainer        Container for fBin
                 TGTextEntry* fTitle               histogram title input field
                  TGComboBox* fTypeCombo           histogram type combo box
                  TGComboBox* fCoordsCombo         Coordinate System combo box
                  TGComboBox* fContCombo           Contour selecting combo box
                     TGLabel* fColContLbl          No. of Contours Label 1
                     TGLabel* fColContLbl1         No. of Contours Label 2
                        Int_t fTitlePrec           font precision level
              TGHButtonGroup* fDimGroup            Radiobuttongroup to change 2D <-> 3D-Plot
               TGRadioButton* fDim                 2D-Plot RadioButton
               TGRadioButton* fDim0                3D-Plot RadioButton
            TGCompositeFrame* f3                   Frame that contains Histogram Type-ComboBox
            TGCompositeFrame* f4                   Frame that contains Histogram Coord-ComboBox
            TGCompositeFrame* f5                   Frame that contains Histogram Contour-ComboBox
            TGCompositeFrame* f6                   Frame that contains the 2D CheckBox DrawOptions
            TGCompositeFrame* f9                   Frame that contains the 3D CheckBox DrawOptions
            TGCompositeFrame* f12                  Frame that contains the Bar-Title
            TGCompositeFrame* f13                  Frame that contains the Bar Width/Offset NumberEntries
            TGCompositeFrame* f16                  Frame that contains the ColorLevel NumberEnrtry
            TGCompositeFrame* f19                  Frame that contains the ColorLevel NumberEnrtry
            TGCompositeFrame* f38                  Frame that contains the Frame Fill widgets
               TGCheckButton* fAddError            CheckBox connected to error bars
               TGCheckButton* fAddPalette          CheckBox connected to Z option (2D)
               TGCheckButton* fAddPalette1         CheckBox connected to Z option (3D)
               TGCheckButton* fAddArr              CheckBox connected to Arr-Option
               TGCheckButton* fAddBox              CheckBox connected to Box-Option
               TGCheckButton* fAddScat             CheckBox connected to Scat-Option
               TGCheckButton* fAddCol              CheckBox connected to Col-Option
               TGCheckButton* fAddFB               Draw front box (or not)
               TGCheckButton* fAddBB               Draw back box (or not)
               TGCheckButton* fAddText             Draw bin contents as text
               TGNumberEntry* fContLevels          Set number of contour levels
               TGNumberEntry* fContLevels1         Set number of contour levels
               TGNumberEntry* fBarWidth            Set bar width of histogram
               TGNumberEntry* fBarOffset           Set bar offset of histogram
            TGCompositeFrame* fBinXCont            Contains the rebin widgets for case 1
                   TGHSlider* fBinXSlider          Slider to set rebinning x integer value
          TGNumberEntryField* fBinXNumberEntry     Label which shows the rebinned bin number
                   TGHSlider* fBinYSlider          Slider to set rebinning y integer value
          TGNumberEntryField* fBinYNumberEntry     Label which shows the rebinned bin number
                TGTextButton* fApply               Apply-Button to accept the rebinned histogram
                TGTextButton* fCancel              Cancel-Button to reprobate the rebinned histogram
            TGCompositeFrame* fBinXCont1           Contains the X Rebin Widgets for case 2
                   TGHSlider* fBinXSlider1         Slider to set x rebinning integer value
          TGNumberEntryField* fBinXNumberEntry1    Label which shows the rebinned x bin number
          TGNumberEntryField* fXOffsetNumberEntry  Shows the offset to the x origin of the histogram
                   TGHSlider* fXBinOffsetSld       Add an x-offset to the origin of the histogram
            TGCompositeFrame* fBinYCont1           Contains the Y Rebin Widgets for case 2
                   TGHSlider* fBinYSlider1         Slider to set y rebinning integer value
          TGNumberEntryField* fBinYNumberEntry1    Label which shows the rebinned y bin number
          TGNumberEntryField* fYOffsetNumberEntry  Shows the offset to the y origin of the histogram
                   TGHSlider* fYBinOffsetSld       Add an y-offset to the origin of the histogram
             TGDoubleHSlider* fSliderX             Slider to set x-axis range
          TGNumberEntryField* fSldXMin             Contains the minimum value of the x-Axis
          TGNumberEntryField* fSldXMax             Contains the maximum value of the x-Axis
             TGDoubleHSlider* fSliderY             Slider to set y-axis range
          TGNumberEntryField* fSldYMin             Contains the minimum value of the y-Axis
          TGNumberEntryField* fSldYMax             Contains the maximum value of the y-Axis
               TGCheckButton* fDelaydraw           Delayed drawing of the new axis range
               TGColorSelect* fFrameColor          Select the Frame Color
           TGedPatternSelect* fFramePattern        Select the Frame Pattern Style

## Class Description

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

/* */

/* */

      These changes can be made via the TH2Editor:
        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:
          'Contour' : ComboBox: draw a contour plot (None, Cont0..4)
          'Cont #'  : TGNumberEntry: set the number of Contours
        2d Plot checkboxes:
          'Arrow'   : arrow mode. Shows gradient between adjacent cells
          'Col'     : a box is drawn for each cell with a color scale
                      varying with contents
          'Text'    : Draw bin contents as text
          'Box'     : a box is drawn for each cell with surface
                      proportional to contents
          'Scat'    : Draw a scatter-plot (default)
          'Palette' : the color palette is drawn

        3d Plot:
          'Type'    : ComboBox: set histogram type Lego or Surface-Plot
                      draw(Lego, Lego1.2, Surf, Surf1..5)
                      see THistPainter::Paint
          'Coords'  : ComboBox: set the coordinate system (Cartesian, ..
                      Spheric) see THistPainter::Paint
          'Cont #'  : TGNumberEntry: set the number of Contours (for e.g.
                      Lego2 drawoption
        3d Plot checkboxes:
          'Errors'  : draw errors in a cartesian lego plot
          'Palette' : the color palette is drawn
          'Front'   : draw the front box of a cartesian lego plot
          'Back'    : draw the back box of a cartesian lego plot
        Available for a 3D lego plot:
          'Bar'     : change the bar attributes
                'W' : change Bar Width
                'O' : change Bar Offset
       Further Editor:
          'Marker'   : change the Marker attributes (color, appearance,
                       thickness) see TAttMarkerEditor

/* */

/* */

       Rebinning Tab:
          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 for example:
             TFile f("hsimple.root");
             hpxpy->Draw("Lego2");              // non ntuple histogram
             ntuple->Draw("px:py","","Lego2");  // ntuple histogram
        Non ntuple histogram:
           'Rebin': with the Sliders (one for the x, one for the y axis)
                    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 sliders 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 be 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.

TH2Editor(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.

~TH2Editor()

     Destructor of TH2 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 DoHistSimple()

     Slot connected to the 2D-Plot RadioButton

void DoHistComplex()

     Slot connected to the 3D-Plot RadioButton

void DoHistChanges()

     Slot connected to the histogram type, the coordinate system and the Contour ComboBox

void DoAddArr(Bool_t on)

     Slot connected to the "Arrow Draw Option"-CheckButton

void DoAddBox(Bool_t on)

     Slot connected to the "Box Draw Option"-CheckButton

void DoAddCol(Bool_t on)

     Slot connected to the "Col Draw Option"-CheckButton

void DoAddScat(Bool_t on)

     Slot connected to the "Scat Draw Option"-CheckButton

void DoAddText(Bool_t on)

     Slot connected to the "Text Draw Option"-CheckButton

void DoAddError(Bool_t on)

     Slot connected to the "Error"-CheckButton

void DoAddPalette(Bool_t on)

     Slot connected to the Color Palette

void DoAddFB()

     Slot connected to the "FB Front-Box Draw Option"-CheckButton

void DoAddBB()

     Slot connected to the "BB Back-Box Draw Option"-CheckButton

void DoContLevel()

     Slot connected to the Contour Level TGNumberEntry

void DoContLevel1()

     Slot connected to the Contour Level TGNumberEntry

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 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 DoBinPressed()

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

void DoBinMoved()

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

void DoBinLabel()

     Slot connected to the Bin Number Entry for the Rebin

void DoApply()

     Slot connected to the Cancel Button in the Rebinned histogram Window

void DoCancel()

     Slot connected to the Cancel Button in the Rebinned histogram Window

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 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??

void DoOffsetMoved()

     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??

void DoBinOffset()

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

void DoSliderXMoved()

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

void DoSliderXPressed()

     slot connected to the x axis range slider
     initialises the "virtual" box which is drawn in delay draw mode

void DoSliderXReleased()

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

void DoXAxisRange()

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

void DoSliderYMoved()

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

void DoSliderYPressed()

     slot connected to the y axis range slider
     initialises the "virtual" box which is drawn in delay draw mode

void DoSliderYReleased()

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

void DoYAxisRange()

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

void DoFillColor(Pixel_t color)

     Slot connected to the fill area color.

void DoFillPattern(Style_t pattern)

     Slot connected to the fill area pattern.

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 GetHistContLabel()

     Returns histogram contour option (None,Cont0..5)

TString GetHistAdditiveLabel()

     Returns histogram additive options (Arr,Box,Col,Scat,Col,Text,E,Z,FB,BB)

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* BuildHistContComboBox(TGFrame* parent, Int_t id)

     Create contour combo box.

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

     Paints a square in 3D

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.

### Inline Functions

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

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