Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include "TObject.h"
17#include "TAttLine.h"
18#include "TAttBBox2D.h"
19
20class TPoint;
21
22class TLine : public TObject, public TAttLine, public TAttBBox2D {
23
24protected:
25 Double_t fX1{0}; ///< X of 1st point
26 Double_t fY1{0}; ///< Y of 1st point
27 Double_t fX2{0}; ///< X of 2nd point
28 Double_t fY2{0}; ///< Y of 2nd point
29
30public:
31 // TLine status bits
32 enum {
33 kLineNDC = BIT(14), ///< Use NDC coordinates
34 kVertical = BIT(15), ///< Line is vertical
35 kHorizontal = BIT(16) ///< Line is horizontal
36 };
37
38 TLine() {}
40 TLine(const TLine &line);
41 virtual ~TLine() = default;
42
43 TLine &operator=(const TLine &src);
44
45 void Copy(TObject &line) const override;
46 Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
49 void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
50 Double_t GetX1() const {return fX1;}
51 Double_t GetX2() const {return fX2;}
52 Double_t GetY1() const {return fY1;}
53 Double_t GetY2() const {return fY2;}
56 void ls(Option_t *option="") const override;
57 void Paint(Option_t *option="") override;
59 virtual void PaintLineNDC(Double_t u1, Double_t v1,Double_t u2, Double_t v2);
60 void Print(Option_t *option="") const override;
61 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
62 virtual void SetNDC(Bool_t isNDC=kTRUE);
63 void SetHorizontal(Bool_t set = kTRUE); // *TOGGLE* *GETTER=IsHorizontal
64 void SetVertical(Bool_t set = kTRUE); // *TOGGLE* *GETTER=IsVertical
65 virtual void SetX1(Double_t x1) {fX1=x1;}
66 virtual void SetX2(Double_t x2) {fX2=x2;}
67 virtual void SetY1(Double_t y1) {fY1=y1;}
68 virtual void SetY2(Double_t y2) {fY2=y2;}
69 Rectangle_t GetBBox() override;
70 TPoint GetBBoxCenter() override;
71 void SetBBoxCenter(const TPoint &p) override;
72 void SetBBoxCenterX(const Int_t x) override;
73 void SetBBoxCenterY(const Int_t y) override;
74 void SetBBoxX1(const Int_t x) override;
75 void SetBBoxX2(const Int_t x) override;
76 void SetBBoxY1(const Int_t y) override;
77 void SetBBoxY2(const Int_t y) override;
78
79 ClassDefOverride(TLine,3) //A line segment
80};
81
82#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:85
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
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 DrawLine
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Option_t Option_t TPoint TPoint const char y1
Abstract base class for elements drawn in the editor.
Definition TAttBBox2D.h:19
Line Attributes class.
Definition TAttLine.h:18
Use the TLine constructor to create a simple line.
Definition TLine.h:22
void ls(Option_t *option="") const override
List this line with its attributes.
Definition TLine.cxx:379
virtual void SetY2(Double_t y2)
Definition TLine.h:68
Double_t fY1
Y of 1st point.
Definition TLine.h:26
Double_t fX1
X of 1st point.
Definition TLine.h:25
virtual void SetX2(Double_t x2)
Definition TLine.h:66
Bool_t IsVertical()
Check whether this line is to be drawn vertically.
Definition TLine.cxx:455
void SetBBoxY1(const Int_t y) override
Set top of BoundingBox to a value (resize in y direction on top)
Definition TLine.cxx:656
void SetVertical(Bool_t set=kTRUE)
Force the line to be drawn vertically.
Definition TLine.cxx:495
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition TLine.cxx:397
TLine()
Definition TLine.h:38
void SetBBoxCenterY(const Int_t y) override
Set Y coordinate of the center of the BoundingBox.
Definition TLine.cxx:616
void SetBBoxX2(const Int_t x) override
Set right hand side of BoundingBox to a value (resize in x direction on right)
Definition TLine.cxx:645
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:114
Bool_t IsHorizontal()
Check whether this line is to be drawn horizontally.
Definition TLine.cxx:447
Double_t GetY1() const
Definition TLine.h:52
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TLine.cxx:427
void Copy(TObject &line) const override
Copy this line to line.
Definition TLine.cxx:76
Double_t GetX2() const
Definition TLine.h:51
void Print(Option_t *option="") const override
Dump this line with its attributes.
Definition TLine.cxx:415
Double_t fX2
X of 2nd point.
Definition TLine.h:27
void SetBBoxX1(const Int_t x) override
Set left hand side of BoundingBox to a value (resize in x direction on left)
Definition TLine.cxx:633
void Paint(Option_t *option="") override
Paint this line with its current attributes.
Definition TLine.cxx:388
void SetBBoxY2(const Int_t y) override
Set bottom of BoundingBox to a value (resize in y direction on bottom)
Definition TLine.cxx:668
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a line.
Definition TLine.cxx:89
TPoint GetBBoxCenter() override
Return the center of the BoundingBox as TPoint in pixels.
Definition TLine.cxx:564
@ kLineNDC
Use NDC coordinates.
Definition TLine.h:33
@ kHorizontal
Line is horizontal.
Definition TLine.h:35
@ kVertical
Line is vertical.
Definition TLine.h:34
virtual void SetX1(Double_t x1)
Definition TLine.h:65
TLine & operator=(const TLine &src)
Assignment operator.
Definition TLine.cxx:67
Double_t fY2
Y of 2nd point.
Definition TLine.h:28
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:406
void SetBBoxCenterX(const Int_t x) override
Set X coordinate of the center of the BoundingBox.
Definition TLine.cxx:600
virtual void SetY1(Double_t y1)
Definition TLine.h:67
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Definition TLine.cxx:463
virtual ~TLine()=default
void SetBBoxCenter(const TPoint &p) override
Set center of the BoundingBox.
Definition TLine.cxx:575
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TLine.cxx:131
Double_t GetX1() const
Definition TLine.h:50
Rectangle_t GetBBox() override
Return the bounding Box of the Line.
Definition TLine.cxx:540
void SetHorizontal(Bool_t set=kTRUE)
Force the line to be drawn horizontally.
Definition TLine.cxx:474
Double_t GetY2() const
Definition TLine.h:53
Mother of all ROOT objects.
Definition TObject.h:41
TLine * line
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Rectangle structure (maps to the X11 XRectangle structure)
Definition GuiTypes.h:361