ROOT  6.06/09
Reference Guide
TGaxis.h
Go to the documentation of this file.
1 // @(#)root/graf:$Id$
2 // Author: Rene Brun, Olivier Couet 12/12/94
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGaxis
13 #define ROOT_TGaxis
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGaxis //
19 // //
20 // Service class for the graphical representation of axis. //
21 // Instances of this class are generated by the histogram classes and //
22 // TGraph. //
23 // //
24 //////////////////////////////////////////////////////////////////////////
25 
26 #ifndef ROOT_TNamed
27 #include "TNamed.h"
28 #endif
29 #ifndef ROOT_TLine
30 #include "TLine.h"
31 #endif
32 #ifndef ROOT_TAttText
33 #include "TAttText.h"
34 #endif
35 
36 class TF1;
37 class TAxis;
38 
39 class TGaxis : public TLine, public TAttText {
40 
41 protected:
42  Double_t fWmin; //Lowest value on the axis
43  Double_t fWmax; //Highest value on the axis
44  Float_t fGridLength; //Length of the grid in NDC
45  Float_t fTickSize; //Size of primary tick mark in NDC
46  Float_t fLabelOffset; //Offset of label wrt axis
47  Float_t fLabelSize; //Size of labels in NDC
48  Float_t fTitleOffset; //Offset of title wrt axis
49  Float_t fTitleSize; //Size of title in NDC
50  Int_t fNdiv; //Number of divisions
51  Int_t fLabelColor; //Color for labels
52  Int_t fLabelFont; //Font for labels
53  TString fChopt; //Axis options
54  TString fName; //axis name
55  TString fTitle; //axis title
56  TString fTimeFormat; //Time format, ex: 09/12/99 12:34:00
57  TString fFunctionName; //name of mapping function pointed by fFunction
58  TF1 *fFunction; //!Pointer to function computing axis values
59  TAxis *fAxis; //!pointer to original TAxis axis (if any)
60 
61  static Int_t fgMaxDigits; //!Number of digits above which the 10>N notation is used
62  static Float_t fXAxisExpXOffset; //!Exponent X offset for the X axis
63  static Float_t fXAxisExpYOffset; //!Exponent Y offset for the X axis
64  static Float_t fYAxisExpXOffset; //!Exponent X offset for the Y axis
65  static Float_t fYAxisExpYOffset; //!Exponent Y offset for the Y axis
66 
67  TGaxis(const TGaxis&);
68  TGaxis& operator=(const TGaxis&);
69 
70 public:
71 
72  TGaxis();
74  Double_t wmin,Double_t wmax,Int_t ndiv=510, Option_t *chopt="",
75  Double_t gridlength = 0);
77  const char *funcname, Int_t ndiv=510, Option_t *chopt="",
78  Double_t gridlength = 0);
79  virtual ~TGaxis();
80 
81  virtual void AdjustBinSize(Double_t A1, Double_t A2, Int_t nold
82  ,Double_t &BinLow, Double_t &BinHigh, Int_t &nbins, Double_t &BinWidth);
83  virtual void CenterLabels(Bool_t center=kTRUE);
84  virtual void CenterTitle(Bool_t center=kTRUE);
86  Double_t wmin,Double_t wmax,Int_t ndiv=510, Option_t *chopt="",
87  Double_t gridlength = 0);
88  Float_t GetGridLength() const {return fGridLength;}
89  TF1 *GetFunction() const {return fFunction;}
90  Int_t GetLabelColor() const {return fLabelColor;}
91  Int_t GetLabelFont() const {return fLabelFont;}
93  Float_t GetLabelSize() const {return fLabelSize;}
95  Float_t GetTitleSize() const {return fTitleSize;}
96  virtual const char *GetName() const {return fName.Data();}
97  virtual const char *GetOption() const {return fChopt.Data();}
98  virtual const char *GetTitle() const {return fTitle.Data();}
99  static Int_t GetMaxDigits();
100  Int_t GetNdiv() const {return fNdiv;}
101  Double_t GetWmin() const {return fWmin;}
102  Double_t GetWmax() const {return fWmax;}
103  Float_t GetTickSize() const {return fTickSize;}
104  virtual void ImportAxisAttributes(TAxis *axis);
105  void LabelsLimits(const char *label, Int_t &first, Int_t &last);
106  virtual void Paint(Option_t *chopt="");
108  Double_t &wmin,Double_t &wmax,Int_t &ndiv, Option_t *chopt="",
109  Double_t gridlength = 0, Bool_t drawGridOnly = kFALSE);
110  virtual void Rotate(Double_t X, Double_t Y, Double_t CFI, Double_t SFI
111  ,Double_t XT, Double_t YT, Double_t &U, Double_t &V);
112  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
113  void SetFunction(const char *funcname="");
114  void SetOption(Option_t *option="");
115  void SetLabelColor(Int_t labelcolor) {fLabelColor = labelcolor;} // *MENU*
116  void SetLabelFont(Int_t labelfont) {fLabelFont = labelfont;} // *MENU*
117  void SetLabelOffset(Float_t labeloffset) {fLabelOffset = labeloffset;} // *MENU*
118  void SetLabelSize(Float_t labelsize) {fLabelSize = labelsize;} // *MENU*
119  static void SetMaxDigits(Int_t maxd=5);
120  virtual void SetName(const char *name); // *MENU*
121  virtual void SetNdivisions(Int_t ndiv) {fNdiv = ndiv;} // *MENU*
122  virtual void SetMoreLogLabels(Bool_t more=kTRUE); // *MENU*
123  virtual void SetNoExponent(Bool_t noExponent=kTRUE); // *MENU*
124  virtual void SetDecimals(Bool_t dot=kTRUE); // *MENU*
125  void SetTickSize(Float_t ticksize) {fTickSize = ticksize;} // *MENU*
126  void SetTickLength(Float_t ticklength) {SetTickSize(ticklength);}
127  void SetGridLength(Float_t gridlength) {fGridLength = gridlength;}
128  void SetTimeFormat(const char *tformat);
129  void SetTimeOffset(Double_t toffset, Option_t *option="local");
130  virtual void SetTitle(const char *title=""); // *MENU*
131  void SetTitleOffset(Float_t titleoffset=1) {fTitleOffset = titleoffset;} // *MENU*
132  void SetTitleSize(Float_t titlesize) {fTitleSize = titlesize;} // *MENU*
133  void SetTitleFont(Int_t titlefont) {SetTextFont(titlefont);} // *MENU*
134  void SetTitleColor(Int_t titlecolor) {SetTextColor(titlecolor);} // *MENU*
135  void SetWmin(Double_t wmin) {fWmin = wmin;}
136  void SetWmax(Double_t wmax) {fWmax = wmax;}
137  static void SetExponentOffset(Float_t xoff=0., Float_t yoff=0., Option_t *axis="xy");
138 
139  ClassDef(TGaxis,5) //Graphics axis
140 };
141 
142 #endif
143 
144 
void SetTickLength(Float_t ticklength)
Definition: TGaxis.h:126
virtual void SetName(const char *name)
Change the name of the axis.
Definition: TGaxis.cxx:2242
Double_t GetWmin() const
Definition: TGaxis.h:101
virtual void SetMoreLogLabels(Bool_t more=kTRUE)
Set the kMoreLogLabels bit flag.
Definition: TGaxis.cxx:2252
Float_t GetLabelOffset() const
Definition: TGaxis.h:92
float xmin
Definition: THbookFile.cxx:93
Float_t GetTickSize() const
Definition: TGaxis.h:103
ClassDef(TAttBBox2D, 0)
Int_t GetLabelFont() const
Definition: TGaxis.h:91
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
void SetTitleColor(Int_t titlecolor)
Definition: TGaxis.h:134
float ymin
Definition: THbookFile.cxx:93
static Int_t fgMaxDigits
pointer to original TAxis axis (if any)
Definition: TGaxis.h:61
Int_t GetNdiv() const
Definition: TGaxis.h:100
static void SetExponentOffset(Float_t xoff=0., Float_t yoff=0., Option_t *axis="xy")
Static function to set X and Y offset of the axis 10^n notation.
Definition: TGaxis.cxx:2367
Float_t GetTitleOffset() const
Definition: TGaxis.h:94
virtual const char * GetName() const
Returns name of object.
Definition: TGaxis.h:96
virtual void CenterLabels(Bool_t center=kTRUE)
If center = kTRUE axis labels are centered in the center of the bin.
Definition: TGaxis.cxx:596
TString fTimeFormat
Definition: TGaxis.h:56
TGaxis & operator=(const TGaxis &)
Assignment operator.
Definition: TGaxis.cxx:556
virtual void SetTitle(const char *title="")
Change the title of the axis.
Definition: TGaxis.cxx:2280
Basic string class.
Definition: TString.h:137
Int_t GetLabelColor() const
Definition: TGaxis.h:90
virtual void ImportAxisAttributes(TAxis *axis)
Internal method to import TAxis attributes to this TGaxis.
Definition: TGaxis.cxx:655
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
int nbins[3]
Float_t GetTitleSize() const
Definition: TGaxis.h:95
TAxis * fAxis
Pointer to function computing axis values.
Definition: TGaxis.h:59
TString fChopt
Definition: TGaxis.h:53
void SetTitleFont(Int_t titlefont)
Definition: TGaxis.h:133
Float_t fLabelOffset
Definition: TGaxis.h:46
virtual void DrawAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, Double_t wmin, Double_t wmax, Int_t ndiv=510, Option_t *chopt="", Double_t gridlength=0)
Draw this axis with new attributes.
Definition: TGaxis.cxx:616
const char * Data() const
Definition: TString.h:349
void SetTitleSize(Float_t titlesize)
Definition: TGaxis.h:132
virtual void SetTextFont(Font_t tfont=62)
Definition: TAttText.h:59
static Float_t fXAxisExpYOffset
Exponent X offset for the X axis.
Definition: TGaxis.h:63
Double_t dot(const TVector2 &v1, const TVector2 &v2)
Definition: CsgOps.cxx:333
static Float_t fYAxisExpYOffset
Exponent X offset for the Y axis.
Definition: TGaxis.h:65
TString fTitle
Definition: TGaxis.h:55
Float_t fGridLength
Definition: TGaxis.h:44
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TGaxis.cxx:2135
void SetOption(Option_t *option="")
To set axis options.
Definition: TGaxis.cxx:2272
Float_t GetGridLength() const
Definition: TGaxis.h:88
virtual const char * GetOption() const
Definition: TGaxis.h:97
void SetTimeFormat(const char *tformat)
Change the format used for time plotting.
Definition: TGaxis.cxx:2307
TString fName
Definition: TGaxis.h:54
virtual ~TGaxis()
TGaxis default destructor.
Definition: TGaxis.cxx:587
char * out
Definition: TBase64.cxx:29
void SetLabelSize(Float_t labelsize)
Definition: TGaxis.h:118
float ymax
Definition: THbookFile.cxx:93
virtual void PaintAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, Double_t &wmin, Double_t &wmax, Int_t &ndiv, Option_t *chopt="", Double_t gridlength=0, Bool_t drawGridOnly=kFALSE)
Control function to draw an axis.
Definition: TGaxis.cxx:705
Class to manage histogram axis.
Definition: TAxis.h:36
static void SetMaxDigits(Int_t maxd=5)
Static function to set fgMaxDigits for axis.
Definition: TGaxis.cxx:2233
void SetFunction(const char *funcname="")
Specify a function to map the axis values.
Definition: TGaxis.cxx:2210
Double_t fWmin
Definition: TGaxis.h:42
Text Attributes class.
Definition: TAttText.h:32
A simple line.
Definition: TLine.h:41
The axis painter class.
Definition: TGaxis.h:39
float xmax
Definition: THbookFile.cxx:93
void SetGridLength(Float_t gridlength)
Definition: TGaxis.h:127
TF1 * fFunction
Definition: TGaxis.h:58
void SetWmax(Double_t wmax)
Definition: TGaxis.h:136
static Float_t fYAxisExpXOffset
Exponent Y offset for the X axis.
Definition: TGaxis.h:64
Int_t fLabelFont
Definition: TGaxis.h:52
virtual void AdjustBinSize(Double_t A1, Double_t A2, Int_t nold, Double_t &BinLow, Double_t &BinHigh, Int_t &nbins, Double_t &BinWidth)
Internal method for axis labels optimisation.
Definition: TGaxis.cxx:2078
void SetLabelOffset(Float_t labeloffset)
Definition: TGaxis.h:117
virtual void SetDecimals(Bool_t dot=kTRUE)
Set the decimals flag.
Definition: TGaxis.cxx:2201
double Double_t
Definition: RtypesCore.h:55
Float_t fTitleOffset
Definition: TGaxis.h:48
TString fFunctionName
Definition: TGaxis.h:57
void SetLabelFont(Int_t labelfont)
Definition: TGaxis.h:116
#define name(a, b)
Definition: linkTestLib0.cpp:5
static Int_t GetMaxDigits()
Static function returning fgMaxDigits (See SetMaxDigits).
Definition: TGaxis.cxx:646
virtual void Paint(Option_t *chopt="")
Draw this axis with its current attributes.
Definition: TGaxis.cxx:684
virtual void Rotate(Double_t X, Double_t Y, Double_t CFI, Double_t SFI, Double_t XT, Double_t YT, Double_t &U, Double_t &V)
Internal method to rotate axis coordinates.
Definition: TGaxis.cxx:2125
Double_t GetWmax() const
Definition: TGaxis.h:102
Float_t fLabelSize
Definition: TGaxis.h:47
Float_t GetLabelSize() const
Definition: TGaxis.h:93
1-Dim function class
Definition: TF1.h:149
void SetTimeOffset(Double_t toffset, Option_t *option="local")
Change the time offset. If option = "gmt", set display mode to GMT.
Definition: TGaxis.cxx:2331
void SetTickSize(Float_t ticksize)
Definition: TGaxis.h:125
Int_t fLabelColor
Definition: TGaxis.h:51
void SetLabelColor(Int_t labelcolor)
Definition: TGaxis.h:115
virtual void SetTextColor(Color_t tcolor=1)
Definition: TAttText.h:57
virtual const char * GetTitle() const
Returns title of object.
Definition: TGaxis.h:98
void SetWmin(Double_t wmin)
Definition: TGaxis.h:135
Float_t fTitleSize
Definition: TGaxis.h:49
void SetTitleOffset(Float_t titleoffset=1)
Definition: TGaxis.h:131
const Bool_t kTRUE
Definition: Rtypes.h:91
Double_t fWmax
Definition: TGaxis.h:43
virtual void SetNoExponent(Bool_t noExponent=kTRUE)
Set the NoExponent flag.
Definition: TGaxis.cxx:2263
virtual void CenterTitle(Bool_t center=kTRUE)
If center = kTRUE axis title will be centered. The default is right adjusted.
Definition: TGaxis.cxx:606
TF1 * GetFunction() const
Definition: TGaxis.h:89
Float_t fTickSize
Definition: TGaxis.h:45
static Float_t fXAxisExpXOffset
Number of digits above which the 10>N notation is used.
Definition: TGaxis.h:62
virtual void SetNdivisions(Int_t ndiv)
Definition: TGaxis.h:121
void LabelsLimits(const char *label, Int_t &first, Int_t &last)
Internal method to find first and last character of a label.
Definition: TGaxis.cxx:2113
Int_t fNdiv
Definition: TGaxis.h:50