source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_FrontView_Deg.ipf @ 1154

Last change on this file since 1154 was 1081, checked in by srkline, 5 years ago

additions to VCALC procedures to correctly account for panel motion (individual, not symmetric). Updated the plotting routines to all (mostly) pass through the same subroutines so that additional averaging modes will be easier to add.

File size: 6.5 KB
Line 
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
18Function 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_L_sep,F_R_sep,F_T_sep, F_B_sep,F_SDD
39        Variable M_L_sep,M_R_sep,M_T_sep, M_B_sep, M_SDD
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_L_sep = V_Value
52        ControlInfo/W=VCALC VCALCCtrl_2aa
53        F_R_sep = V_Value
54        ControlInfo/W=VCALC VCALCCtrl_2b
55        F_T_sep = V_Value
56        ControlInfo/W=VCALC VCALCCtrl_2bb
57        F_B_sep = V_Value
58
59        ControlInfo/W=VCALC VCALCCtrl_2d
60        F_SDD = V_Value
61                               
62        //middle
63        ControlInfo/W=VCALC VCALCCtrl_3a
64        M_L_sep = V_Value
65        ControlInfo/W=VCALC VCALCCtrl_3aa
66        M_R_sep = V_Value
67        ControlInfo/W=VCALC VCALCCtrl_3b
68        M_T_sep = V_Value
69        ControlInfo/W=VCALC VCALCCtrl_3bb
70        M_B_sep = V_Value
71       
72        ControlInfo/W=VCALC VCALCCtrl_3d
73        M_SDD = V_Value
74       
75        //back                 
76        ControlInfo/W=VCALC VCALCCtrl_4a
77        B_offset = V_Value     
78        ControlInfo/W=VCALC VCALCCtrl_4b
79        B_SDD = V_Value
80       
81        // axis range
82        ControlInfo/W=VCALC setVar_a   
83        axisRange = V_Value
84
85        Make/O/D/N=2 fv_degX,fv_degY           
86        fv_degX[0] = -axisRange
87        fv_degX[1] = axisRange
88        fv_degY[0] = -axisRange
89        fv_degY[1] = axisRange
90                       
91// green        fillfgc= (1,52428,26586)
92// black        fillfgc= (0,0,0)
93// yellow fillfgc= (65535,65535,0)
94// blue         fillfgc= (1,16019,65535)
95// red  fillfgc= (65535,0,0)
96// light blue fillfgc= (1,52428,52428)
97// light brown fillfgc= (39321,26208,1)
98
99        //clear the old drawing (this wipes out everything in the layer)
100        DrawAction/L=UserBack/W=VCALC#FrontView delete
101
102        //start drawing from the back, and work to the front as would be visible
103        // ********* all of the dimensions are in cm
104        Variable tmp_x1,tmp_x2,tmp_y1,tmp_y2
105       
106        // back detector +/- degrees
107        tmp_x1 = -atan(B_w/2/(B_SDD)) *(180/pi)
108        tmp_x2 = -tmp_x1
109        tmp_y1 = -atan(B_h/2/(B_SDD)) *(180/pi)
110        tmp_y2 = -tmp_y1
111       
112        //DrawRect [/W=winName ] left, top, right, bottom
113        SetDrawLayer/W=VCALC#FrontView UserBack
114        SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (1,52428,52428)
115        DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1                  //only one panel in back
116
117//
118// MIDDLE 4 panels (T-B then L-R)
119// TO DO -- add in the additional offset (backwards) to the SDD of the T/B panels
120// TOP
121        tmp_x1 = -atan(M_TB_w/2/(M_SDD+middle_SDDsetback))*(180/pi)             // x symmetric y is not
122        tmp_x2 = -tmp_x1
123        tmp_y1 = atan(M_T_sep/(M_SDD+middle_SDDsetback))*(180/pi)
124        tmp_y2 = atan((M_T_sep+M_TB_h)/(M_SDD+middle_SDDsetback))*(180/pi)
125       
126//      Print tmp_x1,tmp_x2,tmp_y1,tmp_y2
127       
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// BOTTOM (x unchanged, negate and swap y1,y2)
132        tmp_y1 = atan((M_B_sep-M_TB_h)/(M_SDD+middle_SDDsetback))*(180/pi)
133        tmp_y2 = atan(M_B_sep/(M_SDD+middle_SDDsetback))*(180/pi)
134        SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (1,16019,65535)
135        DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1         
136       
137// LEFT
138        tmp_x1 = atan((M_L_sep-M_LR_w)/(M_SDD))*(180/pi)                // y symmetric x is not
139        tmp_x2 = atan((M_L_sep)/(M_SDD))*(180/pi)
140        tmp_y1 = atan(M_LR_h/2/(M_SDD))*(180/pi)
141        tmp_y2 = -tmp_y1
142        SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (65535,0,0)
143        DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1                 
144// RIGHT (x changes, y the same)
145        tmp_x1 = atan((M_R_sep)/(M_SDD))*(180/pi)               // y symmetric x is not
146        tmp_x2 = atan((M_LR_w+M_R_sep)/(M_SDD))*(180/pi)
147        SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (65535,0,0)
148        DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1 
149
150//      Print tmp_x1,tmp_x2,tmp_y1,tmp_y2
151       
152////////
153// FRONT 4 panels (T-B then L-R)
154// TO DO -- add in the additional offset (backwards) to the SDD of the T/B panels
155// TOP
156        tmp_x1 = -atan(F_TB_w/2/(F_SDD+front_SDDsetback))*(180/pi)              // x symmetric y is not
157        tmp_x2 = -tmp_x1
158        tmp_y1 = atan(F_T_sep/(F_SDD+front_SDDsetback))*(180/pi)
159        tmp_y2 = atan((F_T_sep+F_TB_h)/(F_SDD+front_SDDsetback))*(180/pi)
160       
161//      Print tmp_x1,tmp_x2,tmp_y1,tmp_y2
162       
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// BOTTOM (x unchanged, negate and swap y1,y2)
167        tmp_y1 = atan((F_B_sep-F_TB_h)/(F_SDD+front_SDDsetback))*(180/pi)
168        tmp_y2 = atan(F_B_sep/(F_SDD+front_SDDsetback))*(180/pi)
169        SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (1,52428,26586)
170        DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1         
171       
172// LEFT
173        tmp_x1 = atan((F_L_sep-F_LR_w)/(F_SDD))*(180/pi)                // y symmetric x is not
174        tmp_x2 = atan((F_L_sep)/(F_SDD))*(180/pi)
175        tmp_y1 = atan(F_LR_h/2/(F_SDD))*(180/pi)
176        tmp_y2 = -tmp_y1
177        SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (39321,26208,1)
178        DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1                 
179// RIGHT (x changes, y the same)
180        tmp_x1 = atan((F_R_sep)/(F_SDD))*(180/pi)               // y symmetric x is not
181        tmp_x2 = atan((F_LR_w+F_R_sep)/(F_SDD))*(180/pi)
182        SetDrawEnv/W=VCALC#FrontView xcoord= bottom,ycoord= left,fillfgc= (39321,26208,1)
183        DrawRect/W=VCALC#FrontView tmp_x1,tmp_y2,tmp_x2,tmp_y1 
184       
185       
186        SetAxis/W=VCALC#FrontView left -axisRange,axisRange
187        SetAxis/W=VCALC#FrontView bottom -axisRange,axisRange
188
189
190        SetDataFolder root:
191               
192        return(0)
193End
Note: See TracBrowser for help on using the repository browser.