]>
Commit | Line | Data |
---|---|---|
dcb55984 | 1 | // $Header$ |
2 | ||
3 | #include "TPCSector3DGL.h" | |
4 | #include <Alieve/TPCSector3D.h> | |
5 | ||
6 | #include <Reve/BoxSetGL.h> | |
7 | ||
8 | #include <TGLDrawFlags.h> | |
9 | ||
10 | #ifdef WIN32 | |
11 | #include "Windows4root.h" | |
12 | #endif | |
13 | #include <GL/gl.h> | |
14 | #include <GL/glu.h> | |
15 | ||
16 | using namespace Reve; | |
17 | using namespace Alieve; | |
18 | ||
19 | //______________________________________________________________________ | |
20 | // TPCSector3DGL | |
21 | // | |
22 | ||
23 | ClassImp(TPCSector3DGL) | |
24 | ||
25 | TPCSector3DGL::TPCSector3DGL() : fSector(0), fBoxRnr(0) | |
26 | { | |
27 | // fCached = false; // Disable display list. | |
28 | } | |
29 | ||
30 | TPCSector3DGL::~TPCSector3DGL() | |
31 | { | |
32 | delete fBoxRnr; | |
33 | } | |
34 | ||
35 | /**************************************************************************/ | |
36 | ||
37 | Bool_t TPCSector3DGL::SetModel(TObject* obj) | |
38 | { | |
39 | #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2) | |
40 | if(set_model(obj, "Alieve::TPCSector3D")) { | |
41 | #else | |
42 | if(SetModelCheckClass(obj, "Alieve::TPCSector3D")) { | |
43 | #endif | |
44 | fSector = (TPCSector3D*) fExternalObj; | |
45 | if(fBoxRnr == 0) { | |
46 | fBoxRnr = new BoxSetGL; | |
47 | fBoxRnr->SetModel(&fSector->fBoxSet); | |
48 | } | |
49 | return kTRUE; | |
50 | } | |
51 | return kFALSE; | |
52 | } | |
53 | ||
54 | void TPCSector3DGL::SetBBox() | |
55 | { | |
56 | #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2) | |
57 | set_axis_aligned_bbox(((TPCSector3D*)fExternalObj)->AssertBBox()); | |
58 | #else | |
59 | SetAxisAlignedBBox(((TPCSector3D*)fExternalObj)->AssertBBox()); | |
60 | #endif | |
61 | } | |
62 | ||
63 | /**************************************************************************/ | |
64 | ||
65 | void TPCSector3DGL::DirectDraw(const TGLDrawFlags & flags) const | |
66 | { | |
67 | // printf("TPCSector3DGL::DirectDraw Style %d, LOD %d\n", flags.Style(), flags.LOD()); | |
68 | ||
69 | fBoxRnr->Render(flags); | |
70 | ||
9a7ad6a0 | 71 | if(fSector->fPointSetOn) { |
72 | UChar_t col[4]; | |
73 | ||
74 | glPushAttrib(GL_POINT_BIT | GL_ENABLE_BIT); | |
75 | glDisable(GL_LIGHTING); | |
76 | glEnable(GL_BLEND); | |
77 | glEnable(GL_POINT_SMOOTH); | |
78 | glPointSize(fSector->GetMarkerSize()); | |
79 | ||
80 | glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); | |
81 | glEnableClientState(GL_VERTEX_ARRAY); | |
82 | ||
83 | const Reve::PointSetArray& psa = fSector->fPointSetArray; | |
84 | for(Int_t b=0; b<psa.GetNBins(); ++b) { | |
85 | Reve::PointSet* ps = psa.GetBin(b); | |
86 | ColorFromIdx(ps->GetMarkerColor(), col); | |
87 | glColor4ubv(col); | |
88 | ||
89 | glVertexPointer(3, GL_FLOAT, 0, ps->GetP()); | |
90 | glDrawArrays(GL_POINTS, 0, ps->GetN()); | |
91 | } | |
92 | ||
93 | glPopClientAttrib(); | |
94 | glPopAttrib(); | |
95 | } | |
96 | ||
dcb55984 | 97 | if(fSector->fRnrFrame) { |
98 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | |
99 | ||
100 | glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT); | |
101 | ||
102 | glDisable(GL_LIGHTING); | |
103 | glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); | |
104 | glEnable(GL_COLOR_MATERIAL); | |
105 | ||
106 | UChar_t col[4]; | |
107 | ColorFromIdx(fSector->fFrameColor, col); | |
108 | glColor4ubv(col); | |
109 | ||
110 | if(fSector->fRnrInn) | |
91cb2b7c | 111 | DrawSegmentFrame(TPCSectorData::GetInnSeg(), 0, 2); |
dcb55984 | 112 | if(fSector->fRnrOut1) |
91cb2b7c | 113 | DrawSegmentFrame(TPCSectorData::GetOut1Seg(), 2, 1); |
dcb55984 | 114 | if(fSector->fRnrOut2) |
91cb2b7c | 115 | DrawSegmentFrame(TPCSectorData::GetOut2Seg(), 2, 2); |
dcb55984 | 116 | |
117 | glPopAttrib(); | |
118 | } | |
119 | } | |
120 | ||
91cb2b7c | 121 | void TPCSector3DGL::DrawSegmentFrame(const TPCSectorData::SegmentInfo& s, |
122 | Int_t botExtraPads, Int_t topExtraPads) const | |
dcb55984 | 123 | { |
124 | Float_t xl, xh, yl, yh, zl, zh; | |
91cb2b7c | 125 | xl = 0.5*s.GetPadWidth()*(TPCSectorData::GetNPadsInRow(s.GetFirstRow()) + botExtraPads); |
126 | xh = 0.5*s.GetPadWidth()*(TPCSectorData::GetNPadsInRow(s.GetLastRow()) + topExtraPads); | |
dcb55984 | 127 | yl = s.GetRLow(); |
128 | yh = yl + s.GetNRows()*s.GetPadHeight(); | |
129 | zl = -0.5; | |
130 | zh = 250.5; | |
131 | ||
132 | glBegin(GL_LINE_LOOP); | |
133 | glVertex3f( xl, yl, zl); glVertex3f( xh, yh, zl); | |
134 | glVertex3f(-xh, yh, zl); glVertex3f(-xl, yl, zl); | |
135 | glEnd(); | |
136 | glBegin(GL_LINE_LOOP); | |
137 | glVertex3f( xl, yl, zh); glVertex3f( xh, yh, zh); | |
138 | glVertex3f(-xh, yh, zh); glVertex3f(-xl, yl, zh); | |
139 | glEnd(); | |
140 | glBegin(GL_LINES); | |
141 | glVertex3f( xl, yl, zl); glVertex3f( xl, yl, zh); | |
142 | glVertex3f( xh, yh, zl); glVertex3f( xh, yh, zh); | |
143 | glVertex3f(-xh, yh, zl); glVertex3f(-xh, yh, zh); | |
144 | glVertex3f(-xl, yl, zl); glVertex3f(-xl, yl, zh); | |
145 | glEnd(); | |
146 | } |