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