1 | #pragma rtGlobals=3 // Use modern global access method and strict wave access. |
---|
2 | |
---|
3 | // |
---|
4 | // The full version of the preferences panel resides in PlotUtilsMacro_v40.ipf |
---|
5 | // and is common to SANS/USANS reduction and Analysis routines. |
---|
6 | // |
---|
7 | // This version has been specifically pulled out to remove the entanglement. |
---|
8 | // |
---|
9 | // SANSPreferences.ipf file is unused (in SANS folder of SVN) |
---|
10 | // |
---|
11 | // DEC 2015 |
---|
12 | // |
---|
13 | |
---|
14 | |
---|
15 | /// TODO |
---|
16 | // -- update all to be only VSANS-specific |
---|
17 | // -- update all of the function names to be unique to VSANS so that there are no |
---|
18 | // name clashes with the "duplicate" version that is in PlotUtils.ipf |
---|
19 | // |
---|
20 | // |
---|
21 | // global variables used by VSANS are stored in: |
---|
22 | // root:Packages:NIST:VSANS:Globals |
---|
23 | // |
---|
24 | |
---|
25 | |
---|
26 | /////////////////////////// |
---|
27 | Proc Show_VSANSPreferences_Panel() |
---|
28 | |
---|
29 | DoWindow/F VSANSPref_Panel |
---|
30 | if(V_flag==0) |
---|
31 | // only re-initialize if the variables don't exist, so you don't overwrite what users have changed |
---|
32 | if( exists("root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault") != 2 ) //if the global variable does not exist, initialize |
---|
33 | Initialize_VSANSPreferences() |
---|
34 | endif |
---|
35 | VSANSPref_Panel() |
---|
36 | Endif |
---|
37 | // Print "Preferences Panel stub" |
---|
38 | End |
---|
39 | |
---|
40 | Proc Initialize_VSANSPreferences() |
---|
41 | // create the globals here if they are not already present |
---|
42 | |
---|
43 | // each package initialization should call this to repeat the initialization |
---|
44 | // without overwriting what was already set |
---|
45 | |
---|
46 | Variable val |
---|
47 | |
---|
48 | ///// items for VSANS reduction |
---|
49 | val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault", 1 ) |
---|
50 | Variable/G root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault=val |
---|
51 | |
---|
52 | val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gAllowDRK", 0 ) |
---|
53 | Variable/G root:Packages:NIST:VSANS:Globals:gAllowDRK=val //don't show DRK as default |
---|
54 | |
---|
55 | val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoTransCheck", 1 ) |
---|
56 | Variable/G root:Packages:NIST:VSANS:Globals:gDoTransCheck=val |
---|
57 | |
---|
58 | val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gBinWidth", 1 ) |
---|
59 | Variable/G root:Packages:NIST:VSANS:Globals:gBinWidth=val |
---|
60 | |
---|
61 | val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gNPhiSteps", 72 ) |
---|
62 | Variable/G root:Packages:NIST:VSANS:Globals:gNPhiSteps=val |
---|
63 | |
---|
64 | // flags to turn detector corrections on/off for testing (you should leave these ON) |
---|
65 | val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoDetectorEffCorr", 1 ) |
---|
66 | Variable/G root:Packages:NIST:VSANS:Globals:gDoDetectorEffCorr = 1 |
---|
67 | |
---|
68 | val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoTransmissionCorr", 1 ) |
---|
69 | Variable/G root:Packages:NIST:VSANS:Globals:gDoTransmissionCorr = 1 |
---|
70 | |
---|
71 | // flag to allow adding raw data files with different attenuation (normally not done) |
---|
72 | val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten",0) |
---|
73 | Variable/G root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten=val |
---|
74 | |
---|
75 | /// items for SANS Analysis |
---|
76 | |
---|
77 | |
---|
78 | /// items for USANS Reduction |
---|
79 | |
---|
80 | |
---|
81 | /// items for everyone |
---|
82 | val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gXML_Write", 0 ) |
---|
83 | Variable/G root:Packages:NIST:VSANS:Globals:gXML_Write = val |
---|
84 | |
---|
85 | |
---|
86 | end |
---|
87 | |
---|
88 | Function LogScalePrefCheck(ctrlName,checked) : CheckBoxControl |
---|
89 | String ctrlName |
---|
90 | Variable checked |
---|
91 | |
---|
92 | NVAR gLog = root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault |
---|
93 | glog=checked |
---|
94 | //print "log pref checked = ",checked |
---|
95 | End |
---|
96 | |
---|
97 | Function DRKProtocolPref(ctrlName,checked) : CheckBoxControl |
---|
98 | String ctrlName |
---|
99 | Variable checked |
---|
100 | |
---|
101 | NVAR gDRK = root:Packages:NIST:VSANS:Globals:gAllowDRK |
---|
102 | gDRK = checked |
---|
103 | //Print "DRK preference = ",checked |
---|
104 | End |
---|
105 | |
---|
106 | Function UnityTransPref(ctrlName,checked) : CheckBoxControl |
---|
107 | String ctrlName |
---|
108 | Variable checked |
---|
109 | |
---|
110 | NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTransCheck |
---|
111 | gVal = checked |
---|
112 | End |
---|
113 | |
---|
114 | Function XMLWritePref(ctrlName,checked) : CheckBoxControl |
---|
115 | String ctrlName |
---|
116 | Variable checked |
---|
117 | |
---|
118 | NVAR gVal = root:Packages:NIST:VSANS:Globals:gXML_Write |
---|
119 | gVal = checked |
---|
120 | End |
---|
121 | |
---|
122 | Function DoTransCorrPref(ctrlName,checked) : CheckBoxControl |
---|
123 | String ctrlName |
---|
124 | Variable checked |
---|
125 | |
---|
126 | NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTransmissionCorr |
---|
127 | gVal = checked |
---|
128 | End |
---|
129 | |
---|
130 | Function DoEfficiencyCorrPref(ctrlName,checked) : CheckBoxControl |
---|
131 | String ctrlName |
---|
132 | Variable checked |
---|
133 | |
---|
134 | NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDetectorEffCorr |
---|
135 | gVal = checked |
---|
136 | End |
---|
137 | |
---|
138 | Function DoRawAttenAdjPref(ctrlName,checked) : CheckBoxControl |
---|
139 | String ctrlName |
---|
140 | Variable checked |
---|
141 | |
---|
142 | NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten |
---|
143 | gVal = checked |
---|
144 | End |
---|
145 | |
---|
146 | Function PrefDoneButtonProc(ctrlName) : ButtonControl |
---|
147 | String ctrlName |
---|
148 | |
---|
149 | DoWindow/K VSANSPref_Panel |
---|
150 | End |
---|
151 | |
---|
152 | Proc VSANSPref_Panel() |
---|
153 | PauseUpdate; Silent 1 // building window... |
---|
154 | NewPanel /W=(646,208,1070,468)/K=2 as "NCNR Preference Panel" |
---|
155 | DoWindow/C VSANSPref_Panel |
---|
156 | ModifyPanel cbRGB=(49694,61514,27679) |
---|
157 | SetDrawLayer UserBack |
---|
158 | ModifyPanel fixedSize=1 |
---|
159 | ////// |
---|
160 | //on main portion of panel, always visible |
---|
161 | Button PrefPanelButtonA,pos={354,12},size={50,20},proc=PrefDoneButtonProc,title="Done" |
---|
162 | |
---|
163 | TabControl PrefTab,pos={7,49},size={410,202},tabLabel(0)="General",proc=PrefTabProc |
---|
164 | TabControl PrefTab,tabLabel(1)="VSANS",tabLabel(2)="USANS",tabLabel(3)="Analysis" |
---|
165 | TabControl PrefTab,value=0 |
---|
166 | TabControl PrefTab labelBack=(49694,61514,27679) |
---|
167 | |
---|
168 | //on tab(0) - General - initially visible |
---|
169 | CheckBox PrefCtrl_0a,pos={21,96},size={124,14},proc=XMLWritePref,title="Use canSAS XML Output" |
---|
170 | CheckBox PrefCtrl_0a,help={"Checking this will set the default output format to be canSAS XML rather than NIST 6 column"} |
---|
171 | CheckBox PrefCtrl_0a,value= root:Packages:NIST:VSANS:Globals:gXML_Write |
---|
172 | |
---|
173 | //on tab(1) - SANS |
---|
174 | CheckBox PrefCtrl_1a,pos={21,100},size={171,14},proc=LogScalePrefCheck,title="Use Log scaling for 2D data display" |
---|
175 | CheckBox PrefCtrl_1a,help={"Checking this will display 2D VSANS data with a logarithmic color scale of neutron counts. If not checked, the color mapping will be linear."} |
---|
176 | CheckBox PrefCtrl_1a,value= root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault |
---|
177 | CheckBox PrefCtrl_1b,pos={21,120},size={163,14},proc=DRKProtocolPref,title="Allow DRK correction in protocols" |
---|
178 | CheckBox PrefCtrl_1b,help={"Checking this will allow DRK correction to be used in reduction protocols. You will need to re-draw the protocol panel for this change to be visible."} |
---|
179 | CheckBox PrefCtrl_1b,value= root:Packages:NIST:VSANS:Globals:gAllowDRK |
---|
180 | CheckBox PrefCtrl_1c,pos={21,140},size={137,14},proc=UnityTransPref,title="Check for Transmission = 1" |
---|
181 | CheckBox PrefCtrl_1c,help={"Checking this will check for SAM or EMP Trans = 1 during data correction"} |
---|
182 | CheckBox PrefCtrl_1c,value= root:Packages:NIST:VSANS:Globals:gDoTransCheck |
---|
183 | SetVariable PrefCtrl_1d,pos={21,170},size={200,15},title="Averaging Bin Width (pixels)" |
---|
184 | SetVariable PrefCtrl_1d,limits={1,100,1},value= root:Packages:NIST:VSANS:Globals:gBinWidth |
---|
185 | SetVariable PrefCtrl_1e,pos={21,195},size={200,15},title="# Phi Steps (annular avg)" |
---|
186 | SetVariable PrefCtrl_1e,limits={1,360,1},value= root:Packages:NIST:VSANS:Globals:gNPhiSteps |
---|
187 | CheckBox PrefCtrl_1f title="Do Transmssion Correction?",size={140,14},value=root:Packages:NIST:VSANS:Globals:gDoTransmissionCorr,proc=DoTransCorrPref |
---|
188 | CheckBox PrefCtrl_1f pos={255,100},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent transmssion."} |
---|
189 | CheckBox PrefCtrl_1g title="Do Efficiency Correction?",size={140,14},proc=DoEfficiencyCorrPref |
---|
190 | CheckBox PrefCtrl_1g value=root:Packages:NIST:VSANS:Globals:gDoDetectorEffCorr,pos={255,120},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent detector efficiency."} |
---|
191 | CheckBox PrefCtrl_1h title="Adjust RAW attenuation?",size={140,14},proc=DoRawAttenAdjPref |
---|
192 | CheckBox PrefCtrl_1h value=root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten,pos={255,140},help={"This is normally not done"} |
---|
193 | |
---|
194 | CheckBox PrefCtrl_1a,disable=1 |
---|
195 | CheckBox PrefCtrl_1b,disable=1 |
---|
196 | CheckBox PrefCtrl_1c,disable=1 |
---|
197 | SetVariable PrefCtrl_1d,disable=1 |
---|
198 | SetVariable PrefCtrl_1e,disable=1 |
---|
199 | CheckBox PrefCtrl_1f,disable=1 |
---|
200 | CheckBox PrefCtrl_1g,disable=1 |
---|
201 | CheckBox PrefCtrl_1h,disable=1 |
---|
202 | |
---|
203 | //on tab(2) - USANS |
---|
204 | GroupBox PrefCtrl_2a pos={21,100},size={1,1},title="nothing to set",fSize=12 |
---|
205 | |
---|
206 | GroupBox PrefCtrl_2a,disable=1 |
---|
207 | |
---|
208 | |
---|
209 | //on tab(3) - Analysis |
---|
210 | GroupBox PrefCtrl_3a pos={21,100},size={1,1},title="nothing to set",fSize=12 |
---|
211 | |
---|
212 | GroupBox PrefCtrl_3a,disable=1 |
---|
213 | |
---|
214 | EndMacro |
---|
215 | |
---|
216 | // function to control the drawing of controls in the TabControl on the main panel |
---|
217 | // Naming scheme for the controls MUST be strictly adhered to... else controls will |
---|
218 | // appear in odd places... |
---|
219 | // all controls are named PrefCtrl_NA where N is the tab number and A is the letter denoting |
---|
220 | // the controls position on that particular tab. |
---|
221 | // in this way, they will always be drawn correctly.. |
---|
222 | // |
---|
223 | Function PrefTabProc(name,tab) |
---|
224 | String name |
---|
225 | Variable tab |
---|
226 | |
---|
227 | // Print "name,number",name,tab |
---|
228 | String ctrlList = ControlNameList("",";"),item="",nameStr="" |
---|
229 | Variable num = ItemsinList(ctrlList,";"),ii,onTab |
---|
230 | for(ii=0;ii<num;ii+=1) |
---|
231 | //items all start w/"PrefCtrl_", 9 characters |
---|
232 | item=StringFromList(ii, ctrlList ,";") |
---|
233 | nameStr=item[0,8] |
---|
234 | if(cmpstr(nameStr,"PrefCtrl_")==0) |
---|
235 | onTab = str2num(item[9]) //[9] is a number |
---|
236 | ControlInfo $item |
---|
237 | switch(abs(V_flag)) |
---|
238 | case 1: |
---|
239 | Button $item,disable=(tab!=onTab) |
---|
240 | break |
---|
241 | case 2: |
---|
242 | CheckBox $item,disable=(tab!=onTab) |
---|
243 | break |
---|
244 | case 5: |
---|
245 | SetVariable $item,disable=(tab!=onTab) |
---|
246 | break |
---|
247 | case 10: |
---|
248 | TitleBox $item,disable=(tab!=onTab) |
---|
249 | break |
---|
250 | case 4: |
---|
251 | ValDisplay $item,disable=(tab!=onTab) |
---|
252 | break |
---|
253 | case 9: |
---|
254 | GroupBox $item,disable=(tab!=onTab) |
---|
255 | break |
---|
256 | // add more items to the switch if different control types are used |
---|
257 | endswitch |
---|
258 | endif |
---|
259 | endfor |
---|
260 | return(0) |
---|
261 | End |
---|