// @(#)root/ged:$Id$
// Author: Carsten Hof 16/08/04

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TH1Editor
#define ROOT_TH1Editor

//////////////////////////////////////////////////////////////////////////
//                                                                      //
//  TH1Editor                                                           //
//                                                                      //
//  Editor changing histogram attributes (Type, Coords, Error, Style)   //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TGedFrame
#include "TGedFrame.h"
#endif


class TH1;
class TGComboBox;
class TGNumberEntry;
class TGCheckButton;
class TGButtonGroup;
class TGHButtonGroup;
class TString;
class TGRadioButton;
class TGDoubleHSlider;
class TGHSlider;
class TGTextEntry;
class TGNumberEntryField;
class TGTextButton;

class TH1Editor : public TGedFrame {

protected:
   TH1                 *fHist;            // histogram object
   Bool_t               fSameOpt;         // flag for option "same"
   TGCompositeFrame    *fBin;             // Contains the Binning Widgets
   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
   TGLayoutHints       *fDimlh;           // layout hints for 2D-Plot RadioButton
   TGLayoutHints       *fDim0lh;          // layout hints for 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    *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

   static  TGComboBox *BuildHistTypeComboBox(TGFrame *parent, Int_t id);       // builts the Type ComboBox
   static  TGComboBox *BuildHistCoordsComboBox(TGFrame *parent, Int_t id);     // builts the Coordinate ComboBox
   static  TGComboBox *BuildHistErrorComboBox(TGFrame *parent, Int_t id);      // builts the Error ComboBox
   static  TGComboBox *BuildHistAddComboBox(TGFrame *parent, Int_t id);        // builts the Add ComboBox
   static  TGComboBox *BuildPercentComboBox(TGFrame *parent, Int_t id);        // builts the ComboBox for setting the Bar options bar1,..., bar4

   virtual void  ConnectSignals2Slots();   // connect the signals to the slots
   void CreateBinTab();                           // Creates the Bin Tab (part of the SetGedEditor)


private:
   Bool_t               fMake;            // Veto Variable
   Bool_t               fMakeB;           // avoid execution of Bar Slots
   Int_t                fPx1old,          // save the coordinates of the "virtual box" in delay draw mode (2D Plot)
                        fPy1old,
                        fPx2old,
                        fPy2old;
   Float_t              fP1NDCold[3],     // save the coordinates of the "virtual box" in delay draw mode
                        fP2NDCold[3],
                        fP3NDCold[3],
                        fP4NDCold[3];
   Float_t              fP1old[3],        // save the coordinates of the "virtual box" in delay draw mode (3D plot)
                        fP2old[3],
                        fP3old[3],
                        fP4old[3],
                        fP5old[3],
                        fP6old[3],
                        fP7old[3],
                        fP8old[3];
   TH1                 *fBinHist;         // Cloned histogram for rebin
   Double_t             fOldOffset;       // save the old offset of the histogram

   TString              GetHistTypeLabel();       // Get the Histogram Type = String which contains the Histogram Draw Option
   TString              GetHistCoordsLabel();     // Get the histogram coordinate system (CYL, SPH, PSR, ..)
   TString              GetHistErrorLabel();      // Get the histogram Error type (E1, .., E4)
   TString              GetHistAddLabel();        // Get the histogram addon (smooth line, simple line, ..)
   void ChangeErrorCombo(Int_t i);


public:
   TH1Editor(const TGWindow *p = 0,
               Int_t width = 140, Int_t height = 30,
               UInt_t options = kChildFrame,
               Pixel_t back = GetDefaultFrameBackground());
   virtual ~TH1Editor();

   virtual Bool_t AcceptModel(TObject* model);
   virtual void   SetModel(TObject* obj);

   virtual void DoTitle(const char *text);
   virtual void DoAddMarker(Bool_t on);
   virtual void DoAddBar(Bool_t);
   virtual void DoAddB(Bool_t);
   virtual void DoAddSimple(Bool_t on);
   virtual void DoHistSimple();
   virtual void DoHistComplex();
   virtual void DoHistChanges();
   virtual void DoHistView();
   virtual void DoBarOffset();
   virtual void DoBarWidth();
   virtual void DoPercent();
   virtual void DoHBar(Bool_t on);
   virtual void DoSliderMoved();
   virtual void DoSliderPressed();
   virtual void DoSliderReleased();
   virtual void DoAxisRange();
   virtual void DoBinMoved(Int_t number);
   virtual void DoBinReleased();
   virtual void DoBinPressed();
   virtual void DoBinLabel();
   virtual void DoBinReleased1();
   virtual void DoBinMoved1();
   virtual void DoBinLabel1();
   virtual void DoOffsetMoved(Int_t num);
   virtual void DoOffsetReleased();
   virtual void DoOffsetPressed();
   virtual void DoBinOffset();
   virtual void DoApply();
   virtual void DoCancel();
   virtual void PaintBox3D(Float_t *p1, Float_t *p2,Float_t *p3, Float_t *p4);
   Int_t* Dividers(Int_t n);
   virtual void RecursiveRemove(TObject* obj);


   ClassDef(TH1Editor,0)  // TH1 editor
};

#endif
 TH1Editor.h:1
 TH1Editor.h:2
 TH1Editor.h:3
 TH1Editor.h:4
 TH1Editor.h:5
 TH1Editor.h:6
 TH1Editor.h:7
 TH1Editor.h:8
 TH1Editor.h:9
 TH1Editor.h:10
 TH1Editor.h:11
 TH1Editor.h:12
 TH1Editor.h:13
 TH1Editor.h:14
 TH1Editor.h:15
 TH1Editor.h:16
 TH1Editor.h:17
 TH1Editor.h:18
 TH1Editor.h:19
 TH1Editor.h:20
 TH1Editor.h:21
 TH1Editor.h:22
 TH1Editor.h:23
 TH1Editor.h:24
 TH1Editor.h:25
 TH1Editor.h:26
 TH1Editor.h:27
 TH1Editor.h:28
 TH1Editor.h:29
 TH1Editor.h:30
 TH1Editor.h:31
 TH1Editor.h:32
 TH1Editor.h:33
 TH1Editor.h:34
 TH1Editor.h:35
 TH1Editor.h:36
 TH1Editor.h:37
 TH1Editor.h:38
 TH1Editor.h:39
 TH1Editor.h:40
 TH1Editor.h:41
 TH1Editor.h:42
 TH1Editor.h:43
 TH1Editor.h:44
 TH1Editor.h:45
 TH1Editor.h:46
 TH1Editor.h:47
 TH1Editor.h:48
 TH1Editor.h:49
 TH1Editor.h:50
 TH1Editor.h:51
 TH1Editor.h:52
 TH1Editor.h:53
 TH1Editor.h:54
 TH1Editor.h:55
 TH1Editor.h:56
 TH1Editor.h:57
 TH1Editor.h:58
 TH1Editor.h:59
 TH1Editor.h:60
 TH1Editor.h:61
 TH1Editor.h:62
 TH1Editor.h:63
 TH1Editor.h:64
 TH1Editor.h:65
 TH1Editor.h:66
 TH1Editor.h:67
 TH1Editor.h:68
 TH1Editor.h:69
 TH1Editor.h:70
 TH1Editor.h:71
 TH1Editor.h:72
 TH1Editor.h:73
 TH1Editor.h:74
 TH1Editor.h:75
 TH1Editor.h:76
 TH1Editor.h:77
 TH1Editor.h:78
 TH1Editor.h:79
 TH1Editor.h:80
 TH1Editor.h:81
 TH1Editor.h:82
 TH1Editor.h:83
 TH1Editor.h:84
 TH1Editor.h:85
 TH1Editor.h:86
 TH1Editor.h:87
 TH1Editor.h:88
 TH1Editor.h:89
 TH1Editor.h:90
 TH1Editor.h:91
 TH1Editor.h:92
 TH1Editor.h:93
 TH1Editor.h:94
 TH1Editor.h:95
 TH1Editor.h:96
 TH1Editor.h:97
 TH1Editor.h:98
 TH1Editor.h:99
 TH1Editor.h:100
 TH1Editor.h:101
 TH1Editor.h:102
 TH1Editor.h:103
 TH1Editor.h:104
 TH1Editor.h:105
 TH1Editor.h:106
 TH1Editor.h:107
 TH1Editor.h:108
 TH1Editor.h:109
 TH1Editor.h:110
 TH1Editor.h:111
 TH1Editor.h:112
 TH1Editor.h:113
 TH1Editor.h:114
 TH1Editor.h:115
 TH1Editor.h:116
 TH1Editor.h:117
 TH1Editor.h:118
 TH1Editor.h:119
 TH1Editor.h:120
 TH1Editor.h:121
 TH1Editor.h:122
 TH1Editor.h:123
 TH1Editor.h:124
 TH1Editor.h:125
 TH1Editor.h:126
 TH1Editor.h:127
 TH1Editor.h:128
 TH1Editor.h:129
 TH1Editor.h:130
 TH1Editor.h:131
 TH1Editor.h:132
 TH1Editor.h:133
 TH1Editor.h:134
 TH1Editor.h:135
 TH1Editor.h:136
 TH1Editor.h:137
 TH1Editor.h:138
 TH1Editor.h:139
 TH1Editor.h:140
 TH1Editor.h:141
 TH1Editor.h:142
 TH1Editor.h:143
 TH1Editor.h:144
 TH1Editor.h:145
 TH1Editor.h:146
 TH1Editor.h:147
 TH1Editor.h:148
 TH1Editor.h:149
 TH1Editor.h:150
 TH1Editor.h:151
 TH1Editor.h:152
 TH1Editor.h:153
 TH1Editor.h:154
 TH1Editor.h:155
 TH1Editor.h:156
 TH1Editor.h:157
 TH1Editor.h:158
 TH1Editor.h:159
 TH1Editor.h:160
 TH1Editor.h:161
 TH1Editor.h:162
 TH1Editor.h:163
 TH1Editor.h:164
 TH1Editor.h:165
 TH1Editor.h:166
 TH1Editor.h:167
 TH1Editor.h:168
 TH1Editor.h:169
 TH1Editor.h:170
 TH1Editor.h:171
 TH1Editor.h:172
 TH1Editor.h:173
 TH1Editor.h:174
 TH1Editor.h:175
 TH1Editor.h:176
 TH1Editor.h:177
 TH1Editor.h:178
 TH1Editor.h:179
 TH1Editor.h:180