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 {
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
85{
86 if (fP.empty()) CalculatePoints();
87
88 if (fC->fHighlightFrame && rnrCtx.Highlight())
89 {
92
93 if (fC->fDrawFrame)
94 {
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 {
110 }
111 glEnd();
112
113 glPopAttrib();
114 }
115 else
116 {
118 }
119}
120
121////////////////////////////////////////////////////////////////////////////////
122/// Render with OpenGL.
123
125{
126 // printf("TEveJetConeGL::DirectDraw LOD %d\n", rnrCtx.CombiLOD());
127
129
132 Int_t lmts = 1;
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
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
152 glVertex3fv(fP[prev]);
153
156
158 glVertex3fv(fP[i]);
159
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
223
224 switch (proj->GetType())
225 {
227 {
228 fP[0] = fC->fApex;
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);
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);
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();
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 {
321 }
323 }
324 else
325 {
327 }
328}
329
330////////////////////////////////////////////////////////////////////////////////
331/// Render with OpenGL.
332
334{
335 // printf("TEveJetConeProjectedGL::DirectDraw LOD %d\n", rnrCtx.CombiLOD());
336
338
341
342 if (fM->fDrawFrame)
343 {
345 glPolygonOffset(1.0f, 1.0f);
346 }
347
349
350 if (fM->fDrawFrame)
351 {
353
357 }
358
359 glPopAttrib();
360}
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
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
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint angle
TRObject operator()(const T1 &t1) const
Exception class thrown by TEve classes and macros.
Definition TEveUtil.h:102
OpenGL renderer class for TEveJetCone.
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.
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
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.
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
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:85
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
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:41
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