]>
Commit | Line | Data |
---|---|---|
ab2f6604 | 1 | // -*- C++ -*- |
2 | // | |
3 | // 1998/10/19 | |
4 | // --------------------------------------------------------------------------- | |
5 | // | |
6 | // AliGTRD1 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 "AliGTRD1.h" | |
20 | #include <TROOT.h> | |
21 | ||
22 | ClassImp(AliGTRD1) | |
23 | ||
24 | //------------------------------------------------------------------------- | |
25 | ||
26 | AliGTRD1::AliGTRD1(Text_t *name, Text_t *title, Float_t dx1, Float_t dx2, Float_t dy, Float_t dz) : AliGShape(name, title) | |
27 | { | |
28 | //*-*-*-*-*-*-*-*-*-*-*-*-*AliGTRD1 shape normal constructor*-*-*-*-*-*-*-*-*-*-*-*-* | |
29 | //*-* ============================= | |
30 | ||
31 | fDx2 = dx2; | |
32 | fDx1 = dx1; | |
33 | fDy = dy; | |
34 | fDz = dz; | |
35 | } | |
36 | ||
37 | //------------------------------------------------------------------------- | |
38 | ||
39 | AliGTRD1::AliGTRD1() | |
40 | { | |
41 | /* Default Constructor */ | |
42 | ||
43 | fDx2 = 0; | |
44 | fName = ""; | |
45 | fTitle = ""; | |
46 | } | |
47 | ||
48 | //------------------------------------------------------------------------- | |
49 | ||
50 | AliGTRD1::AliGTRD1( AliGTRD1* trd1 ) | |
51 | { | |
52 | /* Copy Constructor */ | |
53 | fColor = trd1->fColor; | |
54 | fDx1 = trd1->fDx1; | |
55 | fDx2 = trd1->fDx2; | |
56 | fDy = trd1->fDy; | |
57 | fDz = trd1->fDz; | |
58 | fName = trd1->fName; | |
59 | fTitle = trd1->fTitle; | |
60 | } | |
61 | ||
62 | //---------------------------------------------------------------------------- | |
63 | ||
64 | void AliGTRD1::SetPoints(Float_t *buff) | |
65 | { | |
66 | //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*Create AliGTRD1 points*-*-*-*-*-*-*-*-*-*-*-*-*-*-* | |
67 | //*-* ================== | |
68 | ||
69 | Float_t dx1, dx2, dy, dz; | |
70 | ||
71 | dx1 = fDx1; | |
72 | dx2 = fDx2; | |
73 | dy = fDy; | |
74 | dz = fDz; | |
75 | ||
76 | if (buff) { | |
77 | buff[ 0] = -dx1; buff[ 1] = -dy; buff[ 2] = -dz; | |
78 | buff[ 3] = dx1; buff[ 4] = -dy; buff[ 5] = -dz; | |
79 | buff[ 6] = dx1; buff[ 7] = dy; buff[ 8] = -dz; | |
80 | buff[ 9] = -dx1; buff[10] = dy; buff[11] = -dz; | |
81 | buff[12] = -dx2; buff[13] = -dy; buff[14] = dz; | |
82 | buff[15] = dx2; buff[16] = -dy; buff[17] = dz; | |
83 | buff[18] = dx2; buff[19] = dy; buff[20] = dz; | |
84 | buff[21] = -dx2; buff[22] = dy; buff[23] = dz; | |
85 | } | |
86 | } | |
87 | ||
88 | //------------------------------------------------------------------------- | |
89 | ||
90 | void AliGTRD1::Paint(Option_t *option) | |
91 | { | |
92 | SetLineColor( GetCol() ); | |
93 | ||
94 | const Int_t numpoints = 8; | |
95 | ||
96 | //*-* Allocate memory for points *-* | |
97 | ||
98 | Float_t *points = new Float_t[3*numpoints]; | |
99 | if (!points) return; | |
100 | ||
101 | SetPoints(points); | |
102 | ||
103 | if (gPad->GetView3D()) PaintGLPoints(points); | |
104 | ||
105 | //== for (Int_t i = 0; i < numpoints; i++) | |
106 | // gNode->Local2Master(&points[3*i],&points[3*i]); | |
107 | ||
108 | Int_t c = ((GetLineColor() % 8) - 1) * 4; // Basic colors: 0, 1, ... 7 | |
109 | if (c < 0) c = 0; | |
110 | ||
111 | //*-* Allocate memory for segments *-* | |
112 | ||
113 | X3DBuffer *buff = new X3DBuffer; | |
114 | if (buff) { | |
115 | buff->numPoints = 8; | |
116 | buff->numSegs = 12; | |
117 | buff->numPolys = 6; | |
118 | } | |
119 | ||
120 | //*-* Allocate memory for points *-* | |
121 | ||
122 | buff->points = points; | |
123 | buff->segs = new Int_t[buff->numSegs*3]; | |
124 | ||
125 | if (buff->segs) { | |
126 | buff->segs[ 0] = c; buff->segs[ 1] = 0; buff->segs[ 2] = 1; | |
127 | buff->segs[ 3] = c+1; buff->segs[ 4] = 1; buff->segs[ 5] = 2; | |
128 | buff->segs[ 6] = c+1; buff->segs[ 7] = 2; buff->segs[ 8] = 3; | |
129 | buff->segs[ 9] = c; buff->segs[10] = 3; buff->segs[11] = 0; | |
130 | buff->segs[12] = c+2; buff->segs[13] = 4; buff->segs[14] = 5; | |
131 | buff->segs[15] = c+2; buff->segs[16] = 5; buff->segs[17] = 6; | |
132 | buff->segs[18] = c+3; buff->segs[19] = 6; buff->segs[20] = 7; | |
133 | buff->segs[21] = c+3; buff->segs[22] = 7; buff->segs[23] = 4; | |
134 | buff->segs[24] = c; buff->segs[25] = 0; buff->segs[26] = 4; | |
135 | buff->segs[27] = c+2; buff->segs[28] = 1; buff->segs[29] = 5; | |
136 | buff->segs[30] = c+1; buff->segs[31] = 2; buff->segs[32] = 6; | |
137 | buff->segs[33] = c+3; buff->segs[34] = 3; buff->segs[35] = 7; | |
138 | } | |
139 | ||
140 | //*-* Allocate memory for polygons *-* | |
141 | ||
142 | buff->polys = new Int_t[buff->numPolys*6]; | |
143 | ||
144 | if (buff->polys) { | |
145 | buff->polys[ 0] = c; buff->polys[ 1] = 4; buff->polys[ 2] = 0; | |
146 | buff->polys[ 3] = 9; buff->polys[ 4] = 4; buff->polys[ 5] = 8; | |
147 | buff->polys[ 6] = c+1; buff->polys[ 7] = 4; buff->polys[ 8] = 1; | |
148 | buff->polys[ 9] = 10; buff->polys[10] = 5; buff->polys[11] = 9; | |
149 | buff->polys[12] = c; buff->polys[13] = 4; buff->polys[14] = 2; | |
150 | buff->polys[15] = 11; buff->polys[16] = 6; buff->polys[17] = 10; | |
151 | buff->polys[18] = c+1; buff->polys[19] = 4; buff->polys[20] = 3; | |
152 | buff->polys[21] = 8; buff->polys[22] = 7; buff->polys[23] = 11; | |
153 | buff->polys[24] = c+2; buff->polys[25] = 4; buff->polys[26] = 0; | |
154 | buff->polys[27] = 3; buff->polys[28] = 2; buff->polys[29] = 1; | |
155 | buff->polys[30] = c+3; buff->polys[31] = 4; buff->polys[32] = 4; | |
156 | buff->polys[33] = 5; buff->polys[34] = 6; buff->polys[35] = 7; | |
157 | } | |
158 | ||
159 | //*-* Paint in the pad | |
160 | Bool_t rangeView = strcmp(option,"range")==0 ? kTRUE : kFALSE; | |
161 | PaintShape(buff,rangeView); | |
162 | ||
163 | if (strstr(option, "x3d")) { | |
164 | if(buff && buff->points && buff->segs) | |
165 | FillX3DBuffer(buff); | |
166 | else { | |
167 | gSize3D.numPoints -= buff->numPoints; | |
168 | gSize3D.numSegs -= buff->numSegs; | |
169 | gSize3D.numPolys -= buff->numPolys; | |
170 | } | |
171 | } | |
172 | ||
173 | delete [] points; | |
174 | if (buff->segs) delete [] buff->segs; | |
175 | if (buff->polys) delete [] buff->polys; | |
176 | if (buff) delete buff; | |
177 | } | |
178 |