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