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