1 | #pragma rtGlobals=3 // Use modern global access method and strict wave access. |
---|
2 | |
---|
3 | |
---|
4 | ///////////////////////// |
---|
5 | // |
---|
6 | // Function to draw schematic boxes for the detector coverage based on the geometry |
---|
7 | // of the instrument setup |
---|
8 | // |
---|
9 | // -- all of the dimensions are based on the angles and ranges in degrees |
---|
10 | // |
---|
11 | // -- this draws all 9 of the panels. Zooming is then simply rescaling the axes |
---|
12 | // |
---|
13 | // -- Now it is part of the main panel. This function is then called again |
---|
14 | // to update the drawing when any detector settings are changed |
---|
15 | // |
---|
16 | ////////////////////////// |
---|
17 | |
---|
18 | Function FrontView_1x() |
---|
19 | |
---|
20 | SetDataFolder root:Packages:NIST:VSANS:VCALC |
---|
21 | |
---|
22 | // Dimensions of detectors |
---|
23 | NVAR F_LR_w = root:Packages:NIST:VSANS:VCALC:gFront_LR_w |
---|
24 | NVAR F_LR_h = root:Packages:NIST:VSANS:VCALC:gFront_LR_h |
---|
25 | NVAR F_TB_w = root:Packages:NIST:VSANS:VCALC:gFront_TB_w |
---|
26 | NVAR F_TB_h = root:Packages:NIST:VSANS:VCALC:gFront_TB_h |
---|
27 | |
---|
28 | NVAR M_LR_w = root:Packages:NIST:VSANS:VCALC:gMiddle_LR_w |
---|
29 | NVAR M_LR_h = root:Packages:NIST:VSANS:VCALC:gMiddle_LR_h |
---|
30 | NVAR M_TB_w = root:Packages:NIST:VSANS:VCALC:gMiddle_TB_w |
---|
31 | NVAR M_TB_h = root:Packages:NIST:VSANS:VCALC:gMiddle_TB_h |
---|
32 | |
---|
33 | NVAR B_h = root:Packages:NIST:VSANS:VCALC:gBack_h |
---|
34 | NVAR B_w = root:Packages:NIST:VSANS:VCALC:gBack_w |
---|
35 | |
---|
36 | |
---|
37 | // get the values from the panel |
---|
38 | Variable F_LR_sep,F_TB_sep, F_SDD, F_offset |
---|
39 | Variable M_LR_sep,M_TB_sep, M_SDD, M_offset |
---|
40 | Variable B_SDD, B_offset |
---|
41 | Variable axisRange |
---|
42 | |
---|
43 | // these offset values are in cm !! |
---|
44 | //in cm !! distance T/B are behind L/R - not to be confused with lateral offset |
---|
45 | NVAR front_SDDsetback = root:Packages:NIST:VSANS:VCALC:gFront_SDDsetback |
---|
46 | NVAR middle_SDDsetback = root:Packages:NIST:VSANS:VCALC:gMiddle_SDDsetback |
---|
47 | |
---|
48 | |
---|
49 | //front |
---|
50 | ControlInfo/W=VCALC VCALCCtrl_2a |
---|
51 | F_LR_sep = V_Value |
---|
52 | ControlInfo/W=VCALC VCALCCtrl_2b |
---|
53 | F_TB_sep = V_Value |
---|
54 | ControlInfo/W=VCALC VCALCCtrl_2c |
---|
55 | F_offset = V_Value |
---|
56 | ControlInfo/W=VCALC VCALCCtrl_2d |
---|
57 | F_SDD = V_Value |
---|
58 | |
---|
59 | //middle |
---|
60 | ControlInfo/W=VCALC VCALCCtrl_3a |
---|
61 | M_LR_sep = V_Value |
---|
62 | ControlInfo/W=VCALC VCALCCtrl_3b |
---|
63 | M_TB_sep = V_Value |
---|
64 | ControlInfo/W=VCALC VCALCCtrl_3c |
---|
65 | M_offset = V_Value |
---|
66 | ControlInfo/W=VCALC VCALCCtrl_3d |
---|
67 | M_SDD = V_Value |
---|
68 | |
---|
69 | //back |
---|
70 | ControlInfo/W=VCALC VCALCCtrl_4a |
---|
71 | B_offset = V_Value |
---|
72 | ControlInfo/W=VCALC VCALCCtrl_4b |
---|
73 | B_SDD = V_Value |
---|
74 | |
---|
75 | // axis range |
---|
76 | ControlInfo/W=VCALC setVar_a |
---|
77 | axisRange = V_Value |
---|
78 | |
---|
79 | Make/O/D/N=2 fv_degX,fv_degY |
---|
80 | fv_degX[0] = -axisRange |
---|
81 | fv_degX[1] = axisRange |
---|
82 | fv_degY[0] = -axisRange |
---|
83 | fv_degY[1] = axisRange |
---|
84 | |
---|
85 | // green fillfgc= (1,52428,26586) |
---|
86 | // black fillfgc= (0,0,0) |
---|
87 | // yellow fillfgc= (65535,65535,0) |
---|
88 | // blue fillfgc= (1,16019,65535) |
---|
89 | // red fillfgc= (65535,0,0) |
---|
90 | // light blue fillfgc= (1,52428,52428) |
---|
91 | // light brown fillfgc= (39321,26208,1) |
---|
92 | |
---|
93 | //clear the old drawing (this wipes out everything in the layer) |
---|
94 | DrawAction/L=UserBack/W=VCALC#FrontView delete |
---|
95 | |
---|
96 | //start drawing from the back, and work to the front as would be visible |
---|
97 | // ********* all of the dimensions are in cm |
---|
98 | Variable tmp_x1,tmp_x2,tmp_y1,tmp_y2 |
---|
99 | |
---|
100 | // back detector +/- degrees |
---|
101 | tmp_x1 = -atan(B_w/2/(B_SDD)) *(180/pi) |
---|
102 | tmp_x2 = -tmp_x1 |
---|
103 | tmp_y1 = -atan(B_h/2/(B_SDD)) *(180/pi) |
---|
104 | tmp_y2 = -tmp_y1 |
---|
105 | |
---|
106 | //DrawRect [/W=winName ] left, top, right, bottom |
---|
107 | SetDrawLayer/W=VCALC#FrontView UserBack |
---|
108 | SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (1,52428,52428) |
---|
109 | DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1 //only one panel in back |
---|
110 | |
---|
111 | // |
---|
112 | // MIDDLE 4 panels (T-B then L-R) |
---|
113 | // TO DO -- add in the additional offset (backwards) to the SDD of the T/B panels |
---|
114 | // TOP |
---|
115 | tmp_x1 = -atan(M_TB_w/2/(M_SDD+middle_SDDsetback))*(180/pi) // x symmetric y is not |
---|
116 | tmp_x2 = -tmp_x1 |
---|
117 | tmp_y1 = atan(M_TB_sep/2/(M_SDD+middle_SDDsetback))*(180/pi) |
---|
118 | tmp_y2 = atan((M_TB_sep/2+M_TB_h)/(M_SDD+middle_SDDsetback))*(180/pi) |
---|
119 | |
---|
120 | // Print tmp_x1,tmp_x2,tmp_y1,tmp_y2 |
---|
121 | |
---|
122 | SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (1,16019,65535) |
---|
123 | DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1 |
---|
124 | |
---|
125 | // BOTTOM (x unchanged, negate and swap y1,y2) |
---|
126 | tmp_y1 = -atan((M_TB_sep/2+M_TB_h)/(M_SDD+middle_SDDsetback))*(180/pi) |
---|
127 | tmp_y2 = -atan(M_TB_sep/2/(M_SDD+middle_SDDsetback))*(180/pi) |
---|
128 | SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (1,16019,65535) |
---|
129 | DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1 |
---|
130 | |
---|
131 | // LEFT |
---|
132 | tmp_x1 = -atan((M_LR_w+M_LR_sep/2)/(M_SDD))*(180/pi) // y symmetric x is not |
---|
133 | tmp_x2 = -atan((M_LR_sep/2)/(M_SDD))*(180/pi) |
---|
134 | tmp_y1 = atan(M_LR_h/2/(M_SDD))*(180/pi) |
---|
135 | tmp_y2 = -tmp_y1 |
---|
136 | SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (65535,0,0) |
---|
137 | DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1 |
---|
138 | // RIGHT (x changes, y the same) |
---|
139 | tmp_x1 = atan((M_LR_sep/2)/(M_SDD))*(180/pi) // y symmetric x is not |
---|
140 | tmp_x2 = atan((M_LR_w+M_LR_sep/2)/(M_SDD))*(180/pi) |
---|
141 | SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (65535,0,0) |
---|
142 | DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1 |
---|
143 | |
---|
144 | // Print tmp_x1,tmp_x2,tmp_y1,tmp_y2 |
---|
145 | |
---|
146 | //////// |
---|
147 | // FRONT 4 panels (T-B then L-R) |
---|
148 | // TO DO -- add in the additional offset (backwards) to the SDD of the T/B panels |
---|
149 | // TOP |
---|
150 | tmp_x1 = -atan(F_TB_w/2/(F_SDD+front_SDDsetback))*(180/pi) // x symmetric y is not |
---|
151 | tmp_x2 = -tmp_x1 |
---|
152 | tmp_y1 = atan(F_TB_sep/2/(F_SDD+front_SDDsetback))*(180/pi) |
---|
153 | tmp_y2 = atan((F_TB_sep/2+F_TB_h)/(F_SDD+front_SDDsetback))*(180/pi) |
---|
154 | |
---|
155 | // Print tmp_x1,tmp_x2,tmp_y1,tmp_y2 |
---|
156 | |
---|
157 | SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (1,52428,26586) |
---|
158 | DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1 |
---|
159 | |
---|
160 | // BOTTOM (x unchanged, negate and swap y1,y2) |
---|
161 | tmp_y1 = -atan((F_TB_sep/2+F_TB_h)/(F_SDD+front_SDDsetback))*(180/pi) |
---|
162 | tmp_y2 = -atan(F_TB_sep/2/(F_SDD+front_SDDsetback))*(180/pi) |
---|
163 | SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (1,52428,26586) |
---|
164 | DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1 |
---|
165 | |
---|
166 | // LEFT |
---|
167 | tmp_x1 = -atan((F_LR_w+F_LR_sep/2)/(F_SDD))*(180/pi) // y symmetric x is not |
---|
168 | tmp_x2 = -atan((F_LR_sep/2)/(F_SDD))*(180/pi) |
---|
169 | tmp_y1 = atan(F_LR_h/2/(F_SDD))*(180/pi) |
---|
170 | tmp_y2 = -tmp_y1 |
---|
171 | SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (39321,26208,1) |
---|
172 | DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1 |
---|
173 | // RIGHT (x changes, y the same) |
---|
174 | tmp_x1 = atan((F_LR_sep/2)/(F_SDD))*(180/pi) // y symmetric x is not |
---|
175 | tmp_x2 = atan((F_LR_w+F_LR_sep/2)/(F_SDD))*(180/pi) |
---|
176 | SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (39321,26208,1) |
---|
177 | DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1 |
---|
178 | |
---|
179 | |
---|
180 | SetAxis/W=VCALC#FrontView left -axisRange,axisRange |
---|
181 | SetAxis/W=VCALC#FrontView bottom -axisRange,axisRange |
---|
182 | |
---|
183 | |
---|
184 | SetDataFolder root: |
---|
185 | |
---|
186 | return(0) |
---|
187 | End |
---|