Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include "TLine.h"
16#include "TAttText.h"
17#include "TString.h"
18
19
20class TColorNumber;
21class TF1;
22class TAxis;
23class TLatex;
24class TAxisModLab;
25
26class TGaxis : public TLine, public TAttText {
27
28protected:
29
30 Double_t fWmin; ///< Lowest value on the axis
31 Double_t fWmax; ///< Highest value on the axis
32 Float_t fGridLength; ///< Length of the grid in NDC
33 Float_t fTickSize; ///< Size of primary tick mark in NDC
34 Float_t fLabelOffset; ///< Offset of label wrt axis
35 Float_t fLabelSize; ///< Size of labels in NDC
36 Float_t fTitleOffset; ///< Offset of title wrt axis
37 Float_t fTitleSize; ///< Size of title in NDC
38 Int_t fNdiv; ///< Number of divisions
39 Int_t fLabelColor; ///< Color for labels
40 Int_t fLabelFont; ///< Font for labels
41 Int_t fNModLabs; ///< Number of modified labels
42 TString fChopt; ///< Axis options
43 TString fName; ///< Axis name
44 TString fTitle; ///< Axis title
45 TString fTimeFormat; ///< Time format, ex: 09/12/99 12:34:00
46 TString fFunctionName; ///< Name of mapping function pointed by fFunction
47 TF1 *fFunction; ///<! Pointer to function computing axis values
48 TAxis *fAxis; ///<! Pointer to original TAxis axis (if any)
49 TList *fModLabs; ///< List of modified labels.
50
51 TGaxis(const TGaxis&);
52 TGaxis& operator=(const TGaxis&);
53
54 Bool_t IsOwnedModLabs() const;
55 void CleanupModLabs();
56
57 TAxisModLab *FindModLab(Int_t indx, Int_t numlabels = 0, Double_t v = 0., Double_t eps = -1.) const;
58
59public:
60
61 TGaxis();
63 Double_t wmin,Double_t wmax,Int_t ndiv=510, Option_t *chopt="",
64 Double_t gridlength = 0);
66 const char *funcname, Int_t ndiv=510, Option_t *chopt="",
67 Double_t gridlength = 0);
68 ~TGaxis() override;
69
70 virtual void AdjustBinSize(Double_t A1, Double_t A2, Int_t nold
71 ,Double_t &BinLow, Double_t &BinHigh, Int_t &nbins, Double_t &BinWidth);
72 virtual void CenterLabels(Bool_t center=kTRUE);
73 virtual void CenterTitle(Bool_t center=kTRUE);
74 void ChangeLabelAttributes(Int_t i, Int_t nlabels, TLatex* t, char* c, Double_t value = 0., Double_t eps = -1.);
76 Double_t wmin,Double_t wmax,Int_t ndiv=510, Option_t *chopt="",
77 Double_t gridlength = 0);
79 TF1 *GetFunction() const {return fFunction;}
81 Int_t GetLabelFont() const {return fLabelFont;}
86 const char *GetName() const override {return fName.Data();}
87 const char *GetOption() const override {return fChopt.Data();}
88 const char *GetTitle() const override {return fTitle.Data();}
89 static Int_t GetMaxDigits();
90 Int_t GetNdiv() const {return fNdiv;}
91 Double_t GetWmin() const {return fWmin;}
92 Double_t GetWmax() const {return fWmax;}
93 Float_t GetTickSize() const {return fTickSize;}
94 virtual void ImportAxisAttributes(TAxis *axis);
95 void LabelsLimits(const char *label, Int_t &first, Int_t &last);
96 void Paint(Option_t *chopt="") override;
98 Double_t &wmin,Double_t &wmax,Int_t &ndiv, Option_t *chopt="",
99 Double_t gridlength = 0, Bool_t drawGridOnly = kFALSE);
100 virtual void Rotate(Double_t X, Double_t Y, Double_t CFI, Double_t SFI
101 ,Double_t XT, Double_t YT, Double_t &U, Double_t &V);
103 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
104 void SetFunction(const char *funcname="");
105 void SetOption(Option_t *option="");
106 void SetLabelColor(Int_t labelcolor) {fLabelColor = labelcolor;} // *MENU*
107 void SetLabelFont(Int_t labelfont) {fLabelFont = labelfont;} // *MENU*
108 void SetLabelOffset(Float_t labeloffset) {fLabelOffset = labeloffset;} // *MENU*
109 void SetLabelSize(Float_t labelsize) {fLabelSize = labelsize;} // *MENU*
110 void ChangeLabel(Int_t labNum=0, Double_t labAngle = -1.,
111 Double_t labSize = -1., Int_t labAlign = -1,
112 Int_t labColor = -1 , Int_t labFont = -1,
113 const TString &labText = ""); // *MENU*
114 void ChangeLabelByValue(Double_t labValue, Double_t labAngle = -1.,
115 Double_t labSize = -1., Int_t labAlign = -1,
116 Int_t labColor = -1 , Int_t labFont = -1,
117 const TString &labText = ""); // *MENU*
118 static void SetMaxDigits(Int_t maxd=5);
119 virtual void SetName(const char *name); // *MENU*
120 virtual void SetNdivisions(Int_t ndiv) {fNdiv = ndiv;} // *MENU*
121 virtual void SetMoreLogLabels(Bool_t more=kTRUE); // *MENU*
122 virtual void SetNoExponent(Bool_t noExponent=kTRUE); // *MENU*
123 virtual void SetDecimals(Bool_t dot=kTRUE); // *MENU*
124 void SetTickSize(Float_t ticksize) {fTickSize = ticksize;} // *MENU*
125 void SetTickLength(Float_t ticklength) {SetTickSize(ticklength);}
126 void SetGridLength(Float_t gridlength) {fGridLength = gridlength;}
127 void SetTimeFormat(const char *tformat);
128 void SetTimeOffset(Double_t toffset, Option_t *option="local");
129 virtual void SetTitle(const char *title=""); // *MENU*
130 void SetTitleOffset(Float_t titleoffset=1) {fTitleOffset = titleoffset;} // *MENU*
131 void SetTitleSize(Float_t titlesize) {fTitleSize = titlesize;} // *MENU*
132 void SetTitleFont(Int_t titlefont) {SetTextFont(titlefont);} // *MENU*
133 void SetTitleColor(Int_t titlecolor) {SetTextColor(titlecolor);} // *MENU*
136 static void SetExponentOffset(Float_t xoff=0., Float_t yoff=0., Option_t *axis="xy");
137
138 void SetLabelColor(TColorNumber lcolor);
139
140 ClassDefOverride(TGaxis,6) //Graphics axis
141};
142
143#endif
#define c(i)
Definition RSha256.hxx:101
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
#define X(type, name)
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t wmin
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t SetTextFont
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t wmax
char name[80]
Definition TGX11.cxx:110
float xmin
float ymin
float xmax
float ymax
Text Attributes class.
Definition TAttText.h:20
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:46
TAxis helper class used to store the modified labels.
Definition TAxisModLab.h:21
Class to manage histogram axis.
Definition TAxis.h:32
1-Dim function class
Definition TF1.h:233
The axis painter class.
Definition TGaxis.h:26
virtual void SetNoExponent(Bool_t noExponent=kTRUE)
Set the NoExponent flag.
Definition TGaxis.cxx:2925
void SetTimeFormat(const char *tformat)
Change the format used for time plotting.
Definition TGaxis.cxx:2969
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:1008
TGaxis()
TGaxis default constructor.
Definition TGaxis.cxx:694
void SetTitleOffset(Float_t titleoffset=1)
Definition TGaxis.h:130
void ChangeLabelAttributes(Int_t i, Int_t nlabels, TLatex *t, char *c, Double_t value=0., Double_t eps=-1.)
Helper method used by TGaxis::ChangeLabel.
Definition TGaxis.cxx:2859
Float_t fTitleSize
Size of title in NDC.
Definition TGaxis.h:37
Float_t GetGridLength() const
Definition TGaxis.h:78
void SetLabelFont(Int_t labelfont)
Definition TGaxis.h:107
void SetTitleSize(Float_t titlesize)
Definition TGaxis.h:131
Double_t GetWmin() const
Definition TGaxis.h:91
Float_t fTitleOffset
Offset of title wrt axis.
Definition TGaxis.h:36
const char * GetOption() const override
Definition TGaxis.h:87
TString fTitle
Axis title.
Definition TGaxis.h:44
Int_t fLabelFont
Font for labels.
Definition TGaxis.h:40
void SetTitleFont(Int_t titlefont)
Definition TGaxis.h:132
TAxisModLab * FindModLab(Int_t indx, Int_t numlabels=0, Double_t v=0., Double_t eps=-1.) const
Search for axis modifier by index or value.
Definition TGaxis.cxx:2662
virtual void SetTitle(const char *title="")
Change the title of the axis.
Definition TGaxis.cxx:2942
Int_t fLabelColor
Color for labels.
Definition TGaxis.h:39
TAxis * fAxis
! Pointer to original TAxis axis (if any)
Definition TGaxis.h:48
TString fTimeFormat
Time format, ex: 09/12/99 12:34:00.
Definition TGaxis.h:45
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TGaxis.cxx:2555
TString fFunctionName
Name of mapping function pointed by fFunction.
Definition TGaxis.h:46
void SetLabelOffset(Float_t labeloffset)
Definition TGaxis.h:108
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:2545
Float_t GetLabelOffset() const
Definition TGaxis.h:82
void SetTimeOffset(Double_t toffset, Option_t *option="local")
Change the time offset. If option = "gmt", set display mode to GMT.
Definition TGaxis.cxx:2993
Float_t fTickSize
Size of primary tick mark in NDC.
Definition TGaxis.h:33
void ChangeLabelByValue(Double_t labValue, Double_t labAngle=-1., Double_t labSize=-1., Int_t labAlign=-1, Int_t labColor=-1, Int_t labFont=-1, const TString &labText="")
Define new text attributes for the label value "labValue".
Definition TGaxis.cxx:2813
~TGaxis() override
TGaxis default destructor.
Definition TGaxis.cxx:861
TF1 * GetFunction() const
Definition TGaxis.h:79
virtual void ImportAxisAttributes(TAxis *axis)
Internal method to import TAxis attributes to this TGaxis.
Definition TGaxis.cxx:955
Int_t GetLabelFont() const
Definition TGaxis.h:81
Float_t fLabelOffset
Offset of label wrt axis.
Definition TGaxis.h:34
static void SetMaxDigits(Int_t maxd=5)
Static function to set fgMaxDigits for axis.
Definition TGaxis.cxx:2896
Float_t fLabelSize
Size of labels in NDC.
Definition TGaxis.h:35
Int_t fNdiv
Number of divisions.
Definition TGaxis.h:38
void SetGridLength(Float_t gridlength)
Definition TGaxis.h:126
const char * GetTitle() const override
Returns title of object.
Definition TGaxis.h:88
TString fChopt
Axis options.
Definition TGaxis.h:42
TGaxis & operator=(const TGaxis &)
Assignment operator.
Definition TGaxis.cxx:828
TString fName
Axis name.
Definition TGaxis.h:43
Float_t GetTitleOffset() const
Definition TGaxis.h:84
TF1 * fFunction
! Pointer to function computing axis values
Definition TGaxis.h:47
virtual void SetNdivisions(Int_t ndiv)
Definition TGaxis.h:120
void SetWmax(Double_t wmax)
Definition TGaxis.h:135
Float_t GetTitleSize() const
Definition TGaxis.h:85
static Int_t GetMaxDigits()
Static function returning gStyle->GetAxisMaxDigits().
Definition TGaxis.cxx:947
virtual void CenterLabels(Bool_t center=kTRUE)
If center = kTRUE axis labels are centered in the center of the bin.
Definition TGaxis.cxx:896
const char * GetName() const override
Returns name of object.
Definition TGaxis.h:86
void SetLabelColor(Int_t labelcolor)
Definition TGaxis.h:106
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:2498
void SetTickLength(Float_t ticklength)
Definition TGaxis.h:125
Float_t fGridLength
Length of the grid in NDC.
Definition TGaxis.h:32
Int_t GetLabelColor() const
Definition TGaxis.h:80
virtual void SetDecimals(Bool_t dot=kTRUE)
Set the decimals flag.
Definition TGaxis.cxx:2634
virtual void CenterTitle(Bool_t center=kTRUE)
If center = kTRUE axis title will be centered. The default is right adjusted.
Definition TGaxis.cxx:906
void SetTitleColor(Int_t titlecolor)
Definition TGaxis.h:133
TList * fModLabs
List of modified labels.
Definition TGaxis.h:49
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, const TString &labText="")
Define new text attributes for the label number "labNum".
Definition TGaxis.cxx:2734
void CleanupModLabs()
Correctly cleanup fModLabs - delete content when owned by TGaxis.
Definition TGaxis.cxx:881
Double_t fWmax
Highest value on the axis.
Definition TGaxis.h:31
Float_t GetTickSize() const
Definition TGaxis.h:93
virtual TGaxis * 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:916
virtual void SetMoreLogLabels(Bool_t more=kTRUE)
Set the kMoreLogLabels bit flag.
Definition TGaxis.cxx:2914
void SetWmin(Double_t wmin)
Definition TGaxis.h:134
void SetTickSize(Float_t ticksize)
Definition TGaxis.h:124
Int_t GetNdiv() const
Definition TGaxis.h:90
void Paint(Option_t *chopt="") override
Draw this axis with its current attributes.
Definition TGaxis.cxx:986
Int_t fNModLabs
Number of modified labels.
Definition TGaxis.h:41
Double_t fWmin
Lowest value on the axis.
Definition TGaxis.h:30
void SetLabelSize(Float_t labelsize)
Definition TGaxis.h:109
void SetFunction(const char *funcname="")
Specify a function to map the axis values.
Definition TGaxis.cxx:2643
virtual void SetName(const char *name)
Change the name of the axis.
Definition TGaxis.cxx:2904
static void SetExponentOffset(Float_t xoff=0., Float_t yoff=0., Option_t *axis="xy")
Static method to set X and Y offset of the axis 10^n notation.
Definition TGaxis.cxx:3035
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:2533
Double_t GetWmax() const
Definition TGaxis.h:92
Bool_t IsOwnedModLabs() const
Returns kTRUE when fModLabs owned by TGaxis and should be cleaned up.
Definition TGaxis.cxx:869
void ResetLabelAttributes(TLatex *t)
Helper method used by TGaxis::ChangeLabel.
Definition TGaxis.cxx:2880
Float_t GetLabelSize() const
Definition TGaxis.h:83
void SetOption(Option_t *option="")
To set axis options.
Definition TGaxis.cxx:2934
To draw Mathematical Formula.
Definition TLatex.h:18
Use the TLine constructor to create a simple line.
Definition TLine.h:22
A doubly linked list.
Definition TList.h:38
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376