Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveTrackProjectedGL.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
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 "TEveTrackProjectedGL.h"
13 #include "TEveTrackProjected.h"
14 #include "TEveTrackPropagator.h"
15 #include "TEveProjectionManager.h"
16 
17 #include "TGLIncludes.h"
18 #include "TGLRnrCtx.h"
19 
20 /** \class TEveTrackProjectedGL
21 \ingroup TEve
22 GL-renderer for TEveTrackProjected class.
23 */
24 
25 ClassImp(TEveTrackProjectedGL);
26 
27 ////////////////////////////////////////////////////////////////////////////////
28 /// Constructor.
29 
30 TEveTrackProjectedGL::TEveTrackProjectedGL() : TEveTrackGL(), fM(0)
31 {
32  // fDLCache = kFALSE; // Disable display list.
33 }
34 
35 ////////////////////////////////////////////////////////////////////////////////
36 /// Set model object.
37 
38 Bool_t TEveTrackProjectedGL::SetModel(TObject* obj, const Option_t* /*opt*/)
39 {
40  TEveTrackGL::SetModel(obj);
41  fM = DynCast<TEveTrackProjected>(obj);
42  return kTRUE;
43 }
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// Draw track with GL.
47 
48 void TEveTrackProjectedGL::DirectDraw(TGLRnrCtx& rnrCtx) const
49 {
50  // printf("TEveTrackProjectedGL::DirectDraw Style %d, LOD %d\n", flags.Style(), flags.LOD());
51  if (fM->Size() == 0)
52  return;
53 
54  // lines
55  if (fM->fRnrLine)
56  {
57  TGLCapabilityEnabler sw_smooth(GL_LINE_SMOOTH, fM->fSmooth);
58  TGLCapabilityEnabler sw_blend(GL_BLEND, fM->fSmooth);
59  Int_t start = 0;
60  Float_t* p = fM->GetP();
61  TGLUtil::LockColor(); // Keep color from TGLPhysicalShape.
62  for (std::vector<Int_t>::iterator bpi = fM->fBreakPoints.begin();
63  bpi != fM->fBreakPoints.end(); ++bpi)
64  {
65  Int_t size = *bpi - start;
66  TGLUtil::RenderPolyLine(*fM, fM->GetMainTransparency(), p, size);
67  p += 3*size;
68  start += size;
69  }
70  TGLUtil::UnlockColor();
71  }
72 
73  // markers on lines
74  if (fM->fRnrPoints)
75  {
76  TGLUtil::RenderPolyMarkers(*fM, 0,
77  fM->GetP(), fM->Size(),
78  rnrCtx.GetPickRadius(),
79  rnrCtx.Selection());
80  }
81 
82  // break-points
83  if (fM->fBreakPoints.size() > 1 && fM->fPropagator->GetRnrPTBMarkers())
84  {
85  // Last break-point is last point on track, do not draw it.
86  Int_t nbp = fM->fBreakPoints.size() - 1;
87  Bool_t bmb = fM->fPropagator->GetProjTrackBreaking() == TEveTrackPropagator::kPTB_Break;
88  Int_t nbptd = bmb ? 2*nbp : nbp;
89  std::vector<Float_t> pnts(3*nbptd);
90  Int_t n = 0;
91  for (Int_t i = 0; i < nbp; ++i, n+=3)
92  {
93  fM->GetPoint(fM->fBreakPoints[i] - 1, pnts[n], pnts[n+1], pnts[n+2]);
94  if (bmb)
95  {
96  n += 3;
97  fM->GetPoint(fM->fBreakPoints[i], pnts[n], pnts[n+1], pnts[n+2]);
98  }
99  }
100  TGLUtil::RenderPolyMarkers(fM->fPropagator->RefPTBAtt(), 0,
101  &pnts[0], nbptd,
102  rnrCtx.GetPickRadius(),
103  rnrCtx.Selection());
104  }
105 
106  RenderPathMarksAndFirstVertex(rnrCtx);
107 }