ROOT  6.06/09
Reference Guide
TLine.h
Go to the documentation of this file.
1 // @(#)root/graf:$Id$
2 // Author: Rene Brun 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_TLine
13 #define ROOT_TLine
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TLine //
19 // //
20 // A line segment. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #ifndef ROOT_TObject
25 #include "TObject.h"
26 #endif
27 #ifndef ROOT_TAttLine
28 #include "TAttLine.h"
29 #endif
30 #ifndef ROOT_TAttBBox2D
31 #include "TAttBBox2D.h"
32 #endif
33 #ifndef ROOT_TPoint
34 #include "TPoint.h"
35 #endif
36 #ifndef ROOT_GuiTypes
37 #include "GuiTypes.h"
38 #endif
39 
40 
41 class TLine : public TObject, public TAttLine, public TAttBBox2D {
42 
43 protected:
44  Double_t fX1; //X of 1st point
45  Double_t fY1; //Y of 1st point
46  Double_t fX2; //X of 2nd point
47  Double_t fY2; //Y of 2nd point
48 
49 public:
50  // TLine status bits
51  enum {
52  kLineNDC = BIT(14), // Use NDC coordinates
53  kVertical = BIT(15), // Line is vertical
54  kHorizontal = BIT(16) // Line is horizontal
55  };
56 
57  TLine();
59  TLine(const TLine &line);
60  virtual ~TLine();
61 
62  void Copy(TObject &line) const;
63  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
66  virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
67  Double_t GetX1() const {return fX1;}
68  Double_t GetX2() const {return fX2;}
69  Double_t GetY1() const {return fY1;}
70  Double_t GetY2() const {return fY2;}
73  virtual void ls(Option_t *option="") const;
74  virtual void Paint(Option_t *option="");
75  virtual void PaintLine(Double_t x1, Double_t y1,Double_t x2, Double_t y2);
76  virtual void PaintLineNDC(Double_t u1, Double_t v1,Double_t u2, Double_t v2);
77  virtual void Print(Option_t *option="") const;
78  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
79  virtual void SetNDC(Bool_t isNDC=kTRUE);
80  void SetHorizontal(Bool_t set = kTRUE); // *TOGGLE* *GETTER=IsHorizontal
81  void SetVertical(Bool_t set = kTRUE); // *TOGGLE* *GETTER=IsVertical
82  virtual void SetX1(Double_t x1) {fX1=x1;}
83  virtual void SetX2(Double_t x2) {fX2=x2;}
84  virtual void SetY1(Double_t y1) {fY1=y1;}
85  virtual void SetY2(Double_t y2) {fY2=y2;}
86  virtual Rectangle_t GetBBox();
87  virtual TPoint GetBBoxCenter();
88  virtual void SetBBoxCenter(const TPoint &p);
89  virtual void SetBBoxCenterX(const Int_t x);
90  virtual void SetBBoxCenterY(const Int_t y);
91  virtual void SetBBoxX1(const Int_t x);
92  virtual void SetBBoxX2(const Int_t x);
93  virtual void SetBBoxY1(const Int_t y);
94  virtual void SetBBoxY2(const Int_t y);
95 
96  ClassDef(TLine,3) //A line segment
97 };
98 
99 #endif
virtual void SetY2(Double_t y2)
Definition: TLine.h:85
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TLine.cxx:122
virtual void Print(Option_t *option="") const
Dump this line with its attributes.
Definition: TLine.cxx:398
Double_t fX1
Definition: TLine.h:44
const Double_t * v1
Definition: TArcBall.cxx:33
ClassDef(TAttBBox2D, 0)
TLine * line
Double_t GetX1() const
Definition: TLine.h:67
const char Option_t
Definition: RtypesCore.h:62
#define BIT(n)
Definition: Rtypes.h:120
virtual void SetBBoxY2(const Int_t y)
Set bottom of BoundingBox to a value (resize in y direction on bottom)
Definition: TLine.cxx:649
virtual TLine * DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition: TLine.cxx:93
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a line.
Definition: TLine.cxx:80
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Double_t fX2
Definition: TLine.h:46
void SetHorizontal(Bool_t set=kTRUE)
Force the line to be drawn horizontally.
Definition: TLine.cxx:455
Bool_t IsVertical()
Check whether this line is to be drawn vertically.
Definition: TLine.cxx:436
virtual void SetBBoxY1(const Int_t y)
Set top of BoundingBox to a value (resize in y direction on top)
Definition: TLine.cxx:637
Bool_t IsHorizontal()
Check whether this line is to be drawn horizontally.
Definition: TLine.cxx:428
static const double x2[5]
virtual void PaintLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2)
Draw this line with new coordinates in NDC.
Definition: TLine.cxx:389
Double_t x[n]
Definition: legend1.C:17
Double_t GetY2() const
Definition: TLine.h:70
virtual void ls(Option_t *option="") const
List this line with its attributes.
Definition: TLine.cxx:362
virtual void Paint(Option_t *option="")
Paint this line with its current attributes.
Definition: TLine.cxx:371
virtual void SetBBoxX1(const Int_t x)
Set left hand side of BoundingBox to a value (resize in x direction on left)
Definition: TLine.cxx:614
char * out
Definition: TBase64.cxx:29
Definition: TPoint.h:33
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition: TLine.cxx:380
virtual void SetX2(Double_t x2)
Definition: TLine.h:83
virtual TPoint GetBBoxCenter()
Return the center of the BoundingBox as TPoint in pixels.
Definition: TLine.cxx:545
virtual void SetY1(Double_t y1)
Definition: TLine.h:84
virtual void SetBBoxCenterX(const Int_t x)
Set X coordinate of the center of the BoundingBox.
Definition: TLine.cxx:581
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TLine.cxx:410
Double_t fY1
Definition: TLine.h:45
A simple line.
Definition: TLine.h:41
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Definition: TLine.cxx:444
Double_t GetX2() const
Definition: TLine.h:68
virtual void SetX1(Double_t x1)
Definition: TLine.h:82
virtual void SetBBoxX2(const Int_t x)
Set right hand side of BoundingBox to a value (resize in x direction on right)
Definition: TLine.cxx:626
static const double x1[5]
double Double_t
Definition: RtypesCore.h:55
virtual Rectangle_t GetBBox()
Return the bounding Box of the Line.
Definition: TLine.cxx:521
Double_t y[n]
Definition: legend1.C:17
void SetVertical(Bool_t set=kTRUE)
Force the line to be drawn vertically.
Definition: TLine.cxx:476
virtual void SetBBoxCenterY(const Int_t y)
Set Y coordinate of the center of the BoundingBox.
Definition: TLine.cxx:597
virtual TLine * DrawLineNDC(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates in NDC.
Definition: TLine.cxx:105
void Copy(TObject &line) const
Copy this line to line.
Definition: TLine.cxx:67
Mother of all ROOT objects.
Definition: TObject.h:58
Abstract base class for elements drawn in the editor.
Definition: TAttBBox2D.h:23
Double_t GetY1() const
Definition: TLine.h:69
Double_t fY2
Definition: TLine.h:47
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual ~TLine()
Line default destructor.
Definition: TLine.cxx:51
Line Attributes class.
Definition: TAttLine.h:32
virtual void SetBBoxCenter(const TPoint &p)
Set center of the BoundingBox.
Definition: TLine.cxx:556