TEllipse.cxx

Go to the documentation of this file.
00001 // @(#)root/graf:$Id: TEllipse.cxx 35160 2010-09-06 10:17:37Z couet $
00002 // Author: Rene Brun   16/10/95
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include <stdlib.h>
00013 
00014 #include "Riostream.h"
00015 #include "TROOT.h"
00016 #include "TEllipse.h"
00017 #include "TVirtualPad.h"
00018 #include "TMath.h"
00019 #include "TClass.h"
00020 
00021 const Double_t kPI = 3.14159265358979323846;
00022 
00023 ClassImp(TEllipse)
00024 
00025 
00026 //______________________________________________________________________________
00027 /* Begin_Html
00028 <center><h2>TEllipse : to draw ellipses</h2></center>
00029 The ellipse can be truncated and rotated.
00030 It is defined by its center <tt>(x1,y1)</tt> and two radius
00031 <tt>r1</tt> and <tt>r2</tt>.
00032 A minimum and maximum angle may be specified <tt>(phimin, phimax)</tt>.
00033 The ellipse may be rotated with an angle <tt>theta</tt>. All these
00034 angles are in degrees.
00035 The attributes of the outline line are given via <tt>TAttLine</tt>.
00036 The attributes of the fill area are given via <tt>TAttFill</tt>.
00037 The picture below illustrates different types of ellipses.
00038 <p>
00039 When an ellipse sector only is drawn, the lines connecting the center
00040 of the ellipse to the edges are drawn by default. One can specify
00041 the drawing option "only" to not draw these lines or alternatively
00042 call the function <tt>SetNoEdges()</tt>. To remove completely the ellipse
00043 outline it is enough to specify 0 as line style.
00044 End_Html
00045 Begin_Macro(source)
00046 ../../../tutorials/graphics/ellipse.C
00047 End_Macro */
00048 
00049 
00050 //______________________________________________________________________________
00051 TEllipse::TEllipse(): TObject(), TAttLine(), TAttFill()
00052 {
00053    // Ellipse default constructor.
00054 
00055    fX1 = 0;
00056    fY1 = 0;
00057    fR1 = 1;
00058    fR2 = 1;
00059    fPhimin = 0;
00060    fPhimax = 360;
00061    fTheta  = 0;
00062 }
00063 
00064 
00065 //______________________________________________________________________________
00066 TEllipse::TEllipse(Double_t x1, Double_t y1,Double_t r1,Double_t r2,Double_t phimin,Double_t phimax,Double_t theta)
00067       :TObject(), TAttLine(), TAttFill(0,1001)
00068 {
00069    // Ellipse normal constructor.
00070 
00071    fX1     = x1;
00072    fY1     = y1;
00073    fR1     = r1;
00074    fR2     = r2;
00075    fPhimin = phimin;
00076    fPhimax = phimax;
00077    fTheta  = theta;
00078    if (r2 <= 0) fR2 = fR1;
00079 }
00080 
00081 
00082 //______________________________________________________________________________
00083 TEllipse::~TEllipse()
00084 {
00085    // Ellipse default destructor.
00086 
00087 }
00088 
00089 
00090 //______________________________________________________________________________
00091 TEllipse::TEllipse(const TEllipse &ellipse) : TObject(ellipse), TAttLine(ellipse), TAttFill(ellipse)
00092 {
00093    // Copy constructor.
00094 
00095    fX1 = 0;
00096    fY1 = 0;
00097    fR1 = 1;
00098    fR2 = 1;
00099    fPhimin = 0;
00100    fPhimax = 360;
00101    fTheta  = 0;
00102 
00103    ((TEllipse&)ellipse).Copy(*this);
00104 }
00105 
00106 
00107 //______________________________________________________________________________
00108 void TEllipse::Copy(TObject &obj) const
00109 {
00110    // Copy this ellipse to ellipse.
00111 
00112    TObject::Copy(obj);
00113    TAttLine::Copy(((TEllipse&)obj));
00114    TAttFill::Copy(((TEllipse&)obj));
00115    ((TEllipse&)obj).fX1 = fX1;
00116    ((TEllipse&)obj).fY1 = fY1;
00117    ((TEllipse&)obj).fR1 = fR1;
00118    ((TEllipse&)obj).fR2 = fR2;
00119    ((TEllipse&)obj).fPhimin = fPhimin;
00120    ((TEllipse&)obj).fPhimax = fPhimax;
00121    ((TEllipse&)obj).fTheta  = fTheta;
00122 }
00123 
00124 
00125 //______________________________________________________________________________
00126 Int_t TEllipse::DistancetoPrimitive(Int_t px, Int_t py)
00127 {
00128    // Compute distance from point px,py to an ellipse.
00129    //
00130    // Compute the closest distance of approach from point px,py to this
00131    // ellipse. The distance is computed in pixels units.
00132    //
00133    // In case of a filled ellipse the distance returned is 0 if the point
00134    // (px,py) is inside the ellipse, and is huge if the point is outside.
00135 
00136    Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px));
00137    Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
00138 
00139    Double_t dxnr = x - fX1;
00140    Double_t dynr = y - fY1;
00141 
00142    Double_t ct = TMath::Cos(kPI*GetTheta()/180.0);
00143    Double_t st = TMath::Sin(kPI*GetTheta()/180.0);
00144 
00145    Double_t dx =  dxnr*ct + dynr*st;
00146    Double_t dy = -dxnr*st + dynr*ct;
00147 
00148    Double_t r1 = fR1;
00149    Double_t r2 = fR2;
00150 
00151    if (dx == 0 || r1 == 0 || r2 == 0) return 9999;
00152    Double_t distp = TMath::Sqrt(dx*dx + dy*dy);
00153 
00154    Double_t tana = dy/dx;
00155    tana *= tana;
00156    Double_t distr = TMath::Sqrt((1+tana)/(1.0/(r1*r1) + tana/(r2*r2)));
00157    Int_t dist = 9999;
00158    if (GetFillColor() && GetFillStyle()) {
00159       if (distr > distp) dist = 0;
00160    } else {
00161       if (TMath::Abs(distr-distp)/(r1+r2) < 0.01) dist = 0;
00162    }
00163    return dist;
00164 }
00165 
00166 
00167 //______________________________________________________________________________
00168 void TEllipse::Draw(Option_t *option)
00169 {
00170    // Draw this ellipse with its current attributes.
00171 
00172    AppendPad(option);
00173 
00174 }
00175 
00176 
00177 //______________________________________________________________________________
00178 void TEllipse::DrawEllipse(Double_t x1, Double_t y1,Double_t r1,Double_t r2,Double_t phimin,Double_t phimax,Double_t theta,Option_t *option)
00179 {
00180    // Draw this ellipse with new coordinates.
00181 
00182    TEllipse *newellipse = new TEllipse(x1, y1, r1, r2, phimin, phimax,theta);
00183    TAttLine::Copy(*newellipse);
00184    TAttFill::Copy(*newellipse);
00185    newellipse->SetBit(kCanDelete);
00186    newellipse->AppendPad(option);
00187    if (TestBit(kNoEdges)) newellipse->SetBit(kNoEdges);
00188 }
00189 
00190 
00191 //______________________________________________________________________________
00192 void TEllipse::ExecuteEvent(Int_t event, Int_t px, Int_t py)
00193 {
00194    // Execute action corresponding to one event.
00195    //
00196    //  This member function is called when a line is clicked with the locator
00197    //
00198    //  If Left button clicked on one of the line end points, this point
00199    //     follows the cursor until button is released.
00200    //
00201    //  if Middle button clicked, the line is moved parallel to itself
00202    //     until the button is released.
00203    //
00204    //  NOTE that support for log scale is not implemented
00205 
00206    Int_t kMaxDiff = 10;
00207    const Int_t kMinSize = 25;
00208    const Int_t np = 40;
00209    static Int_t x[np+2], y[np+2];
00210    static Int_t px1,py1,npe,r1,r2,sav1,sav2;
00211    static Int_t pxold, pyold;
00212    static Int_t sig,impair;
00213    Int_t i, dpx, dpy;
00214    Double_t angle,dx,dy,dphi,ct,st,fTy,fBy,fLx,fRx;
00215    static Bool_t pTop, pL, pR, pBot, pINSIDE;
00216    static Int_t pTx,pTy,pLx,pLy,pRx,pRy,pBx,pBy;
00217 
00218    if (!gPad->IsEditable()) return;
00219 
00220    switch (event) {
00221 
00222    case kButton1Down:
00223       gVirtualX->SetLineColor(-1);
00224       TAttLine::Modify();
00225       dphi = (fPhimax-fPhimin)*kPI/(180*np);
00226       ct   = TMath::Cos(kPI*fTheta/180);
00227       st   = TMath::Sin(kPI*fTheta/180);
00228       for (i=0;i<np;i++) {
00229          angle = fPhimin*kPI/180 + Double_t(i)*dphi;
00230          dx    = fR1*TMath::Cos(angle);
00231          dy    = fR2*TMath::Sin(angle);
00232          x[i]  = gPad->XtoAbsPixel(fX1 + dx*ct - dy*st);
00233          y[i]  = gPad->YtoAbsPixel(fY1 + dx*st + dy*ct);
00234       }
00235       if (fPhimax-fPhimin >= 360 ) {
00236          x[np] = x[0];
00237          y[np] = y[0];
00238          npe = np;
00239       } else {
00240          x[np]   = gPad->XtoAbsPixel(fX1);
00241          y[np]   = gPad->YtoAbsPixel(fY1);
00242          x[np+1] = x[0];
00243          y[np+1] = y[0];
00244          npe = np + 1;
00245       }
00246       impair = 0;
00247       px1 = gPad->XtoAbsPixel(fX1);
00248       py1 = gPad->YtoAbsPixel(fY1);
00249       pTx = pBx = px1;
00250       pLy = pRy = py1;
00251       pTy = gPad->YtoAbsPixel(fR2+fY1);
00252       pBy = gPad->YtoAbsPixel(-fR2+fY1);
00253       pLx = gPad->XtoAbsPixel(-fR1+fX1);
00254       pRx = gPad->XtoAbsPixel(fR1+fX1);
00255       r2 = (pBy-pTy)/2;
00256       r1 = (pRx-pLx)/2;
00257       gVirtualX->DrawLine(pRx+4, py1+4, pRx-4, py1+4);
00258       gVirtualX->DrawLine(pRx-4, py1+4, pRx-4, py1-4);
00259       gVirtualX->DrawLine(pRx-4, py1-4, pRx+4, py1-4);
00260       gVirtualX->DrawLine(pRx+4, py1-4, pRx+4, py1+4);
00261       gVirtualX->DrawLine(pLx+4, py1+4, pLx-4, py1+4);
00262       gVirtualX->DrawLine(pLx-4, py1+4, pLx-4, py1-4);
00263       gVirtualX->DrawLine(pLx-4, py1-4, pLx+4, py1-4);
00264       gVirtualX->DrawLine(pLx+4, py1-4, pLx+4, py1+4);
00265       gVirtualX->DrawLine(px1+4, pBy+4, px1-4, pBy+4);
00266       gVirtualX->DrawLine(px1-4, pBy+4, px1-4, pBy-4);
00267       gVirtualX->DrawLine(px1-4, pBy-4, px1+4, pBy-4);
00268       gVirtualX->DrawLine(px1+4, pBy-4, px1+4, pBy+4);
00269       gVirtualX->DrawLine(px1+4, pTy+4, px1-4, pTy+4);
00270       gVirtualX->DrawLine(px1-4, pTy+4, px1-4, pTy-4);
00271       gVirtualX->DrawLine(px1-4, pTy-4, px1+4, pTy-4);
00272       gVirtualX->DrawLine(px1+4, pTy-4, px1+4, pTy+4);
00273       // No break !!!
00274 
00275    case kMouseMotion:
00276       px1 = gPad->XtoAbsPixel(fX1);
00277       py1 = gPad->YtoAbsPixel(fY1);
00278       pTx = pBx = px1;
00279       pLy = pRy = py1;
00280       pTy = gPad->YtoAbsPixel(fR2+fY1);
00281       pBy = gPad->YtoAbsPixel(-fR2+fY1);
00282       pLx = gPad->XtoAbsPixel(-fR1+fX1);
00283       pRx = gPad->XtoAbsPixel(fR1+fX1);
00284       pTop = pL = pR = pBot = pINSIDE = kFALSE;
00285       if ((TMath::Abs(px - pTx) < kMaxDiff) &&
00286           (TMath::Abs(py - pTy) < kMaxDiff)) {             // top edge
00287          pTop = kTRUE;
00288          gPad->SetCursor(kTopSide);
00289       }
00290       else
00291       if ((TMath::Abs(px - pBx) < kMaxDiff) &&
00292           (TMath::Abs(py - pBy) < kMaxDiff)) {             // bottom edge
00293          pBot = kTRUE;
00294          gPad->SetCursor(kBottomSide);
00295       }
00296       else
00297       if ((TMath::Abs(py - pLy) < kMaxDiff) &&
00298           (TMath::Abs(px - pLx) < kMaxDiff)) {             // left edge
00299          pL = kTRUE;
00300          gPad->SetCursor(kLeftSide);
00301       }
00302       else
00303       if ((TMath::Abs(py - pRy) < kMaxDiff) &&
00304           (TMath::Abs(px - pRx) < kMaxDiff)) {             // right edge
00305          pR = kTRUE;
00306          gPad->SetCursor(kRightSide);
00307       }
00308       else {pINSIDE= kTRUE; gPad->SetCursor(kMove); }
00309       pxold = px;  pyold = py;
00310 
00311       break;
00312 
00313    case kButton1Motion:
00314       gVirtualX->DrawLine(pRx+4, py1+4, pRx-4, py1+4);
00315       gVirtualX->DrawLine(pRx-4, py1+4, pRx-4, py1-4);
00316       gVirtualX->DrawLine(pRx-4, py1-4, pRx+4, py1-4);
00317       gVirtualX->DrawLine(pRx+4, py1-4, pRx+4, py1+4);
00318       gVirtualX->DrawLine(pLx+4, py1+4, pLx-4, py1+4);
00319       gVirtualX->DrawLine(pLx-4, py1+4, pLx-4, py1-4);
00320       gVirtualX->DrawLine(pLx-4, py1-4, pLx+4, py1-4);
00321       gVirtualX->DrawLine(pLx+4, py1-4, pLx+4, py1+4);
00322       gVirtualX->DrawLine(px1+4, pBy+4, px1-4, pBy+4);
00323       gVirtualX->DrawLine(px1-4, pBy+4, px1-4, pBy-4);
00324       gVirtualX->DrawLine(px1-4, pBy-4, px1+4, pBy-4);
00325       gVirtualX->DrawLine(px1+4, pBy-4, px1+4, pBy+4);
00326       gVirtualX->DrawLine(px1+4, pTy+4, px1-4, pTy+4);
00327       gVirtualX->DrawLine(px1-4, pTy+4, px1-4, pTy-4);
00328       gVirtualX->DrawLine(px1-4, pTy-4, px1+4, pTy-4);
00329       gVirtualX->DrawLine(px1+4, pTy-4, px1+4, pTy+4);
00330       for (i=0;i<npe;i++) gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
00331       if (pTop) {
00332          sav1 = py1;
00333          sav2 = r2;
00334          py1 += (py - pyold)/2;
00335          r2 -= (py - pyold)/2;
00336          if (TMath::Abs(pyold-py)%2==1) impair++;
00337          if (py-pyold>0) sig=+1;
00338          else sig=-1;
00339          if (impair==2) { impair = 0; py1 += sig; r2 -= sig;}
00340          if (py1 > pBy-kMinSize) {py1 = sav1; r2 = sav2; py = pyold;}
00341       }
00342       if (pBot) {
00343          sav1 = py1;
00344          sav2 = r2;
00345          py1 += (py - pyold)/2;
00346          r2 += (py - pyold)/2;
00347          if (TMath::Abs(pyold-py)%2==1) impair++;
00348          if (py-pyold>0) sig=+1;
00349          else sig=-1;
00350          if (impair==2) { impair = 0; py1 += sig; r2 += sig;}
00351          if (py1 < pTy+kMinSize) {py1 = sav1; r2 = sav2; py = pyold;}
00352       }
00353       if (pL) {
00354          sav1 = px1;
00355          sav2 = r1;
00356          px1 += (px - pxold)/2;
00357          r1 -= (px - pxold)/2;
00358          if (TMath::Abs(pxold-px)%2==1) impair++;
00359          if (px-pxold>0) sig=+1;
00360          else sig=-1;
00361          if (impair==2) { impair = 0; px1 += sig; r1 -= sig;}
00362          if (px1 > pRx-kMinSize) {px1 = sav1; r1 = sav2; px = pxold;}
00363       }
00364       if (pR) {
00365          sav1 = px1;
00366          sav2 = r1;
00367          px1 += (px - pxold)/2;
00368          r1 += (px - pxold)/2;
00369          if (TMath::Abs(pxold-px)%2==1) impair++;
00370          if (px-pxold>0) sig=+1;
00371          else sig=-1;
00372          if (impair==2) { impair = 0; px1 += sig; r1 += sig;}
00373          if (px1 < pLx+kMinSize) {px1 = sav1; r1 = sav2; px = pxold;}
00374       }
00375       if (pTop || pBot || pL || pR) {
00376          gVirtualX->SetLineColor(-1);
00377          TAttLine::Modify();
00378          dphi = (fPhimax-fPhimin)*kPI/(180*np);
00379          ct   = TMath::Cos(kPI*fTheta/180);
00380          st   = TMath::Sin(kPI*fTheta/180);
00381          for (i=0;i<np;i++) {
00382             angle = fPhimin*kPI/180 + Double_t(i)*dphi;
00383             dx    = r1*TMath::Cos(angle);
00384             dy    = r2*TMath::Sin(angle);
00385             x[i]  = px1 + Int_t(dx*ct - dy*st);
00386             y[i]  = py1 + Int_t(dx*st + dy*ct);
00387          }
00388          if (fPhimax-fPhimin >= 360 ) {
00389             x[np] = x[0];
00390             y[np] = y[0];
00391             npe = np;
00392          } else {
00393             x[np]   = px1;
00394             y[np]   = py1;
00395             x[np+1] = x[0];
00396             y[np+1] = y[0];
00397             npe = np + 1;
00398          }
00399          for (i=0;i<npe;i++) gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
00400       }
00401       if (pINSIDE) {
00402          dpx  = px-pxold;  dpy = py-pyold;
00403          px1 += dpx; py1 += dpy;
00404          for (i=0;i<=npe;i++) { x[i] += dpx; y[i] += dpy;}
00405          for (i=0;i<npe;i++) gVirtualX->DrawLine(x[i], y[i], x[i+1], y[i+1]);
00406       }
00407       pTx = pBx = px1;
00408       pRx = px1+r1;
00409       pLx = px1-r1;
00410       pRy = pLy = py1;
00411       pTy = py1-r2;
00412       pBy = py1+r2;
00413       gVirtualX->DrawLine(pRx+4, py1+4, pRx-4, py1+4);
00414       gVirtualX->DrawLine(pRx-4, py1+4, pRx-4, py1-4);
00415       gVirtualX->DrawLine(pRx-4, py1-4, pRx+4, py1-4);
00416       gVirtualX->DrawLine(pRx+4, py1-4, pRx+4, py1+4);
00417       gVirtualX->DrawLine(pLx+4, py1+4, pLx-4, py1+4);
00418       gVirtualX->DrawLine(pLx-4, py1+4, pLx-4, py1-4);
00419       gVirtualX->DrawLine(pLx-4, py1-4, pLx+4, py1-4);
00420       gVirtualX->DrawLine(pLx+4, py1-4, pLx+4, py1+4);
00421       gVirtualX->DrawLine(px1+4, pBy+4, px1-4, pBy+4);
00422       gVirtualX->DrawLine(px1-4, pBy+4, px1-4, pBy-4);
00423       gVirtualX->DrawLine(px1-4, pBy-4, px1+4, pBy-4);
00424       gVirtualX->DrawLine(px1+4, pBy-4, px1+4, pBy+4);
00425       gVirtualX->DrawLine(px1+4, pTy+4, px1-4, pTy+4);
00426       gVirtualX->DrawLine(px1-4, pTy+4, px1-4, pTy-4);
00427       gVirtualX->DrawLine(px1-4, pTy-4, px1+4, pTy-4);
00428       gVirtualX->DrawLine(px1+4, pTy-4, px1+4, pTy+4);
00429       pxold = px;
00430       pyold = py;
00431       break;
00432 
00433    case kButton1Up:
00434       if (gROOT->IsEscaped()) {
00435          gROOT->SetEscape(kFALSE);
00436          break;
00437       }
00438 
00439       fX1 = gPad->AbsPixeltoX(px1);
00440       fY1 = gPad->AbsPixeltoY(py1);
00441       fBy = gPad->AbsPixeltoY(py1+r2);
00442       fTy = gPad->AbsPixeltoY(py1-r2);
00443       fLx = gPad->AbsPixeltoX(px1+r1);
00444       fRx = gPad->AbsPixeltoX(px1-r1);
00445       fR1 = TMath::Abs(fRx-fLx)/2;
00446       fR2 = TMath::Abs(fTy-fBy)/2;
00447       gPad->Modified(kTRUE);
00448       gVirtualX->SetLineColor(-1);
00449    }
00450 }
00451 
00452 
00453 //______________________________________________________________________________
00454 void TEllipse::ls(Option_t *) const
00455 {
00456    // List this ellipse with its attributes.
00457 
00458    TROOT::IndentLevel();
00459    printf("%s:  X1= %f Y1=%f R1=%f R2=%f\n",GetName(),fX1,fY1,fR1,fR2);
00460 }
00461 
00462 
00463 //______________________________________________________________________________
00464 void TEllipse::Paint(Option_t *option)
00465 {
00466    // Paint this ellipse with its current attributes.
00467 
00468    PaintEllipse(fX1,fY1,fR1,fR2,fPhimin,fPhimax,fTheta,option);
00469 }
00470 
00471 
00472 //______________________________________________________________________________
00473 void TEllipse::PaintEllipse(Double_t x1, Double_t y1, Double_t r1, Double_t r2,
00474                             Double_t phimin, Double_t phimax, Double_t theta,
00475                             Option_t *option)
00476 {
00477    // Draw this ellipse with new coordinates.
00478 
00479    const Int_t np = 200;
00480    static Double_t x[np+3], y[np+3];
00481    TAttLine::Modify();  //Change line attributes only if necessary
00482    TAttFill::Modify();  //Change fill attributes only if necessary
00483 
00484    Double_t phi1 = TMath::Min(phimin,phimax);
00485    Double_t phi2 = TMath::Max(phimin,phimax);
00486 
00487    //set number of points approximatively proportional to the ellipse circumference
00488    Double_t circ = kPI*(r1+r2)*(phi2-phi1)/360;
00489    Int_t n = (Int_t)(np*circ/((gPad->GetX2()-gPad->GetX1())+(gPad->GetY2()-gPad->GetY1())));
00490    if (n < 8) n= 8;
00491    if (n > np) n = np;
00492    Double_t angle,dx,dy;
00493    Double_t dphi = (phi2-phi1)*kPI/(180*n);
00494    Double_t ct   = TMath::Cos(kPI*theta/180);
00495    Double_t st   = TMath::Sin(kPI*theta/180);
00496    for (Int_t i=0;i<=n;i++) {
00497       angle = phi1*kPI/180 + Double_t(i)*dphi;
00498       dx    = r1*TMath::Cos(angle);
00499       dy    = r2*TMath::Sin(angle);
00500       x[i]  = gPad->XtoPad(x1 + dx*ct - dy*st);
00501       y[i]  = gPad->YtoPad(y1 + dx*st + dy*ct);
00502    }
00503    TString opt = option;
00504    opt.ToLower();
00505    if (phi2-phi1 >= 360 ) {
00506       if (GetFillStyle()) gPad->PaintFillArea(n,x,y);
00507       if (GetLineStyle()) gPad->PaintPolyLine(n+1,x,y);
00508    } else {
00509       x[n+1] = gPad->XtoPad(x1);
00510       y[n+1] = gPad->YtoPad(y1);
00511       x[n+2] = x[0];
00512       y[n+2] = y[0];
00513       if (GetFillStyle()) gPad->PaintFillArea(n+2,x,y);
00514       if (GetLineStyle()) {
00515          if (TestBit(kNoEdges) || opt.Contains("only")) gPad->PaintPolyLine(n+1,x,y);
00516          else                                           gPad->PaintPolyLine(n+3,x,y);
00517       }
00518    }
00519 }
00520 
00521 
00522 //______________________________________________________________________________
00523 void TEllipse::Print(Option_t *) const
00524 {
00525    // Dump this ellipse with its attributes.
00526 
00527    printf("Ellipse:  X1=%f Y1=%f R1=%f R2=%f",fX1,fY1,fR1,fR2);
00528    if (GetLineColor() != 1) printf(" Color=%d",GetLineColor());
00529    if (GetLineStyle() != 1) printf(" Style=%d",GetLineStyle());
00530    if (GetLineWidth() != 1) printf(" Width=%d",GetLineWidth());
00531    printf("\n");
00532 }
00533 
00534 
00535 //______________________________________________________________________________
00536 void TEllipse::SavePrimitive(ostream &out, Option_t * /*= ""*/)
00537 {
00538    // Save primitive as a C++ statement(s) on output stream out
00539 
00540    out<<"   "<<endl;
00541    if (gROOT->ClassSaved(TEllipse::Class())) {
00542       out<<"   ";
00543    } else {
00544       out<<"   TEllipse *";
00545    }
00546    out<<"ellipse = new TEllipse("<<fX1<<","<<fY1<<","<<fR1<<","<<fR2
00547       <<","<<fPhimin<<","<<fPhimax<<","<<fTheta<<");"<<endl;
00548 
00549    SaveFillAttributes(out,"ellipse",0,1001);
00550    SaveLineAttributes(out,"ellipse",1,1,1);
00551 
00552    if (GetNoEdges()) out<<"   ellipse->SetNoEdges();"<<endl;
00553 
00554    out<<"   ellipse->Draw();"<<endl;
00555 }
00556 
00557 
00558 //______________________________________________________________________________
00559 Bool_t TEllipse::GetNoEdges() const
00560 {
00561    // Return kTRUE if kNoEdges bit is set, kFALSE otherwise.
00562 
00563    return TestBit(kNoEdges) ? kTRUE : kFALSE;
00564 }
00565 
00566 
00567 //______________________________________________________________________________
00568 void TEllipse::SetNoEdges(Bool_t noEdges)
00569 {
00570    // if  noEdges = kTRUE the lines connecting the center to the edges
00571    // will not be drawn.
00572    // default is to draw the edges.
00573 
00574    if (noEdges) SetBit(kNoEdges);
00575    else         ResetBit(kNoEdges);
00576 }
00577 
00578 
00579 //______________________________________________________________________________
00580 void TEllipse::Streamer(TBuffer &R__b)
00581 {
00582    // Stream an object of class TEllipse.
00583 
00584    if (R__b.IsReading()) {
00585       UInt_t R__s, R__c;
00586       Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
00587       if (R__v > 1) {
00588          R__b.ReadClassBuffer(TEllipse::Class(), this, R__v, R__s, R__c);
00589          return;
00590       }
00591       //====process old versions before automatic schema evolution
00592       TObject::Streamer(R__b);
00593       TAttLine::Streamer(R__b);
00594       TAttFill::Streamer(R__b);
00595       Float_t x1,y1,r1,r2,phimin,phimax,theta;
00596       R__b >> x1;     fX1 = x1;
00597       R__b >> y1;     fY1 = y1;
00598       R__b >> r1;     fR1 = r1;
00599       R__b >> r2;     fR2 = r2;
00600       R__b >> phimin; fPhimin = phimin;
00601       R__b >> phimax; fPhimax = phimax;
00602       R__b >> theta;  fTheta  = theta;
00603       R__b.CheckByteCount(R__s, R__c, TEllipse::IsA());
00604       //====end of old versions
00605 
00606    } else {
00607       R__b.WriteClassBuffer(TEllipse::Class(),this);
00608    }
00609 }

Generated on Tue Jul 5 14:14:27 2011 for ROOT_528-00b_version by  doxygen 1.5.1