]>
Commit | Line | Data |
---|---|---|
ab2f6604 | 1 | // -*- C++ -*- |
2 | // | |
3 | // 1998/10/19 | |
4 | // --------------------------------------------------------------------------- | |
5 | // | |
6 | // AliGBox Class | |
7 | // | |
8 | // This file is part of the ALICE Geometry Database . | |
9 | // | |
10 | // Author: Joana E. Santo & company... | |
11 | // | |
12 | // --------------------------------------------------------------------------- | |
13 | ||
14 | #include <TView.h> | |
15 | #include <TCanvas.h> | |
16 | #include <TVirtualPad.h> | |
17 | #include <iostream.h> | |
18 | #include <TGLKernelABC.h> | |
19 | #include "AliGBox.h" | |
20 | #include <TROOT.h> | |
21 | ||
22 | ClassImp(AliGBox) | |
23 | ||
24 | ||
25 | //------------------------------------------------------------------------- | |
26 | ||
27 | AliGBox::AliGBox(Text_t* name,Text_t* title, Float_t Dx, Float_t Dy, Float_t Dz) : AliGShape(name, title) | |
28 | { | |
29 | /* Constructor */ | |
30 | fDx = Dx; | |
31 | fDy = Dy; | |
32 | fDz = Dz; | |
33 | } | |
34 | ||
35 | //------------------------------------------------------------------------- | |
36 | ||
37 | AliGBox::AliGBox( AliGBox* box ) | |
38 | { | |
39 | if( box ) { | |
40 | /* Copy Constructor */ | |
41 | fDx = box->fDx; | |
42 | fDy = box->fDy; | |
43 | fDz = box->fDz; | |
44 | fName = box->fName; | |
45 | fTitle = box->fTitle; | |
46 | fColor = box->fColor; | |
47 | } | |
48 | else{ | |
49 | /* Default Constructor */ | |
50 | fDx = 0; | |
51 | fDy = 0; | |
52 | fDz = 0; | |
53 | fName = ""; | |
54 | fTitle = ""; | |
55 | } | |
56 | } | |
57 | ||
58 | //------------------------------------------------------------------------- | |
59 | ||
60 | AliGBox* AliGBox::operator=(const AliGBox *box) | |
61 | { | |
62 | /* Operator = */ | |
63 | if( this == box) return this; // special case. | |
64 | ||
65 | fDx = box->fDx; | |
66 | fDy = box->fDy; | |
67 | fDz = box->fDz; | |
68 | fName = box->fName; | |
69 | fTitle = box->fTitle; | |
70 | fColor = box->fColor; | |
71 | ||
72 | return this; | |
73 | } | |
74 | ||
75 | //------------------------------------------------------------------------- | |
76 | ||
77 | void AliGBox::DrawShape(Option_t *option) | |
78 | { | |
79 | Draw(option); | |
80 | gPad->Update(); | |
81 | } | |
82 | ||
83 | //------------------------------------------------------------------------- | |
84 | ||
85 | void AliGBox::Paint(Option_t *option) | |
86 | { | |
87 | SetLineColor( GetCol() ); | |
88 | const Int_t numpoints = 8; | |
89 | ||
90 | //*-* Allocate memory for points *-* | |
91 | ||
92 | Float_t *points = new Float_t[3*numpoints]; | |
93 | if (!points) return; | |
94 | ||
95 | SetPoints(points); | |
96 | ||
97 | if (gPad->GetView3D()) PaintGLPoints(points); | |
98 | ||
99 | //== for (Int_t i = 0; i < numpoints; i++) | |
100 | // gNode->Local2Master(&points[3*i],&points[3*i]); | |
101 | ||
102 | Int_t c = ((GetLineColor() % 8) - 1) * 4; // Basic colors: 0, 1, ... 7 | |
103 | if (c < 0) c = 0; | |
104 | ||
105 | //*-* Allocate memory for segments *-* | |
106 | ||
107 | X3DBuffer *buff = new X3DBuffer; | |
108 | if (buff) { | |
109 | buff->numPoints = 8; | |
110 | buff->numSegs = 12; | |
111 | buff->numPolys = 6; | |
112 | } | |
113 | ||
114 | //*-* Allocate memory for points *-* | |
115 | ||
116 | buff->points = points; | |
117 | buff->segs = new Int_t[buff->numSegs*3]; | |
118 | if (buff->segs) { | |
119 | buff->segs[ 0] = c; buff->segs[ 1] = 0; buff->segs[ 2] = 1; | |
120 | buff->segs[ 3] = c+1; buff->segs[ 4] = 1; buff->segs[ 5] = 2; | |
121 | buff->segs[ 6] = c+1; buff->segs[ 7] = 2; buff->segs[ 8] = 3; | |
122 | buff->segs[ 9] = c; buff->segs[10] = 3; buff->segs[11] = 0; | |
123 | buff->segs[12] = c+2; buff->segs[13] = 4; buff->segs[14] = 5; | |
124 | buff->segs[15] = c+2; buff->segs[16] = 5; buff->segs[17] = 6; | |
125 | buff->segs[18] = c+3; buff->segs[19] = 6; buff->segs[20] = 7; | |
126 | buff->segs[21] = c+3; buff->segs[22] = 7; buff->segs[23] = 4; | |
127 | buff->segs[24] = c; buff->segs[25] = 0; buff->segs[26] = 4; | |
128 | buff->segs[27] = c+2; buff->segs[28] = 1; buff->segs[29] = 5; | |
129 | buff->segs[30] = c+1; buff->segs[31] = 2; buff->segs[32] = 6; | |
130 | buff->segs[33] = c+3; buff->segs[34] = 3; buff->segs[35] = 7; | |
131 | } | |
132 | ||
133 | //*-* Allocate memory for polygons *-* | |
134 | ||
135 | buff->polys = new Int_t[buff->numPolys*6]; | |
136 | if (buff->polys) { | |
137 | buff->polys[ 0] = c; buff->polys[ 1] = 4; buff->polys[ 2] = 0; | |
138 | buff->polys[ 3] = 9; buff->polys[ 4] = 4; buff->polys[ 5] = 8; | |
139 | buff->polys[ 6] = c+1; buff->polys[ 7] = 4; buff->polys[ 8] = 1; | |
140 | buff->polys[ 9] = 10; buff->polys[10] = 5; buff->polys[11] = 9; | |
141 | buff->polys[12] = c; buff->polys[13] = 4; buff->polys[14] = 2; | |
142 | buff->polys[15] = 11; buff->polys[16] = 6; buff->polys[17] = 10; | |
143 | buff->polys[18] = c+1; buff->polys[19] = 4; buff->polys[20] = 3; | |
144 | buff->polys[21] = 8; buff->polys[22] = 7; buff->polys[23] = 11; | |
145 | buff->polys[24] = c+2; buff->polys[25] = 4; buff->polys[26] = 0; | |
146 | buff->polys[27] = 3; buff->polys[28] = 2; buff->polys[29] = 1; | |
147 | buff->polys[30] = c+3; buff->polys[31] = 4; buff->polys[32] = 4; | |
148 | buff->polys[33] = 5; buff->polys[34] = 6; buff->polys[35] = 7; | |
149 | } | |
150 | ||
151 | //*-* Paint in the pad | |
152 | Bool_t rangeView = strcmp(option,"range")==0 ? kTRUE : kFALSE; | |
153 | PaintShape(buff,rangeView); | |
154 | ||
155 | if (strstr(option, "x3d")) { | |
156 | if(buff && buff->points && buff->segs) | |
157 | FillX3DBuffer(buff); | |
158 | else { | |
159 | gSize3D.numPoints -= buff->numPoints; | |
160 | gSize3D.numSegs -= buff->numSegs; | |
161 | gSize3D.numPolys -= buff->numPolys; | |
162 | } | |
163 | } | |
164 | ||
165 | delete [] points; | |
166 | if (buff->segs) delete [] buff->segs; | |
167 | if (buff->polys) delete [] buff->polys; | |
168 | if (buff) delete buff; | |
169 | ||
170 | ||
171 | } | |
172 | ||
173 | ||
174 | ||
175 | ||
176 | // --------------------------------------------------------------------------- | |
177 | ||
178 | void AliGBox::PaintGLPoints(Float_t *vertex) | |
179 | { | |
180 | //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*Paint BRIK via OpenGL *-*-*-*-*-*-*-*-*-*-*-*-* | |
181 | //*-* ===================== | |
182 | gGLKernel->PaintBrik(vertex); | |
183 | } | |
184 | ||
185 | ||
186 | // --------------------------------------------------------------------------- | |
187 | ||
188 | void AliGBox::SetPoints(Float_t *buff) | |
189 | { | |
190 | //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*Create AliGBox points*-*-*-*-*-*-*-*-*-*-*-*-*-*-* | |
191 | //*-* ===================== | |
192 | ||
193 | if (buff) { | |
194 | buff[ 0] = -fDx; buff[ 1] = -fDy; buff[ 2] = -fDz; | |
195 | buff[ 3] = fDx; buff[ 4] = -fDy; buff[ 5] = -fDz; | |
196 | buff[ 6] = fDx; buff[ 7] = fDy; buff[ 8] = -fDz; | |
197 | buff[ 9] = -fDx; buff[10] = fDy; buff[11] = -fDz; | |
198 | buff[12] = -fDx; buff[13] = -fDy; buff[14] = fDz; | |
199 | buff[15] = fDx; buff[16] = -fDy; buff[17] = fDz; | |
200 | buff[18] = fDx; buff[19] = fDy; buff[20] = fDz; | |
201 | buff[21] = -fDx; buff[22] = fDy; buff[23] = fDz; | |
202 | } | |
203 | } | |
204 | ||
205 | //------------------------------------------------------------------------- | |
206 | ||
207 | void AliGBox::Sizeof3D() const | |
208 | { | |
209 | //*-*-*-*-*-*-*Return total X3D size of this shape with its attributes*-*-*-*-*-* | |
210 | //*-* ======================================================= | |
211 | ||
212 | //cout << " Entra en AliGBox::Sizeof3D() " << endl; | |
213 | ||
214 | gSize3D.numPoints += 8; | |
215 | gSize3D.numSegs += 12; | |
216 | gSize3D.numPolys += 6; | |
217 | } | |
218 | ||
219 | ||
220 | ||
221 | ||
222 | ||
223 | ||
224 | ||
225 |