ROOT  6.06/09
Reference Guide
TCurlyArc.cxx
Go to the documentation of this file.
1 // @(#)root/graf:$Id$
2 // Author: Otto Schaile 20/11/99
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 /** \class TCurlyArc
13 \ingroup BasicGraphics
14 
15 Implements curly or wavy arcs used to draw Feynman diagrams.
16 
17 Amplitudes and wavelengths may be specified in the constructors,
18 via commands or interactively from popup menus.
19 The class make use of TCurlyLine by inheritance, ExecuteEvent methods
20 are highly inspired from the methods used in TPolyLine and TArc.
21 The picture below has been generated by the tutorial feynman.
22 
23 Begin_Macro(source)
24 ../../../tutorials/graphics/feynman.C
25 End_Macro
26 */
27 
28 #include "Riostream.h"
29 #include "TCurlyArc.h"
30 #include "TROOT.h"
31 #include "TVirtualPad.h"
32 #include "TVirtualX.h"
33 #include "TMath.h"
34 #include "TPoint.h"
35 
39 
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Default constructor
44 
46 {
47  fR1 = 0.;
48  fPhimin = 0.;
49  fPhimax = 0.;
50  fTheta = 0.;
51 }
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 /// Create a new TCurlyArc with center (x1, y1) and radius rad.
55 /// The wavelength and amplitude are given in percent of the line length
56 /// phimin and phimax are given in degrees.
57 
59  Double_t rad, Double_t phimin, Double_t phimax,
60  Double_t wl, Double_t amp)
61  : fR1(rad), fPhimin(phimin),fPhimax(phimax)
62 {
63  fX1 = x1;
64  fY1 = y1;
66  fAmplitude = amp;
67  fWaveLength = wl;
68  fTheta = 0;
69  Build();
70 }
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 /// Create a curly (Gluon) or wavy (Gamma) arc.
74 
75 void TCurlyArc::Build()
76 {
77  Double_t pixeltoX = 1;
78  Double_t pixeltoY = 1;
79  Double_t rPix = fR1;
80  if (gPad) {
81  Double_t ww = (Double_t)gPad->GetWw();
82  Double_t wh = (Double_t)gPad->GetWh();
83  Double_t pxrange = gPad->GetAbsWNDC()*ww;
84  Double_t pyrange = - gPad->GetAbsHNDC()*wh;
85  Double_t xrange = gPad->GetX2() - gPad->GetX1();
86  Double_t yrange = gPad->GetY2() - gPad->GetY1();
87  pixeltoX = xrange / pxrange;
88  pixeltoY = yrange/pyrange;
89  rPix = fR1 / pixeltoX;
90  }
91  Double_t dang = fPhimax - fPhimin;
92  if (dang < 0) dang += 360;
93  Double_t length = TMath::Pi() * fR1 * dang/180;
94  Double_t x1sav = fX1;
95  Double_t y1sav = fY1;
96  fX1 = fY1 = 0;
97  fX2 = length;
98  fY2 = 0;
100  fX1 = x1sav;
101  fY1 = y1sav;
102  Double_t *xv= GetX();
103  Double_t *yv= GetY();
104  Double_t xx, yy, angle;
105  for(Int_t i = 0; i < fNsteps; i++){
106  angle = xv[i] / rPix + fPhimin * TMath::Pi()/180;
107  xx = (yv[i] + rPix) * cos(angle);
108  yy = (yv[i] + rPix) * sin(angle);
109  xx *= pixeltoX;
110  yy *= TMath::Abs(pixeltoY);
111  xv[i] = xx + fX1;
112  yv[i] = yy + fY1;
113  }
114  if (gPad) gPad->Modified();
115 }
116 
117 ////////////////////////////////////////////////////////////////////////////////
118 /// Compute distance from point px,py to an arc.
119 ///
120 /// Compute the closest distance of approach from point px,py to this arc.
121 /// The distance is computed in pixels units.
122 
124 {
125  // Compute distance of point to center of arc
126  Int_t pxc = gPad->XtoAbsPixel(fX1);
127  Int_t pyc = gPad->YtoAbsPixel(fY1);
128  Double_t dist = TMath::Sqrt(Double_t((pxc-px)*(pxc-px)+(pyc-py)*(pyc-py)));
129  Double_t cosa = (px - pxc)/dist;
130  Double_t sina = (pyc - py)/dist;
131  Double_t phi = TMath::ATan2(sina,cosa);
132  if (phi < 0) phi += 2 * TMath::Pi();
133  phi = phi * 180 / TMath::Pi();
134  if (fPhimax > fPhimin){
135  if (phi < fPhimin || phi > fPhimax) return 9999;
136  } else {
137  if (phi > fPhimin && phi < fPhimax) return 9999;
138  }
139  Int_t pxr = gPad->XtoPixel(fR1)- gPad->XtoPixel(0);
140  Double_t distr = TMath::Abs(dist-pxr);
141  return Int_t(distr);
142 }
143 
144 ////////////////////////////////////////////////////////////////////////////////
145 /// Execute action corresponding to one event.
146 ///
147 /// This member function is called when a TCurlyArc is clicked with the locator
148 ///
149 /// If Left button clicked on one of the line end points, this point
150 /// follows the cursor until button is released.
151 ///
152 /// if Middle button clicked, the line is moved parallel to itself
153 /// until the button is released.
154 
155 void TCurlyArc::ExecuteEvent(Int_t event, Int_t px, Int_t py)
156 {
157  if (!gPad) return;
158 
159  Int_t kMaxDiff = 10;
160  const Int_t np = 10;
161  const Double_t pi = TMath::Pi();
162  static Int_t x[np+3], y[np+3];
163  static Int_t px1,py1,npe,r1;
164  static Int_t pxold, pyold;
165  Int_t i, dpx, dpy;
166  Double_t angle,dx,dy,dphi,rLx,rRx;
167  Double_t phi0;
168  static Bool_t pTop, pL, pR, pBot, pINSIDE;
169  static Int_t pTx,pTy,pLx,pLy,pRx,pRy,pBx,pBy;
170 
171  Bool_t opaque = gPad->OpaqueMoving();
172 
173  switch (event) {
174 
175  case kArrowKeyPress:
176  case kButton1Down:
177  if (!opaque) {
178  gVirtualX->SetLineColor(-1);
180  dphi = (fPhimax-fPhimin) * pi / 180;
181  if (dphi<0) dphi += 2 * pi;
182  dphi /= np;
183  phi0 = fPhimin * pi / 180;
184  for (i=0;i<=np;i++) {
185  angle = Double_t(i)*dphi + phi0;
186  dx = fR1*TMath::Cos(angle);
187  dy = fR1*TMath::Sin(angle);
188  Int_t rpixY = gPad->XtoAbsPixel(dy) - gPad->XtoAbsPixel(0);
189  x[i] = gPad->XtoAbsPixel(fX1 + dx);
190  y[i] = gPad->YtoAbsPixel(fY1) + rpixY;
191  }
192  if (fPhimax-fPhimin >= 360 ) {
193  x[np+1] = x[0];
194  y[np+1] = y[0];
195  npe = np;
196  } else {
197  x[np+1] = gPad->XtoAbsPixel(fX1);
198  y[np+1] = gPad->YtoAbsPixel(fY1);
199  x[np+2] = x[0];
200  y[np+2] = y[0];
201  npe = np + 2;
202  }
203  }
204  px1 = gPad->XtoAbsPixel(fX1);
205  py1 = gPad->YtoAbsPixel(fY1);
206  pTx = pBx = px1;
207  pLy = pRy = py1;
208  pLx = gPad->XtoAbsPixel(-fR1+fX1);
209  pRx = gPad->XtoAbsPixel( fR1+fX1);
210  r1 = TMath::Abs(pLx-pRx)/2;
211  // a circle in pixels, radius measured along X
212  pTy = gPad->YtoAbsPixel(fY1) + r1;
213  pBy = gPad->YtoAbsPixel(fY1) - r1;
214 
215  if (!opaque) {
216  gVirtualX->DrawLine(pRx+4, py1+4, pRx-4, py1+4);
217  gVirtualX->DrawLine(pRx-4, py1+4, pRx-4, py1-4);
218  gVirtualX->DrawLine(pRx-4, py1-4, pRx+4, py1-4);
219  gVirtualX->DrawLine(pRx+4, py1-4, pRx+4, py1+4);
220  gVirtualX->DrawLine(pLx+4, py1+4, pLx-4, py1+4);
221  gVirtualX->DrawLine(pLx-4, py1+4, pLx-4, py1-4);
222  gVirtualX->DrawLine(pLx-4, py1-4, pLx+4, py1-4);
223  gVirtualX->DrawLine(pLx+4, py1-4, pLx+4, py1+4);
224  gVirtualX->DrawLine(px1+4, pBy+4, px1-4, pBy+4);
225  gVirtualX->DrawLine(px1-4, pBy+4, px1-4, pBy-4);
226  gVirtualX->DrawLine(px1-4, pBy-4, px1+4, pBy-4);
227  gVirtualX->DrawLine(px1+4, pBy-4, px1+4, pBy+4);
228  gVirtualX->DrawLine(px1+4, pTy+4, px1-4, pTy+4);
229  gVirtualX->DrawLine(px1-4, pTy+4, px1-4, pTy-4);
230  gVirtualX->DrawLine(px1-4, pTy-4, px1+4, pTy-4);
231  gVirtualX->DrawLine(px1+4, pTy-4, px1+4, pTy+4);
232  }
233  // No break !!!
234 
235  case kMouseMotion:
236  px1 = gPad->XtoAbsPixel(fX1);
237  py1 = gPad->YtoAbsPixel(fY1);
238  pTx = pBx = px1;
239  pLy = pRy = py1;
240  pLx = gPad->XtoAbsPixel(-fR1+fX1);
241  pRx = gPad->XtoAbsPixel( fR1+fX1);
242 
243  pTy = gPad->YtoAbsPixel(fY1) + TMath::Abs(pLx-pRx)/2;
244  pBy = gPad->YtoAbsPixel(fY1) - TMath::Abs(pLx-pRx)/2;
245 
246  pTop = pL = pR = pBot = pINSIDE = kFALSE;
247  if ((TMath::Abs(px - pTx) < kMaxDiff) &&
248  (TMath::Abs(py - pTy) < kMaxDiff)) { // top edge
249  pTop = kTRUE;
250  gPad->SetCursor(kTopSide);
251  }
252  else
253  if ((TMath::Abs(px - pBx) < kMaxDiff) &&
254  (TMath::Abs(py - pBy) < kMaxDiff)) { // bottom edge
255  pBot = kTRUE;
256  gPad->SetCursor(kBottomSide);
257  }
258  else
259  if ((TMath::Abs(py - pLy) < kMaxDiff) &&
260  (TMath::Abs(px - pLx) < kMaxDiff)) { // left edge
261  pL = kTRUE;
262  gPad->SetCursor(kLeftSide);
263  }
264  else
265  if ((TMath::Abs(py - pRy) < kMaxDiff) &&
266  (TMath::Abs(px - pRx) < kMaxDiff)) { // right edge
267  pR = kTRUE;
268  gPad->SetCursor(kRightSide);
269  }
270  else {pINSIDE= kTRUE; gPad->SetCursor(kMove); }
271  pxold = px; pyold = py;
272 
273  break;
274 
275  case kArrowKeyRelease:
276  case kButton1Motion:
277  if (!opaque) {
278  gVirtualX->DrawLine(pRx+4, py1+4, pRx-4, py1+4);
279  gVirtualX->DrawLine(pRx-4, py1+4, pRx-4, py1-4);
280  gVirtualX->DrawLine(pRx-4, py1-4, pRx+4, py1-4);
281  gVirtualX->DrawLine(pRx+4, py1-4, pRx+4, py1+4);
282  gVirtualX->DrawLine(pLx+4, py1+4, pLx-4, py1+4);
283  gVirtualX->DrawLine(pLx-4, py1+4, pLx-4, py1-4);
284  gVirtualX->DrawLine(pLx-4, py1-4, pLx+4, py1-4);
285  gVirtualX->DrawLine(pLx+4, py1-4, pLx+4, py1+4);
286  gVirtualX->DrawLine(px1+4, pBy+4, px1-4, pBy+4);
287  gVirtualX->DrawLine(px1-4, pBy+4, px1-4, pBy-4);
288  gVirtualX->DrawLine(px1-4, pBy-4, px1+4, pBy-4);
289  gVirtualX->DrawLine(px1+4, pBy-4, px1+4, pBy+4);
290  gVirtualX->DrawLine(px1+4, pTy+4, px1-4, pTy+4);
291  gVirtualX->DrawLine(px1-4, pTy+4, px1-4, pTy-4);
292  gVirtualX->DrawLine(px1-4, pTy-4, px1+4, pTy-4);
293  gVirtualX->DrawLine(px1+4, pTy-4, px1+4, pTy+4);
294  for (i=0;i<npe;i++) gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
295  }
296  if (pTop) {
297  r1 += (py - pyold);
298  }
299  if (pBot) {
300  r1 -= (py - pyold);
301  }
302  if (pL) {
303  r1 -= (px - pxold);
304  }
305  if (pR) {
306  r1 += (px - pxold);
307  }
308  if (pTop || pBot || pL || pR) {
309  if (!opaque) {
310  gVirtualX->SetLineColor(-1);
312  dphi = (fPhimax-fPhimin) * pi / 180;
313  if (dphi<0) dphi += 2 * pi;
314  dphi /= np;
315  phi0 = fPhimin * pi / 180;
316  Double_t ur1 = r1;
317  Int_t pX1 = gPad->XtoAbsPixel(fX1);
318  Int_t pY1 = gPad->YtoAbsPixel(fY1);
319  for (i=0;i<=np;i++) {
320  angle = Double_t(i)*dphi + phi0;
321  dx = ur1 * TMath::Cos(angle);
322  dy = ur1 * TMath::Sin(angle);
323  x[i] = pX1 + (Int_t)dx;
324  y[i] = pY1 + (Int_t)dy;
325  }
326  if (fPhimax-fPhimin >= 360 ) {
327  x[np+1] = x[0];
328  y[np+1] = y[0];
329  npe = np;
330  } else {
331  x[np+1] = pX1;
332  y[np+1] = pY1;
333  x[np+2] = x[0];
334  y[np+2] = y[0];
335  npe = np + 2;
336  }
337  for (i=0;i<npe;i++) {
338  gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
339  }
340  }
341  else {
342  this->SetStartPoint(gPad->AbsPixeltoX(px1), gPad->AbsPixeltoY(py1));
343  this->SetRadius(TMath::Abs(gPad->AbsPixeltoX(px1-r1)-gPad->AbsPixeltoX(px1+r1))/2);
344  if (pTop) gPad->ShowGuidelines(this, event, 't', true);
345  if (pBot) gPad->ShowGuidelines(this, event, 'b', true);
346  if (pL) gPad->ShowGuidelines(this, event, 'l', true);
347  if (pR) gPad->ShowGuidelines(this, event, 'r', true);
348  gPad->Modified(kTRUE);
349  gPad->Update();
350  }
351  }
352  if (pINSIDE) {
353  dpx = px-pxold; dpy = py-pyold;
354  px1 += dpx; py1 += dpy;
355  if (!opaque) {
356  for (i=0;i<=npe;i++) { x[i] += dpx; y[i] += dpy;}
357  for (i=0;i<npe;i++) gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
358  } else {
359  this->SetStartPoint(gPad->AbsPixeltoX(px1), gPad->AbsPixeltoY(py1));
360  gPad->ShowGuidelines(this, event, 'i', true);
361  gPad->Modified(kTRUE);
362  gPad->Update();
363  }
364  }
365  pTx = pBx = px1;
366  pRx = px1+r1;
367  pLx = px1-r1;
368  pRy = pLy = py1;
369  pTy = py1-r1;
370  pBy = py1+r1;
371  if (!opaque) {
372  gVirtualX->DrawLine(pRx+4, py1+4, pRx-4, py1+4);
373  gVirtualX->DrawLine(pRx-4, py1+4, pRx-4, py1-4);
374  gVirtualX->DrawLine(pRx-4, py1-4, pRx+4, py1-4);
375  gVirtualX->DrawLine(pRx+4, py1-4, pRx+4, py1+4);
376  gVirtualX->DrawLine(pLx+4, py1+4, pLx-4, py1+4);
377  gVirtualX->DrawLine(pLx-4, py1+4, pLx-4, py1-4);
378  gVirtualX->DrawLine(pLx-4, py1-4, pLx+4, py1-4);
379  gVirtualX->DrawLine(pLx+4, py1-4, pLx+4, py1+4);
380  gVirtualX->DrawLine(px1+4, pBy+4, px1-4, pBy+4);
381  gVirtualX->DrawLine(px1-4, pBy+4, px1-4, pBy-4);
382  gVirtualX->DrawLine(px1-4, pBy-4, px1+4, pBy-4);
383  gVirtualX->DrawLine(px1+4, pBy-4, px1+4, pBy+4);
384  gVirtualX->DrawLine(px1+4, pTy+4, px1-4, pTy+4);
385  gVirtualX->DrawLine(px1-4, pTy+4, px1-4, pTy-4);
386  gVirtualX->DrawLine(px1-4, pTy-4, px1+4, pTy-4);
387  gVirtualX->DrawLine(px1+4, pTy-4, px1+4, pTy+4);
388  }
389  pxold = px;
390  pyold = py;
391  break;
392 
393  case kButton1Up:
394  if (opaque) {
395  gPad->ShowGuidelines(this, event);
396  } else {
397  fX1 = gPad->AbsPixeltoX(px1);
398  fY1 = gPad->AbsPixeltoY(py1);
399  rLx = gPad->AbsPixeltoX(px1+r1);
400  rRx = gPad->AbsPixeltoX(px1-r1);
401  fR1 = TMath::Abs(rRx-rLx)/2;
402  }
403  Build();
404  gPad->Modified(kTRUE);
405  if (!opaque) gVirtualX->SetLineColor(-1);
406  }
407 }
408 
409 ////////////////////////////////////////////////////////////////////////////////
410 /// Save primitive as a C++ statement(s) on output stream out
411 
412 void TCurlyArc::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
413 {
414  if (gROOT->ClassSaved(TCurlyArc::Class())) {
415  out<<" ";
416  } else {
417  out<<" TCurlyArc *";
418  }
419  out<<"curlyarc = new TCurlyArc("
420  <<fX1<<","<<fY1<<","<<fR1<<","<<fPhimin<<","<<fPhimax<<","
421  <<fWaveLength<<","<<fAmplitude<<");"<<std::endl;
422  if (!fIsCurly) {
423  out<<" curlyarc->SetWavy();"<<std::endl;
424  }
425  SaveLineAttributes(out,"curlyarc",1,1,1);
426  out<<" curlyarc->Draw();"<<std::endl;
427 }
428 
429 ////////////////////////////////////////////////////////////////////////////////
430 /// Set Curly Arc center.
431 
433 {
434  fX1 = x;
435  fY1 = y;
436  Build();
437 }
438 
439 ////////////////////////////////////////////////////////////////////////////////
440 /// Set Curly Arc radius.
441 
443 {
444  fR1 = x;
445  Build();
446 }
447 
448 ////////////////////////////////////////////////////////////////////////////////
449 /// Set Curly Arc minimum Phi.
450 
452 {
453  fPhimin = x;
454  Build();
455 }
456 
457 ////////////////////////////////////////////////////////////////////////////////
458 /// Set Curly Arc maximum Phi.
459 
461 {
462  fPhimax = x;
463  Build();
464 }
465 
466 ////////////////////////////////////////////////////////////////////////////////
467 /// Set default wave length.
468 
470 {
471  fgDefaultWaveLength = WaveLength;
472 }
473 
474 ////////////////////////////////////////////////////////////////////////////////
475 /// Set default wave amplitude.
476 
478 {
479  fgDefaultAmplitude = Amplitude ;
480 }
481 
482 ////////////////////////////////////////////////////////////////////////////////
483 /// Set default "IsCurly".
484 
486 {
487  fgDefaultIsCurly = IsCurly;
488 }
489 
490 ////////////////////////////////////////////////////////////////////////////////
491 /// Get default wave length.
492 
494 {
495  return fgDefaultWaveLength;
496 }
497 
498 ////////////////////////////////////////////////////////////////////////////////
499 /// Get default wave amplitude.
500 
502 {
503  return fgDefaultAmplitude;
504 }
505 
506 ////////////////////////////////////////////////////////////////////////////////
507 /// Get default "IsCurly".
508 
510 {
511  return fgDefaultIsCurly;
512 }
513 
514 ////////////////////////////////////////////////////////////////////////////////
515 /// Return the bounding Box of the Line
516 
518 {
519  Double_t R2 = fR1 * TMath::Abs(gPad->GetY2()-gPad->GetY1())/TMath::Abs(gPad->GetX2()-gPad->GetX1());
520 
521  Rectangle_t BBox;
522  BBox.fX = gPad->XtoPixel(fX1-fR1);
523  BBox.fY = gPad->YtoPixel(fY1+R2);
524  BBox.fWidth = gPad->XtoPixel(fX1+fR1)-gPad->XtoPixel(fX1-fR1);
525  BBox.fHeight = gPad->YtoPixel(fY1-R2)-gPad->YtoPixel(fY1+R2);
526  return (BBox);
527 }
528 
529 ////////////////////////////////////////////////////////////////////////////////
530 /// Return the center of the BoundingBox as TPoint in pixels
531 
533 {
534  TPoint p;
535  p.SetX(gPad->XtoPixel(fX1));
536  p.SetY(gPad->YtoPixel(fY1));
537  return(p);
538 }
539 
540 ////////////////////////////////////////////////////////////////////////////////
541 /// Set center of the BoundingBox
542 
543 void TCurlyArc::SetBBoxCenter(const TPoint &p)
544 {
545  fX1 = gPad->PixeltoX(p.GetX());
546  fY1 = gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0));
547  Build();
548 }
549 
550 ////////////////////////////////////////////////////////////////////////////////
551 /// Set X coordinate of the center of the BoundingBox
552 
554 {
555  fX1 = gPad->PixeltoX(x);
556  Build();
557 }
558 
559 ////////////////////////////////////////////////////////////////////////////////
560 /// Set Y coordinate of the center of the BoundingBox
561 
563 {
564  fY1 = gPad->PixeltoY(y-gPad->VtoPixel(0));
565  Build();
566 }
567 
568 ////////////////////////////////////////////////////////////////////////////////
569 /// Set left hand side of BoundingBox to a value
570 /// (resize in x direction on left)
571 
572 void TCurlyArc::SetBBoxX1(const Int_t x)
573 {
574  Double_t x1 = gPad->PixeltoX(x);
575  if (x1>fX1+fR1) return;
576 
577  fR1 = (fX1+fR1-x1)*0.5;
578  fX1 = x1 + fR1;
579 }
580 
581 ////////////////////////////////////////////////////////////////////////////////
582 /// Set right hand side of BoundingBox to a value
583 /// (resize in x direction on right)
584 
585 void TCurlyArc::SetBBoxX2(const Int_t x)
586 {
587  Double_t x2 = gPad->PixeltoX(x);
588  if (x2<fX1-fR1) return;
589 
590  fR1 = (x2-fX1+fR1)*0.5;
591  fX1 = x2-fR1;
592 }
593 
594 ////////////////////////////////////////////////////////////////////////////////
595 /// Set top of BoundingBox to a value (resize in y direction on top)
596 
597 void TCurlyArc::SetBBoxY1(const Int_t y)
598 {
599  Double_t R2 = fR1 * TMath::Abs(gPad->GetY2()-gPad->GetY1())/TMath::Abs(gPad->GetX2()-gPad->GetX1());
600 
601  Double_t y1 = gPad->PixeltoY(y-gPad->VtoPixel(0));
602  if (y1<fY1-R2) return;
603 
604  fR1 = (y1-fY1+R2)*0.5 / (TMath::Abs(gPad->GetY2()-gPad->GetY1())/TMath::Abs(gPad->GetX2()-gPad->GetX1()));
605  fY1 = y1-R2;
606 }
607 
608 ////////////////////////////////////////////////////////////////////////////////
609 /// Set bottom of BoundingBox to a value
610 /// (resize in y direction on bottom)
611 
612 void TCurlyArc::SetBBoxY2(const Int_t y)
613 {
614  Double_t R2 = fR1 * TMath::Abs(gPad->GetY2()-gPad->GetY1())/TMath::Abs(gPad->GetX2()-gPad->GetX1());
615 
616  Double_t y2 = gPad->PixeltoY(y-gPad->VtoPixel(0));
617 
618  if (y2>fY1+R2) return;
619 
620  fR1 = (fY1+R2-y2)*0.5 / (TMath::Abs(gPad->GetY2()-gPad->GetY1())/TMath::Abs(gPad->GetX2()-gPad->GetX1()));
621  fY1 = y2+R2;
622 }
virtual void SetPhimax(Double_t phimax)
Set Curly Arc maximum Phi.
Definition: TCurlyArc.cxx:461
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
virtual void SetCenter(Double_t x1, Double_t y1)
Set Curly Arc center.
Definition: TCurlyArc.cxx:433
void SetX(SCoord_t x)
Definition: TPoint.h:51
static Double_t fgDefaultWaveLength
Definition: TCurlyArc.h:33
Bool_t fIsCurly
Definition: TCurlyLine.h:42
static Double_t GetDefaultAmplitude()
Get default wave amplitude.
Definition: TCurlyArc.cxx:502
Double_t * GetX() const
Definition: TPolyLine.h:69
const double pi
Double_t fY2
Definition: TCurlyLine.h:38
const char Option_t
Definition: RtypesCore.h:62
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TCurlyArc.cxx:156
static Bool_t GetDefaultIsCurly()
Get default "IsCurly".
Definition: TCurlyArc.cxx:510
Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to an arc.
Definition: TCurlyArc.cxx:124
Double_t fX1
Definition: TCurlyLine.h:35
static void SetDefaultIsCurly(Bool_t IsCurly)
Set default "IsCurly".
Definition: TCurlyArc.cxx:486
#define gROOT
Definition: TROOT.h:340
static Double_t GetDefaultWaveLength()
Get default wave length.
Definition: TCurlyArc.cxx:494
Double_t fY1
Definition: TCurlyLine.h:36
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void SetBBoxX2(const Int_t x)
Set right hand side of BoundingBox to a value (resize in x direction on right)
Definition: TCurlyArc.cxx:586
virtual void Modify()
Change current line attributes if necessary.
Definition: TAttLine.cxx:229
static Bool_t fgDefaultIsCurly
Definition: TCurlyArc.h:35
void SetY(SCoord_t y)
Definition: TPoint.h:52
Short_t Abs(Short_t d)
Definition: TMathBase.h:110
double cos(double)
ClassImp(TCurlyArc) TCurlyArc
Default constructor.
Definition: TCurlyArc.cxx:41
Double_t fR1
Definition: TCurlyArc.h:28
static const double x2[5]
Double_t x[n]
Definition: legend1.C:17
Double_t * GetY() const
Definition: TPolyLine.h:70
void Class()
Definition: Class.C:29
virtual void SetStartPoint(Double_t x1, Double_t y1)
Set start point.
Definition: TCurlyLine.cxx:397
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:257
virtual void SetBBoxY1(const Int_t y)
Set top of BoundingBox to a value (resize in y direction on top)
Definition: TCurlyArc.cxx:598
Double_t ATan2(Double_t, Double_t)
Definition: TMath.h:454
double sin(double)
SCoord_t GetY() const
Definition: TPoint.h:50
virtual void SetRadius(Double_t radius)
Set Curly Arc radius.
Definition: TCurlyArc.cxx:443
virtual void SetBBoxCenterX(const Int_t x)
Set X coordinate of the center of the BoundingBox.
Definition: TCurlyArc.cxx:554
char * out
Definition: TBase64.cxx:29
Short_t fX
Definition: GuiTypes.h:363
static Double_t fgDefaultAmplitude
Definition: TCurlyArc.h:34
Int_t fNsteps
Definition: TCurlyLine.h:41
Definition: TPoint.h:33
virtual void SetBBoxY2(const Int_t y)
Set bottom of BoundingBox to a value (resize in y direction on bottom)
Definition: TCurlyArc.cxx:613
virtual void Build()
Create a curly (Gluon) or wavy (Gamma) arc.
Definition: TCurlyArc.cxx:76
virtual void SetPhimin(Double_t phimin)
Set Curly Arc minimum Phi.
Definition: TCurlyArc.cxx:452
virtual Rectangle_t GetBBox()
Return the bounding Box of the Line.
Definition: TCurlyArc.cxx:518
Double_t length(const TVector2 &v)
Definition: CsgOps.cxx:347
static void SetDefaultAmplitude(Double_t Amplitude)
Set default wave amplitude.
Definition: TCurlyArc.cxx:478
unsigned int r1[N_CITIES]
Definition: simanTSP.cxx:321
Double_t fPhimin
Definition: TCurlyArc.h:29
virtual TPoint GetBBoxCenter()
Return the center of the BoundingBox as TPoint in pixels.
Definition: TCurlyArc.cxx:533
#define gVirtualX
Definition: TVirtualX.h:362
virtual void SetBBoxX1(const Int_t x)
Set left hand side of BoundingBox to a value (resize in x direction on left)
Definition: TCurlyArc.cxx:573
Double_t Cos(Double_t)
Definition: TMath.h:424
Double_t Pi()
Definition: TMath.h:44
static const double x1[5]
double Double_t
Definition: RtypesCore.h:55
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TCurlyArc.cxx:413
Double_t y[n]
Definition: legend1.C:17
SCoord_t GetX() const
Definition: TPoint.h:49
Double_t fX2
Definition: TCurlyLine.h:37
Double_t fWaveLength
Definition: TCurlyLine.h:39
Double_t fPhimax
Definition: TCurlyArc.h:30
Double_t fAmplitude
Definition: TCurlyLine.h:40
Double_t Sin(Double_t)
Definition: TMath.h:421
Double_t fTheta
Definition: TCurlyArc.h:31
virtual void SetBBoxCenter(const TPoint &p)
Set center of the BoundingBox.
Definition: TCurlyArc.cxx:544
#define gPad
Definition: TVirtualPad.h:288
Double_t Sqrt(Double_t x)
Definition: TMath.h:464
const Bool_t kTRUE
Definition: Rtypes.h:91
static void SetDefaultWaveLength(Double_t WaveLength)
Set default wave length.
Definition: TCurlyArc.cxx:470
Implements curly or wavy arcs used to draw Feynman diagrams.
Definition: TCurlyArc.h:25
virtual void SetBBoxCenterY(const Int_t y)
Set Y coordinate of the center of the BoundingBox.
Definition: TCurlyArc.cxx:563
virtual void Build()
Create a curly (Gluon) or wavy (Gamma) line.
Definition: TCurlyLine.cxx:78