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