Logo ROOT   6.18/05
Reference Guide
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 "Riostream.h"
15#include "TROOT.h"
16#include "TLine.h"
17#include "TVirtualPad.h"
18#include "TClass.h"
19#include "TVirtualX.h"
20#include "TMath.h"
21#include "TPoint.h"
22
24
25/** \class TLine
26\ingroup BasicGraphics
27
28A simple line.
29*/
30
31
32////////////////////////////////////////////////////////////////////////////////
33/// Line normal constructor.
34
36 :TObject(), TAttLine()
37{
38 fX1=x1; fY1=y1; fX2=x2; fY2=y2;
39}
40
41
42////////////////////////////////////////////////////////////////////////////////
43/// Line copy constructor.
44
46{
47 line.TLine::Copy(*this);
48}
49
50////////////////////////////////////////////////////////////////////////////////
51/// Assignment operator
52
54{
55 src.TLine::Copy(*this);
56 return *this;
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// Copy this line to line.
61
62void TLine::Copy(TObject &obj) const
63{
64 TObject::Copy(obj);
65 TAttLine::Copy(((TLine&)obj));
66 ((TLine&)obj).fX1 = fX1;
67 ((TLine&)obj).fY1 = fY1;
68 ((TLine&)obj).fX2 = fX2;
69 ((TLine&)obj).fY2 = fY2;
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// Compute distance from point px,py to a line.
74
76{
77 if (!TestBit(kLineNDC)) return DistancetoLine(px,py,gPad->XtoPad(fX1),gPad->YtoPad(fY1),gPad->XtoPad(fX2),gPad->YtoPad(fY2));
78 Double_t x1 = gPad->GetX1() + fX1*(gPad->GetX2()-gPad->GetX1());
79 Double_t y1 = gPad->GetY1() + fY1*(gPad->GetY2()-gPad->GetY1());
80 Double_t x2 = gPad->GetX1() + fX2*(gPad->GetX2()-gPad->GetX1());
81 Double_t y2 = gPad->GetY1() + fY2*(gPad->GetY2()-gPad->GetY1());
82 return DistancetoLine(px,py,x1,y1,x2,y2);
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Draw this line with new coordinates.
87
89{
90 TLine *newline = new TLine(x1, y1, x2, y2);
91 TAttLine::Copy(*newline);
92 newline->SetBit(kCanDelete);
93 newline->AppendPad();
94 return newline;
95}
96
97////////////////////////////////////////////////////////////////////////////////
98/// Draw this line with new coordinates in NDC.
99
101{
102 TLine *newline = DrawLine(x1, y1, x2, y2);
103 newline->SetBit(kLineNDC);
104 return newline;
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// Execute action corresponding to one event.
109/// This member function is called when a line is clicked with the locator
110///
111/// If Left button clicked on one of the line end points, this point
112/// follows the cursor until button is released.
113///
114/// if Middle button clicked, the line is moved parallel to itself
115/// until the button is released.
116
118{
119 if (!gPad) return;
120
121 Int_t kMaxDiff = 20;
122 static Int_t d1,d2,px1,px2,py1,py2;
123 static Int_t pxold, pyold, px1old, py1old, px2old, py2old;
124 static Double_t oldX1, oldY1, oldX2, oldY2;
125 static Bool_t p1, p2, pL, ndcsav;
126 Double_t dpx,dpy,xp1,yp1;
127 Int_t dx, dy;
128
129 Bool_t opaque = gPad->OpaqueMoving();
130
131 if (!gPad->IsEditable()) return;
132
133 switch (event) {
134
135 case kArrowKeyPress:
136 case kButton1Down:
137 oldX1 = fX1;
138 oldY1 = fY1;
139 oldX2 = fX2;
140 oldY2 = fY2;
141 ndcsav = TestBit(kLineNDC);
142 if (!opaque) {
143 gVirtualX->SetLineColor(-1);
144 TAttLine::Modify(); //Change line attributes only if necessary
145 }
146
147 // No break !!!
148
149 case kMouseMotion:
150
151 if (TestBit(kLineNDC)) {
152 px1 = gPad->UtoPixel(fX1);
153 py1 = gPad->VtoPixel(fY1);
154 px2 = gPad->UtoPixel(fX2);
155 py2 = gPad->VtoPixel(fY2);
156 } else {
157 px1 = gPad->XtoAbsPixel(gPad->XtoPad(fX1));
158 py1 = gPad->YtoAbsPixel(gPad->YtoPad(fY1));
159 px2 = gPad->XtoAbsPixel(gPad->XtoPad(fX2));
160 py2 = gPad->YtoAbsPixel(gPad->YtoPad(fY2));
161 }
162 p1 = p2 = pL = kFALSE;
163
164 d1 = abs(px1 - px) + abs(py1-py); //simply take sum of pixels differences
165 if (d1 < kMaxDiff) { //*-*================>OK take point number 1
166 px1old = px1; py1old = py1;
167 p1 = kTRUE;
168 gPad->SetCursor(kPointer);
169 return;
170 }
171 d2 = abs(px2 - px) + abs(py2-py); //simply take sum of pixels differences
172 if (d2 < kMaxDiff) { //*-*================>OK take point number 2
173 px2old = px2; py2old = py2;
174 p2 = kTRUE;
175 gPad->SetCursor(kPointer);
176 return;
177 }
178
179 pL = kTRUE;
180 pxold = px; pyold = py;
181 gPad->SetCursor(kMove);
182
183 break;
184
185 case kArrowKeyRelease:
186 case kButton1Motion:
187
188 if (p1) {
189 if (!opaque) {
190 gVirtualX->DrawLine(px1old, py1old, px2, py2);
191 gVirtualX->DrawLine(px, py, px2, py2);
192 } else {
193 if (ndcsav) this->SetNDC(kFALSE);
194 this->SetX1(gPad->AbsPixeltoX(px));
195 this->SetY1(gPad->AbsPixeltoY(py));
196 }
197 px1old = px;
198 py1old = py;
199 }
200 if (p2) {
201 if (!opaque) {
202 gVirtualX->DrawLine(px1, py1, px2old, py2old);
203 gVirtualX->DrawLine(px1, py1, px, py);
204 } else {
205 if (ndcsav) this->SetNDC(kFALSE);
206 this->SetX2(gPad->AbsPixeltoX(px));
207 this->SetY2(gPad->AbsPixeltoY(py));
208 }
209 px2old = px;
210 py2old = py;
211 }
212 if (pL) {
213 if (!opaque) gVirtualX->DrawLine(px1, py1, px2, py2);
214 dx = px-pxold; dy = py-pyold;
215 px1 += dx; py1 += dy; px2 += dx; py2 += dy;
216 if (!opaque) gVirtualX->DrawLine(px1, py1, px2, py2);
217 pxold = px;
218 pyold = py;
219 if (opaque) {
220 if (ndcsav) this->SetNDC(kFALSE);
221 this->SetX1(gPad->AbsPixeltoX(px1));
222 this->SetY1(gPad->AbsPixeltoY(py1));
223 this->SetX2(gPad->AbsPixeltoX(px2));
224 this->SetY2(gPad->AbsPixeltoY(py2));
225 }
226 }
227 if (opaque) {
228 if (p1) {
229 //check in which corner the BBox is edited
230 if (fX1>fX2) {
231 if (fY1>fY2)
232 gPad->ShowGuidelines(this, event, '2', true);
233 else
234 gPad->ShowGuidelines(this, event, '3', true);
235 } else {
236 if (fY1>fY2)
237 gPad->ShowGuidelines(this, event, '1', true);
238 else
239 gPad->ShowGuidelines(this, event, '4', true);
240 }
241 }
242 if (p2) {
243 //check in which corner the BBox is edited
244 if (fX1>fX2) {
245 if (fY1>fY2)
246 gPad->ShowGuidelines(this, event, '4', true);
247 else
248 gPad->ShowGuidelines(this, event, '1', true);
249 } else {
250 if (fY1>fY2)
251 gPad->ShowGuidelines(this, event, '3', true);
252 else
253 gPad->ShowGuidelines(this, event, '2', true);
254 }
255 }
256 if (pL) {
257 gPad->ShowGuidelines(this, event, 'i', true);
258 }
259 gPad->Modified(kTRUE);
260 gPad->Update();
261 }
262 break;
263
264 case kButton1Up:
265
266 if (gROOT->IsEscaped()) {
267 gROOT->SetEscape(kFALSE);
268 if (opaque) {
269 this->SetX1(oldX1);
270 this->SetY1(oldY1);
271 this->SetX2(oldX2);
272 this->SetY2(oldY2);
273 gPad->Modified(kTRUE);
274 gPad->Update();
275 }
276 break;
277 }
278 if (opaque) {
279 if (ndcsav && !this->TestBit(kLineNDC)) {
280 this->SetX1((fX1 - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1()));
281 this->SetX2((fX2 - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1()));
282 this->SetY1((fY1 - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1()));
283 this->SetY2((fY2 - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1()));
284 this->SetNDC();
285 }
286 gPad->ShowGuidelines(this, event);
287 } else {
288 if (TestBit(kLineNDC)) {
289 dpx = gPad->GetX2() - gPad->GetX1();
290 dpy = gPad->GetY2() - gPad->GetY1();
291 xp1 = gPad->GetX1();
292 yp1 = gPad->GetY1();
293 if (p1) {
294 fX1 = (gPad->AbsPixeltoX(px)-xp1)/dpx;
295 fY1 = (gPad->AbsPixeltoY(py)-yp1)/dpy;
296 }
297 if (p2) {
298 fX2 = (gPad->AbsPixeltoX(px)-xp1)/dpx;
299 fY2 = (gPad->AbsPixeltoY(py)-yp1)/dpy;
300 }
301 if (pL) {
302 fX1 = (gPad->AbsPixeltoX(px1)-xp1)/dpx;
303 fY1 = (gPad->AbsPixeltoY(py1)-yp1)/dpy;
304 fX2 = (gPad->AbsPixeltoX(px2)-xp1)/dpx;
305 fY2 = (gPad->AbsPixeltoY(py2)-yp1)/dpy;
306 }
307 } else {
308 if (p1) {
309 fX1 = gPad->PadtoX(gPad->AbsPixeltoX(px));
310 fY1 = gPad->PadtoY(gPad->AbsPixeltoY(py));
311 }
312 if (p2) {
313 fX2 = gPad->PadtoX(gPad->AbsPixeltoX(px));
314 fY2 = gPad->PadtoY(gPad->AbsPixeltoY(py));
315 }
316 if (pL) {
317 fX1 = gPad->PadtoX(gPad->AbsPixeltoX(px1));
318 fY1 = gPad->PadtoY(gPad->AbsPixeltoY(py1));
319 fX2 = gPad->PadtoX(gPad->AbsPixeltoX(px2));
320 fY2 = gPad->PadtoY(gPad->AbsPixeltoY(py2));
321 }
322 }
323 if (TestBit(kVertical)) {
324 if (p1) fX2 = fX1;
325 if (p2) fX1 = fX2;
326 }
327 if (TestBit(kHorizontal)) {
328 if (p1) fY2 = fY1;
329 if (p2) fY1 = fY2;
330 }
331 gPad->Modified(kTRUE);
332 gPad->Update();
333 if (!opaque) gVirtualX->SetLineColor(-1);
334 }
335 break;
336
337 case kButton1Locate:
338
339 ExecuteEvent(kButton1Down, px, py);
340 while (1) {
341 px = py = 0;
342 event = gVirtualX->RequestLocator(1,1,px,py);
343
345
346 if (event != -1) { // button is released
347 ExecuteEvent(kButton1Up, px, py);
348 return;
349 }
350 }
351 }
352}
353
354////////////////////////////////////////////////////////////////////////////////
355/// List this line with its attributes.
356
357void TLine::ls(Option_t *) const
358{
360 printf("%s X1=%f Y1=%f X2=%f Y2=%f\n",IsA()->GetName(),fX1,fY1,fX2,fY2);
361}
362
363////////////////////////////////////////////////////////////////////////////////
364/// Paint this line with its current attributes.
365
367{
369 else PaintLine(gPad->XtoPad(fX1),gPad->YtoPad(fY1),gPad->XtoPad(fX2),gPad->YtoPad(fY2));
370}
371
372////////////////////////////////////////////////////////////////////////////////
373/// Draw this line with new coordinates.
374
376{
377 TAttLine::Modify(); //Change line attributes only if necessary
378 gPad->PaintLine(x1,y1,x2,y2);
379}
380
381////////////////////////////////////////////////////////////////////////////////
382/// Draw this line with new coordinates in NDC.
383
385{
386 TAttLine::Modify(); //Change line attributes only if necessary
387 gPad->PaintLineNDC(u1,v1,u2,v2);
388}
389
390////////////////////////////////////////////////////////////////////////////////
391/// Dump this line with its attributes.
392
394{
395 printf("%s X1=%f Y1=%f X2=%f Y2=%f",IsA()->GetName(),fX1,fY1,fX2,fY2);
396 if (GetLineColor() != 1) printf(" Color=%d",GetLineColor());
397 if (GetLineStyle() != 1) printf(" Style=%d",GetLineStyle());
398 if (GetLineWidth() != 1) printf(" Width=%d",GetLineWidth());
399 printf("\n");
400}
401
402////////////////////////////////////////////////////////////////////////////////
403/// Save primitive as a C++ statement(s) on output stream out
404
405void TLine::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
406{
407 if (gROOT->ClassSaved(TLine::Class())) {
408 out<<" ";
409 } else {
410 out<<" TLine *";
411 }
412 out<<"line = new TLine("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
413 <<");"<<std::endl;
414
415 SaveLineAttributes(out,"line",1,1,1);
416
417 out<<" line->Draw();"<<std::endl;
418}
419
420////////////////////////////////////////////////////////////////////////////////
421/// Check whether this line is to be drawn horizontally.
422
424{
425 return TestBit(kHorizontal);
426}
427
428////////////////////////////////////////////////////////////////////////////////
429/// Check whether this line is to be drawn vertically.
430
432{
433 return TestBit(kVertical);
434}
435
436////////////////////////////////////////////////////////////////////////////////
437/// Set NDC mode on if isNDC = kTRUE, off otherwise
438
440{
442 if (isNDC) SetBit(kLineNDC);
443}
444
445////////////////////////////////////////////////////////////////////////////////
446/// Force the line to be drawn horizontally.
447/// Makes fY2 equal to fY1. The line length is kept.
448/// TArrow and TGaxis also get this function by inheritance.
449
450void TLine::SetHorizontal(Bool_t set /*= kTRUE*/)
451{
452 SetBit(kHorizontal, set);
453 if (set) {
455 Int_t px1 = gPad->XtoAbsPixel(fX1);
456 Int_t px2 = gPad->XtoAbsPixel(fX2);
457 Int_t py1 = gPad->YtoAbsPixel(fY1);
458 Int_t py2 = gPad->YtoAbsPixel(fY2);
459 Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
460 if (fX2 >= fX1) fX2 = gPad->AbsPixeltoX(px1+l);
461 else fX2 = gPad->AbsPixeltoX(px1-l);
462 fY2 = fY1;
463 }
464}
465
466////////////////////////////////////////////////////////////////////////////////
467/// Force the line to be drawn vertically.
468/// Makes fX2 equal to fX1. The line length is kept.
469/// TArrow and TGaxis also get this function by inheritance.
470
471void TLine::SetVertical(Bool_t set /*= kTRUE*/)
472{
473 SetBit(kVertical, set);
474 if (set) {
476 Int_t px1 = gPad->XtoAbsPixel(fX1);
477 Int_t px2 = gPad->XtoAbsPixel(fX2);
478 Int_t py1 = gPad->YtoAbsPixel(fY1);
479 Int_t py2 = gPad->YtoAbsPixel(fY2);
480 Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
481 if (fY2 >= fY1) fY2 = gPad->AbsPixeltoY(py1-l);
482 else fY2 = gPad->AbsPixeltoY(py1+l);
483 fX2 = fX1;
484 }
485}
486
487////////////////////////////////////////////////////////////////////////////////
488/// Stream an object of class TLine.
489
490void TLine::Streamer(TBuffer &R__b)
491{
492 if (R__b.IsReading()) {
493 UInt_t R__s, R__c;
494 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
495 if (R__v > 1) {
496 R__b.ReadClassBuffer(TLine::Class(), this, R__v, R__s, R__c);
497 return;
498 }
499 //====process old versions before automatic schema evolution
500 TObject::Streamer(R__b);
501 TAttLine::Streamer(R__b);
502 Float_t x1,y1,x2,y2;
503 R__b >> x1; fX1 = x1;
504 R__b >> y1; fY1 = y1;
505 R__b >> x2; fX2 = x2;
506 R__b >> y2; fY2 = y2;
507 //====end of old versions
508
509 } else {
510 R__b.WriteClassBuffer(TLine::Class(),this);
511 }
512}
513////////////////////////////////////////////////////////////////////////////////
514/// Return the bounding Box of the Line
515
517{
518 Rectangle_t BBox;
519 Int_t px1, py1, px2, py2;
520 px1 = gPad->XtoPixel(fX1);
521 px2 = gPad->XtoPixel(fX2);
522 py1 = gPad->YtoPixel(fY1);
523 py2 = gPad->YtoPixel(fY2);
524
525 Int_t tmp;
526 if (px1>px2) { tmp = px1; px1 = px2; px2 = tmp;}
527 if (py1>py2) { tmp = py1; py1 = py2; py2 = tmp;}
528
529 BBox.fX = px1;
530 BBox.fY = py1;
531 BBox.fWidth = px2-px1;
532 BBox.fHeight = py2-py1;
533
534 return (BBox);
535}
536
537////////////////////////////////////////////////////////////////////////////////
538/// Return the center of the BoundingBox as TPoint in pixels
539
541{
542 TPoint p;
543 p.SetX(gPad->XtoPixel(TMath::Min(fX1,fX2)+0.5*(TMath::Max(fX1, fX2)-TMath::Min(fX1, fX2))));
544 p.SetY(gPad->YtoPixel(TMath::Min(fY1,fY2)+0.5*(TMath::Max(fY1, fY2)-TMath::Min(fY1, fY2))));
545 return(p);
546}
547
548////////////////////////////////////////////////////////////////////////////////
549/// Set center of the BoundingBox
550
552{
555 if (fX2>fX1) {
556 this->SetX1(gPad->PixeltoX(p.GetX())-0.5*w);
557 this->SetX2(gPad->PixeltoX(p.GetX())+0.5*w);
558 }
559 else {
560 this->SetX2(gPad->PixeltoX(p.GetX())-0.5*w);
561 this->SetX1(gPad->PixeltoX(p.GetX())+0.5*w);
562 }
563 if (fY2>fY1) {
564 this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
565 this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
566 }
567 else {
568 this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
569 this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
570 }
571}
572
573////////////////////////////////////////////////////////////////////////////////
574/// Set X coordinate of the center of the BoundingBox
575
577{
579 if (fX2>fX1) {
580 this->SetX1(gPad->PixeltoX(x)-0.5*w);
581 this->SetX2(gPad->PixeltoX(x)+0.5*w);
582 }
583 else {
584 this->SetX2(gPad->PixeltoX(x)-0.5*w);
585 this->SetX1(gPad->PixeltoX(x)+0.5*w);
586 }
587}
588
589////////////////////////////////////////////////////////////////////////////////
590/// Set Y coordinate of the center of the BoundingBox
591
593{
595 if (fY2>fY1) {
596 this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
597 this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
598 }
599 else {
600 this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
601 this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
602 }
603}
604
605////////////////////////////////////////////////////////////////////////////////
606/// Set left hand side of BoundingBox to a value
607/// (resize in x direction on left)
608
610{
611 if (fX2>fX1)
612 this->SetX1(gPad->PixeltoX(x));
613 else
614 this->SetX2(gPad->PixeltoX(x));
615}
616
617////////////////////////////////////////////////////////////////////////////////
618/// Set right hand side of BoundingBox to a value
619/// (resize in x direction on right)
620
622{
623 if (fX2>fX1)
624 this->SetX2(gPad->PixeltoX(x));
625 else
626 this->SetX1(gPad->PixeltoX(x));
627}
628
629////////////////////////////////////////////////////////////////////////////////
630/// Set top of BoundingBox to a value (resize in y direction on top)
631
633{
634 if (fY2>fY1)
635 this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
636 else
637 this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
638}
639
640////////////////////////////////////////////////////////////////////////////////
641/// Set bottom of BoundingBox to a value
642/// (resize in y direction on bottom)
643
645{
646 if (fY2>fY1)
647 this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
648 else
649 this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
650}
@ 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
void Class()
Definition: Class.C:29
#define h(i)
Definition: RSha256.hxx:106
static const double x2[5]
static const double x1[5]
int Int_t
Definition: RtypesCore.h:41
short Version_t
Definition: RtypesCore.h:61
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:365
#define gROOT
Definition: TROOT.h:414
#define gPad
Definition: TVirtualPad.h:286
#define gVirtualX
Definition: TVirtualX.h:345
@ kMove
Definition: TVirtualX.h:46
@ kPointer
Definition: TVirtualX.h:47
Abstract base class for elements drawn in the editor.
Definition: TAttBBox2D.h:19
Line Attributes class.
Definition: TAttLine.h:18
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:234
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Definition: TAttLine.cxx:164
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:198
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:262
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
Bool_t IsReading() const
Definition: TBuffer.h:85
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
A simple line.
Definition: TLine.h:23
virtual void SetY2(Double_t y2)
Definition: TLine.h:69
virtual void SetBBoxCenterX(const Int_t x)
Set X coordinate of the center of the BoundingBox.
Definition: TLine.cxx:576
Double_t fY1
Y of 1st point.
Definition: TLine.h:27
Double_t fX1
X of 1st point.
Definition: TLine.h:26
virtual void SetX2(Double_t x2)
Definition: TLine.h:67
Bool_t IsVertical()
Check whether this line is to be drawn vertically.
Definition: TLine.cxx:431
virtual void ls(Option_t *option="") const
List this line with its attributes.
Definition: TLine.cxx:357
virtual TLine * DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition: TLine.cxx:88
void SetVertical(Bool_t set=kTRUE)
Force the line to be drawn vertically.
Definition: TLine.cxx:471
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition: TLine.cxx:375
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a line.
Definition: TLine.cxx:75
virtual void SetBBoxCenter(const TPoint &p)
Set center of the BoundingBox.
Definition: TLine.cxx:551
virtual Rectangle_t GetBBox()
Return the bounding Box of the Line.
Definition: TLine.cxx:516
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:100
virtual void Print(Option_t *option="") const
Dump this line with its attributes.
Definition: TLine.cxx:393
virtual void SetBBoxX2(const Int_t x)
Set right hand side of BoundingBox to a value (resize in x direction on right)
Definition: TLine.cxx:621
Bool_t IsHorizontal()
Check whether this line is to be drawn horizontally.
Definition: TLine.cxx:423
Double_t fX2
X of 2nd point.
Definition: TLine.h:28
virtual void SetBBoxY1(const Int_t y)
Set top of BoundingBox to a value (resize in y direction on top)
Definition: TLine.cxx:632
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TLine.cxx:117
TLine()=default
virtual void SetX1(Double_t x1)
Definition: TLine.h:66
TLine & operator=(const TLine &src)
Assignment operator.
Definition: TLine.cxx:53
Double_t fY2
Y of 2nd point.
Definition: TLine.h:29
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:384
virtual void SetBBoxCenterY(const Int_t y)
Set Y coordinate of the center of the BoundingBox.
Definition: TLine.cxx:592
virtual void SetBBoxY2(const Int_t y)
Set bottom of BoundingBox to a value (resize in y direction on bottom)
Definition: TLine.cxx:644
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TLine.cxx:405
void Copy(TObject &line) const
Copy this line to line.
Definition: TLine.cxx:62
virtual void SetY1(Double_t y1)
Definition: TLine.h:68
virtual void SetBBoxX1(const Int_t x)
Set left hand side of BoundingBox to a value (resize in x direction on left)
Definition: TLine.cxx:609
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Definition: TLine.cxx:439
virtual TPoint GetBBoxCenter()
Return the center of the BoundingBox as TPoint in pixels.
Definition: TLine.cxx:540
@ kLineNDC
Use NDC coordinates.
Definition: TLine.h:34
@ kHorizontal
Line is horizontal.
Definition: TLine.h:36
@ kVertical
Line is vertical.
Definition: TLine.h:35
void SetHorizontal(Bool_t set=kTRUE)
Force the line to be drawn horizontally.
Definition: TLine.cxx:450
virtual void Paint(Option_t *option="")
Paint this line with its current attributes.
Definition: TLine.cxx:366
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:105
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
virtual void Copy(TObject &object) const
Copy this to obj.
Definition: TObject.cxx:61
void ResetBit(UInt_t f)
Definition: TObject.h:171
@ kCanDelete
if object in a list can be deleted
Definition: TObject.h:58
Definition: TPoint.h:31
SCoord_t GetY() const
Definition: TPoint.h:47
void SetX(SCoord_t x)
Definition: TPoint.h:48
void SetY(SCoord_t y)
Definition: TPoint.h:49
SCoord_t GetX() const
Definition: TPoint.h:46
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition: TROOT.cxx:2855
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)
Definition: TMathBase.h:212
Double_t Sqrt(Double_t x)
Definition: TMath.h:679
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
Short_t fX
Definition: GuiTypes.h:361
UShort_t fHeight
Definition: GuiTypes.h:362
Short_t fY
Definition: GuiTypes.h:361
UShort_t fWidth
Definition: GuiTypes.h:362
auto * l
Definition: textangle.C:4