]>
Commit | Line | Data |
---|---|---|
a897a37a | 1 | #include <AliMUONTUBE.h> |
2 | #include <TTUBE.h> | |
3 | #include "TVirtualPad.h" | |
4 | ClassImp(AliMUONTUBE) | |
5 | ||
6 | AliMUONTUBE::AliMUONTUBE():TTUBE() | |
7 | {;} | |
8 | ||
9 | //_____________________________________________________________________________ | |
10 | ||
11 | AliMUONTUBE::AliMUONTUBE(Text_t *name, Text_t *title, Text_t *material, Float_t rmin, | |
12 | Float_t rmax, Float_t dz,Float_t aspect): | |
13 | TTUBE(name, title, material, rmin, rmax, dz, aspect) | |
14 | {} | |
15 | ||
16 | //______________________________________________________________________________ | |
17 | AliMUONTUBE::AliMUONTUBE(Text_t *name, Text_t *title, Text_t *material, Float_t rmax, | |
18 | Float_t dz) | |
19 | : TTUBE(name, title, material, rmax, dz) | |
20 | { | |
21 | } | |
22 | ||
23 | //______________________________________________________________________________ | |
24 | void AliMUONTUBE::Paint(Option_t *option) | |
25 | { | |
26 | //*-*-*-*-*-*-*-*Paint this 3-D shape with its current attributes*-*-*-*-*-*-*-* | |
27 | //*-* ================================================ | |
28 | ||
29 | Int_t i, j; | |
30 | Int_t n = GetNumberOfDivisions(); | |
31 | const Int_t numpoints = 4*n; | |
32 | ||
33 | //*-* Allocate memory for points *-* | |
34 | ||
35 | Float_t *points = new Float_t[3*numpoints]; | |
36 | if (!points) return; | |
37 | ||
38 | SetPoints(points); | |
39 | ||
40 | if (gPad->GetView3D()) PaintGLPoints(points); | |
41 | ||
42 | //== for (i = 0; i < numpoints; i++) | |
43 | //== gNode->Local2Master(&points[3*i],&points[3*i]); | |
44 | ||
45 | X3DBuffer *buff = new X3DBuffer; | |
46 | if (buff) { | |
47 | buff->numPoints = numpoints; | |
48 | buff->numSegs = n*6; | |
49 | if (strstr(option, "x3d")) buff->numSegs = n*8; | |
50 | buff->numPolys = n*4; | |
51 | } | |
52 | ||
53 | //*-* Allocate memory for points *-* | |
54 | ||
55 | buff->points = points; | |
56 | ||
57 | Int_t c = ((GetLineColor() % 8) - 1) * 4; // Basic colors: 0, 1, ... 7 | |
58 | if (c < 0) c = 0; | |
59 | ||
60 | //*-* Allocate memory for segments *-* | |
61 | ||
62 | buff->segs = new Int_t[buff->numSegs*3]; | |
63 | if (buff->segs) { | |
64 | for (i = 0; i < 4; i++) { | |
65 | for (j = 0; j < n; j++) { | |
66 | buff->segs[(i*n+j)*3 ] = c; | |
67 | buff->segs[(i*n+j)*3+1] = i*n+j; | |
68 | buff->segs[(i*n+j)*3+2] = i*n+j+1; | |
69 | } | |
70 | buff->segs[(i*n+j-1)*3+2] = i*n; | |
71 | } | |
72 | for (i = 4; i < 6; i++) { | |
73 | for (j = 0; j < n; j++) { | |
74 | buff->segs[(i*n+j)*3 ] = c+1; | |
75 | buff->segs[(i*n+j)*3+1] = (i-4)*n+j; | |
76 | buff->segs[(i*n+j)*3+2] = (i-2)*n+j; | |
77 | } | |
78 | } | |
79 | if (strstr(option, "x3d")) | |
80 | { | |
81 | for (i = 6; i < 8; i++) { | |
82 | for (j = 0; j < n; j++) { | |
83 | buff->segs[(i*n+j)*3 ] = c; | |
84 | buff->segs[(i*n+j)*3+1] = 2*(i-6)*n+j; | |
85 | buff->segs[(i*n+j)*3+2] = (2*(i-6)+1)*n+j; | |
86 | } | |
87 | } | |
88 | } | |
89 | } | |
90 | //*-* Allocate memory for polygons *-* | |
91 | ||
92 | Int_t indx = 0; | |
93 | ||
94 | buff->polys = new Int_t[buff->numPolys*6]; | |
95 | if (buff->polys) { | |
96 | for (i = 0; i < 2; i++) { | |
97 | for (j = 0; j < n; j++) { | |
98 | indx = 6*(i*n+j); | |
99 | buff->polys[indx ] = c; | |
100 | buff->polys[indx+1] = 4; | |
101 | buff->polys[indx+2] = i*n+j; | |
102 | buff->polys[indx+3] = (4+i)*n+j; | |
103 | buff->polys[indx+4] = (2+i)*n+j; | |
104 | buff->polys[indx+5] = (4+i)*n+j+1; | |
105 | } | |
106 | buff->polys[indx+5] = (4+i)*n; | |
107 | } | |
108 | for (i = 2; i < 4; i++) { | |
109 | for (j = 0; j < n; j++) { | |
110 | indx = 6*(i*n+j); | |
111 | buff->polys[indx ] = c+(i-2)*2+1; | |
112 | buff->polys[indx+1] = 4; | |
113 | buff->polys[indx+2] = (i-2)*2*n+j; | |
114 | buff->polys[indx+3] = (4+i)*n+j; | |
115 | buff->polys[indx+4] = ((i-2)*2+1)*n+j; | |
116 | buff->polys[indx+5] = (4+i)*n+j+1; | |
117 | } | |
118 | buff->polys[indx+5] = (4+i)*n; | |
119 | } | |
120 | } | |
121 | ||
122 | //*-* Paint in the pad | |
123 | Bool_t rangeView = strcmp(option,"range")==0 ? kTRUE : kFALSE; | |
124 | PaintShape(buff,rangeView); | |
125 | ||
126 | if (strstr(option, "x3d")) { | |
127 | if(buff && buff->points && buff->segs) | |
128 | FillX3DBuffer(buff); | |
129 | else { | |
130 | gSize3D.numPoints -= buff->numPoints; | |
131 | gSize3D.numSegs -= buff->numSegs; | |
132 | gSize3D.numPolys -= buff->numPolys; | |
133 | } | |
134 | } | |
135 | ||
136 | if (buff->points) delete [] buff->points; | |
137 | if (buff->segs) delete [] buff->segs; | |
138 | if (buff->polys) delete [] buff->polys; | |
139 | if (buff) delete buff; | |
140 | } | |
141 |