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
26
27////////////////////////////////////////////////////////////////////////////////
28/// Constructor.
29
31 TGLObject(), fC(nullptr)
32{
33 // fDLCache = kFALSE; // Disable display list.
34}
35
36////////////////////////////////////////////////////////////////////////////////
37/// Set model object.
38
40{
42 return kTRUE;
43}
44
45////////////////////////////////////////////////////////////////////////////////
46/// Set bounding box.
47
52
53////////////////////////////////////////////////////////////////////////////////
54/// Clear DL cache and reset internal point array.
55
61
62////////////////////////////////////////////////////////////////////////////////
63/// Calculate points for drawing.
64
66{
67 assert(fC->fNDiv > 2);
68
69 const Int_t NP = fC->fNDiv;
70 fP.resize(NP);
71 {
72 Float_t angle_step = TMath::TwoPi() / NP;
73 Float_t angle = 0;
74 for (Int_t i = 0; i < NP; ++i, angle += angle_step)
75 {
76 fP[i] = fC->CalcBaseVec(angle);
77 }
78 }
79}
80
81////////////////////////////////////////////////////////////////////////////////
82/// Draw the cone.
83
84void TEveJetConeGL::Draw(TGLRnrCtx& rnrCtx) const
85{
86 if (fP.empty()) CalculatePoints();
87
88 if (fC->fHighlightFrame && rnrCtx.Highlight())
89 {
90 glPushAttrib(GL_ENABLE_BIT);
91 glDisable(GL_LIGHTING);
92
93 if (fC->fDrawFrame)
94 {
95 TGLUtil::LineWidth(fC->fLineWidth);
96 TGLUtil::Color(fC->fLineColor);
97 }
98
99 const Int_t NP = fP.size();
100 glBegin(GL_LINE_LOOP);
101 for (Int_t i = 0; i < NP; ++i)
102 glVertex3fv(fP[i]);
103 glEnd();
104 glBegin(GL_LINES);
105 Double_t angle = 0;
106 for (Int_t i = 0; i < 4; ++i, angle += TMath::PiOver2())
107 {
108 glVertex3fv(fC->fApex);
109 glVertex3fv(fC->CalcBaseVec(angle));
110 }
111 glEnd();
112
113 glPopAttrib();
114 }
115 else
116 {
117 TGLObject::Draw(rnrCtx);
118 }
119}
120
121////////////////////////////////////////////////////////////////////////////////
122/// Render with OpenGL.
123
125{
126 // printf("TEveJetConeGL::DirectDraw LOD %d\n", rnrCtx.CombiLOD());
127
128 glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT | GL_LIGHTING_BIT);
129
130 glDisable(GL_CULL_FACE);
131 glEnable(GL_NORMALIZE);
132 Int_t lmts = 1;
133 glLightModeliv(GL_LIGHT_MODEL_TWO_SIDE, &lmts);
134
135 const Int_t NP = fC->fNDiv;
136 Int_t prev = NP - 1;
137 Int_t i = 0;
138 Int_t next = 1;
139
140 TEveVector curr_normal;
141 TEveVector prev_normal;
142 TMath::Cross((fP[next] - fP[prev]).Arr(), (fP[i] - fC->fApex).Arr(), prev_normal.Arr());
143
144 prev = i; i = next; ++next;
145
146 glBegin(GL_TRIANGLES);
147 do
148 {
149 TMath::Cross((fP[next] - fP[prev]).Arr(), (fP[i] - fC->fApex).Arr(), curr_normal.Arr());
150
151 glNormal3fv(prev_normal);
152 glVertex3fv(fP[prev]);
153
154 glNormal3fv(prev_normal + curr_normal);
155 glVertex3fv(fC->fApex);
156
157 glNormal3fv(curr_normal);
158 glVertex3fv(fP[i]);
159
160 prev_normal = curr_normal;
161
162 prev = i;
163 i = next;
164 ++next; if (next >= NP) next = 0;
165 } while (prev != 0);
166 glEnd();
167
168 glPopAttrib();
169}
170
171/** \class TEveJetConeProjectedGL
172\ingroup TEve
173OpenGL renderer class for TEveJetConeProjected.
174*/
175
176
177////////////////////////////////////////////////////////////////////////////////
178/// Constructor.
179
181 TEveJetConeGL(), fM(nullptr)
182{
183 // fDLCache = kFALSE; // Disable display list.
184}
185
186////////////////////////////////////////////////////////////////////////////////
187/// Set model object.
188
190{
192 fC = dynamic_cast<TEveJetCone*>(fM->GetProjectable());
193 return fC != nullptr;
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Set bounding box.
198
203
204namespace
205{
206 struct less_eve_vec_phi_t
207 {
208 bool operator()(const TEveVector& a, const TEveVector& b)
209 { return a.Phi() < b.Phi(); }
210 };
211}
212
213////////////////////////////////////////////////////////////////////////////////
214/// Calculate points for drawing.
215
217{
218 static const TEveException kEH("TEveJetConeProjectedGL::CalculatePoints ");
219
220 fP.resize(3);
221
222 TEveProjection *proj = fM->GetManager()->GetProjection();
223
224 switch (proj->GetType())
225 {
227 {
228 fP[0] = fC->fApex;
229 fP[1] = fC->CalcBaseVec(TMath::Pi() + TMath::PiOver2());
230 fP[2] = fC->CalcBaseVec(TMath::PiOver2());
231
232 for (Int_t i = 0; i < 3; ++i)
233 proj->ProjectVector(fP[i], fM->fDepth);
234
235 break;
236 }
237
239 {
240 fP[0] = fC->fApex;
241 fP[1] = fC->CalcBaseVec(0);
242 fP[2] = fC->CalcBaseVec(TMath::Pi());
243
244 Float_t tm = fP[1].Theta();
245 Float_t tM = fP[2].Theta();
246
247 if (tM > fC->fThetaC && tm < fC->fThetaC)
248 {
249 fP.reserve(fP.size() + 1);
250 TEveVector v(0, fC->fLimits.fY, fC->fLimits.fZ);
251 fP.push_back(fC->CalcBaseVec(v.Eta(), fC->fPhi));
252 }
253
254 if (tM > TMath::Pi() - fC->fThetaC && tm < TMath::Pi() - fC->fThetaC)
255 {
256 fP.reserve(fP.size() + 1);
257 TEveVector v(0, fC->fLimits.fY, -fC->fLimits.fZ);
258 fP.push_back(fC->CalcBaseVec(v.Eta(), fC->fPhi));
259 }
260
261 const Int_t NP = fP.size();
262 for (Int_t i = 0; i < NP; ++i)
263 proj->ProjectVector(fP[i], fM->fDepth);
264
265 std::sort(fP.begin() + 1, fP.end(), less_eve_vec_phi_t());
266
267 break;
268 }
269
270 default:
271 throw kEH + "Unsupported projection type.";
272 }
273
274}
275
276////////////////////////////////////////////////////////////////////////////////
277/// Draw jet outline.
278
280{
281 const Int_t NP = fP.size();
282 glBegin(GL_LINE_LOOP);
283 for (Int_t i = 0; i < NP; ++i)
284 {
285 glVertex3fv(fP[i].Arr());
286 }
287 glEnd();
288}
289
290////////////////////////////////////////////////////////////////////////////////
291/// Draw jet surface.
292
294{
295 const Int_t NP = fP.size();
296 glBegin(GL_POLYGON);
297 for (Int_t i = 0; i < NP; ++i)
298 {
299 glVertex3fv(fP[i].Arr());
300 }
301 glEnd();
302}
303
304////////////////////////////////////////////////////////////////////////////////
305/// Draw the cone.
306
308{
309 if (fP.empty()) CalculatePoints();
310
311 if (rnrCtx.IsDrawPassOutlineLine())
312 {
314 }
315 else if (fM->fHighlightFrame && rnrCtx.Highlight())
316 {
317 if (fM->fDrawFrame)
318 {
319 TGLUtil::LineWidth(fM->fLineWidth);
320 TGLUtil::Color(fM->fLineColor);
321 }
323 }
324 else
325 {
326 TGLObject::Draw(rnrCtx);
327 }
328}
329
330////////////////////////////////////////////////////////////////////////////////
331/// Render with OpenGL.
332
334{
335 // printf("TEveJetConeProjectedGL::DirectDraw LOD %d\n", rnrCtx.CombiLOD());
336
337 fMultiColor = (fM->fDrawFrame && fM->fFillColor != fM->fLineColor);
338
339 glPushAttrib(GL_ENABLE_BIT);
340 glDisable(GL_LIGHTING);
341
342 if (fM->fDrawFrame)
343 {
344 glEnable(GL_POLYGON_OFFSET_FILL);
345 glPolygonOffset(1.0f, 1.0f);
346 }
347
349
350 if (fM->fDrawFrame)
351 {
352 glEnable(GL_LINE_SMOOTH);
353
354 TGLUtil::Color(fM->fLineColor);
355 TGLUtil::LineWidth(fM->fLineWidth);
357 }
358
359 glPopAttrib();
360}
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
TEveVectorT< Float_t > TEveVector
Definition TEveVector.h:123
TRObject operator()(const T1 &t1) const
Exception class thrown by TEve classes and macros.
Definition TEveUtil.h:102
void SetBBox() override
Set bounding box.
virtual void CalculatePoints() const
Calculate points for drawing.
std::vector< TEveVector > fP
void DLCacheClear() override
Clear DL cache and reset internal point array.
TEveJetConeGL()
Constructor.
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Render with OpenGL.
TEveJetCone * fC
void Draw(TGLRnrCtx &rnrCtx) const override
Draw the cone.
TEveJetConeGL(const TEveJetConeGL &)=delete
Bool_t SetModel(TObject *obj, const Option_t *opt=nullptr) override
Set model object.
void RenderOutline() const
Draw jet outline.
void RenderPolygon() const
Draw jet surface.
TEveJetConeProjected * fM
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Render with OpenGL.
void Draw(TGLRnrCtx &rnrCtx) const override
Draw the cone.
void SetBBox() override
Set bounding box.
Bool_t SetModel(TObject *obj, const Option_t *opt=nullptr) override
Set model object.
void CalculatePoints() const override
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
Base-class for non-linear projections.
void ProjectVector(TEveVector &v, Float_t d)
Project TEveVector.
EPType_e GetType() const
const TT * Arr() const
Definition TEveVector.h:58
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw the GL drawable, using draw flags.
TObject * fExternalObj
! Also plays the role of ID.
virtual void DLCacheClear()
Clear all entries for all LODs for this drawable from the display list cache but keeping the reserved...
Bool_t fMultiColor
Definition TGLObject.h:28
TT * SetModelDynCast(TObject *obj)
Definition TGLObject.h:37
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:85
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:1688
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
Definition TGLUtil.cxx:1934
Mother of all ROOT objects.
Definition TObject.h:42
constexpr Double_t PiOver2()
Definition TMath.h:54
constexpr Double_t Pi()
Definition TMath.h:40
T * Cross(const T v1[3], const T v2[3], T out[3])
Calculates the Cross Product of two vectors: out = [v1 x v2].
Definition TMath.h:1284
constexpr Double_t TwoPi()
Definition TMath.h:47