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
50 :TObject(), TAttLine()
51{
52 fX1=x1; fY1=y1; fX2=x2; fY2=y2;
53}
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);
106 TAttLine::Copy(*newline);
107 newline->SetBit(kCanDelete);
108 newline->AppendPad();
109 return newline;
110}
111
112////////////////////////////////////////////////////////////////////////////////
113/// Draw this line with new coordinates in NDC.
114
116{
117 TLine *newline = DrawLine(x1, y1, x2, y2);
118 newline->SetBit(kLineNDC);
119 return newline;
120}
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;
138 static Int_t pxold, pyold, px1old, py1old, px2old, py2old;
139 static Double_t oldX1, oldY1, oldX2, oldY2;
140 static Bool_t p1, p2, pL, ndcsav;
141 Double_t dpx,dpy,xp1,yp1;
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();
156 ndcsav = TestBit(kLineNDC);
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/// List this line with its attributes.
379
380void TLine::ls(Option_t *) const
381{
383 printf("%s X1=%f Y1=%f X2=%f Y2=%f\n",IsA()->GetName(),fX1,fY1,fX2,fY2);
384}
385
386////////////////////////////////////////////////////////////////////////////////
387/// Paint this line with its current attributes.
388
390{
391 if (!gPad) return;
393 else PaintLine(gPad->XtoPad(fX1),gPad->YtoPad(fY1),gPad->XtoPad(fX2),gPad->YtoPad(fY2));
394}
395
396////////////////////////////////////////////////////////////////////////////////
397/// Draw this line with new coordinates.
398
400{
401 if (!gPad) return;
402 TAttLine::Modify(); //Change line attributes only if necessary
403 gPad->PaintLine(x1,y1,x2,y2);
404}
405
406////////////////////////////////////////////////////////////////////////////////
407/// Draw this line with new coordinates in NDC.
408
410{
411 if (!gPad) return;
412 TAttLine::Modify(); //Change line attributes only if necessary
413 gPad->PaintLineNDC(u1,v1,u2,v2);
414}
415
416////////////////////////////////////////////////////////////////////////////////
417/// Dump this line with its attributes.
418
420{
421 printf("%s X1=%f Y1=%f X2=%f Y2=%f",IsA()->GetName(),fX1,fY1,fX2,fY2);
422 if (GetLineColor() != 1) printf(" Color=%d",GetLineColor());
423 if (GetLineStyle() != 1) printf(" Style=%d",GetLineStyle());
424 if (GetLineWidth() != 1) printf(" Width=%d",GetLineWidth());
425 printf("\n");
426}
427
428////////////////////////////////////////////////////////////////////////////////
429/// Save primitive as a C++ statement(s) on output stream out
430
431void TLine::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
432{
433 if (gROOT->ClassSaved(TLine::Class())) {
434 out<<" ";
435 } else {
436 out<<" TLine *";
437 }
438 out<<"line = new TLine("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2<<");"<<std::endl;
439
440 SaveLineAttributes(out,"line",1,1,1);
441
442 if (TestBit(kLineNDC))
443 out<<" line->SetNDC();"<<std::endl;
444
445 out<<" line->Draw();"<<std::endl;
446}
447
448////////////////////////////////////////////////////////////////////////////////
449/// Check whether this line is to be drawn horizontally.
450
452{
453 return TestBit(kHorizontal);
454}
455
456////////////////////////////////////////////////////////////////////////////////
457/// Check whether this line is to be drawn vertically.
458
460{
461 return TestBit(kVertical);
462}
463
464////////////////////////////////////////////////////////////////////////////////
465/// Set NDC mode on if isNDC = kTRUE, off otherwise
466
468{
470 if (isNDC) SetBit(kLineNDC);
471}
472
473////////////////////////////////////////////////////////////////////////////////
474/// Force the line to be drawn horizontally.
475/// Makes fY2 equal to fY1. The line length is kept.
476/// TArrow and TGaxis also get this function by inheritance.
477
478void TLine::SetHorizontal(Bool_t set /*= kTRUE*/)
479{
480 SetBit(kHorizontal, set);
481 if (set && gPad) {
483 Int_t px1 = gPad->XtoAbsPixel(fX1);
484 Int_t px2 = gPad->XtoAbsPixel(fX2);
485 Int_t py1 = gPad->YtoAbsPixel(fY1);
486 Int_t py2 = gPad->YtoAbsPixel(fY2);
487 Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
488 if (fX2 >= fX1) fX2 = gPad->AbsPixeltoX(px1+l);
489 else fX2 = gPad->AbsPixeltoX(px1-l);
490 fY2 = fY1;
491 }
492}
493
494////////////////////////////////////////////////////////////////////////////////
495/// Force the line to be drawn vertically.
496/// Makes fX2 equal to fX1. The line length is kept.
497/// TArrow and TGaxis also get this function by inheritance.
498
499void TLine::SetVertical(Bool_t set /*= kTRUE*/)
500{
501 SetBit(kVertical, set);
502 if (set && gPad) {
504 Int_t px1 = gPad->XtoAbsPixel(fX1);
505 Int_t px2 = gPad->XtoAbsPixel(fX2);
506 Int_t py1 = gPad->YtoAbsPixel(fY1);
507 Int_t py2 = gPad->YtoAbsPixel(fY2);
508 Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
509 if (fY2 >= fY1) fY2 = gPad->AbsPixeltoY(py1-l);
510 else fY2 = gPad->AbsPixeltoY(py1+l);
511 fX2 = fX1;
512 }
513}
514
515////////////////////////////////////////////////////////////////////////////////
516/// Stream an object of class TLine.
517
519{
520 if (R__b.IsReading()) {
521 UInt_t R__s, R__c;
522 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
523 if (R__v > 1) {
524 R__b.ReadClassBuffer(TLine::Class(), this, R__v, R__s, R__c);
525 return;
526 }
527 //====process old versions before automatic schema evolution
528 TObject::Streamer(R__b);
529 TAttLine::Streamer(R__b);
530 Float_t x1,y1,x2,y2;
531 R__b >> x1; fX1 = x1;
532 R__b >> y1; fY1 = y1;
533 R__b >> x2; fX2 = x2;
534 R__b >> y2; fY2 = y2;
535 //====end of old versions
536
537 } else {
538 R__b.WriteClassBuffer(TLine::Class(),this);
539 }
540}
541////////////////////////////////////////////////////////////////////////////////
542/// Return the bounding Box of the Line
543
545{
546 Rectangle_t BBox{0, 0, 0, 0};
547 if (gPad) {
548 Int_t px1 = gPad->XtoPixel(fX1);
549 Int_t px2 = gPad->XtoPixel(fX2);
550 Int_t py1 = gPad->YtoPixel(fY1);
551 Int_t py2 = gPad->YtoPixel(fY2);
552
553 if (px1 > px2) {
554 Int_t tmp = px1;
555 px1 = px2;
556 px2 = tmp;
557 }
558 if (py1 > py2) {
559 Int_t tmp = py1;
560 py1 = py2;
561 py2 = tmp;
562 }
563
564 BBox.fX = px1;
565 BBox.fY = py1;
566 BBox.fWidth = px2 - px1;
567 BBox.fHeight = py2 - py1;
568 }
569 return BBox;
570}
571
572////////////////////////////////////////////////////////////////////////////////
573/// Return the center of the BoundingBox as TPoint in pixels
574
576{
577 TPoint p(0, 0);
578 if (gPad) {
579 p.SetX(gPad->XtoPixel(TMath::Min(fX1, fX2) + 0.5 * (TMath::Max(fX1, fX2) - TMath::Min(fX1, fX2))));
580 p.SetY(gPad->YtoPixel(TMath::Min(fY1, fY2) + 0.5 * (TMath::Max(fY1, fY2) - TMath::Min(fY1, fY2))));
581 }
582 return p;
583}
584
585////////////////////////////////////////////////////////////////////////////////
586/// Set center of the BoundingBox
587
589{
590 if (!gPad) return;
593 if (fX2>fX1) {
594 this->SetX1(gPad->PixeltoX(p.GetX())-0.5*w);
595 this->SetX2(gPad->PixeltoX(p.GetX())+0.5*w);
596 }
597 else {
598 this->SetX2(gPad->PixeltoX(p.GetX())-0.5*w);
599 this->SetX1(gPad->PixeltoX(p.GetX())+0.5*w);
600 }
601 if (fY2>fY1) {
602 this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
603 this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
604 }
605 else {
606 this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
607 this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
608 }
609}
610
611////////////////////////////////////////////////////////////////////////////////
612/// Set X coordinate of the center of the BoundingBox
613
615{
616 if (!gPad) return;
618 if (fX2>fX1) {
619 this->SetX1(gPad->PixeltoX(x)-0.5*w);
620 this->SetX2(gPad->PixeltoX(x)+0.5*w);
621 }
622 else {
623 this->SetX2(gPad->PixeltoX(x)-0.5*w);
624 this->SetX1(gPad->PixeltoX(x)+0.5*w);
625 }
626}
627
628////////////////////////////////////////////////////////////////////////////////
629/// Set Y coordinate of the center of the BoundingBox
630
632{
633 if (!gPad) return;
635 if (fY2>fY1) {
636 this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
637 this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
638 }
639 else {
640 this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
641 this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
642 }
643}
644
645////////////////////////////////////////////////////////////////////////////////
646/// Set left hand side of BoundingBox to a value
647/// (resize in x direction on left)
648
650{
651 if (!gPad) return;
652 if (fX2>fX1)
653 this->SetX1(gPad->PixeltoX(x));
654 else
655 this->SetX2(gPad->PixeltoX(x));
656}
657
658////////////////////////////////////////////////////////////////////////////////
659/// Set right hand side of BoundingBox to a value
660/// (resize in x direction on right)
661
663{
664 if (!gPad) return;
665 if (fX2>fX1)
666 this->SetX2(gPad->PixeltoX(x));
667 else
668 this->SetX1(gPad->PixeltoX(x));
669}
670
671////////////////////////////////////////////////////////////////////////////////
672/// Set top of BoundingBox to a value (resize in y direction on top)
673
675{
676 if (!gPad) return;
677 if (fY2>fY1)
678 this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
679 else
680 this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
681}
682
683////////////////////////////////////////////////////////////////////////////////
684/// Set bottom of BoundingBox to a value
685/// (resize in y direction on bottom)
686
688{
689 if (!gPad) return;
690 if (fY2>fY1)
691 this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
692 else
693 this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
694}
@ 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:382
winID h TVirtualViewer3D TVirtualGLPainter p
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:406
#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:18
virtual void Streamer(TBuffer &)
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:33
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:35
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:34
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
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
Bool_t IsReading() const
Definition TBuffer.h:86
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
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:380
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:459
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:674
void SetVertical(Bool_t set=kTRUE)
Force the line to be drawn vertically.
Definition TLine.cxx:499
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition TLine.cxx:399
TLine()
Definition TLine.h:38
void SetBBoxCenterY(const Int_t y) override
Set Y coordinate of the center of the BoundingBox.
Definition TLine.cxx:631
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:662
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:451
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:431
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:419
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:649
void Paint(Option_t *option="") override
Paint this line with its current attributes.
Definition TLine.cxx:389
void SetBBoxY2(const Int_t y) override
Set bottom of BoundingBox to a value (resize in y direction on bottom)
Definition TLine.cxx:687
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:575
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:409
void Streamer(TBuffer &) override
Stream an object of class TLine.
Definition TLine.cxx:518
void SetBBoxCenterX(const Int_t x) override
Set X coordinate of the center of the BoundingBox.
Definition TLine.cxx:614
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:467
void SetBBoxCenter(const TPoint &p) override
Set center of the BoundingBox.
Definition TLine.cxx:588
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:544
void SetHorizontal(Bool_t set=kTRUE)
Force the line to be drawn horizontally.
Definition TLine.cxx:478
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:456
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:906
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:202
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:798
virtual void Copy(TObject &object) const
Copy this to obj.
Definition TObject.cxx:158
void ResetBit(UInt_t f)
Definition TObject.h:198
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:62
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:2895
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