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