TH1Editor.cxx

Go to the documentation of this file.
00001 // @(#)root/ged:$Id: TH1Editor.cxx 35073 2010-08-30 14:49:08Z bellenot $
00002 // Author: Carsten Hof   16/08/04
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 //  TH1Editor                                                           //
00015 //  Editor for changing TH1 histogram attributes, rebinning & fitting.  //
00016 //  For all possible draw options (there are a few which are not imple- //
00017 //  mentable in graphical user interface) see THistPainter::Paint in    //
00018 //  root/histpainter/THistPainter.cxx                                   //
00019 //
00020 //Begin_Html
00021 /*
00022 <img src="gif/TH1Editor_1.gif">
00023 */
00024 //End_Html
00025 //Begin_Html
00026 /*
00027 <img src="gif/TH1Editor_2.gif">
00028 */
00029 //End_Html
00030 //
00031 //  These changes can be made via the TH1Editor:                        //
00032 //    Style Tab:                                                        //
00033 //      'Line'     : change Line attributes (color, thickness)          //
00034 //                   see TAttLineEditor                                 //
00035 //      'Fill'     : change Fill attributes (color, pattern)            //
00036 //                   see TAttFillEditor                                 //
00037 //      'Title'    : TextEntry: set the title of the histogram          //
00038 //      'Histogram': change the draw options of the histogram           //
00039 //          'Plot' : Radiobutton: draw a 2D or 3D plot of the histogram //
00040 //                   according to the Plot dimension there will be      //
00041 //                   different drawing possibilities (ComboBoxes/       //
00042 //                   CheckBoxes)                                        //
00043 //    2d Plot:                                                          //
00044 //      'Error'   : ComboBox: add different error bars to the histogram //
00045 //                  (no errors, simple, ...,  see THistPainter::Paint   //
00046 //      'Add'     : ComboBox: further things which can be added to the  //
00047 //                  histogram (None, simple/smooth line, fill area      //
00048 //      'Simple Drawing': CheckBox: draw a simple histogram without     //
00049 //                  errors (= "HIST" drawoption). In combination with   //
00050 //                  some other draw options an outer line is drawn on   //
00051 //                  top of the histogram                                //
00052 //      'Show markers': CheckBox: draw a marker on to of each bin (="P" //
00053 //                  drawoption)                                         //
00054 //      'Draw bar chart': CheckBox: draw a bar chart (="B" drawoption)  //
00055 //                  change the Fill Color with Fill in the Style Tab    //
00056 //                  => will show Bar menue in the Style Tab             //
00057 //      'Bar option': CheckBox: draw a bar chart (="BAR" drawoption)    //
00058 //                  => will show Bar menue in the Style Tab             //
00059 //    3d Plot:                                                          //
00060 //      'Type'    : ComboBox: set histogram type Lego-Plot or Surface   //
00061 //                  draw(Lego, Lego1.2, Surf, Surf1..5)                 //
00062 //                  see THistPainter::Paint                             //
00063 //      'Coords'  : ComboBox: set the coordinate system (Cartesian, ..  //
00064 //                  Spheric) see THistPainter::Paint                    //
00065 //      'Error'   : see 2D plot                                         //
00066 //      'Bar'     : change the bar attributes                           //
00067 //            'W' : change Bar Width                                    //
00068 //            'O' : change Bar Offset                                   //
00069 //      'Percentage': specifies the percentage of the bar which is drawn//
00070 //                    brighter and darker (10% == BAR1 drawoption)      //
00071 //      'Horizontal Bar': draw a horizontal bar chart                   //
00072 //                                                                      //
00073 //      'Marker'   : change the Marker attributes (color, appearance,   //
00074 //                   thickness) see TAttMarkerEditor                    //
00075 //Begin_Html
00076 /*
00077 <img src="gif/TH1Editor1.gif">
00078 */
00079 //End_Html
00080 //      This Tab has two different layouts. One is for a histogram which//
00081 //      is not drawn from an ntuple. The other one is available for a   //
00082 //      histogram which is drawn from an ntuple. In this case the rebin //
00083 //      algorithm can create a rebinned histogram from the original data//
00084 //      i.e. the ntuple.                                                //
00085 //      To see te differences do:                                       //
00086 //         TFile f("hsimple.root");                                     //
00087 //         hpx->Draw("BAR1");        // non ntuple histogram            //
00088 //         ntuple->Draw("px");       // ntuple histogram                //
00089 //    Non ntuple histogram:                                             //
00090 //       'Rebin': with the Slider the number of bins (shown in the field//
00091 //                below the Slider) can be changed to any number which  //
00092 //                divides the number of bins of the original histogram. //
00093 //                Pushing 'Apply' will delete the origin histogram and  //
00094 //                replace it by the rebinned one on the screen          //
00095 //                Pushing 'Ignore' the origin histogram will be restored//
00096 //    Histogram drawn from an ntuple:                                   //
00097 //       'Rebin'  with the slider the number of bins can be enlarged by //
00098 //                a factor of 2,3,4,5 (moving to the right) or reduced  //
00099 //                by a factor of 1/2, 1/3, 1/4, 1/5                     //
00100 //       'BinOffset': with the BinOffset slider the origin of the       //
00101 //                histogram can be changed within one binwidth          //
00102 //                Using this slider the effect of binning the data into //
00103 //                bins can be made visible => statistical fluctuations  //
00104 //       'Axis Range': with the DoubleSlider it is possible to zoom into//
00105 //                the specified axis range. It is also possible to set  //
00106 //                the upper and lower limit in fields below the slider  //
00107 //       'Delayed drawing': all the Binning sliders can set to delay    //
00108 //                draw mode. Then the changes on the histogram are only //
00109 //                updated, when the Slider is released. This should be  //
00110 //                activated if the redrawing of the histogram is too    //
00111 //                time consuming.                                       //
00112 //////////////////////////////////////////////////////////////////////////
00113 //
00114 //Begin_Html
00115 /*
00116 <img src="gif/TH1Editor1_1.gif">
00117 */
00118 //End_Html
00119 //Begin_Html
00120 /*
00121 <img src="gif/TH1Editor1_2.gif">
00122 */
00123 //End_Html
00124 
00125 
00126 #include "TH1Editor.h"
00127 #include "TH1.h"
00128 #include "TGedEditor.h"
00129 #include "TGComboBox.h"
00130 #include "TGTextEntry.h"
00131 #include "TGToolTip.h"
00132 #include "TGLabel.h"
00133 #include "TVirtualPad.h"
00134 #include "TStyle.h"
00135 #include "TString.h"
00136 #include "TGButtonGroup.h"
00137 #include "TGNumberEntry.h"
00138 #include <stdlib.h>
00139 #include "TG3DLine.h"
00140 #include "TGDoubleSlider.h"
00141 #include "TGSlider.h"
00142 #include "TView.h"
00143 #include "TCanvas.h"
00144 #include "TTreePlayer.h"
00145 #include "TSelectorDraw.h"
00146 #include "TGMsgBox.h"
00147 #include "TGTab.h"
00148 
00149 
00150 ClassImp(TH1Editor)
00151 
00152 enum ETH1Wid{
00153    kTH1_TITLE,
00154    kTYPE_HIST,  kTYPE_LEGO,  kTYPE_LEGO1, kTYPE_LEGO2, 
00155    kTYPE_SURF,  kTYPE_SURF1, kTYPE_SURF2, kTYPE_SURF3, kTYPE_SURF4, kTYPE_SURF5,
00156    kCOORDS_CAR, kCOORDS_CYL, kCOORDS_POL, kCOORDS_PSR, kCOORDS_SPH,
00157    kERRORS_NO,  kERRORS_SIMPLE, kERRORS_EDGES, 
00158    kERRORS_REC, kERRORS_FILL,   kERRORS_CONTOUR,
00159    kHIST_TYPE,  kCOORD_TYPE, kERROR_TYPE, kMARKER_ONOFF, kB_ONOFF,  kBAR_ONOFF,
00160    kADD_TYPE,   kADD_NONE,   kADD_SIMPLE, kADD_SMOOTH,   kADD_FILL, 
00161    kADD_BAR,    kADD_LINE,
00162    kDIM_SIMPLE, kDIM_COMPLEX,
00163    kPERCENT_TYPE, kPER_0, kPER_10, kPER_20, kPER_30, kPER_40,
00164    kBAR_H,      kBAR_WIDTH, kBAR_OFFSET,
00165    kSLIDER_MAX, kSLIDER_MIN, 
00166    kDELAYED_DRAWING,
00167    kBINSLIDER, kBINSLIDER1, kBINOFFSET
00168 };
00169 
00170 
00171 //______________________________________________________________________________
00172 TH1Editor::TH1Editor(const TGWindow *p,  Int_t width,
00173                      Int_t height, UInt_t options, Pixel_t back)
00174    : TGedFrame(p, width, height, options | kVerticalFrame, back),
00175      fHist(0),
00176      fSameOpt(kFALSE),
00177      fBin(0),
00178      fBinHist(0)
00179 {
00180    // Constructor of histogram attribute GUI.
00181    
00182    // TextEntry for changing the title of the histogram
00183    MakeTitle("Title");
00184    fTitlePrec = 2;
00185    fTitle = new TGTextEntry(this, new TGTextBuffer(50), kTH1_TITLE);
00186    fTitle->Resize(135, fTitle->GetDefaultHeight());
00187    fTitle->SetToolTipText("Enter the histogram title string");
00188    AddFrame(fTitle, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
00189   
00190    // Histogram draw options
00191    TGCompositeFrame *fHistLbl = new TGCompositeFrame(this, 145, 10, 
00192                                                            kHorizontalFrame | 
00193                                                            kLHintsExpandX   | 
00194                                                            kFixedWidth      | 
00195                                                            kOwnBackground);
00196    fHistLbl->AddFrame(new TGLabel(fHistLbl,"Histogram"), 
00197                       new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00198    fHistLbl->AddFrame(new TGHorizontal3DLine(fHistLbl), 
00199                       new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 0));
00200    AddFrame(fHistLbl, new TGLayoutHints(kLHintsTop,0,0,2,0));
00201 
00202    // TGButtonGroup to change: 2D plot <-> 3D plot   
00203    TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
00204    fDimGroup = new TGHButtonGroup(f2,"Plot");
00205    fDimGroup->SetRadioButtonExclusive();
00206    fDim = new TGRadioButton(fDimGroup,"2-D",kDIM_SIMPLE);
00207    fDim->SetToolTipText("A 2-d plot of the histogram is dawn");
00208    fDim0 = new TGRadioButton(fDimGroup,"3-D",kDIM_COMPLEX);
00209    fDim0->SetToolTipText("A 3-d plot of the histogram is dawn");
00210    fDimGroup->SetLayoutHints(fDimlh=new TGLayoutHints(kLHintsLeft ,-2,3,3,-7),fDim);
00211    fDimGroup->SetLayoutHints(fDim0lh=new TGLayoutHints(kLHintsLeft ,16,-1,3,-7),fDim0);   
00212    fDimGroup->Show();
00213    fDimGroup->ChangeOptions(kFitWidth | kChildFrame | kHorizontalFrame);
00214    f2->AddFrame(fDimGroup, new TGLayoutHints(kLHintsTop, 4, 1, 0, 0));
00215    AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 2, 8));
00216 
00217    // Set the type of histogram (Lego0..2, Surf0..5) for 3D plot 
00218    f3 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
00219    AddFrame(f3, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00220 
00221    TGCompositeFrame *f3a = new TGCompositeFrame(f3, 40, 20);
00222    f3->AddFrame(f3a, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00223    TGLabel *fType = new TGLabel(f3a, "Add: "); 
00224    f3a->AddFrame(fType, new TGLayoutHints(kLHintsLeft, 6, 1, 4, 4));
00225    TGLabel *fCoords = new TGLabel(f3a, "Coords:"); 
00226    f3a->AddFrame(fCoords, new TGLayoutHints(kLHintsLeft, 6, 1, 4, 1));
00227 
00228    TGCompositeFrame *f3b = new TGCompositeFrame(f3, 40, 20);
00229    f3->AddFrame(f3b, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00230    fTypeCombo = BuildHistTypeComboBox(f3b, kHIST_TYPE);
00231    f3b->AddFrame(fTypeCombo, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 1));
00232    fTypeCombo->Resize(80, 20);
00233    fTypeCombo->Associate(this);
00234    //Set the coordinate system (Cartesian, Spheric, ...)      
00235    fCoordsCombo = BuildHistCoordsComboBox(f3b, kCOORD_TYPE);
00236    f3b->AddFrame(fCoordsCombo, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 1));
00237    fCoordsCombo->Resize(80, 20);
00238    fCoordsCombo->Associate(this);
00239    
00240    // Set the Error (No error, error1..5)
00241    TGCompositeFrame *f5 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
00242    AddFrame(f5, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00243 
00244    TGCompositeFrame *f5a = new TGCompositeFrame(f5, 40, 20);
00245    f5->AddFrame(f5a, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00246    TGLabel *fError = new TGLabel(f5a, "Error:"); 
00247    f5a->AddFrame(fError, new TGLayoutHints(kLHintsLeft, 6, 2, 4, 1));
00248 
00249    TGCompositeFrame *f5b = new TGCompositeFrame(f5, 40, 20);
00250    f5->AddFrame(f5b, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00251    fErrorCombo = BuildHistErrorComboBox(f5b, kERROR_TYPE);
00252    f5b->AddFrame(fErrorCombo, new TGLayoutHints(kLHintsLeft, 15, 1, 2, 1));
00253    fErrorCombo->Resize(80, 20);
00254    fErrorCombo->Associate(this);
00255 
00256    // Further draw options: Smooth/Simple Line, Fill Area for 2D plot
00257    f6 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
00258    AddFrame(f6, new TGLayoutHints(kLHintsTop, 1, 1, 0, 3));
00259 
00260    TGCompositeFrame *f6a = new TGCompositeFrame(f6, 40, 20);
00261    f6->AddFrame(f6a, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00262    TGLabel *fAddLabel = new TGLabel(f6a, "Style:"); 
00263    f6a->AddFrame(fAddLabel, new TGLayoutHints(kLHintsLeft, 6, 2, 4, 1));
00264  
00265    TGCompositeFrame *f6b = new TGCompositeFrame(f6, 40, 20);
00266    f6->AddFrame(f6b, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00267    fAddCombo = BuildHistAddComboBox(f6b, kADD_TYPE);
00268    f6b->AddFrame(fAddCombo, new TGLayoutHints(kLHintsLeft, 15, 1, 2, 1));
00269    fAddCombo->Resize(80, 20);
00270    fAddCombo->Associate(this);
00271 
00272    // option related to HIST: some changes needed here! 
00273    // because of inconsistencies   
00274    f15 = new TGCompositeFrame(this, 80, 20, kVerticalFrame); 
00275    fAddSimple = new TGCheckButton(f15, "Simple Drawing", kADD_LINE);
00276    fAddSimple ->SetToolTipText("A simple histogram without errors is drawn (draw option: Hist)");
00277    f15->AddFrame(fAddSimple, new TGLayoutHints(kLHintsLeft, 6, 1, 1, 0));
00278    AddFrame(f15, new TGLayoutHints(kLHintsTop, 1, 1, 0, -1)); 
00279 
00280    // Show Marker Checkbox: draw marker (or not)
00281    f7 = new TGCompositeFrame(this, 80, 20, kVerticalFrame);
00282    fAddMarker = new TGCheckButton(f7, "Show markers", kMARKER_ONOFF);
00283    fAddMarker ->SetToolTipText("Make marker visible/invisible");
00284    f7->AddFrame(fAddMarker, new TGLayoutHints(kLHintsLeft, 6, 1, 1, 0));
00285    AddFrame(f7, new TGLayoutHints(kLHintsTop, 1, 1, 2, 0));
00286 
00287    // Bar Chart Checkbox: draw with option B
00288    f8 = new TGCompositeFrame(this, 80, 20, kVerticalFrame); 
00289    fAddB = new TGCheckButton(f8, "Draw bar chart", kB_ONOFF);
00290    fAddB ->SetToolTipText("Draw a bar chart");
00291    f8->AddFrame(fAddB, new TGLayoutHints(kLHintsLeft, 6, 1, 1, 0));
00292    AddFrame(f8, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00293 
00294    // Bar CheckBox: draw with option BAR +option selected by 
00295    // fPercentCombo (0..4) e.g. BAR2
00296    f9 = new TGCompositeFrame(this, 80, 20, kVerticalFrame); 
00297    fAddBar = new TGCheckButton(f9, "Bar option", kBAR_ONOFF);
00298    fAddBar ->SetToolTipText("Draw bar chart with bar-option");
00299    f9->AddFrame(fAddBar, new TGLayoutHints(kLHintsLeft, 6, 1, 1, 0));
00300    AddFrame(f9, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0)); 
00301 
00302    // Bar Menu => appears when the BAR checkbox is set
00303    f10 = new TGCompositeFrame(this, 145, 10, kHorizontalFrame | 
00304                                              kLHintsExpandX   | 
00305                                              kFixedWidth      | 
00306                                              kOwnBackground);
00307    f10->AddFrame(new TGLabel(f10,"Bar"), 
00308                  new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00309    f10->AddFrame(new TGHorizontal3DLine(f10), 
00310                  new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00311    AddFrame(f10, new TGLayoutHints(kLHintsTop,0,0,6,4));
00312 
00313    // NumberEntry to change the Bar Width   
00314    f11 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
00315    TGLabel *fWidthLbl = new TGLabel(f11, "W:");                              
00316    f11->AddFrame(fWidthLbl, new TGLayoutHints(kLHintsLeft, 1, 3, 4, 1));
00317    fBarWidth = new TGNumberEntry(f11, 1.00, 6, kBAR_WIDTH, 
00318                                  TGNumberFormat::kNESRealTwo,
00319                                  TGNumberFormat::kNEANonNegative, 
00320                                  TGNumberFormat::kNELLimitMinMax, 0.01, 1.);
00321    fBarWidth->GetNumberEntry()->SetToolTipText("Set bin bar width");
00322    fBarWidth->Resize(45,20);
00323    f11->AddFrame(fBarWidth, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 1));
00324 
00325    // NumberEntry to change the Bar OFfset 
00326    TGLabel *foffsetLbl = new TGLabel(f11, "O:");                              
00327    f11->AddFrame(foffsetLbl, new TGLayoutHints(kLHintsLeft, 6,3, 4, 1));
00328    fBarOffset = new TGNumberEntry(f11, 0.00, 5, kBAR_OFFSET, 
00329                                   TGNumberFormat::kNESRealTwo,
00330                                   TGNumberFormat::kNEAAnyNumber, 
00331                                   TGNumberFormat::kNELLimitMinMax, -1., 1.);
00332    fBarOffset->GetNumberEntry()->SetToolTipText("Set bin bar offset");
00333    fBarOffset->Resize(50,20);
00334    f11->AddFrame(fBarOffset, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 1));
00335    AddFrame(f11, new TGLayoutHints(kLHintsTop, 1, 1, 0, 4));
00336  
00337    // ComboBox which specifies the width of the Bar which should be drawn 
00338    // in another color i.e. specifies the number in BAR option e.g. BAR2   
00339    f12 = new TGCompositeFrame(this, 80, 20, kVerticalFrame);
00340    TGCompositeFrame *f13 = new TGCompositeFrame(f12, 80, 20, kHorizontalFrame);
00341    TGLabel *percentLabel = new TGLabel(f13, "Percentage:"); 
00342    f13->AddFrame(percentLabel, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 1));
00343    fPercentCombo = BuildPercentComboBox(f13, kPERCENT_TYPE);
00344    fPercentCombo->Resize(51, 20);
00345    fPercentCombo->Associate(f13);
00346    f13->AddFrame(fPercentCombo, new TGLayoutHints(kLHintsLeft, 14, 1, 2, 1));
00347    f12->AddFrame(f13,new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
00348 
00349    // CHeckBox for horizontal drawing of the Histogram
00350    fMakeHBar = new TGCheckButton(f12, "Horizontal Bar", kBAR_H);
00351    fMakeHBar ->SetToolTipText("Draw a horizontal bar chart with hBar-Option");
00352    f12->AddFrame(fMakeHBar, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 0));
00353    AddFrame(f12, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0)); 
00354 
00355    CreateBinTab();
00356 }
00357 
00358 //______________________________________________________________________________
00359 void TH1Editor::CreateBinTab()
00360 {
00361    // Create binning tab.
00362 
00363    fBin = CreateEditorTabSubFrame("Binning");
00364 
00365    TGCompositeFrame *title1 = new TGCompositeFrame(fBin, 145, 10, 
00366                                                          kHorizontalFrame | 
00367                                                          kLHintsExpandX   | 
00368                                                          kFixedWidth      | 
00369                                                          kOwnBackground);
00370    title1->AddFrame(new TGLabel(title1, "Rebin"), 
00371                     new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00372    title1->AddFrame(new TGHorizontal3DLine(title1),
00373                     new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00374    fBin->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
00375 
00376    // Widgets for rebinning a histogram which does NOT derive from a ntuple
00377    fBinCont = new TGCompositeFrame(fBin, 80, 20, kVerticalFrame);
00378    TGCompositeFrame *f18 = new TGCompositeFrame(fBinCont, 80, 20, 
00379                                                           kHorizontalFrame);
00380    fBinSlider  = new TGHSlider(f18, 100, kSlider1 | kScaleBoth);
00381    fBinSlider->Resize(107,20); 
00382    f18->AddFrame(fBinSlider, new TGLayoutHints(kLHintsLeft, 3,0,0,3));
00383    fBinCont->AddFrame(f18, new TGLayoutHints(kLHintsTop, 15, 7, 3, 5));
00384    
00385    TGCompositeFrame *f20 = new TGCompositeFrame(fBinCont, 80, 20, 
00386                                                           kHorizontalFrame);
00387    TGLabel *binLabel1 = new TGLabel(f20, "# of Bins:");
00388    f20->AddFrame(binLabel1, new TGLayoutHints(kLHintsLeft, 7, 1, 2, 1));
00389    fBinNumberEntry = new TGNumberEntryField(f20, kBINSLIDER, 0.0,  
00390                                             TGNumberFormat::kNESInteger);
00391    ((TGTextEntry*)fBinNumberEntry)->SetToolTipText("Set the number of bins in the rebinned histogram");
00392    fBinNumberEntry->Resize(57,20);
00393    f20->AddFrame(fBinNumberEntry, new TGLayoutHints(kLHintsRight, 21, 0, 0, 0));
00394    fBinCont->AddFrame(f20, new TGLayoutHints(kLHintsTop, 0, 7, 3, 4));
00395    
00396    // Text buttons to Apply or Delete the rebinned histogram
00397    TGCompositeFrame *f23 = new TGCompositeFrame(fBinCont, 118, 20, 
00398                                                           kHorizontalFrame | 
00399                                                           kFixedWidth);
00400    fApply = new TGTextButton(f23, " &Apply ");
00401    f23->AddFrame(fApply, 
00402                  new TGLayoutHints(kLHintsExpandX | kLHintsLeft , 0, 3, 4, 4));
00403    fCancel = new TGTextButton(f23, " &Ignore ");
00404    f23->AddFrame(fCancel, 
00405                  new TGLayoutHints(kLHintsExpandX | kLHintsLeft, 3, 0, 4, 4));
00406    fBinCont->AddFrame(f23, new TGLayoutHints(kLHintsTop, 20, 3, 3, 4));
00407    fBin->AddFrame(fBinCont,new TGLayoutHints(kLHintsTop| kLHintsExpandX)); 
00408    
00409    // Widgets for rebinning a histogram which derives from a ntuple
00410    fBinCont1 = new TGCompositeFrame(fBin, 80, 20, kVerticalFrame);   
00411    TGCompositeFrame *f21 = new TGCompositeFrame(fBinCont1, 80, 20, 
00412                                                            kHorizontalFrame);
00413    fBinSlider1  = new TGHSlider(f21, 100, kSlider1 | kScaleBoth);
00414    fBinSlider1->Resize(107,20); 
00415    fBinSlider1->SetRange(1,9);
00416    fBinSlider1->SetScale(12);
00417    fBinSlider1->SetPosition(5);
00418    f21->AddFrame(fBinSlider1, new TGLayoutHints(kLHintsLeft, 3,0,0,3));
00419    fBinCont1->AddFrame(f21, new TGLayoutHints(kLHintsTop, 15, 7, 5, 0));
00420 
00421    //  Lettering of the Rebin Slider
00422    TGCompositeFrame *f24 = new TGCompositeFrame(fBinCont1, 80, 20, 
00423                                                            kHorizontalFrame);   
00424    TGLabel *l1 = new TGLabel(f24, "-5");
00425    f24->AddFrame(l1, new TGLayoutHints(kLHintsLeft, 18, 1, -1, 0));
00426    TGLabel *l2 = new TGLabel(f24, "-2");
00427    f24->AddFrame(l2, new TGLayoutHints(kLHintsLeft, 26, 2, -1, 0));
00428    TGLabel *l3 = new TGLabel(f24, "2");
00429    f24->AddFrame(l3, new TGLayoutHints(kLHintsLeft, 17, 2, -1, 0));
00430    TGLabel *l4 = new TGLabel(f24, "5");
00431    f24->AddFrame(l4, new TGLayoutHints(kLHintsLeft, 32, 3, -1, 0));
00432    fBinCont1->AddFrame(f24, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
00433       
00434    TGCompositeFrame *f22 = new TGCompositeFrame(fBinCont1, 140, 20, 
00435                                                 kHorizontalFrame);
00436    TGLabel *binLabel2 = new TGLabel(f22, "# of Bins:");
00437    f22->AddFrame(binLabel2, new TGLayoutHints(kLHintsLeft, 7, 1, 4, 1));
00438 
00439    fBinNumberEntry1 = new TGNumberEntryField(f22, kBINSLIDER1, 0.0,  
00440                                              TGNumberFormat::kNESInteger);
00441    ((TGTextEntry*)fBinNumberEntry1)->SetToolTipText("Set the number of bins in the rebinned histogram");
00442    fBinNumberEntry1->Resize(57,20);
00443    f22->AddFrame(fBinNumberEntry1, new TGLayoutHints(kLHintsLeft, 21, 0, 2, 0));
00444    fBinCont1->AddFrame(f22, new TGLayoutHints(kLHintsTop, 0, 7, 2, 4));
00445 
00446    TGCompositeFrame *f26 = new TGCompositeFrame(fBinCont1, 80, 20, 
00447                                                 kHorizontalFrame);
00448    TGLabel *offsetLbl = new TGLabel(f26, "BinOffset:");
00449    f26->AddFrame(offsetLbl, new TGLayoutHints(kLHintsLeft, 6, 1, 2, 1));
00450    fOffsetNumberEntry = new TGNumberEntryField(f26, kBINOFFSET, 0.0,  
00451                                                TGNumberFormat::kNESRealFour,
00452                                                TGNumberFormat::kNEAAnyNumber,
00453                                                TGNumberFormat::kNELLimitMinMax, 
00454                                                0., 1.);
00455    ((TGTextEntry*)fOffsetNumberEntry)->SetToolTipText("Add an offset to the origin of the histogram");
00456    fOffsetNumberEntry->Resize(57,20);
00457    f26->AddFrame(fOffsetNumberEntry, 
00458                  new TGLayoutHints(kLHintsRight, 21, 0, 0, 0));
00459    fBinCont1->AddFrame(f26, new TGLayoutHints(kLHintsTop, 0, 7, 3, 1));
00460 
00461    TGCompositeFrame *f25 = new TGCompositeFrame(fBinCont1, 80, 20, 
00462                                                            kHorizontalFrame);
00463    fBinOffsetSld  = new TGHSlider(f25, 100, kSlider1 | kScaleBoth);
00464    fBinOffsetSld->Resize(107,20); 
00465    f25->AddFrame(fBinOffsetSld, new TGLayoutHints(kLHintsLeft, 15,0,0,2));
00466    fBinCont1->AddFrame(f25, new TGLayoutHints(kLHintsTop, 3, 7, 3, 3));
00467    fBin->AddFrame(fBinCont1, new TGLayoutHints(kLHintsTop));
00468    
00469    // Sliders for axis range
00470    TGCompositeFrame *sldCont = new TGCompositeFrame(fBin, 80, 20, 
00471                                                     kVerticalFrame); 
00472    TGCompositeFrame *title2 = new TGCompositeFrame(sldCont, 145, 10, 
00473                                                             kHorizontalFrame | 
00474                                                             kLHintsExpandX   | 
00475                                                             kFixedWidth      | 
00476                                                             kOwnBackground);
00477    title2->AddFrame(new TGLabel(title2, "Axis Range"), 
00478                     new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00479    title2->AddFrame(new TGHorizontal3DLine(title2),
00480                     new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00481    sldCont->AddFrame(title2, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
00482 
00483    TGCompositeFrame *f14 = new TGCompositeFrame(sldCont, 80, 20, 
00484                                                          kHorizontalFrame);
00485    TGLabel *fSliderLbl = new TGLabel(f14,"x:");
00486    f14->AddFrame(fSliderLbl, 
00487                  new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 4,4, 4, 1)); 
00488    fSlider = new TGDoubleHSlider(f14, 1, 2);
00489    fSlider->Resize(118,20);
00490    f14->AddFrame(fSlider, new TGLayoutHints(kLHintsLeft));
00491    sldCont->AddFrame(f14, new TGLayoutHints(kLHintsTop, 3, 7, 4, 1));
00492    
00493    TGCompositeFrame *f16 = new TGCompositeFrame(sldCont, 80, 20, 
00494                                                          kHorizontalFrame);
00495    fSldMin = new TGNumberEntryField(f16, kSLIDER_MIN, 0.0,  
00496                                     TGNumberFormat::kNESRealTwo,
00497                                     TGNumberFormat::kNEAAnyNumber);
00498    ((TGTextEntry*)fSldMin)->SetToolTipText("Set the minimum value of the x-axis");
00499    fSldMin->Resize(57,20);
00500    f16->AddFrame(fSldMin, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
00501    fSldMax = new TGNumberEntryField(f16, kSLIDER_MAX, 0.0,  
00502                                     TGNumberFormat::kNESRealTwo,
00503                                     TGNumberFormat::kNEAAnyNumber);
00504    ((TGTextEntry*)fSldMax)->SetToolTipText("Set the maximum value of the x-axis");
00505    fSldMax->Resize(57,20);
00506    f16->AddFrame(fSldMax, new TGLayoutHints(kLHintsLeft, 4, 0, 0, 0));
00507    sldCont->AddFrame(f16, new TGLayoutHints(kLHintsTop, 20, 3, 5, 0));
00508 
00509    TGCompositeFrame *f17 = new TGCompositeFrame(sldCont, 80, 20, kVerticalFrame); 
00510    fDelaydraw = new TGCheckButton(f17, "Delayed drawing", kDELAYED_DRAWING);
00511    fDelaydraw ->SetToolTipText("Draw the new histogram only when any Slider is released");
00512    f17->AddFrame(fDelaydraw, new TGLayoutHints(kLHintsLeft, 6, 1, 2, 0));
00513    sldCont->AddFrame(f17, new TGLayoutHints(kLHintsTop, 1, 1, 5, 0)); 
00514    fBin->AddFrame(sldCont, new TGLayoutHints(kLHintsTop)); 
00515 
00516    // to avoid jumping from DoAddBar to DoAddB and vice versa
00517    fMakeB=kTRUE;
00518    // to avoid calling SetDrawoption after every change
00519    fMake=kTRUE;
00520 
00521    fBinHist = 0; // used to save a copy of the histogram 
00522 
00523    // (when not drawn from an ntuple)
00524    fBinOffsetSld->SetRange(0,100);
00525    fBinOffsetSld->SetPosition(0);
00526    fOffsetNumberEntry->SetNumber(0.0000);
00527    fCancel->SetState(kButtonDisabled);  
00528    fApply->SetState(kButtonDisabled);
00529 
00530 }  // end bin tab
00531 
00532 //______________________________________________________________________________
00533 TH1Editor::~TH1Editor()
00534 {
00535    // Destructor of TH1 editor.
00536 
00537    // children of TGButonGroup are not deleted 
00538    delete fDim;
00539    delete fDim0;
00540    delete fDimlh;
00541    delete fDim0lh;
00542 
00543    if (fBinHist) delete fBinHist;
00544    fBinHist = 0;
00545 }
00546 
00547 //______________________________________________________________________________
00548 void TH1Editor::ConnectSignals2Slots()
00549 {
00550    // Connect signals to slots.
00551 
00552    //widgets for draw options
00553    fAddB->Connect("Toggled(Bool_t)", "TH1Editor", this, "DoAddB(Bool_t)");
00554    fAddBar->Connect("Toggled(Bool_t)", "TH1Editor", this, "DoAddBar(Bool_t)");
00555    fTitle->Connect("TextChanged(const char *)", "TH1Editor", this, "DoTitle(const char *)");
00556    fTypeCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoHistChanges()");
00557    fCoordsCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoHistChanges()");
00558    fErrorCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoHistChanges()");
00559    fAddCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoHistChanges()");
00560    fAddMarker->Connect("Toggled(Bool_t)", "TH1Editor", this, "DoAddMarker(Bool_t)");
00561    fAddSimple->Connect("Toggled(Bool_t)", "TH1Editor", this, "DoAddSimple(Bool_t)");
00562 
00563    //change 2D <-> 3D plot
00564    fDimGroup->Connect("Clicked(Int_t)","TH1Editor",this,"DoHistView()");
00565 
00566    // change Bar Width/Offset, the second connection is needed to have the ability to confirm the value also with enter
00567    fBarWidth->Connect("ValueSet(Long_t)", "TH1Editor", this, "DoBarWidth()");
00568    (fBarWidth->GetNumberEntry())->Connect("ReturnPressed()", "TH1Editor", this, "DoBarWidth()");   
00569    fBarOffset->Connect("ValueSet(Long_t)", "TH1Editor", this, "DoBarOffset()");
00570    (fBarOffset->GetNumberEntry())->Connect("ReturnPressed()", "TH1Editor", this, "DoBarOffset()");
00571    fPercentCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoPercent()");
00572    fMakeHBar-> Connect("Toggled(Bool_t)","TH1Editor",this,"DoHBar(Bool_t))"); 
00573 
00574    // Connections for rebinning are created - i.e. slider is
00575    // connected to the slots that perform the rebinning in the  
00576    // case of a histogram not derived from an ntuple.
00577    fBinSlider->Connect("PositionChanged(Int_t)","TH1Editor",this, "DoBinMoved(Int_t)");  
00578    fBinSlider->Connect("Released()","TH1Editor",this, "DoBinReleased()"); 
00579    fBinSlider->Connect("Pressed()","TH1Editor",this, "DoBinPressed()");    
00580    // numberEntry which shows/sets the actual number of bins
00581    fBinNumberEntry->Connect("ReturnPressed()", "TH1Editor", this, "DoBinLabel()");
00582    // Buttons to accept/reject the rebinned histogram
00583    fApply->Connect("Clicked()", "TH1Editor", this, "DoApply()");   
00584    fCancel->Connect("Pressed()", "TH1Editor", this, "DoCancel()");   
00585    // in case of a histogram which is derived from an ntuple these slots are used
00586    fBinSlider1->Connect("Released()","TH1Editor",this, "DoBinReleased1()");  
00587    fBinSlider1->Connect("PositionChanged(Int_t)","TH1Editor",this, "DoBinMoved1()");     
00588    fBinNumberEntry1->Connect("ReturnPressed()", "TH1Editor", this, "DoBinLabel1()");
00589    // slider/slots to change the offset of the histogram
00590    fBinOffsetSld->Connect("PositionChanged(Int_t)", "TH1Editor", this,"DoOffsetMoved(Int_t)");
00591    fBinOffsetSld->Connect("Released()", "TH1Editor", this, "DoOffsetReleased()");
00592    fBinOffsetSld->Connect("Pressed()", "TH1Editor", this, "DoOffsetPressed()");
00593    fOffsetNumberEntry->Connect("ReturnPressed()", "TH1Editor", this, "DoBinOffset()");
00594    // slider/slots to set the visible axisrange 
00595    fSlider->Connect("PositionChanged()","TH1Editor", this,"DoSliderMoved()");
00596    fSlider->Connect("Pressed()","TH1Editor", this, "DoSliderPressed()"); 
00597    fSlider->Connect("Released()","TH1Editor", this, "DoSliderReleased()");     
00598    fSldMin->Connect("ReturnPressed()", "TH1Editor", this, "DoAxisRange()");
00599    fSldMax->Connect("ReturnPressed()", "TH1Editor", this, "DoAxisRange()"); 
00600    fInit = kFALSE;
00601 }
00602 
00603 //______________________________________________________________________________
00604 Bool_t TH1Editor::AcceptModel(TObject* obj)
00605 {
00606    // Check if object is able to configure with this editor.
00607 
00608    if (obj == 0 || !obj->InheritsFrom(TH1::Class()) || 
00609        ((TH1*)obj)->GetDimension()!=1 || 
00610        ((TH1*)obj)->GetEntries() == 0 
00611        /*|| obj->InheritsFrom("TH2")  || obj->InheritsFrom("TProfile")*/) {
00612       return kFALSE;                 
00613    }
00614    return kTRUE;
00615 }
00616 
00617 //______________________________________________________________________________
00618 void TH1Editor::SetModel(TObject* obj)
00619 {
00620    // Pick up current values of histogram attributes.
00621 
00622    if (fBinHist && (obj != fHist)) {
00623       //we have probably moved to a different pad.
00624       //let's restore the original histogram
00625       fHist->Reset();
00626       fHist->SetBins(fBinHist->GetXaxis()->GetNbins(),
00627                      fBinHist->GetXaxis()->GetXmin(),
00628                      fBinHist->GetXaxis()->GetXmax());
00629       fHist->Add(fBinHist);
00630       delete fBinHist; fBinHist = 0;
00631    }
00632 
00633    fHist = (TH1*)obj;
00634    fAvoidSignal = kTRUE;
00635 
00636      const char *text = fHist->GetTitle();
00637    fTitle->SetText(text);
00638    
00639    fMake=kFALSE;
00640    TString str = GetDrawOption();
00641    str.ToUpper();
00642    if (str.Contains("SAME"))
00643       fSameOpt = kTRUE;
00644    else
00645       fSameOpt = kFALSE;
00646    Bool_t errorset = kFALSE;
00647    // if no draw option is specified: (default options)
00648    if (str.IsNull() || str=="" ) {        
00649       fDimGroup->SetButton(kDIM_SIMPLE, kTRUE);
00650       fDimGroup->SetButton(kDIM_COMPLEX, kFALSE);      
00651       HideFrame(f3);  // Hiding the histogram type combo box
00652       ShowFrame(f6);
00653       ShowFrame(f7);
00654       ShowFrame(f8);
00655       ShowFrame(f9);
00656       HideFrame(f10);
00657       HideFrame(f11);
00658       HideFrame(f12);
00659       ShowFrame(f15);
00660       fCoordsCombo->Select(kCOORDS_CAR);
00661       fErrorCombo->Select(kERRORS_NO);
00662       errorset=kTRUE;
00663       fAddCombo->Select(kADD_NONE);
00664       fAddMarker->SetState(kButtonUp);
00665       fAddB->SetState(kButtonUp);
00666       fAddSimple->SetState(kButtonDisabled);
00667       ChangeErrorCombo(1);
00668    // in case of a 2D plot:
00669    } else if (!str.Contains("LEGO") && !str.Contains("SURF")){
00670       fDimGroup->SetButton(kDIM_SIMPLE,kTRUE);
00671       fDimGroup->SetButton(kDIM_COMPLEX,kFALSE);      
00672       HideFrame(f3);  // Hiding the histogram type combo box
00673       ShowFrame(f7);
00674       ShowFrame(f8);
00675       ShowFrame(f9);
00676       ShowFrame(f15);
00677       fCoordsCombo->Select(kCOORDS_CAR);
00678       // initialising fAddCombo
00679       if (str.Contains("C")) {
00680          if (str.Contains("CYL")) {
00681             TString dum = str;
00682             dum.Remove(strstr(dum.Data(),"CYL")-dum.Data(),3);
00683             if (dum.Contains("C")) fAddCombo->Select(kADD_SMOOTH);
00684          } else fAddCombo->Select(kADD_SMOOTH);
00685       } 
00686       else if (str.Contains("LF2")) fAddCombo->Select(kADD_FILL);
00687       else if (str.Contains("L")){
00688          TString dum = str;
00689          if (str.Contains("CYL")) {
00690             dum.Remove(strstr(dum.Data(),"CYL")-dum.Data(),3);
00691             if (dum.Contains("L")) fAddCombo->Select(kADD_SIMPLE);
00692          }
00693          if (str.Contains("POL")) {
00694             dum.Remove(strstr(dum.Data(),"POL")-dum.Data(),3);
00695             if (dum.Contains("L")) fAddCombo->Select(kADD_SIMPLE);
00696          } else fAddCombo->Select(kADD_SIMPLE);
00697       } else fAddCombo->Select(kADD_NONE);
00698 
00699       if (fAddCombo->GetSelected()!=kADD_NONE) 
00700          fAddSimple->SetState(kButtonDisabled);
00701       else if (str.Contains("HIST")) {
00702          if (str=="HIST") fAddSimple->SetState(kButtonDisabled);
00703          else fAddSimple->SetState(kButtonDown);
00704       } else fAddSimple->SetState(kButtonUp);
00705       
00706       if (str.Contains("B")) {
00707          TString dum = str;
00708          if (str.Contains("BAR")) {
00709             fAddBar->SetState(kButtonDown);
00710             fAddB->SetState(kButtonDisabled);
00711             ShowFrame(f10);
00712             ShowFrame(f11);
00713             ShowFrame(f12);
00714          } else {
00715             fAddB->SetState(kButtonDown);
00716             fAddBar->SetState(kButtonDisabled);
00717             fAddSimple->SetState(kButtonDisabled);
00718             ShowFrame(f10);
00719             ShowFrame(f11);      
00720             HideFrame(f12);
00721          }
00722       } else {
00723          fAddB->SetState(kButtonUp);
00724          fAddBar->SetState(kButtonUp);
00725          HideFrame(f10);
00726          HideFrame(f11);
00727          HideFrame(f12);
00728       }
00729       if (str.Contains("P") ) {
00730          fAddMarker->SetState(kButtonDown);
00731          fAddSimple->SetState(kButtonDisabled);
00732       } else if (!str.Contains("BAR")) fAddMarker->SetState(kButtonUp);
00733       ChangeErrorCombo(1);
00734 
00735    // in case of a 3D plot
00736    } else if (str.Contains("LEGO") || str.Contains("SURF")){
00737       fDimGroup->SetButton(kDIM_COMPLEX,kTRUE);
00738       fDimGroup->SetButton(kDIM_SIMPLE,kFALSE);      
00739       TGListBox* lb;
00740       ChangeErrorCombo(0);
00741       // set Coordinate ComboBox
00742       if (str.Contains("SURF")){ 
00743          // surf cannot be combined with spheric and cartesian coordinates 
00744          // i.e. remove them from the combobox
00745          fCoordsCombo->RemoveEntry(kCOORDS_SPH);
00746          fCoordsCombo->RemoveEntry(kCOORDS_CAR);
00747          lb = fCoordsCombo->GetListBox();
00748          lb->Resize(lb->GetWidth(), 49);
00749       } else {
00750          // surf cannot be combined with spheric and cartesian coordinates 
00751          // if surf was selected before here the removed items were added the combobox again
00752          if (((TGLBContainer*)((TGListBox*)fCoordsCombo->GetListBox())->GetContainer())->GetPos(kCOORDS_SPH)==-1) 
00753             fCoordsCombo->AddEntry("Spheric", kCOORDS_SPH);
00754          if (((TGLBContainer*)((TGListBox*)fCoordsCombo->GetListBox())->GetContainer())->GetPos(kCOORDS_CAR)==-1) {
00755             fCoordsCombo->AddEntry("Cartesian", kCOORDS_CAR);
00756             lb = fCoordsCombo->GetListBox();
00757             lb->Resize(lb->GetWidth(), 83);
00758          }
00759       }
00760       // initialising the Type Combobox
00761       if (str.Contains("LEGO2")) fTypeCombo->Select(kTYPE_LEGO2);
00762       else if (str.Contains("LEGO1")) fTypeCombo->Select(kTYPE_LEGO1);
00763       else if (str.Contains("LEGO")) fTypeCombo->Select(kTYPE_LEGO);
00764       else if (str.Contains("SURF5")) fTypeCombo->Select(kTYPE_SURF5);
00765       else if (str.Contains("SURF4")) fTypeCombo->Select(kTYPE_SURF4);
00766       else if (str.Contains("SURF3")) fTypeCombo->Select(kTYPE_SURF3);
00767       else if (str.Contains("SURF2")) fTypeCombo->Select(kTYPE_SURF2);
00768       else if (str.Contains("SURF1")) fTypeCombo->Select(kTYPE_SURF1);
00769       else if (str.Contains("SURF")) fTypeCombo->Select(kTYPE_SURF);
00770 
00771       if (str.Contains("CYL")) fCoordsCombo->Select(kCOORDS_CYL);
00772       else if (str.Contains("POL")) fCoordsCombo->Select(kCOORDS_POL);
00773       else if (str.Contains("SPH")) fCoordsCombo->Select(kCOORDS_SPH);
00774       else if (str.Contains("PSR")) fCoordsCombo->Select(kCOORDS_PSR);
00775       else fCoordsCombo->Select(kCOORDS_CAR); //default
00776 
00777       HideFrame(f6); 
00778       HideFrame(f7); 
00779       HideFrame(f8); 
00780       HideFrame(f9);
00781       HideFrame(f15);
00782       if (str.Contains("LEGO")) {
00783          ShowFrame(f10);
00784          ShowFrame(f11); 
00785          HideFrame(f12);
00786       } else {
00787          HideFrame(f10);
00788          HideFrame(f11); 
00789          HideFrame(f12);
00790       }
00791       fAddMarker->SetState(kButtonDisabled);
00792       fAddB->SetState(kButtonDisabled);
00793    }
00794    
00795    if (!errorset) {   
00796       if (str.Contains("E1")) fErrorCombo->Select(kERRORS_EDGES);
00797       else if (str.Contains("E2")) fErrorCombo->Select(kERRORS_REC);
00798       else if (str.Contains("E3")) fErrorCombo->Select(kERRORS_FILL);
00799       else if (str.Contains("E4")) fErrorCombo->Select(kERRORS_CONTOUR);
00800       else if (str.Contains("E")) {
00801          if (str.Contains("LEGO")) {
00802             TString dum=str;
00803             dum.Remove(strstr(dum.Data(),"LEGO")-dum.Data(),4);
00804             if (dum.Contains("E")) fErrorCombo->Select(kERRORS_SIMPLE);
00805          } else fErrorCombo->Select(kERRORS_SIMPLE); 
00806       } else fErrorCombo->Select(kERRORS_NO); //default
00807    }     
00808     
00809    if (fErrorCombo->GetSelected() != kERRORS_NO){
00810       HideFrame(f7);
00811       HideFrame(f8);
00812    }
00813    if (str.Contains("BAR") || ((fAddBar->GetState()==kButtonDown) && 
00814        (fDim->GetState()==kButtonDown))) {
00815       ShowFrame(f10);
00816       ShowFrame(f11);
00817       ShowFrame(f12);
00818       fBarWidth->SetNumber(fHist->GetBarWidth());
00819       fBarOffset->SetNumber(fHist->GetBarOffset());
00820       if (str.Contains("HBAR")) fMakeHBar->SetState(kButtonDown);
00821       else fMakeHBar->SetState(kButtonUp);
00822       
00823       if (str.Contains("BAR4")) fPercentCombo->Select(kPER_40);
00824       else if (str.Contains("BAR3")) fPercentCombo->Select(kPER_30);
00825       else if (str.Contains("BAR2")) fPercentCombo->Select(kPER_20);
00826       else if (str.Contains("BAR1")) fPercentCombo->Select(kPER_10);
00827       else fPercentCombo->Select(kPER_0);
00828    }
00829 
00830    Int_t nx = fHist -> GetXaxis() -> GetNbins();
00831    Int_t nxbinmin = fHist -> GetXaxis() -> GetFirst();
00832    Int_t nxbinmax = fHist -> GetXaxis() -> GetLast();
00833    
00834    if (fDelaydraw->GetState()!=kButtonDown) fDelaydraw->SetState(kButtonUp);
00835 
00836    TTreePlayer *player = (TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer();
00837    
00838    if (!player || player->GetHistogram()!=fHist ) {
00839       Int_t n = 0;
00840       if (fBinHist) n = fBinHist->GetXaxis()->GetNbins();
00841       else n = nx;
00842       if (n < 1) n = 1;
00843       fBin->HideFrame(fBinCont1);
00844       fBin->ShowFrame(fBinCont);
00845       Int_t* div = Dividers(n);
00846       Int_t up = 0;
00847       if (div[0]-1 <= 1) up = 2;
00848       else up = div[0]-1;  
00849       fBinSlider->SetRange(1,up);
00850       Int_t i = 1;
00851       if (fBinSlider->GetMaxPosition()==2 && fBinSlider->GetPosition()==2) 
00852          fBinSlider->SetPosition(2);
00853       else { 
00854          while ( div[i] != nx) i ++;
00855          fBinSlider->SetPosition(div[0] - i + 1);
00856       }
00857       fBinNumberEntry->SetLimits(TGNumberFormat::kNELLimitMinMax , 2, n);
00858       fBinNumberEntry->SetIntNumber(nx);
00859       delete [] div;
00860    }
00861    else if (fHist==player->GetHistogram()) {
00862       fBin->HideFrame(fBinCont);
00863       fBin->ShowFrame(fBinCont1);      
00864       fBinSlider->SetRange(0,1);
00865       fBinSlider->SetPosition(0);
00866       fBinSlider1->SetPosition(5);      
00867       fBinNumberEntry1->SetLimits(TGNumberFormat::kNELLimitMinMax , 2, 10000);
00868       fBinNumberEntry1->SetIntNumber(nxbinmax-nxbinmin+1);
00869    }
00870 
00871    fSlider->SetRange(1,nx);
00872    fSlider->SetPosition((Double_t)nxbinmin,(Double_t)nxbinmax);
00873 
00874    fSldMin->SetNumber(fHist->GetXaxis()->GetBinLowEdge(nxbinmin));
00875    fSldMax->SetNumber(fHist->GetXaxis()->GetBinUpEdge(nxbinmax));
00876 
00877    fOffsetNumberEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 
00878                                  fHist->GetXaxis()->GetBinWidth(1));
00879       
00880    if (fInit) ConnectSignals2Slots();
00881    fMake=kTRUE;
00882    fGedEditor->GetTab()->SetEnabled(1, kTRUE);
00883    fAvoidSignal = kFALSE;
00884 }
00885 
00886 //______________________________________________________________________________
00887 void TH1Editor::DoTitle(const char *text)
00888 {
00889    // Slot connected to the histogram title setting.
00890   
00891    if (fAvoidSignal) return;
00892    fHist->SetTitle(text);
00893    Update();
00894 }
00895 
00896 //______________________________________________________________________________
00897 void TH1Editor::DoAddMarker(Bool_t on)
00898 {
00899    // Slot connected to the show markers check box.
00900    
00901    if (fAvoidSignal) return;
00902    TString str = GetDrawOption();
00903    str.ToUpper(); 
00904    if (str.Contains("SAME"))
00905       fSameOpt = kTRUE;
00906    else
00907       fSameOpt = kFALSE;
00908    TString dum = str;
00909    
00910    if (dum.Contains("POL")) dum.Remove(strstr(dum.Data(),"POL")-dum.Data(),3);
00911    if (dum.Contains("SPH")) dum.Remove(strstr(dum.Data(),"SPH")-dum.Data(),3); 
00912    if (dum.Contains("PSR")) dum.Remove(strstr(dum.Data(),"PSR")-dum.Data(),3);      
00913    if (on) {
00914       if (!dum.Contains("P")) str += "P"; 
00915       fAddSimple->SetState(kButtonDisabled);
00916       if (str.Contains("HIST")) 
00917          str.Remove(strstr(str.Data(),"HIST")-str.Data(),4);
00918    } else if (fAddMarker->GetState()==kButtonUp) {
00919       if (str.Contains("POL") || str.Contains("SPH")) {
00920          while (dum.Contains("P")) 
00921             dum.Remove(strstr(dum.Data(),"P")-dum.Data(),1);
00922          if (str.Contains("POL")) str = dum + "POL";
00923          if (str.Contains("SPH")) str = dum + "SPH";
00924          if (str.Contains("PSR")) str = dum + "PSR";     
00925       } else if (str.Contains("P")) str.Remove(str.First("P"),1); 
00926       if ((str=="HIST") || (str=="") || 
00927           (fAddB->GetState()==kButtonDown) || 
00928           fAddCombo->GetSelected() != kADD_NONE) 
00929          fAddSimple->SetState(kButtonDisabled);
00930       else if (str.Contains("HIST")) 
00931          fAddSimple->SetState(kButtonDown);
00932       else 
00933          fAddSimple->SetState(kButtonUp);
00934    }
00935    if (fMake) {
00936       if (fSameOpt) str += "SAME";
00937       SetDrawOption(str);
00938       Update();
00939    }
00940 }
00941 
00942 //______________________________________________________________________________
00943 void TH1Editor::DoAddB(Bool_t on)
00944 {
00945    // Slot connected to the bar Add check box.
00946    
00947    if (fAvoidSignal) return;
00948    TString str = GetDrawOption();
00949    str.ToUpper();
00950    if (str.Contains("SAME"))
00951       fSameOpt = kTRUE;
00952    else
00953       fSameOpt = kFALSE;
00954    if (fMakeB) {
00955       fMakeB=kFALSE;
00956       if (on) {
00957          if (!str.Contains("B")) str += "B";
00958          ShowFrame(f10);
00959          ShowFrame(f11);
00960          HideFrame(f12);
00961          fAddBar->SetState(kButtonDisabled);
00962          fAddSimple->SetState(kButtonDisabled);
00963          fBarOffset->SetNumber(fHist->GetBarOffset());
00964          fBarWidth->SetNumber(fHist->GetBarWidth());      
00965       } else if (fAddB->GetState()==kButtonUp) {
00966          while (str.Contains("B")) 
00967             str.Remove(str.First("B"),1);
00968          HideFrame(f10);
00969          HideFrame(f11);
00970          HideFrame(f12);
00971          fAddBar->SetState(kButtonUp);
00972          if (fAddMarker->GetState()!=kButtonDown && 
00973              !(str=="" || str=="HIST" || 
00974              fAddCombo->GetSelected()!=kADD_NONE)) 
00975             fAddSimple->SetState(kButtonUp);
00976       }
00977       if (fSameOpt) str += "SAME";
00978       if (fMake) SetDrawOption(str);
00979       Update(); 
00980 
00981       fMakeB=kTRUE;
00982    }
00983 }
00984 
00985 //______________________________________________________________________________
00986 void TH1Editor::DoAddBar(Bool_t on)
00987 {
00988    // Slot connected to the bar Add check box.
00989    
00990    if (fAvoidSignal) return;
00991    Disconnect(fAddMarker);
00992    TString str = GetDrawOption();
00993    str.ToUpper();
00994    if (str.Contains("SAME"))
00995       fSameOpt = kTRUE;
00996    else
00997       fSameOpt = kFALSE;
00998    if (fMakeB) {
00999       fMakeB=kFALSE;
01000       Int_t o = 0;
01001       if (str.Contains("HBAR")) o=1;
01002       if (str.Contains("BAR4")) 
01003          str.Remove(strstr(str.Data(),"BAR4")-str.Data()-o,4+o);
01004       else if (str.Contains("BAR3")) 
01005          str.Remove(strstr(str.Data(),"BAR3")-str.Data()-o,4+o);
01006       else if (str.Contains("BAR2")) 
01007          str.Remove(strstr(str.Data(),"BAR2")-str.Data()-o,4+o);
01008       else if (str.Contains("BAR1")) 
01009          str.Remove(strstr(str.Data(),"BAR1")-str.Data()-o,4+o);            
01010       else if (str.Contains("BAR0")) 
01011          str.Remove(strstr(str.Data(),"BAR0")-str.Data()-o,4+o);      
01012       else if (str.Contains("BAR")) 
01013          str.Remove(strstr(str.Data(),"BAR")-str.Data()-o,3+o);      
01014       if (on) {
01015          if ((fAddMarker->GetState()==kButtonDown) && 
01016              (fErrorCombo->GetSelected()==kERRORS_NO) && 
01017              (fAddSimple->GetState()!=kButtonDisabled)) 
01018             fAddSimple->SetState(kButtonDisabled);
01019          else if ((fAddMarker->GetState()!=kButtonDown) && 
01020                   (fAddSimple->GetState()==kButtonDisabled)) {
01021             if (str.Contains("HIST")) 
01022                fAddSimple->SetState(kButtonDown);  
01023             else if (fAddCombo->GetSelected()!=kADD_NONE) 
01024                fAddSimple->SetState(kButtonDisabled);
01025             else 
01026                fAddSimple->SetState(kButtonUp);
01027          }
01028          switch (fPercentCombo->GetSelected()){
01029             case(-1): { 
01030                str += "BAR";
01031                fPercentCombo->Select(kPER_0);
01032                break;
01033             }
01034             case(kPER_0): { 
01035                str += "BAR"; 
01036                break;
01037             }
01038             case(kPER_10): { 
01039                str += "BAR1"; 
01040                break;
01041             }
01042             case(kPER_20): { 
01043                str += "BAR2"; 
01044                break;
01045             }
01046             case(kPER_30): { 
01047                str += "BAR3"; 
01048                break;
01049             }
01050             case(kPER_40): { 
01051                str += "BAR4"; 
01052                break;
01053             }    
01054          }
01055          ShowFrame(f10);
01056          ShowFrame(f11);
01057          ShowFrame(f12);
01058          if (fMakeHBar->GetState()==kButtonDown) 
01059             str.Insert(strstr(str.Data(),"BAR")-str.Data(),"H");
01060          fBarOffset->SetNumber(fHist->GetBarOffset());
01061          fBarWidth->SetNumber(fHist->GetBarWidth());      
01062          fAddB->SetState(kButtonDisabled);
01063       } else if (fAddBar->GetState()==kButtonUp) {
01064          HideFrame(f10);
01065          HideFrame(f11); 
01066          HideFrame(f12);
01067          fAddB->SetState(kButtonUp);
01068          if (fAddMarker->GetState()==kButtonDisabled) 
01069             fAddMarker->SetState(kButtonUp);
01070          if (str=="" || str=="HIST" || fAddCombo->GetSelected() != kADD_NONE || 
01071              ((fAddMarker->GetState() == kButtonDown) && 
01072                fErrorCombo->GetSelected() == kERRORS_NO) ) 
01073             fAddSimple->SetState(kButtonDisabled);
01074       }
01075       if (fSameOpt) str += "SAME";
01076       if (fMake) SetDrawOption(str);
01077       Update(); 
01078       ((TGMainFrame*)GetMainFrame())->Layout();
01079       fMakeB=kTRUE;
01080    }
01081    fAddMarker->Connect("Toggled(Bool_t)", "TH1Editor", this, "DoAddMarker(Bool_t)");
01082 }
01083 
01084 //______________________________________________________________________________
01085 void TH1Editor::DoAddSimple(Bool_t on)
01086 {
01087    // Slot connected to fAddSimple check box for drawing a simple histogram
01088    // without errors (== HIST draw option) in combination with some other 
01089    // draw options. It draws an additional line on the top of the bins.
01090 
01091    if (fAvoidSignal) return;
01092    Disconnect(fAddMarker);
01093    //   Bool_t make=kFALSE;
01094    fMake = kFALSE;
01095    TString str = GetDrawOption();
01096    str.ToUpper();
01097    if (str.Contains("SAME"))
01098       fSameOpt = kTRUE;
01099    else
01100       fSameOpt = kFALSE;
01101    if (on) {
01102       if (!str.Contains("HIST")) {
01103          str += "HIST";
01104          fAddMarker->SetState(kButtonDisabled);
01105          fMake=kTRUE;
01106       }
01107    } else if (fAddSimple->GetState()==kButtonUp) {
01108       if (str.Contains("HIST")) {
01109          str.Remove(strstr(str.Data(),"HIST")-str.Data(),4);
01110          fAddMarker->SetState(kButtonUp);        
01111          fMake=kTRUE;
01112       }
01113    }
01114    if (fSameOpt) str += "SAME";
01115    if (fMake) SetDrawOption(str);
01116    fAddMarker->Connect("Toggled(Bool_t)", "TH1Editor", this, "DoAddMarker(Bool_t)");
01117    Update();   
01118 }    
01119 
01120 //______________________________________________________________________________
01121 void TH1Editor::DoHistView()
01122 {
01123    // Slot connected to the 'Plot' button group.
01124 
01125    if (gPad) gPad->GetVirtCanvas()->SetCursor(kWatch);
01126    gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kWatch));
01127 
01128    if (fDim->GetState() == kButtonDown) 
01129       DoHistSimple();
01130    else 
01131       DoHistComplex();
01132 
01133    if (gPad) gPad->GetVirtCanvas()->SetCursor(kPointer);
01134    gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kPointer));
01135 }
01136 
01137 //______________________________________________________________________________
01138 void TH1Editor::DoHistSimple()
01139 {
01140    // Slot connected to the 2D radio button.
01141 
01142    if (fAvoidSignal) return;
01143    if (fDim->GetState()==kButtonDown){
01144       TString str ="";
01145       fMake=kFALSE;
01146       TGListBox* lb;
01147       HideFrame(f3);
01148       ShowFrame(f6);
01149       ShowFrame(f9);
01150       ShowFrame(f15);
01151       ChangeErrorCombo(1);
01152       if ((fAddBar->GetState() != kButtonDown || 
01153            fAddMarker->GetState()==kButtonDown ) &&
01154           (fErrorCombo->GetSelected()==kERRORS_NO)) 
01155          fAddSimple->SetState(kButtonDisabled);
01156       else if ((fAddSimple->GetState()==kButtonDisabled) && 
01157                (fAddMarker->GetState()!=kButtonDown)) 
01158          fAddSimple->SetState(kButtonUp);
01159       else if (fAddSimple->GetState()!=kButtonUp) 
01160          fAddSimple->SetState(kButtonDown);
01161       if (fAddMarker->GetState()==kButtonDisabled && 
01162           fAddSimple->GetState()!=kButtonDown) 
01163          fAddMarker->SetState(kButtonUp);
01164 
01165       if (fErrorCombo->GetSelected()==kERRORS_NO) {   
01166          ShowFrame(f7);
01167          ShowFrame(f8);
01168       } else {
01169          HideFrame(f7);
01170          HideFrame(f8);
01171          if (fAddBar->GetState()==kButtonDisabled)
01172             fAddBar->SetState(kButtonUp);
01173       } 
01174 
01175       if ((fAddB->GetState() == kButtonDisabled)) {
01176          if (fAddBar->GetState()==kButtonDown) {
01177             ShowFrame(f10);
01178             ShowFrame(f11);
01179             ShowFrame(f12);
01180          } else {
01181             HideFrame(f10);  
01182             HideFrame(f11);
01183             HideFrame(f12);
01184          }          
01185       } 
01186       if (fAddBar->GetState() == kButtonDisabled){
01187          ShowFrame(f10);  
01188          ShowFrame(f11);
01189          HideFrame(f12);
01190       } 
01191       if ((fAddBar->GetState() == kButtonUp) && 
01192           (fAddB->GetState() == kButtonUp)) {
01193          HideFrame(f10);  
01194          HideFrame(f11);
01195          HideFrame(f12);
01196       }
01197       if (fAddCombo->GetSelected()== -1 )fAddCombo->Select(kADD_NONE);
01198       if (fErrorCombo->GetSelected()!=kERRORS_NO) {
01199          fAddCombo->RemoveEntries(kADD_SIMPLE,kADD_FILL);
01200          lb = fAddCombo->GetListBox();
01201          lb->Resize(lb->GetWidth(),19);  
01202          Disconnect(fAddCombo);
01203          fAddCombo->Select(kADD_NONE);
01204          fAddCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoHistChanges()"); 
01205       } else {
01206          if (((TGLBContainer*)((TGListBox*)fAddCombo->GetListBox())->GetContainer())->GetPos(kADD_SIMPLE)==-1)
01207             ((TGListBox*)fAddCombo->GetListBox())->AddEntry("Simple Line", kADD_SIMPLE);
01208          if (((TGLBContainer*)((TGListBox*)fAddCombo->GetListBox())->GetContainer())->GetPos(kADD_SMOOTH)==-1)
01209             ((TGListBox*)fAddCombo->GetListBox())->AddEntry("Smooth Line", kADD_SMOOTH);
01210          if (((TGLBContainer*)((TGListBox*)fAddCombo->GetListBox())->GetContainer())->GetPos(kADD_FILL)==-1) {
01211             ((TGListBox*)fAddCombo->GetListBox())->AddEntry("Fill Area",kADD_FILL);
01212             lb = fAddCombo->GetListBox();
01213             lb->Resize(lb->GetWidth(),76);       
01214          }    
01215       }
01216       if (fAddSimple->GetState()==kButtonDown) str+="HIST";
01217       str += GetHistErrorLabel()+GetHistAddLabel();
01218       if (fSameOpt) str += "SAME";
01219       SetDrawOption(str);
01220       Update();
01221       //fGedEditor->GetTab()->Layout();
01222       ((TGMainFrame*)GetMainFrame())->Layout();      
01223       fMake=kTRUE;
01224    }
01225 }
01226 
01227 //______________________________________________________________________________
01228 void TH1Editor::DoHistComplex()
01229 {
01230    // Slot connected to the 3D radio button.
01231 
01232    if (fAvoidSignal) return;
01233    if (fDim0->GetState()==kButtonDown) {
01234       TString str ="";
01235       fMake=kFALSE;
01236       ShowFrame(f3);
01237       HideFrame(f6);
01238       HideFrame(f7);
01239       HideFrame(f8);
01240       HideFrame(f9);
01241       HideFrame(f15);  
01242       ChangeErrorCombo(0); 
01243       if (fTypeCombo->GetSelected()==-1 && fCoordsCombo->GetSelected()==-1) {
01244          str = "LEGO"+GetHistErrorLabel();
01245          fTypeCombo->Select(kTYPE_LEGO);
01246          fCoordsCombo->Select(kCOORDS_CAR);
01247       } else if (fTypeCombo->GetSelected()==-1){
01248          str = "LEGO"+GetHistErrorLabel();
01249          fTypeCombo->Select(kTYPE_LEGO);
01250       } else if (fCoordsCombo->GetSelected()==-1) {
01251          str = GetHistTypeLabel()+GetHistErrorLabel();
01252          fCoordsCombo->Select(kCOORDS_CAR);
01253       } else {
01254          str = GetHistTypeLabel()+GetHistCoordsLabel()+GetHistErrorLabel();
01255       }
01256       if (str.Contains("LEGO")) {
01257          ShowFrame(f10);
01258          ShowFrame(f11); 
01259          HideFrame(f12);
01260       } else {
01261          HideFrame(f10);
01262          HideFrame(f11); 
01263          HideFrame(f12);
01264       }
01265       if (fSameOpt) str += "SAME";
01266       SetDrawOption(str);
01267       Update();
01268       ((TGMainFrame*)GetMainFrame())->Layout();            
01269       fGedEditor->GetTab()->Layout();
01270       fMake=kTRUE;
01271    }
01272 }    
01273 
01274 //______________________________________________________________________________
01275 void TH1Editor::DoHistChanges()
01276 {
01277    // Slot connected to the histogram type, the coordinate type, the error type
01278    // and the Add combo box.
01279    
01280    if (fAvoidSignal) return;
01281    fMakeB= kFALSE;
01282    TGListBox* lb;
01283    if (GetHistTypeLabel().Contains("SURF")) { 
01284       if (fCoordsCombo->GetSelected()==kCOORDS_CAR || 
01285           fCoordsCombo->GetSelected()==kCOORDS_SPH) 
01286          fCoordsCombo->Select(kCOORDS_POL); 
01287       fCoordsCombo->RemoveEntry(kCOORDS_SPH);
01288       fCoordsCombo->RemoveEntry(kCOORDS_CAR);
01289       lb = fCoordsCombo->GetListBox();
01290       lb->Resize(lb->GetWidth(), 49);
01291    } else {
01292       if (((TGLBContainer*)((TGListBox*)fCoordsCombo->GetListBox())->GetContainer())->GetPos(kCOORDS_SPH)==-1)
01293          ((TGListBox*)fCoordsCombo->GetListBox())->AddEntrySort("Spheric", kCOORDS_SPH);
01294       if (((TGLBContainer*)((TGListBox*)fCoordsCombo->GetListBox())->GetContainer())->GetPos(kCOORDS_CAR)==-1) {
01295          ((TGListBox*)fCoordsCombo->GetListBox())->AddEntrySort("Cartesian", kCOORDS_CAR);
01296          lb = fCoordsCombo->GetListBox();
01297          lb->Resize(lb->GetWidth(), 83);
01298       }
01299    }
01300    if (fDim->GetState()!=kButtonUp){
01301       if (fErrorCombo->GetSelected() != kERRORS_NO){
01302          HideFrame(f7);
01303          HideFrame(f8);
01304          ShowFrame(f9);
01305          fAddMarker->SetState(kButtonDisabled);
01306          fAddB->SetState(kButtonDisabled);
01307          if (fAddBar->GetState()==kButtonDisabled) 
01308             fAddBar->SetState(kButtonUp);
01309          if (fAddSimple->GetState()==kButtonDisabled) 
01310             fAddSimple->SetState(kButtonUp);
01311          fAddCombo->RemoveEntries(kADD_SIMPLE,kADD_FILL);
01312          lb = fAddCombo->GetListBox();
01313          lb->Resize(lb->GetWidth(),19);  
01314          Disconnect(fAddCombo);
01315          fAddCombo->Select(kADD_NONE);
01316          fAddCombo->Connect("Selected(Int_t)", "TH1Editor", this, "DoHistChanges()");
01317          if (fAddBar->GetState()==kButtonDown) {
01318             ShowFrame(f10);     
01319             ShowFrame(f11);
01320             ShowFrame(f12);
01321          } else {
01322             HideFrame(f10);
01323             HideFrame(f11);
01324             HideFrame(f12);
01325          }          
01326       } else {
01327          Bool_t on = fMake;
01328          fMake=kFALSE;
01329          ShowFrame(f7);
01330          ShowFrame(f8);
01331          ShowFrame(f9);
01332          if (fAddMarker->GetState()==kButtonDisabled) 
01333             fAddMarker->SetState(kButtonUp);
01334          if (fAddBar->GetState() != kButtonDown && 
01335              fAddB->GetState()==kButtonDisabled) 
01336             fAddB->SetState(kButtonUp);
01337          if (((TGLBContainer*)((TGListBox*)fAddCombo->GetListBox())->GetContainer())->GetPos(kADD_SIMPLE)==-1)
01338             ((TGListBox*)fAddCombo->GetListBox())->AddEntry("Simple Line", kADD_SIMPLE);
01339          if (((TGLBContainer*)((TGListBox*)fAddCombo->GetListBox())->GetContainer())->GetPos(kADD_SMOOTH)==-1)
01340             ((TGListBox*)fAddCombo->GetListBox())->AddEntry("Smooth Line", kADD_SMOOTH);
01341          if (((TGLBContainer*)((TGListBox*)fAddCombo->GetListBox())->GetContainer())->GetPos(kADD_FILL)==-1) { 
01342             ((TGListBox*)fAddCombo->GetListBox())->AddEntry("Fill Area",kADD_FILL);
01343             lb = fAddCombo->GetListBox();
01344             lb->Resize(lb->GetWidth(),76);      
01345          }
01346          fMake=on;
01347       }
01348       if (fAddCombo->GetSelected()!=kADD_NONE) {
01349          fAddSimple->SetState(kButtonDisabled);
01350       } else {
01351          if (fAddMarker->GetState()==kButtonDown) 
01352             fAddSimple->SetState(kButtonDisabled);
01353          else if (fAddSimple->GetState()==kButtonDisabled) 
01354             fAddSimple->SetState(kButtonUp);
01355       }
01356    } else if (fDim0->GetState()==kButtonDown) {
01357       if (GetHistTypeLabel().Contains("LEGO")) {
01358          ShowFrame(f10);
01359          ShowFrame(f11);
01360          HideFrame(f12);
01361       } else {
01362          HideFrame(f10);
01363          HideFrame(f11);
01364          HideFrame(f12);
01365       }
01366    }        
01367    if (fMake) {
01368       TString str = "";
01369       if (fDim->GetState()==kButtonDown) 
01370          str = GetHistErrorLabel()+GetHistAddLabel();
01371       else if (fDim0->GetState()==kButtonDown) 
01372          str = GetHistTypeLabel()+GetHistCoordsLabel()+GetHistErrorLabel();
01373       if (fAddSimple->GetState()==kButtonDown) 
01374          str += "HIST";   
01375       if (fSameOpt) 
01376          str += "SAME";
01377       SetDrawOption(str);
01378       if (str=="" || str=="HIST") fAddSimple->SetState(kButtonDisabled);
01379       Update();
01380    }
01381    ((TGMainFrame*)GetMainFrame())->Layout();            
01382    //   fGedEditor->GetTab()->Layout();
01383    fMakeB=kTRUE;
01384 }
01385 
01386 //______________________________________________________________________________
01387 void TH1Editor::DoBarWidth()
01388 {
01389    // Slot connected to the Bar Width of the Bar Charts.
01390    
01391    if (fAvoidSignal) return;
01392    fHist->SetBarWidth(fBarWidth->GetNumber());
01393    Update();
01394 }
01395    
01396 //______________________________________________________________________________
01397 void TH1Editor::DoBarOffset()
01398 {
01399    // Slot connected to the Bar Offset of the Bar Charts.
01400    
01401    if (fAvoidSignal) return;
01402    Float_t f = fBarOffset->GetNumber();
01403    fHist->SetBarOffset(f);
01404    Update();
01405 }
01406 
01407 //______________________________________________________________________________
01408 void TH1Editor::DoPercent()
01409 {
01410    // Slot connected to the bar percentage settings.
01411       
01412    if (fAvoidSignal) return;
01413    TString str = GetDrawOption();
01414    str.ToUpper();
01415    if (str.Contains("SAME"))
01416       fSameOpt = kTRUE;
01417    else
01418       fSameOpt = kFALSE;
01419    Int_t o = 0;
01420    if (str.Contains("HBAR")) o=1;
01421    if (str.Contains("BAR4")) 
01422       str.Remove(strstr(str.Data(),"BAR4")-str.Data()-1,4+o);
01423    else if (str.Contains("BAR3")) 
01424       str.Remove(strstr(str.Data(),"BAR3")-str.Data()-o,4+o);
01425    else if (str.Contains("BAR2")) 
01426       str.Remove(strstr(str.Data(),"BAR2")-str.Data()-o,4+o);   
01427    else if (str.Contains("BAR1")) 
01428       str.Remove(strstr(str.Data(),"BAR1")-str.Data()-o,4+o);
01429    else if (str.Contains("BAR0")) 
01430       str.Remove(strstr(str.Data(),"BAR0")-str.Data()-o,4+o);
01431    else if (str.Contains("BAR")) 
01432       str.Remove(strstr(str.Data(),"BAR")-str.Data()-o,3+o);
01433    
01434    if (fMakeHBar->GetState()==kButtonDown) str+="H";
01435    switch (fPercentCombo->GetSelected()){
01436       case (kPER_0) :{ str += "BAR"; break;}
01437       case (kPER_10):{ str += "BAR1"; break;}
01438       case (kPER_20):{ str += "BAR2"; break;}            
01439       case (kPER_30):{ str += "BAR3"; break;} 
01440       case (kPER_40):{ str += "BAR4"; break;}                  
01441    }
01442    if (fSameOpt) str += "SAME";
01443    if (fMake) SetDrawOption(str);
01444    Update();
01445 }
01446 
01447 //______________________________________________________________________________
01448 void TH1Editor::DoHBar(Bool_t on)
01449 {
01450    // Slot connected to the Horizontal Bar check button.
01451    
01452    if (fAvoidSignal) return;
01453    TString str = GetDrawOption();
01454    str.ToUpper();
01455    if (str.Contains("SAME"))
01456       fSameOpt = kTRUE;
01457    else
01458       fSameOpt = kFALSE;
01459    if (on) {
01460       if (!str.Contains("HBAR")) 
01461          str.Insert(strstr(str.Data(),"BAR")-str.Data(),"H");
01462    }
01463    else if (fMakeHBar->GetState()==kButtonUp) {
01464       if (str.Contains("HBAR")) 
01465          str.Remove(strstr(str.Data(),"BAR")-str.Data()-1,1);
01466    }
01467    if (fSameOpt) str += "SAME";
01468    if (fMake) SetDrawOption(str);
01469    Update();
01470 }
01471 
01472 //______________________________________________________________________________
01473 void TH1Editor::DoSliderMoved()
01474 {
01475    // Slot connected to the x-Slider for redrawing of the histogram 
01476    // according to the new Slider range.
01477 
01478    if (fAvoidSignal) return;
01479    fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kTRUE); 
01480    fGedEditor->GetPad()->cd();
01481    if (fDelaydraw->GetState()==kButtonDown && fDim->GetState()==kButtonDown) {  
01482       static Int_t px1,py1,px2,py2;
01483       static Float_t ymin,ymax,xleft,xright;
01484       xleft = fHist->GetXaxis()->GetBinLowEdge((Int_t)((fSlider->GetMinPosition())+0.5));
01485       xright =  fHist->GetXaxis()->GetBinUpEdge((Int_t)((fSlider->GetMaxPosition())+0.5));
01486       ymin  = fGedEditor->GetPad()->GetUymin();
01487       ymax  = fGedEditor->GetPad()->GetUymax();
01488       px1   = fGedEditor->GetPad()->XtoAbsPixel(xleft);
01489       py1   = fGedEditor->GetPad()->YtoAbsPixel(ymin);
01490       px2   = fGedEditor->GetPad()->XtoAbsPixel(xright);
01491       py2   = fGedEditor->GetPad()->YtoAbsPixel(ymax);
01492       fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kTRUE); 
01493       fGedEditor->GetPad()->SetLineWidth(1);
01494       fGedEditor->GetPad()->SetLineColor(2);
01495       fGedEditor->GetPad()->SetLineWidth(1);
01496       fGedEditor->GetPad()->SetLineColor(2);
01497       fGedEditor->GetPad()->cd();
01498       gVirtualX->DrawBox(fPx1old, fPy1old, fPx2old, fPy2old, TVirtualX::kHollow);
01499       gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
01500       fPx1old = px1;
01501       fPy1old = py1;
01502       fPx2old = px2 ;
01503       fPy2old = py2;
01504       gVirtualX->Update(0);
01505       fSldMin->SetNumber(xleft);
01506       fSldMax->SetNumber(xright);
01507    }  else  if (fDelaydraw->GetState() == kButtonDown && 
01508                 fDim0->GetState() == kButtonDown && 
01509                 fCoordsCombo->GetSelected() == kCOORDS_CAR) {
01510       static Float_t p1[3], p2[3], p3[3], p4[3], p5[3], p6[3], p7[3], p8[3];
01511       TView *fView = fGedEditor->GetPad()->GetView();
01512       Double_t *rmin = fView->GetRmin();
01513       Double_t *rmax = fView->GetRmax();
01514       p1[0] = p4[0] = p5[0] = p8[0] = 
01515             fHist->GetXaxis()->GetBinLowEdge((Int_t)((fSlider->GetMinPosition())+0.5));
01516       p2[0] = p3[0] = p6[0] = p7[0] = 
01517             fHist->GetXaxis()->GetBinUpEdge((Int_t)((fSlider->GetMaxPosition())+0.5));
01518       p1[1] = p2[1] = p3[1] = p4[1] = rmin[1];
01519       p5[1] = p6[1] = p7[1] = p8[1] = rmax[1];
01520       p1[2] = p2[2] = p5[2] = p6[2] = rmin[2];
01521       p3[2] = p4[2] = p7[2] = p8[2] = rmax[2];
01522       fGedEditor->GetPad()->SetLineWidth(1);
01523       fGedEditor->GetPad()->SetLineColor(2);
01524       PaintBox3D(fP2old, fP3old, fP7old, fP6old);
01525       PaintBox3D(fP1old, fP4old, fP8old, fP5old);
01526       PaintBox3D(p2, p3, p7, p6);
01527       PaintBox3D(p1, p4, p8, p5);
01528       for (Int_t i = 0; i<3; i++){
01529          fP1old[i] = p1[i];
01530          fP2old[i] = p2[i];      
01531          fP3old[i] = p3[i];      
01532          fP4old[i] = p4[i];                              
01533          fP5old[i] = p5[i];
01534          fP6old[i] = p6[i];      
01535          fP7old[i] = p7[i];      
01536          fP8old[i] = p8[i];                              
01537       }
01538       fSldMin->SetNumber(p1[0]);
01539       fSldMax->SetNumber(p2[0]);
01540    } else  if (fDelaydraw->GetState() == kButtonDown && 
01541                fDim0->GetState() == kButtonDown) {
01542       fSldMin->SetNumber(fHist->GetXaxis()->GetBinLowEdge((Int_t)((fSlider->GetMinPosition())+0.5)));
01543       fSldMax->SetNumber(fHist->GetXaxis()->GetBinUpEdge((Int_t)((fSlider->GetMaxPosition())+0.5)));
01544    } else {
01545       fHist->GetXaxis()->SetRange((Int_t)((fSlider->GetMinPosition())+0.5),
01546                                   (Int_t)((fSlider->GetMaxPosition())+0.5));
01547       fSldMin->SetNumber(fHist->GetXaxis()->GetBinLowEdge(fHist->GetXaxis()->GetFirst()));
01548       fSldMax->SetNumber(fHist->GetXaxis()->GetBinUpEdge(fHist->GetXaxis()->GetLast())); 
01549       fClient->NeedRedraw(fSlider,kTRUE);  
01550       Update();   
01551    }
01552    TTreePlayer *player = (TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer();   
01553    if (player && player->GetHistogram() == fHist) {
01554       Int_t last = fHist->GetXaxis()->GetLast();
01555       Int_t first = fHist->GetXaxis()->GetFirst();
01556       fBinNumberEntry1->SetIntNumber(last-first+1);
01557       // How to redraw the NumberEntry without calling Update?? 
01558       // Update kills the "virtual" painted box in Delayed draw mode  
01559       fClient->NeedRedraw(fBinNumberEntry1,kTRUE);
01560       //      fGedEditor->GetTab()->Layout();
01561    }
01562    fClient->NeedRedraw(fSldMin,kTRUE);
01563    fClient->NeedRedraw(fSldMax,kTRUE);   
01564 }
01565 
01566 //______________________________________________________________________________
01567 void TH1Editor::DoSliderPressed()
01568 {
01569    // Slot connected to the x-axis Range slider for initialising the
01570    // values of the slider movement.
01571    
01572    if (fAvoidSignal) return;
01573    fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kTRUE); 
01574    fGedEditor->GetPad()->cd();
01575    static Float_t ymin,ymax,xleft,xright;
01576    Int_t sldmin = (Int_t)((fSlider->GetMinPosition())+0.5);
01577    Int_t sldmax = (Int_t)((fSlider->GetMaxPosition())+0.5);
01578    if (fDelaydraw->GetState() == kButtonDown && 
01579        fDim->GetState()==kButtonDown) {
01580       fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kTRUE); 
01581       fGedEditor->GetPad()->SetLineWidth(1);
01582       fGedEditor->GetPad()->SetLineColor(2);
01583       xleft = fHist->GetXaxis()->GetBinLowEdge(sldmin);
01584       xright =  fHist->GetXaxis()->GetBinUpEdge(sldmax);
01585       ymin  = fGedEditor->GetPad()->GetUymin();
01586       ymax  = fGedEditor->GetPad()->GetUymax();
01587       fPx1old   = fGedEditor->GetPad()->XtoAbsPixel(xleft);
01588       fPy1old   = fGedEditor->GetPad()->YtoAbsPixel(ymin);
01589       fPx2old   = fGedEditor->GetPad()->XtoAbsPixel(xright);
01590       fPy2old   = fGedEditor->GetPad()->YtoAbsPixel(ymax);
01591       gVirtualX->DrawBox(fPx1old, fPy1old, fPx2old, fPy2old, TVirtualX::kHollow);
01592    } else if (fDelaydraw->GetState() == kButtonDown && 
01593               fDim0->GetState() == kButtonDown && 
01594               fCoordsCombo->GetSelected() == kCOORDS_CAR) {
01595       TView *fView = fGedEditor->GetPad()->GetView();
01596       Double_t *rmin = fView->GetRmin();
01597       Double_t *rmax = fView->GetRmax();
01598       fP1old[0] = fP4old[0] = fP5old[0] = fP8old[0] = 
01599                   fHist->GetXaxis()->GetBinLowEdge(sldmin);
01600       fP2old[0] = fP3old[0] = fP6old[0] = fP7old[0] = 
01601                   fHist->GetXaxis()->GetBinUpEdge(sldmax);
01602       fP1old[1] = fP2old[1] = fP3old[1] = fP4old[1] = rmin[1];
01603       fP5old[1] = fP6old[1] = fP7old[1] = fP8old[1] = rmax[1];
01604       fP1old[2] = fP2old[2] = fP5old[2] = fP6old[2] = rmin[2]; 
01605       fP3old[2] = fP4old[2] = fP7old[2] = fP8old[2] = rmax[2];
01606       fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kTRUE); 
01607       fGedEditor->GetPad()->SetLineWidth(1);
01608       fGedEditor->GetPad()->SetLineColor(2);
01609       PaintBox3D(fP2old, fP3old, fP7old, fP6old);
01610       PaintBox3D(fP1old, fP4old, fP8old, fP5old);
01611    }
01612    Update();
01613 }
01614    
01615 //______________________________________________________________________________
01616 void TH1Editor::DoSliderReleased()
01617 {
01618    // Slot connected to the x-axis Range slider for finalizing the 
01619    // values of the slider movement. 
01620 
01621    if (fAvoidSignal) return;
01622    if (fDelaydraw->GetState()==kButtonDown) {
01623       fHist->GetXaxis()->SetRange((Int_t)((fSlider->GetMinPosition())+0.5),
01624                                   (Int_t)((fSlider->GetMaxPosition())+0.5));
01625       fSldMin->SetNumber(fHist->GetXaxis()->GetBinLowEdge(fHist->GetXaxis()->GetFirst()));
01626       fSldMax->SetNumber(fHist->GetXaxis()->GetBinUpEdge(fHist->GetXaxis()->GetLast()));
01627       Update();
01628    } 
01629    TTreePlayer *player = (TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer();   
01630    if (player) if (player->GetHistogram() == fHist) {
01631       Int_t last = fHist->GetXaxis()->GetLast();
01632       Int_t first = fHist->GetXaxis()->GetFirst();
01633       fBinNumberEntry1->SetIntNumber(last-first+1);
01634       Update();
01635    }
01636 }
01637 
01638 //______________________________________________________________________________
01639 void TH1Editor::DoAxisRange()
01640 {
01641    // Slot connected to the number entry fields containing the Max/Min 
01642    // value of the x-axis.
01643    
01644    if (fAvoidSignal) return;
01645    Int_t nx = fHist->GetXaxis()->GetNbins();
01646    Double_t width = fHist->GetXaxis()->GetBinWidth(1);
01647    Double_t lowLimit = fHist->GetXaxis()->GetBinLowEdge(1);
01648    Double_t upLimit = fHist->GetXaxis()->GetBinUpEdge(nx);
01649    if ((fSldMin->GetNumber()+width/2) < (lowLimit)) 
01650       fSldMin->SetNumber(lowLimit); 
01651    if ((fSldMax->GetNumber()-width/2) > (upLimit)) 
01652       fSldMax->SetNumber(upLimit); 
01653 // Set the histogram range and the axis range slider
01654    fHist->GetXaxis()->SetRangeUser(fSldMin->GetNumber()+width/2, 
01655                                    fSldMax->GetNumber()-width/2);
01656    Int_t nxbinmin = fHist->GetXaxis()->GetFirst();
01657    Int_t nxbinmax = fHist->GetXaxis()->GetLast();
01658    fSlider->SetPosition((Double_t)(nxbinmin),(Double_t)(nxbinmax));
01659    Update();
01660 }
01661 
01662 //______________________________________________________________________________
01663 void TH1Editor::DoBinReleased()
01664 {
01665    // Slot connected to the rebin slider in case of a not ntuple histogram
01666    // Updates some other widgets which are related to the rebin slider.
01667 
01668    // draw the rebinned histogram in case of delay draw mode
01669    if (fAvoidSignal) return;
01670    if (fDelaydraw->GetState()==kButtonDown){
01671       if (!fBinHist) {
01672          fBinHist = (TH1*)fHist->Clone("BinHist");
01673       }
01674       Int_t nx = fBinHist->GetXaxis()->GetNbins();
01675       Int_t numx = fBinSlider->GetPosition();
01676       Int_t* divx = Dividers(nx);   
01677       if (divx[0]==2) fBinSlider->SetPosition(2);
01678       if (divx[0]==2) {
01679          delete [] divx;
01680          return;
01681       }
01682       // delete the histogram which is on the screen
01683       fGedEditor->GetPad()->cd();
01684       fHist->Reset();
01685       fHist->SetBins(nx,fBinHist->GetXaxis()->GetXmin(),
01686                      fBinHist->GetXaxis()->GetXmax());
01687       fHist->Add(fBinHist);
01688       fHist->ResetBit(TH1::kCanRebin);
01689       fHist->Rebin(divx[numx]);
01690       // fModel=fHist;
01691       if (divx[0]!=2) {
01692          TAxis* xaxis = fHist->GetXaxis();
01693          Double_t xBinWidth = xaxis->GetBinWidth(1);      
01694          xaxis->SetRangeUser(fSldMin->GetNumber()+xBinWidth/2, 
01695                              fSldMax->GetNumber()-xBinWidth/2);      
01696          fSlider->SetRange(1,(Int_t)nx/divx[numx]);   
01697          fSlider->SetPosition(xaxis->FindBin(fSldMin->GetNumber()+xBinWidth/2),
01698                               xaxis->FindBin(fSldMax->GetNumber()-xBinWidth/2));
01699          // the x-axis range could be changed a little bit by Rebin algorithm
01700          fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
01701          fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
01702       }
01703       if (fCancel->GetState()==kButtonDisabled) 
01704          fCancel->SetState(kButtonUp);
01705       if (fApply->GetState()==kButtonDisabled) 
01706          fApply->SetState(kButtonUp);
01707       Update();
01708       delete [] divx;
01709    }
01710 //   fGedEditor->GetPad()->GetCanvas()->Selected(fGedEditor->GetPad(), fHist,  0);      
01711    //  fModel = fHist;
01712       Refresh(fHist);
01713 }
01714 
01715 //______________________________________________________________________________
01716 void TH1Editor::DoBinMoved(Int_t numx)
01717 {
01718    // Slot connected to the rebin slider in case of a not ntuple histogram
01719    // (does the Rebinning of the histogram). 
01720 
01721    // create a clone in the background, when the slider is moved for 
01722    // the first time
01723    if (fAvoidSignal) return;
01724    if (!fBinHist /*&& fDelaydraw->GetState()!=kButtonDown*/) {
01725       Int_t* divx = Dividers(fHist->GetXaxis()->GetNbins());
01726       if (divx[0]==2) {
01727          delete [] divx;
01728          return;
01729       }
01730       fBinHist = (TH1*)fHist->Clone("BinHist");
01731       delete [] divx;
01732    } 
01733    // if the slider already has been moved and the clone is saved
01734    Int_t nx = fBinHist->GetXaxis()->GetNbins();
01735    Int_t* divx = Dividers(nx);   
01736    if (divx[0]==2) {
01737       fBinSlider->SetPosition(2);
01738       numx=1;
01739       delete [] divx;
01740       return;
01741    }
01742    Int_t maxx = (Int_t)nx/divx[numx];
01743    if (maxx==1) maxx=2;
01744    if (fDelaydraw->GetState() == kButtonUp) {
01745       fGedEditor->GetPad()->cd();
01746       fHist->Reset();
01747       fHist->SetBins(nx,fBinHist->GetXaxis()->GetXmin(),
01748                      fBinHist->GetXaxis()->GetXmax());
01749       fHist->Add(fBinHist);
01750       fHist->ResetBit(TH1::kCanRebin);
01751       fHist->Rebin(divx[numx]);
01752       //fModel=fHist;
01753       TAxis* xaxis = fHist->GetXaxis();
01754       Double_t xBinWidth = xaxis->GetBinWidth(1);
01755       xaxis->SetRangeUser(fSldMin->GetNumber()+xBinWidth/2,
01756                           fSldMax->GetNumber()-xBinWidth/2);
01757       fSlider->SetRange(1,maxx);
01758       fSlider->SetPosition(xaxis->FindBin(fSldMin->GetNumber()+xBinWidth/2),
01759                            xaxis->FindBin(fSldMax->GetNumber()-xBinWidth/2));
01760       // the axis range could be changed a little bit by the Rebin algorithm
01761       fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
01762       fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
01763       fClient->NeedRedraw(fBinSlider,kTRUE);
01764       Update();
01765    }
01766    if (fCancel->GetState()==kButtonDisabled) 
01767       fCancel->SetState(kButtonUp);
01768    if (fApply->GetState()==kButtonDisabled) 
01769       fApply->SetState(kButtonUp);
01770    if (fBinNumberEntry->GetNumber()!=maxx) 
01771       fBinNumberEntry->SetNumber(maxx);
01772    delete [] divx;
01773 }
01774 
01775 //______________________________________________________________________________
01776 void TH1Editor::DoBinPressed()
01777 {
01778    // Slot connected to the rebin slider in case of a not ntuple histogram.
01779 
01780    if (fAvoidSignal) return;
01781    Int_t* d = Dividers(fHist->GetXaxis()->GetNbins());
01782    if (d[0]==2 && !fBinHist) {
01783       new TGMsgBox(fClient->GetDefaultRoot(), this->GetMainFrame(),
01784                    "TH1 Editor", "It is not possible to rebin the histogram", 
01785                    kMBIconExclamation, kMBOk, 0, kVerticalFrame);
01786       gVirtualX->GrabPointer(fBinSlider->GetId(),0,0,0); 
01787    }
01788    delete [] d;
01789    // calling the MessageBox again does NOT work!*/
01790 }
01791 
01792 //______________________________________________________________________________
01793 void TH1Editor::DoBinReleased1()
01794 {               
01795    // Slot connected to the BinNumber Slider in case of a ntuple histogram
01796    // (does the Rebinning of the histogram). 
01797 
01798    if (fAvoidSignal) return;
01799    Double_t oldOffset = fOffsetNumberEntry->GetNumber();   
01800    Int_t number = fBinSlider1->GetPosition();
01801    if (number==5) return;
01802    Int_t fact = 0;
01803    Int_t binNumber = 0;   
01804    TAxis* xaxis = fHist->GetXaxis();
01805    // "compute" the scaling factor:
01806    if (number > 5) fact = number - 4;
01807    else fact = number - 6;
01808    TTreePlayer *player = (TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer();
01809    if (!player) return;
01810    Int_t first = xaxis->GetFirst();
01811    Int_t last = xaxis->GetLast();
01812    Int_t nx = xaxis->GetNbins();
01813    Double_t min = xaxis->GetBinLowEdge(1);       // overall min in user coords
01814    Double_t max = xaxis->GetBinUpEdge(nx);       // overall max in user coords
01815    Double_t rmin = xaxis->GetBinLowEdge(first);  // recent min in user coords
01816    Double_t rmax = xaxis->GetBinUpEdge(last);    // recent max in user coords
01817    
01818    ((TH1*)player->GetHistogram())->ResetBit(TH1::kCanRebin);
01819    ((TH1*)player->GetHistogram())->Reset();
01820 
01821    // get new Number of bins
01822    if (fact > 0) binNumber = fact*nx;
01823    if (fact < 0) binNumber = (Int_t) ((-1)*nx/fact+0.5);
01824    if (binNumber < 1) binNumber = 1;
01825    if (binNumber > 10000) binNumber= 10000;
01826    Double_t newOffset = 1.*fBinOffsetSld->GetPosition()/100*((max-min)/binNumber);
01827    // create new histogram - the main job is done by sel->TakeAction()
01828    ((TH1*)player->GetHistogram())->SetBins(binNumber,
01829                                            min-oldOffset+newOffset,
01830                                            max-oldOffset+newOffset);
01831    TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
01832    if (!sel) return;
01833    sel->TakeAction();
01834 
01835    // restore and set all the attributes which were changed by TakeAction() 
01836    fHist = (TH1*)((TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer())->GetHistogram();
01837    fSlider->SetRange(1,binNumber);
01838    Double_t binWidth = fHist->GetXaxis()->GetBinWidth(1);
01839    fSlider->SetPosition(xaxis->FindBin(rmin), xaxis->FindBin(rmax));
01840    Double_t offset = 1.*fBinOffsetSld->GetPosition()/100*binWidth;
01841    xaxis->SetRange(xaxis->FindBin(rmin+binWidth/2), 
01842                    xaxis->FindBin(rmax-binWidth/2));   // SetRange in binNumbers!
01843    fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
01844    fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
01845    fBinNumberEntry1->SetNumber(xaxis->GetLast() - xaxis->GetFirst() + 1);   
01846    fBinSlider1->SetPosition(5);
01847    fOffsetNumberEntry->SetNumber(offset);
01848    fOffsetNumberEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0,
01849                                  xaxis->GetBinWidth(1));
01850    fClient->NeedRedraw(fBinSlider1);
01851    Update();
01852 }
01853 
01854 //______________________________________________________________________________
01855 void TH1Editor::DoBinMoved1()
01856 {
01857    // Slot connected to the rebin slider in case of an ntuple histogram.
01858    // It updates the BinNumberEntryField during the BinSlider movement.
01859    
01860    if (fAvoidSignal) return;
01861    TAxis* xaxis = fHist->GetXaxis();
01862    Int_t first = xaxis->GetFirst();
01863    Int_t last = xaxis->GetLast();
01864    Int_t number = fBinSlider1->GetPosition();
01865    Int_t n = last -first+1;
01866    Int_t fact = 0;
01867    Int_t binNumber = 0;   
01868    if (number >= 5) fact = number - 4;
01869    else fact = number - 6;
01870    if (fact > 0) binNumber = fact*n;
01871    if (fact < 0) binNumber = (Int_t) ((-1)*n/fact+0.5);
01872    if (binNumber < 1) binNumber = 1;
01873    if (binNumber > 10000) binNumber= 10000;
01874    fBinNumberEntry1->SetIntNumber(binNumber);
01875 //   Update();
01876 }
01877 
01878 //______________________________________________________________________________
01879 void TH1Editor::DoBinLabel()
01880 {
01881    // Slot connected to the Bin number entry of the Rebinning tab.
01882    
01883    if (fAvoidSignal) return;
01884    Int_t num = (Int_t)(fBinNumberEntry->GetNumber());
01885    Int_t nx = 0;
01886    if (fBinHist) nx = fBinHist->GetXaxis()->GetNbins();
01887    else nx = fHist->GetXaxis()->GetNbins();
01888    if (nx < 2) return;
01889    Int_t *div = Dividers(nx);
01890    Int_t diff = TMath::Abs(num - div[1]);
01891    Int_t c = 1;
01892    for (Int_t i = 2; i <= div[0]; i++) {
01893       if ((TMath::Abs(num - div[i])) < diff) {
01894          c = i; 
01895          diff = TMath::Abs(num - div[i]);
01896       }
01897    }
01898    fBinNumberEntry->SetNumber(div[c]);
01899    fBinSlider->SetPosition(div[0] - c +1);
01900    if (fDelaydraw->GetState()==kButtonUp) DoBinMoved(div[0] - c +1);
01901    else DoBinReleased(); 
01902 //   fGedEditor->GetPad()->GetCanvas()->Selected(fGedEditor->GetPad(), fHist,  0);
01903    // fModel = fHist;
01904    Refresh(fHist);
01905    delete [] div;
01906 }
01907 
01908 //______________________________________________________________________________
01909 void TH1Editor::DoBinLabel1()
01910 {
01911    // Slot connected to the Bin number entry of the Rebinning tab.
01912    
01913    if (fAvoidSignal) return;
01914    Double_t oldOffset = fOffsetNumberEntry->GetNumber();
01915    Int_t num = (Int_t)fBinNumberEntry1->GetNumber();   
01916    TAxis* xaxis = fHist->GetXaxis();
01917    TTreePlayer *player = (TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer();
01918    if (!player) return;
01919    Int_t first = xaxis->GetFirst();
01920    Int_t last = xaxis->GetLast();
01921    Int_t nx = xaxis->GetNbins();
01922    Double_t min = xaxis->GetBinLowEdge(1);        // overall min in user coords
01923    Double_t max = xaxis->GetBinUpEdge(nx);        // overall max in user coords
01924    Double_t rmin = xaxis->GetBinLowEdge(first);   // recent min in user coords
01925    Double_t rmax = xaxis->GetBinUpEdge(last);     // recent max in user coords
01926    
01927    ((TH1*)player->GetHistogram())->ResetBit(TH1::kCanRebin);
01928    ((TH1*)player->GetHistogram())->Reset();
01929 
01930 // Calculate the new number of bins in the complete range
01931    Int_t binNumber = (Int_t) ((max-min)/(rmax - rmin)*num + 0.5);
01932    if (binNumber < 1) binNumber = 1;
01933    if (binNumber > 10000) binNumber = 10000;
01934    Double_t offset = 1.*(fBinOffsetSld->GetPosition())/100*(max-min)/binNumber;
01935 // create new histogram - the main job is done by sel->TakeAction()
01936    ((TH1*)player->GetHistogram())->SetBins(binNumber,
01937                                            min-oldOffset+offset,
01938                                            max-oldOffset+offset);
01939    TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
01940    if (!sel) return;
01941    sel->TakeAction();
01942 
01943 // Restore and set all the attributes which were changed by TakeAction() 
01944    fHist = (TH1*)((TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer())->GetHistogram();
01945    fSlider->SetRange(1,binNumber);
01946    Double_t binWidth = xaxis->GetBinWidth(1);
01947    fSlider->SetPosition(xaxis->FindBin(rmin), xaxis->FindBin(rmax));
01948    offset = 1.*fBinOffsetSld->GetPosition()/100*binWidth;
01949    xaxis->SetRange(xaxis->FindBin(rmin+binWidth/2), 
01950                    xaxis->FindBin(rmax-binWidth/2));   // SetRange in binNumbers!
01951    fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
01952    fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
01953    fOffsetNumberEntry->SetNumber(offset);
01954    fOffsetNumberEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, binWidth);
01955    Update();
01956 }
01957 
01958 //______________________________________________________________________________
01959 void TH1Editor::DoOffsetPressed()
01960 {
01961    // Slot connected to the OffSetSlider that saves the OldBinOffset 
01962    // (nessesary for delay draw mode).
01963    
01964    if (fAvoidSignal) return;
01965    fOldOffset = fOffsetNumberEntry->GetNumber();
01966 }
01967 
01968 //______________________________________________________________________________
01969 void TH1Editor::DoOffsetReleased()
01970 {
01971    // Slot connected to the OffSetSlider.
01972    // It changes the origin of the histogram inbetween a binwidth and
01973    // rebin the histogram with the new Offset given by the Slider.
01974 
01975    // !!problem: histogram with variable binwidth??
01976    // computes the new histogram in "delay draw" mode
01977    
01978    if (fAvoidSignal) return;
01979    if (fDelaydraw->GetState()==kButtonDown) {
01980       Int_t num = (Int_t) fBinOffsetSld->GetPosition();
01981       TAxis* xaxis = fHist->GetXaxis();
01982       Double_t binWidth = xaxis->GetBinWidth(1);
01983       Double_t offset =  1.*num/100*binWidth;
01984       Double_t oldOffset = fOldOffset;
01985       Int_t nx = xaxis->GetNbins();   
01986       TTreePlayer *player = (TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer();
01987       if (!player) return;
01988       Int_t first = xaxis->GetFirst();
01989       Int_t last = xaxis->GetLast();
01990       Double_t min = xaxis->GetBinLowEdge(1);          // overall min in user coords
01991       Double_t max = xaxis->GetBinUpEdge(nx);          // overall max in user coords
01992       Double_t rmin = xaxis->GetBinLowEdge(first);     // recent min in user coords
01993       Double_t rmax = xaxis->GetBinUpEdge(last);       // recent max in user coords
01994    
01995       ((TH1*)player->GetHistogram())->ResetBit(TH1::kCanRebin);
01996       ((TH1*)player->GetHistogram())->Reset();
01997  
01998       ((TH1*)player->GetHistogram())->SetBins(nx,
01999                                               min+offset-oldOffset,
02000                                               max+offset-oldOffset);
02001       TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
02002       if (!sel) return;
02003       sel->TakeAction();
02004  
02005       // Restore all the attributes which were changed by TakeAction() 
02006       fHist = (TH1*)((TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer())->GetHistogram();
02007       xaxis->SetRange(xaxis->FindBin(rmin+offset-oldOffset+binWidth/2), 
02008                       xaxis->FindBin(rmax+offset-oldOffset-binWidth/2)); // in binNumbers!
02009       fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
02010       fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
02011       fOffsetNumberEntry->SetNumber(offset);
02012       Update();
02013    } 
02014 }
02015 
02016 //______________________________________________________________________________
02017 void TH1Editor::DoOffsetMoved(Int_t num)
02018 {
02019    // Slot connected to the OffSetSlider.
02020    // It changes the origin of the histogram inbetween a binwidth and
02021    // rebin the histogram with the new offset given by the Slider.
02022 
02023    // !!histogram with variable binwidth??
02024    // !!only works for histograms with fixed binwidth
02025 
02026    if (fAvoidSignal) return;
02027    TAxis* xaxis = fHist->GetXaxis();   
02028    Double_t binWidth = xaxis->GetBinWidth(1);
02029    Double_t offset =  1.*num/100*binWidth;
02030    if (fDelaydraw->GetState()==kButtonUp) {
02031       Double_t oldOffset = fOffsetNumberEntry->GetNumber();
02032       Int_t nx = xaxis->GetNbins();   
02033       TTreePlayer *player = (TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer();
02034       if (!player) return;
02035       Int_t first = xaxis->GetFirst();
02036       Int_t last = xaxis->GetLast();
02037       Double_t min = xaxis->GetBinLowEdge(1);          // overall min in user coords
02038       Double_t max = xaxis->GetBinUpEdge(nx);          // overall max in user coords
02039       Double_t rmin = xaxis->GetBinLowEdge(first);     // recent min in user coords
02040       Double_t rmax = xaxis->GetBinUpEdge(last);       // recent max in user coords
02041    
02042       ((TH1*)player->GetHistogram())->ResetBit(TH1::kCanRebin);
02043       ((TH1*)player->GetHistogram())->Reset();
02044  
02045       ((TH1*)player->GetHistogram())->SetBins(nx,
02046                                               min+offset-oldOffset,
02047                                               max+offset-oldOffset);
02048       TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
02049       if (!sel) return;
02050       sel->TakeAction();
02051  
02052    // Restore all the attributes which were changed by TakeAction() 
02053       fHist = (TH1*)((TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer())->GetHistogram();
02054       xaxis->SetRange(xaxis->FindBin(rmin+offset-oldOffset+binWidth/2), 
02055                       xaxis->FindBin(rmax+offset-oldOffset-binWidth/2)); // in binNumbers!
02056       fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
02057       fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
02058       fClient->NeedRedraw(fBinOffsetSld,kTRUE);
02059    } 
02060    fOffsetNumberEntry->SetNumber(offset);
02061    fClient->NeedRedraw(fOffsetNumberEntry,kTRUE);
02062    Update();
02063 }
02064 
02065 //______________________________________________________________________________
02066 void TH1Editor::DoBinOffset()
02067 {
02068    // Slot connected to the OffSetNumberEntry which is related to the 
02069    // OffSetSlider changes the origin of the histogram inbetween a binwidth.
02070 
02071    if (fAvoidSignal) return;
02072    TAxis* xaxis = fHist->GetXaxis();   
02073    Double_t binWidth = xaxis->GetBinWidth(1);
02074    Double_t offset =  fOffsetNumberEntry->GetNumber();
02075    Double_t oldOffset = 1.*fBinOffsetSld->GetPosition()/100*binWidth;
02076    Int_t nx = xaxis->GetNbins();   
02077    TTreePlayer *player = (TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer();
02078    if (!player) return;
02079    Int_t first = xaxis->GetFirst();
02080    Int_t last = xaxis->GetLast();
02081    Double_t min = xaxis->GetBinLowEdge(1);          // overall min in user coords
02082    Double_t max = xaxis->GetBinUpEdge(nx);          // overall max in user coords
02083    Double_t rmin = xaxis->GetBinLowEdge(first);     // recent min in user coords
02084    Double_t rmax = xaxis->GetBinUpEdge(last);       // recent max in user coords
02085    
02086    ((TH1*)player->GetHistogram())->ResetBit(TH1::kCanRebin);
02087    ((TH1*)player->GetHistogram())->Reset();
02088 
02089    ((TH1*)player->GetHistogram())->SetBins(nx,
02090                                            min+offset-oldOffset,
02091                                            max+offset-oldOffset);
02092    TSelectorDraw *sel = (TSelectorDraw*)player->GetSelector();
02093    if (!sel) return;
02094    sel->TakeAction();
02095 
02096     // Restore all the attributes which were changed by TakeAction() 
02097    fHist = (TH1*)((TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer())->GetHistogram();
02098    xaxis->SetRange(xaxis->FindBin(rmin+offset-oldOffset+binWidth/2),
02099                    xaxis->FindBin(rmax+offset-oldOffset-binWidth/2)); // in binNumbers!
02100    fSldMin->SetNumber(xaxis->GetBinLowEdge(xaxis->GetFirst()));
02101    fSldMax->SetNumber(xaxis->GetBinUpEdge(xaxis->GetLast()));
02102    fBinOffsetSld->SetPosition((Int_t)(offset/binWidth*100));
02103    Update();
02104 }
02105 
02106 //______________________________________________________________________________
02107 void TH1Editor::DoApply()
02108 {
02109    // Slot connected to the Apply button of the Binning tab.
02110    
02111    Int_t ret = 0;
02112    new TGMsgBox(fClient->GetDefaultRoot(), this->GetMainFrame(), 
02113                 "TH1 Editor", "Replace origin histogram with rebinned one?", 
02114                 kMBIconQuestion, kMBYes | kMBNo, &ret, kVerticalFrame);
02115    if (ret==1) {
02116       if (fBinHist) {
02117          delete fBinHist;
02118          fBinHist = 0;
02119       }
02120       Int_t nx = fHist->GetXaxis()->GetNbins();
02121       Int_t *div = Dividers(nx);
02122       Int_t up = 0;
02123       if (div[0]-1 <= 1) up = 2;
02124       else up = div[0]-1; 
02125       fBinSlider->SetRange(1,up);
02126       if (fBinSlider->GetMaxPosition()==2 && div[0]==2 ) 
02127          fBinSlider->SetPosition(2);
02128       else 
02129          fBinSlider->SetPosition(1);
02130       fCancel->SetState(kButtonDisabled);
02131       fApply->SetState(kButtonDisabled);
02132       Update();
02133       delete [] div;
02134    } else if (ret==2) DoCancel();
02135 }
02136 
02137 //______________________________________________________________________________
02138 void TH1Editor::DoCancel()
02139 {
02140    // Slot connected to the Cancel button of the Binning tab.
02141    
02142    if (fBinHist) {
02143       fGedEditor->GetPad()->cd();
02144       fHist->Reset();
02145       fHist->SetBins(fBinHist->GetXaxis()->GetNbins(),
02146                      fBinHist->GetXaxis()->GetXmin(),
02147                      fBinHist->GetXaxis()->GetXmax());
02148       fHist->Add(fBinHist);
02149       fHist->GetXaxis()->SetRange(fBinHist->GetXaxis()->GetFirst(),
02150                                   fBinHist->GetXaxis()->GetLast());
02151       delete fBinHist;
02152       fBinHist = 0;
02153       fCancel->SetState(kButtonDisabled);
02154       fApply->SetState(kButtonDisabled);
02155       Int_t* divx = Dividers(fHist->GetXaxis()->GetNbins());
02156       if (divx[0]!=2) fBinSlider->SetPosition(1);
02157       // Consigning the new Histogram to all other Editors
02158 //      fGedEditor->GetPad()->GetCanvas()->Selected(fGedEditor->GetPad(), fHist,  0);
02159       Update();    
02160       //fModel = fHist;
02161       Refresh(fHist);
02162       delete [] divx;
02163    }
02164 }
02165 
02166 //______________________________________________________________________________
02167 TString TH1Editor::GetHistTypeLabel()
02168 {
02169    // Returns the selected histogram type (HIST, LEGO1-2, SURF1-5).
02170 
02171    TString s="";
02172    switch (fTypeCombo->GetSelected()){
02173       case (-1)         : {s = "LEGO"; break;}
02174       case (kTYPE_LEGO ): {s = "LEGO"; break;}
02175       case (kTYPE_LEGO1): {s = "LEGO1"; break;}
02176       case (kTYPE_LEGO2): {s = "LEGO2"; break;}
02177       case (kTYPE_SURF ): {s = "SURF"; break;}
02178       case (kTYPE_SURF1): {s = "SURF1"; break;}
02179       case (kTYPE_SURF2): {s = "SURF2"; break;}
02180       case (kTYPE_SURF3): {s = "SURF3"; break;}
02181       case (kTYPE_SURF4): {s = "SURF4"; break;}
02182       case (kTYPE_SURF5): {s = "SURF5"; break;}
02183       default:  break;
02184    }
02185 
02186    return s;
02187 }
02188 
02189 //______________________________________________________________________________
02190 TString TH1Editor::GetHistCoordsLabel()
02191 {
02192    // Return the selected coordinate system of the histogram (POL,CYL,SPH,PSR).
02193 
02194    TString s="";
02195    if (fDim->GetState()!=kButtonDown) {
02196       switch (fCoordsCombo->GetSelected()){
02197          case (-1)         : {s = "POL"; break;}
02198          case (kCOORDS_CAR): {s = ""; break;}
02199          case (kCOORDS_POL): {s = "POL"; break;}
02200          case (kCOORDS_CYL): {s = "CYL"; break;}
02201          case (kCOORDS_SPH): {s = "SPH"; break;}
02202          case (kCOORDS_PSR): {s = "PSR"; break;}
02203          default:  break;
02204       }
02205    }
02206 
02207    return s;
02208 }
02209 
02210 //______________________________________________________________________________
02211 TString TH1Editor::GetHistErrorLabel()
02212 {
02213    // Return the selected error type (E,E1-5).
02214    
02215    TString s="";
02216    switch (fErrorCombo->GetSelected()){
02217       case (-1)             : {s = ""; break;}
02218       case (kERRORS_NO)     : {s = ""; break;}
02219       case (kERRORS_SIMPLE) : {s = "E"; break;}
02220       case (kERRORS_EDGES)  : {s = "E1"; break;}
02221       case (kERRORS_REC)    : {s = "E2"; break;}
02222       case (kERRORS_FILL)   : {s = "E3"; break;}
02223       case (kERRORS_CONTOUR): {s = "E4"; break;}
02224       default:  break;
02225    }
02226 
02227    return s;
02228 }
02229 
02230 //______________________________________________________________________________
02231 TString TH1Editor::GetHistAddLabel()
02232 {
02233    // Return the selected shape of the histogram (C, L, LF2).
02234    
02235    TString s="";
02236    switch (fAddCombo->GetSelected()){
02237       case (-1)         : {s = "" ; break;}
02238       case (kADD_NONE)  : {s = "" ; break;}
02239       case (kADD_SMOOTH): {s = "C"; break;}
02240       case (kADD_SIMPLE): {s = "L"; break;}
02241       case (kADD_FILL)  : {s = "LF2"; break;}
02242       default           :  break;
02243    }
02244    if (fAddMarker->GetState()==kButtonDown) s += "P";
02245    if (fAddB->GetState()==kButtonDown) s += "B";
02246    if (fAddBar->GetState()==kButtonDown){
02247       if (fMakeHBar->GetState()==kButtonDown) s+="H";
02248       switch (fPercentCombo->GetSelected()){
02249          case (kPER_0) : { s += "BAR" ; break;}
02250          case (kPER_10): { s += "BAR1"; break;}
02251          case (kPER_20): { s += "BAR2"; break;}            
02252          case (kPER_30): { s += "BAR3"; break;} 
02253          case (kPER_40): { s += "BAR4"; break;}                  
02254       }
02255    }    
02256 
02257    return s;
02258 }
02259 
02260 //______________________________________________________________________________
02261 TGComboBox* TH1Editor::BuildHistTypeComboBox(TGFrame* parent, Int_t id)
02262 {
02263    // Create histogram type combo box.
02264 
02265    TGComboBox *c = new TGComboBox(parent, id);
02266 
02267    c->AddEntry("Lego" , kTYPE_LEGO);
02268    c->AddEntry("Lego1", kTYPE_LEGO1);
02269    c->AddEntry("Lego2", kTYPE_LEGO2);
02270    c->AddEntry("Surf" , kTYPE_SURF);
02271    c->AddEntry("Surf1", kTYPE_SURF1);
02272    c->AddEntry("Surf2", kTYPE_SURF2);
02273    c->AddEntry("Surf3", kTYPE_SURF3);   
02274    c->AddEntry("Surf4", kTYPE_SURF4);   
02275    c->AddEntry("Surf5", kTYPE_SURF5); 
02276    
02277    return c;
02278 }
02279 
02280 //______________________________________________________________________________
02281 TGComboBox* TH1Editor::BuildHistCoordsComboBox(TGFrame* parent, Int_t id)
02282 {
02283    // Create coordinate system type combo box.
02284 
02285    TGComboBox *c = new TGComboBox(parent, id);
02286 
02287    c->AddEntry("Cartesian", kCOORDS_CAR);
02288    c->AddEntry("Cylindric", kCOORDS_CYL);
02289    c->AddEntry("Polar", kCOORDS_POL);
02290    c->AddEntry("Rapidity", kCOORDS_PSR);   
02291    c->AddEntry("Spheric", kCOORDS_SPH);   
02292    TGListBox* lb = c->GetListBox();
02293    lb->Resize(lb->GetWidth(), 83);
02294  
02295    return c;
02296 }
02297 
02298 //______________________________________________________________________________
02299 TGComboBox* TH1Editor::BuildHistErrorComboBox(TGFrame* parent, Int_t id)
02300 {
02301    // Create error type combo box.
02302 
02303    TGComboBox *c = new TGComboBox(parent, id);
02304 
02305    c->AddEntry("No Errors", kERRORS_NO);
02306    c->AddEntry("Simple", kERRORS_SIMPLE);
02307    c->AddEntry("Edges", kERRORS_EDGES);
02308    c->AddEntry("Rectangles",kERRORS_REC);
02309    c->AddEntry("Fill", kERRORS_FILL);   
02310    c->AddEntry("Contour", kERRORS_CONTOUR);   
02311  
02312    return c;
02313 }
02314 
02315 //______________________________________________________________________________
02316 TGComboBox* TH1Editor::BuildHistAddComboBox(TGFrame* parent, Int_t id)
02317 {
02318    // Create Line/Bar combo box.
02319 
02320    TGComboBox *c = new TGComboBox(parent, id);
02321 
02322    c->AddEntry("No Line", kADD_NONE);
02323    c->AddEntry("Simple Line", kADD_SIMPLE);
02324    c->AddEntry("Smooth Line", kADD_SMOOTH);
02325    c->AddEntry("Fill Area",kADD_FILL);
02326    TGListBox* lb = c->GetListBox();
02327    lb->Resize(lb->GetWidth(), 76);
02328    return c;
02329 }
02330 
02331 //______________________________________________________________________________
02332 TGComboBox* TH1Editor::BuildPercentComboBox(TGFrame* parent, Int_t id)
02333 {
02334    // Create Percentage combo box for bar option.
02335    
02336    TGComboBox *c = new TGComboBox(parent, id);
02337    
02338    c->AddEntry(" 0 %", kPER_0);   
02339    c->AddEntry("10 %", kPER_10);   
02340    c->AddEntry("20 %", kPER_20);
02341    c->AddEntry("30 %", kPER_30);
02342    c->AddEntry("40 %", kPER_40);   
02343    TGListBox* lb = c->GetListBox();
02344    lb->Resize(lb->GetWidth(), 83);   
02345    
02346    return c;
02347 }
02348 
02349 //______________________________________________________________________________
02350 void TH1Editor::ChangeErrorCombo(Int_t i)
02351 {
02352    // Change the error combo box entry.
02353    
02354    switch (i){
02355       case 0: {
02356          if (((TGLBContainer*)((TGListBox*)fErrorCombo->GetListBox())->GetContainer())->GetPos(kERRORS_EDGES)!=-1)
02357             fErrorCombo->RemoveEntries(kERRORS_EDGES,kERRORS_CONTOUR);
02358          if (!((fErrorCombo->GetSelected()== kERRORS_NO) || (fErrorCombo->GetSelected()== kERRORS_SIMPLE))) 
02359             fErrorCombo->Select(kERRORS_NO);
02360          TGListBox* lb = fErrorCombo->GetListBox();
02361          lb->Resize(lb->GetWidth(),36);  
02362          break;
02363       }
02364       case 1: {   
02365          if (((TGLBContainer*)((TGListBox*)fErrorCombo->GetListBox())->GetContainer())->GetPos(kERRORS_EDGES)==-1) {
02366             fErrorCombo->AddEntry("Edges", kERRORS_EDGES);
02367             fErrorCombo->AddEntry("Rectangles",kERRORS_REC);
02368             fErrorCombo->AddEntry("Fill", kERRORS_FILL);   
02369             fErrorCombo->AddEntry("Contour", kERRORS_CONTOUR);
02370             TGListBox* lb = fErrorCombo->GetListBox();
02371             lb->Resize(lb->GetWidth(),100);      
02372          }
02373          break;
02374       }
02375    }
02376 }
02377 
02378  //______________________________________________________________________________
02379 void TH1Editor::PaintBox3D(Float_t *p1, Float_t *p2,Float_t *p3, Float_t *p4) 
02380 {
02381    // Paint a 3D box.
02382    
02383    fGedEditor->GetPad()->GetCanvas()->FeedbackMode(kTRUE); 
02384    fGedEditor->GetPad()->SetLineWidth(1);
02385    fGedEditor->GetPad()->SetLineColor(2);
02386    fGedEditor->GetPad()->cd();
02387    fGedEditor->GetPad()->PaintLine3D(p1, p2);
02388    fGedEditor->GetPad()->PaintLine3D(p2, p3);
02389    fGedEditor->GetPad()->PaintLine3D(p3, p4);
02390    fGedEditor->GetPad()->PaintLine3D(p4, p1);
02391 }
02392 
02393 //______________________________________________________________________________
02394 Int_t* TH1Editor::Dividers(Int_t n)
02395 {
02396    // Return an array of dividers of n (without the trivial divider n).
02397    // The number of dividers is saved in the first entry.
02398    
02399    Int_t* div;
02400    if (n <= 0) {
02401       div = new Int_t[1];
02402       div[0]=0;
02403    } else if (n == 1) {
02404       div = new Int_t[2];
02405       div[0]=div[1]=1;
02406    } else {
02407       div = new Int_t[(Int_t) n/2+2];
02408       div[0]=0; 
02409       div[1]=1;
02410 
02411       Int_t num = 1;
02412       for (Int_t i=2; i <= n/2; i++) {
02413          if (n % i == 0) {
02414             num++;
02415             div[num] = i;
02416          }
02417       }
02418       num++;
02419       div[num]=n;
02420       div[0] = num;
02421 //   for (Int_t a=0; a <= div[0]; a++) printf("div[%d] = %d\n", a , div[a]);
02422    }
02423    return div;
02424 }   
02425    

Generated on Tue Jul 5 14:19:47 2011 for ROOT_528-00b_version by  doxygen 1.5.1