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

Last change on this file since 973 was 973, checked in by srkline, 6 years ago

minor changes

File size: 9.3 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2
3
4/// TODO
5// -- update all to be only VSANS-specific
6// -- update all of the function names to be unique to VSANS so that there are no
7//    name clashes with the "duplicate" version that is in PlotUtils.ipf
8//
9// -- Make this a VSANS-only panel
10// -- eliminate the USANS tab
11// -- be sure the general tab is either unique, or eliminate it
12// -- be sure the Analysis tab is unique, or eliminate it
13//
14//
15// global variables used by VSANS are stored in:
16// root:Packages:NIST:VSANS:Globals
17//
18
19
20///////////////////////////
21Proc Show_VSANSPreferences_Panel()
22
23        DoWindow/F VSANSPref_Panel
24        if(V_flag==0)
25                // only re-initialize if the variables don't exist, so you don't overwrite what users have changed
26                if( exists("root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault") != 2 )              //if the global variable does not exist, initialize
27                        Initialize_VSANSPreferences()
28                endif
29                VSANSPref_Panel()
30        Endif
31//      Print "Preferences Panel stub"
32End
33
34
35// TODO -- there are more detector specific corrections here that need to be added
36//
37// create the globals here if they are not already present
38// each package initialization should call this to repeat the initialization
39// without overwriting what was already set
40Proc Initialize_VSANSPreferences()
41       
42        Variable val
43
44        // GENERAL tab
45        /// General items for everyone
46        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gXML_Write", 0 )
47        Variable/G root:Packages:NIST:VSANS:Globals:gXML_Write = val
48       
49       
50        // VSANS tab
51        ///// items for VSANS reduction
52        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault", 1 )
53        Variable/G root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault=val
54       
55//      val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gAllowDRK", 0 )
56//      Variable/G root:Packages:NIST:VSANS:Globals:gAllowDRK=val                       //don't show DRK as default
57       
58        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoTransCheck", 1 )
59        Variable/G root:Packages:NIST:VSANS:Globals:gDoTransCheck=val
60       
61        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gBinWidth", 1 )
62        Variable/G root:Packages:NIST:VSANS:Globals:gBinWidth=val
63       
64        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gNPhiSteps", 72 )
65        Variable/G root:Packages:NIST:VSANS:Globals:gNPhiSteps=val
66       
67        // flags to turn detector corrections on/off for testing (you should leave these ON)
68        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoDetectorEffCorr", 1 )
69        Variable/G root:Packages:NIST:VSANS:Globals:gDoDetectorEffCorr = 1
70       
71        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoTransmissionCorr", 1 )
72        Variable/G root:Packages:NIST:VSANS:Globals:gDoTransmissionCorr = 1
73
74// flag to allow adding raw data files with different attenuation (normally not done)   
75//      val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten",0)
76//      Variable/G root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten=val
77       
78       
79        // VSANS ANALYSIS tab
80        /// items for VSANS Analysis
81       
82       
83end
84
85Function V_LogScalePrefCheck(ctrlName,checked) : CheckBoxControl
86        String ctrlName
87        Variable checked
88       
89        NVAR gLog = root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault
90        glog=checked
91        //print "log pref checked = ",checked
92End
93
94//Function DRKProtocolPref(ctrlName,checked) : CheckBoxControl
95//      String ctrlName
96//      Variable checked
97//     
98//      NVAR gDRK = root:Packages:NIST:VSANS:Globals:gAllowDRK
99//      gDRK = checked
100//      //Print "DRK preference = ",checked
101//End
102
103Function V_UnityTransPref(ctrlName,checked) : CheckBoxControl
104        String ctrlName
105        Variable checked
106       
107        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTransCheck
108        gVal = checked
109End
110
111Function V_XMLWritePref(ctrlName,checked) : CheckBoxControl
112        String ctrlName
113        Variable checked
114       
115        NVAR gVal = root:Packages:NIST:VSANS:Globals:gXML_Write
116        gVal = checked
117End
118
119Function V_DoTransCorrPref(ctrlName,checked) : CheckBoxControl
120        String ctrlName
121        Variable checked
122       
123        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTransmissionCorr
124        gVal = checked
125End
126
127Function V_DoEfficiencyCorrPref(ctrlName,checked) : CheckBoxControl
128        String ctrlName
129        Variable checked
130       
131        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDetectorEffCorr
132        gVal = checked
133End
134
135Function V_DoRawAttenAdjPref(ctrlName,checked) : CheckBoxControl
136        String ctrlName
137        Variable checked
138       
139        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten
140        gVal = checked
141End
142
143Function V_PrefDoneButtonProc(ctrlName) : ButtonControl
144        String ctrlName
145       
146        DoWindow/K VSANSPref_Panel
147End
148
149Proc VSANSPref_Panel()
150        PauseUpdate; Silent 1           // building window...
151        NewPanel /W=(646,208,1070,468)/K=2 as "VSANS Preference Panel"
152        DoWindow/C VSANSPref_Panel
153        ModifyPanel cbRGB=(49694,61514,27679)
154        SetDrawLayer UserBack
155        ModifyPanel fixedSize=1
156//////
157//on main portion of panel, always visible
158        Button PrefPanelButtonA,pos={354,12},size={50,20},proc=V_PrefDoneButtonProc,title="Done"
159
160        TabControl PrefTab,pos={7,49},size={410,202},tabLabel(0)="General",proc=V_PrefTabProc
161        TabControl PrefTab,tabLabel(1)="VSANS",tabLabel(2)="Analysis"
162        TabControl PrefTab,value=1
163        TabControl PrefTab labelBack=(49694,61514,27679)
164       
165//on tab(0) - General
166        CheckBox PrefCtrl_0a,pos={21,96},size={124,14},proc=V_XMLWritePref,title="Use canSAS XML Output"
167        CheckBox PrefCtrl_0a,help={"Checking this will set the default output format to be canSAS XML rather than NIST 6 column"}
168        CheckBox PrefCtrl_0a,value= root:Packages:NIST:VSANS:Globals:gXML_Write
169
170        CheckBox PrefCtrl_0a,disable=1
171
172
173//on tab(1) - VSANS - initially visible
174        CheckBox PrefCtrl_1a,pos={21,100},size={171,14},proc=V_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=V_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=V_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=V_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=V_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=V_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) - Analysis
204        GroupBox PrefCtrl_2a pos={21,100},size={1,1},title="nothing to set",fSize=12
205       
206        GroupBox PrefCtrl_2a,disable=1
207
208End
209
210// function to control the drawing of controls in the TabControl on the main panel
211// Naming scheme for the controls MUST be strictly adhered to... else controls will
212// appear in odd places...
213// all controls are named PrefCtrl_NA where N is the tab number and A is the letter denoting
214// the controls position on that particular tab.
215// in this way, they will always be drawn correctly..
216//
217Function V_PrefTabProc(name,tab)
218        String name
219        Variable tab
220       
221//      Print "name,number",name,tab
222        String ctrlList = ControlNameList("",";"),item="",nameStr=""
223        Variable num = ItemsinList(ctrlList,";"),ii,onTab
224        for(ii=0;ii<num;ii+=1)
225                //items all start w/"PrefCtrl_", 9 characters
226                item=StringFromList(ii, ctrlList ,";")
227                nameStr=item[0,8]
228                if(cmpstr(nameStr,"PrefCtrl_")==0)
229                        onTab = str2num(item[9])                        //[9] is a number
230                        ControlInfo $item
231                        switch(abs(V_flag))     
232                                case 1:
233                                        Button $item,disable=(tab!=onTab)
234                                        break
235                                case 2:
236                                        CheckBox $item,disable=(tab!=onTab)
237                                        break
238                                case 5:
239                                        SetVariable $item,disable=(tab!=onTab)
240                                        break
241                                case 10:       
242                                        TitleBox $item,disable=(tab!=onTab)
243                                        break
244                                case 4:
245                                        ValDisplay $item,disable=(tab!=onTab)
246                                        break
247                                case 9:
248                                        GroupBox $item,disable=(tab!=onTab)
249                                        break
250                                // add more items to the switch if different control types are used
251                        endswitch
252                endif
253        endfor
254        return(0)
255End
Note: See TracBrowser for help on using the repository browser.