// @(#)root/hist:$Id$
// Author: Rene Brun   12/12/94

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

#ifndef ROOT_TAxis
#define ROOT_TAxis


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TAxis                                                                //
//                                                                      //
// Axis class.                                                          //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TNamed
#include "TNamed.h"
#endif
#ifndef ROOT_TAttAxis
#include "TAttAxis.h"
#endif
#ifndef ROOT_TArrayD
#include "TArrayD.h"
#endif

class THashList;

class TAxis : public TNamed, public TAttAxis {

private:
   Int_t        fNbins;          //Number of bins
   Double_t     fXmin;           //low edge of first bin
   Double_t     fXmax;           //upper edge of last bin
   TArrayD      fXbins;          //Bin edges array in X
   Int_t        fFirst;          //first bin to display
   Int_t        fLast;           //last bin to display
   UShort_t     fBits2;          //second bit status word
   Bool_t       fTimeDisplay;    //on/off displaying time values instead of numerics
   TString      fTimeFormat;     //Date&time format, ex: 09/12/99 12:34:00
   TObject     *fParent;         //!Object owning this axis
   THashList   *fLabels;         //List of labels

   // TAxis extra status bits (stored in fBits2)
   enum {
      kAlphanumeric = BIT(0),   // axis is alphanumeric
      kCanExtend = BIT(1),      // axis can be extended
      kNotAlpha = BIT(2)    // axis is forced to be not alphanumeric
   };

   Bool_t       HasBinWithoutLabel() const;
   Bool_t       IsAlphanumeric() { return fBits2 & kAlphanumeric; }
   Bool_t       CanBeAlphanumeric() { return !(fBits2 & kNotAlpha); }
   void         SetAlphanumeric(Bool_t alphanumeric = kTRUE);

public:
   // TAxis status bits
   enum {
          kDecimals      = BIT(7),
          kTickPlus      = BIT(9),
          kTickMinus     = BIT(10),
          kAxisRange     = BIT(11),
          kCenterTitle   = BIT(12),
          kCenterLabels  = BIT(14), //bit 13 is used by TObject
          kRotateTitle   = BIT(15),
          kPalette       = BIT(16),
          kNoExponent    = BIT(17),
          kLabelsHori    = BIT(18),
          kLabelsVert    = BIT(19),
          kLabelsDown    = BIT(20),
          kLabelsUp      = BIT(21),
          kIsInteger     = BIT(22),
          kMoreLogLabels = BIT(23)
   };

   TAxis();
   TAxis(Int_t nbins, Double_t xmin, Double_t xmax);
   TAxis(Int_t nbins, const Double_t *xbins);
   TAxis(const TAxis &axis);
   virtual ~TAxis();
   TAxis& operator=(const TAxis&);

   Bool_t     CanExtend() const { return (fBits2 & kCanExtend);  } 
   void       SetCanExtend(Bool_t canExtend) { fBits2 = canExtend ? (fBits2 | kCanExtend) : (fBits2 & ~kCanExtend); }
   void       SetNoAlphanumeric(Bool_t noalpha = kTRUE) {
      fBits2 = noalpha ? (fBits2 | kNotAlpha) : (fBits2 & ~kNotAlpha);
      if (IsAlphanumeric() ) {
         SetCanExtend(kFALSE);
         SetAlphanumeric(kFALSE);
      }
   }
   void       CenterLabels(Bool_t center=kTRUE);  // *TOGGLE* *GETTER=GetCenterLabels
   void       CenterTitle(Bool_t center=kTRUE);  // *TOGGLE* *GETTER=GetCenterTitle
   const char        *ChooseTimeFormat(Double_t axislength=0);
   virtual void       Copy(TObject &axis) const;
   virtual void       Delete(Option_t * /*option*/ ="") { }
   virtual Int_t      DistancetoPrimitive(Int_t px, Int_t py);
   virtual TObject   *DrawClone(Option_t * /*option*/ ="") const {return 0;}
   virtual void       ExecuteEvent(Int_t event, Int_t px, Int_t py);
   virtual Int_t      FindBin(Double_t x);
   virtual Int_t      FindBin(Double_t x) const { return FindFixBin(x); }
   virtual Int_t      FindBin(const char *label);
   virtual Int_t      FindFixBin(Double_t x) const;
   virtual Int_t      FindFixBin(const char *label) const;
   virtual Double_t   GetBinCenter(Int_t bin) const;
   virtual Double_t   GetBinCenterLog(Int_t bin) const;
   const char        *GetBinLabel(Int_t bin) const;
   virtual Double_t   GetBinLowEdge(Int_t bin) const;
   virtual Double_t   GetBinUpEdge(Int_t bin) const;
   virtual Double_t   GetBinWidth(Int_t bin) const;
   virtual void       GetCenter(Double_t *center) const;
           Bool_t     GetCenterLabels() const { return TestBit(kCenterLabels); }
           Bool_t     GetCenterTitle() const { return TestBit(kCenterTitle); }
           Bool_t     GetDecimals() const { return TestBit(kDecimals); }
   THashList         *GetLabels() const { return fLabels; }
   virtual void       GetLowEdge(Double_t *edge) const;
           Bool_t     GetMoreLogLabels() const { return TestBit(kMoreLogLabels); }
           Int_t      GetNbins() const { return fNbins; }
           Bool_t     GetNoExponent() const { return TestBit(kNoExponent); }
   virtual TObject   *GetParent() const {return fParent;}
           Bool_t     GetRotateTitle() const { return TestBit(kRotateTitle); }
   virtual const char *GetTicks() const;
   virtual Bool_t     GetTimeDisplay() const {return fTimeDisplay;}
   virtual const char *GetTimeFormat() const {return fTimeFormat.Data();}
   virtual const char *GetTimeFormatOnly() const;
   const char        *GetTitle() const {return fTitle.Data();}
   const TArrayD     *GetXbins() const {return &fXbins;}
           Int_t      GetFirst() const;
           Int_t      GetLast() const;
           Double_t   GetXmin() const {return fXmin;}
           Double_t   GetXmax() const {return fXmax;}
   virtual void       ImportAttributes(const TAxis *axis);
   Bool_t             IsVariableBinSize() const {
                         // true if axis has variable bin sizes, false otherwise
                         return (fXbins.GetSize() != 0);
                      }
   virtual void       LabelsOption(Option_t *option="h");  // *MENU*
           void       RotateTitle(Bool_t rotate=kTRUE); // *TOGGLE* *GETTER=GetRotateTitle
   virtual void       SaveAttributes(std::ostream &out, const char *name, const char *subname);
   virtual void       Set(Int_t nbins, Double_t xmin, Double_t xmax);
   virtual void       Set(Int_t nbins, const Float_t *xbins);
   virtual void       Set(Int_t nbins, const Double_t *xbins);
   virtual void       SetBinLabel(Int_t bin, const char *label);
           void       SetDecimals(Bool_t dot = kTRUE); // *TOGGLE* *GETTER=GetDecimals
   virtual void       SetDefaults();
   virtual void       SetDrawOption(Option_t * /*option*/ ="") { }
   virtual void       SetLimits(Double_t xmin, Double_t xmax) { /* set axis limits */ fXmin = xmin; fXmax = xmax; }
           void       SetMoreLogLabels(Bool_t more=kTRUE);  // *TOGGLE* *GETTER=GetMoreLogLabels
           void       SetNoExponent(Bool_t noExponent=kTRUE);  // *TOGGLE* *GETTER=GetNoExponent
   virtual void       SetParent(TObject *obj) {fParent = obj;}
   virtual void       SetRange(Int_t first=0, Int_t last=0);  // *MENU*
   virtual void       SetRangeUser(Double_t ufirst, Double_t ulast);  // *MENU*
   virtual void       SetTicks(Option_t *option="+"); // *MENU*
   virtual void       SetTimeDisplay(Int_t value) {fTimeDisplay = (value != 0);} // *TOGGLE*
   virtual void       SetTimeFormat(const char *format="");  // *MENU*
   virtual void       SetTimeOffset(Double_t toffset, Option_t *option="local");
   virtual void       UnZoom();  // *MENU*
   virtual void       ZoomOut(Double_t factor=0, Double_t offset=0);  // *MENU*

   ClassDef(TAxis,9)  //Axis class
};

//______________________________________________________________________________
inline void TAxis::CenterLabels(Bool_t center)
{
   //   if center = kTRUE axis labels will be centered (hori axes only) on the bin center
   //   default is to center on the primary tick marks
   //   This option does not make sense if there are more bins than tick marks
   SetBit(kCenterLabels, center);
}

//______________________________________________________________________________
inline void TAxis::CenterTitle(Bool_t center)
{
   //   if center = kTRUE axis title will be centered
   //   default is right adjusted
   SetBit(kCenterTitle, center);
}

//___________________________________________________________________________
inline void TAxis::RotateTitle(Bool_t rotate)
{
   // rotate title by 180 degrees
   // by default the title is drawn right adjusted.
   // if rotate is TRUE, the title is left adjusted at the end of the axis and rotated by 180 degrees
   SetBit(kRotateTitle, rotate);
}

//______________________________________________________________________________
inline void TAxis::SetDecimals(Bool_t dot) {
   // sets the decimals flag
   // by default, blank characters are stripped, and then the label is correctly aligned.
   // If the dot is the last character of the string, it is also stripped, unless this option is specified.
   SetBit(kDecimals, dot);
}

//______________________________________________________________________________
inline void TAxis::SetMoreLogLabels(Bool_t more)
{
   // Set the kMoreLogLabels bit flag
   // When this option is selected more labels are drawn when in log scale and there is a small number of decades  (<3).
   // The flag (in fBits) is passed to the drawing function TGaxis::PaintAxis
   SetBit(kMoreLogLabels, more);
}

//______________________________________________________________________________
inline void TAxis::SetNoExponent(Bool_t noExponent)
{
   // Set the NoExponent flag
   // By default, an exponent of the form 10^N is used when the label value are either all very small or very large.
   // The flag (in fBits) is passed to the drawing function TGaxis::PaintAxis
   SetBit(kNoExponent, noExponent);
}


#endif

 TAxis.h:1
 TAxis.h:2
 TAxis.h:3
 TAxis.h:4
 TAxis.h:5
 TAxis.h:6
 TAxis.h:7
 TAxis.h:8
 TAxis.h:9
 TAxis.h:10
 TAxis.h:11
 TAxis.h:12
 TAxis.h:13
 TAxis.h:14
 TAxis.h:15
 TAxis.h:16
 TAxis.h:17
 TAxis.h:18
 TAxis.h:19
 TAxis.h:20
 TAxis.h:21
 TAxis.h:22
 TAxis.h:23
 TAxis.h:24
 TAxis.h:25
 TAxis.h:26
 TAxis.h:27
 TAxis.h:28
 TAxis.h:29
 TAxis.h:30
 TAxis.h:31
 TAxis.h:32
 TAxis.h:33
 TAxis.h:34
 TAxis.h:35
 TAxis.h:36
 TAxis.h:37
 TAxis.h:38
 TAxis.h:39
 TAxis.h:40
 TAxis.h:41
 TAxis.h:42
 TAxis.h:43
 TAxis.h:44
 TAxis.h:45
 TAxis.h:46
 TAxis.h:47
 TAxis.h:48
 TAxis.h:49
 TAxis.h:50
 TAxis.h:51
 TAxis.h:52
 TAxis.h:53
 TAxis.h:54
 TAxis.h:55
 TAxis.h:56
 TAxis.h:57
 TAxis.h:58
 TAxis.h:59
 TAxis.h:60
 TAxis.h:61
 TAxis.h:62
 TAxis.h:63
 TAxis.h:64
 TAxis.h:65
 TAxis.h:66
 TAxis.h:67
 TAxis.h:68
 TAxis.h:69
 TAxis.h:70
 TAxis.h:71
 TAxis.h:72
 TAxis.h:73
 TAxis.h:74
 TAxis.h:75
 TAxis.h:76
 TAxis.h:77
 TAxis.h:78
 TAxis.h:79
 TAxis.h:80
 TAxis.h:81
 TAxis.h:82
 TAxis.h:83
 TAxis.h:84
 TAxis.h:85
 TAxis.h:86
 TAxis.h:87
 TAxis.h:88
 TAxis.h:89
 TAxis.h:90
 TAxis.h:91
 TAxis.h:92
 TAxis.h:93
 TAxis.h:94
 TAxis.h:95
 TAxis.h:96
 TAxis.h:97
 TAxis.h:98
 TAxis.h:99
 TAxis.h:100
 TAxis.h:101
 TAxis.h:102
 TAxis.h:103
 TAxis.h:104
 TAxis.h:105
 TAxis.h:106
 TAxis.h:107
 TAxis.h:108
 TAxis.h:109
 TAxis.h:110
 TAxis.h:111
 TAxis.h:112
 TAxis.h:113
 TAxis.h:114
 TAxis.h:115
 TAxis.h:116
 TAxis.h:117
 TAxis.h:118
 TAxis.h:119
 TAxis.h:120
 TAxis.h:121
 TAxis.h:122
 TAxis.h:123
 TAxis.h:124
 TAxis.h:125
 TAxis.h:126
 TAxis.h:127
 TAxis.h:128
 TAxis.h:129
 TAxis.h:130
 TAxis.h:131
 TAxis.h:132
 TAxis.h:133
 TAxis.h:134
 TAxis.h:135
 TAxis.h:136
 TAxis.h:137
 TAxis.h:138
 TAxis.h:139
 TAxis.h:140
 TAxis.h:141
 TAxis.h:142
 TAxis.h:143
 TAxis.h:144
 TAxis.h:145
 TAxis.h:146
 TAxis.h:147
 TAxis.h:148
 TAxis.h:149
 TAxis.h:150
 TAxis.h:151
 TAxis.h:152
 TAxis.h:153
 TAxis.h:154
 TAxis.h:155
 TAxis.h:156
 TAxis.h:157
 TAxis.h:158
 TAxis.h:159
 TAxis.h:160
 TAxis.h:161
 TAxis.h:162
 TAxis.h:163
 TAxis.h:164
 TAxis.h:165
 TAxis.h:166
 TAxis.h:167
 TAxis.h:168
 TAxis.h:169
 TAxis.h:170
 TAxis.h:171
 TAxis.h:172
 TAxis.h:173
 TAxis.h:174
 TAxis.h:175
 TAxis.h:176
 TAxis.h:177
 TAxis.h:178
 TAxis.h:179
 TAxis.h:180
 TAxis.h:181
 TAxis.h:182
 TAxis.h:183
 TAxis.h:184
 TAxis.h:185
 TAxis.h:186
 TAxis.h:187
 TAxis.h:188
 TAxis.h:189
 TAxis.h:190
 TAxis.h:191
 TAxis.h:192
 TAxis.h:193
 TAxis.h:194
 TAxis.h:195
 TAxis.h:196
 TAxis.h:197
 TAxis.h:198
 TAxis.h:199
 TAxis.h:200
 TAxis.h:201
 TAxis.h:202
 TAxis.h:203
 TAxis.h:204
 TAxis.h:205
 TAxis.h:206
 TAxis.h:207
 TAxis.h:208
 TAxis.h:209
 TAxis.h:210
 TAxis.h:211
 TAxis.h:212
 TAxis.h:213
 TAxis.h:214
 TAxis.h:215
 TAxis.h:216
 TAxis.h:217
 TAxis.h:218
 TAxis.h:219
 TAxis.h:220
 TAxis.h:221
 TAxis.h:222
 TAxis.h:223
 TAxis.h:224