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];
54 fInnerRadius =
new Double_t[3];
55 fOuterRadius =
new Double_t[3];
56 fInnerRadius[0]=innerRadius;
57 fOuterRadius[0]=outerRadius;
59 f_innerCircleX = NULL;
60 f_innerCircleY = NULL;
61 f_outerCircleX = NULL;
62 f_outerCircleY = NULL;
72 if ( gDebug ) cout <<
"BesCircle2D default dtor called" << endl;
83 const Int_t inaxis = 7;
86 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
87 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
88 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
89 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
92 if (px < puxmin - inaxis)
return dist;
93 if (py > puymin + inaxis)
return dist;
94 if (px > puxmax + inaxis)
return dist;
95 if (py < puymax - inaxis)
return dist;
98 if (!view)
return dist;
100 Double_t
x = gPad->PadtoX(gPad->AbsPixeltoX(px));
101 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
114 Double_t distw = 0.0;
115 for (Int_t i = 0; i < 2; i++) {
116 distw += (xwc[i]-fCenter[i]) * (xwc[i]-fCenter[i]);
119 if (distw >= fInnerRadius[0]*fInnerRadius[0] &&
120 distw <= fOuterRadius[0]*fOuterRadius[0])
140 TString opt = option;
150 TString opt = option;
155 if (view == 0) cout <<
"no view found" << endl;
158 Int_t np = fNSegment;
161 delete [] f_innerCircleX;
162 f_innerCircleX = NULL;
165 delete [] f_innerCircleY;
166 f_innerCircleY = NULL;
169 delete [] f_outerCircleX;
170 f_outerCircleX = NULL;
173 delete [] f_outerCircleY;
174 f_outerCircleY = NULL;
185 f_innerCircleX =
new Double_t[np+1];
186 f_innerCircleY =
new Double_t[np+1];
187 f_outerCircleX =
new Double_t[np+1];
188 f_outerCircleY =
new Double_t[np+1];
189 f_areaX =
new Double_t[4*np];
190 f_areaY =
new Double_t[4*np];
196 Double_t dphi = 2*TMath::Pi()/(np);
197 Double_t pointWC[3],pointNDC[3];
199 for (Int_t i=0; i< np ; i++) {
200 angle = Double_t(i)*dphi;
203 pointWC[0] = fCenter[0] + fInnerRadius[0]*TMath::Cos(angle);
204 pointWC[1] = fCenter[1] + fInnerRadius[0]*TMath::Sin(angle);
205 pointWC[2] = fCenter[2];
206 view->
WCtoNDC(pointWC,pointNDC);
207 f_innerCircleX[i] = pointNDC[0];
208 f_innerCircleY[i] = pointNDC[1];
209 f_areaX[4*i] = pointNDC[0];
210 f_areaY[4*i] = pointNDC[1];
212 f_areaX[4*np - 3] = pointNDC[0];
213 f_areaY[4*np - 3] = pointNDC[1];
215 f_areaX[4*i - 3] = pointNDC[0];
216 f_areaY[4*i - 3] = pointNDC[1];
220 pointWC[0] = fCenter[0] + fOuterRadius[0]*TMath::Cos(angle);
221 pointWC[1] = fCenter[1] + fOuterRadius[0]*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)