Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEveJetConeGL.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Author: Matevz Tadel, Jochen Thaeder 2009
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TEveJetConeGL.h"
13#include "TEveJetCone.h"
15
16#include "TMath.h"
17
18#include "TGLRnrCtx.h"
19#include "TGLIncludes.h"
20
21/** \class TEveJetConeGL
22\ingroup TEve
23OpenGL renderer class for TEveJetCone.
24*/
25
27
28////////////////////////////////////////////////////////////////////////////////
29/// Constructor.
30
32 TGLObject(), fC(0)
33{
34 // fDLCache = kFALSE; // Disable display list.
35}
36
37////////////////////////////////////////////////////////////////////////////////
38/// Set model object.
39
41{
42 fC = SetModelDynCast<TEveJetCone>(obj);
43 return kTRUE;
44}
45
46////////////////////////////////////////////////////////////////////////////////
47/// Set bounding box.
48
50{
52}
53
54////////////////////////////////////////////////////////////////////////////////
55/// Clear DL cache and reset internal point array.
56
58{
59 fP.clear();
61}
62
63////////////////////////////////////////////////////////////////////////////////
64/// Calculate points for drawing.
65
67{
68 assert(fC->fNDiv > 2);
69
70 const Int_t NP = fC->fNDiv;
71 fP.resize(NP);
72 {
73 Float_t angle_step = TMath::TwoPi() / NP;
74 Float_t angle = 0;
75 for (Int_t i = 0; i < NP; ++i, angle += angle_step)
76 {
77 fP[i] = fC->CalcBaseVec(angle);
78 }
79 }
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Draw the cone.
84
85void TEveJetConeGL::Draw(TGLRnrCtx& rnrCtx) const
86{
87 if (fP.empty()) CalculatePoints();
88
89 if (fC->fHighlightFrame && rnrCtx.Highlight())
90 {
91 glPushAttrib(GL_ENABLE_BIT);
92 glDisable(GL_LIGHTING);
93
94 if (fC->fDrawFrame)
95 {
98 }
99
100 const Int_t NP = fP.size();
101 glBegin(GL_LINE_LOOP);
102 for (Int_t i = 0; i < NP; ++i)
103 glVertex3fv(fP[i]);
104 glEnd();
105 glBegin(GL_LINES);
106 Double_t angle = 0;
107 for (Int_t i = 0; i < 4; ++i, angle += TMath::PiOver2())
108 {
109 glVertex3fv(fC->fApex);
110 glVertex3fv(fC->CalcBaseVec(angle));
111 }
112 glEnd();
113
114 glPopAttrib();
115 }
116 else
117 {
118 TGLObject::Draw(rnrCtx);
119 }
120}
121
122////////////////////////////////////////////////////////////////////////////////
123/// Render with OpenGL.
124
126{
127 // printf("TEveJetConeGL::DirectDraw LOD %d\n", rnrCtx.CombiLOD());
128
129 glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT | GL_LIGHTING_BIT);
130
131 glDisable(GL_CULL_FACE);
132 glEnable(GL_NORMALIZE);
133 Int_t lmts = 1;
134 glLightModeliv(GL_LIGHT_MODEL_TWO_SIDE, &lmts);
135
136 const Int_t NP = fC->fNDiv;
137 Int_t prev = NP - 1;
138 Int_t i = 0;
139 Int_t next = 1;
140
141 TEveVector curr_normal;
142 TEveVector prev_normal;
143 TMath::Cross((fP[next] - fP[prev]).Arr(), (fP[i] - fC->fApex).Arr(), prev_normal.Arr());
144
145 prev = i; i = next; ++next;
146
147 glBegin(GL_TRIANGLES);
148 do
149 {
150 TMath::Cross((fP[next] - fP[prev]).Arr(), (fP[i] - fC->fApex).Arr(), curr_normal.Arr());
151
152 glNormal3fv(prev_normal);
153 glVertex3fv(fP[prev]);
154
155 glNormal3fv(prev_normal + curr_normal);
156 glVertex3fv(fC->fApex);
157
158 glNormal3fv(curr_normal);
159 glVertex3fv(fP[i]);
160
161 prev_normal = curr_normal;
162
163 prev = i;
164 i = next;
165 ++next; if (next >= NP) next = 0;
166 } while (prev != 0);
167 glEnd();
168
169 glPopAttrib();
170}
171
172/** \class TEveJetConeProjectedGL
173\ingroup TEve
174OpenGL renderer class for TEveJetConeProjected.
175*/
176
178
179////////////////////////////////////////////////////////////////////////////////
180/// Constructor.
181
183 TEveJetConeGL(), fM(0)
184{
185 // fDLCache = kFALSE; // Disable display list.
186}
187
188////////////////////////////////////////////////////////////////////////////////
189/// Set model object.
190
192{
193 fM = SetModelDynCast<TEveJetConeProjected>(obj);
194 fC = dynamic_cast<TEveJetCone*>(fM->GetProjectable());
195 return fC != 0;
196}
197
198////////////////////////////////////////////////////////////////////////////////
199/// Set bounding box.
200
202{
204}
205
206namespace
207{
208 struct less_eve_vec_phi_t
209 {
210 bool operator()(const TEveVector& a, const TEveVector& b)
211 { return a.Phi() < b.Phi(); }
212 };
213}
214
215////////////////////////////////////////////////////////////////////////////////
216/// Calculate points for drawing.
217
219{
220 static const TEveException kEH("TEveJetConeProjectedGL::CalculatePoints ");
221
222 fP.resize(3);
223
225
226 switch (proj->GetType())
227 {
229 {
230 fP[0] = fC->fApex;
233
234 for (Int_t i = 0; i < 3; ++i)
235 proj->ProjectVector(fP[i], fM->fDepth);
236
237 break;
238 }
239
241 {
242 fP[0] = fC->fApex;
243 fP[1] = fC->CalcBaseVec(0);
244 fP[2] = fC->CalcBaseVec(TMath::Pi());
245
246 Float_t tm = fP[1].Theta();
247 Float_t tM = fP[2].Theta();
248
249 if (tM > fC->fThetaC && tm < fC->fThetaC)
250 {
251 fP.reserve(fP.size() + 1);
253 fP.push_back(fC->CalcBaseVec(v.Eta(), fC->fPhi));
254 }
255
256 if (tM > TMath::Pi() - fC->fThetaC && tm < TMath::Pi() - fC->fThetaC)
257 {
258 fP.reserve(fP.size() + 1);
260 fP.push_back(fC->CalcBaseVec(v.Eta(), fC->fPhi));
261 }
262
263 const Int_t NP = fP.size();
264 for (Int_t i = 0; i < NP; ++i)
265 proj->ProjectVector(fP[i], fM->fDepth);
266
267 std::sort(fP.begin() + 1, fP.end(), less_eve_vec_phi_t());
268
269 break;
270 }
271
272 default:
273 throw kEH + "Unsupported projection type.";
274 }
275
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Draw jet outline.
280
282{
283 const Int_t NP = fP.size();
284 glBegin(GL_LINE_LOOP);
285 for (Int_t i = 0; i < NP; ++i)
286 {
287 glVertex3fv(fP[i].Arr());
288 }
289 glEnd();
290}
291
292////////////////////////////////////////////////////////////////////////////////
293/// Draw jet surface.
294
296{
297 const Int_t NP = fP.size();
298 glBegin(GL_POLYGON);
299 for (Int_t i = 0; i < NP; ++i)
300 {
301 glVertex3fv(fP[i].Arr());
302 }
303 glEnd();
304}
305
306////////////////////////////////////////////////////////////////////////////////
307/// Draw the cone.
308
310{
311 if (fP.empty()) CalculatePoints();
312
313 if (rnrCtx.IsDrawPassOutlineLine())
314 {
316 }
317 else if (fM->fHighlightFrame && rnrCtx.Highlight())
318 {
319 if (fM->fDrawFrame)
320 {
323 }
325 }
326 else
327 {
328 TGLObject::Draw(rnrCtx);
329 }
330}
331
332////////////////////////////////////////////////////////////////////////////////
333/// Render with OpenGL.
334
336{
337 // printf("TEveJetConeProjectedGL::DirectDraw LOD %d\n", rnrCtx.CombiLOD());
338
340
341 glPushAttrib(GL_ENABLE_BIT);
342 glDisable(GL_LIGHTING);
343
344 if (fM->fDrawFrame)
345 {
346 glEnable(GL_POLYGON_OFFSET_FILL);
347 glPolygonOffset(1.0f, 1.0f);
348 }
349
351
352 if (fM->fDrawFrame)
353 {
354 glEnable(GL_LINE_SMOOTH);
355
359 }
360
361 glPopAttrib();
362}
#define GL_LINES
Definition GL_glu.h:284
#define GL_TRIANGLES
Definition GL_glu.h:287
#define GL_POLYGON
Definition GL_glu.h:292
#define GL_LINE_LOOP
Definition GL_glu.h:285
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
double Double_t
Definition RtypesCore.h:59
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:91
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:364
TRObject operator()(const T1 &t1) const
Exception class thrown by TEve classes and macros.
Definition TEveUtil.h:102
OpenGL renderer class for TEveJetCone.
virtual void DLCacheClear()
Clear DL cache and reset internal point array.
virtual void CalculatePoints() const
Calculate points for drawing.
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Render with OpenGL.
std::vector< TEveVector > fP
TEveJetConeGL()
Constructor.
TEveJetCone * fC
virtual void SetBBox()
Set bounding box.
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)
Set model object.
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw the cone.
OpenGL renderer class for TEveJetConeProjected.
void RenderOutline() const
Draw jet outline.
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Render with OpenGL.
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw the cone.
void RenderPolygon() const
Draw jet surface.
TEveJetConeProjected * fM
virtual void SetBBox()
Set bounding box.
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)
Set model object.
virtual void CalculatePoints() const
Calculate points for drawing.
TEveJetConeProjectedGL()
Constructor.
Projection of TEveJetCone.
Definition TEveJetCone.h:74
Draws a jet cone with leading particle is specified in (eta,phi) and cone radius is given.
Definition TEveJetCone.h:24
TEveVector fApex
Definition TEveJetCone.h:34
TEveVector CalcBaseVec(Float_t eta, Float_t phi) const
Returns point on the base of the cone with given eta and phi.
TEveVector fLimits
Definition TEveJetCone.h:36
Float_t fThetaC
Definition TEveJetCone.h:37
Float_t fPhi
Definition TEveJetCone.h:38
TEveProjectionManager * GetManager() const
TEveProjectable * GetProjectable() const
TEveProjection * GetProjection()
Base-class for non-linear projections.
void ProjectVector(TEveVector &v, Float_t d)
Project TEveVector.
EPType_e GetType() const
Color_t fFillColor
Definition TEveShape.h:38
Bool_t fDrawFrame
Definition TEveShape.h:42
Bool_t fHighlightFrame
Definition TEveShape.h:43
Float_t fLineWidth
Definition TEveShape.h:40
Color_t fLineColor
Definition TEveShape.h:39
const TT * Arr() const
Definition TEveVector.h:58
TT Theta() const
Definition TEveVector.h:136
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw the GL drawable, using draw flags.
TObject * fExternalObj
first replica
virtual void DLCacheClear()
Clear all entries for all LODs for this drawable from the display list cache but keeping the reserved...
Base-class for direct OpenGL renderers.
Definition TGLObject.h:22
Bool_t fMultiColor
Definition TGLObject.h:28
void SetAxisAlignedBBox(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax, Float_t zmin, Float_t zmax)
Set axis-aligned bounding-box.
Definition TGLObject.cxx:86
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
Bool_t IsDrawPassOutlineLine() const
Definition TGLRnrCtx.h:207
Bool_t Highlight() const
Definition TGLRnrCtx.h:218
static void Color(const TGLColor &color)
Set color from TGLColor.
Definition TGLUtil.cxx:1691
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
Definition TGLUtil.cxx:1937
Mother of all ROOT objects.
Definition TObject.h:37
constexpr Double_t PiOver2()
Definition TMath.h:51
constexpr Double_t Pi()
Definition TMath.h:37
T * Cross(const T v1[3], const T v2[3], T out[3])
Calculate the Cross Product of two vectors: out = [v1 x v2].
Definition TMath.h:1175
constexpr Double_t TwoPi()
Definition TMath.h:44