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
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) return;
135
136 Int_t kMaxDiff = 20;
137 static Int_t d1,d2,px1,px2,py1,py2;
139 static Double_t oldX1, oldY1, oldX2, oldY2;
140 static Bool_t p1, p2, pL, ndcsav;
142 Int_t dx, dy;
143
144 Bool_t opaque = gPad->OpaqueMoving();
145
146 if (!gPad->IsEditable()) return;
147
148 switch (event) {
149
150 case kArrowKeyPress:
151 case kButton1Down:
152 oldX1 = GetX1();
153 oldY1 = GetY1();
154 oldX2 = GetX2();
155 oldY2 = GetY2();
157 if (!opaque) {
158 gVirtualX->SetLineColor(-1);
159 TAttLine::Modify(); //Change line attributes only if necessary
160 }
161
162 // No break !!!
163
164 case kMouseMotion:
165
166 if (TestBit(kLineNDC)) {
167 px1 = gPad->UtoPixel(GetX1());
168 py1 = gPad->VtoPixel(GetY1());
169 px2 = gPad->UtoPixel(GetX2());
170 py2 = gPad->VtoPixel(GetY2());
171 } else {
172 px1 = gPad->XtoAbsPixel(gPad->XtoPad(GetX1()));
173 py1 = gPad->YtoAbsPixel(gPad->YtoPad(GetY1()));
174 px2 = gPad->XtoAbsPixel(gPad->XtoPad(GetX2()));
175 py2 = gPad->YtoAbsPixel(gPad->YtoPad(GetY2()));
176 }
177 p1 = p2 = pL = kFALSE;
178
179 d1 = abs(px1 - px) + abs(py1-py); //simply take sum of pixels differences
180 if (d1 < kMaxDiff) { //*-*================>OK take point number 1
181 px1old = px1; py1old = py1;
182 p1 = kTRUE;
183 gPad->SetCursor(kPointer);
184 return;
185 }
186 d2 = abs(px2 - px) + abs(py2-py); //simply take sum of pixels differences
187 if (d2 < kMaxDiff) { //*-*================>OK take point number 2
188 px2old = px2; py2old = py2;
189 p2 = kTRUE;
190 gPad->SetCursor(kPointer);
191 return;
192 }
193
194 pL = kTRUE;
195 pxold = px; pyold = py;
196 gPad->SetCursor(kMove);
197
198 break;
199
200 case kArrowKeyRelease:
201 case kButton1Motion:
202
203 if (p1) {
204 if (!opaque) {
205 gVirtualX->DrawLine(px1old, py1old, px2, py2);
206 gVirtualX->DrawLine(px, py, px2, py2);
207 } else {
208 if (ndcsav) {
209 SetNDC(kFALSE);
210 SetX2(gPad->GetX1() + oldX2*(gPad->GetX2()-gPad->GetX1()));
211 SetY2(gPad->GetY1() + oldY2*(gPad->GetY2()-gPad->GetY1()));
212 }
213 SetX1(gPad->AbsPixeltoX(px));
214 SetY1(gPad->AbsPixeltoY(py));
215 }
216 px1old = px;
217 py1old = py;
218 }
219 if (p2) {
220 if (!opaque) {
221 gVirtualX->DrawLine(px1, py1, px2old, py2old);
222 gVirtualX->DrawLine(px1, py1, px, py);
223 } else {
224 if (ndcsav) {
225 SetNDC(kFALSE);
226 SetX1(gPad->GetX1() + oldX1*(gPad->GetX2()-gPad->GetX1()));
227 SetY1(gPad->GetY1() + oldY1*(gPad->GetY2()-gPad->GetY1()));
228 }
229 SetX2(gPad->AbsPixeltoX(px));
230 SetY2(gPad->AbsPixeltoY(py));
231 }
232 px2old = px;
233 py2old = py;
234 }
235 if (pL) {
236 if (!opaque) gVirtualX->DrawLine(px1, py1, px2, py2);
237 dx = px-pxold; dy = py-pyold;
238 px1 += dx; py1 += dy; px2 += dx; py2 += dy;
239 if (!opaque) gVirtualX->DrawLine(px1, py1, px2, py2);
240 pxold = px;
241 pyold = py;
242 if (opaque) {
243 if (ndcsav) SetNDC(kFALSE);
244 SetX1(gPad->AbsPixeltoX(px1));
245 SetY1(gPad->AbsPixeltoY(py1));
246 SetX2(gPad->AbsPixeltoX(px2));
247 SetY2(gPad->AbsPixeltoY(py2));
248 }
249 }
250 if (opaque) {
251 if (p1) {
252 //check in which corner the BBox is edited
253 if (GetX1() > GetX2()) {
254 if (GetY1() > GetY2())
255 gPad->ShowGuidelines(this, event, '2', true);
256 else
257 gPad->ShowGuidelines(this, event, '3', true);
258 } else {
259 if (GetY1() > GetY2())
260 gPad->ShowGuidelines(this, event, '1', true);
261 else
262 gPad->ShowGuidelines(this, event, '4', true);
263 }
264 }
265 if (p2) {
266 //check in which corner the BBox is edited
267 if (GetX1() > GetX2()) {
268 if (GetY1() > GetY2())
269 gPad->ShowGuidelines(this, event, '4', true);
270 else
271 gPad->ShowGuidelines(this, event, '1', true);
272 } else {
273 if (GetY1() > GetY2())
274 gPad->ShowGuidelines(this, event, '3', true);
275 else
276 gPad->ShowGuidelines(this, event, '2', true);
277 }
278 }
279 if (pL) {
280 gPad->ShowGuidelines(this, event, 'i', true);
281 }
282 gPad->Modified(kTRUE);
283 gPad->Update();
284 }
285 break;
286
287 case kButton1Up:
288
289 if (gROOT->IsEscaped()) {
290 gROOT->SetEscape(kFALSE);
291 if (opaque) {
292 SetX1(oldX1);
293 SetY1(oldY1);
294 SetX2(oldX2);
295 SetY2(oldY2);
296 gPad->Modified(kTRUE);
297 gPad->Update();
298 }
299 break;
300 }
301 if (opaque) {
302 if (ndcsav && !TestBit(kLineNDC)) {
303 SetX1((GetX1() - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1()));
304 SetX2((GetX2() - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1()));
305 SetY1((GetY1() - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1()));
306 SetY2((GetY2() - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1()));
307 SetNDC();
308 }
309 gPad->ShowGuidelines(this, event);
310 } else {
311 if (TestBit(kLineNDC)) {
312 dpx = gPad->GetX2() - gPad->GetX1();
313 dpy = gPad->GetY2() - gPad->GetY1();
314 xp1 = gPad->GetX1();
315 yp1 = gPad->GetY1();
316 if (p1) {
317 SetX1((gPad->AbsPixeltoX(px)-xp1)/dpx);
318 SetY1((gPad->AbsPixeltoY(py)-yp1)/dpy);
319 }
320 if (p2) {
321 SetX2((gPad->AbsPixeltoX(px)-xp1)/dpx);
322 SetY2((gPad->AbsPixeltoY(py)-yp1)/dpy);
323 }
324 if (pL) {
325 SetX1((gPad->AbsPixeltoX(px1)-xp1)/dpx);
326 SetY1((gPad->AbsPixeltoY(py1)-yp1)/dpy);
327 SetX2((gPad->AbsPixeltoX(px2)-xp1)/dpx);
328 SetY2((gPad->AbsPixeltoY(py2)-yp1)/dpy);
329 }
330 } else {
331 if (p1) {
332 SetX1(gPad->PadtoX(gPad->AbsPixeltoX(px)));
333 SetY1(gPad->PadtoY(gPad->AbsPixeltoY(py)));
334 }
335 if (p2) {
336 SetX2(gPad->PadtoX(gPad->AbsPixeltoX(px)));
337 SetY2(gPad->PadtoY(gPad->AbsPixeltoY(py)));
338 }
339 if (pL) {
340 SetX1(gPad->PadtoX(gPad->AbsPixeltoX(px1)));
341 SetY1(gPad->PadtoY(gPad->AbsPixeltoY(py1)));
342 SetX2(gPad->PadtoX(gPad->AbsPixeltoX(px2)));
343 SetY2(gPad->PadtoY(gPad->AbsPixeltoY(py2)));
344 }
345 }
346 if (TestBit(kVertical)) {
347 if (p1) SetX2(GetX1());
348 if (p2) SetX1(GetX2());
349 }
350 if (TestBit(kHorizontal)) {
351 if (p1) SetY2(GetY1());
352 if (p2) SetY1(GetY2());
353 }
354 gPad->Modified(kTRUE);
355 gPad->Update();
356 if (!opaque) gVirtualX->SetLineColor(-1);
357 }
358 break;
359
360 case kButton1Locate:
361
362 ExecuteEvent(kButton1Down, px, py);
363 while (true) {
364 px = py = 0;
365 event = gVirtualX->RequestLocator(1,1,px,py);
366
368
369 if (event != -1) { // button is released
370 ExecuteEvent(kButton1Up, px, py);
371 return;
372 }
373 }
374 }
375}
376
377////////////////////////////////////////////////////////////////////////////////
378/// Get the slope of this TLine
379
381{
382 Double_t m = 0;
383 if (fX2 == fX1) {
384 Error("GetSlope", "This line is vertical. The slope in undefined");
385 m = TMath::Infinity();
386 } else {
387 m = (fY2-fY1)/(fX2-fX1);
388 }
389 return m;
390}
391
392////////////////////////////////////////////////////////////////////////////////
393/// Get the Y-Intercept of this TLine
394
396{
397 Double_t b = 0;
398 if (fX2 == fX1) {
399 Error("GetYIntercept", "This line is vertical. The Y-Intercept in undefined");
400 b = TMath::Infinity();
401 } else {
402 b = (fY1*fX2-fY2*fX1)/(fX2-fX1);
403 }
404 return b;
405}
406
407////////////////////////////////////////////////////////////////////////////////
408/// List this line with its attributes.
409
410void TLine::ls(Option_t *) const
411{
413 printf("%s X1=%f Y1=%f X2=%f Y2=%f\n",IsA()->GetName(),fX1,fY1,fX2,fY2);
414}
415
416////////////////////////////////////////////////////////////////////////////////
417/// Paint this line with its current attributes.
418
420{
421 if (!gPad) return;
423 else PaintLine(gPad->XtoPad(fX1),gPad->YtoPad(fY1),gPad->XtoPad(fX2),gPad->YtoPad(fY2));
424}
425
426////////////////////////////////////////////////////////////////////////////////
427/// Draw this line with new coordinates.
428
430{
431 if (!gPad) return;
432 TAttLine::Modify(); //Change line attributes only if necessary
433 gPad->PaintLine(x1,y1,x2,y2);
434}
435
436////////////////////////////////////////////////////////////////////////////////
437/// Draw this line with new coordinates in NDC.
438
440{
441 if (!gPad) return;
442 TAttLine::Modify(); //Change line attributes only if necessary
443 gPad->PaintLineNDC(u1,v1,u2,v2);
444}
445
446////////////////////////////////////////////////////////////////////////////////
447/// Dump this line with its attributes.
448
450{
451 printf("%s X1=%f Y1=%f X2=%f Y2=%f",IsA()->GetName(),fX1,fY1,fX2,fY2);
452 if (GetLineColor() != 1) printf(" Color=%d",GetLineColor());
453 if (GetLineStyle() != 1) printf(" Style=%d",GetLineStyle());
454 if (GetLineWidth() != 1) printf(" Width=%d",GetLineWidth());
455 printf("\n");
456}
457
458////////////////////////////////////////////////////////////////////////////////
459/// Save primitive as a C++ statement(s) on output stream out
460
461void TLine::SavePrimitive(std::ostream &out, Option_t *option)
462{
463 SavePrimitiveConstructor(out, Class(), "line", TString::Format("%g, %g, %g, %g", fX1, fY1, fX2, fY2), kFALSE);
464
465 SaveLineAttributes(out, "line", 1, 1, 1);
466
467 if (TestBit(kLineNDC))
468 out << " line->SetNDC();\n";
469
470 if (TestBit(kVertical))
471 out << " line->SetBit(TLine::kVertical);\n";
472
473 if (TestBit(kHorizontal))
474 out << " line->SetBit(TLine::kHorizontal);\n";
475
476 SavePrimitiveDraw(out, "line", option);
477}
478
479////////////////////////////////////////////////////////////////////////////////
480/// Check whether this line is to be drawn horizontally.
481
486
487////////////////////////////////////////////////////////////////////////////////
488/// Check whether this line is to be drawn vertically.
489
491{
492 return TestBit(kVertical);
493}
494
495////////////////////////////////////////////////////////////////////////////////
496/// Set NDC mode on if isNDC = kTRUE, off otherwise
497
502
503////////////////////////////////////////////////////////////////////////////////
504/// Force the line to be drawn horizontally.
505/// Makes fY2 equal to fY1. The line length is kept.
506/// TArrow and TGaxis also get this function by inheritance.
507
508void TLine::SetHorizontal(Bool_t set /*= kTRUE*/)
509{
510 SetBit(kHorizontal, set);
511 if (set && gPad) {
513 Int_t px1 = gPad->XtoAbsPixel(fX1);
514 Int_t px2 = gPad->XtoAbsPixel(fX2);
515 Int_t py1 = gPad->YtoAbsPixel(fY1);
516 Int_t py2 = gPad->YtoAbsPixel(fY2);
517 Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
518 if (fX2 >= fX1) fX2 = gPad->AbsPixeltoX(px1+l);
519 else fX2 = gPad->AbsPixeltoX(px1-l);
520 fY2 = fY1;
521 }
522}
523
524////////////////////////////////////////////////////////////////////////////////
525/// Force the line to be drawn vertically.
526/// Makes fX2 equal to fX1. The line length is kept.
527/// TArrow and TGaxis also get this function by inheritance.
528
529void TLine::SetVertical(Bool_t set /*= kTRUE*/)
530{
531 SetBit(kVertical, set);
532 if (set && gPad) {
534 Int_t px1 = gPad->XtoAbsPixel(fX1);
535 Int_t px2 = gPad->XtoAbsPixel(fX2);
536 Int_t py1 = gPad->YtoAbsPixel(fY1);
537 Int_t py2 = gPad->YtoAbsPixel(fY2);
538 Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
539 if (fY2 >= fY1) fY2 = gPad->AbsPixeltoY(py1-l);
540 else fY2 = gPad->AbsPixeltoY(py1+l);
541 fX2 = fX1;
542 }
543}
544
545////////////////////////////////////////////////////////////////////////////////
546/// Stream an object of class TLine.
547
549{
550 if (R__b.IsReading()) {
552 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
553 if (R__v > 1) {
554 R__b.ReadClassBuffer(TLine::Class(), this, R__v, R__s, R__c);
555 return;
556 }
557 //====process old versions before automatic schema evolution
560 Float_t x1,y1,x2,y2;
561 R__b >> x1; fX1 = x1;
562 R__b >> y1; fY1 = y1;
563 R__b >> x2; fX2 = x2;
564 R__b >> y2; fY2 = y2;
565 //====end of old versions
566
567 } else {
568 R__b.WriteClassBuffer(TLine::Class(),this);
569 }
570}
571////////////////////////////////////////////////////////////////////////////////
572/// Return the bounding Box of the Line
573
575{
576 Rectangle_t BBox{0, 0, 0, 0};
577 if (gPad) {
578 Int_t px1 = gPad->XtoPixel(fX1);
579 Int_t px2 = gPad->XtoPixel(fX2);
580 Int_t py1 = gPad->YtoPixel(fY1);
581 Int_t py2 = gPad->YtoPixel(fY2);
582
583 if (px1 > px2) {
584 Int_t tmp = px1;
585 px1 = px2;
586 px2 = tmp;
587 }
588 if (py1 > py2) {
589 Int_t tmp = py1;
590 py1 = py2;
591 py2 = tmp;
592 }
593
594 BBox.fX = px1;
595 BBox.fY = py1;
596 BBox.fWidth = px2 - px1;
597 BBox.fHeight = py2 - py1;
598 }
599 return BBox;
600}
601
602////////////////////////////////////////////////////////////////////////////////
603/// Return the center of the BoundingBox as TPoint in pixels
604
606{
607 TPoint p(0, 0);
608 if (gPad) {
609 p.SetX(gPad->XtoPixel(TMath::Min(fX1, fX2) + 0.5 * (TMath::Max(fX1, fX2) - TMath::Min(fX1, fX2))));
610 p.SetY(gPad->YtoPixel(TMath::Min(fY1, fY2) + 0.5 * (TMath::Max(fY1, fY2) - TMath::Min(fY1, fY2))));
611 }
612 return p;
613}
614
615////////////////////////////////////////////////////////////////////////////////
616/// Set center of the BoundingBox
617
619{
620 if (!gPad) return;
623 if (fX2>fX1) {
624 this->SetX1(gPad->PixeltoX(p.GetX())-0.5*w);
625 this->SetX2(gPad->PixeltoX(p.GetX())+0.5*w);
626 }
627 else {
628 this->SetX2(gPad->PixeltoX(p.GetX())-0.5*w);
629 this->SetX1(gPad->PixeltoX(p.GetX())+0.5*w);
630 }
631 if (fY2>fY1) {
632 this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
633 this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
634 }
635 else {
636 this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
637 this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
638 }
639}
640
641////////////////////////////////////////////////////////////////////////////////
642/// Set X coordinate of the center of the BoundingBox
643
645{
646 if (!gPad) return;
648 if (fX2>fX1) {
649 this->SetX1(gPad->PixeltoX(x)-0.5*w);
650 this->SetX2(gPad->PixeltoX(x)+0.5*w);
651 }
652 else {
653 this->SetX2(gPad->PixeltoX(x)-0.5*w);
654 this->SetX1(gPad->PixeltoX(x)+0.5*w);
655 }
656}
657
658////////////////////////////////////////////////////////////////////////////////
659/// Set Y coordinate of the center of the BoundingBox
660
662{
663 if (!gPad) return;
665 if (fY2>fY1) {
666 this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
667 this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
668 }
669 else {
670 this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
671 this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
672 }
673}
674
675////////////////////////////////////////////////////////////////////////////////
676/// Set left hand side of BoundingBox to a value
677/// (resize in x direction on left)
678
680{
681 if (!gPad) return;
682 if (fX2>fX1)
683 this->SetX1(gPad->PixeltoX(x));
684 else
685 this->SetX2(gPad->PixeltoX(x));
686}
687
688////////////////////////////////////////////////////////////////////////////////
689/// Set right hand side of BoundingBox to a value
690/// (resize in x direction on right)
691
693{
694 if (!gPad) return;
695 if (fX2>fX1)
696 this->SetX2(gPad->PixeltoX(x));
697 else
698 this->SetX1(gPad->PixeltoX(x));
699}
700
701////////////////////////////////////////////////////////////////////////////////
702/// Set top of BoundingBox to a value (resize in y direction on top)
703
705{
706 if (!gPad) return;
707 if (fY2>fY1)
708 this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
709 else
710 this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
711}
712
713////////////////////////////////////////////////////////////////////////////////
714/// Set bottom of BoundingBox to a value
715/// (resize in y direction on bottom)
716
718{
719 if (!gPad) return;
720 if (fY2>fY1)
721 this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
722 else
723 this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
724}
@ 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
Definition RtypesCore.h:45
short Version_t
Definition RtypesCore.h:65
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
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:414
#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:247
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Definition TAttLine.cxx:177
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:211
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:275
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:410
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:395
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:490
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:704
void SetVertical(Bool_t set=kTRUE)
Force the line to be drawn vertically.
Definition TLine.cxx:529
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition TLine.cxx:429
Double_t GetSlope() const
Get the slope of this TLine.
Definition TLine.cxx:380
TLine()
Definition TLine.h:38
void SetBBoxCenterY(const Int_t y) override
Set Y coordinate of the center of the BoundingBox.
Definition TLine.cxx:661
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:692
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:482
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:461
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:449
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:679
void Paint(Option_t *option="") override
Paint this line with its current attributes.
Definition TLine.cxx:419
void SetBBoxY2(const Int_t y) override
Set bottom of BoundingBox to a value (resize in y direction on bottom)
Definition TLine.cxx:717
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:605
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:439
void Streamer(TBuffer &) override
Stream an object of class TLine.
Definition TLine.cxx:548
void SetBBoxCenterX(const Int_t x) override
Set X coordinate of the center of the BoundingBox.
Definition TLine.cxx:644
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:498
void SetBBoxCenter(const TPoint &p) override
Set center of the BoundingBox.
Definition TLine.cxx:618
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:574
void SetHorizontal(Bool_t set=kTRUE)
Force the line to be drawn horizontally.
Definition TLine.cxx:508
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:2896
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:2378
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:250
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:668
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
Double_t Infinity()
Returns an infinity as defined by the IEEE standard.
Definition TMath.h:923
Rectangle structure (maps to the X11 XRectangle structure)
Definition GuiTypes.h:361
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4