Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TLine.cxx
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#include <cstdlib>
13
14#include <iostream>
15#include "TROOT.h"
16#include "TBuffer.h"
17#include "TLine.h"
18#include "TVirtualPad.h"
19#include "TClass.h"
20#include "TVirtualPadPainter.h"
21#include "TCanvasImp.h"
22#include "TMath.h"
23#include "TPoint.h"
24
25
26/** \class TLine
27\ingroup BasicGraphics
28
29Use the TLine constructor to create a simple line.
30
31~~~ {.cpp}
32 TLine(Double_t x1,Double_t y1,Double_t x2,Double_t y2)
33~~~
34
35`x1`, `y1`, `x2`, `y2` are the coordinates of the first and the second point.
36
37_**Example**_:
38
39~~~ {.cpp}
40 root[] l = new TLine(0.2,0.2,0.8,0.3)
41 root[] l->Draw()
42~~~
43*/
44
45
46////////////////////////////////////////////////////////////////////////////////
47/// Line normal constructor.
48
54
55
56////////////////////////////////////////////////////////////////////////////////
57/// Line copy constructor.
58
60{
61 line.TLine::Copy(*this);
62}
63
64////////////////////////////////////////////////////////////////////////////////
65/// Assignment operator
66
68{
69 src.TLine::Copy(*this);
70 return *this;
71}
72
73////////////////////////////////////////////////////////////////////////////////
74/// Copy this line to line.
75
76void TLine::Copy(TObject &obj) const
77{
78 TObject::Copy(obj);
79 TAttLine::Copy(((TLine&)obj));
80 ((TLine&)obj).fX1 = fX1;
81 ((TLine&)obj).fY1 = fY1;
82 ((TLine&)obj).fX2 = fX2;
83 ((TLine&)obj).fY2 = fY2;
84}
85
86////////////////////////////////////////////////////////////////////////////////
87/// Compute distance from point px,py to a line.
88
90{
91 if (!gPad) return 9999;
92 if (!TestBit(kLineNDC)) return DistancetoLine(px,py,gPad->XtoPad(fX1),gPad->YtoPad(fY1),gPad->XtoPad(fX2),gPad->YtoPad(fY2));
93 Double_t x1 = gPad->GetX1() + fX1*(gPad->GetX2()-gPad->GetX1());
94 Double_t y1 = gPad->GetY1() + fY1*(gPad->GetY2()-gPad->GetY1());
95 Double_t x2 = gPad->GetX1() + fX2*(gPad->GetX2()-gPad->GetX1());
96 Double_t y2 = gPad->GetY1() + fY2*(gPad->GetY2()-gPad->GetY1());
97 return DistancetoLine(px,py,x1,y1,x2,y2);
98}
99
100////////////////////////////////////////////////////////////////////////////////
101/// Draw this line with new coordinates.
102
104{
105 TLine *newline = new TLine(x1, y1, x2, y2);
107 newline->SetBit(kCanDelete);
108 newline->AppendPad();
109 return newline;
110}
111
112////////////////////////////////////////////////////////////////////////////////
113/// Draw this line with new coordinates in NDC.
114
121
122////////////////////////////////////////////////////////////////////////////////
123/// Execute action corresponding to one event.
124/// This member function is called when a line is clicked with the locator
125///
126/// If Left button clicked on one of the line end points, this point
127/// follows the cursor until button is released.
128///
129/// if Middle button clicked, the line is moved parallel to itself
130/// until the button is released.
131
133{
134 if (!gPad || !gPad->IsEditable()) return;
135
136 constexpr Int_t kMaxDiff = 20;
137 static Int_t px1,px2,py1,py2,pxold,pyold;
138 static Double_t oldX1, oldY1, oldX2, oldY2;
139 static Int_t selectPoint;
140
141 auto parent = gPad;
142
143 Bool_t opaque = parent->OpaqueMoving();
144
145 auto action = [this, parent](Int_t code, Int_t _x1, Int_t _y1, Int_t _x2 = 0, Int_t _y2 = 0) {
146 Double_t x1, y1, x2, y2;
147
149
150 if (isndc) {
151 x1 = (1. * _x1 / parent->GetWw() - parent->GetAbsXlowNDC()) / parent->GetAbsWNDC();
152 y1 = ((1 - 1. * _y1 / parent->GetWh()) - parent->GetAbsYlowNDC()) / parent->GetAbsHNDC();
153 x2 = (1. * _x2 / parent->GetWw() - parent->GetAbsXlowNDC()) / parent->GetAbsWNDC();
154 y2 = ((1 - 1. * _y2 / parent->GetWh()) - parent->GetAbsYlowNDC()) / parent->GetAbsHNDC();
155 } else {
156 x1 = parent->AbsPixeltoX(_x1);
157 y1 = parent->AbsPixeltoY(_y1);
158 x2 = parent->AbsPixeltoX(_x2);
159 y2 = parent->AbsPixeltoY(_y2);
160 }
161 if (code == 0) {
162 auto pp = parent->GetPainter();
163 pp->SetAttLine(*this);
164 if (isndc)
165 pp->DrawLineNDC(x1, y1, x2, y2);
166 else
167 pp->DrawLine(x1, y1, x2, y2);
168 } else {
169 if (!isndc && parent->GetLogx()) {
170 x1 = TMath::Power(10, x1);
171 x2 = TMath::Power(10, x2);
172 }
173 if (!isndc && parent->GetLogy()) {
174 y1 = TMath::Power(10, y1);
175 y2 = TMath::Power(10, y2);
176 }
177
178 if (code & 1) {
179 SetX1(x1);
180 SetY1(y1);
181 }
182 if (code & 2) {
183 SetX2(x2);
184 SetY2(y2);
185 }
186 if (TestBit(kVertical)) {
187 if (code & 1)
188 SetX2(GetX1());
189 else
190 SetX1(GetX2());
191 }
192 if (TestBit(kHorizontal)) {
193 if (code & 1)
194 SetY2(GetY1());
195 else
196 SetY1(GetY2());
197 }
198 }
199 };
200
201 switch (event) {
202
203 case kArrowKeyPress:
204 case kButton1Down:
205 oldX1 = GetX1();
206 oldY1 = GetY1();
207 oldX2 = GetX2();
208 oldY2 = GetY2();
209
210 // No break !!!
211
212 case kMouseMotion:
213
214 if (TestBit(kLineNDC)) {
215 px1 = parent->UtoAbsPixel(GetX1());
216 py1 = parent->VtoAbsPixel(GetY1());
217 px2 = parent->UtoAbsPixel(GetX2());
218 py2 = parent->VtoAbsPixel(GetY2());
219 } else {
220 px1 = parent->XtoAbsPixel(parent->XtoPad(GetX1()));
221 py1 = parent->YtoAbsPixel(parent->YtoPad(GetY1()));
222 px2 = parent->XtoAbsPixel(parent->XtoPad(GetX2()));
223 py2 = parent->YtoAbsPixel(parent->YtoPad(GetY2()));
224 }
225
226 //simply take sum of pixels differences
227 if (abs(px1 - px) + abs(py1 - py) < kMaxDiff) { //*-*================>OK take point number 1
228 selectPoint = 1;
229 parent->SetCursor(kPointer);
230 } else if (abs(px2 - px) + abs(py2 - py) < kMaxDiff) { //*-*================>OK take point number 2
231 selectPoint = 2;
232 parent->SetCursor(kPointer);
233 } else {
234 selectPoint = 3;
235 pxold = px;
236 pyold = py;
237 parent->SetCursor(kMove);
238 }
239
240 break;
241
242 case kArrowKeyRelease:
243 case kButton1Motion:
244 if (!opaque)
245 action(0, px1, py1, px2, py2);
246 if (selectPoint == 1) {
247 px1 = px;
248 py1 = py;
249 } else if (selectPoint == 2) {
250 px2 = px;
251 py2 = py;
252 } else if (selectPoint == 3) {
253 px1 += px - pxold;
254 py1 += py - pyold;
255 px2 += px - pxold;
256 py2 += py -pyold;
257 pxold = px;
258 pyold = py;
259 }
260 action(!opaque ? 0 : selectPoint, px1, py1, px2, py2);
261 if (opaque) {
262 if (selectPoint == 1) {
263 //check in which corner the BBox is edited
264 if (GetX1() > GetX2())
265 parent->ShowGuidelines(this, event, GetY1() > GetY2() ? '2' : '3', true);
266 else
267 parent->ShowGuidelines(this, event, GetY1() > GetY2() ? '1' : '4', true);
268 } else if (selectPoint == 2) {
269 //check in which corner the BBox is edited
270 if (GetX1() > GetX2())
271 parent->ShowGuidelines(this, event, GetY1() > GetY2() ? '4' : '1', true);
272 else
273 parent->ShowGuidelines(this, event, GetY1() > GetY2() ? '3' : '2', true);
274 } else if (selectPoint == 3) {
275 parent->ShowGuidelines(this, event, 'i', true);
276 }
277 parent->Modified(kTRUE);
278 parent->Update();
279 }
280 break;
281
282 case kButton1Up:
283
284 if (gROOT->IsEscaped()) {
285 gROOT->SetEscape(kFALSE);
286 if (opaque) {
287 SetX1(oldX1);
288 SetY1(oldY1);
289 SetX2(oldX2);
290 SetY2(oldY2);
291 parent->ShowGuidelines(this, event);
292 parent->Modified(kTRUE);
293 parent->Update();
294 }
295 break;
296 }
297 if (opaque) {
298 parent->ShowGuidelines(this, event);
299 } else {
300 action(selectPoint, px1, py1, px2, py2);
301 parent->Modified(kTRUE);
302 parent->Update();
303 }
304 selectPoint = 0;
305 break;
306
307 case kButton1Locate:
308
309 // Sergey: code is never used, has to be removed in ROOT7
310 ExecuteEvent(kButton1Down, px, py);
311 while (true) {
312 px = py = 0;
313 event = parent->GetCanvasImp()->RequestLocator(px, py);
314
316
317 if (event != -1) { // button is released
318 ExecuteEvent(kButton1Up, px, py);
319 return;
320 }
321 }
322 }
323}
324
325////////////////////////////////////////////////////////////////////////////////
326/// Get the slope of this TLine
327
329{
330 Double_t m = 0;
331 if (fX2 == fX1) {
332 Error("GetSlope", "This line is vertical. The slope in undefined");
333 m = TMath::Infinity();
334 } else {
335 m = (fY2-fY1)/(fX2-fX1);
336 }
337 return m;
338}
339
340////////////////////////////////////////////////////////////////////////////////
341/// Get the Y-Intercept of this TLine
342
344{
345 Double_t b = 0;
346 if (fX2 == fX1) {
347 Error("GetYIntercept", "This line is vertical. The Y-Intercept in undefined");
348 b = TMath::Infinity();
349 } else {
350 b = (fY1*fX2-fY2*fX1)/(fX2-fX1);
351 }
352 return b;
353}
354
355////////////////////////////////////////////////////////////////////////////////
356/// List this line with its attributes.
357
358void TLine::ls(Option_t *) const
359{
361 printf("%s X1=%f Y1=%f X2=%f Y2=%f\n",IsA()->GetName(),fX1,fY1,fX2,fY2);
362}
363
364////////////////////////////////////////////////////////////////////////////////
365/// Paint this line with its current attributes.
366
368{
369 if (!gPad) return;
371 else PaintLine(gPad->XtoPad(fX1),gPad->YtoPad(fY1),gPad->XtoPad(fX2),gPad->YtoPad(fY2));
372}
373
374////////////////////////////////////////////////////////////////////////////////
375/// Draw this line with new coordinates.
376
378{
379 if (!gPad) return;
380 TAttLine::Modify(); //Change line attributes only if necessary
381 gPad->PaintLine(x1,y1,x2,y2);
382}
383
384////////////////////////////////////////////////////////////////////////////////
385/// Draw this line with new coordinates in NDC.
386
388{
389 if (!gPad) return;
390 TAttLine::Modify(); //Change line attributes only if necessary
391 gPad->PaintLineNDC(u1,v1,u2,v2);
392}
393
394////////////////////////////////////////////////////////////////////////////////
395/// Dump this line with its attributes.
396
398{
399 printf("%s X1=%f Y1=%f X2=%f Y2=%f",IsA()->GetName(),fX1,fY1,fX2,fY2);
400 if (GetLineColor() != 1) printf(" Color=%d",GetLineColor());
401 if (GetLineStyle() != 1) printf(" Style=%d",GetLineStyle());
402 if (GetLineWidth() != 1) printf(" Width=%d",GetLineWidth());
403 printf("\n");
404}
405
406////////////////////////////////////////////////////////////////////////////////
407/// Save primitive as a C++ statement(s) on output stream out
408
409void TLine::SavePrimitive(std::ostream &out, Option_t *option)
410{
411 SavePrimitiveConstructor(out, Class(), "line", TString::Format("%g, %g, %g, %g", fX1, fY1, fX2, fY2), kFALSE);
412
413 SaveLineAttributes(out, "line", 1, 1, 1);
414
415 if (TestBit(kLineNDC))
416 out << " line->SetNDC();\n";
417
418 if (TestBit(kVertical))
419 out << " line->SetBit(TLine::kVertical);\n";
420
421 if (TestBit(kHorizontal))
422 out << " line->SetBit(TLine::kHorizontal);\n";
423
424 SavePrimitiveDraw(out, "line", option);
425}
426
427////////////////////////////////////////////////////////////////////////////////
428/// Check whether this line is to be drawn horizontally.
429
434
435////////////////////////////////////////////////////////////////////////////////
436/// Check whether this line is to be drawn vertically.
437
439{
440 return TestBit(kVertical);
441}
442
443////////////////////////////////////////////////////////////////////////////////
444/// Set NDC mode on if isNDC = kTRUE, off otherwise
445
450
451////////////////////////////////////////////////////////////////////////////////
452/// Force the line to be drawn horizontally.
453/// Makes fY2 equal to fY1. The line length is kept.
454/// TArrow and TGaxis also get this function by inheritance.
455
456void TLine::SetHorizontal(Bool_t set /*= kTRUE*/)
457{
458 SetBit(kHorizontal, set);
459 if (set && gPad) {
461 Int_t px1 = gPad->XtoAbsPixel(fX1);
462 Int_t px2 = gPad->XtoAbsPixel(fX2);
463 Int_t py1 = gPad->YtoAbsPixel(fY1);
464 Int_t py2 = gPad->YtoAbsPixel(fY2);
465 Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
466 if (fX2 >= fX1) fX2 = gPad->AbsPixeltoX(px1+l);
467 else fX2 = gPad->AbsPixeltoX(px1-l);
468 fY2 = fY1;
469 }
470}
471
472////////////////////////////////////////////////////////////////////////////////
473/// Force the line to be drawn vertically.
474/// Makes fX2 equal to fX1. The line length is kept.
475/// TArrow and TGaxis also get this function by inheritance.
476
477void TLine::SetVertical(Bool_t set /*= kTRUE*/)
478{
479 SetBit(kVertical, set);
480 if (set && gPad) {
482 Int_t px1 = gPad->XtoAbsPixel(fX1);
483 Int_t px2 = gPad->XtoAbsPixel(fX2);
484 Int_t py1 = gPad->YtoAbsPixel(fY1);
485 Int_t py2 = gPad->YtoAbsPixel(fY2);
486 Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
487 if (fY2 >= fY1) fY2 = gPad->AbsPixeltoY(py1-l);
488 else fY2 = gPad->AbsPixeltoY(py1+l);
489 fX2 = fX1;
490 }
491}
492
493////////////////////////////////////////////////////////////////////////////////
494/// Stream an object of class TLine.
495
497{
498 if (R__b.IsReading()) {
500 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
501 if (R__v > 1) {
502 R__b.ReadClassBuffer(TLine::Class(), this, R__v, R__s, R__c);
503 return;
504 }
505 //====process old versions before automatic schema evolution
508 Float_t x1,y1,x2,y2;
509 R__b >> x1; fX1 = x1;
510 R__b >> y1; fY1 = y1;
511 R__b >> x2; fX2 = x2;
512 R__b >> y2; fY2 = y2;
513 //====end of old versions
514
515 } else {
516 R__b.WriteClassBuffer(TLine::Class(),this);
517 }
518}
519////////////////////////////////////////////////////////////////////////////////
520/// Return the bounding Box of the Line
521
523{
524 Rectangle_t BBox{0, 0, 0, 0};
525 if (gPad) {
526 Int_t px1 = gPad->XtoPixel(fX1);
527 Int_t px2 = gPad->XtoPixel(fX2);
528 Int_t py1 = gPad->YtoPixel(fY1);
529 Int_t py2 = gPad->YtoPixel(fY2);
530
531 if (px1 > px2) {
532 Int_t tmp = px1;
533 px1 = px2;
534 px2 = tmp;
535 }
536 if (py1 > py2) {
537 Int_t tmp = py1;
538 py1 = py2;
539 py2 = tmp;
540 }
541
542 BBox.fX = px1;
543 BBox.fY = py1;
544 BBox.fWidth = px2 - px1;
545 BBox.fHeight = py2 - py1;
546 }
547 return BBox;
548}
549
550////////////////////////////////////////////////////////////////////////////////
551/// Return the center of the BoundingBox as TPoint in pixels
552
554{
555 TPoint p(0, 0);
556 if (gPad) {
557 p.SetX(gPad->XtoPixel(TMath::Min(fX1, fX2) + 0.5 * (TMath::Max(fX1, fX2) - TMath::Min(fX1, fX2))));
558 p.SetY(gPad->YtoPixel(TMath::Min(fY1, fY2) + 0.5 * (TMath::Max(fY1, fY2) - TMath::Min(fY1, fY2))));
559 }
560 return p;
561}
562
563////////////////////////////////////////////////////////////////////////////////
564/// Set center of the BoundingBox
565
567{
568 if (!gPad) return;
571 if (fX2>fX1) {
572 this->SetX1(gPad->PixeltoX(p.GetX())-0.5*w);
573 this->SetX2(gPad->PixeltoX(p.GetX())+0.5*w);
574 }
575 else {
576 this->SetX2(gPad->PixeltoX(p.GetX())-0.5*w);
577 this->SetX1(gPad->PixeltoX(p.GetX())+0.5*w);
578 }
579 if (fY2>fY1) {
580 this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
581 this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
582 }
583 else {
584 this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
585 this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
586 }
587}
588
589////////////////////////////////////////////////////////////////////////////////
590/// Set X coordinate of the center of the BoundingBox
591
593{
594 if (!gPad) return;
596 if (fX2>fX1) {
597 this->SetX1(gPad->PixeltoX(x)-0.5*w);
598 this->SetX2(gPad->PixeltoX(x)+0.5*w);
599 }
600 else {
601 this->SetX2(gPad->PixeltoX(x)-0.5*w);
602 this->SetX1(gPad->PixeltoX(x)+0.5*w);
603 }
604}
605
606////////////////////////////////////////////////////////////////////////////////
607/// Set Y coordinate of the center of the BoundingBox
608
610{
611 if (!gPad) return;
613 if (fY2>fY1) {
614 this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
615 this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
616 }
617 else {
618 this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
619 this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
620 }
621}
622
623////////////////////////////////////////////////////////////////////////////////
624/// Set left hand side of BoundingBox to a value
625/// (resize in x direction on left)
626
628{
629 if (!gPad) return;
630 if (fX2>fX1)
631 this->SetX1(gPad->PixeltoX(x));
632 else
633 this->SetX2(gPad->PixeltoX(x));
634}
635
636////////////////////////////////////////////////////////////////////////////////
637/// Set right hand side of BoundingBox to a value
638/// (resize in x direction on right)
639
641{
642 if (!gPad) return;
643 if (fX2>fX1)
644 this->SetX2(gPad->PixeltoX(x));
645 else
646 this->SetX1(gPad->PixeltoX(x));
647}
648
649////////////////////////////////////////////////////////////////////////////////
650/// Set top of BoundingBox to a value (resize in y direction on top)
651
653{
654 if (!gPad) return;
655 if (fY2>fY1)
656 this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
657 else
658 this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
659}
660
661////////////////////////////////////////////////////////////////////////////////
662/// Set bottom of BoundingBox to a value
663/// (resize in y direction on bottom)
664
666{
667 if (!gPad) return;
668 if (fY2>fY1)
669 this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
670 else
671 this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
672}
@ kMouseMotion
Definition Buttons.h:23
@ kArrowKeyRelease
Definition Buttons.h:21
@ kButton1Motion
Definition Buttons.h:20
@ kButton1Up
Definition Buttons.h:19
@ kArrowKeyPress
Definition Buttons.h:21
@ kButton1Down
Definition Buttons.h:17
@ kButton1Locate
Definition Buttons.h:22
@ kMove
Definition GuiTypes.h:375
@ kPointer
Definition GuiTypes.h:376
#define b(i)
Definition RSha256.hxx:100
#define h(i)
Definition RSha256.hxx:106
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
short Version_t
Class version identifier (short)
Definition RtypesCore.h:79
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
#define gROOT
Definition TROOT.h:421
#define gPad
Abstract base class for elements drawn in the editor.
Definition TAttBBox2D.h:19
Line Attributes class.
Definition TAttLine.h:21
virtual void Streamer(TBuffer &)
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:36
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:38
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:37
virtual void Modify()
Change current line attributes if necessary.
Definition TAttLine.cxx:246
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Definition TAttLine.cxx:176
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.
Definition TAttLine.cxx:210
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.
Definition TAttLine.cxx:289
Buffer base class used for serializing objects.
Definition TBuffer.h:43
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:358
virtual void SetY2(Double_t y2)
Definition TLine.h:70
static TClass * Class()
Double_t fY1
Y of 1st point.
Definition TLine.h:26
Double_t fX1
X of 1st point.
Definition TLine.h:25
Double_t GetYIntercept() const
Get the Y-Intercept of this TLine.
Definition TLine.cxx:343
virtual void SetX2(Double_t x2)
Definition TLine.h:68
@ kLineNDC
Use NDC coordinates.
Definition TLine.h:33
@ kHorizontal
Line is horizontal.
Definition TLine.h:35
@ kVertical
Line is vertical.
Definition TLine.h:34
Bool_t IsVertical()
Check whether this line is to be drawn vertically.
Definition TLine.cxx:438
virtual TLine * DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition TLine.cxx:103
void SetBBoxY1(const Int_t y) override
Set top of BoundingBox to a value (resize in y direction on top)
Definition TLine.cxx:652
void SetVertical(Bool_t set=kTRUE)
Force the line to be drawn vertically.
Definition TLine.cxx:477
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition TLine.cxx:377
Double_t GetSlope() const
Get the slope of this TLine.
Definition TLine.cxx:328
TLine()
Definition TLine.h:38
void SetBBoxCenterY(const Int_t y) override
Set Y coordinate of the center of the BoundingBox.
Definition TLine.cxx:609
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:640
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:115
Bool_t IsHorizontal()
Check whether this line is to be drawn horizontally.
Definition TLine.cxx:430
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:409
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:397
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:627
void Paint(Option_t *option="") override
Paint this line with its current attributes.
Definition TLine.cxx:367
void SetBBoxY2(const Int_t y) override
Set bottom of BoundingBox to a value (resize in y direction on bottom)
Definition TLine.cxx:665
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:553
virtual void SetX1(Double_t x1)
Definition TLine.h:67
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:387
void Streamer(TBuffer &) override
Stream an object of class TLine.
Definition TLine.cxx:496
void SetBBoxCenterX(const Int_t x) override
Set X coordinate of the center of the BoundingBox.
Definition TLine.cxx:592
TClass * IsA() const override
Definition TLine.h:81
virtual void SetY1(Double_t y1)
Definition TLine.h:69
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Definition TLine.cxx:446
void SetBBoxCenter(const TPoint &p) override
Set center of the BoundingBox.
Definition TLine.cxx:566
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TLine.cxx:132
Double_t GetX1() const
Definition TLine.h:50
Rectangle_t GetBBox() override
Return the bounding Box of the Line.
Definition TLine.cxx:522
void SetHorizontal(Bool_t set=kTRUE)
Force the line to be drawn horizontally.
Definition TLine.cxx:456
Double_t GetY2() const
Definition TLine.h:53
Mother of all ROOT objects.
Definition TObject.h:42
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:459
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:994
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:885
virtual void Copy(TObject &object) const
Copy this to obj.
Definition TObject.cxx:156
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1095
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
Definition TObject.cxx:842
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
Definition TObject.cxx:774
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:71
SCoord_t GetY() const
Definition TPoint.h:47
SCoord_t GetX() const
Definition TPoint.h:46
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:2910
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2384
TLine * line
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Definition TMath.h:732
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
Double_t Infinity()
Returns an infinity as defined by the IEEE standard.
Definition TMath.h:928
Rectangle structure (maps to the X11 XRectangle structure)
Definition GuiTypes.h:362
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4