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