]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/BoxSetGL.cxx
Added methods Track::ImportHits() and Track::ImportClusters(); fixed a charge value...
[u/mrichter/AliRoot.git] / EVE / Reve / BoxSetGL.cxx
1 // $Header$
2
3 #include "BoxSetGL.h"
4 #include <Reve/BoxSet.h>
5
6 #include <TGLDrawFlags.h>
7 #ifdef WIN32
8 #include "Windows4root.h"
9 #endif
10 #include <GL/gl.h>
11 #include <GL/glu.h>
12
13 using namespace Reve;
14
15 //______________________________________________________________________
16 // BoxSetGL
17 //
18
19 ClassImp(BoxSetGL)
20
21 BoxSetGL::BoxSetGL()
22 {
23   // fCached = false; // Disable display list.
24 }
25
26 BoxSetGL::~BoxSetGL()
27 {}
28
29 /**************************************************************************/
30
31 Bool_t BoxSetGL::SetModel(TObject* obj)
32 {
33 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2)
34   return set_model(obj, "Reve::BoxSet");
35 #else
36   return SetModelCheckClass(obj, "Reve::BoxSet");
37 #endif
38 }
39
40 void BoxSetGL::SetBBox()
41 {
42 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2)
43   set_axis_aligned_bbox(((BoxSet*)fExternalObj)->AssertBBox());
44 #else
45   SetAxisAlignedBBox(((BoxSet*)fExternalObj)->AssertBBox());
46 #endif
47 }
48
49 /**************************************************************************/
50
51 void BoxSetGL::DirectDraw(const TGLDrawFlags& /*flags*/) const
52 {
53   BoxSet& mB = * (BoxSet*) fExternalObj;
54   // printf("BoxSetGL::DirectDraw N boxes %d\n", mB.fBoxes.size());
55
56   glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
57   glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
58   glEnable(GL_COLOR_MATERIAL);
59   glDisable(GL_CULL_FACE);
60
61   Float_t c[4]; glGetFloatv(GL_CURRENT_COLOR, c);
62
63   glBegin(GL_QUADS);
64   for(std::vector<Box>::iterator q=mB.fBoxes.begin(); q!=mB.fBoxes.end(); ++q) {
65     UChar_t* c = (UChar_t*) &q->color;
66     glColor3ub(c[0], c[1], c[2]);
67
68     // bottom: 3210
69     glNormal3f(0, 0, -1);
70     glVertex3fv(q->vertices + 9);  glVertex3fv(q->vertices + 6);
71     glVertex3fv(q->vertices + 3);  glVertex3fv(q->vertices);
72     // top:   4567
73     glNormal3f(0, 0, 1);
74     glVertex3fv(q->vertices + 12); glVertex3fv(q->vertices + 15);
75     glVertex3fv(q->vertices + 18); glVertex3fv(q->vertices + 21);
76     // front: 0154
77     glNormal3f(0, -1, 0);
78     glVertex3fv(q->vertices);      glVertex3fv(q->vertices + 3);
79     glVertex3fv(q->vertices + 15); glVertex3fv(q->vertices + 12);
80     // back:  7623
81     glNormal3f(0, 1, 0);
82     glVertex3fv(q->vertices + 21); glVertex3fv(q->vertices + 18);
83     glVertex3fv(q->vertices + 6);  glVertex3fv(q->vertices + 9);
84     // left:  4730
85     glNormal3f(-1, 0, 0);
86     glVertex3fv(q->vertices + 12); glVertex3fv(q->vertices + 21);
87     glVertex3fv(q->vertices + 9);  glVertex3fv(q->vertices);
88     // right: 5126
89     glNormal3f(1, 0, 0);
90     glVertex3fv(q->vertices + 15); glVertex3fv(q->vertices + 3);
91     glVertex3fv(q->vertices + 6);  glVertex3fv(q->vertices + 18);
92   }
93   glEnd();
94
95   glPopAttrib();
96 }