Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches

Line Attributes class.

This class is used (in general by secondary inheritance) by many other classes (graphics, histograms). It holds all the line attributes.

Line attributes

Line attributes are:

Line Color

The line color is a color index (integer) pointing in the ROOT color table. The line color of any class inheriting from TAttLine can be changed using the method SetLineColor and retrieved using the method GetLineColor. The following table shows the first 50 default colors.

Color transparency

SetLineColorAlpha(), allows to set a transparent color. In the following example the line color of the histogram histo is set to blue with an opacity of 35% (i.e. a transparency of 65%). (The color kBlue itself is internally stored as fully opaque.)

histo->SetLineColorAlpha(kBlue, 0.35);
@ kBlue
Definition Rtypes.h:66

The transparency is available on all platforms when the flag OpenGL.CanvasPreferGL is set to 1 in $ROOTSYS/etc/system.rootrc, or on Mac with the Cocoa backend. On the file output it is visible with PDF, PNG, Gif, JPEG, SVG, TeX ... but not PostScript.

Alternatively, you can call at the top of your script gSytle->SetCanvasPreferGL();. Or if you prefer to activate GL for a single canvas c, then use c->SetSupportGL(true);.

Line Width

The line width is expressed in pixel units. The line width of any class inheriting from TAttLine can be changed using the method SetLineWidth and retrieved using the method GetLineWidth. The following picture shows the line widths from 1 to 10 pixels.

Line Style

Line styles are identified via integer numbers. The line style of any class inheriting from TAttLine can be changed using the method SetLineStyle and retrieved using the method GetLineStyle.

The first 10 line styles are predefined as shown on the following picture:

Some line styles can be accessed via the following enum:

kSolid = 1
@ kDashed
Definition TAttLine.h:48
@ kSolid
Definition TAttLine.h:48
@ kDashDotted
Definition TAttLine.h:48
@ kDotted
Definition TAttLine.h:48

Additional line styles can be defined using TStyle::SetLineStyleString. For example the line style number 11 can be defined as follow:

gStyle->SetLineStyleString(11,"400 200");
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
void SetLineStyleString(Int_t i, const char *text)
Set line style string using the PostScript convention.
Definition TStyle.cxx:1479

Existing line styles (1 to 10) can be redefined using the same method.

Definition at line 18 of file TAttLine.h.

Public Member Functions

 TAttLine ()
 AttLine default constructor.
 
 TAttLine (Color_t lcolor, Style_t lstyle, Width_t lwidth)
 AttLine normal constructor.
 
virtual ~TAttLine ()
 AttLine destructor.
 
void Copy (TAttLine &attline) const
 Copy this line attributes to a new TAttLine.
 
Int_t DistancetoLine (Int_t px, Int_t py, Double_t xp1, Double_t yp1, Double_t xp2, Double_t yp2)
 Compute distance from point px,py to a line.
 
virtual Color_t GetLineColor () const
 Return the line color.
 
virtual Style_t GetLineStyle () const
 Return the line style.
 
virtual Width_t GetLineWidth () const
 Return the line width.
 
virtual TClassIsA () const
 
virtual void Modify ()
 Change current line attributes if necessary.
 
virtual void ResetAttLine (Option_t *option="")
 Reset this line attributes to default values.
 
virtual void SaveLineAttributes (std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
 Save line attributes as C++ statement(s) on output stream out.
 
virtual void SetLineAttributes ()
 Invoke the DialogCanvas Line attributes.
 
virtual void SetLineColor (Color_t lcolor)
 Set the line color.
 
virtual void SetLineColorAlpha (Color_t lcolor, Float_t lalpha)
 Set a transparent line color.
 
virtual void SetLineStyle (Style_t lstyle)
 Set the line style.
 
virtual void SetLineWidth (Width_t lwidth)
 Set the line width.
 
virtual void Streamer (TBuffer &)
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 

Static Public Member Functions

static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 

Protected Attributes

Color_t fLineColor
 Line color.
 
Style_t fLineStyle
 Line style.
 
Width_t fLineWidth
 Line width.
 

#include <TAttLine.h>

Inheritance diagram for TAttLine:
[legend]

Constructor & Destructor Documentation

◆ TAttLine() [1/2]

TAttLine::TAttLine ( )

AttLine default constructor.

Definition at line 143 of file TAttLine.cxx.

◆ TAttLine() [2/2]

TAttLine::TAttLine ( Color_t  color,
Style_t  style,
Width_t  width 
)

AttLine normal constructor.

Line attributes are taking from the argument list

  • color : must be one of the valid color index
  • style : 1=solid, 2=dash, 3=dash-dot, 4=dot-dot. New styles can be defined using TStyle::SetLineStyleString.
  • width : expressed in pixel units

Definition at line 160 of file TAttLine.cxx.

◆ ~TAttLine()

TAttLine::~TAttLine ( )
virtual

AttLine destructor.

Definition at line 170 of file TAttLine.cxx.

Member Function Documentation

◆ Class()

static TClass * TAttLine::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * TAttLine::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t TAttLine::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 45 of file TAttLine.h.

◆ Copy()

void TAttLine::Copy ( TAttLine attline) const

Copy this line attributes to a new TAttLine.

Definition at line 177 of file TAttLine.cxx.

◆ DeclFileName()

static const char * TAttLine::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 45 of file TAttLine.h.

◆ DistancetoLine()

Int_t TAttLine::DistancetoLine ( Int_t  px,
Int_t  py,
Double_t  xp1,
Double_t  yp1,
Double_t  xp2,
Double_t  yp2 
)

Compute distance from point px,py to a line.

Compute the closest distance of approach from point px,py to this line. The distance is computed in pixels units.

Algorithm:

A(x1,y1) P B(x2,y2)
-----------------+------------------------------
|
|
|
|
M(x,y)
Let us call a = distance AM A=a**2
b = distance BM B=b**2
c = distance AB C=c**2
d = distance PM D=d**2
u = distance AP U=u**2
v = distance BP V=v**2 c = u + v
D = A - U
D = B - V = B -(c-u)**2
==> u = (A -B +C)/2c
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17

Definition at line 211 of file TAttLine.cxx.

◆ GetLineColor()

virtual Color_t TAttLine::GetLineColor ( ) const
inlinevirtual

Return the line color.

Reimplemented in TGraphMultiErrors, TGWin32VirtualXProxy, and TWebPadPainter.

Definition at line 33 of file TAttLine.h.

◆ GetLineStyle()

virtual Style_t TAttLine::GetLineStyle ( ) const
inlinevirtual

Return the line style.

Reimplemented in TGraphMultiErrors, TGWin32VirtualXProxy, and TWebPadPainter.

Definition at line 34 of file TAttLine.h.

◆ GetLineWidth()

virtual Width_t TAttLine::GetLineWidth ( ) const
inlinevirtual

Return the line width.

Reimplemented in TGraphMultiErrors, TGWin32VirtualXProxy, and TWebPadPainter.

Definition at line 35 of file TAttLine.h.

◆ IsA()

virtual TClass * TAttLine::IsA ( ) const
inlinevirtual
Returns
TClass describing current object

Reimplemented in ROOT::Experimental::XRooFit::xRooHypoSpace, TMVA::TSpline1, TMVA::TSpline2, Jet, TStyle, TVirtualPad, TVirtualPS, TVirtualX, TGeoBatemanSol, TGeoPhysicalNode, TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly, TVirtualGeoTrack, TGeoOverlap, TGCocoa, TGQuartz, TAnnotation, TButton, TCanvas, TDialogCanvas, TGroupButton, TInspectCanvas, TPad, TPaveClass, TSlider, TSliderBox, TView, TArc, TArrow, TBox, TCandle, TCrown, TCurlyArc, TCurlyLine, TCutG, TDiamond, TEllipse, TFrame, TGaxis, TGraphPolar, TGraphPolargram, TGraphQQ, TLatex, TLegend, TLegendEntry, TLine, TPave, TPaveLabel, TPaveStats, TPavesText, TPaveText, TPieSlice, TPolyLine, TWbox, TGraphEdge, TGraphNode, TImageDump, TPDF, TPostScript, TSVG, TTeXDump, TGWin32, TGX11, TGX11TTF, TEveLine, TEveLineProjected, TEveScalableStraightLineSet, TEveStraightLineSet, TEveStraightLineSetProjected, TEveTrack, TEveTrackList, TEveTrackProjected, TEveTrackListProjected, TEveMCTrack, TBRIK, TCONE, TCONS, TCTUB, TELTU, TGTRA, THelix, THYPE, TMarker3DBox, TNode, TNodeDiv, TPARA, TPCON, TPGON, TPolyLine3D, TShape, TSPHE, TTRAP, TTRD1, TTRD2, TTUBE, TTUBS, TXTRU, TGLAxis, TGLTH3Composition, TWebPadPainter, TWebPS, THbookTree, TEfficiency, TF1, TF12, TF2, TF3, TGraph, TGraph2D, TGraph2DAsymmErrors, TGraph2DErrors, TGraphAsymmErrors, TGraphBentErrors, TGraphErrors, TGraphMultiErrors, TH1, TH1C, TH1S, TH1I, TH1L, TH1F, TH1D, TH1K, TH2, TH2C, TH2S, TH2I, TH2L, TH2F, TH2D, TH2Poly, TH3, TH3C, TH3S, TH3I, TH3L, TH3F, TH3D, TProfile, TProfile2D, TProfile2Poly, TProfile3D, TScatter, TSpline, TSpline3, TSpline5, ROOT::v5::TF1Data, TPaletteAxis, TParticle, TPrimary, TMCParticle, TProofChain, RooCurve, RooEllipse, RooHist, TChain, TNtuple, TNtupleD, TTree, TTreeSQL, TParallelCoordRange, TParallelCoordSelect, TParallelCoordVar, and TSpider.

Definition at line 45 of file TAttLine.h.

◆ Modify()

void TAttLine::Modify ( )
virtual

Change current line attributes if necessary.

Definition at line 247 of file TAttLine.cxx.

◆ ResetAttLine()

void TAttLine::ResetAttLine ( Option_t option = "")
virtual

Reset this line attributes to default values.

Reimplemented in TGWin32VirtualXProxy.

Definition at line 265 of file TAttLine.cxx.

◆ SaveLineAttributes()

void TAttLine::SaveLineAttributes ( std::ostream &  out,
const char *  name,
Int_t  coldef = 1,
Int_t  stydef = 1,
Int_t  widdef = 1 
)
virtual

Save line attributes as C++ statement(s) on output stream out.

Definition at line 275 of file TAttLine.cxx.

◆ SetLineAttributes()

void TAttLine::SetLineAttributes ( )
virtual

Invoke the DialogCanvas Line attributes.

Reimplemented in TGWin32VirtualXProxy.

Definition at line 294 of file TAttLine.cxx.

◆ SetLineColor()

◆ SetLineColorAlpha()

void TAttLine::SetLineColorAlpha ( Color_t  lcolor,
Float_t  lalpha 
)
virtual

Set a transparent line color.

Parameters
lcolordefines the line color
lalphadefines the percentage of opacity from 0. (fully transparent) to 1. (fully opaque).
Note
lalpha is ignored (treated as 1) if the TCanvas has no GL support activated.

Reimplemented in TGraphMultiErrors.

Definition at line 305 of file TAttLine.cxx.

◆ SetLineStyle()

virtual void TAttLine::SetLineStyle ( Style_t  lstyle)
inlinevirtual

◆ SetLineWidth()

◆ Streamer()

virtual void TAttLine::Streamer ( TBuffer )
virtual

Reimplemented in ROOT::Experimental::XRooFit::xRooHypoSpace, TMVA::TSpline1, TMVA::TSpline2, Jet, TStyle, TVirtualPad, TVirtualPS, TVirtualX, TGeoBatemanSol, TGeoPhysicalNode, TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly, TVirtualGeoTrack, TGeoOverlap, TGCocoa, TGQuartz, TAnnotation, TButton, TCanvas, TDialogCanvas, TGroupButton, TInspectCanvas, TPad, TPaveClass, TSlider, TSliderBox, TView, TArc, TArrow, TBox, TCandle, TCrown, TCurlyArc, TCurlyLine, TCutG, TDiamond, TEllipse, TFrame, TGaxis, TGraphPolar, TGraphPolargram, TGraphQQ, TLatex, TLegend, TLegendEntry, TLine, TPave, TPaveLabel, TPaveStats, TPavesText, TPaveText, TPieSlice, TPolyLine, TWbox, TGraphEdge, TGraphNode, TImageDump, TPDF, TPostScript, TSVG, TTeXDump, TGWin32, TGX11, TGX11TTF, TEveLine, TEveLineProjected, TEveScalableStraightLineSet, TEveStraightLineSet, TEveStraightLineSetProjected, TEveTrack, TEveTrackList, TEveTrackProjected, TEveTrackListProjected, TEveMCTrack, TBRIK, TCONE, TCONS, TCTUB, TELTU, TGTRA, THelix, THYPE, TMarker3DBox, TNode, TNodeDiv, TPARA, TPCON, TPGON, TPolyLine3D, TShape, TSPHE, TTRAP, TTRD1, TTRD2, TTUBE, TTUBS, TXTRU, TGLAxis, TGLTH3Composition, TWebPadPainter, TWebPS, THbookTree, TEfficiency, TF1, TF12, TF2, TF3, TGraph, TGraph2D, TGraph2DAsymmErrors, TGraph2DErrors, TGraphAsymmErrors, TGraphBentErrors, TGraphErrors, TGraphMultiErrors, TH1, TH1C, TH1S, TH1I, TH1L, TH1F, TH1D, TH1K, TH2, TH2C, TH2S, TH2I, TH2L, TH2F, TH2D, TH2Poly, TH3, TH3C, TH3S, TH3I, TH3L, TH3F, TH3D, TProfile, TProfile2D, TProfile2Poly, TProfile3D, TScatter, TSpline, TSpline3, TSpline5, ROOT::v5::TF1Data, TPaletteAxis, TParticle, TPrimary, TMCParticle, TProofChain, RooCurve, RooEllipse, RooHist, TChain, TNtuple, TNtupleD, TTree, TTreeSQL, TParallelCoordRange, TParallelCoordSelect, TParallelCoordVar, and TSpider.

◆ StreamerNVirtual()

void TAttLine::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 45 of file TAttLine.h.

Member Data Documentation

◆ fLineColor

Color_t TAttLine::fLineColor
protected

Line color.

Definition at line 21 of file TAttLine.h.

◆ fLineStyle

Style_t TAttLine::fLineStyle
protected

Line style.

Definition at line 22 of file TAttLine.h.

◆ fLineWidth

Width_t TAttLine::fLineWidth
protected

Line width.

Definition at line 23 of file TAttLine.h.

  • core/base/inc/TAttLine.h
  • core/base/src/TAttLine.cxx