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 "TVirtualX.h"
21#include "TMath.h"
22#include "TPoint.h"
23
24
25/** \class TLine
26\ingroup BasicGraphics
27
28Use the TLine constructor to create a simple line.
29
30~~~ {.cpp}
31 TLine(Double_t x1,Double_t y1,Double_t x2,Double_t y2)
32~~~
33
34`x1`, `y1`, `x2`, `y2` are the coordinates of the first and the second point.
35
36_**Example**_:
37
38~~~ {.cpp}
39 root[] l = new TLine(0.2,0.2,0.8,0.3)
40 root[] l->Draw()
41~~~
42*/
43
44
45////////////////////////////////////////////////////////////////////////////////
46/// Line normal constructor.
47
53
54
55////////////////////////////////////////////////////////////////////////////////
56/// Line copy constructor.
57
59{
60 line.TLine::Copy(*this);
61}
62
63////////////////////////////////////////////////////////////////////////////////
64/// Assignment operator
65
67{
68 src.TLine::Copy(*this);
69 return *this;
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// Copy this line to line.
74
75void TLine::Copy(TObject &obj) const
76{
77 TObject::Copy(obj);
78 TAttLine::Copy(((TLine&)obj));
79 ((TLine&)obj).fX1 = fX1;
80 ((TLine&)obj).fY1 = fY1;
81 ((TLine&)obj).fX2 = fX2;
82 ((TLine&)obj).fY2 = fY2;
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Compute distance from point px,py to a line.
87
89{
90 if (!gPad) return 9999;
91 if (!TestBit(kLineNDC)) return DistancetoLine(px,py,gPad->XtoPad(fX1),gPad->YtoPad(fY1),gPad->XtoPad(fX2),gPad->YtoPad(fY2));
92 Double_t x1 = gPad->GetX1() + fX1*(gPad->GetX2()-gPad->GetX1());
93 Double_t y1 = gPad->GetY1() + fY1*(gPad->GetY2()-gPad->GetY1());
94 Double_t x2 = gPad->GetX1() + fX2*(gPad->GetX2()-gPad->GetX1());
95 Double_t y2 = gPad->GetY1() + fY2*(gPad->GetY2()-gPad->GetY1());
96 return DistancetoLine(px,py,x1,y1,x2,y2);
97}
98
99////////////////////////////////////////////////////////////////////////////////
100/// Draw this line with new coordinates.
101
103{
104 TLine *newline = new TLine(x1, y1, x2, y2);
106 newline->SetBit(kCanDelete);
107 newline->AppendPad();
108 return newline;
109}
110
111////////////////////////////////////////////////////////////////////////////////
112/// Draw this line with new coordinates in NDC.
113
120
121////////////////////////////////////////////////////////////////////////////////
122/// Execute action corresponding to one event.
123/// This member function is called when a line is clicked with the locator
124///
125/// If Left button clicked on one of the line end points, this point
126/// follows the cursor until button is released.
127///
128/// if Middle button clicked, the line is moved parallel to itself
129/// until the button is released.
130
132{
133 if (!gPad) return;
134
135 Int_t kMaxDiff = 20;
136 static Int_t d1,d2,px1,px2,py1,py2;
138 static Double_t oldX1, oldY1, oldX2, oldY2;
139 static Bool_t p1, p2, pL, ndcsav;
141 Int_t dx, dy;
142
143 Bool_t opaque = gPad->OpaqueMoving();
144
145 if (!gPad->IsEditable()) return;
146
147 switch (event) {
148
149 case kArrowKeyPress:
150 case kButton1Down:
151 oldX1 = GetX1();
152 oldY1 = GetY1();
153 oldX2 = GetX2();
154 oldY2 = GetY2();
156 if (!opaque) {
157 gVirtualX->SetLineColor(-1);
158 TAttLine::Modify(); //Change line attributes only if necessary
159 }
160
161 // No break !!!
162
163 case kMouseMotion:
164
165 if (TestBit(kLineNDC)) {
166 px1 = gPad->UtoPixel(GetX1());
167 py1 = gPad->VtoPixel(GetY1());
168 px2 = gPad->UtoPixel(GetX2());
169 py2 = gPad->VtoPixel(GetY2());
170 } else {
171 px1 = gPad->XtoAbsPixel(gPad->XtoPad(GetX1()));
172 py1 = gPad->YtoAbsPixel(gPad->YtoPad(GetY1()));
173 px2 = gPad->XtoAbsPixel(gPad->XtoPad(GetX2()));
174 py2 = gPad->YtoAbsPixel(gPad->YtoPad(GetY2()));
175 }
176 p1 = p2 = pL = kFALSE;
177
178 d1 = abs(px1 - px) + abs(py1-py); //simply take sum of pixels differences
179 if (d1 < kMaxDiff) { //*-*================>OK take point number 1
180 px1old = px1; py1old = py1;
181 p1 = kTRUE;
182 gPad->SetCursor(kPointer);
183 return;
184 }
185 d2 = abs(px2 - px) + abs(py2-py); //simply take sum of pixels differences
186 if (d2 < kMaxDiff) { //*-*================>OK take point number 2
187 px2old = px2; py2old = py2;
188 p2 = kTRUE;
189 gPad->SetCursor(kPointer);
190 return;
191 }
192
193 pL = kTRUE;
194 pxold = px; pyold = py;
195 gPad->SetCursor(kMove);
196
197 break;
198
199 case kArrowKeyRelease:
200 case kButton1Motion:
201
202 if (p1) {
203 if (!opaque) {
204 gVirtualX->DrawLine(px1old, py1old, px2, py2);
205 gVirtualX->DrawLine(px, py, px2, py2);
206 } else {
207 if (ndcsav) {
208 SetNDC(kFALSE);
209 SetX2(gPad->GetX1() + oldX2*(gPad->GetX2()-gPad->GetX1()));
210 SetY2(gPad->GetY1() + oldY2*(gPad->GetY2()-gPad->GetY1()));
211 }
212 SetX1(gPad->AbsPixeltoX(px));
213 SetY1(gPad->AbsPixeltoY(py));
214 }
215 px1old = px;
216 py1old = py;
217 }
218 if (p2) {
219 if (!opaque) {
220 gVirtualX->DrawLine(px1, py1, px2old, py2old);
221 gVirtualX->DrawLine(px1, py1, px, py);
222 } else {
223 if (ndcsav) {
224 SetNDC(kFALSE);
225 SetX1(gPad->GetX1() + oldX1*(gPad->GetX2()-gPad->GetX1()));
226 SetY1(gPad->GetY1() + oldY1*(gPad->GetY2()-gPad->GetY1()));
227 }
228 SetX2(gPad->AbsPixeltoX(px));
229 SetY2(gPad->AbsPixeltoY(py));
230 }
231 px2old = px;
232 py2old = py;
233 }
234 if (pL) {
235 if (!opaque) gVirtualX->DrawLine(px1, py1, px2, py2);
236 dx = px-pxold; dy = py-pyold;
237 px1 += dx; py1 += dy; px2 += dx; py2 += dy;
238 if (!opaque) gVirtualX->DrawLine(px1, py1, px2, py2);
239 pxold = px;
240 pyold = py;
241 if (opaque) {
242 if (ndcsav) SetNDC(kFALSE);
243 SetX1(gPad->AbsPixeltoX(px1));
244 SetY1(gPad->AbsPixeltoY(py1));
245 SetX2(gPad->AbsPixeltoX(px2));
246 SetY2(gPad->AbsPixeltoY(py2));
247 }
248 }
249 if (opaque) {
250 if (p1) {
251 //check in which corner the BBox is edited
252 if (GetX1() > GetX2()) {
253 if (GetY1() > GetY2())
254 gPad->ShowGuidelines(this, event, '2', true);
255 else
256 gPad->ShowGuidelines(this, event, '3', true);
257 } else {
258 if (GetY1() > GetY2())
259 gPad->ShowGuidelines(this, event, '1', true);
260 else
261 gPad->ShowGuidelines(this, event, '4', true);
262 }
263 }
264 if (p2) {
265 //check in which corner the BBox is edited
266 if (GetX1() > GetX2()) {
267 if (GetY1() > GetY2())
268 gPad->ShowGuidelines(this, event, '4', true);
269 else
270 gPad->ShowGuidelines(this, event, '1', true);
271 } else {
272 if (GetY1() > GetY2())
273 gPad->ShowGuidelines(this, event, '3', true);
274 else
275 gPad->ShowGuidelines(this, event, '2', true);
276 }
277 }
278 if (pL) {
279 gPad->ShowGuidelines(this, event, 'i', true);
280 }
281 gPad->Modified(kTRUE);
282 gPad->Update();
283 }
284 break;
285
286 case kButton1Up:
287
288 if (gROOT->IsEscaped()) {
289 gROOT->SetEscape(kFALSE);
290 if (opaque) {
291 gPad->ShowGuidelines(this, event);
292 SetX1(oldX1);
293 SetY1(oldY1);
294 SetX2(oldX2);
295 SetY2(oldY2);
296 SetNDC(ndcsav);
297 gPad->Modified(kTRUE);
298 gPad->Update();
299 }
300 break;
301 }
302 if (opaque) {
303 if (ndcsav && !TestBit(kLineNDC)) {
304 SetX1((GetX1() - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1()));
305 SetX2((GetX2() - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1()));
306 SetY1((GetY1() - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1()));
307 SetY2((GetY2() - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1()));
308 SetNDC();
309 }
310 gPad->ShowGuidelines(this, event);
311 } else {
312 if (TestBit(kLineNDC)) {
313 dpx = gPad->GetX2() - gPad->GetX1();
314 dpy = gPad->GetY2() - gPad->GetY1();
315 xp1 = gPad->GetX1();
316 yp1 = gPad->GetY1();
317 if (p1) {
318 SetX1((gPad->AbsPixeltoX(px)-xp1)/dpx);
319 SetY1((gPad->AbsPixeltoY(py)-yp1)/dpy);
320 }
321 if (p2) {
322 SetX2((gPad->AbsPixeltoX(px)-xp1)/dpx);
323 SetY2((gPad->AbsPixeltoY(py)-yp1)/dpy);
324 }
325 if (pL) {
326 SetX1((gPad->AbsPixeltoX(px1)-xp1)/dpx);
327 SetY1((gPad->AbsPixeltoY(py1)-yp1)/dpy);
328 SetX2((gPad->AbsPixeltoX(px2)-xp1)/dpx);
329 SetY2((gPad->AbsPixeltoY(py2)-yp1)/dpy);
330 }
331 } else {
332 if (p1) {
333 SetX1(gPad->PadtoX(gPad->AbsPixeltoX(px)));
334 SetY1(gPad->PadtoY(gPad->AbsPixeltoY(py)));
335 }
336 if (p2) {
337 SetX2(gPad->PadtoX(gPad->AbsPixeltoX(px)));
338 SetY2(gPad->PadtoY(gPad->AbsPixeltoY(py)));
339 }
340 if (pL) {
341 SetX1(gPad->PadtoX(gPad->AbsPixeltoX(px1)));
342 SetY1(gPad->PadtoY(gPad->AbsPixeltoY(py1)));
343 SetX2(gPad->PadtoX(gPad->AbsPixeltoX(px2)));
344 SetY2(gPad->PadtoY(gPad->AbsPixeltoY(py2)));
345 }
346 }
347 if (TestBit(kVertical)) {
348 if (p1) SetX2(GetX1());
349 if (p2) SetX1(GetX2());
350 }
351 if (TestBit(kHorizontal)) {
352 if (p1) SetY2(GetY1());
353 if (p2) SetY1(GetY2());
354 }
355 gPad->Modified(kTRUE);
356 gPad->Update();
357 if (!opaque) gVirtualX->SetLineColor(-1);
358 }
359 break;
360
361 case kButton1Locate:
362
363 ExecuteEvent(kButton1Down, px, py);
364 while (true) {
365 px = py = 0;
366 event = gVirtualX->RequestLocator(1,1,px,py);
367
369
370 if (event != -1) { // button is released
371 ExecuteEvent(kButton1Up, px, py);
372 return;
373 }
374 }
375 }
376}
377
378////////////////////////////////////////////////////////////////////////////////
379/// Get the slope of this TLine
380
382{
383 Double_t m = 0;
384 if (fX2 == fX1) {
385 Error("GetSlope", "This line is vertical. The slope in undefined");
386 m = TMath::Infinity();
387 } else {
388 m = (fY2-fY1)/(fX2-fX1);
389 }
390 return m;
391}
392
393////////////////////////////////////////////////////////////////////////////////
394/// Get the Y-Intercept of this TLine
395
397{
398 Double_t b = 0;
399 if (fX2 == fX1) {
400 Error("GetYIntercept", "This line is vertical. The Y-Intercept in undefined");
401 b = TMath::Infinity();
402 } else {
403 b = (fY1*fX2-fY2*fX1)/(fX2-fX1);
404 }
405 return b;
406}
407
408////////////////////////////////////////////////////////////////////////////////
409/// List this line with its attributes.
410
411void TLine::ls(Option_t *) const
412{
414 printf("%s X1=%f Y1=%f X2=%f Y2=%f\n",IsA()->GetName(),fX1,fY1,fX2,fY2);
415}
416
417////////////////////////////////////////////////////////////////////////////////
418/// Paint this line with its current attributes.
419
421{
422 if (!gPad) return;
424 else PaintLine(gPad->XtoPad(fX1),gPad->YtoPad(fY1),gPad->XtoPad(fX2),gPad->YtoPad(fY2));
425}
426
427////////////////////////////////////////////////////////////////////////////////
428/// Draw this line with new coordinates.
429
431{
432 if (!gPad) return;
433 TAttLine::Modify(); //Change line attributes only if necessary
434 gPad->PaintLine(x1,y1,x2,y2);
435}
436
437////////////////////////////////////////////////////////////////////////////////
438/// Draw this line with new coordinates in NDC.
439
441{
442 if (!gPad) return;
443 TAttLine::Modify(); //Change line attributes only if necessary
444 gPad->PaintLineNDC(u1,v1,u2,v2);
445}
446
447////////////////////////////////////////////////////////////////////////////////
448/// Dump this line with its attributes.
449
451{
452 printf("%s X1=%f Y1=%f X2=%f Y2=%f",IsA()->GetName(),fX1,fY1,fX2,fY2);
453 if (GetLineColor() != 1) printf(" Color=%d",GetLineColor());
454 if (GetLineStyle() != 1) printf(" Style=%d",GetLineStyle());
455 if (GetLineWidth() != 1) printf(" Width=%d",GetLineWidth());
456 printf("\n");
457}
458
459////////////////////////////////////////////////////////////////////////////////
460/// Save primitive as a C++ statement(s) on output stream out
461
462void TLine::SavePrimitive(std::ostream &out, Option_t *option)
463{
464 SavePrimitiveConstructor(out, Class(), "line", TString::Format("%g, %g, %g, %g", fX1, fY1, fX2, fY2), kFALSE);
465
466 SaveLineAttributes(out, "line", 1, 1, 1);
467
468 if (TestBit(kLineNDC))
469 out << " line->SetNDC();\n";
470
471 if (TestBit(kVertical))
472 out << " line->SetBit(TLine::kVertical);\n";
473
474 if (TestBit(kHorizontal))
475 out << " line->SetBit(TLine::kHorizontal);\n";
476
477 SavePrimitiveDraw(out, "line", option);
478}
479
480////////////////////////////////////////////////////////////////////////////////
481/// Check whether this line is to be drawn horizontally.
482
487
488////////////////////////////////////////////////////////////////////////////////
489/// Check whether this line is to be drawn vertically.
490
492{
493 return TestBit(kVertical);
494}
495
496////////////////////////////////////////////////////////////////////////////////
497/// Set NDC mode on if isNDC = kTRUE, off otherwise
498
503
504////////////////////////////////////////////////////////////////////////////////
505/// Force the line to be drawn horizontally.
506/// Makes fY2 equal to fY1. The line length is kept.
507/// TArrow and TGaxis also get this function by inheritance.
508
509void TLine::SetHorizontal(Bool_t set /*= kTRUE*/)
510{
511 SetBit(kHorizontal, set);
512 if (set && gPad) {
514 Int_t px1 = gPad->XtoAbsPixel(fX1);
515 Int_t px2 = gPad->XtoAbsPixel(fX2);
516 Int_t py1 = gPad->YtoAbsPixel(fY1);
517 Int_t py2 = gPad->YtoAbsPixel(fY2);
518 Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
519 if (fX2 >= fX1) fX2 = gPad->AbsPixeltoX(px1+l);
520 else fX2 = gPad->AbsPixeltoX(px1-l);
521 fY2 = fY1;
522 }
523}
524
525////////////////////////////////////////////////////////////////////////////////
526/// Force the line to be drawn vertically.
527/// Makes fX2 equal to fX1. The line length is kept.
528/// TArrow and TGaxis also get this function by inheritance.
529
530void TLine::SetVertical(Bool_t set /*= kTRUE*/)
531{
532 SetBit(kVertical, set);
533 if (set && gPad) {
535 Int_t px1 = gPad->XtoAbsPixel(fX1);
536 Int_t px2 = gPad->XtoAbsPixel(fX2);
537 Int_t py1 = gPad->YtoAbsPixel(fY1);
538 Int_t py2 = gPad->YtoAbsPixel(fY2);
539 Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
540 if (fY2 >= fY1) fY2 = gPad->AbsPixeltoY(py1-l);
541 else fY2 = gPad->AbsPixeltoY(py1+l);
542 fX2 = fX1;
543 }
544}
545
546////////////////////////////////////////////////////////////////////////////////
547/// Stream an object of class TLine.
548
550{
551 if (R__b.IsReading()) {
553 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
554 if (R__v > 1) {
555 R__b.ReadClassBuffer(TLine::Class(), this, R__v, R__s, R__c);
556 return;
557 }
558 //====process old versions before automatic schema evolution
561 Float_t x1,y1,x2,y2;
562 R__b >> x1; fX1 = x1;
563 R__b >> y1; fY1 = y1;
564 R__b >> x2; fX2 = x2;
565 R__b >> y2; fY2 = y2;
566 //====end of old versions
567
568 } else {
569 R__b.WriteClassBuffer(TLine::Class(),this);
570 }
571}
572////////////////////////////////////////////////////////////////////////////////
573/// Return the bounding Box of the Line
574
576{
577 Rectangle_t BBox{0, 0, 0, 0};
578 if (gPad) {
579 Int_t px1 = gPad->XtoPixel(fX1);
580 Int_t px2 = gPad->XtoPixel(fX2);
581 Int_t py1 = gPad->YtoPixel(fY1);
582 Int_t py2 = gPad->YtoPixel(fY2);
583
584 if (px1 > px2) {
585 Int_t tmp = px1;
586 px1 = px2;
587 px2 = tmp;
588 }
589 if (py1 > py2) {
590 Int_t tmp = py1;
591 py1 = py2;
592 py2 = tmp;
593 }
594
595 BBox.fX = px1;
596 BBox.fY = py1;
597 BBox.fWidth = px2 - px1;
598 BBox.fHeight = py2 - py1;
599 }
600 return BBox;
601}
602
603////////////////////////////////////////////////////////////////////////////////
604/// Return the center of the BoundingBox as TPoint in pixels
605
607{
608 TPoint p(0, 0);
609 if (gPad) {
610 p.SetX(gPad->XtoPixel(TMath::Min(fX1, fX2) + 0.5 * (TMath::Max(fX1, fX2) - TMath::Min(fX1, fX2))));
611 p.SetY(gPad->YtoPixel(TMath::Min(fY1, fY2) + 0.5 * (TMath::Max(fY1, fY2) - TMath::Min(fY1, fY2))));
612 }
613 return p;
614}
615
616////////////////////////////////////////////////////////////////////////////////
617/// Set center of the BoundingBox
618
620{
621 if (!gPad) return;
624 if (fX2>fX1) {
625 this->SetX1(gPad->PixeltoX(p.GetX())-0.5*w);
626 this->SetX2(gPad->PixeltoX(p.GetX())+0.5*w);
627 }
628 else {
629 this->SetX2(gPad->PixeltoX(p.GetX())-0.5*w);
630 this->SetX1(gPad->PixeltoX(p.GetX())+0.5*w);
631 }
632 if (fY2>fY1) {
633 this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
634 this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
635 }
636 else {
637 this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
638 this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
639 }
640}
641
642////////////////////////////////////////////////////////////////////////////////
643/// Set X coordinate of the center of the BoundingBox
644
646{
647 if (!gPad) return;
649 if (fX2>fX1) {
650 this->SetX1(gPad->PixeltoX(x)-0.5*w);
651 this->SetX2(gPad->PixeltoX(x)+0.5*w);
652 }
653 else {
654 this->SetX2(gPad->PixeltoX(x)-0.5*w);
655 this->SetX1(gPad->PixeltoX(x)+0.5*w);
656 }
657}
658
659////////////////////////////////////////////////////////////////////////////////
660/// Set Y coordinate of the center of the BoundingBox
661
663{
664 if (!gPad) return;
666 if (fY2>fY1) {
667 this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
668 this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
669 }
670 else {
671 this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
672 this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
673 }
674}
675
676////////////////////////////////////////////////////////////////////////////////
677/// Set left hand side of BoundingBox to a value
678/// (resize in x direction on left)
679
681{
682 if (!gPad) return;
683 if (fX2>fX1)
684 this->SetX1(gPad->PixeltoX(x));
685 else
686 this->SetX2(gPad->PixeltoX(x));
687}
688
689////////////////////////////////////////////////////////////////////////////////
690/// Set right hand side of BoundingBox to a value
691/// (resize in x direction on right)
692
694{
695 if (!gPad) return;
696 if (fX2>fX1)
697 this->SetX2(gPad->PixeltoX(x));
698 else
699 this->SetX1(gPad->PixeltoX(x));
700}
701
702////////////////////////////////////////////////////////////////////////////////
703/// Set top of BoundingBox to a value (resize in y direction on top)
704
706{
707 if (!gPad) return;
708 if (fY2>fY1)
709 this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
710 else
711 this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
712}
713
714////////////////////////////////////////////////////////////////////////////////
715/// Set bottom of BoundingBox to a value
716/// (resize in y direction on bottom)
717
719{
720 if (!gPad) return;
721 if (fY2>fY1)
722 this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
723 else
724 this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
725}
@ 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:374
@ kPointer
Definition GuiTypes.h:375
#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:411
#define gPad
#define gVirtualX
Definition TVirtualX.h:337
Abstract base class for elements drawn in the editor.
Definition TAttBBox2D.h:19
Line Attributes class.
Definition TAttLine.h:20
virtual void Streamer(TBuffer &)
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:35
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:37
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:36
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:274
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:411
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:396
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:491
virtual TLine * DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition TLine.cxx:102
void SetBBoxY1(const Int_t y) override
Set top of BoundingBox to a value (resize in y direction on top)
Definition TLine.cxx:705
void SetVertical(Bool_t set=kTRUE)
Force the line to be drawn vertically.
Definition TLine.cxx:530
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition TLine.cxx:430
Double_t GetSlope() const
Get the slope of this TLine.
Definition TLine.cxx:381
TLine()
Definition TLine.h:38
void SetBBoxCenterY(const Int_t y) override
Set Y coordinate of the center of the BoundingBox.
Definition TLine.cxx:662
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:693
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:483
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:462
void Copy(TObject &line) const override
Copy this line to line.
Definition TLine.cxx:75
Double_t GetX2() const
Definition TLine.h:51
void Print(Option_t *option="") const override
Dump this line with its attributes.
Definition TLine.cxx:450
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:680
void Paint(Option_t *option="") override
Paint this line with its current attributes.
Definition TLine.cxx:420
void SetBBoxY2(const Int_t y) override
Set bottom of BoundingBox to a value (resize in y direction on bottom)
Definition TLine.cxx:718
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a line.
Definition TLine.cxx:88
TPoint GetBBoxCenter() override
Return the center of the BoundingBox as TPoint in pixels.
Definition TLine.cxx:606
virtual void SetX1(Double_t x1)
Definition TLine.h:67
TLine & operator=(const TLine &src)
Assignment operator.
Definition TLine.cxx:66
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:440
void Streamer(TBuffer &) override
Stream an object of class TLine.
Definition TLine.cxx:549
void SetBBoxCenterX(const Int_t x) override
Set X coordinate of the center of the BoundingBox.
Definition TLine.cxx:645
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:499
void SetBBoxCenter(const TPoint &p) override
Set center of the BoundingBox.
Definition TLine.cxx:619
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:575
void SetHorizontal(Bool_t set=kTRUE)
Force the line to be drawn horizontally.
Definition TLine.cxx:509
Double_t GetY2() const
Definition TLine.h:53
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:457
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:202
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:972
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:864
virtual void Copy(TObject &object) const
Copy this to obj.
Definition TObject.cxx:159
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
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:822
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:771
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:68
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:2900
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:251
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:199
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:361
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4