File indexing completed on 2025-01-18 10:11:31
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TAxis
0013 #define ROOT_TAxis
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "TNamed.h"
0025 #include "TAttAxis.h"
0026 #include "TArrayD.h"
0027
0028 class THashList;
0029 class TAxisModLab;
0030
0031 class TAxis : public TNamed, public TAttAxis {
0032
0033 private:
0034 Int_t fNbins;
0035 Double_t fXmin;
0036 Double_t fXmax;
0037 TArrayD fXbins;
0038 Int_t fFirst;
0039 Int_t fLast;
0040 UShort_t fBits2;
0041 Bool_t fTimeDisplay;
0042 TString fTimeFormat;
0043 TObject *fParent;
0044 THashList *fLabels;
0045 TList *fModLabs;
0046
0047
0048 enum {
0049 kAlphanumeric = BIT(0),
0050 kCanExtend = BIT(1),
0051 kNotAlpha = BIT(2)
0052 };
0053
0054 Bool_t HasBinWithoutLabel() const;
0055
0056
0057 TAxisModLab *FindModLab(Int_t num, Double_t v = 0., Double_t eps = 0.) const;
0058
0059 public:
0060
0061 enum EStatusBits {
0062 kDecimals = BIT(7),
0063 kTickPlus = BIT(9),
0064 kTickMinus = BIT(10),
0065 kAxisRange = BIT(11),
0066 kCenterTitle = BIT(12),
0067 kCenterLabels = BIT(14),
0068 kRotateTitle = BIT(15),
0069 kPalette = BIT(16),
0070 kNoExponent = BIT(17),
0071 kLabelsHori = BIT(18),
0072 kLabelsVert = BIT(19),
0073 kLabelsDown = BIT(20),
0074 kLabelsUp = BIT(21),
0075 kIsInteger = BIT(22),
0076 kMoreLogLabels = BIT(23)
0077 };
0078
0079 TAxis();
0080 TAxis(Int_t nbins, Double_t xmin, Double_t xmax);
0081 TAxis(Int_t nbins, const Double_t *xbins);
0082 TAxis(const TAxis &axis);
0083 ~TAxis() override;
0084 TAxis& operator=(const TAxis&);
0085
0086 Bool_t CanExtend() const { return (fBits2 & kCanExtend); }
0087 Bool_t CanBeAlphanumeric() { return !(fBits2 & kNotAlpha); }
0088 Bool_t IsAlphanumeric() const { return fBits2 & kAlphanumeric; }
0089 void SetAlphanumeric(Bool_t alphanumeric = kTRUE);
0090 void SetCanExtend(Bool_t canExtend) { fBits2 = canExtend ? (fBits2 | kCanExtend) : (fBits2 & ~kCanExtend); }
0091 void SetNoAlphanumeric(Bool_t noalpha = kTRUE) {
0092 fBits2 = noalpha ? (fBits2 | kNotAlpha) : (fBits2 & ~kNotAlpha);
0093 if (IsAlphanumeric() ) {
0094 SetCanExtend(kFALSE);
0095 SetAlphanumeric(kFALSE);
0096 }
0097 }
0098 void CenterLabels(Bool_t center=kTRUE);
0099 void CenterTitle(Bool_t center=kTRUE);
0100 const char *ChooseTimeFormat(Double_t axislength=0);
0101 void Copy(TObject &axis) const override;
0102 void Delete(Option_t * ="") override { }
0103 Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
0104 TObject *DrawClone(Option_t * ="") const override {return nullptr;}
0105 void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
0106 virtual Int_t FindBin(Double_t x);
0107 virtual Int_t FindBin(Double_t x) const { return FindFixBin(x); }
0108 virtual Int_t FindBin(const char *label);
0109 virtual Int_t FindFixBin(Double_t x) const;
0110 virtual Int_t FindFixBin(const char *label) const;
0111 virtual Double_t GetBinCenter(Int_t bin) const;
0112 virtual Double_t GetBinCenterLog(Int_t bin) const;
0113 const char *GetBinLabel(Int_t bin) const;
0114 virtual Double_t GetBinLowEdge(Int_t bin) const;
0115 virtual Double_t GetBinUpEdge(Int_t bin) const;
0116 virtual Double_t GetBinWidth(Int_t bin) const;
0117 virtual void GetCenter(Double_t *center) const;
0118 Bool_t GetCenterLabels() const { return TestBit(kCenterLabels); }
0119 Bool_t GetCenterTitle() const { return TestBit(kCenterTitle); }
0120 Bool_t GetDecimals() const { return TestBit(kDecimals); }
0121 THashList *GetLabels() const { return fLabels; }
0122 TList *GetModifiedLabels() const { return fModLabs; }
0123 virtual void GetLowEdge(Double_t *edge) const;
0124 Bool_t GetMoreLogLabels() const { return TestBit(kMoreLogLabels); }
0125 Int_t GetNbins() const { return fNbins; }
0126 Int_t GetNlabels() const;
0127 Bool_t GetNoExponent() const { return TestBit(kNoExponent); }
0128 virtual TObject *GetParent() const {return fParent;}
0129 Bool_t GetRotateTitle() const { return TestBit(kRotateTitle); }
0130 virtual const char *GetTicks() const;
0131 virtual Bool_t GetTimeDisplay() const {return fTimeDisplay;}
0132 virtual const char *GetTimeFormat() const {return fTimeFormat.Data();}
0133 virtual const char *GetTimeFormatOnly() const;
0134 UInt_t GetTimeOffset();
0135 const char *GetTitle() const override {return fTitle.Data();}
0136 const TArrayD *GetXbins() const {return &fXbins;}
0137 Int_t GetFirst() const;
0138 Int_t GetLast() const;
0139 Double_t GetXmin() const {return fXmin;}
0140 Double_t GetXmax() const {return fXmax;}
0141 virtual void ImportAttributes(const TAxis *axis);
0142 Bool_t IsVariableBinSize() const {
0143
0144 return (fXbins.GetSize() != 0);
0145 }
0146 virtual void LabelsOption(Option_t *option="h");
0147 void RotateTitle(Bool_t rotate=kTRUE);
0148 void SaveAttributes(std::ostream &out, const char *name, const char *subname) override;
0149 virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax);
0150 virtual void Set(Int_t nbins, const Float_t *xbins);
0151 virtual void Set(Int_t nbins, const Double_t *xbins);
0152 virtual void SetBinLabel(Int_t bin, const char *label);
0153 void SetDecimals(Bool_t dot = kTRUE);
0154 virtual void SetDefaults();
0155 void SetDrawOption(Option_t * ="") override { }
0156 void ChangeLabel(Int_t labNum=0, Double_t labAngle = -1.,
0157 Double_t labSize = -1., Int_t labAlign = -1,
0158 Int_t labColor = -1 , Int_t labFont = -1,
0159 const TString &labText = "");
0160 void ChangeLabelByValue(Double_t labValue, Double_t labAngle = -1.,
0161 Double_t labSize = -1., Int_t labAlign = -1,
0162 Int_t labColor = -1 , Int_t labFont = -1,
0163 const TString &labText = "");
0164 virtual void SetLimits(Double_t xmin, Double_t xmax) { fXmin = xmin; fXmax = xmax; }
0165 void SetMoreLogLabels(Bool_t more=kTRUE);
0166 void SetNoExponent(Bool_t noExponent=kTRUE);
0167 virtual void SetParent(TObject *obj) {fParent = obj;}
0168 virtual void SetRange(Int_t first=0, Int_t last=0);
0169 virtual void SetRangeUser(Double_t ufirst, Double_t ulast);
0170 virtual void SetTicks(Option_t *option="+");
0171 virtual void SetTimeDisplay(Int_t value) {fTimeDisplay = (value != 0);}
0172 virtual void SetTimeFormat(const char *format="");
0173 virtual void SetTimeOffset(Double_t toffset, Option_t *option="local");
0174 virtual void UnZoom();
0175 virtual void ZoomOut(Double_t factor=0, Double_t offset=0);
0176
0177 ClassDefOverride(TAxis,10)
0178 };
0179
0180
0181
0182
0183
0184
0185 inline void TAxis::CenterLabels(Bool_t center)
0186 {
0187 SetBit(kCenterLabels, center);
0188 }
0189
0190
0191
0192
0193
0194 inline void TAxis::CenterTitle(Bool_t center)
0195 {
0196 SetBit(kCenterTitle, center);
0197 }
0198
0199
0200
0201
0202
0203 inline void TAxis::RotateTitle(Bool_t rotate)
0204 {
0205 SetBit(kRotateTitle, rotate);
0206 }
0207
0208
0209
0210
0211
0212
0213 inline void TAxis::SetDecimals(Bool_t dot) {
0214 SetBit(kDecimals, dot);
0215 }
0216
0217
0218
0219
0220
0221
0222
0223 inline void TAxis::SetMoreLogLabels(Bool_t more)
0224 {
0225 SetBit(kMoreLogLabels, more);
0226 }
0227
0228
0229
0230
0231
0232
0233 inline void TAxis::SetNoExponent(Bool_t noExponent)
0234 {
0235 SetBit(kNoExponent, noExponent);
0236 }
0237
0238
0239 #endif