#include <BesCircle2D.h>
Public Member Functions | |
BesCircle2D (const char *name, const char *title, Double_t innerRadius, Double_t outerRadius, Double_t *center) | |
BesCircle2D () | |
BesCircle2D (const char *name, const char *title, Double_t innerRadius, Double_t outerRadius, Double_t *center) | |
BesCircle2D () | |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
virtual void | Draw (Option_t *option="") |
virtual void | Draw (Option_t *option="") |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
virtual void | GetCenter (Double_t *center) |
virtual void | GetCenter (Double_t *center) |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
virtual void | Paint (Option_t *option="") |
virtual void | Paint (Option_t *option="") |
virtual void | SetCenter (Double_t x, Double_t y, Double_t z) |
virtual void | SetCenter (Double_t x, Double_t y, Double_t z) |
virtual void | SetNSegment (Int_t np) |
virtual void | SetNSegment (Int_t np) |
virtual | ~BesCircle2D () |
virtual | ~BesCircle2D () |
Private Attributes | |
Double_t * | f_areaX |
Double_t * | f_areaX |
Double_t * | f_areaY |
Double_t * | f_areaY |
Double_t * | f_innerCircleX |
Double_t * | f_innerCircleX |
Double_t * | f_innerCircleY |
Double_t * | f_innerCircleY |
Double_t * | f_outerCircleX |
Double_t * | f_outerCircleX |
Double_t * | f_outerCircleY |
Double_t * | f_outerCircleY |
Double_t * | fCenter |
Double_t * | fCenter |
Double_t * | fInnerRadius |
Double_t * | fInnerRadius |
Int_t | fNSegment |
Double_t * | fOuterRadius |
Double_t * | fOuterRadius |
|
|
|
00046 : 00047 TNamed(name, title), TAttLine(), TAttFill() { 00048 // 00049 // BesCircle2D normal constructor 00050 if ( gDebug ) cout << "BesCircle2D normal ctor called" << endl; 00051 00052 fCenter = new Double_t[3]; 00053 for ( Int_t i = 0; i < 3; i++ ) fCenter[i] = center[i]; 00054 fInnerRadius = new Double_t[3]; 00055 fOuterRadius = new Double_t[3]; 00056 fInnerRadius[0]=innerRadius; 00057 fOuterRadius[0]=outerRadius; 00058 fNSegment = 40; 00059 f_innerCircleX = NULL; 00060 f_innerCircleY = NULL; 00061 f_outerCircleX = NULL; 00062 f_outerCircleY = NULL; 00063 f_areaX = NULL; 00064 f_areaY = NULL; 00065 }
|
|
00069 { 00070 // 00071 // BesCircle2D default destructor 00072 if ( gDebug ) cout << "BesCircle2D default dtor called" << endl; 00073 00074 delete fCenter; 00075 delete fInnerRadius; 00076 delete fOuterRadius; 00077 }
|
|
|
|
|
|
|
|
|
|
00081 { 00082 00083 const Int_t inaxis = 7; 00084 Int_t dist = 9999; 00085 00086 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin()); 00087 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin()); 00088 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax()); 00089 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax()); 00090 00091 // return if point is not in the user area 00092 if (px < puxmin - inaxis) return dist; 00093 if (py > puymin + inaxis) return dist; 00094 if (px > puxmax + inaxis) return dist; 00095 if (py < puymax - inaxis) return dist; 00096 00097 BesView *view = (BesView*)gPad->GetView(); 00098 if (!view) return dist; 00099 00100 Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px)); 00101 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py)); 00102 Double_t xndc[3]; 00103 //if (view->GetViewType() & kXYView) 00104 xndc[0] = x; 00105 xndc[1] = y; 00106 xndc[2] = 0; 00107 //cout << "NDC X:" << xndc[0] << " Y:" << xndc[1] << endl; 00108 00109 Double_t xwc[3]; 00110 view->NDCtoWC(xndc, xwc); 00111 //cout << "WC X:" << xwc[0] << " Y:" << xwc[1] << endl; 00112 //cout << "Center X:" << fCenter[0] << " Y:" << fCenter[1] << endl; 00113 00114 Double_t distw = 0.0; 00115 for (Int_t i = 0; i < 2; i++) { 00116 distw += (xwc[i]-fCenter[i]) * (xwc[i]-fCenter[i]); 00117 } 00118 00119 if (distw >= fInnerRadius[0]*fInnerRadius[0] && 00120 distw <= fOuterRadius[0]*fOuterRadius[0]) 00121 return 0; 00122 else 00123 return dist; 00124 }
|
|
|
|
00137 { 00138 // 00139 // BesCircle2D draw function 00140 TString opt = option; 00141 opt.ToUpper(); 00142 00143 AppendPad(option); 00144 }
|
|
|
|
00128 { 00129 //cout << "I am in " << GetName() << endl; 00130 00131 BesView *view = (BesView*)gPad->GetView(); 00132 if (view) view->ExecuteEvent(event, px, py); 00133 }
|
|
|
|
00275 { 00276 for (Int_t i = 0; i < 3; i++) center[i] = fCenter[i]; 00277 }
|
|
|
|
00256 { 00257 00258 BesView *view = (BesView*)gPad->GetView(); 00259 if (view) return view->GetObjectInfo(px, py); 00260 else return TObject::GetObjectInfo(px, py); 00261 }
|
|
|
|
00148 { 00149 // BesCircle2D paint function 00150 TString opt = option; 00151 opt.ToUpper(); 00152 00153 // Transform to normalised desktop coordinates 00154 BesView *view = (BesView*)gPad->GetView(); 00155 if (view == 0) cout << "no view found" << endl; 00156 00157 // Draw Painted area between circles as PaintFilledArea 00158 Int_t np = fNSegment; //40; 00159 00160 if (f_innerCircleX){ 00161 delete [] f_innerCircleX; 00162 f_innerCircleX = NULL; 00163 } 00164 if (f_innerCircleY){ 00165 delete [] f_innerCircleY; 00166 f_innerCircleY = NULL; 00167 } 00168 if (f_outerCircleX){ 00169 delete [] f_outerCircleX; 00170 f_outerCircleX = NULL; 00171 } 00172 if (f_outerCircleY){ 00173 delete [] f_outerCircleY; 00174 f_outerCircleY = NULL; 00175 } 00176 if (f_areaX) { 00177 delete [] f_areaX; 00178 f_areaX = NULL; 00179 } 00180 if (f_areaY) { 00181 delete [] f_areaY; 00182 f_areaY = NULL; 00183 } 00184 00185 f_innerCircleX = new Double_t[np+1]; 00186 f_innerCircleY = new Double_t[np+1]; 00187 f_outerCircleX = new Double_t[np+1]; 00188 f_outerCircleY = new Double_t[np+1]; 00189 f_areaX = new Double_t[4*np]; 00190 f_areaY = new Double_t[4*np]; 00191 00192 TAttLine::Modify(); //Change line attributes only if necessary 00193 TAttFill::Modify(); //Change fill attributes only if necessary 00194 00195 Double_t angle; 00196 Double_t dphi = 2*TMath::Pi()/(np); 00197 Double_t pointWC[3],pointNDC[3]; 00198 00199 for (Int_t i=0; i< np ; i++) { 00200 angle = Double_t(i)*dphi; 00201 00202 // inner circle 00203 pointWC[0] = fCenter[0] + fInnerRadius[0]*TMath::Cos(angle); 00204 pointWC[1] = fCenter[1] + fInnerRadius[0]*TMath::Sin(angle); 00205 pointWC[2] = fCenter[2]; 00206 view->WCtoNDC(pointWC,pointNDC); 00207 f_innerCircleX[i] = pointNDC[0]; 00208 f_innerCircleY[i] = pointNDC[1]; 00209 f_areaX[4*i] = pointNDC[0]; 00210 f_areaY[4*i] = pointNDC[1]; 00211 if ( i == 0 ) { 00212 f_areaX[4*np - 3] = pointNDC[0]; 00213 f_areaY[4*np - 3] = pointNDC[1]; 00214 } else { 00215 f_areaX[4*i - 3] = pointNDC[0]; 00216 f_areaY[4*i - 3] = pointNDC[1]; 00217 } 00218 00219 // outer circle 00220 pointWC[0] = fCenter[0] + fOuterRadius[0]*TMath::Cos(angle); 00221 pointWC[1] = fCenter[1] + fOuterRadius[0]*TMath::Sin(angle); 00222 pointWC[2] = fCenter[2]; 00223 view->WCtoNDC(pointWC,pointNDC); 00224 f_outerCircleX[i] = pointNDC[0]; 00225 f_outerCircleY[i] = pointNDC[1]; 00226 f_areaX[4*i + 3] = pointNDC[0]; 00227 f_areaY[4*i + 3] = pointNDC[1]; 00228 if ( i == 0 ) { 00229 f_areaX[4*np - 2] = pointNDC[0]; 00230 f_areaY[4*np - 2] = pointNDC[1]; 00231 } else { 00232 f_areaX[4*i - 2] = pointNDC[0]; 00233 f_areaY[4*i - 2] = pointNDC[1]; 00234 } 00235 00236 } 00237 00238 // last point for circles 00239 f_innerCircleX[np] = f_innerCircleX[0]; 00240 f_innerCircleY[np] = f_innerCircleY[0]; 00241 f_outerCircleX[np] = f_outerCircleX[0]; 00242 f_outerCircleY[np] = f_outerCircleY[0]; 00243 00244 // paint filled areas 00245 for (Int_t i = 0; i < np; i++ ) { 00246 gPad->PaintFillArea(4,&f_areaX[4*i],&f_areaY[4*i]); 00247 } 00248 00249 // paint circles 00250 gPad->PaintPolyLine(np+1,f_innerCircleX,f_innerCircleY); 00251 gPad->PaintPolyLine(np+1,f_outerCircleX,f_outerCircleY); 00252 00253 }
|
|
|
|
|
|
00052 { 00053 fNSegment = np; 00054 }
|
|
00052 { 00053 fNSegment = np; 00054 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|