Logo ROOT  
Reference Guide

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 a transparency of 35%. The color kBlue itself remains fully opaque.

histo->SetLineColorAlpha(kBlue, 0.35);

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.

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:

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");

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. More...
 TAttLine (Color_t lcolor, Style_t lstyle, Width_t lwidth)
 AttLine normal constructor. More...
virtual ~TAttLine ()
 AttLine destructor. More...
void Copy (TAttLine &attline) const
 Copy this line attributes to a new TAttLine. More...
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. More...
virtual void Modify ()
 Change current line attributes if necessary. More...
virtual void ResetAttLine (Option_t *option="")
 Reset this line attributes to default values. More...
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. More...
virtual void SetLineAttributes ()
 Invoke the DialogCanvas Line attributes. More...
virtual void SetLineColorAlpha (Color_t lcolor, Float_t lalpha)
 Set a transparent line color. More...

Protected Attributes

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

#include <TAttLine.h>

Inheritance diagram for TAttLine:

Constructor & Destructor Documentation

◆ TAttLine() [1/2]

TAttLine::TAttLine ( )

AttLine default constructor.

Definition at line 138 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 155 of file TAttLine.cxx.

◆ ~TAttLine()

TAttLine::~TAttLine ( )

AttLine destructor.

Definition at line 165 of file TAttLine.cxx.

Member Function Documentation

◆ Copy()

void TAttLine::Copy ( TAttLine attline) const

Copy this line attributes to a new TAttLine.

Definition at line 172 of file TAttLine.cxx.

◆ 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.


A(x1,y1) P B(x2,y2)
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

Definition at line 206 of file TAttLine.cxx.

◆ Modify()

void TAttLine::Modify ( )

Change current line attributes if necessary.

Definition at line 242 of file TAttLine.cxx.

◆ ResetAttLine()

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

Reset this line attributes to default values.

Reimplemented in TGWin32VirtualXProxy.

Definition at line 260 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 

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

Definition at line 270 of file TAttLine.cxx.

◆ SetLineAttributes()

void TAttLine::SetLineAttributes ( )

Invoke the DialogCanvas Line attributes.

Reimplemented in TGWin32VirtualXProxy.

Definition at line 290 of file TAttLine.cxx.

◆ SetLineColorAlpha()

void TAttLine::SetLineColorAlpha ( Color_t  lcolor,
Float_t  lalpha 

Set a transparent line color.

lalpha defines the percentage of the color opacity from 0. (fully transparent) to 1. (fully opaque).

Definition at line 299 of file TAttLine.cxx.

Member Data Documentation

◆ fLineColor

Color_t TAttLine::fLineColor

Line color.

Definition at line 27 of file TAttLine.h.

◆ fLineStyle

Style_t TAttLine::fLineStyle

Line style.

Definition at line 28 of file TAttLine.h.

◆ fLineWidth

Width_t TAttLine::fLineWidth

Line width.

Definition at line 29 of file TAttLine.h.

The documentation for this class was generated from the following files:
#define c(i)
Definition: RSha256.hxx:119
@ kSolid
Definition: TAttLine.h:48
void SetLineStyleString(Int_t i, const char *text)
Set line style string using the PostScript convention.
Definition: TStyle.cxx:1434
static double P[]
Definition: SpecFuncCephes.cxx:285
Double_t x[n]
Definition: legend1.C:17
static double A[]
Definition: SpecFuncCephes.cxx:170
@ v
Definition: rootcling_impl.cxx:3635
#define b(i)
Definition: RSha256.hxx:118
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
static double C[]
Definition: SpecFuncCephes.cxx:187
@ kDashDotted
Definition: TAttLine.h:48
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
static constexpr double us
Definition: TGeant4SystemOfUnits.h:170
auto * a
Definition: textangle.C:12
Double_t y[n]
Definition: legend1.C:17
@ kBlue
Definition: Rtypes.h:66
#define d(i)
Definition: RSha256.hxx:120
@ kDashed
Definition: TAttLine.h:48
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
static double B[]
Definition: SpecFuncCephes.cxx:178
@ kDotted
Definition: TAttLine.h:48