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

Last change on this file since 1246 was 1246, checked in by srkline, 3 years ago

A large number of changes to the size of panels to enable "Laptop Mode" where all of the panels and controls are scaled down so that they fit on screen and are still in correct proportion. For the laptop I'm using for testing, the resolution is 1920x1080. For this, a scaling of 0.7 seems to work. The on/off of the "laptop Mode" is controlled by a checkbox in the preference panel (under the General tab).

There are still more panels to update in the next commit.

File size: 16.6 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        DoAlert 1,"Do you want small panels? (this can be changed later in preferences)"
131        if(V_flag == 1)
132                // yes
133                Variable/G root:Packages:NIST:VSANS:Globals:gLaptopMode = 1
134        endif
135// flag to allow adding raw data files with different attenuation (normally not done)   
136//      val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten",0)
137//      Variable/G root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten=val
138       
139       
140        // VSANS ANALYSIS tab
141        /// items for VSANS Analysis
142       
143
144       
145       
146end
147
148Function V_InitializeWindowTrans()
149
150        Variable/G root:Packages:NIST:VSANS:Globals:gDoDownstreamWindowCor = 1
151
152        // TODO -- when correcting this, search for all occurences!!! also in V_WorkFolderUtils !!!
153        // these global values need to be replaced with real numbers
154        // error is currently set to zero
155        Variable/G root:Packages:NIST:VSANS:Globals:gDownstreamWinTrans = 1
156        Variable/G root:Packages:NIST:VSANS:Globals:gDownstreamWinTransErr = 0
157
158end
159
160Function V_LogScalePrefCheck(ctrlName,checked) : CheckBoxControl
161        String ctrlName
162        Variable checked
163       
164        NVAR gLog = root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault
165        glog=checked
166        //print "log pref checked = ",checked
167End
168
169//Function DRKProtocolPref(ctrlName,checked) : CheckBoxControl
170//      String ctrlName
171//      Variable checked
172//     
173//      NVAR gDRK = root:Packages:NIST:VSANS:Globals:gAllowDRK
174//      gDRK = checked
175//      //Print "DRK preference = ",checked
176//End
177
178Function V_UnityTransPref(ctrlName,checked) : CheckBoxControl
179        String ctrlName
180        Variable checked
181       
182        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTransCheck
183        gVal = checked
184End
185
186Function V_XMLWritePref(ctrlName,checked) : CheckBoxControl
187        String ctrlName
188        Variable checked
189       
190        NVAR gVal = root:Packages:NIST:VSANS:Globals:gXML_Write
191        gVal = checked
192End
193
194Function V_DoTransCorrPref(ctrlName,checked) : CheckBoxControl
195        String ctrlName
196        Variable checked
197       
198        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTransmissionCor
199        gVal = checked
200End
201
202// this is efficiency + shadowing
203Function V_DoEfficiencyCorrPref(ctrlName,checked) : CheckBoxControl
204        String ctrlName
205        Variable checked
206       
207        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor
208        gVal = checked
209End
210
211Function V_DoRawAttenAdjPref(ctrlName,checked) : CheckBoxControl
212        String ctrlName
213        Variable checked
214       
215        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten
216        gVal = checked
217End
218
219Function V_DoDIVCorPref(ctrlName,checked) : CheckBoxControl
220        String ctrlName
221        Variable checked
222       
223        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDIVCor
224        gVal = checked
225End
226
227Function V_DoDeadTimeCorPref(ctrlName,checked) : CheckBoxControl
228        String ctrlName
229        Variable checked
230       
231        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor
232        gVal = checked
233End
234
235Function V_DoSolidAngleCorPref(ctrlName,checked) : CheckBoxControl
236        String ctrlName
237        Variable checked
238       
239        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor
240        gVal = checked
241End
242
243Function V_DoNonLinearCorPref(ctrlName,checked) : CheckBoxControl
244        String ctrlName
245        Variable checked
246       
247        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoNonLinearCor
248        gVal = checked
249End
250
251// not needed-- efficiency and shadowing are done together
252//Function V_DoTubeShadowCorPref(ctrlName,checked) : CheckBoxControl
253//      String ctrlName
254//      Variable checked
255//     
256//      NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor
257//      gVal = checked
258//End
259
260Function V_DoMonitorNormPref(ctrlName,checked) : CheckBoxControl
261        String ctrlName
262        Variable checked
263       
264        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoMonitorNormalization
265        gVal = checked
266End
267
268Function V_DoDownstreamWindowCorPref(ctrlName,checked) : CheckBoxControl
269        String ctrlName
270        Variable checked
271       
272        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDownstreamWindowCor
273        gVal = checked
274End
275
276
277Function V_IgnoreDetBPref(ctrlName,checked) : CheckBoxControl
278        String ctrlName
279        Variable checked
280       
281        NVAR gVal = root:Packages:NIST:VSANS:Globals:gIgnoreDetB
282        gVal = checked
283End
284
285Function V_LaptopModePref(ctrlName,checked) : CheckBoxControl
286        String ctrlName
287        Variable checked
288       
289        NVAR gVal = root:Packages:NIST:VSANS:Globals:gLaptopMode
290        gVal = checked
291End
292
293
294
295
296Function V_PrefDoneButtonProc(ctrlName) : ButtonControl
297        String ctrlName
298       
299        DoWindow/K VSANSPref_Panel
300End
301
302
303Proc VSANSPref_Panel()
304        Variable sc=1
305       
306        if(root:Packages:NIST:VSANS:Globals:gLaptopMode == 1)
307                sc = 0.7
308        endif
309
310        PauseUpdate; Silent 1           // building window...
311        NewPanel /W=(646*sc,208*sc,1070*sc,468*sc)/K=2 as "VSANS Preference Panel"
312        DoWindow/C VSANSPref_Panel
313        ModifyPanel cbRGB=(47748,57192,54093)
314        SetDrawLayer UserBack
315        ModifyPanel fixedSize=1
316//////
317//on main portion of panel, always visible
318        Button PrefPanelButtonA,pos={354*sc,12*sc},size={50*sc,20*sc},proc=V_PrefDoneButtonProc,title="Done"
319
320        TabControl PrefTab,pos={7*sc,49*sc},size={410*sc,202*sc},tabLabel(0)="General",proc=V_PrefTabProc
321        TabControl PrefTab,tabLabel(1)="VSANS",tabLabel(2)="Analysis"
322        TabControl PrefTab,value=1
323        TabControl PrefTab labelBack=(47748,57192,54093)
324       
325//on tab(0) - General
326        CheckBox PrefCtrl_0a,pos={21*sc,96*sc},size={124*sc,14*sc},proc=V_XMLWritePref,title="Use canSAS XML Output"
327        CheckBox PrefCtrl_0a,help={"Checking this will set the default output format to be canSAS XML rather than NIST 6 column"}
328        CheckBox PrefCtrl_0a,value= root:Packages:NIST:VSANS:Globals:gXML_Write
329        CheckBox PrefCtrl_0b,pos={21*sc,120*sc},size={124*sc,14*sc},proc=V_LaptopModePref,title="Laptop Mode for Panels"
330        CheckBox PrefCtrl_0b,help={"Checking this will draw panels smaller to fit on a 1920x1080 laptop screen"}
331        CheckBox PrefCtrl_0b,value= root:Packages:NIST:VSANS:Globals:gLaptopMode
332
333        CheckBox PrefCtrl_0a,disable=1
334        CheckBox PrefCtrl_0b,disable=1
335
336
337//on tab(1) - VSANS - initially visible
338        CheckBox PrefCtrl_1a,pos={21*sc,80*sc},size={171*sc,14*sc},proc=V_LogScalePrefCheck,title="Use Log scaling for 2D data display"
339        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."}
340        CheckBox PrefCtrl_1a,value= root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault
341//      CheckBox PrefCtrl_1b,pos={21,120},size={163,14},proc=V_DRKProtocolPref,title="Allow DRK correction in protocols"
342//      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."}
343//      CheckBox PrefCtrl_1b,value= root:Packages:NIST:VSANS:Globals:gAllowDRK
344        CheckBox PrefCtrl_1c,pos={21*sc,100*sc},size={137*sc,14*sc},proc=V_UnityTransPref,title="Check for Transmission = 1"
345        CheckBox PrefCtrl_1c,help={"Checking this will check for SAM or EMP Trans = 1 during data correction"}
346        CheckBox PrefCtrl_1c,value= root:Packages:NIST:VSANS:Globals:gDoTransCheck
347        SetVariable PrefCtrl_1d,pos={21*sc,130*sc},size={200*sc,15*sc},title="Averaging Bin Width (pixels)"
348        SetVariable PrefCtrl_1d,limits={1,100,1},value= root:Packages:NIST:VSANS:Globals:gBinWidth
349        SetVariable PrefCtrl_1e,pos={21*sc,155*sc},size={200*sc,15*sc},title="# Phi Steps (annular avg)"
350        SetVariable PrefCtrl_1e,limits={1,360,1},value= root:Packages:NIST:VSANS:Globals:gNPhiSteps
351        SetVariable PrefCtrl_1p,pos={21*sc,180*sc},size={200*sc,15*sc},title="Window Transmission"
352        SetVariable PrefCtrl_1p,limits={0.01,1,0.001},value= root:Packages:NIST:VSANS:Globals:gDownstreamWinTrans
353
354       
355        CheckBox PrefCtrl_1f title="Do Transmssion Correction?",size={140*sc,14*sc},value=root:Packages:NIST:VSANS:Globals:gDoTransmissionCor,proc=V_DoTransCorrPref
356        CheckBox PrefCtrl_1f pos={255*sc,80*sc},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent transmssion."}
357        CheckBox PrefCtrl_1g title="Do Tube Efficiency+Shadowing?",size={140*sc,14*sc},proc=V_DoEfficiencyCorrPref
358        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."}
359//      CheckBox PrefCtrl_1h title="Adjust RAW attenuation?",size={140,14},proc=V_DoRawAttenAdjPref
360//      CheckBox PrefCtrl_1h value=root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten,pos={255,140},help={"This is normally not done"}
361
362        CheckBox PrefCtrl_1i title="Do DIV Correction?",size={140*sc,14*sc},proc=V_DoDIVCorPref
363        CheckBox PrefCtrl_1i value=root:Packages:NIST:VSANS:Globals:gDoDIVCor,pos={255*sc,120*sc},help={"TURN OFF ONLY FOR DEBUGGING."}
364        CheckBox PrefCtrl_1j title="Do DeadTime Correction?",size={140*sc,14*sc},proc=V_DoDeadTimeCorPref
365        CheckBox PrefCtrl_1j value=root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor,pos={255*sc,140*sc},help={"TURN OFF ONLY FOR DEBUGGING."}   
366        CheckBox PrefCtrl_1k title="Do Solid Angle Correction?",size={140*sc,14*sc},proc=V_DoSolidAngleCorPref
367        CheckBox PrefCtrl_1k value=root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor,pos={255*sc,160*sc},help={"TURN OFF ONLY FOR DEBUGGING."}
368        CheckBox PrefCtrl_1l title="Do Non-linear Correction?",size={140*sc,14*sc},proc=V_DoNonLinearCorPref,disable=2
369        CheckBox PrefCtrl_1l value=root:Packages:NIST:VSANS:Globals:gDoNonLinearCor,pos={255*sc,180*sc},help={"Non-linear correction can't be turned off"}
370        CheckBox PrefCtrl_1m title="Do Downstream Window Corr?",size={140*sc,14*sc},proc=V_DoDownstreamWindowCorPref
371        CheckBox PrefCtrl_1m value=root:Packages:NIST:VSANS:Globals:gDoDownstreamWindowCor,pos={255*sc,200*sc},help={"TURN OFF ONLY FOR DEBUGGING."}
372//      CheckBox PrefCtrl_1n title="Do Monitor Normalization?",size={140,14},proc=V_DoMonitorNormPref
373//      CheckBox PrefCtrl_1n value=root:Packages:NIST:VSANS:Globals:gDoMonitorNormalization,pos={255,220},help={"TURN OFF ONLY FOR DEBUGGING."}
374        CheckBox PrefCtrl_1o title="Ignore Back Detector?",size={140*sc,14*sc},proc=V_IgnoreDetBPref
375        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."}         
376       
377//      CheckBox PrefCtrl_1a,disable=1
378//      CheckBox PrefCtrl_1b,disable=1
379//      CheckBox PrefCtrl_1c,disable=1
380//      SetVariable PrefCtrl_1d,disable=1
381//      SetVariable PrefCtrl_1e,disable=1
382//      CheckBox PrefCtrl_1f,disable=1
383//      CheckBox PrefCtrl_1g,disable=1
384//      CheckBox PrefCtrl_1h,disable=1
385//      CheckBox PrefCtrl_1g,value=0,disable=2          // angle dependent efficiency not done yet
386//      CheckBox PrefCtrl_1m,value=0,disable=2          // downstream window transmission no done yet
387
388//on tab(2) - Analysis
389        GroupBox PrefCtrl_2a pos={21*sc,100*sc},size={1,1},title="nothing to set",fSize=12
390       
391        GroupBox PrefCtrl_2a,disable=1
392End
393
394// function to control the drawing of controls in the TabControl on the main panel
395// Naming scheme for the controls MUST be strictly adhered to... else controls will
396// appear in odd places...
397// all controls are named PrefCtrl_NA where N is the tab number and A is the letter denoting
398// the controls position on that particular tab.
399// in this way, they will always be drawn correctly..
400//
401Function V_PrefTabProc(name,tab)
402        String name
403        Variable tab
404       
405//      Print "name,number",name,tab
406        String ctrlList = ControlNameList("",";"),item="",nameStr=""
407        Variable num = ItemsinList(ctrlList,";"),ii,onTab
408        for(ii=0;ii<num;ii+=1)
409                //items all start w/"PrefCtrl_", 9 characters
410                item=StringFromList(ii, ctrlList ,";")
411                nameStr=item[0,8]
412                if(cmpstr(nameStr,"PrefCtrl_")==0)
413                        onTab = str2num(item[9])                        //[9] is a number
414                        ControlInfo $item
415                        switch(abs(V_flag))     
416                                case 1:
417                                        Button $item,disable=(tab!=onTab)
418                                        break
419                                case 2:
420                                        CheckBox $item,disable=(tab!=onTab)
421                                        break
422                                case 5:
423                                        SetVariable $item,disable=(tab!=onTab)
424                                        break
425                                case 10:       
426                                        TitleBox $item,disable=(tab!=onTab)
427                                        break
428                                case 4:
429                                        ValDisplay $item,disable=(tab!=onTab)
430                                        break
431                                case 9:
432                                        GroupBox $item,disable=(tab!=onTab)
433                                        break
434                                // add more items to the switch if different control types are used
435                        endswitch
436                endif
437        endfor
438        return(0)
439End
Note: See TracBrowser for help on using the repository browser.