]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/LineGL.cxx
Follow-up on gl/ changes introduced in ROOT-5.16.
[u/mrichter/AliRoot.git] / EVE / Reve / LineGL.cxx
1 // $Header$
2
3 #include "LineGL.h"
4 #include <Reve/Line.h>
5
6 #include <TGLRnrCtx.h>
7 #include <TGLIncludes.h>
8
9 using namespace Reve;
10
11 //______________________________________________________________________
12 // LineGL
13 //
14
15 ClassImp(LineGL)
16
17 LineGL::LineGL() : TPointSet3DGL(), fM(0)
18 {
19   // fDLCache = false; // Disable display list.
20 }
21
22 LineGL::~LineGL()
23 {}
24
25 /**************************************************************************/
26
27 Bool_t LineGL::SetModel(TObject* obj, const Option_t* /*opt*/)
28 {
29   // TPointSet3DGL::SetModel(obj);
30   if(SetModelCheckClass(obj, Line::Class())) {
31     fM = dynamic_cast<Line*>(obj);
32     return kTRUE;
33   }
34   return kFALSE;
35 }
36
37 /**************************************************************************/
38
39 void LineGL::DirectDraw(TGLRnrCtx & rnrCtx) const
40 {
41   // Direct GL rendering for Line.
42
43   // printf("LineGL::DirectDraw Style %d, LOD %d\n", rnrCtx.Style(), rnrCtx.LOD());
44
45   if (rnrCtx.DrawPass() == TGLRnrCtx::kPassOutlineLine)
46     return;
47
48   Line& q = *fM;
49   if (q.Size() <= 0) return;
50
51   glPushAttrib(GL_POINT_BIT | GL_LINE_BIT | GL_ENABLE_BIT);
52   glDisable(GL_LIGHTING);
53
54   UChar_t color[4];
55
56   if (q.fRnrLine)
57   {
58     glPushAttrib(GL_LINE_BIT);
59     ColorFromIdx(q.GetLineColor(), color);
60     glColor4ubv(color);
61     glLineWidth(q.GetLineWidth());
62     if (q.GetLineStyle() > 1) {
63       Int_t    fac = 1;
64       UShort_t pat = 0xffff;
65       switch (q.GetLineStyle()) {
66       case 2:  pat = 0x3333; break;
67       case 3:  pat = 0x5555; break;
68       case 4:  pat = 0xf040; break;
69       case 5:  pat = 0xf4f4; break;
70       case 6:  pat = 0xf111; break;
71       case 7:  pat = 0xf0f0; break;
72       case 8:  pat = 0xff11; break;
73       case 9:  pat = 0x3fff; break;
74       case 10: pat = 0x08ff; fac = 2; break;
75       }
76
77       glLineStipple(1, pat);
78       glEnable(GL_LINE_STIPPLE);
79     }
80
81     const Float_t* p = q.GetP();
82     const Int_t    n = q.Size();
83     glBegin(GL_LINE_STRIP);
84     for (Int_t i=0; i<n; ++i, p+=3)
85       glVertex3fv(p);
86     glEnd();
87     glPopAttrib();
88   }
89
90   if (q.fRnrPoints)
91   {
92     ColorFromIdx(q.GetMarkerColor(), color);
93     glColor4ubv(color);
94     Int_t ms = q.GetMarkerStyle();
95     if (ms != 2 && ms != 3 && ms != 5 && ms != 28)
96       RenderPoints(rnrCtx);
97     else
98       RenderCrosses(rnrCtx);
99   }
100
101   glPopAttrib();
102 }