Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
23 ClassImp(TLine);
24 
25 /** \class TLine
26 \ingroup BasicGraphics
27 
28 A simple line.
29 */
30 
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// Line normal constructor.
34 
35 TLine::TLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
36  :TObject(), TAttLine()
37 {
38  fX1=x1; fY1=y1; fX2=x2; fY2=y2;
39 }
40 
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Line copy constructor.
44 
45 TLine::TLine(const TLine &line) : TObject(line), TAttLine(line), TAttBBox2D(line)
46 {
47  line.TLine::Copy(*this);
48 }
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// Assignment operator
52 
53 TLine &TLine::operator=(const TLine &src)
54 {
55  src.TLine::Copy(*this);
56  return *this;
57 }
58 
59 ////////////////////////////////////////////////////////////////////////////////
60 /// Copy this line to line.
61 
62 void 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 
75 Int_t TLine::DistancetoPrimitive(Int_t px, Int_t py)
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 
88 TLine *TLine::DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
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 
100 TLine *TLine::DrawLineNDC(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
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 
117 void TLine::ExecuteEvent(Int_t event, Int_t px, Int_t py)
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 = GetX1();
138  oldY1 = GetY1();
139  oldX2 = GetX2();
140  oldY2 = GetY2();
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(GetX1());
153  py1 = gPad->VtoPixel(GetY1());
154  px2 = gPad->UtoPixel(GetX2());
155  py2 = gPad->VtoPixel(GetY2());
156  } else {
157  px1 = gPad->XtoAbsPixel(gPad->XtoPad(GetX1()));
158  py1 = gPad->YtoAbsPixel(gPad->YtoPad(GetY1()));
159  px2 = gPad->XtoAbsPixel(gPad->XtoPad(GetX2()));
160  py2 = gPad->YtoAbsPixel(gPad->YtoPad(GetY2()));
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) {
194  SetNDC(kFALSE);
195  SetX2(gPad->GetX1() + oldX2*(gPad->GetX2()-gPad->GetX1()));
196  SetY2(gPad->GetY1() + oldY2*(gPad->GetY2()-gPad->GetY1()));
197  }
198  SetX1(gPad->AbsPixeltoX(px));
199  SetY1(gPad->AbsPixeltoY(py));
200  }
201  px1old = px;
202  py1old = py;
203  }
204  if (p2) {
205  if (!opaque) {
206  gVirtualX->DrawLine(px1, py1, px2old, py2old);
207  gVirtualX->DrawLine(px1, py1, px, py);
208  } else {
209  if (ndcsav) {
210  SetNDC(kFALSE);
211  SetX1(gPad->GetX1() + oldX1*(gPad->GetX2()-gPad->GetX1()));
212  SetY1(gPad->GetY1() + oldY1*(gPad->GetY2()-gPad->GetY1()));
213  }
214  SetX2(gPad->AbsPixeltoX(px));
215  SetY2(gPad->AbsPixeltoY(py));
216  }
217  px2old = px;
218  py2old = py;
219  }
220  if (pL) {
221  if (!opaque) gVirtualX->DrawLine(px1, py1, px2, py2);
222  dx = px-pxold; dy = py-pyold;
223  px1 += dx; py1 += dy; px2 += dx; py2 += dy;
224  if (!opaque) gVirtualX->DrawLine(px1, py1, px2, py2);
225  pxold = px;
226  pyold = py;
227  if (opaque) {
228  if (ndcsav) SetNDC(kFALSE);
229  SetX1(gPad->AbsPixeltoX(px1));
230  SetY1(gPad->AbsPixeltoY(py1));
231  SetX2(gPad->AbsPixeltoX(px2));
232  SetY2(gPad->AbsPixeltoY(py2));
233  }
234  }
235  if (opaque) {
236  if (p1) {
237  //check in which corner the BBox is edited
238  if (GetX1() > GetX2()) {
239  if (GetY1() > GetY2())
240  gPad->ShowGuidelines(this, event, '2', true);
241  else
242  gPad->ShowGuidelines(this, event, '3', true);
243  } else {
244  if (GetY1() > GetY2())
245  gPad->ShowGuidelines(this, event, '1', true);
246  else
247  gPad->ShowGuidelines(this, event, '4', true);
248  }
249  }
250  if (p2) {
251  //check in which corner the BBox is edited
252  if (GetX1() > GetX2()) {
253  if (GetY1() > GetY2())
254  gPad->ShowGuidelines(this, event, '4', true);
255  else
256  gPad->ShowGuidelines(this, event, '1', true);
257  } else {
258  if (GetY1() > GetY2())
259  gPad->ShowGuidelines(this, event, '3', true);
260  else
261  gPad->ShowGuidelines(this, event, '2', true);
262  }
263  }
264  if (pL) {
265  gPad->ShowGuidelines(this, event, 'i', true);
266  }
267  gPad->Modified(kTRUE);
268  gPad->Update();
269  }
270  break;
271 
272  case kButton1Up:
273 
274  if (gROOT->IsEscaped()) {
275  gROOT->SetEscape(kFALSE);
276  if (opaque) {
277  SetX1(oldX1);
278  SetY1(oldY1);
279  SetX2(oldX2);
280  SetY2(oldY2);
281  gPad->Modified(kTRUE);
282  gPad->Update();
283  }
284  break;
285  }
286  if (opaque) {
287  if (ndcsav && !TestBit(kLineNDC)) {
288  SetX1((GetX1() - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1()));
289  SetX2((GetX2() - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1()));
290  SetY1((GetY1() - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1()));
291  SetY2((GetY2() - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1()));
292  SetNDC();
293  }
294  gPad->ShowGuidelines(this, event);
295  } else {
296  if (TestBit(kLineNDC)) {
297  dpx = gPad->GetX2() - gPad->GetX1();
298  dpy = gPad->GetY2() - gPad->GetY1();
299  xp1 = gPad->GetX1();
300  yp1 = gPad->GetY1();
301  if (p1) {
302  SetX1((gPad->AbsPixeltoX(px)-xp1)/dpx);
303  SetY1((gPad->AbsPixeltoY(py)-yp1)/dpy);
304  }
305  if (p2) {
306  SetX2((gPad->AbsPixeltoX(px)-xp1)/dpx);
307  SetY2((gPad->AbsPixeltoY(py)-yp1)/dpy);
308  }
309  if (pL) {
310  SetX1((gPad->AbsPixeltoX(px1)-xp1)/dpx);
311  SetY1((gPad->AbsPixeltoY(py1)-yp1)/dpy);
312  SetX2((gPad->AbsPixeltoX(px2)-xp1)/dpx);
313  SetY2((gPad->AbsPixeltoY(py2)-yp1)/dpy);
314  }
315  } else {
316  if (p1) {
317  SetX1(gPad->PadtoX(gPad->AbsPixeltoX(px)));
318  SetY1(gPad->PadtoY(gPad->AbsPixeltoY(py)));
319  }
320  if (p2) {
321  SetX2(gPad->PadtoX(gPad->AbsPixeltoX(px)));
322  SetY2(gPad->PadtoY(gPad->AbsPixeltoY(py)));
323  }
324  if (pL) {
325  SetX1(gPad->PadtoX(gPad->AbsPixeltoX(px1)));
326  SetY1(gPad->PadtoY(gPad->AbsPixeltoY(py1)));
327  SetX2(gPad->PadtoX(gPad->AbsPixeltoX(px2)));
328  SetY2(gPad->PadtoY(gPad->AbsPixeltoY(py2)));
329  }
330  }
331  if (TestBit(kVertical)) {
332  if (p1) SetX2(GetX1());
333  if (p2) SetX1(GetX2());
334  }
335  if (TestBit(kHorizontal)) {
336  if (p1) SetY2(GetY1());
337  if (p2) SetY1(GetY2());
338  }
339  gPad->Modified(kTRUE);
340  gPad->Update();
341  if (!opaque) gVirtualX->SetLineColor(-1);
342  }
343  break;
344 
345  case kButton1Locate:
346 
347  ExecuteEvent(kButton1Down, px, py);
348  while (1) {
349  px = py = 0;
350  event = gVirtualX->RequestLocator(1,1,px,py);
351 
352  ExecuteEvent(kButton1Motion, px, py);
353 
354  if (event != -1) { // button is released
355  ExecuteEvent(kButton1Up, px, py);
356  return;
357  }
358  }
359  }
360 }
361 
362 ////////////////////////////////////////////////////////////////////////////////
363 /// List this line with its attributes.
364 
365 void TLine::ls(Option_t *) const
366 {
367  TROOT::IndentLevel();
368  printf("%s X1=%f Y1=%f X2=%f Y2=%f\n",IsA()->GetName(),fX1,fY1,fX2,fY2);
369 }
370 
371 ////////////////////////////////////////////////////////////////////////////////
372 /// Paint this line with its current attributes.
373 
374 void TLine::Paint(Option_t *)
375 {
376  if (TestBit(kLineNDC)) PaintLineNDC(fX1,fY1,fX2,fY2);
377  else PaintLine(gPad->XtoPad(fX1),gPad->YtoPad(fY1),gPad->XtoPad(fX2),gPad->YtoPad(fY2));
378 }
379 
380 ////////////////////////////////////////////////////////////////////////////////
381 /// Draw this line with new coordinates.
382 
383 void TLine::PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
384 {
385  TAttLine::Modify(); //Change line attributes only if necessary
386  gPad->PaintLine(x1,y1,x2,y2);
387 }
388 
389 ////////////////////////////////////////////////////////////////////////////////
390 /// Draw this line with new coordinates in NDC.
391 
392 void TLine::PaintLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2)
393 {
394  TAttLine::Modify(); //Change line attributes only if necessary
395  gPad->PaintLineNDC(u1,v1,u2,v2);
396 }
397 
398 ////////////////////////////////////////////////////////////////////////////////
399 /// Dump this line with its attributes.
400 
401 void TLine::Print(Option_t *) const
402 {
403  printf("%s X1=%f Y1=%f X2=%f Y2=%f",IsA()->GetName(),fX1,fY1,fX2,fY2);
404  if (GetLineColor() != 1) printf(" Color=%d",GetLineColor());
405  if (GetLineStyle() != 1) printf(" Style=%d",GetLineStyle());
406  if (GetLineWidth() != 1) printf(" Width=%d",GetLineWidth());
407  printf("\n");
408 }
409 
410 ////////////////////////////////////////////////////////////////////////////////
411 /// Save primitive as a C++ statement(s) on output stream out
412 
413 void TLine::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
414 {
415  if (gROOT->ClassSaved(TLine::Class())) {
416  out<<" ";
417  } else {
418  out<<" TLine *";
419  }
420  out<<"line = new TLine("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2<<");"<<std::endl;
421 
422  SaveLineAttributes(out,"line",1,1,1);
423 
424  if (TestBit(kLineNDC))
425  out<<" line->SetNDC();"<<std::endl;
426 
427  out<<" line->Draw();"<<std::endl;
428 }
429 
430 ////////////////////////////////////////////////////////////////////////////////
431 /// Check whether this line is to be drawn horizontally.
432 
433 Bool_t TLine::IsHorizontal()
434 {
435  return TestBit(kHorizontal);
436 }
437 
438 ////////////////////////////////////////////////////////////////////////////////
439 /// Check whether this line is to be drawn vertically.
440 
441 Bool_t TLine::IsVertical()
442 {
443  return TestBit(kVertical);
444 }
445 
446 ////////////////////////////////////////////////////////////////////////////////
447 /// Set NDC mode on if isNDC = kTRUE, off otherwise
448 
449 void TLine::SetNDC(Bool_t isNDC)
450 {
451  ResetBit(kLineNDC);
452  if (isNDC) SetBit(kLineNDC);
453 }
454 
455 ////////////////////////////////////////////////////////////////////////////////
456 /// Force the line to be drawn horizontally.
457 /// Makes fY2 equal to fY1. The line length is kept.
458 /// TArrow and TGaxis also get this function by inheritance.
459 
460 void TLine::SetHorizontal(Bool_t set /*= kTRUE*/)
461 {
462  SetBit(kHorizontal, set);
463  if (set) {
464  SetVertical(kFALSE);
465  Int_t px1 = gPad->XtoAbsPixel(fX1);
466  Int_t px2 = gPad->XtoAbsPixel(fX2);
467  Int_t py1 = gPad->YtoAbsPixel(fY1);
468  Int_t py2 = gPad->YtoAbsPixel(fY2);
469  Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
470  if (fX2 >= fX1) fX2 = gPad->AbsPixeltoX(px1+l);
471  else fX2 = gPad->AbsPixeltoX(px1-l);
472  fY2 = fY1;
473  }
474 }
475 
476 ////////////////////////////////////////////////////////////////////////////////
477 /// Force the line to be drawn vertically.
478 /// Makes fX2 equal to fX1. The line length is kept.
479 /// TArrow and TGaxis also get this function by inheritance.
480 
481 void TLine::SetVertical(Bool_t set /*= kTRUE*/)
482 {
483  SetBit(kVertical, set);
484  if (set) {
485  SetHorizontal(kFALSE);
486  Int_t px1 = gPad->XtoAbsPixel(fX1);
487  Int_t px2 = gPad->XtoAbsPixel(fX2);
488  Int_t py1 = gPad->YtoAbsPixel(fY1);
489  Int_t py2 = gPad->YtoAbsPixel(fY2);
490  Int_t l = Int_t(TMath::Sqrt((px2-px1)*(px2-px1)+(py2-py1)*(py2-py1)));
491  if (fY2 >= fY1) fY2 = gPad->AbsPixeltoY(py1-l);
492  else fY2 = gPad->AbsPixeltoY(py1+l);
493  fX2 = fX1;
494  }
495 }
496 
497 ////////////////////////////////////////////////////////////////////////////////
498 /// Stream an object of class TLine.
499 
500 void TLine::Streamer(TBuffer &R__b)
501 {
502  if (R__b.IsReading()) {
503  UInt_t R__s, R__c;
504  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
505  if (R__v > 1) {
506  R__b.ReadClassBuffer(TLine::Class(), this, R__v, R__s, R__c);
507  return;
508  }
509  //====process old versions before automatic schema evolution
510  TObject::Streamer(R__b);
511  TAttLine::Streamer(R__b);
512  Float_t x1,y1,x2,y2;
513  R__b >> x1; fX1 = x1;
514  R__b >> y1; fY1 = y1;
515  R__b >> x2; fX2 = x2;
516  R__b >> y2; fY2 = y2;
517  //====end of old versions
518 
519  } else {
520  R__b.WriteClassBuffer(TLine::Class(),this);
521  }
522 }
523 ////////////////////////////////////////////////////////////////////////////////
524 /// Return the bounding Box of the Line
525 
526 Rectangle_t TLine::GetBBox()
527 {
528  Rectangle_t BBox;
529  Int_t px1, py1, px2, py2;
530  px1 = gPad->XtoPixel(fX1);
531  px2 = gPad->XtoPixel(fX2);
532  py1 = gPad->YtoPixel(fY1);
533  py2 = gPad->YtoPixel(fY2);
534 
535  Int_t tmp;
536  if (px1>px2) { tmp = px1; px1 = px2; px2 = tmp;}
537  if (py1>py2) { tmp = py1; py1 = py2; py2 = tmp;}
538 
539  BBox.fX = px1;
540  BBox.fY = py1;
541  BBox.fWidth = px2-px1;
542  BBox.fHeight = py2-py1;
543 
544  return (BBox);
545 }
546 
547 ////////////////////////////////////////////////////////////////////////////////
548 /// Return the center of the BoundingBox as TPoint in pixels
549 
550 TPoint TLine::GetBBoxCenter()
551 {
552  TPoint p;
553  p.SetX(gPad->XtoPixel(TMath::Min(fX1,fX2)+0.5*(TMath::Max(fX1, fX2)-TMath::Min(fX1, fX2))));
554  p.SetY(gPad->YtoPixel(TMath::Min(fY1,fY2)+0.5*(TMath::Max(fY1, fY2)-TMath::Min(fY1, fY2))));
555  return(p);
556 }
557 
558 ////////////////////////////////////////////////////////////////////////////////
559 /// Set center of the BoundingBox
560 
561 void TLine::SetBBoxCenter(const TPoint &p)
562 {
563  Double_t w = TMath::Max(fX1, fX2)-TMath::Min(fX1, fX2);
564  Double_t h = TMath::Max(fY1, fY2)-TMath::Min(fY1, fY2);
565  if (fX2>fX1) {
566  this->SetX1(gPad->PixeltoX(p.GetX())-0.5*w);
567  this->SetX2(gPad->PixeltoX(p.GetX())+0.5*w);
568  }
569  else {
570  this->SetX2(gPad->PixeltoX(p.GetX())-0.5*w);
571  this->SetX1(gPad->PixeltoX(p.GetX())+0.5*w);
572  }
573  if (fY2>fY1) {
574  this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
575  this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
576  }
577  else {
578  this->SetY2(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))-0.5*h);
579  this->SetY1(gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0))+0.5*h);
580  }
581 }
582 
583 ////////////////////////////////////////////////////////////////////////////////
584 /// Set X coordinate of the center of the BoundingBox
585 
586 void TLine::SetBBoxCenterX(const Int_t x)
587 {
588  Double_t w = TMath::Max(fX1, fX2)-TMath::Min(fX1, fX2);
589  if (fX2>fX1) {
590  this->SetX1(gPad->PixeltoX(x)-0.5*w);
591  this->SetX2(gPad->PixeltoX(x)+0.5*w);
592  }
593  else {
594  this->SetX2(gPad->PixeltoX(x)-0.5*w);
595  this->SetX1(gPad->PixeltoX(x)+0.5*w);
596  }
597 }
598 
599 ////////////////////////////////////////////////////////////////////////////////
600 /// Set Y coordinate of the center of the BoundingBox
601 
602 void TLine::SetBBoxCenterY(const Int_t y)
603 {
604  Double_t h = TMath::Max(fY1, fY2)-TMath::Min(fY1, fY2);
605  if (fY2>fY1) {
606  this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
607  this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
608  }
609  else {
610  this->SetY2(gPad->PixeltoY(y-gPad->VtoPixel(0))-0.5*h);
611  this->SetY1(gPad->PixeltoY(y-gPad->VtoPixel(0))+0.5*h);
612  }
613 }
614 
615 ////////////////////////////////////////////////////////////////////////////////
616 /// Set left hand side of BoundingBox to a value
617 /// (resize in x direction on left)
618 
619 void TLine::SetBBoxX1(const Int_t x)
620 {
621  if (fX2>fX1)
622  this->SetX1(gPad->PixeltoX(x));
623  else
624  this->SetX2(gPad->PixeltoX(x));
625 }
626 
627 ////////////////////////////////////////////////////////////////////////////////
628 /// Set right hand side of BoundingBox to a value
629 /// (resize in x direction on right)
630 
631 void TLine::SetBBoxX2(const Int_t x)
632 {
633  if (fX2>fX1)
634  this->SetX2(gPad->PixeltoX(x));
635  else
636  this->SetX1(gPad->PixeltoX(x));
637 }
638 
639 ////////////////////////////////////////////////////////////////////////////////
640 /// Set top of BoundingBox to a value (resize in y direction on top)
641 
642 void TLine::SetBBoxY1(const Int_t y)
643 {
644  if (fY2>fY1)
645  this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
646  else
647  this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
648 }
649 
650 ////////////////////////////////////////////////////////////////////////////////
651 /// Set bottom of BoundingBox to a value
652 /// (resize in y direction on bottom)
653 
654 void TLine::SetBBoxY2(const Int_t y)
655 {
656  if (fY2>fY1)
657  this->SetY1(gPad->PixeltoY(y - gPad->VtoPixel(0)));
658  else
659  this->SetY2(gPad->PixeltoY(y - gPad->VtoPixel(0)));
660 }