Logo ROOT   6.08/07
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 #ifndef ROOT_TNamed
17 #include "TNamed.h"
18 #endif
19 #ifndef ROOT_TLine
20 #include "TLine.h"
21 #endif
22 #ifndef ROOT_TAttText
23 #include "TAttText.h"
24 #endif
25 
26 class TF1;
27 class TAxis;
28 class TLatex;
29 
30 class TGaxis : public TLine, public TAttText {
31 
32 protected:
33 
34  Double_t fWmin; ///< Lowest value on the axis
35  Double_t fWmax; ///< Highest value on the axis
36  Float_t fGridLength; ///< Length of the grid in NDC
37  Float_t fTickSize; ///< Size of primary tick mark in NDC
38  Float_t fLabelOffset; ///< Offset of label wrt axis
39  Float_t fLabelSize; ///< Size of labels in NDC
40  Float_t fTitleOffset; ///< Offset of title wrt axis
41  Float_t fTitleSize; ///< Size of title in NDC
42  Int_t fNdiv; ///< Number of divisions
43  Int_t fLabelColor; ///< Color for labels
44  Int_t fLabelFont; ///< Font for labels
45  Int_t fNModLabs; ///< Number of modified labels
46  TString fChopt; ///< Axis options
47  TString fName; ///< Axis name
48  TString fTitle; ///< Axis title
49  TString fTimeFormat; ///< Time format, ex: 09/12/99 12:34:00
50  TString fFunctionName; ///< Name of mapping function pointed by fFunction
51  TF1 *fFunction; ///<! Pointer to function computing axis values
52  TAxis *fAxis; ///<! Pointer to original TAxis axis (if any)
53  TList *fModLabs; ///< List of modified labels.
54 
55  static Int_t fgMaxDigits; ///<! Number of digits above which the 10>N notation is used
56  static Float_t fXAxisExpXOffset; ///<! Exponent X offset for the X axis
57  static Float_t fXAxisExpYOffset; ///<! Exponent Y offset for the X axis
58  static Float_t fYAxisExpXOffset; ///<! Exponent X offset for the Y axis
59  static Float_t fYAxisExpYOffset; ///<! Exponent Y offset for the Y axis
60 
61  TGaxis(const TGaxis&);
62  TGaxis& operator=(const TGaxis&);
63 
64 public:
65 
66  TGaxis();
68  Double_t wmin,Double_t wmax,Int_t ndiv=510, Option_t *chopt="",
69  Double_t gridlength = 0);
71  const char *funcname, Int_t ndiv=510, Option_t *chopt="",
72  Double_t gridlength = 0);
73  virtual ~TGaxis();
74 
75  virtual void AdjustBinSize(Double_t A1, Double_t A2, Int_t nold
76  ,Double_t &BinLow, Double_t &BinHigh, Int_t &nbins, Double_t &BinWidth);
77  virtual void CenterLabels(Bool_t center=kTRUE);
78  virtual void CenterTitle(Bool_t center=kTRUE);
79  void ChangeLabelAttributes(Int_t i, Int_t nlabels, TLatex* t, char* c);
81  Double_t wmin,Double_t wmax,Int_t ndiv=510, Option_t *chopt="",
82  Double_t gridlength = 0);
83  Float_t GetGridLength() const {return fGridLength;}
84  TF1 *GetFunction() const {return fFunction;}
85  Int_t GetLabelColor() const {return fLabelColor;}
86  Int_t GetLabelFont() const {return fLabelFont;}
88  Float_t GetLabelSize() const {return fLabelSize;}
90  Float_t GetTitleSize() const {return fTitleSize;}
91  virtual const char *GetName() const {return fName.Data();}
92  virtual const char *GetOption() const {return fChopt.Data();}
93  virtual const char *GetTitle() const {return fTitle.Data();}
94  static Int_t GetMaxDigits();
95  Int_t GetNdiv() const {return fNdiv;}
96  Double_t GetWmin() const {return fWmin;}
97  Double_t GetWmax() const {return fWmax;}
98  Float_t GetTickSize() const {return fTickSize;}
99  virtual void ImportAxisAttributes(TAxis *axis);
100  void LabelsLimits(const char *label, Int_t &first, Int_t &last);
101  virtual void Paint(Option_t *chopt="");
103  Double_t &wmin,Double_t &wmax,Int_t &ndiv, Option_t *chopt="",
104  Double_t gridlength = 0, Bool_t drawGridOnly = kFALSE);
105  virtual void Rotate(Double_t X, Double_t Y, Double_t CFI, Double_t SFI
106  ,Double_t XT, Double_t YT, Double_t &U, Double_t &V);
107  void ResetLabelAttributes(TLatex* t);
108  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
109  void SetFunction(const char *funcname="");
110  void SetOption(Option_t *option="");
111  void SetLabelColor(Int_t labelcolor) {fLabelColor = labelcolor;} // *MENU*
112  void SetLabelFont(Int_t labelfont) {fLabelFont = labelfont;} // *MENU*
113  void SetLabelOffset(Float_t labeloffset) {fLabelOffset = labeloffset;} // *MENU*
114  void SetLabelSize(Float_t labelsize) {fLabelSize = labelsize;} // *MENU*
115  void ChangeLabel(Int_t labNum=0, Double_t labAngle = -1.,
116  Double_t labSize = -1., Int_t labAlign = -1,
117  Int_t labColor = -1 , Int_t labFont = -1,
118  TString labText = ""); // *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,6) //Graphics axis
140 };
141 
142 #endif
Int_t GetLabelFont() const
Definition: TGaxis.h:86
void SetTickLength(Float_t ticklength)
Definition: TGaxis.h:126
virtual void SetName(const char *name)
Change the name of the axis.
Definition: TGaxis.cxx:2393
virtual void SetMoreLogLabels(Bool_t more=kTRUE)
Set the kMoreLogLabels bit flag.
Definition: TGaxis.cxx:2403
float xmin
Definition: THbookFile.cxx:93
float Float_t
Definition: RtypesCore.h:53
return c
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
! Number of digits above which the 10>N notation is used
Definition: TGaxis.h:55
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:2522
Float_t GetLabelSize() const
Definition: TGaxis.h:88
virtual void CenterLabels(Bool_t center=kTRUE)
If center = kTRUE axis labels are centered in the center of the bin.
Definition: TGaxis.cxx:633
TString fTimeFormat
Time format, ex: 09/12/99 12:34:00.
Definition: TGaxis.h:49
TGaxis & operator=(const TGaxis &)
Assignment operator.
Definition: TGaxis.cxx:591
virtual void SetTitle(const char *title="")
Change the title of the axis.
Definition: TGaxis.cxx:2431
Basic string class.
Definition: TString.h:137
virtual void ImportAxisAttributes(TAxis *axis)
Internal method to import TAxis attributes to this TGaxis.
Definition: TGaxis.cxx:692
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]
TAxis * fAxis
! Pointer to original TAxis axis (if any)
Definition: TGaxis.h:52
TString fChopt
Axis options.
Definition: TGaxis.h:46
void SetTitleFont(Int_t titlefont)
Definition: TGaxis.h:133
Float_t fLabelOffset
Offset of label wrt axis.
Definition: TGaxis.h:38
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:653
void ChangeLabelAttributes(Int_t i, Int_t nlabels, TLatex *t, char *c)
Definition: TGaxis.cxx:2337
void SetTitleSize(Float_t titlesize)
Definition: TGaxis.h:132
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:51
static Float_t fXAxisExpYOffset
! Exponent Y offset for the X axis
Definition: TGaxis.h:57
static Float_t fYAxisExpYOffset
! Exponent Y offset for the Y axis
Definition: TGaxis.h:59
TString fTitle
Axis title.
Definition: TGaxis.h:48
#define ClassDef(name, id)
Definition: Rtypes.h:254
Float_t fGridLength
Length of the grid in NDC.
Definition: TGaxis.h:36
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TGaxis.cxx:2175
Int_t fNModLabs
Number of modified labels.
Definition: TGaxis.h:45
To draw Mathematical Formula.
Definition: TLatex.h:25
void SetOption(Option_t *option="")
To set axis options.
Definition: TGaxis.cxx:2423
virtual const char * GetName() const
Returns name of object.
Definition: TGaxis.h:91
void SetTimeFormat(const char *tformat)
Change the format used for time plotting.
Definition: TGaxis.cxx:2458
TString fName
Axis name.
Definition: TGaxis.h:47
virtual ~TGaxis()
TGaxis default destructor.
Definition: TGaxis.cxx:624
void SetLabelSize(Float_t labelsize)
Definition: TGaxis.h:114
A doubly linked list.
Definition: TList.h:47
TList * fModLabs
List of modified labels.
Definition: TGaxis.h:53
Float_t GetGridLength() const
Definition: TGaxis.h:83
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:742
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:2384
void SetFunction(const char *funcname="")
Specify a function to map the axis values.
Definition: TGaxis.cxx:2250
Double_t fWmin
Lowest value on the axis.
Definition: TGaxis.h:34
Text Attributes class.
Definition: TAttText.h:24
A simple line.
Definition: TLine.h:33
The axis painter class.
Definition: TGaxis.h:30
float xmax
Definition: THbookFile.cxx:93
void SetGridLength(Float_t gridlength)
Definition: TGaxis.h:127
TF1 * fFunction
! Pointer to function computing axis values
Definition: TGaxis.h:51
Int_t GetNdiv() const
Definition: TGaxis.h:95
void SetWmax(Double_t wmax)
Definition: TGaxis.h:136
static Float_t fYAxisExpXOffset
! Exponent X offset for the Y axis
Definition: TGaxis.h:58
void ResetLabelAttributes(TLatex *t)
Reset the label attributes to the value they have before the last call to ChangeLabelAttributes.
Definition: TGaxis.cxx:2368
Int_t fLabelFont
Font for labels.
Definition: TGaxis.h:44
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:2118
void SetLabelOffset(Float_t labeloffset)
Definition: TGaxis.h:113
virtual void SetDecimals(Bool_t dot=kTRUE)
Set the decimals flag.
Definition: TGaxis.cxx:2241
double Double_t
Definition: RtypesCore.h:55
Double_t GetWmin() const
Definition: TGaxis.h:96
Float_t fTitleOffset
Offset of title wrt axis.
Definition: TGaxis.h:40
TString fFunctionName
Name of mapping function pointed by fFunction.
Definition: TGaxis.h:50
virtual const char * GetTitle() const
Returns title of object.
Definition: TGaxis.h:93
void SetLabelFont(Int_t labelfont)
Definition: TGaxis.h:112
Double_t GetWmax() const
Definition: TGaxis.h:97
static Int_t GetMaxDigits()
Static function returning fgMaxDigits (See SetMaxDigits).
Definition: TGaxis.cxx:683
TGaxis()
TGaxis default constructor.
Definition: TGaxis.cxx:466
virtual void Paint(Option_t *chopt="")
Draw this axis with its current attributes.
Definition: TGaxis.cxx:721
Float_t GetTitleOffset() const
Definition: TGaxis.h:89
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:2165
Float_t fLabelSize
Size of labels in NDC.
Definition: TGaxis.h:39
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:2482
void SetTickSize(Float_t ticksize)
Definition: TGaxis.h:125
Int_t fLabelColor
Color for labels.
Definition: TGaxis.h:43
Float_t GetLabelOffset() const
Definition: TGaxis.h:87
void SetLabelColor(Int_t labelcolor)
Definition: TGaxis.h:111
TF1 * GetFunction() const
Definition: TGaxis.h:84
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition: TAttText.h:49
Definition: first.py:1
void SetWmin(Double_t wmin)
Definition: TGaxis.h:135
Float_t fTitleSize
Size of title in NDC.
Definition: TGaxis.h:41
void SetTitleOffset(Float_t titleoffset=1)
Definition: TGaxis.h:131
const Bool_t kTRUE
Definition: Rtypes.h:91
Double_t fWmax
Highest value on the axis.
Definition: TGaxis.h:35
Float_t GetTickSize() const
Definition: TGaxis.h:98
virtual void SetNoExponent(Bool_t noExponent=kTRUE)
Set the NoExponent flag.
Definition: TGaxis.cxx:2414
virtual void CenterTitle(Bool_t center=kTRUE)
If center = kTRUE axis title will be centered. The default is right adjusted.
Definition: TGaxis.cxx:643
Float_t fTickSize
Size of primary tick mark in NDC.
Definition: TGaxis.h:37
char name[80]
Definition: TGX11.cxx:109
static Float_t fXAxisExpXOffset
! Exponent X offset for the X axis
Definition: TGaxis.h:56
virtual void SetNdivisions(Int_t ndiv)
Definition: TGaxis.h:121
virtual const char * GetOption() const
Definition: TGaxis.h:92
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:2153
Int_t GetLabelColor() const
Definition: TGaxis.h:85
Int_t fNdiv
Number of divisions.
Definition: TGaxis.h:42
void ChangeLabel(Int_t labNum=0, Double_t labAngle=-1., Double_t labSize=-1., Int_t labAlign=-1, Int_t labColor=-1, Int_t labFont=-1, TString labText="")
Define new text attributes for the label number "labNum".
Definition: TGaxis.cxx:2302
Float_t GetTitleSize() const
Definition: TGaxis.h:90
const char * Data() const
Definition: TString.h:349