13#include "BesVisLib/BesCircle2D.h"
14#include "BesVisLib/BesView.h"
31 if ( gDebug ) cout <<
"BesCircle2D ctor called" << endl;
36 f_innerCircleX = NULL;
37 f_innerCircleY = NULL;
38 f_outerCircleX = NULL;
39 f_outerCircleY = NULL;
47 TNamed(name,
title), TAttLine(), TAttFill() {
50 if ( gDebug ) cout <<
"BesCircle2D normal ctor called" << endl;
52 fCenter =
new Double_t[3];
53 for ( Int_t i = 0; i < 3; i++ ) fCenter[i] = center[i];
55 fInnerRadius = innerRadius;
56 fOuterRadius = outerRadius;
58 f_innerCircleX = NULL;
59 f_innerCircleY = NULL;
60 f_outerCircleX = NULL;
61 f_outerCircleY = NULL;
71 if ( gDebug ) cout <<
"BesCircle2D default dtor called" << endl;
80 const Int_t inaxis = 7;
83 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
84 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
85 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
86 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
89 if (px < puxmin - inaxis)
return dist;
90 if (py > puymin + inaxis)
return dist;
91 if (px > puxmax + inaxis)
return dist;
92 if (py < puymax - inaxis)
return dist;
95 if (!view)
return dist;
97 Double_t
x = gPad->PadtoX(gPad->AbsPixeltoX(px));
98 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
111 Double_t distw = 0.0;
112 for (Int_t i = 0; i < 2; i++) {
113 distw += (xwc[i]-fCenter[i]) * (xwc[i]-fCenter[i]);
117 if (distw >= fInnerRadius * fInnerRadius &&
118 distw <= fOuterRadius * fOuterRadius)
138 TString opt = option;
148 TString opt = option;
153 if (view == 0) cout <<
"no view found" << endl;
156 Int_t np = fNSegment;
159 delete [] f_innerCircleX;
160 f_innerCircleX = NULL;
163 delete [] f_innerCircleY;
164 f_innerCircleY = NULL;
167 delete [] f_outerCircleX;
168 f_outerCircleX = NULL;
171 delete [] f_outerCircleY;
172 f_outerCircleY = NULL;
183 f_innerCircleX =
new Double_t[np+1];
184 f_innerCircleY =
new Double_t[np+1];
185 f_outerCircleX =
new Double_t[np+1];
186 f_outerCircleY =
new Double_t[np+1];
187 f_areaX =
new Double_t[4*np];
188 f_areaY =
new Double_t[4*np];
194 Double_t dphi = 2*TMath::Pi()/(np);
195 Double_t pointWC[3],pointNDC[3];
197 for (Int_t i=0; i< np ; i++) {
198 angle = Double_t(i)*dphi;
202 pointWC[0] = fCenter[0] + fInnerRadius * TMath::Cos(angle);
203 pointWC[1] = fCenter[1] + fInnerRadius * TMath::Sin(angle);
204 pointWC[2] = fCenter[2];
205 view->
WCtoNDC(pointWC,pointNDC);
206 f_innerCircleX[i] = pointNDC[0];
207 f_innerCircleY[i] = pointNDC[1];
208 f_areaX[4*i] = pointNDC[0];
209 f_areaY[4*i] = pointNDC[1];
211 f_areaX[4*np - 3] = pointNDC[0];
212 f_areaY[4*np - 3] = pointNDC[1];
214 f_areaX[4*i - 3] = pointNDC[0];
215 f_areaY[4*i - 3] = pointNDC[1];
220 pointWC[0] = fCenter[0] + fOuterRadius * TMath::Cos(angle);
221 pointWC[1] = fCenter[1] + fOuterRadius * TMath::Sin(angle);
222 pointWC[2] = fCenter[2];
223 view->
WCtoNDC(pointWC,pointNDC);
224 f_outerCircleX[i] = pointNDC[0];
225 f_outerCircleY[i] = pointNDC[1];
226 f_areaX[4*i + 3] = pointNDC[0];
227 f_areaY[4*i + 3] = pointNDC[1];
229 f_areaX[4*np - 2] = pointNDC[0];
230 f_areaY[4*np - 2] = pointNDC[1];
232 f_areaX[4*i - 2] = pointNDC[0];
233 f_areaY[4*i - 2] = pointNDC[1];
239 f_innerCircleX[np] = f_innerCircleX[0];
240 f_innerCircleY[np] = f_innerCircleY[0];
241 f_outerCircleX[np] = f_outerCircleX[0];
242 f_outerCircleY[np] = f_outerCircleY[0];
245 for (Int_t i = 0; i < np; i++ ) {
246 gPad->PaintFillArea(4,&f_areaX[4*i],&f_areaY[4*i]);
251 gPad->PaintPolyLine(np+1,f_innerCircleX,f_innerCircleY);
252 gPad->PaintPolyLine(np+1,f_outerCircleX,f_outerCircleY);
261 else return TObject::GetObjectInfo(px, py);
277 for (Int_t i = 0; i < 3; i++) center[i] = fCenter[i];
ClassImp(BesCircle2D) BesCircle2D
virtual void Paint(Option_t *option="")
virtual void Draw(Option_t *option="")
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
virtual void SetCenter(Double_t x, Double_t y, Double_t z)
virtual char * GetObjectInfo(Int_t px, Int_t py) const
virtual void GetCenter(Double_t *center)
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)
virtual char * GetObjectInfo(Int_t px, Int_t py) const
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual void NDCtoWC(const Float_t *pn, Float_t *pw)