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 SetX1(oldX1);
292 SetY1(oldY1);
293 SetX2(oldX2);
294 SetY2(oldY2);
295 gPad->Modified(kTRUE);
296 gPad->Update();
297 }
298 break;
299 }
300 if (opaque) {
301 if (ndcsav && !TestBit(kLineNDC)) {
302 SetX1((GetX1() - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1()));
303 SetX2((GetX2() - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1()));
304 SetY1((GetY1() - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1()));
305 SetY2((GetY2() - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1()));
306 SetNDC();
307 }
308 gPad->ShowGuidelines(this, event);
309 } else {
310 if (TestBit(kLineNDC)) {
311 dpx = gPad->GetX2() - gPad->GetX1();
312 dpy = gPad->GetY2() - gPad->GetY1();
313 xp1 = gPad->GetX1();
314 yp1 = gPad->GetY1();
315 if (p1) {
316 SetX1((gPad->AbsPixeltoX(px)-xp1)/dpx);
317 SetY1((gPad->AbsPixeltoY(py)-yp1)/dpy);
318 }
319 if (p2) {
320 SetX2((gPad->AbsPixeltoX(px)-xp1)/dpx);
321 SetY2((gPad->AbsPixeltoY(py)-yp1)/dpy);
322 }
323 if (pL) {
324 SetX1((gPad->AbsPixeltoX(px1)-xp1)/dpx);
325 SetY1((gPad->AbsPixeltoY(py1)-yp1)/dpy);
326 SetX2((gPad->AbsPixeltoX(px2)-xp1)/dpx);
327 SetY2((gPad->AbsPixeltoY(py2)-yp1)/dpy);
328 }
329 } else {
330 if (p1) {
331 SetX1(gPad->PadtoX(gPad->AbsPixeltoX(px)));
332 SetY1(gPad->PadtoY(gPad->AbsPixeltoY(py)));
333 }
334 if (p2) {
335 SetX2(gPad->PadtoX(gPad->AbsPixeltoX(px)));
336 SetY2(gPad->PadtoY(gPad->AbsPixeltoY(py)));
337 }
338 if (pL) {
339 SetX1(gPad->PadtoX(gPad->AbsPixeltoX(px1)));
340 SetY1(gPad->PadtoY(gPad->AbsPixeltoY(py1)));
341 SetX2(gPad->PadtoX(gPad->AbsPixeltoX(px2)));
342 SetY2(gPad->PadtoY(gPad->AbsPixeltoY(py2)));
343 }
344 }
345 if (TestBit(kVertical)) {
346 if (p1) SetX2(GetX1());
347 if (p2) SetX1(GetX2());
348 }
349 if (TestBit(kHorizontal)) {
350 if (p1) SetY2(GetY1());
351 if (p2) SetY1(GetY2());
352 }
353 gPad->Modified(kTRUE);
354 gPad->Update();
355 if (!opaque) gVirtualX->SetLineColor(-1);
356 }
357 break;
358
359 case kButton1Locate:
360
361 ExecuteEvent(kButton1Down, px, py);
362 while (true) {
363 px = py = 0;
364 event = gVirtualX->RequestLocator(1,1,px,py);
365
367
368 if (event != -1) { // button is released
369 ExecuteEvent(kButton1Up, px, py);
370 return;
371 }
372 }
373 }
374}
375
376////////////////////////////////////////////////////////////////////////////////
377/// Get the slope of this TLine
378
380{
381 Double_t m = 0;
382 if (fX2 == fX1) {
383 Error("GetSlope", "This line is vertical. The slope in undefined");
384 m = TMath::Infinity();
385 } else {
386 m = (fY2-fY1)/(fX2-fX1);
387 }
388 return m;
389}
390
391////////////////////////////////////////////////////////////////////////////////
392/// Get the Y-Intercept of this TLine
393
395{
396 Double_t b = 0;
397 if (fX2 == fX1) {
398 Error("GetYIntercept", "This line is vertical. The Y-Intercept in undefined");
399 b = TMath::Infinity();
400 } else {
401 b = (fY1*fX2-fY2*fX1)/(fX2-fX1);
402 }
403 return b;
404}
405
406////////////////////////////////////////////////////////////////////////////////
407/// List this line with its attributes.
408
409void TLine::ls(Option_t *) const
410{
412 printf("%s X1=%f Y1=%f X2=%f Y2=%f\n",IsA()->GetName(),fX1,fY1,fX2,fY2);
413}
414
415////////////////////////////////////////////////////////////////////////////////
416/// Paint this line with its current attributes.
417
419{
420 if (!gPad) return;
422 else PaintLine(gPad->XtoPad(fX1),gPad->YtoPad(fY1),gPad->XtoPad(fX2),gPad->YtoPad(fY2));
423}
424
425////////////////////////////////////////////////////////////////////////////////
426/// Draw this line with new coordinates.
427
429{
430 if (!gPad) return;
431 TAttLine::Modify(); //Change line attributes only if necessary
432 gPad->PaintLine(x1,y1,x2,y2);
433}
434
435////////////////////////////////////////////////////////////////////////////////
436/// Draw this line with new coordinates in NDC.
437
439{
440 if (!gPad) return;
441 TAttLine::Modify(); //Change line attributes only if necessary
442 gPad->PaintLineNDC(u1,v1,u2,v2);
443}
444
445////////////////////////////////////////////////////////////////////////////////
446/// Dump this line with its attributes.
447
449{
450 printf("%s X1=%f Y1=%f X2=%f Y2=%f",IsA()->GetName(),fX1,fY1,fX2,fY2);
451 if (GetLineColor() != 1) printf(" Color=%d",GetLineColor());
452 if (GetLineStyle() != 1) printf(" Style=%d",GetLineStyle());
453 if (GetLineWidth() != 1) printf(" Width=%d",GetLineWidth());
454 printf("\n");
455}
456
457////////////////////////////////////////////////////////////////////////////////
458/// Save primitive as a C++ statement(s) on output stream out
459
460void TLine::SavePrimitive(std::ostream &out, Option_t *option)
461{
462 SavePrimitiveConstructor(out, Class(), "line", TString::Format("%g, %g, %g, %g", fX1, fY1, fX2, fY2), kFALSE);
463
464 SaveLineAttributes(out, "line", 1, 1, 1);
465
466 if (TestBit(kLineNDC))
467 out << " line->SetNDC();\n";
468
469 if (TestBit(kVertical))
470 out << " line->SetBit(TLine::kVertical);\n";
471
472 if (TestBit(kHorizontal))
473 out << " line->SetBit(TLine::kHorizontal);\n";
474
475 SavePrimitiveDraw(out, "line", option);
476}
477
478////////////////////////////////////////////////////////////////////////////////
479/// Check whether this line is to be drawn horizontally.
480
485
486////////////////////////////////////////////////////////////////////////////////
487/// Check whether this line is to be drawn vertically.
488
490{
491 return TestBit(kVertical);
492}
493
494////////////////////////////////////////////////////////////////////////////////
495/// Set NDC mode on if isNDC = kTRUE, off otherwise
496
501
502////////////////////////////////////////////////////////////////////////////////
503/// Force the line to be drawn horizontally.
504/// Makes fY2 equal to fY1. The line length is kept.
505/// TArrow and TGaxis also get this function by inheritance.
506
507void TLine::SetHorizontal(Bool_t set /*= kTRUE*/)
508{
509 SetBit(kHorizontal, set);
510 if (set && gPad) {
512 Int_t px1 = gPad->XtoAbsPixel(fX1);
513 Int_t px2 = gPad->XtoAbsPixel(fX2);
514 Int_t py1 = gPad->YtoAbsPixel(fY1);
515 Int_t py2 = gPad->YtoAbsPixel(fY2);
516 Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
517 if (fX2 >= fX1) fX2 = gPad->AbsPixeltoX(px1+l);
518 else fX2 = gPad->AbsPixeltoX(px1-l);
519 fY2 = fY1;
520 }
521}
522
523////////////////////////////////////////////////////////////////////////////////
524/// Force the line to be drawn vertically.
525/// Makes fX2 equal to fX1. The line length is kept.
526/// TArrow and TGaxis also get this function by inheritance.
527
528void TLine::SetVertical(Bool_t set /*= kTRUE*/)
529{
530 SetBit(kVertical, set);
531 if (set && gPad) {
533 Int_t px1 = gPad->XtoAbsPixel(fX1);
534 Int_t px2 = gPad->XtoAbsPixel(fX2);
535 Int_t py1 = gPad->YtoAbsPixel(fY1);
536 Int_t py2 = gPad->YtoAbsPixel(fY2);
537 Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
538 if (fY2 >= fY1) fY2 = gPad->AbsPixeltoY(py1-l);
539 else fY2 = gPad->AbsPixeltoY(py1+l);
540 fX2 = fX1;
541 }
542}
543
544////////////////////////////////////////////////////////////////////////////////
545/// Stream an object of class TLine.
546
548{
549 if (R__b.IsReading()) {
551 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
552 if (R__v > 1) {
553 R__b.ReadClassBuffer(TLine::Class(), this, R__v, R__s, R__c);
554 return;
555 }
556 //====process old versions before automatic schema evolution
559 Float_t x1,y1,x2,y2;
560 R__b >> x1; fX1 = x1;
561 R__b >> y1; fY1 = y1;
562 R__b >> x2; fX2 = x2;
563 R__b >> y2; fY2 = y2;
564 //====end of old versions
565
566 } else {
567 R__b.WriteClassBuffer(TLine::Class(),this);
568 }
569}
570////////////////////////////////////////////////////////////////////////////////
571/// Return the bounding Box of the Line
572
574{
575 Rectangle_t BBox{0, 0, 0, 0};
576 if (gPad) {
577 Int_t px1 = gPad->XtoPixel(fX1);
578 Int_t px2 = gPad->XtoPixel(fX2);
579 Int_t py1 = gPad->YtoPixel(fY1);
580 Int_t py2 = gPad->YtoPixel(fY2);
581
582 if (px1 > px2) {
583 Int_t tmp = px1;
584 px1 = px2;
585 px2 = tmp;
586 }
587 if (py1 > py2) {
588 Int_t tmp = py1;
589 py1 = py2;
590 py2 = tmp;
591 }
592
593 BBox.fX = px1;
594 BBox.fY = py1;
595 BBox.fWidth = px2 - px1;
596 BBox.fHeight = py2 - py1;
597 }
598 return BBox;
599}
600
601////////////////////////////////////////////////////////////////////////////////
602/// Return the center of the BoundingBox as TPoint in pixels
603
605{
606 TPoint p(0, 0);
607 if (gPad) {
608 p.SetX(gPad->XtoPixel(TMath::Min(fX1, fX2) + 0.5 * (TMath::Max(fX1, fX2) - TMath::Min(fX1, fX2))));
609 p.SetY(gPad->YtoPixel(TMath::Min(fY1, fY2) + 0.5 * (TMath::Max(fY1, fY2) - TMath::Min(fY1, fY2))));
610 }
611 return p;
612}
613
614////////////////////////////////////////////////////////////////////////////////
615/// Set center of the BoundingBox
616
618{
619 if (!gPad) return;
622 if (fX2>fX1) {
623 this->SetX1(gPad->PixeltoX(p.GetX())-0.5*w);
624 this->SetX2(gPad->PixeltoX(p.GetX())+0.5*w);
625 }
626 else {
627 this->SetX2(gPad->PixeltoX(p.GetX())-0.5*w);
628 this->SetX1(gPad->PixeltoX(p.GetX())+0.5*w);
629 }
630 if (fY2>fY1) {
631 this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
632 this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
633 }
634 else {
635 this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
636 this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
637 }
638}
639
640////////////////////////////////////////////////////////////////////////////////
641/// Set X coordinate of the center of the BoundingBox
642
644{
645 if (!gPad) return;
647 if (fX2>fX1) {
648 this->SetX1(gPad->PixeltoX(x)-0.5*w);
649 this->SetX2(gPad->PixeltoX(x)+0.5*w);
650 }
651 else {
652 this->SetX2(gPad->PixeltoX(x)-0.5*w);
653 this->SetX1(gPad->PixeltoX(x)+0.5*w);
654 }
655}
656
657////////////////////////////////////////////////////////////////////////////////
658/// Set Y coordinate of the center of the BoundingBox
659
661{
662 if (!gPad) return;
664 if (fY2>fY1) {
665 this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
666 this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
667 }
668 else {
669 this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
670 this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
671 }
672}
673
674////////////////////////////////////////////////////////////////////////////////
675/// Set left hand side of BoundingBox to a value
676/// (resize in x direction on left)
677
679{
680 if (!gPad) return;
681 if (fX2>fX1)
682 this->SetX1(gPad->PixeltoX(x));
683 else
684 this->SetX2(gPad->PixeltoX(x));
685}
686
687////////////////////////////////////////////////////////////////////////////////
688/// Set right hand side of BoundingBox to a value
689/// (resize in x direction on right)
690
692{
693 if (!gPad) return;
694 if (fX2>fX1)
695 this->SetX2(gPad->PixeltoX(x));
696 else
697 this->SetX1(gPad->PixeltoX(x));
698}
699
700////////////////////////////////////////////////////////////////////////////////
701/// Set top of BoundingBox to a value (resize in y direction on top)
702
704{
705 if (!gPad) return;
706 if (fY2>fY1)
707 this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
708 else
709 this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
710}
711
712////////////////////////////////////////////////////////////////////////////////
713/// Set bottom of BoundingBox to a value
714/// (resize in y direction on bottom)
715
717{
718 if (!gPad) return;
719 if (fY2>fY1)
720 this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
721 else
722 this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
723}
@ 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:409
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:394
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:489
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:703
void SetVertical(Bool_t set=kTRUE)
Force the line to be drawn vertically.
Definition TLine.cxx:528
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition TLine.cxx:428
Double_t GetSlope() const
Get the slope of this TLine.
Definition TLine.cxx:379
TLine()
Definition TLine.h:38
void SetBBoxCenterY(const Int_t y) override
Set Y coordinate of the center of the BoundingBox.
Definition TLine.cxx:660
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:691
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:481
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:460
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:448
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:678
void Paint(Option_t *option="") override
Paint this line with its current attributes.
Definition TLine.cxx:418
void SetBBoxY2(const Int_t y) override
Set bottom of BoundingBox to a value (resize in y direction on bottom)
Definition TLine.cxx:716
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:604
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:438
void Streamer(TBuffer &) override
Stream an object of class TLine.
Definition TLine.cxx:547
void SetBBoxCenterX(const Int_t x) override
Set X coordinate of the center of the BoundingBox.
Definition TLine.cxx:643
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:497
void SetBBoxCenter(const TPoint &p) override
Set center of the BoundingBox.
Definition TLine.cxx:617
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:573
void SetHorizontal(Bool_t set=kTRUE)
Force the line to be drawn horizontally.
Definition TLine.cxx:507
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:2898
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