26 ClassImp(TEveJetConeGL);
31 TEveJetConeGL::TEveJetConeGL() :
40 Bool_t TEveJetConeGL::SetModel(TObject* obj,
const Option_t* )
42 fC = SetModelDynCast<TEveJetCone>(obj);
49 void TEveJetConeGL::SetBBox()
51 SetAxisAlignedBBox(((TEveJetCone*)fExternalObj)->AssertBBox());
57 void TEveJetConeGL::DLCacheClear()
60 TGLObject::DLCacheClear();
66 void TEveJetConeGL::CalculatePoints()
const
68 assert(fC->fNDiv > 2);
70 const Int_t NP = fC->fNDiv;
73 Float_t angle_step = TMath::TwoPi() / NP;
75 for (Int_t i = 0; i < NP; ++i, angle += angle_step)
77 fP[i] = fC->CalcBaseVec(angle);
85 void TEveJetConeGL::Draw(TGLRnrCtx& rnrCtx)
const
87 if (fP.empty()) CalculatePoints();
89 if (fC->fHighlightFrame && rnrCtx.Highlight())
91 glPushAttrib(GL_ENABLE_BIT);
92 glDisable(GL_LIGHTING);
96 TGLUtil::LineWidth(fC->fLineWidth);
97 TGLUtil::Color(fC->fLineColor);
100 const Int_t NP = fP.size();
101 glBegin(GL_LINE_LOOP);
102 for (Int_t i = 0; i < NP; ++i)
107 for (Int_t i = 0; i < 4; ++i, angle += TMath::PiOver2())
109 glVertex3fv(fC->fApex);
110 glVertex3fv(fC->CalcBaseVec(angle));
118 TGLObject::Draw(rnrCtx);
125 void TEveJetConeGL::DirectDraw(TGLRnrCtx& )
const
129 glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT | GL_LIGHTING_BIT);
131 glDisable(GL_CULL_FACE);
132 glEnable(GL_NORMALIZE);
134 glLightModeliv(GL_LIGHT_MODEL_TWO_SIDE, &lmts);
136 const Int_t NP = fC->fNDiv;
141 TEveVector curr_normal;
142 TEveVector prev_normal;
143 TMath::Cross((fP[next] - fP[prev]).Arr(), (fP[i] - fC->fApex).Arr(), prev_normal.Arr());
145 prev = i; i = next; ++next;
147 glBegin(GL_TRIANGLES);
150 TMath::Cross((fP[next] - fP[prev]).Arr(), (fP[i] - fC->fApex).Arr(), curr_normal.Arr());
152 glNormal3fv(prev_normal);
153 glVertex3fv(fP[prev]);
155 glNormal3fv(prev_normal + curr_normal);
156 glVertex3fv(fC->fApex);
158 glNormal3fv(curr_normal);
161 prev_normal = curr_normal;
165 ++next;
if (next >= NP) next = 0;
177 ClassImp(TEveJetConeProjectedGL);
182 TEveJetConeProjectedGL::TEveJetConeProjectedGL() :
183 TEveJetConeGL(), fM(0)
191 Bool_t TEveJetConeProjectedGL::SetModel(TObject* obj,
const Option_t* )
193 fM = SetModelDynCast<TEveJetConeProjected>(obj);
194 fC =
dynamic_cast<TEveJetCone*
>(fM->GetProjectable());
201 void TEveJetConeProjectedGL::SetBBox()
203 SetAxisAlignedBBox(((TEveJetConeProjected*)fExternalObj)->AssertBBox());
208 struct less_eve_vec_phi_t
210 bool operator()(
const TEveVector& a,
const TEveVector& b)
211 {
return a.Phi() < b.Phi(); }
218 void TEveJetConeProjectedGL::CalculatePoints()
const
220 static const TEveException kEH(
"TEveJetConeProjectedGL::CalculatePoints ");
224 TEveProjection *proj = fM->GetManager()->GetProjection();
226 switch (proj->GetType())
228 case TEveProjection::kPT_RPhi:
231 fP[1] = fC->CalcBaseVec(TMath::Pi() + TMath::PiOver2());
232 fP[2] = fC->CalcBaseVec(TMath::PiOver2());
234 for (Int_t i = 0; i < 3; ++i)
235 proj->ProjectVector(fP[i], fM->fDepth);
240 case TEveProjection::kPT_RhoZ:
243 fP[1] = fC->CalcBaseVec(0);
244 fP[2] = fC->CalcBaseVec(TMath::Pi());
246 Float_t tm = fP[1].Theta();
247 Float_t tM = fP[2].Theta();
249 if (tM > fC->fThetaC && tm < fC->fThetaC)
251 fP.reserve(fP.size() + 1);
252 TEveVector v(0, fC->fLimits.fY, fC->fLimits.fZ);
253 fP.push_back(fC->CalcBaseVec(v.Eta(), fC->fPhi));
256 if (tM > TMath::Pi() - fC->fThetaC && tm < TMath::Pi() - fC->fThetaC)
258 fP.reserve(fP.size() + 1);
259 TEveVector v(0, fC->fLimits.fY, -fC->fLimits.fZ);
260 fP.push_back(fC->CalcBaseVec(v.Eta(), fC->fPhi));
263 const Int_t NP = fP.size();
264 for (Int_t i = 0; i < NP; ++i)
265 proj->ProjectVector(fP[i], fM->fDepth);
267 std::sort(fP.begin() + 1, fP.end(), less_eve_vec_phi_t());
273 throw kEH +
"Unsupported projection type.";
281 void TEveJetConeProjectedGL::RenderOutline()
const
283 const Int_t NP = fP.size();
284 glBegin(GL_LINE_LOOP);
285 for (Int_t i = 0; i < NP; ++i)
287 glVertex3fv(fP[i].Arr());
295 void TEveJetConeProjectedGL::RenderPolygon()
const
297 const Int_t NP = fP.size();
299 for (Int_t i = 0; i < NP; ++i)
301 glVertex3fv(fP[i].Arr());
309 void TEveJetConeProjectedGL::Draw(TGLRnrCtx& rnrCtx)
const
311 if (fP.empty()) CalculatePoints();
313 if (rnrCtx.IsDrawPassOutlineLine())
317 else if (fM->fHighlightFrame && rnrCtx.Highlight())
321 TGLUtil::LineWidth(fM->fLineWidth);
322 TGLUtil::Color(fM->fLineColor);
328 TGLObject::Draw(rnrCtx);
335 void TEveJetConeProjectedGL::DirectDraw(TGLRnrCtx& )
const
339 fMultiColor = (fM->fDrawFrame && fM->fFillColor != fM->fLineColor);
341 glPushAttrib(GL_ENABLE_BIT);
342 glDisable(GL_LIGHTING);
346 glEnable(GL_POLYGON_OFFSET_FILL);
347 glPolygonOffset(1.0f, 1.0f);
354 glEnable(GL_LINE_SMOOTH);
356 TGLUtil::Color(fM->fLineColor);
357 TGLUtil::LineWidth(fM->fLineWidth);