source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_VSANS_Preferences.ipf @ 1249

Last change on this file since 1249 was 1249, checked in by srkline, 2 years ago

minor changes - can't find the diff command in TortoiseSVN...

File size: 16.9 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2#pragma IgorVersion = 7.00
3
4
5///
6// x- update all to be only VSANS-specific
7// x- update all of the function names to be unique to VSANS so that there are no
8//    name clashes with the "duplicate" version that is in PlotUtils.ipf
9//
10// x- Make this a VSANS-only panel
11// x- eliminate the USANS tab
12// x- be sure the general tab is either unique, or eliminate it
13// x- be sure the Analysis tab is unique, or eliminate it
14//
15//
16// global variables used by VSANS are stored in:
17// root:Packages:NIST:VSANS:Globals
18//
19
20
21///////////////////////////
22Proc Show_VSANSPreferences_Panel()
23
24        DoWindow/F VSANSPref_Panel
25        if(V_flag==0)
26                // only re-initialize if the variables don't exist, so you don't overwrite what users have changed
27                if( exists("root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault") != 2 )              //if the global variable does not exist, initialize
28                        Initialize_VSANSPreferences()
29                endif
30                // these variables were recently created, so they may not exist if someone
31                // opens an old experiment -- then errors will result
32                if(exists("root:Packages:NIST:VSANS:Globals:gDoDownstreamWindowCor") != 2)
33                        V_InitializeWindowTrans()               //set up the globals (need to check in multiple places)
34                endif
35               
36                VSANSPref_Panel()
37        Endif
38//      Print "Preferences Panel stub"
39End
40
41
42//  x- there are more detector specific corrections here that need to be added
43//
44// create the globals here if they are not already present
45// each package initialization should call this to repeat the initialization
46// without overwriting what was already set
47Proc Initialize_VSANSPreferences()
48       
49        Variable val
50
51        // GENERAL tab
52        /// General items for everyone
53        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gXML_Write", 0 )
54        Variable/G root:Packages:NIST:VSANS:Globals:gXML_Write = val
55
56        // flag to set "Laptop Mode" where the panels are drawn smaller and onscreen
57        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gLaptopMode", 0 )
58        Variable/G root:Packages:NIST:VSANS:Globals:gLaptopMode = val   
59       
60        // VSANS tab
61        ///// items for VSANS reduction
62        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault", 1 )
63        Variable/G root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault=val
64       
65//      val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gAllowDRK", 0 )
66//      Variable/G root:Packages:NIST:VSANS:Globals:gAllowDRK=val                       //don't show DRK as default
67       
68        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoTransCheck", 1 )
69        Variable/G root:Packages:NIST:VSANS:Globals:gDoTransCheck=val
70       
71        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gBinWidth", 1.2 )
72        Variable/G root:Packages:NIST:VSANS:Globals:gBinWidth=val
73       
74        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gNPhiSteps", 90 )
75        Variable/G root:Packages:NIST:VSANS:Globals:gNPhiSteps=val
76       
77        // flags to turn detector corrections on/off for testing (you should leave these ON)
78        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoDetectorEffCor", 1 )
79        Variable/G root:Packages:NIST:VSANS:Globals:gDoDetectorEffCor = 1
80       
81        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoTransmissionCor", 1 )
82        Variable/G root:Packages:NIST:VSANS:Globals:gDoTransmissionCor = 1
83
84        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoDIVCor", 1 )
85        Variable/G root:Packages:NIST:VSANS:Globals:gDoDIVCor = 1
86       
87        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor", 1 )
88        Variable/G root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor = 1
89
90        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor", 1 )
91        Variable/G root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor = 1
92
93        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoNonLinearCor", 1 )
94        Variable/G root:Packages:NIST:VSANS:Globals:gDoNonLinearCor = 1
95
96        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor", 1 )
97        Variable/G root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor = 1
98       
99        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoMonitorNormalization", 1 )
100        Variable/G root:Packages:NIST:VSANS:Globals:gDoMonitorNormalization = 1
101
102        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoDownstreamWindowCor", 1 )
103        Variable/G root:Packages:NIST:VSANS:Globals:gDoDownstreamWindowCor = 1
104        V_InitializeWindowTrans()               //set up the globals (need to check in multiple places)
105
106        // Special global to prevent fake data from "B" detector from being written out
107        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gIgnoreDetB", 1 )
108        Variable/G root:Packages:NIST:VSANS:Globals:gIgnoreDetB = 1
109
110// TODOHIGHRES
111// OCT 2018
112// new global to flag the highRes detector binning to accomodate the change in binning
113//  that was set 10/16/18 (changed from 4x4 bin to 1x1= no binning)
114// set this flag == 1 for 1x1
115// set flag 4 == 4x4
116        Variable/G root:Packages:NIST:VSANS:Globals:gHighResBinning = 4
117                       
118        DoAlert 1,"Are you using the back detector? (This can be changed later in the Preferences Panel)"
119        if(V_flag == 1)
120                // yes
121                Variable/G root:Packages:NIST:VSANS:Globals:gIgnoreDetB = 0
122//              DoAlert 1,"Are you using 1x1 binning?"
123//              if(V_flag == 1)
124//                      // yes
125//                      Variable/G root:Packages:NIST:VSANS:Globals:gHighResBinning = 1
126//              endif
127        endif
128
129
130// this is now a VSANS menu item rather than a question at startup
131//      DoAlert 1,"Do you want small panels? (this can be changed later in preferences)"
132//      if(V_flag == 1)
133//              // yes
134//              Variable/G root:Packages:NIST:VSANS:Globals:gLaptopMode = 1
135//      endif
136
137
138// flag to allow adding raw data files with different attenuation (normally not done)   
139//      val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten",0)
140//      Variable/G root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten=val
141       
142       
143        // VSANS ANALYSIS tab
144        /// items for VSANS Analysis
145       
146
147       
148       
149end
150
151Function V_InitializeWindowTrans()
152
153        Variable/G root:Packages:NIST:VSANS:Globals:gDoDownstreamWindowCor = 1
154
155        // TODO -- when correcting this, search for all occurences!!! also in V_WorkFolderUtils !!!
156        // these global values need to be replaced with real numbers
157        // error is currently set to zero
158        Variable/G root:Packages:NIST:VSANS:Globals:gDownstreamWinTrans = 1
159        Variable/G root:Packages:NIST:VSANS:Globals:gDownstreamWinTransErr = 0
160
161end
162
163Function V_LogScalePrefCheck(ctrlName,checked) : CheckBoxControl
164        String ctrlName
165        Variable checked
166       
167        NVAR gLog = root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault
168        glog=checked
169        //print "log pref checked = ",checked
170End
171
172//Function DRKProtocolPref(ctrlName,checked) : CheckBoxControl
173//      String ctrlName
174//      Variable checked
175//     
176//      NVAR gDRK = root:Packages:NIST:VSANS:Globals:gAllowDRK
177//      gDRK = checked
178//      //Print "DRK preference = ",checked
179//End
180
181Function V_UnityTransPref(ctrlName,checked) : CheckBoxControl
182        String ctrlName
183        Variable checked
184       
185        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTransCheck
186        gVal = checked
187End
188
189Function V_XMLWritePref(ctrlName,checked) : CheckBoxControl
190        String ctrlName
191        Variable checked
192       
193        NVAR gVal = root:Packages:NIST:VSANS:Globals:gXML_Write
194        gVal = checked
195End
196
197Function V_DoTransCorrPref(ctrlName,checked) : CheckBoxControl
198        String ctrlName
199        Variable checked
200       
201        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTransmissionCor
202        gVal = checked
203End
204
205// this is efficiency + shadowing
206Function V_DoEfficiencyCorrPref(ctrlName,checked) : CheckBoxControl
207        String ctrlName
208        Variable checked
209       
210        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor
211        gVal = checked
212End
213
214Function V_DoRawAttenAdjPref(ctrlName,checked) : CheckBoxControl
215        String ctrlName
216        Variable checked
217       
218        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten
219        gVal = checked
220End
221
222Function V_DoDIVCorPref(ctrlName,checked) : CheckBoxControl
223        String ctrlName
224        Variable checked
225       
226        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDIVCor
227        gVal = checked
228End
229
230Function V_DoDeadTimeCorPref(ctrlName,checked) : CheckBoxControl
231        String ctrlName
232        Variable checked
233       
234        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor
235        gVal = checked
236End
237
238Function V_DoSolidAngleCorPref(ctrlName,checked) : CheckBoxControl
239        String ctrlName
240        Variable checked
241       
242        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor
243        gVal = checked
244End
245
246Function V_DoNonLinearCorPref(ctrlName,checked) : CheckBoxControl
247        String ctrlName
248        Variable checked
249       
250        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoNonLinearCor
251        gVal = checked
252End
253
254// not needed-- efficiency and shadowing are done together
255//Function V_DoTubeShadowCorPref(ctrlName,checked) : CheckBoxControl
256//      String ctrlName
257//      Variable checked
258//     
259//      NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor
260//      gVal = checked
261//End
262
263Function V_DoMonitorNormPref(ctrlName,checked) : CheckBoxControl
264        String ctrlName
265        Variable checked
266       
267        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoMonitorNormalization
268        gVal = checked
269End
270
271Function V_DoDownstreamWindowCorPref(ctrlName,checked) : CheckBoxControl
272        String ctrlName
273        Variable checked
274       
275        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDownstreamWindowCor
276        gVal = checked
277End
278
279
280Function V_IgnoreDetBPref(ctrlName,checked) : CheckBoxControl
281        String ctrlName
282        Variable checked
283       
284        NVAR gVal = root:Packages:NIST:VSANS:Globals:gIgnoreDetB
285        gVal = checked
286End
287
288Function V_LaptopModePref(ctrlName,checked) : CheckBoxControl
289        String ctrlName
290        Variable checked
291       
292        NVAR gVal = root:Packages:NIST:VSANS:Globals:gLaptopMode
293        gVal = checked
294End
295
296
297Proc V_SetLaptopMode()
298
299        root:Packages:NIST:VSANS:Globals:gLaptopMode = 1       
300       
301        DoWindow/K Main_VSANS_Panel
302        Initialize_VSANS()
303        DoAlert 0,"Laptop Mode is ON, go to VSANS preferences to turn mode off"
304       
305End
306
307
308Function V_PrefDoneButtonProc(ctrlName) : ButtonControl
309        String ctrlName
310       
311        DoWindow/K VSANSPref_Panel
312End
313
314
315Proc VSANSPref_Panel()
316        Variable sc=1
317       
318        if(root:Packages:NIST:VSANS:Globals:gLaptopMode == 1)
319                sc = 0.9
320        endif
321
322        PauseUpdate; Silent 1           // building window...
323        NewPanel /W=(646*sc,208*sc,1070*sc,468*sc)/K=2 as "VSANS Preference Panel"
324        DoWindow/C VSANSPref_Panel
325        ModifyPanel cbRGB=(47748,57192,54093)
326        SetDrawLayer UserBack
327        ModifyPanel fixedSize=1
328//////
329//on main portion of panel, always visible
330        Button PrefPanelButtonA,pos={354*sc,12*sc},size={50*sc,20*sc},proc=V_PrefDoneButtonProc,title="Done"
331
332        TabControl PrefTab,pos={7*sc,49*sc},size={410*sc,202*sc},tabLabel(0)="General",proc=V_PrefTabProc
333        TabControl PrefTab,tabLabel(1)="VSANS",tabLabel(2)="Analysis"
334        TabControl PrefTab,value=1
335        TabControl PrefTab labelBack=(47748,57192,54093)
336       
337//on tab(0) - General
338        CheckBox PrefCtrl_0a,pos={21*sc,96*sc},size={124*sc,14*sc},proc=V_XMLWritePref,title="Use canSAS XML Output"
339        CheckBox PrefCtrl_0a,help={"Checking this will set the default output format to be canSAS XML rather than NIST 6 column"}
340        CheckBox PrefCtrl_0a,value= root:Packages:NIST:VSANS:Globals:gXML_Write
341        CheckBox PrefCtrl_0b,pos={21*sc,120*sc},size={124*sc,14*sc},proc=V_LaptopModePref,title="Laptop Mode for Panels"
342        CheckBox PrefCtrl_0b,help={"Checking this will draw panels smaller to fit on a 1920x1080 laptop screen"}
343        CheckBox PrefCtrl_0b,value= root:Packages:NIST:VSANS:Globals:gLaptopMode
344
345        CheckBox PrefCtrl_0a,disable=1
346        CheckBox PrefCtrl_0b,disable=1
347
348
349//on tab(1) - VSANS - initially visible
350        CheckBox PrefCtrl_1a,pos={21*sc,80*sc},size={171*sc,14*sc},proc=V_LogScalePrefCheck,title="Use Log scaling for 2D data display"
351        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."}
352        CheckBox PrefCtrl_1a,value= root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault
353//      CheckBox PrefCtrl_1b,pos={21,120},size={163,14},proc=V_DRKProtocolPref,title="Allow DRK correction in protocols"
354//      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."}
355//      CheckBox PrefCtrl_1b,value= root:Packages:NIST:VSANS:Globals:gAllowDRK
356        CheckBox PrefCtrl_1c,pos={21*sc,100*sc},size={137*sc,14*sc},proc=V_UnityTransPref,title="Check for Transmission = 1"
357        CheckBox PrefCtrl_1c,help={"Checking this will check for SAM or EMP Trans = 1 during data correction"}
358        CheckBox PrefCtrl_1c,value= root:Packages:NIST:VSANS:Globals:gDoTransCheck
359        SetVariable PrefCtrl_1d,pos={21*sc,130*sc},size={200*sc,15*sc},title="Averaging Bin Width (pixels)"
360        SetVariable PrefCtrl_1d,limits={1,100,1},value= root:Packages:NIST:VSANS:Globals:gBinWidth
361        SetVariable PrefCtrl_1e,pos={21*sc,155*sc},size={200*sc,15*sc},title="# Phi Steps (annular avg)"
362        SetVariable PrefCtrl_1e,limits={1,360,1},value= root:Packages:NIST:VSANS:Globals:gNPhiSteps
363        SetVariable PrefCtrl_1p,pos={21*sc,180*sc},size={200*sc,15*sc},title="Window Transmission"
364        SetVariable PrefCtrl_1p,limits={0.01,1,0.001},value= root:Packages:NIST:VSANS:Globals:gDownstreamWinTrans
365
366       
367        CheckBox PrefCtrl_1f title="Do Transmssion Correction?",size={140*sc,14*sc},value=root:Packages:NIST:VSANS:Globals:gDoTransmissionCor,proc=V_DoTransCorrPref
368        CheckBox PrefCtrl_1f pos={255*sc,80*sc},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent transmssion."}
369        CheckBox PrefCtrl_1g title="Do Tube Efficiency+Shadowing?",size={140*sc,14*sc},proc=V_DoEfficiencyCorrPref
370        CheckBox PrefCtrl_1g value=root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor,pos={255*sc,100*sc},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent detector efficiency."}
371//      CheckBox PrefCtrl_1h title="Adjust RAW attenuation?",size={140,14},proc=V_DoRawAttenAdjPref
372//      CheckBox PrefCtrl_1h value=root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten,pos={255,140},help={"This is normally not done"}
373
374        CheckBox PrefCtrl_1i title="Do DIV Correction?",size={140*sc,14*sc},proc=V_DoDIVCorPref
375        CheckBox PrefCtrl_1i value=root:Packages:NIST:VSANS:Globals:gDoDIVCor,pos={255*sc,120*sc},help={"TURN OFF ONLY FOR DEBUGGING."}
376        CheckBox PrefCtrl_1j title="Do DeadTime Correction?",size={140*sc,14*sc},proc=V_DoDeadTimeCorPref
377        CheckBox PrefCtrl_1j value=root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor,pos={255*sc,140*sc},help={"TURN OFF ONLY FOR DEBUGGING."}   
378        CheckBox PrefCtrl_1k title="Do Solid Angle Correction?",size={140*sc,14*sc},proc=V_DoSolidAngleCorPref
379        CheckBox PrefCtrl_1k value=root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor,pos={255*sc,160*sc},help={"TURN OFF ONLY FOR DEBUGGING."}
380        CheckBox PrefCtrl_1l title="Do Non-linear Correction?",size={140*sc,14*sc},proc=V_DoNonLinearCorPref,disable=2
381        CheckBox PrefCtrl_1l value=root:Packages:NIST:VSANS:Globals:gDoNonLinearCor,pos={255*sc,180*sc},help={"Non-linear correction can't be turned off"}
382        CheckBox PrefCtrl_1m title="Do Downstream Window Corr?",size={140*sc,14*sc},proc=V_DoDownstreamWindowCorPref
383        CheckBox PrefCtrl_1m value=root:Packages:NIST:VSANS:Globals:gDoDownstreamWindowCor,pos={255*sc,200*sc},help={"TURN OFF ONLY FOR DEBUGGING."}
384//      CheckBox PrefCtrl_1n title="Do Monitor Normalization?",size={140,14},proc=V_DoMonitorNormPref
385//      CheckBox PrefCtrl_1n value=root:Packages:NIST:VSANS:Globals:gDoMonitorNormalization,pos={255,220},help={"TURN OFF ONLY FOR DEBUGGING."}
386        CheckBox PrefCtrl_1o title="Ignore Back Detector?",size={140*sc,14*sc},proc=V_IgnoreDetBPref
387        CheckBox PrefCtrl_1o value=root:Packages:NIST:VSANS:Globals:gIgnoreDetB,pos={150*sc,220*sc},help={"Will prevent data from Back detector being written to data files."}         
388       
389//      CheckBox PrefCtrl_1a,disable=1
390//      CheckBox PrefCtrl_1b,disable=1
391//      CheckBox PrefCtrl_1c,disable=1
392//      SetVariable PrefCtrl_1d,disable=1
393//      SetVariable PrefCtrl_1e,disable=1
394//      CheckBox PrefCtrl_1f,disable=1
395//      CheckBox PrefCtrl_1g,disable=1
396//      CheckBox PrefCtrl_1h,disable=1
397//      CheckBox PrefCtrl_1g,value=0,disable=2          // angle dependent efficiency not done yet
398//      CheckBox PrefCtrl_1m,value=0,disable=2          // downstream window transmission no done yet
399
400//on tab(2) - Analysis
401        GroupBox PrefCtrl_2a pos={21*sc,100*sc},size={1,1},title="nothing to set",fSize=12
402       
403        GroupBox PrefCtrl_2a,disable=1
404End
405
406// function to control the drawing of controls in the TabControl on the main panel
407// Naming scheme for the controls MUST be strictly adhered to... else controls will
408// appear in odd places...
409// all controls are named PrefCtrl_NA where N is the tab number and A is the letter denoting
410// the controls position on that particular tab.
411// in this way, they will always be drawn correctly..
412//
413Function V_PrefTabProc(name,tab)
414        String name
415        Variable tab
416       
417//      Print "name,number",name,tab
418        String ctrlList = ControlNameList("",";"),item="",nameStr=""
419        Variable num = ItemsinList(ctrlList,";"),ii,onTab
420        for(ii=0;ii<num;ii+=1)
421                //items all start w/"PrefCtrl_", 9 characters
422                item=StringFromList(ii, ctrlList ,";")
423                nameStr=item[0,8]
424                if(cmpstr(nameStr,"PrefCtrl_")==0)
425                        onTab = str2num(item[9])                        //[9] is a number
426                        ControlInfo $item
427                        switch(abs(V_flag))     
428                                case 1:
429                                        Button $item,disable=(tab!=onTab)
430                                        break
431                                case 2:
432                                        CheckBox $item,disable=(tab!=onTab)
433                                        break
434                                case 5:
435                                        SetVariable $item,disable=(tab!=onTab)
436                                        break
437                                case 10:       
438                                        TitleBox $item,disable=(tab!=onTab)
439                                        break
440                                case 4:
441                                        ValDisplay $item,disable=(tab!=onTab)
442                                        break
443                                case 9:
444                                        GroupBox $item,disable=(tab!=onTab)
445                                        break
446                                // add more items to the switch if different control types are used
447                        endswitch
448                endif
449        endfor
450        return(0)
451End
Note: See TracBrowser for help on using the repository browser.